You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Alex Herbert (Jira)" <ji...@apache.org> on 2021/07/23 13:56:00 UTC

[jira] [Created] (RNG-156) Dirichlet distribution sampler

Alex Herbert created RNG-156:
--------------------------------

             Summary: Dirichlet distribution sampler
                 Key: RNG-156
                 URL: https://issues.apache.org/jira/browse/RNG-156
             Project: Commons RNG
          Issue Type: New Feature
          Components: sampling
    Affects Versions: 1.4
            Reporter: Alex Herbert


Add sampling from a [Dirichlet distribution|https://en.wikipedia.org/wiki/Dirichlet_distribution#Random_number_generation].

Samples can be produced by generating Gamma(shape=alpha, scale=1) deviates for each category with concentration alpha, summing the deviates and dividing by the sum.

Proposed public API.
{code:java}
public abstract class DirichletSampler
    implements SharedStateObjectSampler<double[]> {

    public double[] sample();
    public DirichletSampler withUniformRandomProvider(UniformRandomProvider rng);

    public static DirichletSampler of(UniformRandomProvider rng,
                                      double... alpha);
    public static DirichletSampler symmetric(UniformRandomProvider rng,
                                             int k,
                                             double alpha);
}
{code}
The symmetric case is a special case where the alpha concentration parameters are the same for all categories. This can be implemented with a single sampler which reduces memory footprint. This is especially true when alpha > 1 as a AhrensDieterMarsagliaTsangGammaSampler holds two precomputed values and a normalised Gaussian sampler.

An example of using a symmetric case is a unit Simplex which uses dimension k and alpha=1.

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)