Class MultivariateNormal

  • All Implemented Interfaces:
    java.io.Serializable , jline.lang.Copyable

    
    public class MultivariateNormal
    extends ContinuousDistribution implements Serializable
                        

    A multivariate normal (Gaussian) distribution. Represents a d-dimensional normal distribution with mean vector mu and covariance matrix Sigma. The distribution can be used standalone or within a Prior for mixture models.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      int getDimension() Gets the dimensionality of this distribution.
      Matrix getMeanVector() Gets the mean vector.
      Matrix getCovariance() Gets the covariance matrix.
      Matrix getCorrelation() Gets the correlation matrix from the covariance matrix.
      double getMean() Gets the mean of the first component (for Prior compatibility).
      double getVar() Gets the variance of the first component.
      double getSCV() Gets the squared coefficient of variation (not meaningful for multivariate).
      double getSkewness() Gets the skewness.
      Array<double> sample(int n, Random random) Generates random samples from the distribution.
      Matrix sampleMatrix(int n, Random random) Generates random samples from the distribution.
      double evalPDF(Matrix x) Evaluates the probability density function.
      double evalPDF(Array<double> x) Evaluates the probability density function.
      double evalCDF(double t) CDF is not well-defined for multivariate distributions.
      double evalLST(double s) LST is not well-defined for multivariate distributions.
      MultivariateNormal getMarginal(Array<int> indices) Extracts a marginal distribution for a subset of dimensions.
      Normal getMarginalUniv(int index) Extracts a univariate marginal distribution.
      MatrixCell getProcess() Gets the process representation with actual distribution parameters.
      String toString()
      • Methods inherited from class jline.lang.processes.Distribution

        evalProbInterval, getName, getNumParams, getParam, getRate, getSupport, isContinuous, isDisabled, isDiscrete, isImmediate, isMarkovian, mean, name, numParams, param, rate, sample, scv, setNumParams, setParam, skewness, support, var
      • Methods inherited from class jline.lang.Copyable

        copy
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultivariateNormal

        MultivariateNormal(Array<double> mu, Matrix Sigma)
        Creates a multivariate normal distribution.
        Parameters:
        mu - Mean vector (d-dimensional)
        Sigma - Covariance matrix (d x d, must be positive definite)
      • MultivariateNormal

        MultivariateNormal(Matrix mu, Matrix Sigma)
        Creates a multivariate normal distribution.
        Parameters:
        mu - Mean vector (d x 1 Matrix)
        Sigma - Covariance matrix (d x d, must be positive definite)
    • Method Detail

      • getDimension

         int getDimension()

        Gets the dimensionality of this distribution.

        Returns:

        the number of dimensions d

      • getMeanVector

         Matrix getMeanVector()

        Gets the mean vector.

        Returns:

        d x 1 Matrix containing the mean

      • getCovariance

         Matrix getCovariance()

        Gets the covariance matrix.

        Returns:

        d x d Matrix containing the covariance

      • getCorrelation

         Matrix getCorrelation()

        Gets the correlation matrix from the covariance matrix.

        Returns:

        d x d Matrix containing the correlation coefficients

      • getMean

         double getMean()

        Gets the mean of the first component (for Prior compatibility). For multivariate use, prefer getMeanVector().

        Returns:

        the mean of the first dimension

      • getVar

         double getVar()

        Gets the variance of the first component.

        Returns:

        the variance of the first dimension

      • getSCV

         double getSCV()

        Gets the squared coefficient of variation (not meaningful for multivariate).

        Returns:

        Double.NaN (not defined for multivariate distributions)

      • getSkewness

         double getSkewness()

        Gets the skewness.

        Returns:

        0.0 (multivariate normal is symmetric)

      • sample

         Array<double> sample(int n, Random random)

        Generates random samples from the distribution. Uses the Cholesky decomposition: X = mu + L*Z where Z ~ N(0, I).

        Parameters:
        n - the number of samples to generate
        random - the random number generator to use
        Returns:

        flattened array of n*d samples (each dimension is a column)

      • sampleMatrix

         Matrix sampleMatrix(int n, Random random)

        Generates random samples from the distribution. Returns samples as an n x d matrix.

        Parameters:
        n - the number of samples to generate
        random - the random number generator to use
        Returns:

        n x d Matrix of samples

      • evalPDF

         double evalPDF(Matrix x)

        Evaluates the probability density function.

        Parameters:
        x - the point at which to evaluate (d x 1 Matrix)
        Returns:

        the PDF value at x

      • evalPDF

         double evalPDF(Array<double> x)

        Evaluates the probability density function.

        Parameters:
        x - the point at which to evaluate (d-dimensional array)
        Returns:

        the PDF value at x

      • evalCDF

         double evalCDF(double t)

        CDF is not well-defined for multivariate distributions.

        Parameters:
        t - ignored
        Returns:

        never returns

      • evalLST

         double evalLST(double s)

        LST is not well-defined for multivariate distributions.

        Parameters:
        s - ignored
        Returns:

        never returns

      • getMarginal

         MultivariateNormal getMarginal(Array<int> indices)

        Extracts a marginal distribution for a subset of dimensions.

        Parameters:
        indices - array of dimension indices to keep (0-based)
        Returns:

        MultivariateNormal distribution for the marginal

      • getMarginalUniv

         Normal getMarginalUniv(int index)

        Extracts a univariate marginal distribution.

        Parameters:
        index - dimension index to extract (0-based)
        Returns:

        Normal distribution for that dimension

      • getProcess

         MatrixCell getProcess()

        Gets the process representation with actual distribution parameters.

        Returns:

        MatrixCell containing mu and Sigma