Random number generation
2015-05-14 — 2023-09-08
Wherein a practical pseudo‑RNG implementation is described, the absence of seedable generators in JavaScript is noted, and methods for producing non‑uniform variates from uniform draws are considered.
Practical pseudo-RNG implementation. See also pseudorandomness for theories Monte Carlo for some applications, and for some background theory algorithmic statistics.
1 Uniform PRNGs
Generating uniformly distributed numbers on some interval, such as [0,1].
I regularly need to do this in languages that do not support…
- local
- seedable
- convenient
… PRNGs.
JavaScript doesn’t support seeding. Supercollider does but insists on a per-thread RNG. MaxMSP is a miscellany of folly as usual.
2 Non-uniform variates
Say you have a uniform RNG but you need… Poisson? Gaussian? RNGs. Now what?
- Luc Devroye’s wonderful and unexpectedly deep Non-Uniform Random Variate Generation has analytic results
- Using NNs to do it? Reassure yourself this is possible (in principle) with the approximation results in Perekrestenko, Müller, and Bölcskei (2020); Perekrestenko, Eberhard, and Bölcskei (2021).