d4_random library

Generate random numbers from various distributions.

For seeded random number generation, see the functions suffixed 'Source' and randomLcg.

Functions

randomBates(num n) num Function()
Returns a function for generating random numbers with a Bates distribution with n independent variables.
randomBatesSource(num source()) num Function() Function(num)
Returns a randomBates function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomBernoulli(num p) int Function()
Returns a function for generating either 1 or 0 according to a Bernoulli distribution with 1 being returned with success probability p and 0 with failure probability q = 1 - p.
randomBernoulliSource(num source()) int Function() Function(num)
Returns a randomBernoulli function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomBeta(num alpha, num beta) num Function()
Returns a function for generating random numbers with a beta distribution with alpha and beta shape parameters, which must both be positive.
randomBetaSource(num source()) num Function() Function(num, num)
Returns a randomBeta function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomBinomial(num n, num p) num Function()
Returns a function for generating random numbers with a binomial distribution with n the number of trials and p the probability of success in each trial.
randomBinomialSource(num source()) num Function() Function(num, num)
Returns a randomBinomial function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomCauchy([num a = 0, num b = 1]) num Function()
Returns a function for generating random numbers with a Cauchy distribution.
randomCauchySource(num source()) num Function() Function([num, num])
Returns a randomCauchy function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomExponential(num lambda) num Function()
Returns a function for generating random numbers with an exponential distribution with the rate lambda; equivalent to time between events in a Poisson process with a mean of 1 / lambda.
randomExponentialSource(num source()) num Function() Function(num)
Returns a randomExponential function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomGamma(num k, [num theta = 1]) num Function()
Returns a function for generating random numbers with a gamma distribution with k the shape parameter and theta the scale parameter.
randomGammaSource(num source()) num Function() Function(num, [num])
Returns a randomGamma function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomGeometric(num p) num Function()
Returns a function for generating numbers with a geometric distribution with success probability p.
randomGeometricSource(num source()) num Function() Function(num)
Returns a randomGeometric function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomInt({num min = 0, required num max}) int Function()
Returns a function for generating random integers with a uniform distribution.
randomIntSource(num source()) int Function() Function({required num max, num min})
Returns a randomInt function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomIrwinHall(num n) num Function()
Returns a function for generating random numbers with an Irwin–Hall distribution with n independent variables.
randomIrwinHallSource(num source()) num Function() Function(num)
Returns a randomIrwinHall function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomLcg([num? seed]) num Function()
Returns a linear congruential generator; this function can be called repeatedly to obtain pseudorandom values well-distributed on the interval [0,1) and with a long period (up to 1 billion numbers), similar to Random.nextDouble.
randomLogistic([num a = 0, num b = 1]) num Function()
Returns a function for generating random numbers with a logistic distribution.
randomLogisticSource(num source()) num Function() Function([num, num])
Returns a randomLogistic function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomLogNormal([num mu = 0, num sigma = 1]) num Function()
Returns a function for generating random numbers with a log-normal distribution.
randomLogNormalSource(num source()) num Function() Function([num, num])
Returns a randomLogNormal function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomNormal([num mu = 0, num sigma = 1]) num Function()
Returns a function for generating random numbers with a normal (Gaussian) distribution.
randomNormalSource(num source()) num Function() Function([num, num])
Returns a randomNormal function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomPareto(num alpha) num Function()
Returns a function for generating random numbers with a Pareto distribution with the shape alpha.
randomParetoSource(num source()) num Function() Function(num)
Returns a randomPareto function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomPoisson(num lambda) num Function()
Returns a function for generating random numbers with a Poisson distribution with mean lambda.
randomPoissonSource(num source()) num Function() Function(num)
Returns a randomPoisson function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomUniform({num min = 0, num max = 1}) num Function()
Returns a function for generating random numbers with a uniform distribution.
randomUniformSource(num source()) num Function() Function({num max, num min})
Returns a randomUniform function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.
randomWeibull(num k, [num a = 0, num b = 1]) num Function()
Returns a function for generating random numbers with one of the generalized extreme value distributions, depending on k:
randomWeibullSource(num source()) num Function() Function(num, [num, num])
Returns a randomWeibull function but where the given random number generator source is used as the source of randomness instead of Random.nextDouble.