source: node_modules/d3-random/src/weibull.js@ e4c61dd

Last change on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago

Prototype 1.1

  • Property mode set to 100644
File size: 535 bytes
Line 
1import defaultSource from "./defaultSource.js";
2
3export default (function sourceRandomWeibull(source) {
4 function randomWeibull(k, a, b) {
5 var outerFunc;
6 if ((k = +k) === 0) {
7 outerFunc = x => -Math.log(x);
8 } else {
9 k = 1 / k;
10 outerFunc = x => Math.pow(x, k);
11 }
12 a = a == null ? 0 : +a;
13 b = b == null ? 1 : +b;
14 return function() {
15 return a + b * outerFunc(-Math.log1p(-source()));
16 };
17 }
18
19 randomWeibull.source = sourceRandomWeibull;
20
21 return randomWeibull;
22})(defaultSource);
Note: See TracBrowser for help on using the repository browser.