https://github.com/jnywong/monte-carlo-estimate-pi
Simple python script to estimate pi using the Monte Carlo method.
https://github.com/jnywong/monte-carlo-estimate-pi
Last synced: about 2 months ago
JSON representation
Simple python script to estimate pi using the Monte Carlo method.
- Host: GitHub
- URL: https://github.com/jnywong/monte-carlo-estimate-pi
- Owner: jnywong
- License: mit
- Created: 2022-07-12T14:08:06.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-07-12T14:46:40.000Z (almost 3 years ago)
- Last Synced: 2025-02-14T14:18:26.500Z (4 months ago)
- Language: Python
- Size: 1.41 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]
![]()
monte-carlo-estimate-pi
Simple python script to estimate pi using the Monte Carlo method.
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
## About The Project
This is a small project that uses the Monte Carlo method to estimate $\pi$.
### Method
The area of a circle is
$$
A_c = \pi r^2,
$$where $r$ is the radius of the circle.
The area of a square enclosing the circle is
$$
A_s = (2r)^2 = 4 r^2.
$$We estimate $\pi$ by looking at the ratio between these two areas:
$$
\frac{A_c}{A_s} = \frac{\pi r^2}{4 r^2} \Rightarrow \pi \approx4\frac{A_c}{A_s}.
$$## Getting Started
This code requires Python 3.
## Usage
Run the code using
```shell
python3 estimate-pi.py num_points
```
where `num_points` is the number of points to be used in the estimation, e.g. 100.## Roadmap
- [ ] Create an interactive dashboard so that the user can choose the number of points
- [ ] Host the interactive app on a websiteSee the [open issues](https://github.com/jnywong/monte-carlo-estimate-pi/issues) for a full list of proposed features (and known issues).
## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request## License
Distributed under the MIT License. See [LICENSE.md](LICENSE.md) for more information.
## Contact
Jenny Wong - [@_jennywong_](https://twitter.com/_jennywong_) - [email protected]
Project Link - [https://github.com/jnywong/monte-carlo-estimate-pi](https://github.com/jnywong/monte-carlo-estimate-pi)
## Acknowledgments
* [Geeksforgeeks](https://www.geeksforgeeks.org/estimating-value-pi-using-monte-carlo/)
* [Best-README-Template](https://github.com/othneildrew/Best-README-Template)[contributors-shield]: https://img.shields.io/github/contributors/jnywong/monte-carlo-estimate-pi.svg?style=for-the-badge
[contributors-url]: https://github.com/jnywong/monte-carlo-estimate-pi/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/jnywong/monte-carlo-estimate-pi.svg?style=for-the-badge
[forks-url]: https://github.com/jnywong/monte-carlo-estimate-pi/network/members
[stars-shield]: https://img.shields.io/github/stars/jnywong/monte-carlo-estimate-pi.svg?style=for-the-badge
[stars-url]: https://github.com/jnywong/monte-carlo-estimate-pi/stargazers
[issues-shield]: https://img.shields.io/github/issues/jnywong/monte-carlo-estimate-pi.svg?style=for-the-badge
[issues-url]: https://github.com/jnywong/monte-carlo-estimate-pi/issues
[license-shield]: https://img.shields.io/github/license/jnywong/monte-carlo-estimate-pi.svg?style=for-the-badge
[license-url]: https://github.com/jnywong/monte-carlo-estimate-pi/blob/master/LICENSE.md
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/thisisjennywong
[product-screenshot]: images/screenshot.png
[Next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white
[Next-url]: https://nextjs.org/
[React.js]: https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB
[React-url]: https://reactjs.org/
[Vue.js]: https://img.shields.io/badge/Vue.js-35495E?style=for-the-badge&logo=vuedotjs&logoColor=4FC08D
[Vue-url]: https://vuejs.org/
[Angular.io]: https://img.shields.io/badge/Angular-DD0031?style=for-the-badge&logo=angular&logoColor=white
[Angular-url]: https://angular.io/
[Svelte.dev]: https://img.shields.io/badge/Svelte-4A4A55?style=for-the-badge&logo=svelte&logoColor=FF3E00
[Svelte-url]: https://svelte.dev/
[Laravel.com]: https://img.shields.io/badge/Laravel-FF2D20?style=for-the-badge&logo=laravel&logoColor=white
[Laravel-url]: https://laravel.com
[Bootstrap.com]: https://img.shields.io/badge/Bootstrap-563D7C?style=for-the-badge&logo=bootstrap&logoColor=white
[Bootstrap-url]: https://getbootstrap.com
[JQuery.com]: https://img.shields.io/badge/jQuery-0769AD?style=for-the-badge&logo=jquery&logoColor=white
[JQuery-url]: https://jquery.com