- #1
econmajor
- 5
- 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: