The fish-tank state-space model

One of the first things that drew my attention to combining math and art, and signaled to me that their combination might still be useful to both was teaching myself Action Script.  With little Flash programming experience, I had to fall back on models that I knew---methods for financial series, simulation, and state-space models, including forecasting and credit risk.  So while I was learning a new tool, I wondered whether there was any insight to be gained from making them beautiful, something you might see by visualizing the same data differently than before.

Now, as any school-child will tell you, a two-factor Brownian motion looks like this:

(Smart kid.)  Waving my hands a little bit, I can tell you that what that means is the balls' rates of moving left or right behave like particles suspended in a fluid, buffeted by numerous infinitesimal forces acting in uncoordinated directions.  But, as many of you guessed by email to me, or on the post on this over at Ribbonfarm, while this is a Brownian motion model, there's something "off" about it:

To put a name to it: the x and y rates of change have a random correlation with each other (ie, how fast the ball will go left or right is related to how fast it will go up or down) that is common across all balls, but it itself changes randomly over time.

Now, that's a lot of words.  Visually, you can intuit this in that it makes it look as if the fluid they're suspended in is facing irregular waves and changing currents.  You can see that they're "connected" somehow.  Another visual metaphor might be that they're light objects being held aloft by a fan blowing beneath them, but the fan's air output is unstable and sometimes changes.  Even if you don't know (or care to know) the formula, the visualization lets you see that relationship that you would miss simply looking at line graphs in a timeseries plot.

The other insight that this visualization gave me at least was a reminder about the meaning of correlation.  Any model (that isn't using copulas) uses Pearson's rho as a measure of linear, pair-wise correlation to express the relatedness between random variables.  Visually, what 'linear" and "pair-wise" mean is: start by concentrating on any two fish in the tank.  Now imagine a line drawn between them, a straight, solid bar that's holding them together.  They jitter together along that bar, shocked left/right and up/down by related amounts, just as wheels would on a common axis.  

Now the fun part---take one of those fish, and draw the bar to another.  This exercise is works for any two balls in the tank.  Simultaneously, every ball has that linear pair-wise relationship with every other.  And while, by looking, you can imagine that axis relating the motions of any two balls together, the system as a whole looks chaotic.  Your brain can't "see" more than about 3 of these axes, but does intuit that there is a relationship, or fundamental set of rules making these fish move "together."

They're each tangoing perfectly together, perfectly in step, and yet the dance as a whole is indiscernible and superficially chaotic.

And this, I think, is the best insight of all: every art has rules just like math does.  Symmetry is a rule.  Palette is a rule.  And while these rules are difficult to describe concisely and perhaps often beyond easy mathematical representation, you are able to see and appreciate the structure even without them.  And that's why I want to encourage mathematicians and analysts to play a bit, and to keep your aesthetic sense because it isn't altogether a different thing than your mathematical sense.  For all their development, remember that Markov models, the workhorses of stochastic calculus, were invented to explore scansion and meter in reading Pushkin's Eugene Onegin.  

Don't be afraid to play by the rules and call it art.  Pushkin did.

Now, turning to the insights this might give us about more financially practical mathematical applications:

If you're considering total displacement of the Fish's path, this is not terribly dissimilar to two-factor credit contagion models or credit-based derivatives.  Namely, if you are a real stochastic calculus monster, questions you might wonder looking at this visualization are:

  1. What is the expected number of balls in the lower right quadrant at time t?
  2. In expectation, how many times will a particular ball cross the y axis drawn at the point of origin between t = 0, and time t?

Questions like these are visual equivalents of default risk and option pricing questions, and if you can answer them, you could be in the market for being in the market.

This was a demo, and a learning tool for me.  But I can watch it all day.  If anyone sees more that I missed, and is interested in developing this application into a analysis platform or pedagogical aid (which is always welcome because teaching probability is hard), please contact me.