JohannesBuchner / PyMultiNest

Pythonic Bayesian inference and visualization for the MultiNest Nested Sampling Algorithm and PyCuba's cubature algorithms.
http://johannesbuchner.github.io/PyMultiNest/
Other
194 stars 88 forks source link

unit cube prior #221

Closed pkuxjw closed 1 year ago

pkuxjw commented 1 year ago

According to the document, the prior cube should be unit. However, when I print these prior parameters, some of them are larger than 1. I am confused about this. Many thanks!

JohannesBuchner commented 1 year ago

Maybe you modified the array? Show the code

rpoleski commented 1 year ago

You probably print the values in your own space, which is not unit cube. Please provide MWE.

pkuxjw commented 1 year ago
vpar = np.array([[0,4095],[0,4095],[0,30],[-2,1]])
def prior(cube,ndim,nparams):
      print(cube[-1])
      for i in range(nparams):
            cube[i] = vpar[i,0]+cube[i]*(vpar[i,1]-vpar[i,0])
      for i in range(args_i[1]):
           cube[i] = int(cube[i])  
      cube[-1] = np.power(10,cube[-1])

when I run the code, it present a problem of 'overflow encountered in power '.

rpoleski commented 1 year ago

Please use indentation and code specifier here. Please provide full code. The current one cannot be re-run by readers. Are you sure it's range(args_i[1]) in the second loop? If so, then args_i[1] has to be provided. I think you can diagnose your problem without PyMultiNest.

pkuxjw commented 1 year ago

Please use indentation and code specifier here. Please provide full code. The current one cannot be re-run by readers. Are you sure it's range(args_i[1]) in the second loop? If so, then args_i[1] has to be provided. I think you can diagnose your problem without PyMultiNest.

sorry, I did not notice the form problem. My problem is why some values of cube[-1] is larger than 1. Isn't it a unit cube prior?

vpar = np.array([[0,4095],[0,4095],[0,30],[-2,1]])
def prior(cube,ndim,nparams):
     print(cube[-1])
     for i in range(nparams):
           cube[i] = vpar[i,0]+cube[i]*(vpar[i,1]-vpar[i,0])
     for i in range(2):
           cube[i] = int(cube[i])
     cube[-1] = np.power(10,cube[-1])]
JohannesBuchner commented 1 year ago

Well, you are modifying it in the line cube[i] = vpar[i,0]+cube[i]*(vpar[i,1]-vpar[i,0]) since it loops i from 0 to nparams-1 (which is the -1 entry)