## Cobaya and CLASS: How do you set list parameters for CLASS through Cobaya

Use of Cobaya. camb, CLASS, cosmomc, compilers, etc.
Tanvi Karwal
Posts: 11
Joined: April 10 2020
Affiliation: University of Pennsylvania

### Cobaya and CLASS: How do you set list parameters for CLASS through Cobaya

Hello!

CLASS run for a cosmology using a .ini file takes input for certain parameters through a comma-separated list. Eg.

Code: Select all

m_ncdm = 0.04, 0.04, 0.04

How does Cobaya pass such "list parameters" to CLASS? I'm not seeing anything in the theories/classy/classy.py code for Cobaya to interface with CLASS and set list parameters. I'm currently trying to modify theories/classy/classy.py myself to include such a feature, but if there's already a way to do this, please let me know!

Ultimately, I want to run a sampler individually varying each entry in the list. So, eg. m_ncdm[0], m_ncdm[1] and m_ncdm[2] are independently varied through coabaya for say an MCMC.

Thank you!
Tanvi

Kris Pardo
Posts: 3
Joined: November 30 2020
Affiliation: Jet Propulsion Lab

### Re: Cobaya and CLASS: How do you set list parameters for CLASS through Cobaya

Hi Tanvi,

Did you ever solve this issue? I'm having the same problem and haven't found a solution anywhere.

Thanks,
Kris

Tanvi Karwal
Posts: 11
Joined: April 10 2020
Affiliation: University of Pennsylvania

### Re: Cobaya and CLASS: How do you set list parameters for CLASS through Cobaya

Hi Kris,

Yep. I didn't realise there was already a built-in solution. Here's an example with neutrino masses taken from the cobaya github (where I raised this issue also) by Lukas Hergt:

Code: Select all

m1:
prior:
min: 0
max: 1
drop: true
m2:
prior:
min: 0
max: 1
drop: true
m3:
prior:
min: 0
max: 1
drop: true
m_ncdm:
value: 'lambda m1, m2, m3: str(m1) + "," + str(m2) + "," + str(m3)'
derived: false
Note that the "drop"s are important otherwise class will try (and fail) to read your parameters m1, m2, m3 and the cobaya run will fail.
The "derived: false" tells cobaya that the parameter needs to be passed to class (although I expect derived: false should be the default anyway).

The link to the issue also includes my code to modify cobaya if you'd prefer to pass parameters as in MontePython, with m__1, m__2, m__3 and so on. The code then internally parses it to match class input. I prefer the solution above more than my own code though.

Hope that helps!

Best,
Tanvi

Kris Pardo
Posts: 3
Joined: November 30 2020
Affiliation: Jet Propulsion Lab

### Re: Cobaya and CLASS: How do you set list parameters for CLASS through Cobaya

Hi Tanvi,

Thank you so much! This worked perfectly.

Best,
Kris