LOTTERY SIMULATION DRAW Feedback
Use the form below to configure your lottery.
Play a Lottery
Lottery Ball Simulator
Our simulator will let you generate any amount of numbers based on you particular lotto game. If you are playing Powerball, select 6 numbers. If you are playing a state lottery, find out what your state rules are and then select the appropriate settings to match your game.
Here are a list of popular lottos and the corresponding balls. Starting November 2019, you can click on the link to set the default settings
2. Mega Millions
3. Massachusetts – The Numbers Game
Run the simulator as many times as you like, you should get a different outcome every time! This lotto generator will simulate a lottery drawing machine to spit out the numbers you need. Please let us know if you’d like us to add any features! Thanks for playing!
Use our lottery ball simulation to generate numbers that a lotto ball machine might pick at random.
I wrote a python simulator to play the lottery for me
How long will it take me to win the lottery?
Jul 20 · 6 min read
I grew up in New York where the lottery is a big part of my family’s culture. A refrigerator looks incomplete to me unless there are a few scratch-offs or Mega Million tickets stuck to it. Every holiday or birthday I would (and still do) receive scratch off tickets combined with half-joke/half-threats that “if you win big, I’m getting a cut!”
For better or for worse, I eventually m o ved to Alabama where the lottery is illegal. This was a bit of a shock for me, but I eventually got used to it. Every time I visit family in NY, however, I’m reminded of the pull it has on people when I see the glowing billboards, when I see the primary colored logos blasted in my face at every gas station, and (of course) when I hear my family bring it up in conversation regularly.
All that goes to say, I’ve always been curious about the actual numbers behind the scenes. I finally decided to buckle down and simulate the Mega Million to add some perspective to the way I think about it.
Table of Contents
- Mega Millions Rules Refresher
- How Does the Simulation Work?
- Results of 3 Simulation Runs and Visualizations
Mega Millions Rules
Let’s start with the basics. How do you play Mega Millions and what are the rules? (If you already know this, feel free to skip)
Their website explains it pretty well. Below is an image with the instructions and the prize breakdowns with their corresponding odds.
Take a second and go over that. And yes, on that last row the 1/37 odds of winning the megaball is correct. That stumped me for a minute too. The reason it’s not 1/25 (which you would initially assume due to there only being 25 mega balls) is because that prize is specifically for instances when you win only the mega ball without matching any white balls.
How does the simulation work?
At its core, its 2 random number generators and a ‘while-loop’. The simulator continues to generate random numbers (replicating the 5 white balls and the mega ball) again and again until they match, aka, the jackpot is won. During each run there are if-statements which add up the smaller prizes so we can keep track of the total profit/loss.
Assumptions going in:
- You purchase one ticket every drawing (2 tickets a week) and you always get the standard megaball $2 ticket
- If you win the jackpot, you take the lumpsum cash option
- All earnings calculations are before taxes (and we’re not factoring in time-value of money in these scenarios either)
- Interesting to compare the results to the mathematical probabilities on the Mega Millions website
- Gives you the ability to say you “won the lottery”
Check out the code below, or if you want more detail visit my Github
As you probably notice, I set the jackpot prize at $197,000,000. That isn’t arbitrary. I calculated the average cash jackpot over the last 3 years. Feel free to experiment with it and change the jackpot during your simulations.
Mathematically (if you read the rules in the previous section), you should win the jackpot once every 302,575,350 plays. I ran my simulator 3 times. Let’s compare these runs with that statistical average.
Helpful analogy: If you roll a dice 6 times, theoretically you should roll one ‘6’. However, we all know you could roll a ‘6’ on your first try. OR you could roll a ‘6’ after 20 rolls. Same for winning the lottery. Just because you play the lottery 302 million times, doesn’t guarantee you will win once. You might win thousands of times. Or you might not win until a billion tries. That’s what make these scenarios fun. You never know what the results might be.
With that said, let’s look at the results!
Scenario 1 — Lucky: 25 million plays — 244,744 yrs
If you bought 1 ticket per draw (twice a week) it would take you 244,744 years before you won the jackpot in this scenario. And this is extremely lucky! Take a look at the breakdown in quantity of prizes won below:
Below shows the distribution of duds and prizes types won for the 25million plays.
I grew up in New York where the lottery is a big part of my family’s culture. A refrigerator looks incomplete to me unless there are a few scratch-offs or Mega Million tickets stuck to it. Every…