[
https://issues.apache.org/jira/browse/RNG-179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17541883#comment-17541883
]
Alex Herbert commented on RNG-179:
----------------------------------
For reference the API is:
{code:java}
UniformRandomProvider rng = ...;
// Represented exactly
long[] frequencies = {1, 1, 2, 3, 1};
DiscreteSampler sampler1 = FastLoadedDiceRollerSampler.of(rng, frequencies);
// Represented exactly using relative weights
double[] weights = {1, 0.5, 0.125, 3.5, 1};
DiscreteSampler sampler2 = FastLoadedDiceRollerSampler.of(rng, weights);
{code}
When using frequencies the maximum number of categories is approximately ((2^31
- 1) / 63) = 34,087,042 and the sum of frequencies must be below Long.MAX_VALUE.
When using weights the maximum number of categories is approximately 1,000,000
if all weights are Double.MAX_VALUE with the exception of 1 weight of
Double.MIN_VALUE. In practice this range of weights is unrealistic and more
categories should be possible. The construction algorithm does not require the
weights to sum to a finite double value.
> The Fast Loaded Dice Roller: A Near-Optimal Exact Sampler for Discrete
> Probability Distributions
> ------------------------------------------------------------------------------------------------
>
> Key: RNG-179
> URL: https://issues.apache.org/jira/browse/RNG-179
> Project: Commons RNG
> Issue Type: New Feature
> Components: sampling
> Reporter: Vladimir Sitnikov
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> It might make sense to implement Fast Loaded Dice Roller sampler.
> See https://arxiv.org/pdf/2003.03830v2.pdf,
> https://github.com/probcomp/fast-loaded-dice-roller
> The authors claim that Fast Loaded Dice Roller is faster than the Alias
> Method.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)