Skip to content

A powerful and efficient lottery simulation tool to analyze the probability of matching numbers in a Super5 lottery game.

License

Notifications You must be signed in to change notification settings

CliveMlt/Super5-Lottery-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Super5-Lottery-Simulator

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.

Features

  • 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.

Requirements

  • Python 3.x
  • numpy
  • tqdm
  • plotly

Installation

  1. Clone the repository:
    git clone https://github.com/CliveMlt/Super5-Lottery-Simulator.git
  2. Navigate to the project directory:
    cd Super5-Lottery-Simulator
  3. Install the required packages:
    pip install numpy tqdm plotly

Usage

Run the main script:

python lottery_sim1.py
python lottery_sim2.py

Menu Options

  1. Super5: Generate a random set of Super5 lottery numbers.
  2. Powerball: Generate random Powerball lottery numbers.
  3. Mega Millions: Generate random Mega Millions lottery numbers.
  4. Run Lottery Simulation: Run a simulation to analyze the probability of matching numbers in a Super5 lottery game.
  5. Quit: Exit the application.

Lottery Simulation

Generating Super5 Numbers If you choose option 1, it will generate 5 random Super5 Numbers like the below:
Super5: [2, 14, 25, 33, 45]

Running a Simulation

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.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A powerful and efficient lottery simulation tool to analyze the probability of matching numbers in a Super5 lottery game.

Topics

Resources

License

Stars

Watchers

Forks

Languages