UNPKG

@thi.ng/random

Version:

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

15 lines (14 loc) 249 B
import { SYSTEM } from "./system.js"; const coin = (rnd = SYSTEM) => rnd.float() < 0.5; const fairCoin = (rnd = SYSTEM) => { let a, b; do { a = coin(rnd); b = coin(rnd); } while (a === b); return a; }; export { coin, fairCoin };