osl_dynamics.inference.ops.mvn_log_prob#

osl_dynamics.inference.ops.mvn_log_prob(x, mu, sigma)#

Multivariate normal log-likelihood with an analytic gradient.

The log-likelihood is calculated with tfp.distributions.MultivariateNormalTriL. The gradient is calculated from

  • \(\partial \log p / \partial \mu = \Sigma^{-1} (x - \mu)\)

  • \(\partial \log p / \partial \Sigma = -\frac{1}{2} (\Sigma^{-1} - \Sigma^{-1} (x - \mu) (x - \mu)^T \Sigma^{-1})\)

using the Cholesky factor from the forward pass.

Parameters:
xtf.Tensor

Data. Shape is (…, n_channels).

mutf.Tensor

Means. Shape is (…, n_channels).

sigmatf.Tensor

Covariances. Shape is (…, n_channels, n_channels). All inputs must have the same batch shape (…).

Returns:
log_probtf.Tensor

Log-likelihood. Shape is (…).