0

I'm using this package https://github.com/joshburkart/mathematica-mcmc and am trying to evaluate the following:

  MCMC[(5 Log[ 1.015` NIntegrate[1.3636363636363636`*^26/Sqrt[
 a + b (1 + z)], {z, 0, 0.015`}]])/ Log[10], {{a, .7, .01, Real}, {b, 0, .01, Real}}, 2]

and I get The integrand 1.36364*10^26/Sqrt[a+b (1+z)] has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,0.015`}}. >>

In the end it does spit out a value for the parameters a and b. However because of that error message I'm not so confident that those are the right values. Can anyone tell how I can fix MCMC package so this error doesn't come up anymore when I have NIntegrate in my likelihood?

  • 1
    Possible duplicate: https://mathematica.stackexchange.com/questions/18393/what-are-the-most-common-pitfalls-awaiting-new-users/26037#26037 – Michael E2 May 13 '17 at 20:25

1 Answers1

4

If you define a numerical arguments function for the NIntegrate expression inside MCMC[...] then no messages are given:

In[1]:= Import["https://raw.githubusercontent.com/joshburkart/\
mathematica-mcmc/master/mcmc.m"]

In[2]:= F[a_?NumberQ, b_?NumberQ] := 
  NIntegrate[
   1.3636363636363636`*^26/Sqrt[a + b (1 + z)], {z, 0, 0.015`}];

In[3]:= MCMC[(5 Log[1.015` F[a, b]])/
  Log[10], {{a, .7, .01, Real}, {b, 0, .01, Real}}, 2]

Out[3]= "MCMCResult"[{a -> 0.701463, 
  b -> 0.000967457}, "\[LeftSkeleton]2\[RightSkeleton]"]
Anton Antonov
  • 37,787
  • 3
  • 100
  • 178