You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
535 B
22 lines
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);
|
|
|