markovflow.likelihoods.multivariate_gaussian

Module containing a multivariate Gaussian likelihood.

Module Contents

class MultivariateGaussian(chol_covariance: gpflow.base.TensorType)[source]

Bases: markovflow.likelihoods.likelihoods.Likelihood

Represents a multivariate Gaussian likelihood. For example:

\[p(yᵢ | fᵢ) = 𝓝(yᵢ; fᵢ, Σ= LLᵀ)\]

See also the documentation for the base Likelihood class.

Parameters

chol_covariance – A TensorType containing the Cholesky factor of the covariance of the Gaussian noise, with shape [obs_dim, obs_dim].

property obs_dimint[source]

Return the dimensionality of each observation.

log_probability_density(fs: tf.Tensor, observations: tf.Tensor)tf.Tensor[source]

Compute the log probability density \(log p(Y|F)\).

For a multivariate Gaussian, this is \(log 𝓝(yᵢ; fᵢ, Σ)\).

Parameters
  • fs – A tensor representing a conditioning variable, with shape batch_shape + [num_data, obs_dim].

  • observations – A tensor representing a conditioned variable, with shape batch_shape + [num_data, obs_dim].

Returns

A tensor representing \(log p(yᵢ | fᵢ)\), with shape batch_shape + [num_data].

variational_expectations(f_means: tf.Tensor, f_covariances: tf.Tensor, observations: tf.Tensor)tf.Tensor[source]

Calculate a variational expectation for each observation:

\[∫ q(fᵢ) log p(yᵢ|fᵢ) dfᵢ\]

…where:

  • \(q(fᵢ) ~ N(μᵢ, Σᵢ)\)

  • \(p(y |f)\) is a general likelihood function

For a multivariate Gaussian this is:

\[∫ 𝓝(fᵢ; μᵢ, Sᵢ) log𝓝(yᵢ; fᵢ, Σ= LLᵀ) dfᵢ = -½ Tr(Σ⁻¹Sᵢ) + log𝓝(yᵢ; μᵢ, Σ)\]
Parameters
  • f_means – The marginal \(f\) means for each state of the StateSpaceModel, with shape batch_shape + [num_data, obs_dim].

  • f_covariances – The marginal \(f\) covariances for each state of the StateSpaceModel, with shape batch_shape + [num_data, obs_dim, obs_dim].

  • observations – The \(y\) values at which to evaluate the log probability, with shape batch_shape + [num_data, obs_dim].

Returns

A tensor with shape batch_shape + [num_data].

predict_density(f_means: tf.Tensor, f_covariances: tf.Tensor, observations: tf.Tensor)tf.Tensor[source]

Predict a density. This calculates:

\[∫ q(F) p(Y|F) dF\]

…of a Gaussian approximation \(q(F) ~ N(μ, Σ)\) to the posterior density \(p(F|Y)\).

For a multivariate Gaussian this is:

\[log ∫ 𝓝(fᵢ; μᵢ, Sᵢ) 𝓝(yᵢ; fᵢ, Σ= LLᵀ) dfᵢ = log 𝓝(yᵢ; μᵢ, Σ + Sᵢ)\]
Parameters
  • f_means – The marginal \(f\) means for each state of the StateSpaceModel, with shape batch_shape + [num_data, obs_dim].

  • f_covariances – The marginal \(f\) covariances for each state of the StateSpaceModel, with shape batch_shape + [num_data, obs_dim, obs_dim].

  • observations – The \(y\) values at which to evaluate the log probability, with shape batch_shape + [num_data, obs_dim].

predict_mean_and_var(f_means: tf.Tensor, f_covariances: tf.Tensor)Tuple[tf.Tensor, tf.Tensor][source]

Predict the observation means and covariances given the f-space means and covariances.

That is, calculate:

\[p(y* | x*, x, y) = ∫ p(y* | f*) p(f* | x*, x, y) df*\]

…where:

  • f_means and f_covariances is our representation of \(p(f* | x*, x, y)\)

  • \(p(y* | f*)\) is defined by the likelihood

For a multivariate Gaussian this is:

\[p(y* | x*, x, y) = ∫ 𝓝(f*; μ*, S*) 𝓝(y*; f*, Σ= LLᵀ) dfᵢ = 𝓝(y*; μ*, Σ + S*)\]
Parameters
  • f_means – The marginal \(f\) means for some arbitrary predicted time points, with shape batch_shape + [num_data, obs_dim].

  • f_covariances – The marginal \(f\) covariances for some arbitrary predicted time points, with shape batch_shape + [num_data, obs_dim, obs_dim].

Returns

A tuple of tensors containing observation means and covariances, with respective shapes batch_shape + [num_time_points, obs_dim], batch_shape + [num_time_points, obs_dim, obs_dim].