Examples

The repository contains runnable scripts in the examples/ directory. The pages below are rendered from a selected subset of those scripts. Each page states the objective, shows at least one plot, and then includes the full script so that the example can be copied or run directly.

Example coverage

The selected examples cover the main GPmp operations:

Notation used below

The example pages use the same names as the scripts. Observation points are stored in xi and written mathematically as \(x_i\). Prediction points are stored in xt and written as \(x_t\).

The latent process is denoted by \(Z\). A typical model is

\[Z \sim \mathcal{GP}(m, k_\theta),\]

where \(m\) is the mean function and \(k_\theta\) is the covariance kernel. In the fixed-regularity Matérn examples, the covariance parameter vector follows the sigma2_rho layout

\[\theta = \mathrm{covparam} = \left(\log(\sigma^2), -\log(\rho_0), \ldots, -\log(\rho_{d-1})\right).\]

The matern example uses the sigma2_nu_rho layout

\[\theta = \left(\log(\sigma^2), \log(\nu), -\log(\rho_0), \ldots, -\log(\rho_{d-1})\right).\]

The covariance kernel is written with a lowercase symbol \(k_\theta\). Covariance matrices and blocks are written with uppercase symbols. For example, \(K_{ii}\) is the matrix with entries \(k_\theta(x_i^a, x_i^b)\), and \(K_{it}\) contains the covariances between observation points and prediction points.

Random variables use uppercase letters. Thus \(Z_i = Z(x_i)\) and \(Z_t = Z(x_t)\) are random variables. The arrays zi and zt store realizations, denoted by lowercase \(z_i\) and \(z_t\).

Selected examples

Topic

Page

What it illustrates

Matérn covariance functions

Plotting Matérn covariances

Compare half-integer and nu-parameterized Matérn kernels.

1D interpolation

1D interpolation

Build a noise-free GP interpolator, select covariance parameters, and plot the posterior.

2D interpolation

2D interpolation

Build an anisotropic Matérn GP and inspect reference, prediction, error, and uncertainty fields.

Higher-dimensional interpolation

Higher-dimensional interpolation

Use leave-one-out diagnostics when spatial plotting is no longer practical.

Matérn regularity selection

Higher-dimensional interpolation with Matérn regularity selection

Select the Matérn regularity together with variance and lengthscales.

Custom covariance

Custom covariance

Define and use a covariance callable with the GPmp model interface.

Noisy observations

Noisy observations

Model noisy observations while predicting the latent process.

Conditional sample paths

Conditional sample paths

Generate posterior sample paths in the noise-free setting.

Noisy conditional sample paths

Noisy conditional sample paths

Generate conditional paths when observations have heteroscedastic noise.

ML / REML / REMAP comparison

ML / REML / REMAP parameter selection

Compare parameter-selection criteria on the same one-dimensional setup.

Posterior parameter sampling

Posterior parameter sampling

Start from REMAP selection and explore covariance-parameter uncertainty.

Dataloader-based selection

Dataloader-based parameter selection

Use Dataset and DataLoader objects for batched parameter selection.

Running examples locally

Run an example from the repository root, for instance:

python examples/gpmp_example02_1d_interpolation.py

When writing new examples, prefer the same structure: define data generation, define the model, select covariance parameters, run prediction or diagnostics, and keep plotting in small functions.