Recently I’ve been working on some problems in disease modeling for influenza, and one of the problems is to calculate the basic reproduction number for a model which includes differential disease strengths in poor and rich risk groups. Calculating this number is generally done with a method called the “Next Generation Matrix” method, and to do this one needs to calculate two matrices of partial derivatives, invert one and multiply it by the other, then calculate the eigenvalues – the basic reproduction number is the largest eigenvalue of the resulting calculation. Doing this for just one risk group in the model I’m fiddling with can be done analytically in about 7 pages of notes – it involves finding the inverse of a 5×5 matrix, but actually this is quite quick to do by hand because most of the matrices involved are wide open spaces of zeros. However, once one extends the model to four risk groups the calculation becomes nastier – it involves inverting a 20×20 matrix, then finding the eigenvalues of a product of 20×20 matrix. Even recognizing that most of these matrices are zero elements, one still ends up with a fiendish hand calculation. On top of this, the matrices themselves contain many separate values all multiplied together. I started this by hand and decided today that I want to take a shortcut – a student needs to use some basic values from this soon and neither she nor I are going to get it done analytically before our deadline.
So tonight I came home and, after a nice dinner and an hour spent with my partner, I spent about an hour programming Matlab to do the calculation numerically for me. I now have the two values that my student needs, and if she needs to tweak her model it’s just a few presses of a button on my computer to get the updated reproduction number. Also, it’s a matter of a second’s work to test any other parameter in the model, and with a few loops I can produce charts of relationships between the reproduction number and any parameter. It’s nice and it was fairly trivial to program in Matlab. In this instance Matlab saved me a couple of days’ work fiddling around with some enormously tricky (though not mathematically challenging) hand calculations.
On this blog a short while back I investigated a weird probability distribution I had encountered at Grognardia. For that calculation, rather than going through the (eye-bleedingly horrible) tedium of attempting to generate a mathematical expression for the probability distributions I wanted to analyze, I simply ran a simulation in R with so many runs (about 100,000) that all random error was stripped out and I essentially got the exact shape of the theoretical underlying distribution I wanted.
In both cases, it’s pretty clear that I’m using a computer to do my thinking for me.
This is very different to using a computer to run an experiment based on the theory one developed painstakingly by hand. Rather, I’m using the brute number-crunching power of modern machines to simply get the theoretical result I’m looking for without doing the thinking. That Grognardia problem involved a badly programmed loop that executed a total of 4,500,000 dice results just to produce one chart. I did it on a computer with 32Gb of RAM and 12 chips, it took about 3 seconds – and I didn’t even have to program efficiently (I did it in R without using the vector nature of R, just straight looping like a 12 year old). The resulting charts are so close to the analytical probability distribution that it makes no difference whatsoever that they’re empirical – that hour of programming and the 3 seconds of processor time short circuited days and days of painstaking theoretical work to find the form of the probability distributions.
Obviously if I want to publish any of these things I need to do the hard work, so on balance I think that these numerical short cuts are a good thing – they help me to work out the feasibility of a hard task, get values to use in empirical work while I continue with the analytic problems, and give a way to check my work. But on the flip side – and much as I hate to sound like a maths grognard or something – I do sometimes wonder if the sheer power of computers has got to the point where they genuinely do offer a brutal, empirical short cut to actual mathematical thinking. Why seek an elegant mathematical solution to a problem when you can just spend 10 minutes on a computer and get all the dynamics of your solution without having to worry about the hard stuff? For people like me, with a good enough education in maths and physics to know what we need to do, but not enough concerted experience in the hard yards to be able to do the complex nitty-gritty of the work, this may be a godsend. But from the broader perspective of the discipline, will it lead to an overall, population-wide loss of the analytical skills that make maths and physics so powerful? And if so, in the future will we see students at universities losing their deep insight into the discipline as the power of the computer gives them ways to short cut the hard task of learning and applying the theory?
Maybe those 12 chips, 32Gb of RAM, 27 inch screen and 1Gb graphics card are a mixed blessing …
June 14, 2012 at 11:17 am
That computer sounds awesome.
You should play Dwarf Fortress with a massive starting area on it then post boasts about the FPS onto the .
In other news, can you build a monte carlo [1] analysis model of Exalted dice rolls for me? I’d like something where different combat strategies are used against each other with different Charm picks randomly used. Then the best set of Charms and abilities should rise to the top with the fewest simulated user deaths.
[1] Is this brute force approach called monte carlo analysis in the circles you move in? It is in the financial and estimation work I’ve seen it suggested for.
June 14, 2012 at 11:21 am
Opps, “onto the .” should be “onto the Dawrf Fortress message boards.” (fairly obviously).
June 14, 2012 at 12:48 pm
The computer is definitely made of awesome. I still occasionally have to leave it on overnight for certain tasks though, and the next best machine (8 cores, 16Gb RAM) is running hot at the moment as various students set multi-level models running for days at a time. I guess I could unleash it on Dwarf Fortress but sadly no amount of processor power will cover up for a complete lack of rudimentary skills. Can program, can’t shoot. Though there’s the point: I am only a poor programmer at best, but with this beast under my control I don’t need to worry about efficiency or any of that malarky – I just set the monster to work, and the results are done before I can complain. But in comparison to my FPS skills, my programming would be classed as “legendary.”
I have been meaning to do an analysis of Exalted rolls, because they are a nice combination of die pool and exploding dice. Working exploding dice in is quite easy with a proper Monte Carlo process, so it could be fun. I considered writing something to do Pathfinder battle tests, too, but there are too many decision points to make it easy. If I used a very simple set of decision rules – i.e. set a list of priorities and use the abilities immediately on commencement of battle in accordance with the priorities – then it would be doable. Otherwise you will just have to wait for someone to design an Exalted-based computer RPG (wouldn’t that be great!) I also want to do WFRP3 dice, but they’re also tricky – most of the methods I’ve seen used for WFRP3 dice are based on approximations.
What I do here isn’t quite Monte Carlo – the matrix inversion is a straight out calculation (like calculating 1/120000, but fiddlier); probability distributions don’t contain quite enough steps to be a Monte Carlo simulation. If I used them in a battle, that would be a Monte Carlo analysis. So you used the term correctly. Monte Carlo analysis doesn’t supplant theory, so much as apply it. The matrix inversion example, though, is a straight-out case of me using a computer to avoid having to do fiddly calculations of formulae that I graph; instead of doing that, I just go straight to the graphing. So the computer has removed my need to do the theoretical calculation part.
June 14, 2012 at 2:22 pm
On Dwarf Fortress: Its not a shooty First Person Shooter, it’s a neckbeardy world simulation game based on controlling a population of alcoholic dwarves as they dig a mine, Delve Too Deep And Too Greedy and then are all slain by invading goblins. The graphics are terrible unless you use various graphics packs (which upgrade it them to bad).
In this scenario it’s noteworthy for the fact that it tracks minutiae such as the teeth in every dwarf and invading goblins head (all the better to work out how many have been knocked out). This attention to trivia tends to make it grind even top of the line gaming PCs into the dust, leaving to Frames Per Second falling.
For a combat analysis (both Exalted and Pathfinder), do you really need a strategy decision tree? Couldn’t you just have say 100 combat options then have the computer randomly pick one each turn? As long as the program tracks the series of decisions then you should see that “Attack, Attack, Defend” is more likely to win than both “Strip Naked” and “Attack, Strip Naked”. Basically, even the strategic choice becomes a part of the analysis instead of being part of the framework.
June 14, 2012 at 4:28 pm
I reckon my computer would have that for breakfast. I don’t know why I’d want to … Yes, a random decision-making Monte Carlo model would work better in some ways. Maybe I’ll try it!
June 15, 2012 at 7:15 am
Why play Dwarf Fortress? Because its a simulation of life! A bunch of alcoholics form a community, drink together then burst into random rages and madness as life assails them. It can only end in death and tears!
It should be mandatory for everyone to play it until they absorb the core lessons.
July 9, 2012 at 8:08 am
What about Rolemaster? Exactly how deadly are those pesky rabbits?