You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 distribution
lognormal(mean=0, stdev=1): the lognormal distribution - a distribution whose log has a normal(mean,stdev) distribution
vonmisse(mean=0, kappa=0): the von Misse distribution, basically a gaussian over a circle
triangular(lo=0, hi=1, mode=(lo+hi)/2): a triangular distribution with a high point of mode.
exponential(lambda=1): an exponential distribution (from 0 to infinity). (The mean is 1/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)
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.
About
Proposal to add a set of new non-uniform random distributions to JS