NumCosmo
NumCosmo: The Numerical Cosmology Library
NumCosmo is a C library for cosmological calculations and statistical analysis. It is written in C using the GObject system, so every class is available from Python and other GObject-Introspection languages through the numcosmo_py package — without writing binding code. Computations run in C; models, data, and fits are scripted from Python.
Current version: 0.27.0
New to the library? Start with the installation guide and the Simple Example.
Design
NumCosmo is organized around three ideas:
- C performance, Python ergonomics. Classes implemented in C are subclassed, configured, and driven from Python via GObject-Introspection. There is no separate binding layer to maintain.
- Models behind interfaces. Each cosmological ingredient is a model with a well-defined interface, so implementations are interchangeable — swap a dark energy parametrization or a halo mass function without touching the code that consumes it.
- Statistics built in. Models are parameterized objects that connect directly to the fitting and sampling tools, so the same object used for a prediction is the one constrained against data.
What it computes
- Background and distances
-
\(\Lambda\)CDM, wCDM and other dark-energy parametrizations, and kinematic (model-independent) reconstructions of the expansion history. See
NcHICosmoandNcDistance. - Large-scale structure
- Linear and nonlinear (Halofit) matter power spectra, transfer functions, halo mass functions, halo density profiles, and weak-lensing surface mass density.
- Galaxy clusters
- Cluster number counts, mass-observable relations, and cluster weak-lensing likelihoods for constraining masses and cosmology.
- Observational likelihoods
- Type Ia supernovae, Baryon Acoustic Oscillations, cosmic chronometers (\(H(z)\)), and the CMB (including the Planck likelihood and a Boltzmann solver for the linear power spectrum).
- Cross-correlations
- A generic framework (XCor) for two-point cross-correlations between observables such as galaxy counts, weak lensing, and CMB lensing.
- Primordial and bouncing cosmology
-
Primordial power spectra from inflationary and bouncing models, built on the complex-structure mode evolver
NcmCSQ1D(see CSQ1D Formalism).
Statistical framework
The library provides best-fit estimation, Fisher-matrix forecasts, likelihood ratio tests, and several Markov Chain Monte Carlo samplers, including the Ensemble Sampler MCMC (NcmFitESMCMC) and APES, an approximate-posterior ensemble sampler (NcmFitESMCMCWalkerAPES). The benchmarks compare results against the Core Cosmology Library (CCL). Fits and samplers are parallelized with MPI and OpenMP.
Generic numerical tools
Beyond cosmology, NumCosmo includes reusable building blocks: adaptive numerical differentiation, multidimensional KDE and RBF interpolation, a HEALPix implementation, FFTLog transforms, and spline and ODE utilities. These live in the NumCosmoMath namespace.
External libraries
NumCosmo integrates with several established libraries: Sundials (ODE solvers), FFTW (Fourier transforms), NLopt (nonlinear optimization), and libcuba/cubature (high-dimensional integration), among others.
Next steps
- Install NumCosmo
- Browse the examples and tutorials
- Reference: NumCosmoMath API · NumCosmo API