Top Description Fields Constructors Methods
org.apache.commons.math3.distribution

public Class MixtureMultivariateRealDistribution<T extends MultivariateRealDistribution>

extends AbstractMultivariateRealDistribution
Class Inheritance
Known Direct Subclasses
org.apache.commons.math3.distribution.MixtureMultivariateNormalDistribution
Type Parameters
<T>
Type of the mixture components.
Imports
java.util.ArrayList, .List, org.apache.commons.math3.exception.DimensionMismatchException, .MathArithmeticException, .NotPositiveException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.random.RandomGenerator, .Well19937c, org.apache.commons.math3.util.Pair

Class for representing mixture model distributions.
Since
3.1

Field Summary

Modifier and TypeField and Description
private final List<T>
distribution

Mixture components.

private final double[]
weight

Normalized weight of each mixture component.

Inherited from org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution:
random

Constructor Summary

AccessConstructor and Description
public
MixtureMultivariateRealDistribution(List<Pair<Double, T>>
List of (weight, distribution) pairs from which to sample.
components
)

Creates a mixture model from a list of distributions and their associated weights.

public
MixtureMultivariateRealDistribution(RandomGenerator
Random number generator.
rng
,
List<Pair<Double, T>>
Distributions from which to sample.
components
)

Creates a mixture model from a list of distributions and their associated weights.

Method Summary

Modifier and TypeMethod and Description
public double
density(final double[]
Point at which the PDF is evaluated.
values
)

Implements org.apache.commons.math3.distribution.MultivariateRealDistribution.density.

Returns the probability density function (PDF) of this distribution evaluated at the specified point x.

public List<Pair<Double, T>>

Returns:

the component distributions and associated weights.
getComponents
()

Gets the distributions that make up the mixture model.

public void
reseedRandomGenerator(long
Seed with which to initialize the random number generator.
seed
)

Overrides org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution.reseedRandomGenerator.

Implements org.apache.commons.math3.distribution.MultivariateRealDistribution.reseedRandomGenerator.

Reseeds the random generator used to generate samples.

public double[]
Inherited from org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution:
getDimensionsample

Field Detail

distributionback to summary
private final List<T> distribution

Mixture components.

weightback to summary
private final double[] weight

Normalized weight of each mixture component.

Constructor Detail

MixtureMultivariateRealDistributionback to summary
public MixtureMultivariateRealDistribution(List<Pair<Double, T>> components)

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 (see sample() and sample(int)). In case no sampling is needed for the created distribution, it is advised to pass null as random generator via the appropriate constructors to avoid the additional initialisation overhead.

Parameters
components:List<Pair<Double, T>>

List of (weight, distribution) pairs from which to sample.

MixtureMultivariateRealDistributionback to summary
public MixtureMultivariateRealDistribution(RandomGenerator rng, List<Pair<Double, T>> components)

Creates a mixture model from a list of distributions and their associated weights.

Parameters
rng:RandomGenerator

Random number generator.

components:List<Pair<Double, T>>

Distributions from which to sample.

Exceptions
NotPositiveException:
if any of the weights is negative.
DimensionMismatchException:
if not all components have the same number of variables.

Method Detail

densityback to summary
public double density(final double[] values)

Implements org.apache.commons.math3.distribution.MultivariateRealDistribution.density.

Doc from org.apache.commons.math3.distribution.MultivariateRealDistribution.density.

Returns the probability density function (PDF) of this distribution evaluated at the specified point x. In general, the PDF is the derivative of the cumulative distribution function. If the derivative does not exist at x, 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:double[]

Point at which the PDF is evaluated.

Returns:double

the value of the probability density function at point x.

getComponentsback to summary
public List<Pair<Double, T>> getComponents()

Gets the distributions that make up the mixture model.

Returns:List<Pair<Double, T>>

the component distributions and associated weights.

reseedRandomGeneratorback to summary
public void reseedRandomGenerator(long seed)

Overrides org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution.reseedRandomGenerator.

Implements org.apache.commons.math3.distribution.MultivariateRealDistribution.reseedRandomGenerator.

Doc from org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution.reseedRandomGenerator.

Reseeds the random generator used to generate samples.

Parameters
seed:long

Doc from org.apache.commons.math3.distribution.MultivariateRealDistribution.reseedRandomGenerator.

Seed with which to initialize the random number generator.

Annotations
@Override
sampleback to summary
public double[] sample()

Implements abstract org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution.sample.

Implements org.apache.commons.math3.distribution.MultivariateRealDistribution.sample.

Doc from org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution.sample.

Generates a random value vector sampled from this distribution.

Returns:double[]

Doc from org.apache.commons.math3.distribution.MultivariateRealDistribution.sample.

a random value vector.

Annotations
@Override