feat:node-modules
This commit is contained in:
75
node_modules/mathjs/lib/cjs/function/probability/combinations.js
generated
vendored
Normal file
75
node_modules/mathjs/lib/cjs/function/probability/combinations.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createCombinations = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _combinations = require("../../plain/number/combinations.js");
|
||||
const name = 'combinations';
|
||||
const dependencies = ['typed'];
|
||||
const createCombinations = exports.createCombinations = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Compute the number of ways of picking `k` unordered outcomes from `n`
|
||||
* possibilities.
|
||||
*
|
||||
* Combinations only takes integer arguments.
|
||||
* The following condition must be enforced: k <= n.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.combinations(n, k)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.combinations(7, 5) // returns 21
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* combinationsWithRep, permutations, factorial
|
||||
*
|
||||
* @param {number | BigNumber} n Total number of objects in the set
|
||||
* @param {number | BigNumber} k Number of objects in the subset
|
||||
* @return {number | BigNumber} Number of possible combinations.
|
||||
*/
|
||||
return typed(name, {
|
||||
'number, number': _combinations.combinationsNumber,
|
||||
'BigNumber, BigNumber': function (n, k) {
|
||||
const BigNumber = n.constructor;
|
||||
let result, i;
|
||||
const nMinusk = n.minus(k);
|
||||
const one = new BigNumber(1);
|
||||
if (!isPositiveInteger(n) || !isPositiveInteger(k)) {
|
||||
throw new TypeError('Positive integer value expected in function combinations');
|
||||
}
|
||||
if (k.gt(n)) {
|
||||
throw new TypeError('k must be less than n in function combinations');
|
||||
}
|
||||
result = one;
|
||||
if (k.lt(nMinusk)) {
|
||||
for (i = one; i.lte(nMinusk); i = i.plus(one)) {
|
||||
result = result.times(k.plus(i)).dividedBy(i);
|
||||
}
|
||||
} else {
|
||||
for (i = one; i.lte(k); i = i.plus(one)) {
|
||||
result = result.times(nMinusk.plus(i)).dividedBy(i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO: implement support for collection in combinations
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Test whether BigNumber n is a positive integer
|
||||
* @param {BigNumber} n
|
||||
* @returns {boolean} isPositiveInteger
|
||||
*/
|
||||
function isPositiveInteger(n) {
|
||||
return n.isInteger() && n.gte(0);
|
||||
}
|
||||
90
node_modules/mathjs/lib/cjs/function/probability/combinationsWithRep.js
generated
vendored
Normal file
90
node_modules/mathjs/lib/cjs/function/probability/combinationsWithRep.js
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createCombinationsWithRep = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _number = require("../../utils/number.js");
|
||||
var _product = require("../../utils/product.js");
|
||||
const name = 'combinationsWithRep';
|
||||
const dependencies = ['typed'];
|
||||
const createCombinationsWithRep = exports.createCombinationsWithRep = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed
|
||||
} = _ref;
|
||||
/**
|
||||
* Compute the number of ways of picking `k` unordered outcomes from `n`
|
||||
* possibilities, allowing individual outcomes to be repeated more than once.
|
||||
*
|
||||
* CombinationsWithRep only takes integer arguments.
|
||||
* The following condition must be enforced: k <= n + k -1.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.combinationsWithRep(n, k)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.combinationsWithRep(7, 5) // returns 462
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* combinations, permutations, factorial
|
||||
*
|
||||
* @param {number | BigNumber} n Total number of objects in the set
|
||||
* @param {number | BigNumber} k Number of objects in the subset
|
||||
* @return {number | BigNumber} Number of possible combinations with replacement.
|
||||
*/
|
||||
return typed(name, {
|
||||
'number, number': function (n, k) {
|
||||
if (!(0, _number.isInteger)(n) || n < 0) {
|
||||
throw new TypeError('Positive integer value expected in function combinationsWithRep');
|
||||
}
|
||||
if (!(0, _number.isInteger)(k) || k < 0) {
|
||||
throw new TypeError('Positive integer value expected in function combinationsWithRep');
|
||||
}
|
||||
if (n < 1) {
|
||||
throw new TypeError('k must be less than or equal to n + k - 1');
|
||||
}
|
||||
if (k < n - 1) {
|
||||
const prodrange = (0, _product.product)(n, n + k - 1);
|
||||
return prodrange / (0, _product.product)(1, k);
|
||||
}
|
||||
const prodrange = (0, _product.product)(k + 1, n + k - 1);
|
||||
return prodrange / (0, _product.product)(1, n - 1);
|
||||
},
|
||||
'BigNumber, BigNumber': function (n, k) {
|
||||
const BigNumber = n.constructor;
|
||||
let result, i;
|
||||
const one = new BigNumber(1);
|
||||
const nMinusOne = n.minus(one);
|
||||
if (!isPositiveInteger(n) || !isPositiveInteger(k)) {
|
||||
throw new TypeError('Positive integer value expected in function combinationsWithRep');
|
||||
}
|
||||
if (n.lt(one)) {
|
||||
throw new TypeError('k must be less than or equal to n + k - 1 in function combinationsWithRep');
|
||||
}
|
||||
result = one;
|
||||
if (k.lt(nMinusOne)) {
|
||||
for (i = one; i.lte(nMinusOne); i = i.plus(one)) {
|
||||
result = result.times(k.plus(i)).dividedBy(i);
|
||||
}
|
||||
} else {
|
||||
for (i = one; i.lte(k); i = i.plus(one)) {
|
||||
result = result.times(nMinusOne.plus(i)).dividedBy(i);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Test whether BigNumber n is a positive integer
|
||||
* @param {BigNumber} n
|
||||
* @returns {boolean} isPositiveInteger
|
||||
*/
|
||||
function isPositiveInteger(n) {
|
||||
return n.isInteger() && n.gte(0);
|
||||
}
|
||||
53
node_modules/mathjs/lib/cjs/function/probability/factorial.js
generated
vendored
Normal file
53
node_modules/mathjs/lib/cjs/function/probability/factorial.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createFactorial = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'factorial';
|
||||
const dependencies = ['typed', 'gamma'];
|
||||
const createFactorial = exports.createFactorial = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
gamma
|
||||
} = _ref;
|
||||
/**
|
||||
* Compute the factorial of a value
|
||||
*
|
||||
* Factorial only supports an integer value as argument.
|
||||
* For matrices, the function is evaluated element wise.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.factorial(n)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.factorial(5) // returns 120
|
||||
* math.factorial(3) // returns 6
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* combinations, combinationsWithRep, gamma, permutations
|
||||
*
|
||||
* @param {number | BigNumber | Array | Matrix} n An integer number
|
||||
* @return {number | BigNumber | Array | Matrix} The factorial of `n`
|
||||
*/
|
||||
return typed(name, {
|
||||
number: function (n) {
|
||||
if (n < 0) {
|
||||
throw new Error('Value must be non-negative');
|
||||
}
|
||||
return gamma(n + 1);
|
||||
},
|
||||
BigNumber: function (n) {
|
||||
if (n.isNegative()) {
|
||||
throw new Error('Value must be non-negative');
|
||||
}
|
||||
return gamma(n.plus(1));
|
||||
},
|
||||
'Array | Matrix': typed.referToSelf(self => n => (0, _collection.deepMap)(n, self))
|
||||
});
|
||||
});
|
||||
126
node_modules/mathjs/lib/cjs/function/probability/gamma.js
generated
vendored
Normal file
126
node_modules/mathjs/lib/cjs/function/probability/gamma.js
generated
vendored
Normal file
@@ -0,0 +1,126 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createGamma = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _index = require("../../plain/number/index.js");
|
||||
const name = 'gamma';
|
||||
const dependencies = ['typed', 'config', 'multiplyScalar', 'pow', 'BigNumber', 'Complex'];
|
||||
const createGamma = exports.createGamma = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
config,
|
||||
multiplyScalar,
|
||||
pow,
|
||||
BigNumber,
|
||||
Complex
|
||||
} = _ref;
|
||||
/**
|
||||
* Compute the gamma function of a value using Lanczos approximation for
|
||||
* small values, and an extended Stirling approximation for large values.
|
||||
*
|
||||
* To avoid confusion with the matrix Gamma function, this function does
|
||||
* not apply to matrices.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.gamma(n)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.gamma(5) // returns 24
|
||||
* math.gamma(-0.5) // returns -3.5449077018110335
|
||||
* math.gamma(math.i) // returns -0.15494982830180973 - 0.49801566811835596i
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* combinations, factorial, permutations
|
||||
*
|
||||
* @param {number | BigNumber | Complex} n A real or complex number
|
||||
* @return {number | BigNumber | Complex} The gamma of `n`
|
||||
*/
|
||||
|
||||
function gammaComplex(n) {
|
||||
if (n.im === 0) {
|
||||
return (0, _index.gammaNumber)(n.re);
|
||||
}
|
||||
|
||||
// Lanczos approximation doesn't work well with real part lower than 0.5
|
||||
// So reflection formula is required
|
||||
if (n.re < 0.5) {
|
||||
// Euler's reflection formula
|
||||
// gamma(1-z) * gamma(z) = PI / sin(PI * z)
|
||||
// real part of Z should not be integer [sin(PI) == 0 -> 1/0 - undefined]
|
||||
// thanks to imperfect sin implementation sin(PI * n) != 0
|
||||
// we can safely use it anyway
|
||||
const t = new Complex(1 - n.re, -n.im);
|
||||
const r = new Complex(Math.PI * n.re, Math.PI * n.im);
|
||||
return new Complex(Math.PI).div(r.sin()).div(gammaComplex(t));
|
||||
}
|
||||
|
||||
// Lanczos approximation
|
||||
// z -= 1
|
||||
n = new Complex(n.re - 1, n.im);
|
||||
|
||||
// x = gammaPval[0]
|
||||
let x = new Complex(_index.gammaP[0], 0);
|
||||
// for (i, gammaPval) in enumerate(gammaP):
|
||||
for (let i = 1; i < _index.gammaP.length; ++i) {
|
||||
// x += gammaPval / (z + i)
|
||||
const gammaPval = new Complex(_index.gammaP[i], 0);
|
||||
x = x.add(gammaPval.div(n.add(i)));
|
||||
}
|
||||
// t = z + gammaG + 0.5
|
||||
const t = new Complex(n.re + _index.gammaG + 0.5, n.im);
|
||||
|
||||
// y = sqrt(2 * pi) * t ** (z + 0.5) * exp(-t) * x
|
||||
const twoPiSqrt = Math.sqrt(2 * Math.PI);
|
||||
const tpow = t.pow(n.add(0.5));
|
||||
const expt = t.neg().exp();
|
||||
|
||||
// y = [x] * [sqrt(2 * pi)] * [t ** (z + 0.5)] * [exp(-t)]
|
||||
return x.mul(twoPiSqrt).mul(tpow).mul(expt);
|
||||
}
|
||||
return typed(name, {
|
||||
number: _index.gammaNumber,
|
||||
Complex: gammaComplex,
|
||||
BigNumber: function (n) {
|
||||
if (n.isInteger()) {
|
||||
return n.isNegative() || n.isZero() ? new BigNumber(Infinity) : bigFactorial(n.minus(1));
|
||||
}
|
||||
if (!n.isFinite()) {
|
||||
return new BigNumber(n.isNegative() ? NaN : Infinity);
|
||||
}
|
||||
throw new Error('Integer BigNumber expected');
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Calculate factorial for a BigNumber
|
||||
* @param {BigNumber} n
|
||||
* @returns {BigNumber} Returns the factorial of n
|
||||
*/
|
||||
function bigFactorial(n) {
|
||||
if (n < 8) {
|
||||
return new BigNumber([1, 1, 2, 6, 24, 120, 720, 5040][n]);
|
||||
}
|
||||
const precision = config.precision + (Math.log(n.toNumber()) | 0);
|
||||
const Big = BigNumber.clone({
|
||||
precision
|
||||
});
|
||||
if (n % 2 === 1) {
|
||||
return n.times(bigFactorial(new BigNumber(n - 1)));
|
||||
}
|
||||
let p = n;
|
||||
let prod = new Big(n);
|
||||
let sum = n.toNumber();
|
||||
while (p > 2) {
|
||||
p -= 2;
|
||||
sum += p;
|
||||
prod = prod.times(sum);
|
||||
}
|
||||
return new BigNumber(prod.toPrecision(BigNumber.precision));
|
||||
}
|
||||
});
|
||||
83
node_modules/mathjs/lib/cjs/function/probability/kldivergence.js
generated
vendored
Normal file
83
node_modules/mathjs/lib/cjs/function/probability/kldivergence.js
generated
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createKldivergence = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'kldivergence';
|
||||
const dependencies = ['typed', 'matrix', 'divide', 'sum', 'multiply', 'map', 'dotDivide', 'log', 'isNumeric'];
|
||||
const createKldivergence = exports.createKldivergence = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
matrix,
|
||||
divide,
|
||||
sum,
|
||||
multiply,
|
||||
map,
|
||||
dotDivide,
|
||||
log,
|
||||
isNumeric
|
||||
} = _ref;
|
||||
/**
|
||||
* Calculate the Kullback-Leibler (KL) divergence between two distributions
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.kldivergence(x, y)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.kldivergence([0.7,0.5,0.4], [0.2,0.9,0.5]) //returns 0.24376698773121153
|
||||
*
|
||||
*
|
||||
* @param {Array | Matrix} q First vector
|
||||
* @param {Array | Matrix} p Second vector
|
||||
* @return {number} Returns distance between q and p
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array, Array': function (q, p) {
|
||||
return _kldiv(matrix(q), matrix(p));
|
||||
},
|
||||
'Matrix, Array': function (q, p) {
|
||||
return _kldiv(q, matrix(p));
|
||||
},
|
||||
'Array, Matrix': function (q, p) {
|
||||
return _kldiv(matrix(q), p);
|
||||
},
|
||||
'Matrix, Matrix': function (q, p) {
|
||||
return _kldiv(q, p);
|
||||
}
|
||||
});
|
||||
function _kldiv(q, p) {
|
||||
const plength = p.size().length;
|
||||
const qlength = q.size().length;
|
||||
if (plength > 1) {
|
||||
throw new Error('first object must be one dimensional');
|
||||
}
|
||||
if (qlength > 1) {
|
||||
throw new Error('second object must be one dimensional');
|
||||
}
|
||||
if (plength !== qlength) {
|
||||
throw new Error('Length of two vectors must be equal');
|
||||
}
|
||||
|
||||
// Before calculation, apply normalization
|
||||
const sumq = sum(q);
|
||||
if (sumq === 0) {
|
||||
throw new Error('Sum of elements in first object must be non zero');
|
||||
}
|
||||
const sump = sum(p);
|
||||
if (sump === 0) {
|
||||
throw new Error('Sum of elements in second object must be non zero');
|
||||
}
|
||||
const qnorm = divide(q, sum(q));
|
||||
const pnorm = divide(p, sum(p));
|
||||
const result = sum(multiply(qnorm, map(dotDivide(qnorm, pnorm), x => log(x))));
|
||||
if (isNumeric(result)) {
|
||||
return result;
|
||||
} else {
|
||||
return Number.NaN;
|
||||
}
|
||||
}
|
||||
});
|
||||
143
node_modules/mathjs/lib/cjs/function/probability/lgamma.js
generated
vendored
Normal file
143
node_modules/mathjs/lib/cjs/function/probability/lgamma.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createLgamma = void 0;
|
||||
var _index = require("../../plain/number/index.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _number = require("../../utils/number.js");
|
||||
/* eslint-disable no-loss-of-precision */
|
||||
|
||||
// References
|
||||
// ----------
|
||||
// [1] Hare, "Computing the Principal Branch of log-Gamma", Journal of Algorithms, 1997.
|
||||
// [2] https://math.stackexchange.com/questions/1338753/how-do-i-calculate-values-for-gamma-function-with-complex-arguments
|
||||
|
||||
const name = 'lgamma';
|
||||
const dependencies = ['Complex', 'typed'];
|
||||
const createLgamma = exports.createLgamma = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
Complex,
|
||||
typed
|
||||
} = _ref;
|
||||
// Stirling series is non-convergent, we need to use the recurrence `lgamma(z) = lgamma(z+1) - log z` to get
|
||||
// sufficient accuracy.
|
||||
//
|
||||
// These two values are copied from Scipy implementation:
|
||||
// https://github.com/scipy/scipy/blob/v1.8.0/scipy/special/_loggamma.pxd#L37
|
||||
const SMALL_RE = 7;
|
||||
const SMALL_IM = 7;
|
||||
|
||||
/**
|
||||
* The coefficients are B[2*n]/(2*n*(2*n - 1)) where B[2*n] is the (2*n)th Bernoulli number. See (1.1) in [1].
|
||||
*
|
||||
* If you cannot access the paper, can also get these values from the formula in [2].
|
||||
*
|
||||
* 1 / 12 = 0.00833333333333333333333333333333
|
||||
* 1 / 360 = 0.00277777777777777777777777777778
|
||||
* ...
|
||||
* 3617 / 133400 = 0.02955065359477124183006535947712
|
||||
*/
|
||||
const coeffs = [-2.955065359477124183e-2, 6.4102564102564102564e-3, -1.9175269175269175269e-3, 8.4175084175084175084e-4, -5.952380952380952381e-4, 7.9365079365079365079e-4, -2.7777777777777777778e-3, 8.3333333333333333333e-2];
|
||||
|
||||
/**
|
||||
* Logarithm of the gamma function for real, positive numbers and complex numbers,
|
||||
* using Lanczos approximation for numbers and Stirling series for complex numbers.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.lgamma(n)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.lgamma(5) // returns 3.178053830347945
|
||||
* math.lgamma(0) // returns Infinity
|
||||
* math.lgamma(-0.5) // returns NaN
|
||||
* math.lgamma(math.i) // returns -0.6509231993018536 - 1.8724366472624294i
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* gamma
|
||||
*
|
||||
* @param {number | Complex} n A real or complex number
|
||||
* @return {number | Complex} The log gamma of `n`
|
||||
*/
|
||||
return typed(name, {
|
||||
number: _index.lgammaNumber,
|
||||
Complex: lgammaComplex,
|
||||
BigNumber: function () {
|
||||
throw new Error("mathjs doesn't yet provide an implementation of the algorithm lgamma for BigNumber");
|
||||
}
|
||||
});
|
||||
function lgammaComplex(n) {
|
||||
const TWOPI = 6.2831853071795864769252842; // 2*pi
|
||||
const LOGPI = 1.1447298858494001741434262; // log(pi)
|
||||
|
||||
const REFLECTION = 0.1;
|
||||
if (n.isNaN()) {
|
||||
return new Complex(NaN, NaN);
|
||||
} else if (n.im === 0) {
|
||||
return new Complex((0, _index.lgammaNumber)(n.re), 0);
|
||||
} else if (n.re >= SMALL_RE || Math.abs(n.im) >= SMALL_IM) {
|
||||
return lgammaStirling(n);
|
||||
} else if (n.re <= REFLECTION) {
|
||||
// Reflection formula. see Proposition 3.1 in [1]
|
||||
const tmp = (0, _number.copysign)(TWOPI, n.im) * Math.floor(0.5 * n.re + 0.25);
|
||||
const a = n.mul(Math.PI).sin().log();
|
||||
const b = lgammaComplex(new Complex(1 - n.re, -n.im));
|
||||
return new Complex(LOGPI, tmp).sub(a).sub(b);
|
||||
} else if (n.im >= 0) {
|
||||
return lgammaRecurrence(n);
|
||||
} else {
|
||||
return lgammaRecurrence(n.conjugate()).conjugate();
|
||||
}
|
||||
}
|
||||
function lgammaStirling(z) {
|
||||
// formula ref in [2]
|
||||
// computation ref:
|
||||
// https://github.com/scipy/scipy/blob/v1.8.0/scipy/special/_loggamma.pxd#L101
|
||||
|
||||
// left part
|
||||
|
||||
// x (log(x) - 1) + 1/2 (log(2PI) - log(x))
|
||||
// => (x - 0.5) * log(x) - x + log(2PI) / 2
|
||||
const leftPart = z.sub(0.5).mul(z.log()).sub(z).add(_index.lnSqrt2PI);
|
||||
|
||||
// right part
|
||||
|
||||
const rz = new Complex(1, 0).div(z);
|
||||
const rzz = rz.div(z);
|
||||
let a = coeffs[0];
|
||||
let b = coeffs[1];
|
||||
const r = 2 * rzz.re;
|
||||
const s = rzz.re * rzz.re + rzz.im * rzz.im;
|
||||
for (let i = 2; i < 8; i++) {
|
||||
const tmp = b;
|
||||
b = -s * a + coeffs[i];
|
||||
a = r * a + tmp;
|
||||
}
|
||||
const rightPart = rz.mul(rzz.mul(a).add(b));
|
||||
|
||||
// plus left and right
|
||||
|
||||
return leftPart.add(rightPart);
|
||||
}
|
||||
function lgammaRecurrence(z) {
|
||||
// computation ref:
|
||||
// https://github.com/scipy/scipy/blob/v1.8.0/scipy/special/_loggamma.pxd#L78
|
||||
|
||||
let signflips = 0;
|
||||
let sb = 0;
|
||||
let shiftprod = z;
|
||||
z = z.add(1);
|
||||
while (z.re <= SMALL_RE) {
|
||||
shiftprod = shiftprod.mul(z);
|
||||
const nsb = shiftprod.im < 0 ? 1 : 0;
|
||||
if (nsb !== 0 && sb === 0) signflips++;
|
||||
sb = nsb;
|
||||
z = z.add(1);
|
||||
}
|
||||
return lgammaStirling(z).sub(shiftprod.log()).sub(new Complex(0, signflips * 2 * Math.PI * 1));
|
||||
}
|
||||
});
|
||||
56
node_modules/mathjs/lib/cjs/function/probability/multinomial.js
generated
vendored
Normal file
56
node_modules/mathjs/lib/cjs/function/probability/multinomial.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createMultinomial = void 0;
|
||||
var _collection = require("../../utils/collection.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'multinomial';
|
||||
const dependencies = ['typed', 'add', 'divide', 'multiply', 'factorial', 'isInteger', 'isPositive'];
|
||||
const createMultinomial = exports.createMultinomial = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
add,
|
||||
divide,
|
||||
multiply,
|
||||
factorial,
|
||||
isInteger,
|
||||
isPositive
|
||||
} = _ref;
|
||||
/**
|
||||
* Multinomial Coefficients compute the number of ways of picking a1, a2, ..., ai unordered outcomes from `n` possibilities.
|
||||
*
|
||||
* multinomial takes one array of integers as an argument.
|
||||
* The following condition must be enforced: every ai <= 0
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.multinomial(a) // a is an array type
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.multinomial([1,2,1]) // returns 12
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* combinations, factorial
|
||||
*
|
||||
* @param {number[] | BigNumber[]} a Integer numbers of objects in the subset
|
||||
* @return {Number | BigNumber} Multinomial coefficient.
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix': function (a) {
|
||||
let sum = 0;
|
||||
let denom = 1;
|
||||
(0, _collection.deepForEach)(a, function (ai) {
|
||||
if (!isInteger(ai) || !isPositive(ai)) {
|
||||
throw new TypeError('Positive integer value expected in function multinomial');
|
||||
}
|
||||
sum = add(sum, ai);
|
||||
denom = multiply(denom, factorial(ai));
|
||||
});
|
||||
return divide(factorial(sum), denom);
|
||||
}
|
||||
});
|
||||
});
|
||||
84
node_modules/mathjs/lib/cjs/function/probability/permutations.js
generated
vendored
Normal file
84
node_modules/mathjs/lib/cjs/function/probability/permutations.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createPermutations = void 0;
|
||||
var _number = require("../../utils/number.js");
|
||||
var _product = require("../../utils/product.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
const name = 'permutations';
|
||||
const dependencies = ['typed', 'factorial'];
|
||||
const createPermutations = exports.createPermutations = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
factorial
|
||||
} = _ref;
|
||||
/**
|
||||
* Compute the number of ways of obtaining an ordered subset of `k` elements
|
||||
* from a set of `n` elements.
|
||||
*
|
||||
* Permutations only takes integer arguments.
|
||||
* The following condition must be enforced: k <= n.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.permutations(n)
|
||||
* math.permutations(n, k)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.permutations(5) // 120
|
||||
* math.permutations(5, 3) // 60
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* combinations, combinationsWithRep, factorial
|
||||
*
|
||||
* @param {number | BigNumber} n The number of objects in total
|
||||
* @param {number | BigNumber} [k] The number of objects in the subset
|
||||
* @return {number | BigNumber} The number of permutations
|
||||
*/
|
||||
return typed(name, {
|
||||
'number | BigNumber': factorial,
|
||||
'number, number': function (n, k) {
|
||||
if (!(0, _number.isInteger)(n) || n < 0) {
|
||||
throw new TypeError('Positive integer value expected in function permutations');
|
||||
}
|
||||
if (!(0, _number.isInteger)(k) || k < 0) {
|
||||
throw new TypeError('Positive integer value expected in function permutations');
|
||||
}
|
||||
if (k > n) {
|
||||
throw new TypeError('second argument k must be less than or equal to first argument n');
|
||||
}
|
||||
// Permute n objects, k at a time
|
||||
return (0, _product.product)(n - k + 1, n);
|
||||
},
|
||||
'BigNumber, BigNumber': function (n, k) {
|
||||
let result, i;
|
||||
if (!isPositiveInteger(n) || !isPositiveInteger(k)) {
|
||||
throw new TypeError('Positive integer value expected in function permutations');
|
||||
}
|
||||
if (k.gt(n)) {
|
||||
throw new TypeError('second argument k must be less than or equal to first argument n');
|
||||
}
|
||||
const one = n.mul(0).add(1);
|
||||
result = one;
|
||||
for (i = n.minus(k).plus(1); i.lte(n); i = i.plus(1)) {
|
||||
result = result.times(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO: implement support for collection in permutations
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Test whether BigNumber n is a positive integer
|
||||
* @param {BigNumber} n
|
||||
* @returns {boolean} isPositiveInteger
|
||||
*/
|
||||
function isPositiveInteger(n) {
|
||||
return n.isInteger() && n.gte(0);
|
||||
}
|
||||
156
node_modules/mathjs/lib/cjs/function/probability/pickRandom.js
generated
vendored
Normal file
156
node_modules/mathjs/lib/cjs/function/probability/pickRandom.js
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createPickRandom = void 0;
|
||||
var _array = require("../../utils/array.js");
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _is = require("../../utils/is.js");
|
||||
var _seededRNG = require("./util/seededRNG.js");
|
||||
const name = 'pickRandom';
|
||||
const dependencies = ['typed', 'config', '?on'];
|
||||
const createPickRandom = exports.createPickRandom = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
config,
|
||||
on
|
||||
} = _ref;
|
||||
// seeded pseudo random number generator
|
||||
let rng = (0, _seededRNG.createRng)(config.randomSeed);
|
||||
if (on) {
|
||||
on('config', function (curr, prev) {
|
||||
if (curr.randomSeed !== prev.randomSeed) {
|
||||
rng = (0, _seededRNG.createRng)(curr.randomSeed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Random pick one or more values from a one dimensional array.
|
||||
* Array elements are picked using a random function with uniform or weighted distribution.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.pickRandom(array)
|
||||
* math.pickRandom(array, number)
|
||||
* math.pickRandom(array, weights)
|
||||
* math.pickRandom(array, number, weights)
|
||||
* math.pickRandom(array, weights, number)
|
||||
* math.pickRandom(array, { weights, number, elementWise })
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.pickRandom([3, 6, 12, 2]) // returns one of the values in the array
|
||||
* math.pickRandom([3, 6, 12, 2], 2) // returns an array of two of the values in the array
|
||||
* math.pickRandom([3, 6, 12, 2], { number: 2 }) // returns an array of two of the values in the array
|
||||
* math.pickRandom([3, 6, 12, 2], [1, 3, 2, 1]) // returns one of the values in the array with weighted distribution
|
||||
* math.pickRandom([3, 6, 12, 2], 2, [1, 3, 2, 1]) // returns an array of two of the values in the array with weighted distribution
|
||||
* math.pickRandom([3, 6, 12, 2], [1, 3, 2, 1], 2) // returns an array of two of the values in the array with weighted distribution
|
||||
*
|
||||
* math.pickRandom([{x: 1.0, y: 2.0}, {x: 1.1, y: 2.0}], { elementWise: false })
|
||||
* // returns one of the items in the array
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* random, randomInt
|
||||
*
|
||||
* @param {Array | Matrix} array A one dimensional array
|
||||
* @param {Int} number An int or float
|
||||
* @param {Array | Matrix} weights An array of ints or floats
|
||||
* @return {number | Array} Returns a single random value from array when number is undefined.
|
||||
* Returns an array with the configured number of elements when number is defined.
|
||||
*/
|
||||
return typed(name, {
|
||||
'Array | Matrix': function (possibles) {
|
||||
return _pickRandom(possibles, {});
|
||||
},
|
||||
'Array | Matrix, Object': function (possibles, options) {
|
||||
return _pickRandom(possibles, options);
|
||||
},
|
||||
'Array | Matrix, number': function (possibles, number) {
|
||||
return _pickRandom(possibles, {
|
||||
number
|
||||
});
|
||||
},
|
||||
'Array | Matrix, Array | Matrix': function (possibles, weights) {
|
||||
return _pickRandom(possibles, {
|
||||
weights
|
||||
});
|
||||
},
|
||||
'Array | Matrix, Array | Matrix, number': function (possibles, weights, number) {
|
||||
return _pickRandom(possibles, {
|
||||
number,
|
||||
weights
|
||||
});
|
||||
},
|
||||
'Array | Matrix, number, Array | Matrix': function (possibles, number, weights) {
|
||||
return _pickRandom(possibles, {
|
||||
number,
|
||||
weights
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {Array | Matrix} possibles
|
||||
* @param {{
|
||||
* number?: number,
|
||||
* weights?: Array | Matrix,
|
||||
* elementWise: boolean
|
||||
* }} options
|
||||
* @returns {number | Array}
|
||||
* @private
|
||||
*/
|
||||
function _pickRandom(possibles, _ref2) {
|
||||
let {
|
||||
number,
|
||||
weights,
|
||||
elementWise = true
|
||||
} = _ref2;
|
||||
const single = typeof number === 'undefined';
|
||||
if (single) {
|
||||
number = 1;
|
||||
}
|
||||
const createMatrix = (0, _is.isMatrix)(possibles) ? possibles.create : (0, _is.isMatrix)(weights) ? weights.create : null;
|
||||
possibles = possibles.valueOf(); // get Array
|
||||
if (weights) {
|
||||
weights = weights.valueOf(); // get Array
|
||||
}
|
||||
if (elementWise === true) {
|
||||
possibles = (0, _array.flatten)(possibles);
|
||||
weights = (0, _array.flatten)(weights);
|
||||
}
|
||||
let totalWeights = 0;
|
||||
if (typeof weights !== 'undefined') {
|
||||
if (weights.length !== possibles.length) {
|
||||
throw new Error('Weights must have the same length as possibles');
|
||||
}
|
||||
for (let i = 0, len = weights.length; i < len; i++) {
|
||||
if (!(0, _is.isNumber)(weights[i]) || weights[i] < 0) {
|
||||
throw new Error('Weights must be an array of positive numbers');
|
||||
}
|
||||
totalWeights += weights[i];
|
||||
}
|
||||
}
|
||||
const length = possibles.length;
|
||||
const result = [];
|
||||
let pick;
|
||||
while (result.length < number) {
|
||||
if (typeof weights === 'undefined') {
|
||||
pick = possibles[Math.floor(rng() * length)];
|
||||
} else {
|
||||
let randKey = rng() * totalWeights;
|
||||
for (let i = 0, len = possibles.length; i < len; i++) {
|
||||
randKey -= weights[i];
|
||||
if (randKey < 0) {
|
||||
pick = possibles[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
result.push(pick);
|
||||
}
|
||||
return single ? result[0] : createMatrix ? createMatrix(result) : result;
|
||||
}
|
||||
});
|
||||
102
node_modules/mathjs/lib/cjs/function/probability/random.js
generated
vendored
Normal file
102
node_modules/mathjs/lib/cjs/function/probability/random.js
generated
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createRandomNumber = exports.createRandom = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _is = require("../../utils/is.js");
|
||||
var _seededRNG = require("./util/seededRNG.js");
|
||||
var _randomMatrix2 = require("./util/randomMatrix.js");
|
||||
const name = 'random';
|
||||
const dependencies = ['typed', 'config', '?on'];
|
||||
const createRandom = exports.createRandom = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
config,
|
||||
on
|
||||
} = _ref;
|
||||
// seeded pseudo random number generator
|
||||
let rng = (0, _seededRNG.createRng)(config.randomSeed);
|
||||
if (on) {
|
||||
on('config', function (curr, prev) {
|
||||
if (curr.randomSeed !== prev.randomSeed) {
|
||||
rng = (0, _seededRNG.createRng)(curr.randomSeed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random number larger or equal to `min` and smaller than `max`
|
||||
* using a uniform distribution.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.random() // generate a random number between 0 and 1
|
||||
* math.random(max) // generate a random number between 0 and max
|
||||
* math.random(min, max) // generate a random number between min and max
|
||||
* math.random(size) // generate a matrix with random numbers between 0 and 1
|
||||
* math.random(size, max) // generate a matrix with random numbers between 0 and max
|
||||
* math.random(size, min, max) // generate a matrix with random numbers between min and max
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.random() // returns a random number between 0 and 1
|
||||
* math.random(100) // returns a random number between 0 and 100
|
||||
* math.random(30, 40) // returns a random number between 30 and 40
|
||||
* math.random([2, 3]) // returns a 2x3 matrix with random numbers between 0 and 1
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* randomInt, pickRandom
|
||||
*
|
||||
* @param {Array | Matrix} [size] If provided, an array or matrix with given
|
||||
* size and filled with random values is returned
|
||||
* @param {number} [min] Minimum boundary for the random value, included
|
||||
* @param {number} [max] Maximum boundary for the random value, excluded
|
||||
* @return {number | Array | Matrix} A random number
|
||||
*/
|
||||
return typed(name, {
|
||||
'': () => _random(0, 1),
|
||||
number: max => _random(0, max),
|
||||
'number, number': (min, max) => _random(min, max),
|
||||
'Array | Matrix': size => _randomMatrix(size, 0, 1),
|
||||
'Array | Matrix, number': (size, max) => _randomMatrix(size, 0, max),
|
||||
'Array | Matrix, number, number': (size, min, max) => _randomMatrix(size, min, max)
|
||||
});
|
||||
function _randomMatrix(size, min, max) {
|
||||
const res = (0, _randomMatrix2.randomMatrix)(size.valueOf(), () => _random(min, max));
|
||||
return (0, _is.isMatrix)(size) ? size.create(res, 'number') : res;
|
||||
}
|
||||
function _random(min, max) {
|
||||
return min + rng() * (max - min);
|
||||
}
|
||||
});
|
||||
|
||||
// number only implementation of random, no matrix support
|
||||
// TODO: there is quite some duplicate code in both createRandom and createRandomNumber, can we improve that?
|
||||
const createRandomNumber = exports.createRandomNumber = /* #__PURE__ */(0, _factory.factory)(name, ['typed', 'config', '?on'], _ref2 => {
|
||||
let {
|
||||
typed,
|
||||
config,
|
||||
on,
|
||||
matrix
|
||||
} = _ref2;
|
||||
// seeded pseudo random number generator1
|
||||
let rng = (0, _seededRNG.createRng)(config.randomSeed);
|
||||
if (on) {
|
||||
on('config', function (curr, prev) {
|
||||
if (curr.randomSeed !== prev.randomSeed) {
|
||||
rng = (0, _seededRNG.createRng)(curr.randomSeed);
|
||||
}
|
||||
});
|
||||
}
|
||||
return typed(name, {
|
||||
'': () => _random(0, 1),
|
||||
number: max => _random(0, max),
|
||||
'number, number': (min, max) => _random(min, max)
|
||||
});
|
||||
function _random(min, max) {
|
||||
return min + rng() * (max - min);
|
||||
}
|
||||
});
|
||||
73
node_modules/mathjs/lib/cjs/function/probability/randomInt.js
generated
vendored
Normal file
73
node_modules/mathjs/lib/cjs/function/probability/randomInt.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createRandomInt = void 0;
|
||||
var _factory = require("../../utils/factory.js");
|
||||
var _randomMatrix = require("./util/randomMatrix.js");
|
||||
var _seededRNG = require("./util/seededRNG.js");
|
||||
var _is = require("../../utils/is.js");
|
||||
const name = 'randomInt';
|
||||
const dependencies = ['typed', 'config', '?on'];
|
||||
const createRandomInt = exports.createRandomInt = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
||||
let {
|
||||
typed,
|
||||
config,
|
||||
on
|
||||
} = _ref;
|
||||
// seeded pseudo random number generator
|
||||
let rng = (0, _seededRNG.createRng)(config.randomSeed);
|
||||
if (on) {
|
||||
on('config', function (curr, prev) {
|
||||
if (curr.randomSeed !== prev.randomSeed) {
|
||||
rng = (0, _seededRNG.createRng)(curr.randomSeed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a random integer number larger or equal to `min` and smaller than `max`
|
||||
* using a uniform distribution.
|
||||
*
|
||||
* Syntax:
|
||||
*
|
||||
* math.randomInt() // generate a random integer between 0 and 1
|
||||
* math.randomInt(max) // generate a random integer between 0 and max
|
||||
* math.randomInt(min, max) // generate a random integer between min and max
|
||||
* math.randomInt(size) // generate a matrix with random integer between 0 and 1
|
||||
* math.randomInt(size, max) // generate a matrix with random integer between 0 and max
|
||||
* math.randomInt(size, min, max) // generate a matrix with random integer between min and max
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* math.randomInt(100) // returns a random integer between 0 and 100
|
||||
* math.randomInt(30, 40) // returns a random integer between 30 and 40
|
||||
* math.randomInt([2, 3]) // returns a 2x3 matrix with random integers between 0 and 1
|
||||
*
|
||||
* See also:
|
||||
*
|
||||
* random, pickRandom
|
||||
*
|
||||
* @param {Array | Matrix} [size] If provided, an array or matrix with given
|
||||
* size and filled with random values is returned
|
||||
* @param {number} [min] Minimum boundary for the random value, included
|
||||
* @param {number} [max] Maximum boundary for the random value, excluded
|
||||
* @return {number | Array | Matrix} A random integer value
|
||||
*/
|
||||
return typed(name, {
|
||||
'': () => _randomInt(0, 1),
|
||||
number: max => _randomInt(0, max),
|
||||
'number, number': (min, max) => _randomInt(min, max),
|
||||
'Array | Matrix': size => _randomIntMatrix(size, 0, 1),
|
||||
'Array | Matrix, number': (size, max) => _randomIntMatrix(size, 0, max),
|
||||
'Array | Matrix, number, number': (size, min, max) => _randomIntMatrix(size, min, max)
|
||||
});
|
||||
function _randomIntMatrix(size, min, max) {
|
||||
const res = (0, _randomMatrix.randomMatrix)(size.valueOf(), () => _randomInt(min, max));
|
||||
return (0, _is.isMatrix)(size) ? size.create(res, 'number') : res;
|
||||
}
|
||||
function _randomInt(min, max) {
|
||||
return Math.floor(min + rng() * (max - min));
|
||||
}
|
||||
});
|
||||
26
node_modules/mathjs/lib/cjs/function/probability/util/randomMatrix.js
generated
vendored
Normal file
26
node_modules/mathjs/lib/cjs/function/probability/util/randomMatrix.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.randomMatrix = randomMatrix;
|
||||
/**
|
||||
* This is a util function for generating a random matrix recursively.
|
||||
* @param {number[]} size
|
||||
* @param {function} random
|
||||
* @returns {Array}
|
||||
*/
|
||||
function randomMatrix(size, random) {
|
||||
const data = [];
|
||||
size = size.slice(0);
|
||||
if (size.length > 1) {
|
||||
for (let i = 0, length = size.shift(); i < length; i++) {
|
||||
data.push(randomMatrix(size, random));
|
||||
}
|
||||
} else {
|
||||
for (let i = 0, length = size.shift(); i < length; i++) {
|
||||
data.push(random());
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
26
node_modules/mathjs/lib/cjs/function/probability/util/seededRNG.js
generated
vendored
Normal file
26
node_modules/mathjs/lib/cjs/function/probability/util/seededRNG.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.createRng = createRng;
|
||||
var _seedrandom = _interopRequireDefault(require("seedrandom"));
|
||||
const singletonRandom = /* #__PURE__ */(0, _seedrandom.default)(Date.now());
|
||||
function createRng(randomSeed) {
|
||||
let random;
|
||||
|
||||
// create a new random generator with given seed
|
||||
function setSeed(seed) {
|
||||
random = seed === null ? singletonRandom : (0, _seedrandom.default)(String(seed));
|
||||
}
|
||||
|
||||
// initialize a seeded pseudo random number generator with config's random seed
|
||||
setSeed(randomSeed);
|
||||
|
||||
// wrapper function so the rng can be updated via generator
|
||||
function rng() {
|
||||
return random();
|
||||
}
|
||||
return rng;
|
||||
}
|
||||
Reference in New Issue
Block a user