Zheng Zhang
active

Advanced Methods

Computational Tools for Cosmology and Applied Mathematics

Advanced Methods

Open-source computational tools spanning polynomial emulation, Monte Carlo post-analysis, and stochastic dynamics — bridging modern numerical methods with cosmological and mathematical applications.

Overview

This workspace brings together four independent but complementary Python packages, each addressing a different facet of computational science. From building fast, interpretable emulators for cosmological observables to performing global sensitivity analysis on Monte Carlo chains and solving Fokker-Planck equations, these tools share a common philosophy: make advanced numerical methods accessible, efficient, and scientifically transparent.

Projects

Emulation

MomentEmu

A general-purpose polynomial emulator based on moment projection, introduced in Zhang (2025). Given simulation data {(θ(i), y(i))}, MomentEmu constructs a moment matrix Mαβ and moment vector να, then solves the linear system M c = ν to obtain closed-form polynomial coefficients — no iterative optimisation needed.

Key properties: millisecond-level evaluation, negligible training cost (seconds, not hours), fully symbolic & differentiable output, forward (θ → y) and inverse (y → θ) modes, auto-differentiation via JAX, PyTorch, and SymPy.

MomentEmu workflow: data standardisation, moment matrix assembly, polynomial fitting, and model selection

The MomentEmu workflow: standardise data, assemble moment matrices, solve for polynomial coefficients, and select the optimal degree via validation RMSE.

View on GitHub →
Cosmology

PolyCAMB — CMB Emulation with MomentEmu

Proof-of-concept application of MomentEmu to cosmological parameter estimation using CAMB. Two emulators are provided:

  • PolyCAMB-Dℓ — maps six ΛCDM parameters to the CMB power spectra (TT, EE, BB, TE) at sub-percent accuracy over ℓ ≤ 4050. Training on ~47k simulations takes ~9 s; a full spectrum evaluation takes ~1.5 ms.
  • PolyCAMB-peak — bidirectional mapping between cosmological parameters and acoustic peak features (locations & amplitudes of the first five peaks). The resulting symbolic expressions recover the known analytic dependences of peak-height ratios on Ωbh², Ωch², and ns.
PolyCAMB validation: emulated vs CAMB power spectrum and fractional residuals below 0.02%
PolyCAMB-Dℓ validation: emulated spectrum (orange) vs CAMB (dashed), with residuals < 0.02%. Stars mark acoustic peaks predicted by PolyCAMB-peak.
Training performance: RMSE and training time vs polynomial degree
Training performance vs polynomial degree. A degree-5 fit achieves ~0.05% RMSE in ~9 seconds.
Corner plot: MCMC posteriors from PolyCAMB vs raw CAMB are nearly identical
MCMC posteriors (Planck TT/TE/EE+lowE+lowT): PolyCAMB (orange) vs CAMB (blue). Best-fit shifts ≤ 0.01σ; ~140× speed-up.
Symbolic peak-height ratios H2 and H3: PolyCAMB vs Hu & Sugiyama analytic approximations
Symbolic peak-height ratios H2, H3: PolyCAMB-peak (orange) recovers known analytic dependences (blue) at ~0.04% accuracy vs CAMB (gray).
Statistics

MCPost

Comprehensive Monte Carlo post-analysis package. Provides global sensitivity analysis (mutual information, distance correlation, permutation importance, GP surrogates with ARD, Sobol’ indices) and Monte Carlo / quasi-Monte Carlo integration with importance sampling. Modular, typed, and extensible via a registry-based plugin system.

View on GitHub →
Stochastic Processes

KME

Numerical solver for the Fokker-Planck equation using the Kramers-Moyal expansion. Tracks the time evolution of probability density functions for stochastic processes, with built-in visualisation of PDF evolution at different time slices. Supports user-defined drift and diffusion coefficients.

View on GitHub →

Get Started

Key Takeaway

These four packages demonstrate the breadth of modern computational methods in cosmology and applied mathematics — from polynomial emulation with symbolic transparency to sensitivity analysis of Monte Carlo chains and stochastic process modelling. Each is pip-installable, documented with Jupyter notebooks, and designed for scientific transparency.

All packages are available on GitHub:

  • MomentEmu: pip install git+https://github.com/zzhang0123/MomentEmu.git
  • MCPost: pip install MC-post
  • PolyCAMB examples: git clone https://github.com/MomentEmu/MomentEmu-PolyCAMB-examples.git