Updated my Lottery simulator
A while back I wrote a quick and dirty lottery simulator to check to see if, on the mega millions lottery would I make more money if I did the megaplier or if I bought two tickets. I was not too pleased with the results however (after 200 million draws on a 175 million to 1 shot I did not get any jackpots and only 4 pick 5's). So I backed up the source code and forgot about it.
Then I ran into this article on digg.com about better Random number generators. So I wrote up the MT algorithm from the article (copy and paste with a nextInt function added) and then I rewrote my simulation algorithm to better match reality (this is really what helped). I then did 20 million and then 350 million iterations (which in the real world would have taken 3,379,068 years!) and was impressed by the results. Picking two tickets each time I got four jackpots and the one ticket with megaplier got two jackpots (exactly what I was expecting).
So which is better? Well if you took out the jackpots (and the 20 million iteration test did not have any) then its better to megaply. But if your goal is to get the jackpot then its better to buy the two tickets. Now to keep things in perspective in the course of my virtual three million year existance I spent a whopping 700 million virtual dollars only to win 328 million. If I was to take the four dollars a week and put in in a bank account a 3% interest the amount would be obscene (it blew the buffer of a double which is somewhere around 2^1023 in just 35033 years).
Below are the numbers I came up with in the simulation. The first set is the odds for megamillions and the prizes assigned (I made the Jackpot 50 million dollars). The second set is for the extra ticket and the third set is for the megaplier
P.S. The total time it took to do these calculation on my laptop (350 million iterations of a java program) - 12 minutes. I love my laptop.
P.P.S I wonder how quickly a Cray could run it :)
Then I ran into this article on digg.com about better Random number generators. So I wrote up the MT algorithm from the article (copy and paste with a nextInt function added) and then I rewrote my simulation algorithm to better match reality (this is really what helped). I then did 20 million and then 350 million iterations (which in the real world would have taken 3,379,068 years!) and was impressed by the results. Picking two tickets each time I got four jackpots and the one ticket with megaplier got two jackpots (exactly what I was expecting).
So which is better? Well if you took out the jackpots (and the 20 million iteration test did not have any) then its better to megaply. But if your goal is to get the jackpot then its better to buy the two tickets. Now to keep things in perspective in the course of my virtual three million year existance I spent a whopping 700 million virtual dollars only to win 328 million. If I was to take the four dollars a week and put in in a bank account a 3% interest the amount would be obscene (it blew the buffer of a double which is somewhere around 2^1023 in just 35033 years
Below are the numbers I came up with in the simulation. The first set is the odds for megamillions and the prizes assigned (I made the Jackpot 50 million dollars). The second set is for the extra ticket and the third set is for the megaplier
Level | Matches | Prize | # to 1 odds | ||||
0 | Jackpot! | $50,000,000 | 175,711,536 | ||||
1 | 5 no PB | $250,000 | 3,904,701 | ||||
2 | 4 + PB | $10,000 | 689,065 | ||||
3 | 4 no PB | $150 | 15,313 | ||||
4 | 3 + PB | $150 | 13,781 | ||||
5 | 2 + PB | $10 | 844 | ||||
6 | 3 no PB | $7 | 306 | ||||
7 | 1 + PB | $3 | 141 | ||||
8 | PB | $2 | 75 | ||||
Extra Drawing | | |
0 | 4 | $200,000,000.00 |
1 | 200 | $50,000,000.00 |
2 | 803 | $8,030,000.00 |
3 | 46,139 | $6,920,850.00 |
4 | 41,973 | $6,295,950.00 |
5 | 684,333 | $6,843,330.00 |
6 | 2,303,089 | $16,121,623.00 |
7 | 4,105,529 | $12,316,587.00 |
8 | 7,720,275 | $15,440,550.00 |
Total | | $321,968,890.00 |
PowerBall | X2 | X3 | X4 | |
0 | 1 | 1 | 0 | $100,000,000.00 |
1 | 29 | 28 | 37 | $72,500,000.00 |
2 | 133 | 143 | 142 | $12,630,000.00 |
3 | 7,592 | 7,535 | 7,954 | $10,440,750.00 |
4 | 6,896 | 6,934 | 7,066 | $9,428,700.00 |
5 | 114,088 | 113,815 | 113,897 | $10,252,090.00 |
6 | 383,771 | 384,809 | 383,179 | $24,182,795.00 |
7 | 684,965 | 684,194 | 682,967 | $18,463,140.00 |
8 | 1,286,608 | 1,288,171 | 1,289,057 | $23,187,914.00 |
Total | | | | $281,085,389.00 |
P.S. The total time it took to do these calculation on my laptop (350 million iterations of a java program) - 12 minutes. I love my laptop.
P.P.S I wonder how quickly a Cray could run it :)
0 Comments:
Post a Comment
<< Home