landstrasse
Version:
Strongly typed WAMP Client for browsers
19 lines • 754 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalRand = void 0;
// @author Crossbar.io Technologies GmbH and contributors
// @see https://github.com/crossbario/autobahn-js/blob/v20.9.2/packages/autobahn/lib/util.js#L92
const normalRand = (mean, sd) => {
// Derive a Gaussian from Uniform random variables
// http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
let x1, x2, rad;
do {
x1 = 2 * Math.random() - 1;
x2 = 2 * Math.random() - 1;
rad = x1 * x1 + x2 * x2;
} while (rad >= 1 || rad == 0);
const c = Math.sqrt(-2 * Math.log(rad) / rad);
return (mean || 0) + (x1 * c) * (sd || 1);
};
exports.normalRand = normalRand;
//# sourceMappingURL=index.js.map