In this my first time running cobaya for a cosmological likelihood. I want to get the plot Omega_m vs Omega_dark energy. I am goint to describe my steps:

I got my measured Cls from a cmb-map done by synfast with the CAMB input.

My cosmological parameters for CAMB are pars = camb.set_params(H0=67.5, ombh2=0.0221, omch2=0.121, tau=0.06, As=2.09e-9, ns=0.963, halofit_version='mead', lmax=2500). Then. I prepare my likelihood and dictionary,

Code: Select all

```
from cobaya.likelihood import Likelihood
import numpy as np
class MyLikelihood(Likelihood):
def initialize(self):
"""
Prepare any computation, importing necessary code, files, etc.
Here, we load the Cls data.
"""
# Load your data file, for example, experimental Cls
self.data = np.loadtxt("Cls") # Replace "Cls.txt" with your actual file
# If you have associated errors, load them similarly (uncomment below if needed)
# self.errors = np.loadtxt("sigma.txt")
def get_requirements(self):
"""
Return dictionary specifying quantities calculated by a theory code.
Here, we request C_l^{tt} (temperature) up to lmax = 2552.
"""
return {'Cl': {'tt': 2554}} # You can request other spectra like 'ee', 'te' if needed.
def logp(self, **params_values):
"""
Compute the log-likelihood given a set of parameter values.
"""
# Get the theoretical Cls from the theory code (e.g., CAMB or CLASS)
cls = self.provider.get_Cl(ell_factor=True)
# Calculate chi-squared: sum of squared differences between data and theory Cls
chi2 = np.sum((self.data - cls['tt'][2:]) ** 2) # Skipping ell=0,1 as usual
# Return the log-likelihood (-0.5 * chi2)
return -0.5 * chi2
info = {
"likelihood": {
"My_custom_likelihood": MyLikelihood
},
# Theory block for CAMB
"theory": {
"camb": {
"extra_args": {
"lmax": 2554,
"lens_potential_accuracy": 0
}
}
},
# Parameters
"params": {
"ombh2": {
"prior": {"min": 0.005, "max": 0.1},
"ref": {
"dist": "norm",
"loc": 0.0221,
"scale": 0.0001
},
"proposal": 0.0001,
"latex": r"\Omega_b h^{2}"
},
"omch2": {
"prior": {"min": 0.001, "max": 0.99},
"ref": {
"dist": "norm",
"loc": 0.121,
"scale": 0.001
},
"proposal": 0.0005,
"latex": r"\Omega_c h^{2}"
}
},
# Sampler
"sampler": {
"mcmc": {
"Rminus1_stop": 0.001,
"max_tries": 10000
}
},
# Output and resuming settings
"resume": False # Disable resuming
}
updated_info, sampler=run(info)
camb] `camb` module loaded successfully from /home/akozameh/miniconda3/envs/CMB/lib/python3.10/site-packages/camb
[mcmc] Getting initial point... (this may take a few seconds)
[model] *ERROR* Could not find random point giving finite posterior after 10000 tries.
```

Thanks in advance!