Mathematica Numerical vs. Monte-Carlo Simulations

AI Thread Summary
The discussion revolves around the comparison of numerical integration results obtained from Mathematica's NIntegrate and Monte Carlo simulations for a specific integral that lacks a closed-form solution. A small, consistent discrepancy between the two methods raises questions about the accuracy of the Monte Carlo approach. Participants emphasize that NIntegrate is a well-tested numerical integrator, while Monte Carlo methods can introduce significant errors due to their reliance on random sampling and potential issues with random number generation.Concerns are raised about the sampling method used in the Monte Carlo simulations, particularly regarding the range of values generated and the representation of the exponential distribution. The discussion highlights the importance of ensuring that the random samples adequately cover the necessary range and that the sampling distribution is unbiased. Suggestions include generating multiple sets of samples to analyze the mean and standard deviation, as well as using QQ plots to compare the generated data against the expected distribution.
Physics news on Phys.org
  • #52
mfig said:
What is the small discrepancy? 1 part in 1 million? 1 part in 1 billion? Is there some reason you are using an exponential distribution and not a uniform distribution for your sampling? If you post just the MC integration code, we might be able to see a problem with it.

See this thread for more details. The discrepancy is shown on the figure attached on post #41. Mathematica code can be found on post #35.
 
  • #53
S_David said:
Mathematica code can be found on post #35.

Thanks, but I was asking about the Monte-Carlo code for the integration. If you post this code, someone might be able to see a shortcoming in the code, or explain the discrepancy.
 
  • #54
I explained the steps of Monte-Carlo simulations on post # 35 I believe. The rest are just semantics. Monte-Carlo is not for the integration by the way. But rather simulation of the same metric as the integration tries to evaluate. This is the idea behind it; to have two independent methods to evaluate the same quantity. I don't have the code at hand right now, but I will try to post it if necessary.
 
  • #55
S_David said:
Monte-Carlo is not for the integration by the way.

I see. I was under the impression you were comparing the results of some numerical integration technique to a MC integration method. Now that I know there are other, unseen, codes involved somewhere along the way I see no way of relating the results of the numerical integration technique mentioned in the first post to the results of some other simulation involving a MC technique somehow. :(

Good luck!
 
  • #56
S_David said:
Any comment on this? Is it acceptable to say on a scientific article that the small discrepancy in results is due to some inaccuracy in the simulations?
I wouldn't even report the Monte Carlo results. I don't trust them. There are too many unknowns and uncontrolled errors.
 
  • #57
Dale said:
I wouldn't even report the Monte Carlo results. I don't trust them. There are too many unknowns and uncontrolled errors.

But it's a good practice in my field to verify the numerical results. Most reviewers don't follow the mathematical derivations, and judge by the results and the general trend.
 
  • #58
Isn't your whole concern that the Monte Carlo simulation does not verify your result?

In any case, the Monte Carlo is also a numerical result, so how can you use one numerical result to verify another. Since the two methods disagree then there are two possibilities, either you made a mistake in the code or numerical errors are causing the disagreement. If the disagreement is due to numerical errors then the problem is in the Monte Carlo since it does not control numerical errors.
 
  • #59
Dale said:
Isn't your whole concern that the Monte Carlo simulation does not verify your result?

In any case, the Monte Carlo is also a numerical result, so how can you use one numerical result to verify another. Since the two methods disagree then there are two possibilities, either you made a mistake in the code or numerical errors are causing the disagreement. If the disagreement is due to numerical errors then the problem is in the Monte Carlo since it does not control numerical errors.

If the discrepancy is huge or not constant, then yes, I would say there is something wrong definitely. But the discrepancy is very small and constant. By numerical I meant plotting a mathematical equation vs. averaging which is the case in Monte Carlo simulations. Both are two different and independent methods to evaluate the same results. Monte Carlo is a verification in this sense. You are right though, I might have made a mistake. In that case I haven't found it.
 

Similar threads

Replies
13
Views
2K
Replies
4
Views
3K
Replies
1
Views
2K
Replies
3
Views
2K
Replies
34
Views
4K
Replies
5
Views
3K
Replies
8
Views
3K
Back
Top