Extends RandomMultivariateGen for a Dirichlet. More...
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. | |
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
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.
| 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.
| stream | the random number stream used to generate uniforms. |
| alphas | the \(\alpha_i\) parameters of the generated distribution. |
| IllegalArgumentException | if one \(\alpha_k\) is negative or 0. |
| NullPointerException | if any argument is `null`. |
Definition at line 78 of file DirichletGen.java.
| double umontreal.ssj.randvarmulti.DirichletGen.getAlpha | ( | int | i | ) |
Returns the \(\alpha_{i+1}\) parameter for this Dirichlet generator.
| i | the index of the parameter. |
| ArrayIndexOutOfBoundsException | if `i` is negative or greater than or equal to getDimension. |
Definition at line 101 of file DirichletGen.java.
| void umontreal.ssj.randvarmulti.DirichletGen.nextPoint | ( | double[] | p | ) |
Generates a point from the Dirichlet distribution.
| p | the array to be filled with the generated point. |
Reimplemented from umontreal.ssj.randvarmulti.RandomMultivariateGen.
Definition at line 135 of file DirichletGen.java.
|
static |
Generates a new point from the Dirichlet distribution with parameters alphas, using the stream stream.
The generated values are placed into p.
| stream | the random number stream used to generate the uniforms. |
| alphas | the \(\alpha_i\) parameters of the distribution, for \(i=1,…,k\). |
| p | the array to be filled with the generated point. |
Definition at line 115 of file DirichletGen.java.