In honour of Pi day, we've created a repository with the code to the fun little gimmicks shown in our pi day video!
The project includes three different implementations of the Monte Carlo method for estimating π:
-
Simple Version (
monte_carlo_simple.py):- Basic implementation of the Monte Carlo method
- Quick and straightforward calculation
-
Statistics Version (
monte_carlo_with_stats.py):- Enhanced version with detailed statistics
- Prettier console outputs
- High-precision calculations using mpmath
-
Animated Visualization (
monte_carlo_animation.py):- Cool visualization of the Monte Carlo process
- Real-time point plotting with neon effect
- Live statistics updates
- Generates encryption keys using digits of π
- Uses high-precision π calculations
- Includes progress visualization
- Python 3.x
- Required packages listed in requirements.txt
- Clone the repository
- Create a virtual environment:
python -m venv venv - Activate the virtual environment:
- Windows:
venv\Scripts\activate - Unix/MacOS:
source venv/bin/activate
- Windows:
- Install dependencies:
pip install -r requirements.txt
Each script can be run independently:
# Run the animated visualization
python estimating_pi_using_monte_carlo/monte_carlo_animation.py
# Run the statistics version
python estimating_pi_using_monte_carlo/monte_carlo_with_stats.py
# Run the simple version
python estimating_pi_using_monte_carlo/monte_carlo_simple.py
# Generate a pi-based encryption key
python pi_encryption.pyExplore and have a play around!
We welcome contributions to make this Pi Day celebration even better! Here's how you can contribute:
-
Add New Features
- New π estimation methods
- Different visualization styles
- Additional π-based tools
-
Improve Existing Code
- Optimize performance
- Enhance visualizations
- Add error handling
- Improve documentation
-
Report Issues
- Bug reports
- Feature requests
- Documentation improvements
- Fork the repository
- Create a new branch:
git checkout -b feature/your-feature-name - Make your changes
- Test your changes thoroughly
- Submit a pull request with a clear description of your changes
- Follow PEP 8 Python style guide
- Add docstrings to new functions/classes
- Comment complex code sections
- Keep a similar aesthetic for visualizations
Have questions or ideas? Feel free to:
- Open an issue
- Start a discussion
- Reach out to the maintainers
Thank you for helping make this project better! 🥧