-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dump_callback etc. #18
Comments
PS: I suppose I could add a routine to the prior or likelihood functions to do this - is that the best way forward? |
Yes, the dump_callback would be the right way to do it. However, since I have not used it before, the implementation is not really tested. You will receive nsamples, nlive, n, and then what is in the postdist file as a 2-dimensional double array (nsamples x n). I would be happy if you could test it. The benefit of writing to a pdf file and watching it with a viewer is that the output is permanent (does not go away if your code crashed), and that you are independent from graphical displays. The second option is progressPrinter, which just reads the MultiNest output every so often. Note that there can be a partial output and so it might fail once in some read-outs, but it should be stable against that and just try again. You can build on e.g. ProgressPrinter, and read self.live using numpy.loadtxt The third option is as you say, just output on every evaluation. This will probably make your code very slow, because also points that will be rejected are used then. |
Thanks for the speedy reply. Happy to test - I want to try dump_callback - pymultinest.run(..., dump_callback=func) func(???): What would be an example of the syntax for ProgressPrinter (sounds a bit |
You can always start with def func(*args):
print args but in this case, using ctypes to convert the array def func(nsamples, nlive, n, postdist):
print nsamples, nlive, n, postdist
arr_type = ((ctypes.c_float * nsamples) * n)
values = arr_type(postdist)
print nsamples, nlive, n, values |
something along those lines anyways, you will have to try around a bit |
Thanks - so I get an error with dump_wrapper:
File I tried setting the name of func to dump_wrapper, but get the same. |
That should be dump_callback instead of dump_wrapper |
Now I get (1000 live points): Acceptance Rate: 0.847836 Could this take a while to debug? :-S |
Try as a starting point def func(nsamples, nlive, n, postdist):
print 'python dumper callback called!'
sys.stdout.flush()
print nsamples, nlive, n
sys.stdout.flush() |
Here you go (n_iter_before_update=10): generating live points |
In the multinest bridge try simplifying
to
and
to
|
Same problem: Starting MultiNest |
Try putting a few printf in before the p.Dumper() call
with
in run.py |
*nsamples, *nlive and n are fine, so the problem must be with postdist (and |
You can check by replacing postdist in the p.Dumper call by NULL for the moment. |
Hi - I'm trying to pass the current sample values to a python wrapper to plot them using pyplot as MultiNEST runs, rather than using show as in your demo script, because I hope it's more efficient than using show -> pdf.
I have a function to do the plot update, but I can't figure out how to extract the current sample values. Should I use dump_callback, or progressPrinter, or go via an ascii file..? How should I do that if so?
Thanks v much.
The text was updated successfully, but these errors were encountered: