UNPKG

@thi.ng/random

Version:

Pseudo-random number generators w/ unified API, distributions, weighted choices, ID generation

10 lines (9 loc) 210 B
import { SYSTEM } from "./system.js"; const weightedProbability = (weight, rnd = SYSTEM) => { const a = rnd.float(); const b = rnd.float(); return [a, b < weight(a)]; }; export { weightedProbability };