org.apache.commons.math3.distribution

## Class MixtureMultivariateRealDistribution<T extends MultivariateRealDistribution>

- java.lang.Object
- - org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution
  - - org.apache.commons.math3.distribution.MixtureMultivariateRealDistribution<T>

- Type Parameters:
    `T` - Type of the mixture components.
  All Implemented Interfaces:
    MultivariateRealDistribution

      public class MixtureMultivariateRealDistribution<T extends MultivariateRealDistribution>
      extends AbstractMultivariateRealDistribution

  Class for representing mixture model distributions.
  Since:
    3.1
  Version:
    $Id: MixtureMultivariateRealDistribution.java 1416643 2012-12-03 19:37:14Z tn $

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.util.List<T>` | `distribution` Mixture components.
    `private double[]` | `weight` Normalized weight of each mixture component.

    - ### Fields inherited from class org.apache.commons.math3.distribution.AbstractMultivariateRealDistribution

      `random`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MixtureMultivariateRealDistribution(java.util.List<Pair<java.lang.Double,T>> components)` Creates a mixture model from a list of distributions and their associated weights.
    `MixtureMultivariateRealDistribution(RandomGenerator rng, java.util.List<Pair<java.lang.Double,T>> components)` Creates a mixture model from a list of distributions and their associated weights.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `double` | `density(double[] values)` Returns the probability density function (PDF) of this distribution evaluated at the specified point `x`.
    `java.util.List<Pair<java.lang.Double,T>>` | `getComponents()` 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.apache.commons.math3.distribution.AbstractMultivariateRealDistribution

      `getDimension, sample`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### weight

          private final double[] weight

      Normalized weight of each mixture component.

    - #### distribution

          private final java.util.List<T extends MultivariateRealDistribution> distribution

      Mixture components.

  - ### Constructor Detail

    - #### MixtureMultivariateRealDistribution

          public MixtureMultivariateRealDistribution(java.util.List<Pair<java.lang.Double,T>> components)

      Creates a mixture model from a list of distributions and their associated weights.
      Parameters:
        `components` - List of (weight, distribution) pairs from which to sample.

    - #### MixtureMultivariateRealDistribution

          public MixtureMultivariateRealDistribution(RandomGenerator rng,
                                             java.util.List<Pair<java.lang.Double,T>> components)

      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:
        `NotPositiveException` - if any of the weights is negative.
        `DimensionMismatchException` - if not all components have the same number of variables.

  - ### Method Detail

    - #### density

          public double density(double[] values)

      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` - 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 interface `MultivariateRealDistribution`
      Specified by:
        `sample` in class `AbstractMultivariateRealDistribution`
      Returns:
        a random value vector.

    - #### reseedRandomGenerator

          public void reseedRandomGenerator(long seed)

      Reseeds the random generator used to generate samples.
      Specified by:
        `reseedRandomGenerator` in interface `MultivariateRealDistribution`
      Overrides:
        `reseedRandomGenerator` in class `AbstractMultivariateRealDistribution`
      Parameters:
        `seed` - Seed with which to initialize the random number generator.

    - #### getComponents

          public java.util.List<Pair<java.lang.Double,T>> getComponents()

      Gets the distributions that make up the mixture model.
      Returns:
        the component distributions and associated weights.

Copyright (c) 2003-2013 Apache Software Foundation