Volume using Monte Carlo Method

4.3k Views Asked by At

I want to find the volume above $xy$-plane and below the surface given by equation $z = x^2 +2y^2$ for $(x,y) \in [0,1] \times [0,1]$ using Monte Carlo method.

Can anybody help me please? Can you please share related questions so that I can have an idea of how to solve it?

Thanks.

2

There are 2 best solutions below

2
On BEST ANSWER

I assume you've got the gist of the idea behind the method from the comments above.

Here's the breakdown of the code:

  1. Pick a random vector (here a point in 3D) uniformly distributed over a box that contains the volume you'd like to sample. It doesn't have to be a snug fit, the box must simply be bigger.
  2. If the vector happens to be inside your the region, you'd like to find the volume of, let a counter variable tick one up, e.g. by k = k+1.
  3. Do this a large number of times, say $N$. Now $$\frac{k}{N}\approx\frac{\text{volume of region}}{\text{volume of box}},$$ and since the volume of the box is easy to calculate, you can find the desired volume. If $N\rightarrow \infty,$ the approximation will become an equality.

If you're having trouble implementing this in some specific software (like Python or Matlab), please ask over at Stack Overflow.

3
On

An alternative:

Sample random points $(x_i,y_i)$ uniformly in $[0,1]^2$ and calculate the corresponding $z_i=x_i^2+2y_i^2$ value.

Do this for many sample points, and calculate the average of the $z_i$ values. This is the average height of your region. Since the set $[0,1]\times[0,1]$ has area $1$, this average height is equal to the volume of your region.