Montecarlo estimate of a integrand from 0 to $\infty$

371 Views Asked by At

I have a question about monte carlo estimation of integrals. Suppose I am told to estimate using monte carlo, the integral: $$f(y) = \int_{0}^{y}\frac{4}{1+x^{2}}dx$$ I want to estimate $f(\infty)$. I know that with some calculation, the exact values are given by $\pi$ and $2\pi$. However, there is some confusion with respect to defining the bounds and area given that the interval is now $\infty$. With an upper bound, such as $f(1)$ for example, I know I can generate random points from $[0,1]$x$[0,4]$ but I'm a bit confused as to what I should do in this case for $f(\infty)$.

I am told that: To deal with this, pick a value $x_{max}$ and approximate the integrand as zero for $x > x_{max}$. Keeping the number of samples fixed at 107, use semilogx to plot the absolute error of your estimate as a function of $x_{max}$ for $x_{max}$ = $10^{0}, 10^{1}, 10^{2}, . . . , 10^{7}$.

The biggest problem is that I am having trouble visualizing how to set $x_{max}$ and the points. I would greatly appreciate it if someone could provide some help with respect to this as I am just barely grasping the understanding monte carlo estimation.

Thank you

2

There are 2 best solutions below

19
On BEST ANSWER

You have $\int_0^\infty \frac{4}{1+x^2} dx = \int_0^y \frac{4}{1+x^2} dx + \int_y^\infty \frac{4}{1+x^2} dx$. Here $y$ is a parameter that you choose. To make this work by using the rejection sampling method that you are proposing, you need an analytical error estimate for the second term (because there is no uniform distribution on an infinite rectangle). A lower bound is of course zero; an upper bound is $\int_y^\infty \frac{4}{x^2} dx = \frac{4}{y}$. So you can calculate the original integral with an error tolerance of $\varepsilon$ by calculating the first piece to an accuracy of $\varepsilon/2$ with $y>\frac{8}{\varepsilon}$ (so that the second piece is also less than $\varepsilon/2$).

0
On

You can split the integral into two pieces: $\int_{0}^{\infty}\frac{4}{1+x^{2}}dx= \int_{0}^{y}\frac{4}{1+x^{2}}dx+ \int_{y}^{\infty}\frac{4}{1+x^{2}}dx$, use Monte Carlo on the first and approximate the second by $\int_{y}^{\infty}\frac{4}{x^{2}}dx=-\frac 4{x}|_y^\infty=\frac 4{y}$ You can bound the error on the second piece by (what does removing the $+1$ change?). You should choose the breakpoint $y$ so the error caused by ignoring the $+1$ in the tail portion is about the same as the random error in your Monte Carlo.