Random Non-Uniform Distributions
June 6, 2025 ยท View on GitHub
- Stage 0
- Authors: WhosyVox and Tab Atkins-Bittner
- Champions: Tab Atkins-Bittner
- Spec Text: currently this README
This proposal introduces several new functions for sampling from non-uniform random distributions.
This proposal stands alongside Simple Random Functions and Random Collection Functions, and like those, uses the Random namespace object introduced by Seeded Random.
Distribution Methods
Python includes a decent selection of distributions. We should probably at least include the normal/gaussian distribution, given its high degree of usefulness. Should we include more? All of Python's distributions? Other distributions?
normal(mean=0, stdev=1): the gaussian/normal distributionlognormal(mean=0, stdev=1): the lognormal distribution - a distribution whose log has anormal(mean,stdev)distributionvonmisse(mean=0, kappa=0): the von Misse distribution, basically a gaussian over a circletriangular(lo=0, hi=1, mode=(lo+hi)/2): a triangular distribution with a high point ofmode.exponential(lambda=1): an exponential distribution (from 0 to infinity). (The mean is1/lambda.)binomial(n, p=0.5): the binomial distribution - how many successes in N trials with P chance of success? (sampling with replacement)geometric(p=.5): the geometric distribution - how many failures before the first success, with P chance of success? (sampling with replacement)hypergeometric(n, N, K): the hyper-geometric distribution - how many successes in n trials if exactly K of the N possible outcomes are a success? (sampling without replacement)beta(alpha, beta): the beta distributiongamma(alpha, beta): the gamma distributionpareto(alpha): the Pareto distributionweibull(alpha, beta): the Weibull distribution
Interaction with Random.Seeded
All of the above functions will also be defined on the Random.Seeded class as methods, with identical signatures and behavior. That is, Random.normal(...) and new SeededRandom(...).normal(...) will both work.
Precise generation algorithms will be defined for the Random.Seeded methods, to ensure reproducibility. It's recommended that the Random versions use the same algorithm, but not strictly required; doing so just lets you use an internal Random.Seeded object and avoid implementing the same function twice.
History
- 2025-06: Split out from Random Functions as part of the condition for that proposal advancing to Stage 1.