Calculating sigma8 in cobaya

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Post Reply
Alex Krolewski
Posts: 11
Joined: November 07 2019
Affiliation: UC Berkeley

Calculating sigma8 in cobaya

Post by Alex Krolewski » November 12 2019

I'm using cobaya to sample over As and would like to additionally output sigma8 in my chains. But I'm having some difficulty doing this. I tried "get_sigma8" in pycamb as in boxes 8 and 9 here:

https://camb.readthedocs.io/en/latest/CAMBdemo.html

Running the following code:

model = get_model(info)
theory = model.likelihood.theory
pars = theory.camb.CAMBparams()
theory.camb.get_results(pars)

I got CAMBValueError: Parameter values not set on the last line.

Is there perhaps another method to get sigma8?

Omar Darwish
Posts: 11
Joined: October 01 2019
Affiliation: unige

Re: Calculating sigma8 in cobaya

Post by Omar Darwish » November 12 2019

To put sigma8 in your chains you just add it as a derived parameter in the info dictionary:

params = odict([
["logAs", {"prior": {"min": lnAs_min, "max": lnAs_max}, "ref": {"dist": "norm", "loc": lnAs_central, "scale": 1.67162852e-02}, "proposal": 1.67162852e-02}],.......
["As", {"value": lambda logAs: 1e-10*np.exp(logAs), "latex": r"A_s"}],
["sigma8", {"derived": True, "latex": r"\sigma_8"}]])

(....... represents other parameters you want to put)

Then in the info:

info = {
"likelihood": .....,
"theory": {"camb": {"extra_args": {"accurate_massive_neutrino_transfers": True, "redshifts": [0.], "nonlinear": True, "kmax": 10., "dark_energy_model": "ppf", "WantTransfer": True}}},
"params": params,
"sampler": {"evaluate": {None}}, #{"mcmc": {"burn_in": 100, "max_samples": 20000, "max_tries": 400, "learn_proposal": True, "covmat": chains_dir+starting_covmat}},
"timing": True,
"resume": True,
#"debug": True,
"output": .....}


where "redshifts" are the redshifts where you want to calculate sigma8.

This is how I've done it. I do not know if there are other ways, but from what I understood cobaya developers want to you use the functions that they give you to get parameters, without accessing specific attributes of the theory.

Let me know if it is not clear!

Alex Krolewski
Posts: 11
Joined: November 07 2019
Affiliation: UC Berkeley

Re: Calculating sigma8 in cobaya

Post by Alex Krolewski » November 19 2019

Thank you, this solved my problem!

Post Reply