0
$\begingroup$

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?

$\endgroup$
3
$\begingroup$

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]"]
$\endgroup$
  • $\begingroup$ Thank you very much Anton. I greatly appreciate this help. Much thanks again :) $\endgroup$ – Daniel Berkowitz May 13 '17 at 18:17
  • $\begingroup$ @DanielBerkowitz No problem, good luck. $\endgroup$ – Anton Antonov May 13 '17 at 19:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.