brinckmann / montepython_public

Public repository for the Monte Python Code
MIT License
93 stars 77 forks source link

Requesting best-fit values and contour plots at certain redshift values. #325

Closed ClaudioNahmad closed 1 year ago

ClaudioNahmad commented 1 year ago

Hey,

I'm running MP_3.5 with {CMB, SNe, BAO} and {SNe, BAO} data. I would like to obtain best-fit values of the parameters at specific redshifts, not just at z=0. My objective is to have both: contour plots and bf-values, at z's similar to the DESI observation redshifts for different tracers (e.g. at z=0.8 to compare with the LRG data, at z=1.1 for ELG data and at z=2.3 for QSOs).

I have mild experience modifying the CLASS code but it seems to me this is not a CLASS issue, but more of a MP issue since it would involve (maybe, i don't know) stopping the chains at certain z and gathering the info there. Im really ignorant on this subject.

I could not find a similar issue here, but please excuse me if someone had asked for something similar before.

Thanks in advance for your answer(s).

-Claudio

brinckmann commented 1 year ago

Hi Claudio,

An option might be to run CLASS through the wrapper with the parameter values inferred by MontePython and ask for the quantities you're interested in at the redshift you're interested in them. Although it seems to me that for a standard cosmology like LCDM, where the evolution of the universe is straightforward, you can compute quantities, e.g. H(z), as a function of redshift if have the bestfit values at z=0. But if you have an extended cosmology then you'll have to think how best to do it.

Also note you might find the mean parameter values the more statistically relevant quantity than bestfit values. If you do want to use bestfit values, you should probably run a minimizer first, to get a more accurate estimate of the bestfit. There are a few good minimizer choices, like BOBYQA or minuit, but we don't have these in the official version yet (we will soon^TM). You can see issue #236 and the github of @alexreevesy for a BOBYQA implementation in MontePython.

Best, Thejs

nnedelko commented 1 year ago

Hi,

In case the issue is still relevant: if the parameters you're interested in can be computed by CLASS as a function of redshift, you can indeed feed your entire chain through the CLASS wrapper line by line to retroactively add them to the chain, then you can analyse this updated chain (don't forget to add the new parameters to the .paramnames and log.param files). Here's an example script adding the Hubble parameter and the angular distance at a range of z, but it works with any parameter defined as a callable function in CLASS. If you have many chains, I recommend running it one chain at a time in a loop like this for i in {1..360};do nohup python drag_loop_a_TDE.py "$i" '220323_TDE_3GBase_sptlens_LSS_ultimate' '2023-03-22_1000000_';echo "$i"; done;, otherwise it tends to eat up memory.

Best regards, Nikita

ClaudioNahmad commented 1 year ago

thanks @brinckmann and @nnedelko! i think i have simplified the issue (in a sense) so i will reformulate it:

Is there a way to tell MP to calculate a certain parameter (e.g. \Omega_b) at a specific redshift (e.g. \Omega_b(z=0.6)) ?

I know that CLASS does this at each MCMC step (since we are talking about background quantities), but doesn't save all those values, for obvious reasons, it justs calculates the -logLike associated with the "final" parameters and keeps on repeating in each step...

Im imagining that one could, in a certain way, define a 'derived' parameter in the .param file, called for example \Omega_b_z0-6 (to say something). Then, in each step, when MP runs CLASS, ask MP to save the parameter, and add it to the list of parameters.

That is the specific thing i'd like to do, since, by that method, such parameter would have a likelihood associated and the contours could be computed as if it were another 'calculated' parameter. Is there a straightforward way to do it? or should i go with what @nnedelko sugested?

I hope my explanation is sufficiently clear. Thanks in advance

ClaudioNahmad commented 1 year ago

Hello, i decided to resolve the issue as Nikita kindly suggested, so i'm closing this issue now.

Thanks for the responses.