A Monte Carlo Casino Game

I wrote here about my solution to this week's Riddler.  I wanted to expand a bit on the method, and present some simulation results.

First, let's think about what we actually did.  The problem tells us that we're drawing random numbers from the interval [0,1] until their sum exceeds 1.  This is basically the same as asking us to keep rolling an n-sided die, with sides numbered from 1 to n, until their sum exceeds n itself.  I showed the steps we'd use to solve for n = 5, generalized for any n, and then showed that as n goes to infinity, this sum approaches the mathematical constant e.

This week's puzzle specifically requested that we solve it by hand, which I did:

But I couldn't resist running a simulation to check my work.  So here's a bit of Python where I did so, running 100,000 trials of the dice-rolling variant of the casino game for every value of n from 1 to 99:

And here's the result:

For a 1-sided die, you would obviously always need exactly 2 rolls to exceed a sum of 1 so the expected (gross) winnings are $200.  For a 2-sided die, 1/4 of the time you'd roll two consecutive 1s and have to roll a third time; otherwise you'll be done in exactly 2 rolls, so the expected winnings are $225.  As you can see, the expected number of rolls quickly approaches the analytical solution of $100e \approx $271.83 we came up with.

 

Leave a Reply