my question is how to solve the following problem using the Monte Carlo Integration method:
$P = \int_a^b\int_x^d g(x,y) dydx$
Most of the tutorials I read concentrate on specific limits, just like $P = \int_0^3\int_0^5 g(x,y) dydx$, which can be easily solved by uniformly sampling and averaging.
However, few of them refers to above problem.
Thank you!
To pick a point from a uniform distribution in the quadrilateral, first choose $x$ in the interval $(a,b)$ using a density function $f(x)=k|d-x|$, where $k$ is computed by $\int\limits_a^b f(x)dx=1$. Choose $y$ uniformly in the interval $|x,d|$.
To evaluate the integral compute $h=g(x,y)$ at the chosen $(x,y)$. If $x\le d$ add $h$.
However if $x\gt d$ subtract $h$. This is necessary because $\int\limits_d^b\int\limits_x^d g(x,y)dydx=-\int\limits_d^b\int\limits_d^x g(x,y)dydx$, since the lower limit should not exceed the upper limit for $y$ integral.