Re:Show HN: Pi Approximation using Monte Carlo
by nemetroid on Sunday August 10, 2014 @08:01AM
(#8159522)
> not quite possible in the browser!
It's not the browser (or JS) that's slow, it's all the animations and stuff. If you write Javascript to do only what the OCaml code does, it runs fast enough: http://jsfiddle.net/qmw4d9p9/1/
Re:Show HN: Pi Approximation using Monte Carlo
by Goopplesoft on Sunday August 10, 2014 @03:31AM
(#8159122)
Thanks for the share. Tried this in python using some higher iterations and started getting good numbers around 1E6
Link: http://nbviewer.ipython.org/gist/pnegahdar/eb62475b28d5b394d...
Re:Show HN: Pi Approximation using Monte Carlo
by fphilipe on Sunday August 10, 2014 @03:53AM
(#8159154)
Nice work. I did a very similar simulation a year ago when I learned about MC in the context of particle filtering in a course about recursive estimation at ETH.
Re:Show HN: Pi Approximation using Monte Carlo
by krat0sprakhar on Sunday August 10, 2014 @04:08AM
(#8159172)
Wow! Nicely done. The idea of showing relative error is pretty cool :D
This is a small hack that I created over the weekend. I learnt about the Monte Carlo method while doing Princeton's Functional Programming course[0] in OCaml[1] as one of the assignment problems. To get the first four digits consistently, I ran around 200,000 - 400,000 simulations - not quite possible in the browser!
[0] - http://www.cs.princeton.edu/~dpw/courses/cos326-12/
[1] - https://github.com/prakhar1989/ocaml-experiments/blob/master...