0
$\begingroup$

I’m currently getting to grips with the AdaptiveMonteCarlo method in the NIntegrate function. I’ve been using the sub-method MonteCarloRule, however I’m unsure from reading the Mathematica documentation exactly how the option Points (for this sub-method) actually works. Suppose for example I have the following integral $$\int_{0}^{\pi}\sin(x)dx $$ Then using NIntegrate I have

NIntegrate[Sin[x], {x,0,Pi}, Method->{“AdaptiveMonteCarlo”, Method->{“MonteCarloRule”, “Points”->5}, “MaxRecursion”->200}, AccuracyGoal->5, PrecisionGoal->5]

Now, I realise that I could simply use Integrate on this integral and get an exact result, but I wanted to choose a relatively simple analytic integral as practise.

Using Points->5 gives a pretty accurate result, but does specifying Points->5 mean that NIntegrate only uses 5 points in its Monte Carlo routine? I’m assuming there must be more to it than that otherwise I wouldn’t expect the result to be so close to the true result.

Any help would be much appreciated.

$\endgroup$
  • $\begingroup$ See this answer to a similar question "Monte Carlo integration with random numbers generated from a Gaussian distribution". $\endgroup$ – Anton Antonov Oct 9 '17 at 18:46
  • $\begingroup$ @AntonAntonov Thanks for the link. I’ve had a read through your answer, but I’m still unsure as to what Points does?! Is it related to PointGenerator? $\endgroup$ – user35305 Oct 9 '17 at 19:14
  • $\begingroup$ Points specifies the number of sampling points in a single rule application. The point generator uses that option value. $\endgroup$ – Anton Antonov Oct 9 '17 at 19:27
  • $\begingroup$ @AntonAntonov So is the example I gave literally only using 5 sample points to calculate the integral? $\endgroup$ – user35305 Oct 9 '17 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.