UNPKG

d3-random

Version:

Generate random numbers from various distributions.

23 lines (19 loc) 535 B
import defaultSource from "./defaultSource.js"; export default (function sourceRandomWeibull(source) { function randomWeibull(k, a, b) { var outerFunc; if ((k = +k) === 0) { outerFunc = x => -Math.log(x); } else { k = 1 / k; outerFunc = x => Math.pow(x, k); } a = a == null ? 0 : +a; b = b == null ? 1 : +b; return function() { return a + b * outerFunc(-Math.log1p(-source())); }; } randomWeibull.source = sourceRandomWeibull; return randomWeibull; })(defaultSource);