[Math] Volume using Monte Carlo Method

monte carlonumerical methodsvolume

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.

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.

Related Question