Skip to content

PhD-Brown/xi-dark-energy-bao-mcmc

Repository files navigation

🌌 Xi Dark Energy BAO MCMC

Exploratory Bayesian comparison of ΛCDM, CPL and an oscillating dark-energy equation of state

using Pantheon+SH0ES supernovae and DESI DR2 BAO


Python License Status Method Topic Inference


A compact research-grade pipeline for testing whether an oscillating dark-energy equation of state can compete with standard cosmological parameterizations when confronted with modern distance probes.


1. Overview

This repository implements an exploratory cosmological analysis combining:

  • Pantheon+SH0ES Type Ia supernovae, using distance moduli and the full statistical + systematic covariance matrix;
  • DESI DR2 BAO measurements, using DV/rd, DM/rd, and DH/rd
  • Bayesian MCMC inference with emcee;
  • Model comparison using χ², AIC and BIC;
  • Convergence diagnostics based on acceptance fractions and integrated autocorrelation times.

The goal is to compare three models:

Model Description Free parameters
ΛCDM Standard flat cosmology with w = −1 2
CPL Dynamical dark energy with w(z) = w₀ + wₐ z/(1+z) 4
Ξosc Phenomenological oscillating dark-energy equation of state 6

The oscillating model is written as:

$$ w(t)=w_{0,\mathrm{mean}}+\epsilon\cos\left(\frac{2\pi t}{T}+\phi_0\right) $$

where ε controls the oscillation amplitude, T the characteristic period and φ₀ the phase.

Important

This project does not claim a discovery of oscillating dark energy.
It is an exploratory, reproducible test of whether a phenomenological oscillating equation of state remains competitive against standard dark-energy parameterizations.


2. Scientific motivation

The standard cosmological model, ΛCDM, assumes that the accelerated expansion of the Universe is driven by a cosmological constant with:

$$ w=-1 $$

However, current and upcoming distance probes motivate careful tests of whether the dark-energy equation of state could evolve with cosmic time.

A common phenomenological extension is the Chevallier–Polarski–Linder (CPL) parameterization:

$$ w(z)=w_0+w_a\frac{z}{1+z} $$

This project adds a third possibility:

$$ w(t)=w_{0,\mathrm{mean}}+\epsilon\cos\left(\frac{2\pi t}{T}+\phi_0\right) $$

which asks a simple question:

Could current supernova + BAO distance data accommodate a small oscillatory component in the dark-energy equation of state?

The analysis is intentionally modest and transparent: it does not try to establish a full physical theory, but rather tests a phenomenological signature against observational data.


3. Data used

Pantheon+SH0ES supernovae

The supernova component uses the Pantheon+SH0ES distance-modulus catalogue. The script reads:

  • zHD
  • MU_SH0ES or MU_SHOES
  • MU_SH0ES_ERR_DIAG or MU_SHOES_ERR_DIAG

and applies the redshift cut:

$$ z>0.01 $$

For the final run:

$$ N_{\rm SNe}=1590 $$

The full statistical + systematic covariance matrix is used.

DESI DR2 BAO

The BAO component uses 13 DESI DR2 BAO measurements of the form:

  • DV/rd
  • DM/rd
  • DH/rd

with a fixed fiducial sound horizon:

$$ r_d = 147.09\ \mathrm{Mpc} $$

For the final combined analysis:

$$ N_{\rm total}=1590+13=1603 $$


4. Method

For each model, the pipeline:

  1. defines the expansion history E(z)=H(z)/H₀;
  2. computes cosmological distances in a flat universe;
  3. predicts supernova distance moduli (μ(z));
  4. predicts BAO observables DV/rd, DM/rd, and DH/rd;
  5. evaluates the combined Gaussian likelihood using covariance matrices;
  6. samples the posterior using MCMC;
  7. summarizes marginalized constraints;
  8. compares models using χ², AIC and BIC.

The model-comparison criteria are:

$$ \mathrm{AIC}=\chi^2+2k $$

and

$$ \mathrm{BIC}=\chi^2+k\ln N $$

where k is the number of fitted parameters and N is the total number of data points.


5. Final exploratory run

The final long run used:

python src/xi_protocol1b_bao_run.py --nsteps 100000 --burn-in 20000 --nwalkers 96

with:

Quantity Value
Supernovae retained 1590
BAO measurements 13
Total data points 1603
MCMC steps 100000
Burn-in 20000
Walkers 96
Samples retained for Ξosc 7680000

6. Main results

Model comparison

Model χ² k AIC BIC ΔAIC
CPL 1531.824 4 1539.824 1561.343 0.000
Ξosc 1529.763 6 1541.763 1574.041 1.939
ΛCDM 1554.165 2 1558.165 1568.924 18.341

Key interpretation:

  • Ξosc gives the lowest raw χ².
  • CPL remains slightly preferred by AIC.
  • The difference between CPL and Ξosc is small:

$$ \Delta\mathrm{AIC}\approx1.94 $$

  • BIC is more severe and favors CPL because Ξosc has two additional parameters.
  • ΛCDM is disfavored relative to the two dynamical models in this exploratory setup.

7. Oscillation-amplitude diagnostic

For the oscillating model, the final marginalized constraint is:

ε = 0.1847+0.0768−0.0867

Using a symmetrized uncertainty:

$$ \sigma_\epsilon \approx 0.0818 $$

which gives:

$$ \frac{\epsilon}{\sigma_\epsilon}\approx2.26 $$

This is an interesting non-zero preference, but it is not strong enough to claim a detection.

A conservative reading is:

The combined Pantheon+SH0ES + DESI DR2 BAO dataset allows an oscillatory dark-energy component and gives it the best raw χ², but the evidence is not decisive once model complexity is penalized.


8. Figures

Posterior constraints for Ξosc

Xi oscillator corner plot

Reconstructed equation of state

Reconstructed equation of state

DESI DR2 BAO residuals

BAO residuals

Additional figures are available in:

figures/protocol1b_pantheon_desi/
figures/protocol1_pantheon_only/
figures/diagnostics/

9. Repository structure

xi-dark-energy-bao-mcmc/
│
├── README.md
├── LICENSE
├── CITATION.cff
├── requirements.txt
├── environment.yml
├── pyproject.toml
├── Makefile
│
├── src/
│   ├── xi_protocol1b_bao_run.py
│   ├── xi_protocol1_run.py
│   ├── 00_load_pantheon.py
│   └── xi_cosmo/
│       ├── results.py
│       ├── diagnostics.py
│       ├── labels.py
│       └── plotting.py
│
├── scripts/
│   ├── check_environment.py
│   ├── download_data.py
│   ├── export_final_tables.py
│   ├── make_chain_diagnostics.py
│   ├── organize_existing_outputs.py
│   ├── run_quick.ps1
│   └── run_final.ps1
│
├── data/
│   ├── README.md
│   └── raw/
│
├── figures/
│   ├── protocol1_pantheon_only/
│   ├── protocol1b_pantheon_desi/
│   └── diagnostics/
│
├── results/
│   └── protocol1b_pantheon_desi/
│       ├── final_model_comparison.csv
│       ├── final_parameter_estimates.csv
│       ├── final_model_comparison.md
│       └── chains/
│
├── notebooks/
│   ├── 00_project_overview.ipynb
│   ├── 01_data_inspection.ipynb
│   ├── 02_results_review.ipynb
│   └── 03_mcmc_diagnostics.ipynb
│
├── reports/
│   ├── Protocole1b_Pantheon_DESI_DR2_AlexBaker.pdf
│   └── latex/
│
├── docs/
│
└── tests/

10. Installation

Option A — Standard Python environment

git clone https://github.com/PhD-Brown/xi-dark-energy-bao-mcmc.git
cd xi-dark-energy-bao-mcmc

python -m venv .venv

On Windows PowerShell:

.\.venv\Scripts\Activate.ps1

On macOS/Linux:

source .venv/bin/activate

Then install:

python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .

Option B — Conda

conda env create -f environment.yml
conda activate xi-dark-energy
pip install -e .

11. Data setup

The raw data files are not committed by default.

Required Pantheon+SH0ES files

Place the following files in:

data/raw/

Required files:

Pantheon+SH0ES.dat
Pantheon+SH0ES_STAT+SYS.cov

DESI DR2 BAO files

The DESI BAO files can be downloaded automatically:

python scripts/download_data.py

This creates:

data/raw/desi_gaussian_bao_ALL_GCcomb_mean.txt
data/raw/desi_gaussian_bao_ALL_GCcomb_cov.txt

See data/README.md for details.


12. Running the analysis

Quick smoke test

Use this to verify that the pipeline runs end-to-end without launching a long MCMC:

python src/xi_protocol1b_bao_run.py --quick

On Windows:

.\scripts\run_quick.ps1

Medium test

python src/xi_protocol1b_bao_run.py --nsteps 5000 --burn-in 1000 --nwalkers 64

Final long run

python src/xi_protocol1b_bao_run.py --nsteps 100000 --burn-in 20000 --nwalkers 96

On Windows:

.\scripts\run_final.ps1

13. Outputs

The main runtime script writes outputs to:

results/
figures/

including:

results/summary_protocol1b_combined.txt
results/model_comparison_combined.csv
results/chains_<MODEL>_combined.npy

figures/corner_<MODEL>_combined.png
figures/w_of_z_combined.png
figures/bao_residuals_combined.png

Curated final outputs used for the report and public notebooks are organized under:

results/protocol1b_pantheon_desi/
figures/protocol1b_pantheon_desi/

Large MCMC chain files are intentionally ignored by Git:

results/**/chains/*.npy

They should be kept locally or distributed through a GitHub Release or external archive if needed.


14. Notebooks

The repository includes four lightweight notebooks:

Notebook Purpose
00_project_overview.ipynb Public-facing overview of the final results
01_data_inspection.ipynb Checks local data files and basic dimensions
02_results_review.ipynb Reviews final tables and model-comparison results
03_mcmc_diagnostics.ipynb Inspects saved MCMC chains if available locally

The overview notebook does not rerun the full MCMC. It loads final summary tables and reproduces the key interpretation.


15. Diagnostics

The final long run gave for Ξosc:

acceptance fraction ≈ 0.180
tau_max ≈ 1504
N/50 = 2000

Thus the practical criterion:

$$ N/50 > \tau_{\max} $$

is satisfied for the final run.

However, some parameters remain weakly constrained, especially:

  • T
  • φ₀

This is expected for an exploratory oscillatory model with phase and period freedom.


16. Testing

Run the local checks with:

python scripts/check_environment.py
python scripts/export_final_tables.py
python scripts/make_chain_diagnostics.py
python -m pytest tests -q
python -m compileall src scripts

The repository also includes a GitHub Actions workflow:

.github/workflows/python-check.yml

which installs the package and runs the test suite.


17. Scientific caveats

This project should be read as a methodological and exploratory analysis, not as a definitive cosmological claim.

Important caveats:

  1. ε ≈ 2.3σ is suggestive but not decisive.
  2. T and φ₀ remain weakly constrained.
  3. BIC favors CPL over Ξosc.
  4. The fixed rd choice should be varied in future work.
  5. Additional probes should be included before drawing strong physical conclusions.
  6. The Ξosc model is phenomenological and should eventually be connected to a more complete theoretical framework.

18. Future work

Possible extensions include:

  • varying or marginalizing over rd;
  • adding CMB priors;
  • adding cosmic chronometers H(z);
  • testing alternative BAO covariance treatments;
  • comparing with more flexible dark-energy reconstructions;
  • performing prior-sensitivity analyses on ε, T, and φ₀;
  • using nested sampling for a stronger Bayesian evidence comparison;
  • testing whether oscillatory behavior survives under alternative data combinations.

19. Project status

This repository is currently at the level of:

v0.1.0 — Initial exploratory Pantheon+SH0ES + DESI DR2 BAO analysis

It is suitable as:

  • a reproducible research mini-project;
  • a portfolio project in observational cosmology;
  • a demonstration of Bayesian inference with real astrophysical data;
  • a starting point for more robust dark-energy model comparison.

20. Citation

If you use or adapt this repository, please cite it using the metadata in:

CITATION.cff

A suggested citation format is:

Baker, A. (2026). Xi Dark Energy BAO MCMC: Exploratory Bayesian comparison of
ΛCDM, CPL and an oscillating dark-energy equation of state using Pantheon+SH0ES
and DESI DR2 BAO.

21. License

This project is released under the MIT License. See LICENSE.


22. Acknowledgements

This repository was developed as an exploratory cosmology analysis project using public distance-probe datasets and open-source scientific Python tools, including:

  • numpy
  • pandas
  • scipy
  • matplotlib
  • astropy
  • emcee
  • corner

The analysis is intended as a transparent and reproducible starting point for further discussion, validation and extension.


Scientific takeaway

Ξosc achieves the lowest raw χ², remains close to CPL according to AIC, and shows a non-zero oscillation amplitude at approximately 2.3σ.

However, CPL remains preferred by BIC, and the result should be interpreted as an exploratory indication rather than a detection.


Exploratory. Reproducible. Open to refinement.

About

Exploratory Bayesian comparison of ΛCDM, CPL and an oscillating dark-energy equation of state using Pantheon+SH0ES supernovae and DESI DR2 BAO.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors