Package org.tribuo.math.distributions
Class MultivariateNormalDistribution
java.lang.Object
org.tribuo.math.distributions.MultivariateNormalDistribution
A class for sampling from multivariate normal distributions.
-
Constructor Summary
ConstructorDescriptionMultivariateNormalDistribution
(double[] means, double[][] covariance, long seed) Constructs a multivariate normal distribution that can be sampled from.MultivariateNormalDistribution
(double[] means, double[][] covariance, long seed, boolean eigenDecomposition) Constructs a multivariate normal distribution that can be sampled from.MultivariateNormalDistribution
(DenseVector means, DenseMatrix covariance, long seed) Constructs a multivariate normal distribution that can be sampled from.MultivariateNormalDistribution
(DenseVector means, DenseMatrix covariance, long seed, boolean eigenDecomposition) Constructs a multivariate normal distribution that can be sampled from. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]
Sample a vector from this multivariate normal distribution.Sample a vector from this multivariate normal distribution.toString()
-
Constructor Details
-
MultivariateNormalDistribution
public MultivariateNormalDistribution(double[] means, double[][] covariance, long seed) Constructs a multivariate normal distribution that can be sampled from.Throws
IllegalArgumentException
if the covariance matrix is not positive definite.Uses a
DenseMatrix.CholeskyFactorization
to compute the sampling covariance matrix.- Parameters:
means
- The mean vector.covariance
- The covariance matrix.seed
- The RNG seed.
-
MultivariateNormalDistribution
public MultivariateNormalDistribution(double[] means, double[][] covariance, long seed, boolean eigenDecomposition) Constructs a multivariate normal distribution that can be sampled from.Throws
IllegalArgumentException
if the covariance matrix is not positive definite.- Parameters:
means
- The mean vector.covariance
- The covariance matrix.seed
- The RNG seed.eigenDecomposition
- If true use an eigen decomposition to compute the sampling covariance matrix rather than a cholesky factorization.
-
MultivariateNormalDistribution
Constructs a multivariate normal distribution that can be sampled from.Throws
IllegalArgumentException
if the covariance matrix is not positive definite.Uses a
DenseMatrix.CholeskyFactorization
to compute the sampling covariance matrix.- Parameters:
means
- The mean vector.covariance
- The covariance matrix.seed
- The RNG seed.
-
MultivariateNormalDistribution
public MultivariateNormalDistribution(DenseVector means, DenseMatrix covariance, long seed, boolean eigenDecomposition) Constructs a multivariate normal distribution that can be sampled from.Throws
IllegalArgumentException
if the covariance matrix is not positive definite.- Parameters:
means
- The mean vector.covariance
- The covariance matrix.seed
- The RNG seed.eigenDecomposition
- If true use an eigen decomposition to compute the sampling covariance matrix rather than a cholesky factorization.
-
-
Method Details
-
sampleVector
Sample a vector from this multivariate normal distribution.- Returns:
- A sample from this distribution.
-
sampleArray
public double[] sampleArray()Sample a vector from this multivariate normal distribution.- Returns:
- A sample from this distribution.
-
toString
-