How can a double integral be used to estimate pi using Monte Carlo integration?

Sonden
Messages
7
Reaction score
0

Homework Statement


I am supposed to calculate/estimate pi using a Monte Carlo method. This is of course trivial: create N uniformly distributed random pairs (x,y) in [0,1]^2 and check how many, M, that have x^2+y^2<1. Then M/N=pi/4.

Now, the strange thing is that I am not supposed to do it that way. Instead I'm supposed to use a double integral (Monte Carlo integration): "At a first glance, this may not seem like a integration problem, but it can be formulated as such. Write down the (double) integral (and thus the expected value) that correspond to this procedure, i.e. the integral I = 4E[g(X)] = pi", where E[g(X)] is the expected value for a function g and X a random variable. I've glanced at it for several hours now, I still haven't got a clue how to do it. Of course,
\int_0^1 \int_0^{2 \pi}rdrd\theta=\pi
but is this useful here?
 
Physics news on Phys.org
This seems dumb, since the upper bound of the integral w.r.t. \theta contains the mathematical constant you are trying to evaluate. I think your initial approach is correct.
 
I think your original idea, the one you ruled out, is the method intended in the problem. It is essentially evaluating a double integral. Why do you think you're not supposed to do it that way?
 
Sonden said:

Homework Statement


I am supposed to calculate/estimate pi using a Monte Carlo method. This is of course trivial: create N uniformly distributed random pairs (x,y) in [0,1]^2 and check how many, M, that have x^2+y^2<1. Then M/N=pi/4.

Now, the strange thing is that I am not supposed to do it that way. Instead I'm supposed to use a double integral (Monte Carlo integration): "At a first glance, this may not seem like a integration problem, but it can be formulated as such. Write down the (double) integral (and thus the expected value) that correspond to this procedure, i.e. the integral I = 4E[g(X)] = pi", where E[g(X)] is the expected value for a function g and X a random variable. I've glanced at it for several hours now, I still haven't got a clue how to do it. Of course,
\int_0^1 \int_0^{2 \pi}rdrd\theta=\pi
but is this useful here?
Useful? If that weren't true this method of approximating \pi wouldn't work!

The whole point is that since that integral is equal to \pi, approximating that integral, with a Monte Carlo method, approximates \pi.
 
vela: because the teacher wants MC *integration* (that the unit circle's area is pi perhaps follows from integration but...). :)

Is this true?:

4 times the expected value for a function g(X,Y), where X, Y are random variables with some probability distribution f(x,y), is

4E[g(X,Y)]=4\int\int_{\mathbb{R}^2}g(x,y)f(x,y)dxdy

Then if f(x,y)=1/4 in [-1,1]^2 and 0 elsewhere,

4\int\int_{\mathbb{R}^2}g(x,y)f(x,y)dxdy=\int\int_{[-1,1]^2}g(x,y)dxdy.

Now if g(x,y)=1 inside the unit circle and 0 elsewhere, we get

4E[g(X,Y)]=\int\int_{unit \; circle}dxdy=\pi

so

\pi/4=E[g(X,Y)] \approx 1/N\sum_{i=1}^N g(x_i,y_i)

according to the law of large numbers (I think?), where (x_i, y_i) are random pairs with f:s distribution, ie they are uniformly distributed on [-1,1]^2 and g(x_i,y_i)=1 if they are inside the unit circle, ie if x_i^2+y_i^2<1, and g(x_i,y_i)=0 otherwise (that is, between the unit circle and [-1,1]^2). Is this derivation correct?
 
Last edited:
You do realize, I hope, that you essentially just rederived the "trivial" method you alluded to in your first post.
 
But this time I used the law of large numbers, so I know that I can get as close to pi as I wish by taking N large enough. Which was obvious from the start, but still... ;)
 
If you denote:

<br /> I(A) = \left\{\begin{array}{ll}<br /> 1&amp;, A \, \mathrm{occurs} \\<br /> <br /> 0 &amp;, \bar{A} \, \mathrm{occurs}<br /> \end{array}\right.<br />

the indicator of a random event A (P(A) = p, P(\bar{A}) = q, \, p + q = 1), then:

<br /> E(I) = 1 \cdot p + 0 \cdot q = p<br />

and

<br /> \sigma^{2}(I) = (1 - p)^2 \cdot p + (0 - p)^2 \cdot q = p q^{2} + p^{2} q = p q (p + q) = p q = p(1 - p) \le \frac{1}{4}<br />

Thus, this random variable satisfies the provisions of the Law of Large numbers and the sample mean is a good estimate of the probability of the event.
 
Last edited:
Back
Top