Dice and Squares
“That’s going to be a quick one,” I thought. It did not turn out that way.
An email from friend and hero Rob Eastaway, asking if I can run a Monte Carlo simulation for him. The problem:
Imagine you’re playing a game like Snakes and Ladders but without snakes or ladders. Each move, you roll a six-sided die and move on that many squares. For each square, what’s the probability you land on it?
Of course I can! And I can check it against a couple of Rob’s observations:
- Because you can only land on square 1 by rolling a 1 on your first go, the probability of landing on 1 is
- In the long run, you move 3.5 squares each go, so the probability for high-numbered squares should be close to
.
So, I set up a simulation, ran it 10,000,000 times, and estimated the probability to 1dp as requested. Job done, right?
Well, it wouldn’t be worth writing up if I’d stopped there.
A Monte Carlo simulation? We can do better than that.
Rather than simulate it, we can calculate the probability for each square.
We can set up a recurrence relation:
In principle, you can solve that exactly for as many values of
But did I catch something out of the corner of my eye?
Hello, sensei.
My powers are fading.
Well, fading is your power. What have you got for us?
When you see a recurrence relation, you should think “generating function.”
Of course!
On your first throw, you’re at square 0 with probability 1, so we’ll get
I know better than to question.
Now, each time we throw the die, we multiply the existing probability distribution by
Oh yes – the coefficient of
Indeed. And so
So you have the probability distribution of where you will be after any number of throws – and you have to add them all up to get Rob’s distribution?
Correct! I shall – against all my principles – drop the
That’s a geometric sequence!
It is.
I can’t say that that looks pleasant.
It isn’t.
I would not put such a thing into Wolfram|Alpha. I have not seen any Wolfram|Alphas around here. Don’t ask me any more questions.