Finding PI digits using Monte Carlo

我怕爱的太早我们不能终老 提交于 2019-12-03 17:21:47

This is a classic example of Monte Carlo. But if you're trying to break the calculation of pi into parallel parts, why not just use an infinite series and let each core take a range, then sum the results as you go?

http://mathworld.wolfram.com/PiFormulas.html

Your fractional error goes by sqrt(N)/N = 1/sqrt(N), So this is a very inefficient way to get a precise estimate. This limit is set by the statistical nature of the measurement and can't be beaten.

You should be able to get about floor(log_10(N))/2-1 digits of good precision for N throws. Maybe -2 just to be safe...

Even at that it assumes that you are using a real RNG or a good enough PRNG.

Use a quasi random number generator (http://www.nag.co.uk/IndustryArticles/introduction_to_quasi_random_numbers.pdf) instead of a standard pseudo RNG. Quasi random numbers cover the integration area (what you're doing is a MC integration) more evenly than pseudo random numbers, giving better convergence.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!