UNPKG

random

Version:

Seedable random number generator supporting many common distributions.

16 lines 426 B
import { numberValidator } from '../validation'; export default (random, n = 1, p = 0.5) => { numberValidator(n).isInt().isPositive(); numberValidator(p).greaterThanOrEqual(0).lessThan(1); return () => { let i = 0; let x = 0; while (i++ < n) { if (random.next() < p) { x++; } } return x; }; }; //# sourceMappingURL=binomial.js.map