Why Does Multiplying by 20 Correct My Monte Carlo Integration Result?

econmajor
Messages
5
Reaction score
1

Homework Statement


$$f(x)=NormalPDF(x,2,1)+NormalPDF(x,2,(1/2)^2)$$.

where NormalPDF(a,b) is the PDF for a normal distribution with mean a and variance b.

Use Monte Carlo Integratoion to find: $$\int_{-10}^{10}f(x)dx$$

Homework Equations


The solution to this integration is 2.
I use the method described in this video:


The Attempt at a Solution


What I have done is as follows:
- draw n (=5000) random numbers uniformly distributed from -10 to 10. in R: runif(n,-10,10)
- evaluate the function f for each of the n randomly distributed numbers so I end up with n different values of f
- find the mean of those values and that is my integral.

I end up with 0.1 instead of 2. What do I do wrong? When I experiment with $$\int_{0}^{1}\exp(-x^2/2)$$ and use the same method I get the correct result

When I multiply by 20 then I get the correct answer. I assume it has something to do with my integration Interval. But I can't see why it gets me the correct answer when mulitiplying by 20
 
Last edited:
Physics news on Phys.org
By generating a large number of random numbers ##x## in the integration interval [-10,10] and taking the average of ##f(x)## you have estimated the mean of ##f(x)## in the interval. The mean of a function ##f## over an interval ##[a,b]## is defined as
$$\frac{\int_a^b f(x)dx}{b-a}$$
So, to estimate the integral, you need to multiply your estimate of the mean (0.1) by ##(b-a)## which in this case is ## (10--10)=20##.
 
  • Like
Likes Orodruin
There are two things I don't understand about this problem. First, when finding the nth root of a number, there should in theory be n solutions. However, the formula produces n+1 roots. Here is how. The first root is simply ##\left(r\right)^{\left(\frac{1}{n}\right)}##. Then you multiply this first root by n additional expressions given by the formula, as you go through k=0,1,...n-1. So you end up with n+1 roots, which cannot be correct. Let me illustrate what I mean. For this...
Back
Top