montepython_public icon indicating copy to clipboard operation
montepython_public copied to clipboard

Importance sampling

Open wilmarcardonac opened this issue 10 years ago • 8 comments

Dear Benjamin,

We are trying to use importance sampling by using the following command line

python montepython/MontePython.py --conf class.conf -p input.param -o chains/output -m IS --IS-starting-folder chains/input

where chains/input contains previous chains and input.param contains additional experiments to those in the log file found in chains/input. Is it correct or we are doing something wrong ?

We are running MontePython 2.0.5

Thanks in advance,

wilmarcardonac avatar Oct 20 '14 10:10 wilmarcardonac

Everything looks fine. Keep in mind that the likelihood you add should have its minimum of chi2 around a few, otherwise the method will be less precise. Do you experience any problem with the setup? Was the doc unclear on this topic?

baudren avatar Oct 20 '14 11:10 baudren

On a technical note: the correct call (from version 2.0.3) should be

python montepython/MontePython.py run --conf class.conf -p input.param -o chains/output -m IS --IS-starting-folder chains/input

although the old way of invoking MontePython (without the run command) is still supported.

montefra avatar Oct 20 '14 12:10 montefra

True! The transition for people that were used to the previous way will take some time, though. I still forget it sometimes :sweat_smile:

baudren avatar Oct 20 '14 12:10 baudren

Thanks for your answer. The problem seems to be the call of the function

sample.compute_lkl()

in the importance_sampling.py module. The functions recover_new_experiments and translate chain seem to work fine, at least when reading the existing chains. However, somehow when computing the new likelihood, the sampler.compute_lkl() gives unexpected huge values.

We are using mock data, then in principle the contours should overlap. Does the method work only for well converged existing chains is this case ?

I think I have some problem with my browser because I cannot see any documentation for most of last modules in the website... we saw the comments on the source code.

Thanks again,

wilmarcardonac avatar Oct 27 '14 07:10 wilmarcardonac

Ah, I think I know what is going on, @wilmarcardonac

Depending on the likelihood you are adding, you might have a minimum of - log likelihood that is still very high. Hence the difference between the two likelihoods will be large, and will generate very low multiplicity points. I guess that the algorithm then stop to make sense, not because it is broken, but because of the precision of the machine - if the multiplicity hit the 1e-120, I am not sure how Python will behave.

Did you try to analyse anyway the result you obtained from the new chains? Does it seem to make sense?

If not, I can try to look how to push the numerical precision of Python for this specific case. Let me know,

baudren avatar Oct 28 '14 00:10 baudren

Hi Benjamin,

Thanks a lot for your answer.

We are making a test with the fake_planck and the fake_euclid likelihoods. Do you think that a problem like this could arise in that case ? It seems that the minima of these two likelihoods (I mean the -log likelihood) differ by two orders of magnitude...

wilmarcardonac avatar Oct 28 '14 18:10 wilmarcardonac

The problem that can appear is that importance sampling will be not adapted to the problem, i.e. that the posterior distribution will be affected greatly by the addition of the new likelihood.

You should only use Importance sampling for problems of the following form:

  • you did a run with a very constraining experiment, e.g. Planck
  • you want to run now with Planck+H0, H0 being a prior on $H_0$ coming from direct measurement. The latter item will be much less constraining, and therefore the total posterior distribution will not shift much.
  • You can therefore use importance sampling to avoid resampling the parameter space, but using the previously obtained chains.

In your case, Euclid and Planck are both constraining, and the combination might be very different than either of the single ones.

baudren avatar Oct 29 '14 00:10 baudren

Update: it might be that you are encountering an error due to clik behaviour, and a stupid thing on my side. I found a way to fix it, and I will update it on the 2.1 branch. Stay tuned

baudren avatar Oct 29 '14 08:10 baudren