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

Extends RandomMultivariateGen for a Dirichlet. More...

Inheritance diagram for umontreal.ssj.randvarmulti.DirichletGen:
umontreal.ssj.randvarmulti.RandomMultivariateGen

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.
double getAlpha (int i)
 Returns the \(\alpha_{i+1}\) parameter for this Dirichlet generator.
void nextPoint (double[] p)
 Generates a point from the Dirichlet distribution.
Public Member Functions inherited from umontreal.ssj.randvarmulti.RandomMultivariateGen
void nextArrayOfPoints (double[][] v, int start, int n)
 Generates \(n\) random points.
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.
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.

Detailed Description

Extends RandomMultivariateGen for a Dirichlet.

[94]  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 @ref umontreal.ssj.randvar.GammaAcceptanceRejectionGen
    in package `randvar`, using the same stream for all the uniforms.

    Note: when the shape parameters @f$\alpha_i@f$ 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 @f$x_i@f$ will often have one variate equals to
    1, and all others set at (or near) 0.

    <div class="SSJ-bigskip"></div>

Definition at line 57 of file DirichletGen.java.

Constructor & Destructor Documentation

◆ DirichletGen()

umontreal.ssj.randvarmulti.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`.

Definition at line 78 of file DirichletGen.java.

Member Function Documentation

◆ getAlpha()

double umontreal.ssj.randvarmulti.DirichletGen.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.

Definition at line 101 of file DirichletGen.java.

◆ nextPoint() [1/2]

void umontreal.ssj.randvarmulti.DirichletGen.nextPoint ( double[] p)

Generates a point from the Dirichlet distribution.

Parameters
pthe array to be filled with the generated point.

Reimplemented from umontreal.ssj.randvarmulti.RandomMultivariateGen.

Definition at line 135 of file DirichletGen.java.

◆ nextPoint() [2/2]

void umontreal.ssj.randvarmulti.DirichletGen.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.

Definition at line 115 of file DirichletGen.java.


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