distr_multivariate_normal function

Gaussian distribution

Gaussian distribution

Creates a multivariate normal (also called Gaussian) distribution parameterized by a mean vector and a covariance matrix.

distr_multivariate_normal( loc, covariance_matrix = NULL, precision_matrix = NULL, scale_tril = NULL, validate_args = NULL )

Arguments

  • loc: (Tensor): mean of the distribution
  • covariance_matrix: (Tensor): positive-definite covariance matrix
  • precision_matrix: (Tensor): positive-definite precision matrix
  • scale_tril: (Tensor): lower-triangular factor of covariance, with positive-valued diagonal
  • validate_args: Bool wether to validate the arguments or not.

Details

The multivariate normal distribution can be parameterized either in terms of a positive definite covariance matrix Σ\mathbf{\Sigma}

or a positive definite precision matrix Σ1\mathbf{\Sigma}^{-1}

or a lower-triangular matrix L\mathbf{L} with positive-valued diagonal entries, such that Σ=LL\mathbf{\Sigma} = \mathbf{L}\mathbf{L}^\top. This triangular matrix can be obtained via e.g. Cholesky decomposition of the covariance.

Note

Only one of covariance_matrix or precision_matrix or scale_tril can be specified. Using scale_tril will be more efficient: all computations internally are based on scale_tril. If covariance_matrix or precision_matrix is passed instead, it is only used to compute the corresponding lower triangular matrices using a Cholesky decomposition.

Examples

if (torch_is_installed()) { m <- distr_multivariate_normal(torch_zeros(2), torch_eye(2)) m$sample() # normally distributed with mean=`[0,0]` and covariance_matrix=`I` }

See Also

Distribution for details on the available methods.

Other distributions: distr_bernoulli(), distr_chi2(), distr_gamma(), distr_normal(), distr_poisson()

  • Maintainer: Daniel Falbel
  • License: MIT + file LICENSE
  • Last published: 2025-02-14