ExactPosterior#

class gpjax.conditioning.ExactPosterior(prior, likelihood, train_data)[source]#

Bases: Posterior

Exactly conditioned GP: a Gaussian likelihood integrated analytically.

Caches the lower Cholesky factor of \(\Sigma = K_{xx} + \texttt{jitter}\,\mathbf{I} + \mathrm{diag}(\sigma^2)\) and the representer weights \(\alpha = \Sigma^{-1}(y - m(x))\). The predictive moments, the evidence, LOO densities, and pathwise samples are all views of these two objects.

Parameters:
loo()[source]#

Per-point leave-one-out predictive log-densities.

Computed from the cached factor via Rasmussen & Williams eq. 5.12 — no model is refit. Sum the result for the LOOCV objective.

Return type:

Float[jaxlib._jax.Array, ‘NP’] | Float[ndarray, ‘NP’]

sample_approx(num_samples, key, num_features=100)[source]#

Draw approximate posterior samples via pathwise conditioning.

Decomposes each sample into Fourier features of the prior plus canonical features weighted through the cached training factor (Wilson et al., 2020).

Parameters:
  • num_samples (int) – The desired number of samples.

  • key (UInt32[jaxlib._jax.Array, '2'] | Key[jaxlib._jax.Array, '']) – The random seed used for the sample(s).

  • num_features (int | None) – The number of Fourier features used to approximate the prior component of each sample.

Returns:

A function evaluating the sample draws at any

inputs; the same draw is returned for all queries.

Return type:

FunctionalSample