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

AliasMethodDiscreteSampler

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

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

    Description

      From Wikipedia:

      Alias Method

      In computing, the alias method is a family of efficient algorithms for sampling from
      a discrete probability distribution, due to A. J. Walker. That is, it returns integer
      values 1 ≤ i ≤ n according to some arbitrary probability distribution. The algorithms
      typically use O(n log n) or O(n) preprocessing time, after which random values can
      be drawn from the distribution in O(1) time.
      

      Create a sampler using the Alias method:

      package org.apache.commons.rng.sampling.distribution;
      
      public class AliasMethodDiscreteSampler implements DiscreteSampler {
          public AliasMethodDiscreteSampler(UniformRandomProvider rng, 
                                            double[] probabilities) {
              // Validate probabilities sum to >0
              // Construct alias tables
          }
          @Override
          public int sample() {
              // Sample from alias tables
          }
      }
      

      Attachments

        1. alias_con.jpg
          22 kB
          Alex Herbert
        2. alias_sample.jpg
          30 kB
          Alex Herbert

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            aherbert Alex Herbert
            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 - 0.5h
                0.5h

                Slack

                  Issue deployment