Uploaded image for project: 'Commons RNG'
  1. Commons RNG
  2. RNG-156

Dirichlet distribution sampler

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Implemented
    • 1.4
    • 1.4
    • sampling
    • None

    Description

      Add sampling from a Dirichlet distribution.

      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.

      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);
      }
      

      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.

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              aherbert Alex Herbert
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m