Calculate the integral with the help of Monte Catlo method and three given points.

56 Views Asked by At

For a time I am trying to solve this task:

Using Monte Carlo method, approximate the integral $\int_{-1}^{1}\int_{-1}^{1}x^{2}cos(y)dxdy$ using the given realizations of a random vector which has independent components uniformally distributed within the interval $[0;1]$: $$u_{1}=[0.90;0.36] \\ u_{2}=[0.66;0.08] \\u_{3}=[0.77;0.93] $$

I'm trying to solve this in the following way, knowing that the function in question is symmetric with respect to axes $x$ and $y$:

  1. I calculate the values of the function in points $u_{1}, u_{2}, u_{3}$: $$f(u_{1})=f(0.90,0.36)=0.758 \\ f(u_{2})=f(0.66,0.08)=0.434 \\ f(u_{3})=f(0.77,0.93)=0.354 $$
  2. I calculate the average value of the function $$f_{\phi}=0.515$$
  3. To get the value of the integral I multiply the average value with the area of the integration range $$\int_{-1}^{1}\int_{-1}^{1}f(x,y)dxdy=f_{\phi}*A=0.515*4=2.061$$

The result I get is wrong - it sgould be something around $1.12$. What am I doing wrong?

EDIT: I stumbled upon this kind of solution but have no idea where does it result from. We somehow change the variables of the integrated function with respect to the integration range. $$ u=\frac{x-a}{b-a}=\frac{x-(-1)}{1-(-1)} \to x=2u-1 \to \frac{du}{dx}=\frac{1}{2} \to dx=2du$$ $$ v=\frac{y-a}{b-a}=\frac{x-(-1)}{1-(-1)} \to y=2v-1 \to \frac{dv}{dy}=\frac{1}{2} \to dy=2dv$$

This leads to $$\int_{-1}^{1}\int_{-1}^{1}(2u-1)^{2}cos(2v-1)2du2dy$$ Following the same algorithmm as before, calculating values of the function $f(u,v)=(2u-1)^{2}cos(2v-1)$ in the points $u_{1}, u_{2}, u_{3}$, the avreage value multiplied by the area gives me the result of $1,164$ which is a good approximation of the integral.

2

There are 2 best solutions below

6
On

The integral you have to evaluate is supposed to give the volume of a solid above $[-1,1]\times[-1,1]$ and below the surface determined by your function whose graph is given below:

enter image description here

It is obvious that over $[-1,1]\times[-1,1]$ surface is below $z=1$ and above $0$.

Let's see what if we generate pairs of random variables $\{(X_i,Y_i)\}$ uniformly distributed over $[0,1]\times[0,1]$. Then the average

$$\lim_{N\to \infty}\frac1N\sum_1^N X_i^{2}\cos(Y_i)=$$ $$E[X_i^{2}\cos(Y_i)\mid (X_1,Y_1)\in[0,1]\times[0,1]]=\int_{0}^{1}\int_{0}^{1}x^{2}\cos(y)dxdy$$

with probability one (law of large numbers). So the original integral equals the average times $4$.

Your calculation is OK. The difference from the true value of the integral is a result of the little number of data. I did an experiment with $1000$ data and the result was $1.12796$. Working with data sets of three numbers I even got $0.17$ as an approximation of the integral.

I guess that the moral of the original example partly is that small datasets may give very bad bad approximations.

0
On

Observe that your three sample points are taken from the region $[0,1]\times[0,1]$, but the integral is over $[-1,1]\times[-1,1]$. So, your estimate is for the integral $\int_0^1\int_0^1f(x,y)\,dx\,dy$ instead of $\int_{-1}^1\int_{-1}^1f(x,y)\,dx\,dy$. You need to scale the sample points so that they’re uniformly distributed over the correct region, which is what the change of variables in your edit accomplishes.