JohannesBuchner / UltraNest

Fit and compare complex models reliably and rapidly. Advanced nested sampling.
https://johannesbuchner.github.io/UltraNest/
Other
153 stars 30 forks source link

ReactiveNestedCalibrator dos not work well #145

Open Lowerce opened 2 months ago

Lowerce commented 2 months ago

Description

I follow the command recommended in ReactiveNestedCalibrator. But it seems nothing output.

What I Did

sampler = ReactiveNestedCalibrator(my_param_names, my_loglike, my_transform) 
sampler.stepsampler = SliceSampler(nsteps=10, generate_direction=region_oriented_direction)
sampler.run(min_num_livepoints=400)
JohannesBuchner commented 2 months ago

That is very strange! Is this in a python script or a notebook? Can you rerun it from scratch?

Lowerce commented 2 months ago

That is very strange! Is this in a python script or a notebook? Can you rerun it from scratch?

In a python script. The corresponding one could work well:

sampler = ReactiveNestedSampler(my_param_names, my_loglike, my_transform)
sampler.stepsampler = SliceSampler(nsteps=10, generate_direction=region_oriented_direction)
sampler.run(min_num_livepoints=400)

How could I "return it from scratch"? I would like to try. ReactiveNestedCalibrator seems behavior different with ReactiveNestedSampler for I can't get the return value of sampler.run from ReactiveNestedCalibrator. It will return an <generator object ReactiveNestedCalibrator.run at 0x1467de3c0>.

By the way, the plot method implemented in ReactiveNestedCalibrator could not work well too. The following issue is raised:

self.sampler.stepsampler.plot(os.path.join(self.sampler.logs['plots'], 'stepsampler.pdf'))
AttributeError: 'ReactiveNestedCalibrator' object has no attribute 'sampler'
JohannesBuchner commented 2 months ago

I'm quite confused. if you call run() then you should at least get to the first print here: https://github.com/JohannesBuchner/UltraNest/blob/master/ultranest/calibrator.py#L97

shiningsurya commented 2 months ago

sorry for interjecting here, this is something i also faced.

ReactiveNestedCalibrator returns generator of list of [nstep, result]. Only when you access, the actual sampling is performed.

i am running it like

for nstep, results in sampler:
    print(f" {nstep:d}", results, sep='\n')