Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Part II: Gaussian Processes - Foundations and Theory

From Expensive Simulations to Fast Emulators | Module 6: The Learnable Universe | ASTR 596

San Diego State University

“All models are wrong, but some are useful. The practical question is not whether to use a model, but which model to use.”

George E. P. Box


Learning Outcomes

By the end of Part II, you will be able to:



The Big Picture: The Computational Crisis in Modern Astrophysics

The Problem We’re Solving

You’ve spent the semester building physics from first principles:

Module 1-2: Statistical Foundations

Module 3: Dynamics in Phase Space

Module 4: Radiative Transfer

Module 5: Bayesian Inference

Projects 2, 3, 5: Building the Machinery

Each simulator encodes centuries of physics compressed into a few hundred lines of code. They work beautifully. They give correct answers.

They’re also prohibitively slow.

Output: Cluster properties at time t=10tdynt = 10 \, t_{\rm dyn}, where the dynamical time is defined as tdynRh3/(GMtot)t_{\rm dyn} \equiv \sqrt{R_h^3 / (G M_{\rm tot})} (the characteristic timescale for orbital motion at the half-mass radius)

Note on Plummer profiles: For the Plummer density profile you’re using, the half-mass radius relates to the scale radius as Rh1.305aR_h \approx 1.305 a (the exact factor depends on definitions and conventions; verify in your simulator’s documentation). So clusters with larger aa have longer dynamical times (slower evolution): tdyna3/2/GMtott_{\rm dyn} \propto a^{3/2} / \sqrt{G M_{\rm tot}}. This means aa directly controls the evolutionary timescale—important for interpreting your emulator’s learned lengthscale a\ell_a!

Computational Cost:

Now suppose you want to answer scientific questions:

  1. Parameter Space Exploration: “Which initial conditions lead to cluster survival vs dissolution?”

    • Need: ~5,000 simulations to sample 3D space densely (roughly 17\sim 17 points per dimension for 1735,00017^3 \approx 5{,}000 total)

    • Cost: 5,000 × 2 min = ~167 hours = 7 days of compute

  2. Bayesian Parameter Inference: “What initial conditions produced the Pleiades cluster?”

    • Need: ~100,000 MCMC samples × likelihood evaluations

    • Cost: 100,000 × 2 min = ~3,333 hours = 138 days = 4.5 months

  3. Optimization: “What initial setup maximizes cluster lifetime?”

    • Need: ~50,000 gradient evaluations for optimization

    • Cost: 50,000 × 2 min = ~1,666 hours = 69 days = 2.3 months

This is not a toy problem. This is real research.


### The Traditional Approach: Suffer or Approximate

Historically, astronomers faced a choice:

**Option 1: Just Wait**

- Run the expensive simulations
- Use supercomputers, parallelize, optimize
- Wait weeks/months for results
- **Problem**: Kills iteration speed, makes exploration impossible

**Option 2: Use Simple Models**

- Fit polynomials, power laws, linear regression
- Fast to evaluate, easy to interpret
- **Problem**: Physics is nonlinear, complex, high-dimensional. Simple models fail.

**Option 3: Dimensional Reduction**

- Derive simplified analytic approximations (e.g., virial theorem $Q = 1$ for equilibrium)
- Use scaling relations (e.g., $t_{\rm relax} \propto N / \ln N$)
- **Problem**: Valid only in limited regimes, miss interesting dynamics (unless validated with new simulations)

**Option 4: Give Up on Some Questions**

- Don't do parameter inference, don't optimize, don't explore broadly
- **Problem**: Science suffers

### The Modern Solution: Emulation

**Key Insight**: Your simulator $f_{\rm sim}$ is deterministic (or nearly so). Once you fix initial conditions $\mathbf{x}$, the output $y$ is determined by physics:

$$
y = f_{\rm sim}(\mathbf{x}) + \epsilon
$$

where $\epsilon$ represents numerical noise (finite timesteps, roundoff errors, stochastic elements).

**The Emulation Strategy**:

1. **One-Time Investment**: Run $N = 200\text{-}500$ simulations with carefully chosen initial conditions
   - Cost: $500 \times 2 \text{ min} \approx 16 \text{ hours}$ (one night of compute)
   - Generate training dataset: $\mathcal{D} = \{(\mathbf{x}_i, y_i)\}_{i=1}^N$

2. **Learn the Function**: Train a *surrogate model* (emulator) $f_{\rm emu}$ that approximates $f_{\rm sim}$
   - Cost: Minutes to hours (one-time training)
   - Result: Fast function $f_{\rm emu}(\mathbf{x})$ that mimics $f_{\rm sim}(\mathbf{x})$

3. **Deploy Everywhere**: Use $f_{\rm emu}$ instead of $f_{\rm sim}$ for:
   - Parameter space exploration: evaluate $f_{\rm emu}$ at millions of points
   - MCMC sampling: cheap likelihood evaluations
   - Optimization: fast gradient computation (if emulator is differentiable)
   - **Speedup**: $10^4$ to $10^6$ times faster than simulator

4. **Quantify Trust**: Emulator provides **uncertainty estimates**
   - "I predict bound fraction = $0.65 \pm 0.08$"
   - Know when to trust predictions, when to run more simulations
   - Principled decision-making about computational budget

:::{admonition} Connection to Module 5: Bayesian Inference
:class: note

In Project 4, you used MCMC to sample posterior distributions:

$$
p(\theta | \mathcal{D}) \propto p(\mathcal{D} | \theta) \, p(\theta)
$$

Each MCMC step required evaluating the likelihood $p(\mathcal{D} | \theta)$. When your model was simple (e.g., Gaussian with unknown mean/variance), this was cheap—just compute a probability.

But what if the likelihood requires *running a simulation*?

$$
p(\mathcal{D} | \theta) = p(\text{observed cluster properties} | \text{initial conditions } \theta)
$$

Then each MCMC step costs 2 minutes, and 100,000 samples = 138 days. **Intractable.**

**Emulation makes Bayesian inference feasible**: Replace $f_{\rm sim}(\theta)$ with $f_{\rm emu}(\theta)$ in the likelihood. Now each MCMC step costs milliseconds, and 100,000 samples = 1 hour.

This workflow is called **simulation-based inference** or **likelihood-free inference**, and it's how modern experiments (LIGO, DESI, Planck) constrain cosmological and astrophysical parameters.

[FIGURE 1.1: Emulation Workflow]

View Figure: Complete Emulation Workflow from Simulation to Inference

Figure 1.1: The complete emulation workflow. Red (expensive): Run your physics simulator 100-500 times at carefully chosen design points. Blue (training): Collect training dataset linking initial conditions to outcomes. Green (GP): Train Gaussian Process emulator that learns this mapping and provides uncertainty estimates μ(θ) ± σ(θ). Yellow (fast): Query emulator millions of times for parameter inference, sensitivity analysis, and exploration. The one-time upfront cost enables downstream analyses that would be impossible with the direct simulator.

Key Insight: GPs provide both prediction μ(θ) AND uncertainty σ(θ), enabling trustworthy predictions with error bars, adaptive sampling (add more training data where uncertain), and rigorous parameter inference (uncertainty propagation in MCMC).


First Principles: Why Gaussian Processes Work

The Core Idea: Functions as Infinite-Dimensional Vectors

You’re familiar with probability distributions over scalars and vectors:

Scalar random variable: xN(μ,σ2)x \sim \mathcal{N}(\mu, \sigma^2)

Vector random variable: xN(μ,Σ)\mathbf{x} \sim \mathcal{N}(\boldsymbol{\mu}, \boldsymbol{\Sigma})

A Gaussian Process extends this to functions:

fGP(m,k)f \sim \mathcal{GP}(m, k)

Definition (Gaussian Process):

A stochastic process f(x)f(\mathbf{x}) is a Gaussian Process if, for any finite collection of input points {x1,,xn}\{\mathbf{x}_1, \ldots, \mathbf{x}_n\}, the joint distribution of function values is a multivariate Gaussian:

[f(x1)f(x2)f(xn)]N([m(x1)m(x2)m(xn)],[k(x1,x1)k(x1,x2)k(x1,xn)k(x2,x1)k(x2,x2)k(x2,xn)k(xn,x1)k(xn,x2)k(xn,xn)])\begin{bmatrix} f(\mathbf{x}_1) \\ f(\mathbf{x}_2) \\ \vdots \\ f(\mathbf{x}_n) \end{bmatrix} \sim \mathcal{N}\left( \begin{bmatrix} m(\mathbf{x}_1) \\ m(\mathbf{x}_2) \\ \vdots \\ m(\mathbf{x}_n) \end{bmatrix}, \begin{bmatrix} k(\mathbf{x}_1, \mathbf{x}_1) & k(\mathbf{x}_1, \mathbf{x}_2) & \cdots & k(\mathbf{x}_1, \mathbf{x}_n) \\ k(\mathbf{x}_2, \mathbf{x}_1) & k(\mathbf{x}_2, \mathbf{x}_2) & \cdots & k(\mathbf{x}_2, \mathbf{x}_n) \\ \vdots & \vdots & \ddots & \vdots \\ k(\mathbf{x}_n, \mathbf{x}_1) & k(\mathbf{x}_n, \mathbf{x}_2) & \cdots & k(\mathbf{x}_n, \mathbf{x}_n) \end{bmatrix} \right)

Intuition:

GP prior samples showing lengthscale effects on function smoothness

Figure 1:Figure 2.1: GP Prior Samples - How Lengthscale Controls Smoothness. Random function samples from GP(0, k_SE) with different lengthscales demonstrate how ℓ controls function smoothness. Top row: Individual samples show that small ℓ = 0.1 produces highly wiggly (high-frequency) functions, while large ℓ = 1.0 produces smooth (low-frequency) functions. Bottom row: Prior confidence bands (±2σ) with correlation length visualization. The red arrows show the lengthscale ℓ—the distance over which function values remain correlated (correlation drops to ~60% at distance ℓ). Key Insight: Small lengthscales require dense training data to capture rapid variations; large lengthscales allow sparse sampling since the function varies slowly.

From Finite to Infinite: The Consistency Requirement

Why use Gaussians for functions? Two reasons:

1. Computational Tractability

Gaussian distributions have magical properties (recall Module 1):

These properties mean we can compute predictions in closed form — no MCMC, no numerical integration, just linear algebra.

2. Consistency Under Marginalization

Suppose I specify a GP prior fGP(0,k)f \sim \mathcal{GP}(0, k). Then by definition:

[f(x1)f(x2)f(x3)]N(0,[k(x1,x1)k(x1,x2)k(x1,x3)k(x2,x1)k(x2,x2)k(x2,x3)k(x3,x1)k(x3,x2)k(x3,x3)])\begin{bmatrix} f(\mathbf{x}_1) \\ f(\mathbf{x}_2) \\ f(\mathbf{x}_3) \end{bmatrix} \sim \mathcal{N}\left(0, \begin{bmatrix} k(\mathbf{x}_1, \mathbf{x}_1) & k(\mathbf{x}_1, \mathbf{x}_2) & k(\mathbf{x}_1, \mathbf{x}_3) \\ k(\mathbf{x}_2, \mathbf{x}_1) & k(\mathbf{x}_2, \mathbf{x}_2) & k(\mathbf{x}_2, \mathbf{x}_3) \\ k(\mathbf{x}_3, \mathbf{x}_1) & k(\mathbf{x}_3, \mathbf{x}_2) & k(\mathbf{x}_3, \mathbf{x}_3) \end{bmatrix}\right)

But also:

[f(x1)f(x2)]N(0,[k(x1,x1)k(x1,x2)k(x2,x1)k(x2,x2)])\begin{bmatrix} f(\mathbf{x}_1) \\ f(\mathbf{x}_2) \end{bmatrix} \sim \mathcal{N}\left(0, \begin{bmatrix} k(\mathbf{x}_1, \mathbf{x}_1) & k(\mathbf{x}_1, \mathbf{x}_2) \\ k(\mathbf{x}_2, \mathbf{x}_1) & k(\mathbf{x}_2, \mathbf{x}_2) \end{bmatrix}\right)

Consistency: The distribution over [f(x1),f(x2)][f(\mathbf{x}_1), f(\mathbf{x}_2)] obtained by marginalizing out f(x3)f(\mathbf{x}_3) from the 3D Gaussian must match the 2D Gaussian. Gaussians satisfy this automatically.

This is called the Kolmogorov consistency theorem, and it’s why GPs are mathematically well-defined even though functions are infinite-dimensional.


🔴 The Mathematical Machinery: Gaussian Conditioning

Reviewing Multivariate Gaussians

Before we predict with GPs, we need the key formula from Module 1: Gaussian conditioning.

Suppose we have a joint Gaussian distribution over two sets of variables:

[f1f2]N([μ1μ2],[Σ11Σ12Σ21Σ22])\begin{bmatrix} \mathbf{f}_1 \\ \mathbf{f}_2 \end{bmatrix} \sim \mathcal{N}\left( \begin{bmatrix} \boldsymbol{\mu}_1 \\ \boldsymbol{\mu}_2 \end{bmatrix}, \begin{bmatrix} \boldsymbol{\Sigma}_{11} & \boldsymbol{\Sigma}_{12} \\ \boldsymbol{\Sigma}_{21} & \boldsymbol{\Sigma}_{22} \end{bmatrix} \right)

where:

Question: If we observe f1=y\mathbf{f}_1 = \mathbf{y} (actual data), what is the distribution of f2\mathbf{f}_2?

Theorem (Gaussian Conditioning):

The conditional distribution is Gaussian:

p(f2f1=y)=N(f2μ21,Σ21)p(\mathbf{f}_2 | \mathbf{f}_1 = \mathbf{y}) = \mathcal{N}(\mathbf{f}_2 | \boldsymbol{\mu}_{2|1}, \boldsymbol{\Sigma}_{2|1})

where:

μ21=μ2+Σ21Σ111(yμ1)Σ21=Σ22Σ21Σ111Σ12\boxed{ \begin{align} \boldsymbol{\mu}_{2|1} &= \boldsymbol{\mu}_2 + \boldsymbol{\Sigma}_{21} \boldsymbol{\Sigma}_{11}^{-1} (\mathbf{y} - \boldsymbol{\mu}_1) \tag{Posterior Mean}\\[1em] \boldsymbol{\Sigma}_{2|1} &= \boldsymbol{\Sigma}_{22} - \boldsymbol{\Sigma}_{21} \boldsymbol{\Sigma}_{11}^{-1} \boldsymbol{\Sigma}_{12} \tag{Posterior Covariance} \end{align} }

This is the entire machinery of Gaussian Process regression.

Interpreting the Formulas

Let’s unpack these equations physically:

Posterior Mean μ21=μ2+Σ21Σ111(yμ1)\boldsymbol{\mu}_{2|1} = \boldsymbol{\mu}_2 + \boldsymbol{\Sigma}_{21} \boldsymbol{\Sigma}_{11}^{-1} (\mathbf{y} - \boldsymbol{\mu}_1)

Physical interpretation: If test point x\mathbf{x}_* is highly correlated with training point xi\mathbf{x}_i (large Σ21\Sigma_{21}), then observing yiy_i strongly influences prediction at x\mathbf{x}_*.

Posterior Covariance Σ21=Σ22Σ21Σ111Σ12\boldsymbol{\Sigma}_{2|1} = \boldsymbol{\Sigma}_{22} - \boldsymbol{\Sigma}_{21} \boldsymbol{\Sigma}_{11}^{-1} \boldsymbol{\Sigma}_{12}

Physical interpretation: Uncertainty depends only on where you observed data (the xi\mathbf{x}_i), not on what you observed (the yiy_i). This makes sense: uncertainty is about information geometry, not values.

From Conditioning to GP Prediction

Now apply this to Gaussian Processes. We have:

Training data: D={(xi,yi)}i=1N\mathcal{D} = \{(\mathbf{x}_i, y_i)\}_{i=1}^N where yi=f(xi)+ϵiy_i = f(\mathbf{x}_i) + \epsilon_i

GP prior: fGP(m,k)f \sim \mathcal{GP}(m, k)

Goal: Predict f(x)f(\mathbf{x}_*) at new test point x\mathbf{x}_*

Setup: Form joint distribution over training outputs and test output:

[yf]N([mm],[K+σn2IkkTk])\begin{bmatrix} \mathbf{y} \\ f_* \end{bmatrix} \sim \mathcal{N}\left( \begin{bmatrix} \mathbf{m} \\ m_* \end{bmatrix}, \begin{bmatrix} \mathbf{K} + \sigma_n^2 \mathbf{I} & \mathbf{k}_* \\ \mathbf{k}_*^T & k_{**} \end{bmatrix} \right)

where:

Apply Gaussian conditioning: Condition on observed y\mathbf{y} to get posterior over ff_*:

μ(x)=m(x)+kT(K+σn2I)1(ym)σ2(x)=kkT(K+σn2I)1k\boxed{ \begin{align} \mu(\mathbf{x}_*) &= m(\mathbf{x}_*) + \mathbf{k}_*^T (\mathbf{K} + \sigma_n^2 \mathbf{I})^{-1} (\mathbf{y} - \mathbf{m}) \tag{GP Predictive Mean}\\[1em] \sigma^2(\mathbf{x}_*) &= k_{**} - \mathbf{k}_*^T (\mathbf{K} + \sigma_n^2 \mathbf{I})^{-1} \mathbf{k}_* \tag{GP Predictive Variance} \end{align} }

These are the fundamental equations of GP regression.

What These Equations Mean

Let’s interpret each term:

Predictive Mean: μ(x)=m(x)+kT(K+σn2I)1(ym)\mu(\mathbf{x}_*) = m(\mathbf{x}_*) + \mathbf{k}_*^T (\mathbf{K} + \sigma_n^2 \mathbf{I})^{-1} (\mathbf{y} - \mathbf{m})

  1. Prior mean m(x)m(\mathbf{x}_*): Default guess (often zero)

  2. Data term (ym)(\mathbf{y} - \mathbf{m}): How training outputs differ from prior expectations

  3. Weights (K+σn2I)1(ym)(\mathbf{K} + \sigma_n^2 \mathbf{I})^{-1} (\mathbf{y} - \mathbf{m}): How much influence each training point has (depends on noise and correlations)

  4. Similarity k\mathbf{k}_*: How similar test point is to each training point

  5. Weighted average: Prediction is weighted sum of training residuals, weighted by similarity

Predictive Variance: σ2(x)=kkT(K+σn2I)1k\sigma^2(\mathbf{x}_*) = k_{**} - \mathbf{k}_*^T (\mathbf{K} + \sigma_n^2 \mathbf{I})^{-1} \mathbf{k}_*

  1. Prior variance kk_{**}: Uncertainty before seeing data (usually normalized to 1)

  2. Reduction kT(K+σn2I)1k\mathbf{k}_*^T (\mathbf{K} + \sigma_n^2 \mathbf{I})^{-1} \mathbf{k}_*: How much training data reduces uncertainty

  3. Key property: Variance is small (confident) when test point is similar to training points (large k\mathbf{k}_*)

  4. Another key property: Variance is large (uncertain) far from training data


🔴 Kernels: Encoding Physical Intuition

What Kernels Do

The kernel function k:RD×RDRk: \mathbb{R}^D \times \mathbb{R}^D \to \mathbb{R} is the heart of the GP. It encodes all your prior beliefs about the function you’re learning.

Definition: The kernel k(x,x)k(\mathbf{x}, \mathbf{x}') measures the covariance between function values at inputs x\mathbf{x} and x\mathbf{x}':

k(x,x)=E[(f(x)m(x))(f(x)m(x))]k(\mathbf{x}, \mathbf{x}') = \mathbb{E}[(f(\mathbf{x}) - m(\mathbf{x}))(f(\mathbf{x}') - m(\mathbf{x}'))]

Interpretation:

Key Properties (for a valid kernel):

  1. Symmetry: k(x,x)=k(x,x)k(\mathbf{x}, \mathbf{x}') = k(\mathbf{x}', \mathbf{x}) (covariance is symmetric)

  2. Positive Semi-Definite: For any set of points {xi}\{\mathbf{x}_i\}, the matrix Kij=k(xi,xj)K_{ij} = k(\mathbf{x}_i, \mathbf{x}_j) must have non-negative eigenvalues

  3. Stationarity (common but not required): Many kernels are stationary, k(x,x)=k(xx)k(\mathbf{x}, \mathbf{x}') = k(\mathbf{x} - \mathbf{x}') (depends only on distance, not absolute location). Non-stationary kernels can model varying lengthscales (e.g., input warping, Gibbs kernel).

The Squared Exponential (RBF) Kernel

The most common kernel is the Squared Exponential (SE), also called Radial Basis Function (RBF):

kSE(x,x)=σf2exp(xx222)k_{\text{SE}}(\mathbf{x}, \mathbf{x}') = \sigma_f^2 \exp\left( -\frac{\|\mathbf{x} - \mathbf{x}'\|^2}{2\ell^2} \right)

Hyperparameters:

Anisotropic version (Automatic Relevance Determination - ARD):

When dimensions have different importance, use per-dimension lengthscales:

kSE-ARD(x,x)=σf2exp(12d=1D(xdxd)2d2)k_{\text{SE-ARD}}(\mathbf{x}, \mathbf{x}') = \sigma_f^2 \exp\left( -\frac{1}{2} \sum_{d=1}^D \frac{(x_d - x'_d)^2}{\ell_d^2} \right)

where each d\ell_d controls sensitivity to dimension dd. Small d\ell_d → high sensitivity, large d\ell_d → low sensitivity.

Physical interpretation:

  1. Exponential decay: Correlation decreases exponentially with distance xx\|\mathbf{x} - \mathbf{x}'\|

  2. Lengthscale: If xx=\|\mathbf{x} - \mathbf{x}'\| = \ell, then k=σf2e1/20.6σf2k = \sigma_f^2 e^{-1/2} \approx 0.6 \sigma_f^2 (60% correlated)

  3. Short lengthscale: Function varies rapidly, needs data points close together

  4. Long lengthscale: Function varies slowly, data points far apart still informative

  5. Infinite smoothness: Functions drawn from SE GP are infinitely differentiable (unrealistic for many physical systems!)

Visualization: Imagine bound fraction vs virial ratio QQ:

The Matérn Family: More Realistic Smoothness

The SE kernel assumes infinitely smooth functions. Real physics is often rougher. The Matérn family allows tunable smoothness:

kMateˊrn(x,x)=σf221νΓ(ν)(2νxx)νKν(2νxx)k_{\text{Matérn}}(\mathbf{x}, \mathbf{x}') = \sigma_f^2 \frac{2^{1-\nu}}{\Gamma(\nu)} \left( \sqrt{2\nu} \frac{\|\mathbf{x} - \mathbf{x}'\|}{\ell} \right)^\nu K_\nu\left( \sqrt{2\nu} \frac{\|\mathbf{x} - \mathbf{x}'\|}{\ell} \right)

where:

Key cases:

  1. ν=1/2\nu = 1/2 (Matérn-1/2):

    • Equivalent to Ornstein-Uhlenbeck process

    • Functions are continuous but not differentiable (rough, can have kinks)

    • With r=xxr = \|\mathbf{x} - \mathbf{x}'\|:

      k(x,x)=σf2exp(r/)k(\mathbf{x}, \mathbf{x}') = \sigma_f^2 \exp(-r / \ell)
    • Note: Still continuous! Doesn’t model true discontinuities, just permits roughness.

  2. ν=3/2\nu = 3/2 (Matérn-3/2):

    • Functions are once differentiable (smooth but can have kinks in second derivative)

    • With r=xxr = \|\mathbf{x} - \mathbf{x}'\|:

      k(x,x)=σf2(1+3r)exp(3r)k(\mathbf{x}, \mathbf{x}') = \sigma_f^2 \left(1 + \sqrt{3} \frac{r}{\ell}\right) \exp\left(-\sqrt{3} \frac{r}{\ell}\right)
  3. ν=5/2\nu = 5/2 (Matérn-5/2):

    • Functions are twice differentiable (smoother, often good default)

    • With r=xxr = \|\mathbf{x} - \mathbf{x}'\|:

      k(x,x)=σf2(1+5r+5r232)exp(5r)k(\mathbf{x}, \mathbf{x}') = \sigma_f^2 \left(1 + \sqrt{5} \frac{r}{\ell} + \frac{5r^2}{3\ell^2}\right) \exp\left(-\sqrt{5} \frac{r}{\ell}\right)
  4. ν\nu \to \infty: Recovers SE kernel (infinitely smooth)

When to use which:

Practical tuning guide:

Matérn family smoothness comparison showing differentiability controlled by nu

Figure 4:Figure 2.3: Matérn Smoothness Comparison. Matérn family smoothness comparison showing how ν controls differentiability. Top row: Function samples f(x) for each smoothness parameter. Middle row: Numerical derivatives f’(x) reveal roughness—Matérn-1/2 (ν=0.5) shows visible kinks and is NOT differentiable (rough, discontinuous slopes); Matérn-3/2 (ν=1.5) has smooth first derivatives but rough second derivatives (once differentiable); Matérn-5/2 (ν=2.5) is very smooth (twice differentiable). Bottom row: Kernel correlation k(r) vs distance shows how quickly correlations decay. Practical Recommendation: Use Matérn-5/2 as default for physics emulation—smooth enough for realistic systems but more flexible than infinitely-smooth SE kernel. Only use SE when you KNOW the function is truly infinitely smooth (rare in real physics). Use Matérn-3/2 if validation shows underfitting or if you expect rougher behavior.

Periodic Kernels: Exploiting Symmetries

If your function has periodic structure, you can encode this:

kPer(x,x)=σf2exp(2sin2(πxx/p)2)k_{\text{Per}}(x, x') = \sigma_f^2 \exp\left( -\frac{2 \sin^2(\pi |x - x'| / p)}{\ell^2} \right)

Note: This is the 1D periodic kernel. For vector inputs, periodicity is typically applied per dimension: kPer(x,x)=dσf2exp(2sin2(π(xdxd)/pd)d2)k_{\text{Per}}(\mathbf{x}, \mathbf{x}') = \prod_d \sigma_f^2 \exp\left(-\frac{2\sin^2(\pi(x_d - x_d')/p_d)}{\ell_d^2}\right). Use only if you have strong physical reason to expect periodicity in a specific dimension (e.g., orbital angular position, stellar rotation phase).

where:

When to use:

N-body example: If you’re emulating cluster properties in a rotating frame, periodic kernel might capture rotational symmetry. (Rare, but possible!)

Compositional Kernels: Building Complexity

You can combine kernels to build more complex priors:

1. Addition k(x,x)=k1(x,x)+k2(x,x)k(\mathbf{x}, \mathbf{x}') = k_1(\mathbf{x}, \mathbf{x}') + k_2(\mathbf{x}, \mathbf{x}')

2. Multiplication k(x,x)=k1(x,x)k2(x,x)k(\mathbf{x}, \mathbf{x}') = k_1(\mathbf{x}, \mathbf{x}') \cdot k_2(\mathbf{x}, \mathbf{x}')

3. Per-dimension kernels:

k(x,x)=d=1Dkd(xd,xd)k(\mathbf{x}, \mathbf{x}') = \prod_{d=1}^D k_d(x_d, x'_d)

🔴 Decision Framework: When to Use What

You now understand what GPs are and how they work. But when should you actually use them?

The Method Landscape

Modern surrogate modeling has three main approaches:

MethodStrengthsWeaknessesWhen to Use
Polynomial / Basis Function ExpansionSimple, interpretable, fastLimited flexibility, high-D curseLinear systems, low-D, known structure
Gaussian ProcessesUncertainty quantification, data-efficient, interpretable hyperparametersO(N3)O(N^3) scaling, assumes smoothness, struggles in high-DLow-D (D<10D < 10-20), need uncertainty, limited data (N<5000N < 5000), interpretability important
Neural NetworksScales to high-D, handles complex patterns, can learn representationsNeeds lots of data, uncertain uncertainty, black boxHigh-D (D>20D > 20), abundant data (N>10,000N > 10,000), complex discontinuities

When to Use Gaussian Processes

GPs Excel When:

Low-dimensional inputs (single-digit to low-tens, roughly D10D \lesssim 10–20)

Limited training data (N=100N = 100-5000)

Uncertainty quantification is critical

Smooth or structured functions

Interpretability matters

Need gradients

When NOT to Use Gaussian Processes

High-dimensional inputs (D>20D > 20)

Large datasets (N>5000N > 5000-10,000)

Discontinuous or highly irregular functions

Complex structured outputs

Real-time constraints

Decision Tree for Your N-Body Emulation

Let’s apply this to your project:

Your Problem:

Analysis:

Verdict: Gaussian Processes are ideal for this problem!

But also try Neural Networks because:

[FIGURE 5.1: Emulation Method Decision Tree]

View Figure: Complete Decision Tree for Choosing Emulation Methods

Figure 5.1: Decision tree for choosing emulation methods based on problem characteristics. Green boxes: Recommended methods with strong theoretical/empirical support. Yellow boxes: Alternative methods to consider. Red boxes: Warning situations requiring problem reformulation. Blue diamonds: Decision points based on dimensionality, data availability, and smoothness assumptions. For your N-body cluster emulation (d=3, n≈250, smooth physics, need UQ), follow the path: d≤5 → Yes UQ → n<1000 → Standard GP with SE or Matérn kernel—the ideal choice!

Quick Reference: Standard GP (d≤5, n<1000) for small data + uncertainty. GP with ARD (5<d≤20) for automatic feature selection. Sparse GP (n>5000) for computational efficiency. Neural Networks (d>20 or n>10,000) for high-dimensional/large-data regimes. Decision Rule: Use GPs when you need rigorous uncertainty quantification, have limited expensive training data, smooth outputs, and interpretable lengthscales matter.


🎓 What We’ve Learned: Theory Summary

Let’s step back and see what we’ve covered in Part I.

First Principles

  1. The Problem: Scientific simulations encode physics but are too slow for exploration, optimization, inference

  2. The Solution: Emulation—learn a fast surrogate from modest training data

  3. Why GPs Work:

    • Bayesian inference in function space

    • Gaussian conditioning gives predictions in closed form

    • Kernels encode physical structure (smoothness, lengthscales)

    • Uncertainty quantification is built-in (know when to trust predictions)

  4. When to Use GPs:

    • Low-dimensional problems (D<20D < 20)

    • Limited data (N<5000N < 5000)

    • Smooth physics

    • Uncertainty matters

    • Interpretability desired

Connection to Everything You’ve Learned

Module 1 (Statistics):

Module 2-3 (Stellar Systems):

Module 4 (Radiative Transfer):

Module 5 (Bayesian Inference):

Project 5 (JAX):

The Philosophical Point

Machine learning is not magic. It’s principled probabilistic inference with mathematical foundations.

GPs exemplify this:

When you implement a GP, you’re not using a black box—you’re applying a century of mathematics (Kolmogorov, Wiener, Rasmussen) to solve a 21st-century astrophysics problem.

This is computational astrophysics in 2025!


🔮 Preview: Part II

In Part II: GP Implementation, you’ll learn:

See you in Part II! Continue to Part II: Gaussian Processes - Implementation and Practice.


Self-Check Rubric: Do You Understand GPs?

Before Part II, honestly assess yourself using this rubric. This will help you identify gaps and ensure you’re ready for implementation.

1. Conceptual Understanding

If you checked <3 boxes: Reread “First Principles” and “Uncertainty” sections before Part II.

2. Practical Knowledge

If you checked <3 boxes: Work through the “Kernels” and “Computational” sections with paper and pen.

3. Physical Intuition

If you checked <3 boxes: Reread the “Why This Matters” sections and think about your N-body simulations.

4. Implementation Readiness

If you checked <3 boxes: Start Part II prepared to learn; ask questions early.


Scoring:

Note: Honest self-assessment helps you learn faster. If you’re uncertain about a box, leave it unchecked and revisit that topic.


📖 Glossary of Key Terms

ARD (Automatic Relevance Determination): Kernel with per-dimension lengthscales d\ell_d, allowing the GP to learn which input dimensions matter most. Small d\ell_d → high sensitivity to dimension dd, large d\ell_d → low sensitivity (GP effectively ignores that dimension).

LHS (Latin Hypercube Sampling): Stratified sampling method ensuring uniform coverage in each dimension separately. Better than random sampling for space-filling experimental designs. Widely used for training surrogate models.

OOD (Out-of-Distribution): Test points far from training data, where the emulator extrapolates and uncertainty is high. Detect via kernel similarity: maxik(x,xi)/σf2<threshold\max_i k(\mathbf{x}_*, \mathbf{x}_i) / \sigma_f^2 < \text{threshold} (e.g., 0.05; validate empirically for your problem as threshold depends on learned hyperparameters).

ICM/LMC (Intrinsic Coregionalization Model / Linear Model of Coregionalization): Multi-output GP methods that model correlations between outputs via cross-covariance functions. Beyond scope of this course; see Álvarez et al. (2012) for details.

Epistemic Uncertainty: Uncertainty about the latent function ff (reducible with more training data). From GP: σ2(x)\sigma_*^2(\mathbf{x}). Also called “model uncertainty” or “knowledge uncertainty.”

Aleatoric Uncertainty: Irreducible noise in observations (measurement error, simulation stochasticity). From likelihood: σn2\sigma_n^2. Also called “data uncertainty.”

Marginal Likelihood (Evidence): p(yX,θ)p(\mathbf{y} | X, \boldsymbol{\theta}), the probability of observing training data given hyperparameters, integrating over all possible functions. Used for Type-II maximum likelihood hyperparameter optimization. Implements Occam’s razor automatically.

Kernel (Covariance Function): k(x,x)k(\mathbf{x}, \mathbf{x}'), measures correlation between function values at inputs x\mathbf{x} and x\mathbf{x}'. Encodes smoothness assumptions and prior beliefs about function structure.

Lengthscale (\ell): Characteristic distance in input space over which function values remain correlated. Small \ell → rapid variation (wiggly functions), large \ell → smooth variation (slowly varying functions). Units: same as input dimensions.

Signal Variance (σf2\sigma_f^2): Prior variance of function values (overall amplitude of variation). Units: output2^2.

Noise Variance (σn2\sigma_n^2): Observation noise level (aleatoric uncertainty). Units: output2^2.

Cholesky Factorization: Decomposition Ky=LLT\mathbf{K}_y = \mathbf{L} \mathbf{L}^T where L\mathbf{L} is lower-triangular. Numerically stable way to solve linear systems and compute determinants. Essential for GP implementation.

Jitter: Small constant added to kernel matrix diagonal to ensure numerical stability: Ky=K+(σn2+ϵjitter)I\mathbf{K}_y = \mathbf{K} + (\sigma_n^2 + \epsilon_{\rm jitter}) \mathbf{I}. Prevents Cholesky failures from near-singular matrices. Typical values: ϵjitter106\epsilon_{\rm jitter} \sim 10^{-6} (scale-aware).

SE (Squared Exponential) Kernel: Also called RBF (Radial Basis Function). Assumes infinitely smooth functions. Often too smooth for real physics.

Matérn Kernel: Family of kernels with tunable smoothness ν\nu. Matérn-5/2 is recommended default (twice differentiable, realistic for physics).

PSD (Positive Semi-Definite): Property required for valid kernels. Ensures covariance matrices have non-negative eigenvalues (variances can’t be negative).

MCMC (Markov Chain Monte Carlo): Sampling method for complex posterior distributions (from Module 5). GPs enable MCMC-based inference by providing fast, differentiable emulators of expensive simulators.

JAX: Just-In-Time compiled array computing library for Python with automatic differentiation. Makes GP implementation fast and enables gradient-based hyperparameter optimization.

JIT (Just-In-Time Compilation): Compilation technique that speeds up Python code to near-C performance. Use @jit decorator in JAX.

vmap (Vectorized Map): JAX function for automatic vectorization. Maps a function over batch dimension efficiently (avoids Python loops).


Continue to Part II for implementation! 🚀

“The best way to understand a Gaussian Process is to implement one.” — Every computational scientist ever