gpflux.sampling.utils#

This module contains utilities for sampling from multivariate Gaussian distributions.

Module Contents#

_cholesky_with_jitter(cov: gpflow.base.TensorType) tf.Tensor[source]#

Compute the Cholesky of the covariance, adding jitter (determined by gpflow.default_jitter()) to the diagonal to improve stability.

Parameters:

cov – full covariance with shape [..., N, D, D].

draw_conditional_sample(mean: gpflow.base.TensorType, cov: gpflow.base.TensorType, f_old: gpflow.base.TensorType) tf.Tensor[source]#

Draw a sample \(\tilde{f}_\text{new}\) from the conditional multivariate Gaussian \(p(f_\text{new} | f_\text{old})\), where the parameters mean and cov are the mean and covariance matrix of the joint multivariate Gaussian over \([f_\text{old}, f_\text{new}]\).

Parameters:
  • mean

    A tensor with the shape [..., D, N+M] with the mean of [f_old, f_new]. For each [..., D] this is a stacked vector of the form:

    \[\begin{split}\begin{pmatrix} \operatorname{mean}(f_\text{old}) \;[N] \\ \operatorname{mean}(f_\text{new}) \;[M] \end{pmatrix}\end{split}\]

  • cov

    A tensor with the shape [..., D, N+M, N+M] with the covariance of [f_old, f_new]. For each [..., D], there is a 2x2 block matrix of the form:

    \[\begin{split}\begin{pmatrix} \operatorname{cov}(f_\text{old}, f_\text{old}) \;[N, N] & \operatorname{cov}(f_\text{old}, f_\text{new}) \;[N, M] \\ \operatorname{cov}(f_\text{new}, f_\text{old}) \;[M, N] & \operatorname{cov}(f_\text{new}, f_\text{new}) \;[M, M] \end{pmatrix}\end{split}\]

  • f_old – A tensor of observations with the shape [..., D, N], drawn from Normal distribution with mean \(\operatorname{mean}(f_\text{old}) \;[N]\), and covariance \(\operatorname{cov}(f_\text{old}, f_\text{old}) \;[N, N]\)

Returns:

A sample \(\tilde{f}_\text{new}\) from the conditional normal \(p(f_\text{new} | f_\text{old})\) with the shape [..., D, M].