A curated collection of Jupyter notebooks introducing and applying statistical methods and cosmological inference tools to problems in cosmology.
This repository combines:
- Practical statistical tutorials for students and researchers.
- Step-by-step Cobaya tutorials for Bayesian cosmological parameter estimation and model comparison, now included as a subfolder of the main tutorials.
- Measuring the Hubble Constant (H₀) with Type Ia Supernovae – Bayesian inference, MCMC, and parameter estimation using SNe Ia data.
- Measuring H₀ with Cobaya – Same analysis recast using Cobaya as the MCMC sampler.
- Tutorial 1 – Introduction to Cobaya: sampling multivariate Gaussian and Ring likelihoods.
- Tutorial 2 – Advanced Cobaya: running cosmology chains and using the
get_model()wrapper to access internal calculations.
- CAMB & CosmoPower – Hands-on tutorial computing power spectra with CAMB and CosmoPower emulator, including a
cloelibexample.
- H₀ Statistics Exercises – Practice problems on basic cosmological statistics using SNe Ia and H₀.
- CAMB & CosmoPower Exercises – Exercises on computing and manipulating power spectra (+
cloelib).
- Python for Astronomy – Python basics and tools relevant to astronomy and cosmology.
git clone https://github.com/gcanasherrera/Stats4Cosmology.git
cd Stats4Cosmologyjupyter labOpen any notebook under the tutorials/ folder to explore Stats4Cosmology, or navigate to tutorials/software/ for software specific exercises.
You can run Cobaya notebooks on Google Colab. For Cobaya specific notebooks you will need:
!pip install cobaya
!cobaya-install cosmo -p .The notebooks rely on standard scientific Python libraries widely used in astronomy and cosmology:
numpy– numerical computingscipy– scientific routinesastropy– astronomy & cosmology utilitiesmatplotlib– plottingseaborn– statistical visualizationjupyter– interactive notebookscobaya– cosmological Bayesian analysis (for Cobaya tutorials)camb– CMB power spectrum code (for TheoryCodes tutorials)cosmopower– neural network emulator for power spectra (for TheoryCodes tutorials)cloelib– Euclid Consortium's theory-prediction library (for TheoryCodes tutorials)
- Students in astrophysics, physics, or statistics wanting hands-on cosmological inference training.
- Researchers looking for ready-to-use templates for teaching, lectures, or experimentation.
- Educators needing practical examples for cosmology and data science courses.
- Anyone interested in learning how to use Cobaya for Bayesian cosmological analysis.
Developed and maintained by Dr. Guadalupe Cañas-Herrera, inspired by real-world cosmological pipelines in the era of Euclid, probably biased by Planck 18 analysis experience.
This project is licensed under the MIT License – see the LICENSE file for details.
If you find these notebooks useful in your research or teaching, please cite:
@misc{stats4cosmology,
author = {Cañas Herrera, Guadalupe},
title = {Stats4Cosmology: Jupyter notebooks for statistical methods in cosmology, including Cobaya tutorials},
year = {2025},
howpublished = {\url{https://github.com/gcanasherrera/Stats4Cosmology}}
}