News for hackers. Stuff that matters.
Re:Show HN: Pi Approximation using Monte Carlo by adwn on Sunday August 10, 2014 @04:45AM (#8159240)
Monte Carlo methods are never "seriously" used to approximate pi – there are algorithms which converge much, much faster. This here, however, is not a "serious" attempt at computing pi, but a learning exercise for someone who just found out about Monte Carlo methods.

Regarding the randomness of the problem to solve: A practical application for Monte Carlo methods is integration over a high-dimensional space (with dozens or more degrees of freedom). Traditional deterministic methods have a runtime which is exponential in the number of dimensions, while for Monte Carlo integration, the error of the result decreases as 1/sqrt(N) (where N is the number of samples, which is proportional to the runtime), independent of the dimensionality of the integration space.

Re:Show HN: Pi Approximation using Monte Carlo by wfunction on Sunday August 10, 2014 @05:07AM (#8159270)
I think you missed my point. I know this isn't how pi is calculated, that is completely irrelevant to what I've been trying to say. I also know Monte Carlo has other benefits, and that's entirely my point: the actual benefits aren't illustrated in the example.

what I'm saying is that the entire point of illustrating an algorithm by example is to illustrate the power of the algorithm compared to a naive approach, regardless of whether or not there is a better way to solve the example problem.

i.e., the example should motivate the algorithm. But computing pi is one of the worst possible illustrations of why anyone would use Monte Carlo, because it's inferior to the naive approach. i.e., it doesn't motivate why anyone would want to use Monte Carlo.

Re:Show HN: Pi Approximation using Monte Carlo by keithpeter on Sunday August 10, 2014 @10:05AM (#8159736)
"But computing pi is one of the worst possible illustrations of why anyone would use Monte Carlo, because it's inferior to the naive approach. i.e., it doesn't motivate why anyone would want to use Monte Carlo."

Any suggestions for a simulation that does illustrate the use of Monte Carlo methods while still being explainable with 16+ age range non-specialist mathematics? I'm hacking around with two step simulations like a tree diagram...

http://sohcahtoa.org.uk/pages/maths_montecarlo.html

My crack at saying how slowly a monte-carlo simulation 'converges' to a value of pi (not really converging, just confidence intervals tightening around the value).

Re:Show HN: Pi Approximation using Monte Carlo by jwmerrill on Sunday August 10, 2014 @02:36PM (#8160348)
I like computing the volume of the intersection of 3 orthogonal cylinders as a less trivial example problem. It's still easy to compute whether a given point is inside the volume, and there's still an analytic solution to compare to, but the problem is complicated enough that you start to appreciate how much easier MC is than other approaches.
Re:Show HN: Pi Approximation using Monte Carlo by jwmerrill on Sunday August 10, 2014 @02:45PM (#8160368)
Or compute the area of the mandlebrot set. This one has the advantage of being highly non-convex, which makes it hard to decide how to implement a recursive subdivision routine, since you don't know whether some of the target area is inside a given square just from looking at a few points on its boundary.
Re:Show HN: Pi Approximation using Monte Carlo by keithpeter on Monday August 11, 2014 @09:55AM (#8163235)
Mandlebrot set a bit over the maths level for intended group, but other repeated maps like logistic equation might be OK. I'll go with the cylinders first!
Re:Show HN: Pi Approximation using Monte Carlo by keithpeter on Monday August 11, 2014 @09:53AM (#8163228)
Sounds nice. Easy to visualise and close enough to a crucible design (toroidal volume intersected by a cube off axis and oblique to the central axis of the toroid) I once heard of in the days of Fortran.
Re:Show HN: Pi Approximation using Monte Carlo by wfunction on Sunday August 10, 2014 @04:00PM (#8160565)
Yeah, search for "Example #1" and subsequently "Monte Carlo" on this page:

http://jakevdp.github.io/blog/2014/06/06/frequentism-and-bay...

Re:Show HN: Pi Approximation using Monte Carlo by Houshalter on Sunday August 10, 2014 @03:27PM (#8160461)
The advantage of Monte Carlo isn't that it's the best method, it's that it's so simple. You just sample random points and see how many are in the circle.
Re:Show HN: Pi Approximation using Monte Carlo by wfunction on Sunday August 10, 2014 @03:34PM (#8160479)
> The advantage of Monte Carlo isn't that it's the best method

I feel like you didn't read a single sentence of my comment, because that's exactly what I said I was not saying.

Re:Show HN: Pi Approximation using Monte Carlo by Houshalter on Sunday August 10, 2014 @05:35PM (#8160822)
Regardless, it's the simplest method and very general.