discreteDistribution

The range equivalent of dice, each element of which is the result of the roll of a random die with relative probabilities stored in the range proportions. Each successive value of front reflects the index in proportions that was chosen. If no random number generator is specified, the default rndGen will be used as the source of randomness.

This offers a superior option in the event of making many rolls of the same die, as the sum and CDF of proportions only needs to be calculated upon construction and not with each call.

  1. auto discreteDistribution(UniformRNG rng, Range proportions)
    discreteDistribution
    (
    SearchPolicy search = SearchPolicy.binarySearch
    UniformRNG
    Range
    )
    (
    UniformRNG rng
    ,)
    if (
    isInputRange!Range &&
    isNumeric!(ElementType!Range)
    &&
    isUniformRNG!UniformRNG
    )
  2. auto discreteDistribution(Range proportions)
  3. auto discreteDistribution(UniformRNG rng, Num[] proportions)
  4. auto discreteDistribution(Num[] proportions)

Meta