joezuntz / cosmosis

Other
22 stars 16 forks source link

Adding prior for derived parameters (parameters not sampled in) #85

Closed margaret-ikape closed 1 year ago

margaret-ikape commented 1 year ago

Hi, when I run cosmosis, I do a computation that I write to the chains, but I would like to add a prior on this parameter. I tried including the parameter name under the [cosmological_parameters] in the priors ini file but it appears the prior was ignored. Is there a way to include a prior on such parameter?

Thank you!

joezuntz commented 1 year ago

Hi @margaret-ikape - right, we don't currently support priors on derived parameters. I can have a look at adding that; it's a little complicated because we compute the priors before the likelihoods in order to fast-reject some samples. There would be edge cases where it would never work like the apriori sampler.

If you do not need the Bayesian evidence then you can instead include the prior as part of the likelihood, and it will have the same effect. You can just add a new likelihood for it.

margaret-ikape commented 1 year ago

Thanks for your reply @joezuntz. I'll give your suggestion a try and explore other options and get back to you.

margaret-ikape commented 1 year ago

Hi @joezuntz

I hope you are well. I tried to include a prior on the derived parameter by modifying the posterior after weighting with the prior, but this hasn’t worked as I imagined (I may have done something wrong). Would you have some time to look at adding in a prior?

Thanks, Margaret

joezuntz commented 1 year ago

Hi @margaret-ikape

I'm just back from leave now, and have had a think about this. I don't think it will work cleanly, so instead I think you need to add these constraints in the likelihood, or re-paramatrize. You could also re-weight samples at the end of the chain, that would work too. So I'll close this for now.

Cheers, Joe