A powerful and efficient lottery simulation tool to analyze the probability of matching numbers in a Super5 lottery game. This tool also provides functionalities to generate random lottery numbers for various popular lottery games.
- Generate random lottery numbers for Super5, Powerball, and Mega Millions.
- Run large-scale simulations to understand the probability of matching numbers.
- Visualize the results using interactive Plotly charts.
- Multi-processing support to speed up simulations using all available CPU cores.
- Python 3.x
- numpy
- tqdm
- plotly
- Clone the repository:
git clone https://github.com/CliveMlt/Super5-Lottery-Simulator.git
- Navigate to the project directory:
cd Super5-Lottery-Simulator
- Install the required packages:
pip install numpy tqdm plotly
Run the main script:
python lottery_sim1.py
python lottery_sim2.py
- Super5: Generate a random set of Super5 lottery numbers.
- Powerball: Generate random Powerball lottery numbers.
- Mega Millions: Generate random Mega Millions lottery numbers.
- Run Lottery Simulation: Run a simulation to analyze the probability of matching numbers in a Super5 lottery game.
- Quit: Exit the application.
Generating Super5 Numbers
If you choose option 1, it will generate 5 random Super5 Numbers like the below:
Super5: [2, 14, 25, 33, 45]
If you choose option 4, the simulation will run and display the progress using a progress bar.
The simulation uses all available CPU cores to be faster and more efficient. It divides the total number of plays into smaller chunks, and each chunk is processed in parallel by different CPU cores.
This ensures that the simulation completes in a reasonable time even for a large number of plays.
The simulation can be ran using two methods for parallel processing:
lottery_sim1.py uses 'executor.map' while lottery_sim2.py uses 'executor.submit'.
Playing Super5...: 100%|██████████████████████████████████████████| 10000000/10000000 [01:00<00:00, 165593.17it/s]
After completion, the results will be printed:
Super5: [22, 3, 7, 8, 30]
0 Matches: 5,471,343 (1 in 2)
1 Match: 3,505,012 (1 in 3)
2 Matches: 900,833 (1 in 11)
3 Matches: 115,235 (1 in 87)
4 Matches: 7,382 (1 in 1,355)
5 Matches: 195 (1 in 51,282)
Total execution time: 60.39 seconds
An interactive bar chart will also be displayed showing the match counts.
This project is licensed under the MIT License. See the LICENSE file for details.