https://github.com/deanpdx/monte-carlo-pi
https://github.com/deanpdx/monte-carlo-pi
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/deanpdx/monte-carlo-pi
- Owner: DeanPDX
- License: mit
- Created: 2021-05-07T23:28:04.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-09-01T16:06:14.000Z (almost 4 years ago)
- Last Synced: 2025-01-01T12:46:09.503Z (over 1 year ago)
- Language: Go
- Size: 1.1 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# monte-carlo-pi
A monte carlo simulation written in go that attempts to estimate [Pi](https://golang.org/pkg/math/#pkg-constants). Inspired by [this excellent blog post](https://ggcarvalho.dev/posts/montecarlo/). I'm using [Ebitengine](https://github.com/hajimehoshi/ebiten) to show the algorithm work visually. When you `go run main.go` you will see something like this:

As you can see, this run achieved a result of 3.140872, which is off by only 0.000721. Due to the nature of monte carlo simulations, different runs will give you different results but I was consistently estimating Pi pretty accurately. Play with the constants at the top (make sure to keep width/height proportionate if you change them) and try running the test again.