Numerical Integration: Monte Carlo integration
Efficiency of Monte Carlo integration (programming assignment)
Use your previously implemented function for Monte Carlo integration.
- Find out how large the sample must be to approximate the integral \(\displaystyle\int_0^1\frac{4}{x^2+1}dx\) with a precision of \(0.1\), \(0.01\), \(0.001\) and \(0.0001\).
- Compare the result from part (a) with the following probability-based algorithm to approximate an integral \(\displaystyle \int_a^bf(x)\,\dd x\): draw a uniform sample of values in the interval \([a,b]\), calculate the mean value of the function \(f\) for the drawn values in the sample and multiply this mean value by the length of the interval, i.e. by \(b-a\).
Unlock full access