Class MixtureMultivariateRealDistribution<T extends MultivariateRealDistribution>
java.lang.Object
org.hipparchus.distribution.multivariate.AbstractMultivariateRealDistribution
org.hipparchus.distribution.multivariate.MixtureMultivariateRealDistribution<T>
- Type Parameters:
T
- Type of the mixture components.
- All Implemented Interfaces:
MultivariateRealDistribution
- Direct Known Subclasses:
MixtureMultivariateNormalDistribution
public class MixtureMultivariateRealDistribution<T extends MultivariateRealDistribution>
extends AbstractMultivariateRealDistribution
Class for representing
mixture model distributions.
-
Field Summary
Fields inherited from class org.hipparchus.distribution.multivariate.AbstractMultivariateRealDistribution
random
-
Constructor Summary
ConstructorDescriptionMixtureMultivariateRealDistribution
(List<Pair<Double, T>> components) Creates a mixture model from a list of distributions and their associated weights.MixtureMultivariateRealDistribution
(RandomGenerator rng, List<Pair<Double, T>> components) Creates a mixture model from a list of distributions and their associated weights. -
Method Summary
Modifier and TypeMethodDescriptiondouble
density
(double[] values) Returns the probability density function (PDF) of this distribution evaluated at the specified pointx
.Gets the distributions that make up the mixture model.void
reseedRandomGenerator
(long seed) Reseeds the random generator used to generate samples.double[]
sample()
Generates a random value vector sampled from this distribution.Methods inherited from class org.hipparchus.distribution.multivariate.AbstractMultivariateRealDistribution
getDimension, sample
-
Constructor Details
-
MixtureMultivariateRealDistribution
Creates a mixture model from a list of distributions and their associated weights.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:
components
- List of (weight, distribution) pairs from which to sample.
-
MixtureMultivariateRealDistribution
Creates a mixture model from a list of distributions and their associated weights.- Parameters:
rng
- Random number generator.components
- Distributions from which to sample.- Throws:
MathIllegalArgumentException
- if any of the weights is negative.MathIllegalArgumentException
- if not all components have the same number of variables.
-
-
Method Details
-
density
public double density(double[] values) 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:
values
- Point at which the PDF is evaluated.- Returns:
- the value of the probability density function at point
x
.
-
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.
-
reseedRandomGenerator
public void reseedRandomGenerator(long seed) Reseeds the random generator used to generate samples.- Specified by:
reseedRandomGenerator
in interfaceMultivariateRealDistribution
- Overrides:
reseedRandomGenerator
in classAbstractMultivariateRealDistribution
- Parameters:
seed
- Seed with which to initialize the random number generator.
-
getComponents
Gets the distributions that make up the mixture model.- Returns:
- the component distributions and associated weights.
-