Nov 17, 2014 - *tap tap*... is this thing working?


Yay! I’ve got myself jekyll’d up and am githubified. I wish I’d got my noggin around git a little earlier - it would have helped the progress of the PhD modelling no end (thesis and models available here; explanation of the PhD’s origins here. I’ll be adding more more user-friendly chunks of code and blog from the thesis).

As well as discovering how git makes my life easier when coding/writing (I have branches for the code behind every figure, yay!), I’m having a go at using github to bring everything together and make it visible in one place. Whether in or out of academia (currently out!), I’m hoping it’ll be a good way to interact with others on the projects I want to pursue.

Visualisation has been at the heart of a lot of my coding through the PhD and beyond. It was partly through visualising and interacting with my agents in the PhD model that I learned to understand its dynamics, in a way that led directly to more robust mathematical insights. I also discovered that visualisations I found useful as a modeller didn’t necessarily translate into good figures for communicating to others. Quite the opposite, in fact.

I discovered this the hard way: all the thesis figures needed re-doing post-viva. The paper-friendly outputs I now have are both interactive and much better on the printed page. (For a start, I spent a lot of time making decent black-and-white outputs, to avoid the ‘these look good in colour if you look at the online version’ problem). Most importantly, I’ve got a better handle on how to achieve these different visualisation aims.

That whole process led me to ponder the nature of visualisation: here’s a post of mine on the topic, where I wonder about the difference between a box-plot and an x-ray. I think my own original PhD visualisations were closer to x-rays than boxplots: images that I’d learned to interpret through intense interaction and feedback over a long time. Good for my understanding - utterly, hopelessly useless for communicating with others.

It was fascinating to see the same process at work recently in Christopher Nolan’s Interstellar: physicist Kip Thorne gained new insights into the workings of black holes when Nolan’s FX team used his maths to create a visualisation. It produced some light effects that were initially thought to be a coding error. In fact, they’d done such a good job implementing Kip Thorne’s maths, it was showing something he’d not predicted - but emerged naturally from his work. He plans to get two papers off the back of the discovery.

‘Visualisation’ is a bit of a hideous word. The aim is to show - or to provide a path for someone’s mind to dig into the nature of something in a way they otherwise would struggle to. Bill Phillip’s MONIAC is a stupendous, pre-computer example of this. Tim Harford introduces his latest economics populariser with the machine - you can read most of this via Amazon’s ‘look inside’ option. (Harford also tells something of Phillips’ incredible life story; hear more about this, and see the machine in action, in this Cambridge University video, using a MONIAC machine restored by Allan McRobie). In Harford’s telling of the tale, the amused derision of other economists, faced with this pipe-and-water contraption, quickly turned to amazement on seeing the thing function. It’s easy to forget: prior to this machine, the economy as a system had never been `visible’. Some, perhaps, had mental models of superior power - but even then, I’d argue there’s nothing quite like the tactile experience of feedback to get under the skin of a model.

The MONIAC machine seems to have become a little more talked about since the crash. Harford uses it to set the stage for macro-economics. Diane Coyle, on the other hand (in GDP: a brief but affectionate history) uses MONIAC as an exemplar of the ‘engineering mindset’ - a physical manifestation of the “illusion of precise control” (p.21). Phillips apparently did later work on the possibility of actually damping economic oscillations - the pursuit of precise control was certainly on the minds of economists wanting to avoid another Great Depression. But this nicely illustrates how models polarise views about our ability to understand society, let alone steer it. (And as I mention here, the ‘engineering mindset’ Coyle identifies is, to some of an Austrian bent, a slippery slope to totalitarianism).

MONIAC’s users were aware of its limitations (as Newlyn said, “hydraulics is no substitute for economics”) - but there’s a question here, one that I haven’t answered for myself satisfactorily, about how people and society are shaped by the models they use. My favourite self-aware modeller, Paul Krugman is very clear in his views:

Whenever somebody claims to have a deeper understanding of economics (or actually anything) that transcends the insights of simple models, my reaction is that this is self-delusion. Any time you make any kind of causal statement about economics, you are at least implicitly using a model of how the economy works. And when you refuse to be explicit about that model, you almost always end up - whether you know it or not - de facto using models that are much more simplistic than the crossing curves or whatever your intellectual opponents are using. Think, in particular, of all the Austrians declaring that the economy is too complicated for any simple model - and then confidently declaring that the Fed’s monetary expansion would cause runaway inflation.

He goes on to show that didn’t happen. But he’s also well aware that models shape the way one views reality - and, as I always go on about, J.C. Scott is right to say that if the viewer has power, as governments do (or corporations, for that matter) - models shape their view of reality and then reality is shaped by their actions.

Which is all a rather long way from the piffling visualisation code I’ll be sticking up on the github page - but I hope I’ve made the point that how we use and understand models and visualisation is important. It’s only going to get more important too. Perhaps finance houses will soon have traders hooked up to oculus rifts doing the full neuromancer, linking with their AI systems centaur-fashion. Bloomberg are already producing mock-ups of the first basic step - giving them access to a huge array of virtual, leap-motion controlled terminals.

Back to the mundane matter of actually coding: pretty much everything I’ve done so far has been in Java (though I’m getting the hang of R and it’s really rather good!) with the visualisation working through the Processing libraries, building in Netbeans. I need to get out into the messier, noisier world of web development and javascript. Until relatively recently, it was still easy enough to showcase Java through applets on the web - this has become increasingly impossible. Java’s still got plenty of life in it, of course - but it’s not much use if you want to present via the web.

That’s deeply annoying. I can show a bunch of screenshots and ask people to download and run a jar. I used to just provide a link. Showcasing java visualisations, then, is now an official pain in the arse. I still plan to use it - for some of the things I’d like to do, its speed still wins. But for communicating? For some projects, maybe - but not on the web. Hopefully this blog will help me change that. Processing (the Java based graphics package I use a lot) does have an option for exporting as javascript (here’s an example of one of mine running in the browser) but I’m a long way from feeling as comfortable with web development generally as I do with Java.

Nowt wrong with being outside yer comfort zone, though, eh? So let’s see what happens…