cosmodesi / desilike

BSD 3-Clause "New" or "Revised" License
19 stars 14 forks source link

how to change parameters in fisher_example.ipynb? #3

Closed pmcdonal closed 1 year ago

pmcdonal commented 1 year ago

Trying to compute the "CMB Fisher", I got as far as trying

for p in cosmo.all_params.select(basename=['tau_reio']): p.update(fixed=False)

for p in cosmo.all_params.select(basename=['omega_ncdm']): p.update(fixed=False) but the fisher = Fisher(likelihood) crashes in either case with ParameterPriorError: Provide parameter limited reference distribution or proposal

I'm wondering what this Planck "Fisher" is anyway... it looks like it could be 2nd derivatives of lnL at some point? but the actual lnL of real data? Are there nuisance parameters in Planck likelihood that need to be marginalized over? (of course tau generally should be) (I started looking at this just now because I noticed the nominal rms-from-chains neutrino mass constraint from Planck alone is actually quite a bit smaller than expected from my old Fisher calculations. I am wondering if this is just that these chains are kind of weird for this parameter because trapped against zero bound... or is it something else...)

adematti commented 1 year ago

Fisher needs typical parameter variation ranges to estimate derivatives with finite-differentiation. This can be provided through e.g.: likelihood.all_params['m_ncdm'].update(ref={'dist': 'norm', 'loc': 0.06, 'scale': 0.12}, fixed=False)

Thanks to your post I updated reference distributions for tau_reio and m_ncdm, so you should not have this issue anymore. However, I haven't really been able to get reliable Fisher forecasts for m_ncdm starting from Planck likelihoods... nor for w0, wa, Omega_k. My guess is the Planck posterior is too far from Gaussian in the region I estimated the Fisher matrix. In the end, it may just be easier and safer to Taylor expand the Cl's, as shown at the end of the notebook fisher_planck.ipynb (which now gathers tests of Fisher estimation from Planck likelihoods).

pmcdonal commented 1 year ago

Inevitably I will need to experiment myself, but I wonder what it means "reliable"?... generally you expect 2nd derivative to depend on position, but if other data limits you to a range in which the joint distribution is Gaussian, it can only be the 2nd derivative there that matters (along with 1st derivative of course to give pull). Anyway, it is great to have all these options to experiment.

pmcdonal commented 1 year ago

It is hard for me to figure out what to do to change what (e.g., derivative step), but at some level that is probably unavoidable... there is a learning curve...

adematti commented 1 year ago

help(Fisher), looking at ref_scale argument, may be helpful? (If not, I'll update the doc). If you'd like to change the step for a specific parameter, you can do it by updating its reference distribution, as above. (I'm in a big rush, trying to finish up basic documentation, while trying to allow some to do useful stuff with the code, sorry...)

pmcdonal commented 1 year ago

I found you need to change "proposal" number for specific parameter... (after trying reference.scale)

adematti commented 1 year ago

I guess I should fix that :), and find a clearer default...