Theory and practice make for an interesting relationship. The world would be beautiful if all theory came out true in reality. Of course, some things would be difficult to observe in reality. Can you imagine watching in real-time someone shooting a basketball 1,000 times? Or the number of red beetles that drive by? Just simulate it! Seemingly anything of numerical quality can be simulated; this includes basketball shots, options pricing, and the temperatures of the day. This is called a Monte Carlo simulation when a numerical algorithm is run based off repeated sampling of random numbers.
Now, imagine that you are an intern. As your boss, I give you a dice and tell you to keep rolling it until you hit the sequence 1, 2, 3, 4, 5, and 6 in that order. Keep a running total of throws and let me know how many it took. A theoretical value of throws can be calculated using martingales:
Let Ɵ equal the first the time the pattern appears. To simplify things, let’s assume that a gambler comes at the beginning of each day and bets $1 on 1. If he wins he gains $6 and comes back the next day and if he loses, he goes home bankrupt. Continuous gamblers come each day betting on the pattern in that order: 1, 2, 3, 4, 5, 6. Eventually, the Ɵ-5th gambler will win and the game will come to a close. The expected payout X can be calculated as:
Ɵ-1-(66-1) = Ɵ-66
Since E(Ɵ) <>
0 = E(X) = E(Ɵ)
E(Ɵ) = 66 = 46,656
If interested, Google the theorems, but the heuristics are not of concern. Just know that a theoretical value can be calculated and it is 46,656.
Through a quick calculation, it states that you need to roll the dice 46,656 times to pull in the desired sequence. Lucky you! Now, let’s run a Monte Carlo simulation to demonstrate real world numbers.
Running the MATLAB program produces a value of 46,858. This is a absolute error of 0.4%; pretty good. Personally, I have always been an applications person. I want to see things in reality, and always get a sense of accomplishment when numbers match up. When the numbers are horribly wrong, then obviously something is wrong with the theory. Fortunately, this is a case when theory and practice syncs together.
Well, intern, you have over 46,000 rolls left. Get cracking!