COSMIX — COSmological Modular Inference eXplorer
COSMIX is a modular, likelihood-driven Bayesian inference framework for testing modified gravity and dark energy cosmological models against observational data. It supports multiple samplers (emcee, Dynesty, PolyChord) and a growing library of likelihoods (CC, Pantheon+, DESI DR2 BAO, RSD, GW standard sirens, DES-SN5YR).
Installation
From PyPI
pip install pycosmix
From source (for development)
git clone https://github.com/AmeyaKolhatkar/COSMIX.git
cd COSMIX
pip install -e .
For a specific tagged release (recommended for reproducible research):
git clone --branch v1.5.1 https://github.com/AmeyaKolhatkar/COSMIX.git
cd COSMIX
pip install -e .
Alternatively, a stable archived version is available via Zenodo:
Optional: build documentation locally
pip install -e ".[docs]"
Optional: PolyChord nested sampler
Warning! The PolyChord nested sampler has not been tested extensively. If you still wish to use it, do
pip install -e src/cosmix/data/PolyChordLite
On Windows you will need WinLibs/MinGW with gfortran
and ensure <mingw64>/bin is on your PATH (or set POLYCHORD_DLL_DIR).
Quick Start
1. Configure a run
Edit input.yaml (or copy it) to specify the model, datasets, sampler, and output options:
run:
name: "MyModel_test"
run_id: "my_model_test_1"
model:
name: MyModel # LCDM | fQ_Hybrid | fQ_EHybrid | fQ_LSR | fQ_LSR_IDE | fQ_Hybrid_IDE
likelihoods:
- name: cosmicchronometers # Cosmic Chronometers
- name: desidr2bao # DESI DR2 BAO
- name: pantheonplus # Pantheon+ (SN Ia)
- name: rsd # Redshift Space Distortions
sampler:
name: dynesty # emcee | dynesty | polychord
init:
nlive: 500
outputs:
plots:
trace: true
corner: true
residual: true
archive: true
2. Run
Once installed, the cosmix command is available on your PATH:
cosmix input.yaml
Results are saved to runs/<run_id>/ including the chain, diagnostics,
information criteria (AIC, BIC, DIC), and publication-quality figures.
3. Override parameters (optional)
Every parameter declared by the model or a likelihood can be changed per run in a
parameters: block, without editing code:
parameters:
lambda0: {fixed: 1.5} # fix a free parameter
rd: {fixed: 147.05} # re-value an already fixed one
# or {free: true, prior: {type: uniform, low: 130, high: 160}}
M: {fixed: -19.25} # fix a marginalized one
# or {free: true} / {marginalized: true}
H0: {prior: {type: uniform, low: 60, high: 80}, proposal: 0.3}
omega_b: {prior: {type: gaussian, mean: 0.02237, sigma: 0.00015}}
Keys: fixed, free, prior (implies free), proposal, marginalized. fixed,
free/prior and marginalized are mutually exclusive. Unknown parameter names or keys stop
the run with a suggestion. The applied settings are saved in each run’s manifest.yaml.
Project Structure
COSMIX/
├── pyproject.toml # Package metadata, dependencies, build config
├── input.yaml # Template run configuration
├── src/
│ └── cosmix/
│ ├── run_cosmix.py # Main entry point — reads input.yaml and runs the pipeline
│ ├── Constants.py # Physical constants (c, Omegar0)
│ ├── core/ # Framework internals (pipeline, parameter management, caching)
│ ├── theory/ # Cosmological models (LCDM, f(Q) variants)
│ │ ├── Solvers_/ # ODE/root solvers (RK4, analytical, Numba JIT)
│ │ └── Background_/ # Background state layout
│ ├── likelihoods/ # Observational likelihoods
│ ├── samplers/ # Sampler wrappers (emcee, Dynesty, PolyChord)
│ ├── drivers/ # Multi-chain convergence strategies
│ ├── postprocessing/ # Results, diagnostics, visualization, archival
│ │ └── Archive_/ # Run manifest, serialization (YAML/JSON/NumPy)
│ └── data/ # Observational data files
│ └── PolyChordLite/ # Bundled PolyChord source (build separately)
└── runs/ # Output directory (gitignored contents)
Available Models
Key |
Description |
|---|---|
|
Standard ΛCDM |
|
w₀w_aCDM (CPL equation of state) |
|
μ–Σ modified growth on a ΛCDM background (μ₀ = Σ₀) |
|
f(Q) with ΛCDM background plus the λ₀√(QQ₀) growth coupling |
|
|
|
f(Q) Hybrid model (analytical solution) |
|
Extended f(Q) Hybrid model (ODE solver) |
|
f(Q) Hybrid model with spatial curvature |
|
f(Q) Log-Square-Root model |
|
f(Q) LSR with Interacting Dark Energy |
|
f(Q) Hybrid with Interacting Dark Energy |
|
Squared f(Q) model with spatial curvature |
Available Likelihoods
Key |
Dataset |
Reference |
|---|---|---|
|
Cosmic Chronometers (correlated + uncorrelated) |
Moresco et al. |
|
Pantheon+ (SN Ia, no SH0ES prior) |
Brout et al. 2022 |
|
Pantheon+SH0ES (SN Ia + H₀ prior) |
Brout et al. 2022 |
|
DESI DR2 BAO (full GC combination) |
DESI Collaboration 2025 |
|
Redshift Space Distortions (fσ₈) |
Various |
|
RSD compilation with the WiggleZ covariance |
Various |
|
SDSS DR16 BAO, BAO+fσ₈ or RSD ( |
eBOSS Collaboration 2021 |
|
Planck ln(10¹⁰A_s) prior, A_s computed per sample with CAMB |
Planck 2018 |
|
Deprecated; use |
— |
|
GW Standard Sirens (GW170817) |
LIGO/Virgo (Test implementation only) |
|
DES-SN5YR (SN Ia with probabilistic classification) |
DES Collaboration |
|
DES-Dovekie Likelihood |
DES Collaboration |
|
SH0ES H₀ Gaussian prior |
Riess et al. |
|
TRGB H₀ prior |
Freedman et al. |
|
H0LiCOW H₀ prior |
Wong et al. |
|
Compressed CMB |
Z. Zhai and Y. Wang |
|
Eg Statistic |
G. Alestas et al. |
Adding a New Model
Create
src/cosmix/theory/MyModel.pyinheriting fromcosmix.core.CosmologyModelBase.Implement
declare_parameters(),check_physicality(), andget_requirements().Register it through the
Registry.pyutilityfrom cosmix.core.Registry import cosmix_registry @cosmix_registry.register_model("MyModel") class MyModel(...)
Reference it in
input.yamlasmodel: { name: MyModel }.
Adding a New Likelihood
Create
src/cosmix/likelihoods/MyLikelihood.pyinheriting fromcosmix.core.LikelihoodBase_.Implement
declare_parameters(),get_requirements(), andlnlike().Register it through the
Registry.pyutilityfrom cosmix.core.Registry import cosmix_registry @cosmix_registry.register_likelihood("MyLikelihood") class MyLikelihood(...)
Under Development
The PolyChord sampler has not been fully tested yet. User discretion is adviced.
The
multi_automode foremceesampler is not fully developed. The goal is to implement the auto stop feature found in most Bayesian inference codes likeCobaya.The
MetropolisHastings.pysampler is premature. Avoid using it for serious projects.
Coming Soon
Full
CAMB-based CMB power spectrum likelihoods (preliminary interface already in place).
Requirements
Python ≥ 3.10
See
pyproject.tomlfor the full list of dependencies.A Fortran compiler (
gfortran) is only needed if building PolyChordLite.
License
This project is licensed under the GNU General Public License v3.0. See LICENSE for details.
Citation
If you use COSMIX in your research, please cite the following:
@software{kolhatkar_cosmix_2026,
author = {Kolhatkar, Ameya},
title = {{COSMIX: Cosmological Modular Inference Explorer}},
year = 2026,
publisher = {Zenodo},
version = {v1.5.1},
doi = {10.5281/zenodo.19791571},
url = {https://doi.org/10.5281/zenodo.19791571}
}
AI Assistance
Parts of the code and documentation were written with the assistance of Claude Code (Anthropic). All the design decisions, physics and validation are the author’s, and all the code was reviewed by the author.
Contact
If there are any issues or suggestions for the code please feel free to contact me at
kolhatkarameya1996@gmail.com