SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
umontreal.ssj.randvar.MixtureGen Class Reference

This class implements random variate generators for a mixture distribution. More...

Inheritance diagram for umontreal.ssj.randvar.MixtureGen:
umontreal.ssj.randvar.RandomVariateGen

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 .

Detailed Description

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.

Constructor & Destructor Documentation

◆ MixtureGen()

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.

Parameters
sthe random stream that will be used to generate the random variates
diststhe distributions that define the mixture
weightsthe probability to select each distribution in the mixture

Definition at line 83 of file MixtureGen.java.

Member Function Documentation

◆ getDistribution()

Distribution umontreal.ssj.randvar.MixtureGen.getDistribution ( )

This method is not supported, it will throw an UnsupportedOperationException.

Use method getDistributions instead.

Exceptions
UnsupportedOperationExceptionthis method is not supported

Reimplemented from umontreal.ssj.randvar.RandomVariateGen.

Definition at line 116 of file MixtureGen.java.

◆ getDistributions()

Distribution[] umontreal.ssj.randvar.MixtureGen.getDistributions ( )

Returns the distributions of this mixture.

See also getWeights .

Definition at line 123 of file MixtureGen.java.

◆ getWeights()

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.

◆ nextDouble()

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.

Returns
the generated value

Reimplemented from umontreal.ssj.randvar.RandomVariateGen.

Definition at line 140 of file MixtureGen.java.

Member Data Documentation

◆ dists

Distribution [] umontreal.ssj.randvar.MixtureGen.dists
protected

The different distributions that compose this mixture.

Definition at line 57 of file MixtureGen.java.

◆ weights

double [] umontreal.ssj.randvar.MixtureGen.weights
protected

The probability of each distribution that compose this mixture, see variable dists .

Definition at line 69 of file MixtureGen.java.

◆ weightsDist

DiscreteDistribution umontreal.ssj.randvar.MixtureGen.weightsDist
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.


The documentation for this class was generated from the following file: