5

Is there a way of estimating Pi with the Buffon's method without assuming Pi known?

To be more precise: in a Monte Carlo simulation of the experiment invented by Buffon I would (ideally) generate 2 random numbers with uniform distribution within [0,1] and [0,Pi] respectively (the two numbers being the distance of the center of the needle from the border of the strip and the orientation of the needle). Unfortunately this is sort of cheating because one must already know the value of Pi in order to generate the angle.

A possible reasonable -at least in principle- solution is to work around this problem by generating 2 points in a rectangle and then extract the probability distribution for needle's center and orientation from them (imposing the fixed length of the needle). However analytic calculations to get some usable formulas seem a complete mess to me.

Is there some smarter way of doing that?

  • 2
    It's a great question, and I'm personally glad to have seen it here. But maybe better suited to math.stackexchange.com? – chase Mar 10 '14 at 10:45
  • What about a random angle between 0 and 180 degrees? –  Mar 10 '14 at 11:50
  • @CarlWitthoft that doesn't help since the problem involves computing trigonometric quantities with the angle... and you'd have to convert to radians with a factor of $\pi$. – chase Mar 10 '14 at 12:01
  • Why can't pi be assumed to be known? – Kyle Kanos Mar 10 '14 at 12:49
  • This question appears to be off-topic because it is about programming methods and not physics. Perhaps StackOverflow or SciComp.StackExchange might be a better place for this question? – Kyle Kanos Mar 10 '14 at 12:50
  • Yes, I'm sorry about that. Is there a way of moving the question there without starting a new discussion? If not i'll just copy-and-paste my question. –  Mar 10 '14 at 12:55
  • A book you might like - History of Pi by Petr Beckmann. –  Mar 10 '14 at 13:28

3 Answers3

2

Here's an alternative game (code in R; hope it's understandable). Basically the same concept as SeanD's answer.

# from http://giventhedata.blogspot.com/2012/09/estimating-pi-with-r-via-mcs-dart-very.html
est.pi <- function(n){

# drawing in  [0,1] x [0,1] covers one quarter of square and circle.

# draw random numbers for the coordinates of the "dart-hits"
a <- runif(n,0,1)
b <- runif(n,0,1)
# use the pythagorean theorem
c <- sqrt((a^2) + (b^2) )
inside <- sum(c<1)
#outside <- n-inside
pi.est <- nside/n*4

 return(pi.est)
}
  • You can save yourself a crapload of time by ignoring the sqrt term and compare a^2+b^2 to r^2 (which is still 1 here). Powers are generally slower than using multiplication, so you can save yourself even more time by using c <- a*a + b*b. – Kyle Kanos Mar 10 '14 at 12:37
  • 2
    This is ok for estimating Pi but has nothing to do with the Buffon's method. One can at most use this estimation for Pi to start the "needle's-drop" simulation which anyhow assumes to know Pi. –  Mar 10 '14 at 12:51
  • @cherbert Agreed - I just posted this up as an alternative method of using random numbers to derive $\pi$ –  Mar 10 '14 at 12:58
  • This method works, but it is not the same "experiment" as the needle. – dmckee --- ex-moderator kitten Mar 10 '14 at 15:08
1

Why don't you check it intersects the curve $x^2+y^2=1$, that's a circle and you didn't need to know $\pi$.

Sean D
  • 111
  • 2
1

For a given $(y,\theta)$ pair you really only need to decide whether $y\pm\frac{1}{2}sin\theta$ (the endpoints) crosses a line:

enter image description here

One possiblity is to sample $sin(\theta)$ directly, either using a lookup table or its Taylor series to whatever precision you care for: $$ sin(x) = x - \frac{x^3}{3!} + \frac{x^5}{5!} + \cdots$$

That is, you can avoid $\pi$ at the expense of using a non-uniform PDF. Draw a pair of numbers $(y, y')$ where $y'$ is now sampled from the sinusoidal distribution. Now check whether $y\pm\frac{1}{2}y'$ crosses a line.

Of course, there are approximations to $\pi$ based on Taylor series, so it' still a bit of a chicken-and-egg problem...

chase
  • 111
  • 1