SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | Static Public Member Functions | List of all members
DirichletGen Class Reference

Extends RandomMultivariateGen for a Dirichlet [98]  distribution. More...

Inheritance diagram for DirichletGen:
[legend]
Collaboration diagram for DirichletGen:
[legend]

Public Member Functions

 DirichletGen (RandomStream stream, double[] alphas)
 Constructs a new Dirichlet generator with parameters \(\alpha_{i+1}=\) alphas[i], for \(i=0,…,k-1\), and the stream stream. More...
 
double getAlpha (int i)
 Returns the \(\alpha_{i+1}\) parameter for this Dirichlet generator. More...
 
void nextPoint (double[] p)
 Generates a point from the Dirichlet distribution. More...
 
- Public Member Functions inherited from RandomMultivariateGen
abstract void nextPoint (double[] p)
 Generates a random point \(p\) using the the stream contained in this object.
 
void nextArrayOfPoints (double[][] v, int start, int n)
 Generates \(n\) random points. More...
 
int getDimension ()
 Returns the dimension of this multivariate generator (the dimension of the random points).
 
RandomStream getStream ()
 Returns the umontreal.ssj.rng.RandomStream used by this object. More...
 
void setStream (RandomStream stream)
 Sets the umontreal.ssj.rng.RandomStream used by this object to stream.
 

Static Public Member Functions

static void nextPoint (RandomStream stream, double[] alphas, double[] p)
 Generates a new point from the Dirichlet distribution with parameters alphas, using the stream stream. More...
 

Additional Inherited Members

- Protected Attributes inherited from RandomMultivariateGen
int dimension
 
RandomStream stream
 
RandomVariateGen gen1
 

Detailed Description

Extends RandomMultivariateGen for a Dirichlet [98]  distribution.

This distribution uses the parameters \(\alpha_1,…,\alpha_k\), and has density

\[ f(x_1,…,x_k) = \frac{\Gamma(\alpha_0)\prod_{i=1}^k x_i^{\alpha_i - 1}}{\prod_{i=1}^k \Gamma(\alpha_i)} \]

where \(\alpha_0=\sum_{i=1}^k\alpha_i\).

Here, the successive coordinates of the Dirichlet vector are generated

Remarks
Pierre: How?

via the class umontreal.ssj.randvar.GammaAcceptanceRejectionGen in package randvar, using the same stream for all the uniforms.

Note: when the shape parameters \(\alpha_i\) are all very small, the results may lose some numerical precision. For example, the value of the density function of the Dirichlet multivariate may return 0. Also, the generated \(x_i\) will often have one variate equals to 1, and all others set at (or near) 0.

Constructor & Destructor Documentation

◆ DirichletGen()

DirichletGen ( RandomStream  stream,
double []  alphas 
)

Constructs a new Dirichlet generator with parameters \(\alpha_{i+1}=\) alphas[i], for \(i=0,…,k-1\), and the stream stream.

Parameters
streamthe random number stream used to generate uniforms.
alphasthe \(\alpha_i\) parameters of the generated distribution.
Exceptions
IllegalArgumentExceptionif one \(\alpha_k\) is negative or 0.
NullPointerExceptionif any argument is null.

Member Function Documentation

◆ getAlpha()

double getAlpha ( int  i)

Returns the \(\alpha_{i+1}\) parameter for this Dirichlet generator.

Parameters
ithe index of the parameter.
Returns
the value of the parameter.
Exceptions
ArrayIndexOutOfBoundsExceptionif i is negative or greater than or equal to getDimension.

◆ nextPoint() [1/2]

static void nextPoint ( RandomStream  stream,
double []  alphas,
double []  p 
)
static

Generates a new point from the Dirichlet distribution with parameters alphas, using the stream stream.

The generated values are placed into p.

Parameters
streamthe random number stream used to generate the uniforms.
alphasthe \(\alpha_i\) parameters of the distribution, for \(i=1,…,k\).
pthe array to be filled with the generated point.

◆ nextPoint() [2/2]

void nextPoint ( double []  p)

Generates a point from the Dirichlet distribution.

Parameters
pthe array to be filled with the generated point.

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