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

Click For Summary
SUMMARY

The discussion centers on the application of Monte Carlo Integration to evaluate the integral $$\int_{-10}^{10}f(x)dx$$ where $$f(x)=NormalPDF(x,2,1)+NormalPDF(x,2,(1/2)^2)$$. The user initially obtained an incorrect result of 0.1 instead of the expected 2. The key insight is that to estimate the integral correctly, one must multiply the mean of the function evaluations by the width of the integration interval, which is 20 in this case. This adjustment aligns with the definition of the mean of a function over an interval, confirming that the integral is indeed $$\int_a^b f(x)dx = (b-a) \cdot \text{mean}(f(x))$$.

PREREQUISITES
  • Understanding of Monte Carlo Integration techniques
  • Familiarity with the Normal Probability Density Function (NormalPDF)
  • Basic knowledge of R programming, specifically the use of the runif function
  • Concept of mean value theorem for integrals
NEXT STEPS
  • Study the implementation of Monte Carlo Integration in R using different distributions
  • Explore the properties and applications of the Normal Probability Density Function
  • Learn about the mean value theorem for integrals and its implications in numerical methods
  • Investigate common pitfalls in Monte Carlo simulations and how to avoid them
USEFUL FOR

Students and practitioners in statistics, data science, and numerical analysis, particularly those interested in Monte Carlo methods and integration techniques.

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   Reactions: Orodruin

Similar threads

Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 19 ·
Replies
19
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
7
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 12 ·
Replies
12
Views
3K