This class implements random variate generators for a mixture distribution. More...
Public Member Functions | |
| MixtureGen (RandomStream s, Distribution[] dists, double[] weights) | |
| Creates a new mixture distribution generator defined by the given. | |
| double | nextDouble () |
| Generates a random number from the continuous distribution contained in this object. | |
Mixture distribution parameters @{ | |
| Distribution | getDistribution () |
| This method is not supported, it will throw an UnsupportedOperationException. | |
| Distribution[] | getDistributions () |
| Returns the distributions of this mixture. | |
| double[] | getWeights () |
| Returns the probability associated with each distribution of the mixture. | |
| Public Member Functions inherited from umontreal.ssj.randvar.RandomVariateGen | |
| RandomVariateGen (RandomStream s, Distribution dist) | |
| Creates a new random variate generator from the distribution dist, using stream s. | |
| void | nextArrayOfDouble (double[] v, int start, int n) |
| Generates n random numbers from the continuous distribution contained in this object. | |
| double[] | nextArrayOfDouble (int n) |
| Generates n random numbers from the continuous distribution contained in this object, and returns them in a new array of size n. | |
| RandomStream | getStream () |
| Returns the umontreal.ssj.rng.RandomStream used by this generator. | |
| void | setStream (RandomStream stream) |
| Sets the umontreal.ssj.rng.RandomStream used by this generator to stream. | |
| String | toString () |
| Returns a String containing information about the current generator. | |
Protected Attributes | |
| Distribution[] | dists |
| The different distributions that compose this mixture. | |
| DiscreteDistribution | weightsDist |
| The discrete distribution that is used to select randomly a distribution from the mixture when generating a random variate. | |
| double[] | weights |
| The probability of each distribution that compose this mixture, see variable dists . | |
This class implements random variate generators for a mixture distribution.
Consider a random variable \(X\) defined by a mixture of \(k\) distributions. Let \(f_i(x)\) be the density or probability mass function of the \(i\)-th distribution with associated weight \(w_i \in [0, 1]\). The sum of the \(k\) weights must equal to 1, i.e., \(\sum_{i=1}^k w_i = 1\).
The density or probability mass function \(f(x)\) of \(X\) is then
\[f(x) = \sum_{i=1}^k f_i(x). \]
In the class constructor, the user must give an array of size \(k\) of umontreal.ssj.probdist.Distribution and an array of double of same length for the associated weights \(w_i\). To generate a random variate, the implementation of this class will first select randomly (and proportionally to the weights \(w_i\)) a distribution \(D_i\) from the mixture. Then, it will generate a random variate by inversion by calling the method Distribution.inverseF.
Definition at line 52 of file MixtureGen.java.
| umontreal.ssj.randvar.MixtureGen.MixtureGen | ( | RandomStream | s, |
| Distribution[] | dists, | ||
| double[] | weights ) |
Creates a new mixture distribution generator defined by the given.
Distribution and weights, using the random stream s. The list of distributions and associated weights are given by arguments dists and weights. The weights must be non-negative, and they must sum to 1.
| s | the random stream that will be used to generate the random variates |
| dists | the distributions that define the mixture |
| weights | the probability to select each distribution in the mixture |
Definition at line 83 of file MixtureGen.java.
| Distribution umontreal.ssj.randvar.MixtureGen.getDistribution | ( | ) |
This method is not supported, it will throw an UnsupportedOperationException.
Use method getDistributions instead.
| UnsupportedOperationException | this method is not supported |
Reimplemented from umontreal.ssj.randvar.RandomVariateGen.
Definition at line 116 of file MixtureGen.java.
| Distribution[] umontreal.ssj.randvar.MixtureGen.getDistributions | ( | ) |
Returns the distributions of this mixture.
See also getWeights .
Definition at line 123 of file MixtureGen.java.
| double[] umontreal.ssj.randvar.MixtureGen.getWeights | ( | ) |
Returns the probability associated with each distribution of the mixture.
See also getDistributions .
Definition at line 131 of file MixtureGen.java.
| double umontreal.ssj.randvar.MixtureGen.nextDouble | ( | ) |
Generates a random number from the continuous distribution contained in this object.
By default, this method uses inversion by calling the umontreal.ssj.probdist.ContinuousDistribution.inverseF method of the distribution object. Alternative generating methods are provided in subclasses.
Reimplemented from umontreal.ssj.randvar.RandomVariateGen.
Definition at line 140 of file MixtureGen.java.
|
protected |
The different distributions that compose this mixture.
Definition at line 57 of file MixtureGen.java.
|
protected |
The probability of each distribution that compose this mixture, see variable dists .
Definition at line 69 of file MixtureGen.java.
|
protected |
The discrete distribution that is used to select randomly a distribution from the mixture when generating a random variate.
Definition at line 63 of file MixtureGen.java.