Class MultivariateNormalDistribution
- All Implemented Interfaces:
MultivariateRealDistribution
-
Field Summary
Fields inherited from class org.hipparchus.distribution.multivariate.AbstractMultivariateRealDistribution
random
-
Constructor Summary
ConstructorDescriptionMultivariateNormalDistribution
(double[] means, double[][] covariances) Creates a multivariate normal distribution with the given mean vector and covariance matrix.
The number of dimensions is equal to the length of the mean vector and to the number of rows and columns of the covariance matrix.MultivariateNormalDistribution
(double[] means, double[][] covariances, double singularMatrixCheckTolerance) Creates a multivariate normal distribution with the given mean vector and covariance matrix.
The number of dimensions is equal to the length of the mean vector and to the number of rows and columns of the covariance matrix.MultivariateNormalDistribution
(RandomGenerator rng, double[] means, double[][] covariances) Creates a multivariate normal distribution with the given mean vector and covariance matrix.MultivariateNormalDistribution
(RandomGenerator rng, double[] means, double[][] covariances, double singularMatrixCheckTolerance) Creates a multivariate normal distribution with the given mean vector and covariance matrix. -
Method Summary
Modifier and TypeMethodDescriptiondouble
density
(double[] vals) Returns the probability density function (PDF) of this distribution evaluated at the specified pointx
.Gets the covariance matrix.double[]
getMeans()
Gets the mean vector.double
Gets the current setting for the tolerance check used during singular checks before inversiondouble[]
Gets the square root of each element on the diagonal of the covariance matrix.double[]
sample()
Generates a random value vector sampled from this distribution.Methods inherited from class org.hipparchus.distribution.multivariate.AbstractMultivariateRealDistribution
getDimension, reseedRandomGenerator, sample
-
Constructor Details
-
MultivariateNormalDistribution
public MultivariateNormalDistribution(double[] means, double[][] covariances) throws MathIllegalArgumentException Creates a multivariate normal distribution with the given mean vector and covariance matrix.
The number of dimensions is equal to the length of the mean vector and to the number of rows and columns of the covariance matrix. It is frequently written as "p" in formulae.Note: this constructor will implicitly create an instance of
Well19937c
as random generator to be used for sampling only (seesample()
andAbstractMultivariateRealDistribution.sample(int)
). In case no sampling is needed for the created distribution, it is advised to passnull
as random generator via the appropriate constructors to avoid the additional initialisation overhead.- Parameters:
means
- Vector of means.covariances
- Covariance matrix.- Throws:
MathIllegalArgumentException
- if the arrays length are inconsistent.MathIllegalArgumentException
- if the eigenvalue decomposition cannot be performed on the provided covariance matrix.MathIllegalArgumentException
- if any of the eigenvalues is negative.
-
MultivariateNormalDistribution
public MultivariateNormalDistribution(double[] means, double[][] covariances, double singularMatrixCheckTolerance) throws MathIllegalArgumentException Creates a multivariate normal distribution with the given mean vector and covariance matrix.
The number of dimensions is equal to the length of the mean vector and to the number of rows and columns of the covariance matrix. It is frequently written as "p" in formulae.Note: this constructor will implicitly create an instance of
Well19937c
as random generator to be used for sampling only (seesample()
andAbstractMultivariateRealDistribution.sample(int)
). In case no sampling is needed for the created distribution, it is advised to passnull
as random generator via the appropriate constructors to avoid the additional initialisation overhead.- Parameters:
means
- Vector of means.covariances
- Covariance matrix.singularMatrixCheckTolerance
- Tolerance used during the singular matrix check before inversion- Throws:
MathIllegalArgumentException
- if the arrays length are inconsistent.MathIllegalArgumentException
- if the eigenvalue decomposition cannot be performed on the provided covariance matrix.MathIllegalArgumentException
- if any of the eigenvalues is negative.
-
MultivariateNormalDistribution
Creates a multivariate normal distribution with the given mean vector and covariance matrix.
The number of dimensions is equal to the length of the mean vector and to the number of rows and columns of the covariance matrix. It is frequently written as "p" in formulae.- Parameters:
rng
- Random Number Generator.means
- Vector of means.covariances
- Covariance matrix.- Throws:
MathIllegalArgumentException
- if the arrays length are inconsistent.MathIllegalArgumentException
- if the eigenvalue decomposition cannot be performed on the provided covariance matrix.MathIllegalArgumentException
- if any of the eigenvalues is negative.
-
MultivariateNormalDistribution
public MultivariateNormalDistribution(RandomGenerator rng, double[] means, double[][] covariances, double singularMatrixCheckTolerance) throws MathIllegalArgumentException Creates a multivariate normal distribution with the given mean vector and covariance matrix.
The number of dimensions is equal to the length of the mean vector and to the number of rows and columns of the covariance matrix. It is frequently written as "p" in formulae.- Parameters:
rng
- Random Number Generator.means
- Vector of means.covariances
- Covariance matrix.singularMatrixCheckTolerance
- Tolerance used during the singular matrix check before inversion- Throws:
MathIllegalArgumentException
- if the arrays length are inconsistent.MathIllegalArgumentException
- if the eigenvalue decomposition cannot be performed on the provided covariance matrix.MathIllegalArgumentException
- if any of the eigenvalues is negative.
-
-
Method Details
-
getMeans
public double[] getMeans()Gets the mean vector.- Returns:
- the mean vector.
-
getCovariances
Gets the covariance matrix.- Returns:
- the covariance matrix.
-
getSingularMatrixCheckTolerance
public double getSingularMatrixCheckTolerance()Gets the current setting for the tolerance check used during singular checks before inversion- Returns:
- tolerance
-
density
Returns the probability density function (PDF) of this distribution evaluated at the specified pointx
. In general, the PDF is the derivative of the cumulative distribution function. If the derivative does not exist atx
, then an appropriate replacement should be returned, e.g.Double.POSITIVE_INFINITY
,Double.NaN
, or the limit inferior or limit superior of the difference quotient.- Parameters:
vals
- Point at which the PDF is evaluated.- Returns:
- the value of the probability density function at point
x
. - Throws:
MathIllegalArgumentException
-
getStandardDeviations
public double[] getStandardDeviations()Gets the square root of each element on the diagonal of the covariance matrix.- Returns:
- the standard deviations.
-
sample
public double[] sample()Generates a random value vector sampled from this distribution.- Specified by:
sample
in interfaceMultivariateRealDistribution
- Specified by:
sample
in classAbstractMultivariateRealDistribution
- Returns:
- a random value vector.
-