Skip to content
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

Record individual likelihood in chain files #107

Open
tririver opened this issue Dec 5, 2017 · 1 comment
Open

Record individual likelihood in chain files #107

tririver opened this issue Dec 5, 2017 · 1 comment

Comments

@tririver
Copy link

tririver commented Dec 5, 2017

Hi everybody,

Is there an option to print individual likelihoods in chain files? For example, in CosmoMC, if both CMB and BAO data are used, in the chain files there are columns for chi2_CMB* and chi2_BAO* respectively. Would MontePython have this feature?

Thanks in advance :)

@brinckmann
Copy link
Contributor

Hi,

This is not currently implemented. We have the option --display-each-chi2 when using 'run', which you can e.g. use along with -f 0 to print the -loglkl and effective chi2 for each likelihood in the best fit.

If this is not enough, in order to have it output in the chain, this should be possible, but it will take some modifications of (at least) montepython/mcmc.py, montepython/io_mp.py and montepython/sampler.py.

I think the way I would do it is I would set the compute_lkl function in sampler.py to return the current loglkl along with the full information loglkl information for each likelihood following the approach of the --display-each-chi2 option in the same function.

This will break montepython/mcmc.py, which uses the loglkl output from sampler.py by calling sampler.compute_lkl, as well as any other place the code uses this. So what you want to do is you want a 'loglkl' variable that functions as currently, and a 'loglkl_all' that contains the full information of total_loglkl and each_loglkl. You then need to pass loglkl_all' to all instances using io_mp.print_vector.

Finally, you need to make sure the print_vector function in io_mp.py correctly processes the array loglkl_all, this is just simple string formatting.

I can't promise this won't introduce additional bugs, but hopefully you can figure out how to handle them if it does. Otherwise, you can ask again. If you get it to work, I would appreciate if you reply with your final solution and I will consider including it in the public version. Thanks!

Best,
Thejs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants