MCPcopy Index your code
hub / github.com/clips/pattern / _rndExp

Function _rndExp

pattern/canvas.js:2501–2510  ·  view source on GitHub ↗
(bias)

Source from the content-addressed store, hash-verified

2499var _RANDOM_MAP = [90.0, 9.00, 4.00, 2.33, 1.50, 1.00, 0.66, 0.43, 0.25, 0.11, 0.01];
2500
2501function _rndExp(bias) {
2502 if (bias === undefined) bias = 0.5;
2503 bias = Math.max(0, Math.min(bias, 1)) * 10;
2504 var i = parseInt(Math.floor(bias)); // bias*10 => index in the _map curve.
2505 var n = _RANDOM_MAP[i]; // If bias is 0.3, rnd()**2.33 will average 0.3.
2506 if (bias < 10) {
2507 n += (_RANDOM_MAP[i+1]-n) * (bias-i);
2508 }
2509 return n;
2510}
2511
2512function random(v1, v2, bias) {
2513 /* Returns a number between v1 and v2, including v1 but not v2.

Callers 1

randomFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…