Skip to main content

A Bayesian Inference Pipeline for Modified Gravity

Project description

COSMIX — COSmological Modular Inference eXplorer

DOI

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.4.0 https://github.com/AmeyaKolhatkar/COSMIX.git
cd COSMIX
pip install -e .

Alternatively, a stable archived version is available via Zenodo: DOI

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"
  run_id: "my_model_test_1"

model:
  name: fQ_EHybrid          # LCDM | fQ_Hybrid | fQ_EHybrid | fQ_LSR | fQ_LSR_IDE | fQ_Hybrid_IDE

likelihoods:
  - name: CC                 # Cosmic Chronometers
  - name: DDTB               # DESI DR2 BAO
  - name: PP                 # 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
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
gw GW Standard Sirens (GW170817) LIGO/Virgo
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

  1. Create src/cosmix/theory/MyModel.py inheriting from cosmix.core.CosmologyModelBase.
  2. Implement declare_parameters(), check_physicality(), and get_requirements().
  3. Register it through the Registry.py utility
    from cosmix.core.Registry import cosmix_registry
    
    @cosmix_registry.register_model("MyModel")
    class MyModel(...)
    
  4. Reference it in input.yaml as model: { name: MyModel }.

Adding a New Likelihood

  1. Create src/cosmix/likelihoods/MyLikelihood.py inheriting from cosmix.core.LikelihoodBase_.
  2. Implement declare_parameters(), get_requirements(), and lnlike().
  3. Register it through the Registry.py utility
    from 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_auto mode for emcee sampler is not fully developed. The goal is to implement the auto stop feature found in most Bayesian inference codes like Cobaya.
  • The MetropolisHastings.py sampler 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.toml for 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.0.0},
  doi          = {10.5281/zenodo.19791571},
  url          = {https://doi.org/10.5281/zenodo.19791571}
}

Contact

If there are any issues or suggestions for the code please feel free to contact me at
kolhatkarameya1996@gmail.com


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycosmix-1.4.0.tar.gz (89.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycosmix-1.4.0-py3-none-any.whl (90.4 MB view details)

Uploaded Python 3

File details

Details for the file pycosmix-1.4.0.tar.gz.

File metadata

  • Download URL: pycosmix-1.4.0.tar.gz
  • Upload date:
  • Size: 89.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pycosmix-1.4.0.tar.gz
Algorithm Hash digest
SHA256 0a5ac1b01ac0aad89a16718216dc83bd708558fddae6aa2128eb56762565c593
MD5 24802ecacf0418c572a576896a716d51
BLAKE2b-256 9cc01d4ca7c4656d949c00678bad554fe03c84166d0d66592afe976be4bbb93c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycosmix-1.4.0.tar.gz:

Publisher: publish.yaml on AmeyaKolhatkar/COSMIX

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycosmix-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: pycosmix-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 90.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pycosmix-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e139adbe75c4ae733a717e085071b8257d26eb7bdabd53bd9d13bd52151d1115
MD5 ebb121d1c2cd0f7b165b65a76690662c
BLAKE2b-256 68f04b1ae571d5364f01fa77fd19955c3b470037cefdb63a9adc043e0d83222b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycosmix-1.4.0-py3-none-any.whl:

Publisher: publish.yaml on AmeyaKolhatkar/COSMIX

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page