MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: NIntegrate with AdaptiveMonteCarlo gives different results

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123345] Re: NIntegrate with AdaptiveMonteCarlo gives different results
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Fri, 2 Dec 2011 07:21:55 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

On 12/1/11 at 8:03 AM, fuchi8 at tiscali.it (valentina) wrote:

>Hello everybody, I am dealing with a three dimensional integral and
>I am using NIntegrate. Searching the web I found out that the best
>method is the AdaptiveMonteCarlo, which also speed up the
>calculation. this is the integral, no particular singular points:

>test[d_] := (0.5  NIntegrate[(compnx[x, y, z, d] +
>compny[x, y, z, d] + compnz[x, y, z, d]), {z, -R - d/2, R + d/2},
>{x, -R, R}, {y, -R, R}, Method -> "MultiDimensionalRule"]*hc) //
>Timing

>so I want to calculate it for different values of the parameter d,
>but for example if I successively calculate it for d=4 i get two
>different results which differs of about 30-50 MeV.

>Does anyone know if it is a bug or how could I fix it?

You have not posted code for the function compnx. So, I will
have to speculate as to the source of the problem.

Mathematica caches results from computations for a variety of
algorithms. And the next evaluation makes use of the cached
results from the previous calculation. Mathematica also has
default time constraints on algorithms that can run for long
times such as integration. The combined effect cached
information and time constraints is that a second calculation
can be different than the first.

There are a few ways to check on my speculation above.

=46irst, you can use ClearSystemCache[] between the two
computations. This will clear cached information and should make
the second computation agree with the first.

Another possibility would be to add

TimeConstraint->some large value

If the my speculation is correct, a large enough value should
cause both computations to be the same as the second result.

Also, I see in the subject of your post you comment about
AdaptiveMonteCarlo integration. Yet your code specifies the
method to use as MultiDimensionsalRule. I don't believe
specifying the method as you've done in your code actually does
MonteCarlo sampling. At least that is the impression I get when
reading tutorial/NIntegrateOverview.




  • Prev by Date: Re: Laplace equation with gradient boundary conditions
  • Next by Date: Re: Problem with Coding for Box Whisker Chart
  • Previous by thread: Re: NIntegrate with AdaptiveMonteCarlo gives different results
  • Next by thread: Re: problem in minimization of a matrix