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.0 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.
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 |
|---|---|
LCDM |
Standard ΛCDM |
CPL |
w₀w_aCDM (CPL equation of state) |
MG_muSig |
μ–Σ modified growth on a ΛCDM background (μ₀ = Σ₀) |
fQ_LCDM |
f(Q) with ΛCDM background plus the λ₀√(QQ₀) growth coupling |
fQ_LCDM_Curved |
fQ_LCDM with spatial curvature |
fQ_Hybrid |
f(Q) Hybrid model (analytical solution) |
fQ_EHybrid |
Extended f(Q) Hybrid model (ODE solver) |
fQ_Hybrid_Curved |
f(Q) Hybrid model with spatial curvature |
fQ_LSR |
f(Q) Log-Square-Root model |
fQ_LSR_IDE |
f(Q) LSR with Interacting Dark Energy |
fQ_Hybrid_IDE |
f(Q) Hybrid with Interacting Dark Energy |
fQ_Squared_Curved |
Squared f(Q) model with spatial curvature |
Available Likelihoods
| Key | Dataset | Reference |
|---|---|---|
cosmicchronometers |
Cosmic Chronometers (correlated + uncorrelated) | Moresco et al. |
pantheonplus |
Pantheon+ (SN Ia, no SH0ES prior) | Brout et al. 2022 |
pantheonplusshoes |
Pantheon+SH0ES (SN Ia + H₀ prior) | Brout et al. 2022 |
desidr2bao |
DESI DR2 BAO (full GC combination) | DESI Collaboration 2025 |
rsd |
Redshift Space Distortions (fσ₈) | Various |
rsdwigglez |
RSD compilation with the WiggleZ covariance | Various |
sdssdr16 |
SDSS DR16 BAO, BAO+fσ₈ or RSD (mode option) |
eBOSS Collaboration 2021 |
planckaspriorcamb |
Planck ln(10¹⁰A_s) prior, A_s computed per sample with CAMB | Planck 2018 |
planckasprior |
Deprecated; use planckaspriorcamb |
— |
gw |
GW Standard Sirens (GW170817) | LIGO/Virgo (Test implementation only) |
desy5 |
DES-SN5YR (SN Ia with probabilistic classification) | DES Collaboration |
desdovekie |
DES-Dovekie Likelihood | DES Collaboration |
shoes |
SH0ES H₀ Gaussian prior | Riess et al. |
trgb |
TRGB H₀ prior | Freedman et al. |
holicow |
H0LiCOW H₀ prior | Wong et al. |
compressedcmb |
Compressed CMB | Z. Zhai and Y. Wang |
egstatistic |
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.0},
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
Metadata
Release files for pycosmix 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pycosmix-1.5.0.tar.gz | 89.3 MB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pycosmix-1.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 179.9 MB
Release files / pycosmix-1.5.0.tar.gz
| Download URL | pycosmix-1.5.0.tar.gz |
|---|---|
| Size | 89.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62d89960c679500b4b2090ff38c1a581e13506e9abadc2e66d1995db6caf4060
|
|
BLAKE2b-256 checksum How to use checksums |
7b737bfd25e621f012c52c1087e686b6806f41542e07e22fe2184a2d66e128fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logRelease files / pycosmix-1.5.0-py3-none-any.whl
| Download URL | pycosmix-1.5.0-py3-none-any.whl |
|---|---|
| Size | 90.6 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d02b77e89795e47eecf512e8c53d0fc46bc45f70be5cdd050533abcf77a61da
|
|
BLAKE2b-256 checksum How to use checksums |
c11559e8617c67483cad9807d763081e2472dbc33cf2cded41e9cfffec995ad8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logSecurity for pycosmix 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pycosmix-1.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.