Class MultivariateNormalDistribution

java.lang.Object
org.tribuo.math.distributions.MultivariateNormalDistribution

public final class MultivariateNormalDistribution extends Object
A class for sampling from multivariate normal distributions.
  • 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

      public MultivariateNormalDistribution(DenseVector means, DenseMatrix 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(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

      public DenseVector 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

      public String toString()
      Overrides:
      toString in class Object