diff --git a/bower.json b/bower.json index f281f62..0bd309b 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ml", - "version": "5.2.0", + "version": "5.3.0", "main": [ "dist/ml.js", "dist/ml.min.js" diff --git a/dist/ml.js b/dist/ml.js index d90a48b..3493c17 100644 --- a/dist/ml.js +++ b/dist/ml.js @@ -1,6 +1,6 @@ /** * ml - Machine learning tools - * @version v5.2.0 + * @version v5.3.0 * @link https://github.com/mljs/ml * @license MIT */ @@ -1090,12 +1090,12 @@ ${indent}columns: ${matrix.columns} }; } - /** - * @private - * Check that a row index is not out of bounds - * @param {Matrix} matrix - * @param {number} index - * @param {boolean} [outer] + /** + * @private + * Check that a row index is not out of bounds + * @param {Matrix} matrix + * @param {number} index + * @param {boolean} [outer] */ function checkRowIndex(matrix, index, outer) { let max = outer ? matrix.rows : matrix.rows - 1; @@ -1104,12 +1104,12 @@ ${indent}columns: ${matrix.columns} throw new RangeError('Row index out of range'); } } - /** - * @private - * Check that a column index is not out of bounds - * @param {Matrix} matrix - * @param {number} index - * @param {boolean} [outer] + /** + * @private + * Check that a column index is not out of bounds + * @param {Matrix} matrix + * @param {number} index + * @param {boolean} [outer] */ function checkColumnIndex(matrix, index, outer) { @@ -1119,13 +1119,13 @@ ${indent}columns: ${matrix.columns} throw new RangeError('Column index out of range'); } } - /** - * @private - * Check that the provided vector is an array with the right length - * @param {Matrix} matrix - * @param {Array|Matrix} vector - * @return {Array} - * @throws {RangeError} + /** + * @private + * Check that the provided vector is an array with the right length + * @param {Matrix} matrix + * @param {Array|Matrix} vector + * @return {Array} + * @throws {RangeError} */ function checkRowVector(matrix, vector) { @@ -1139,13 +1139,13 @@ ${indent}columns: ${matrix.columns} return vector; } - /** - * @private - * Check that the provided vector is an array with the right length - * @param {Matrix} matrix - * @param {Array|Matrix} vector - * @return {Array} - * @throws {RangeError} + /** + * @private + * Check that the provided vector is an array with the right length + * @param {Matrix} matrix + * @param {Array|Matrix} vector + * @return {Array} + * @throws {RangeError} */ function checkColumnVector(matrix, vector) { @@ -16904,6 +16904,510 @@ ${indent}columns: ${matrix.columns} tanimoto: tanimoto }); + function zeroInsteadOfNegative(X) { + let rows = X.rows; + let columns = X.columns; + let newMatrix = new Matrix(X); + + for (let r = 0; r < rows; r++) { + for (let c = 0; c < columns; c++) { + if (newMatrix.get(r, c) < 0) { + newMatrix.set(r, c, 0); + } + } + } + + return newMatrix; + } + + function checkMatrixS(data, originalMatrix) { + let { + A, + S + } = data; //check if is there at least one element cero + + let indices = []; + let sum = S.sum('row'); + + for (let i = 0; i < sum.length; i++) { + if (sum[i] === 0) { + indices.push(i); + continue; + } else { + for (let j = 0; j < S.columns; j++) { + if (isNaN(S.get(i, j))) { + indices.push(i); + break; + } + } + } + } // if there than just one zero or NaN element + // run a NMF with the residual matrix Y - A*B + + + if (indices.length > 0) { + let temp = fastExtractNMF(originalMatrix.clone().subM(A.mmul(S)), indices.length); + + for (let i = 0; i < indices.length; i++) { + for (let j = 0; j < S.columns; j++) { + S.set(indices[i], j, temp.S.get(i, j)); + } + + for (let j = 0; j < A.rows; j++) { + A.set(j, indices[i], temp.A.get(j, i)); + } + } + } + + return Object.assign({}, data, { + A, + S + }); + } + + function fastExtractNMF(residual, r) { + if (r <= 0) return { + A: [], + S: [] + }; + const { + columns, + rows + } = residual; + let A = Matrix.zeros(rows, r); + let S = Matrix.zeros(r, columns); + + for (let i = 0; i < r; i++) { + residual = zeroInsteadOfNegative(residual); + if (residual.sum() === 0) continue; + let res2 = Matrix.pow(residual, 2).sum('column'); //find the max of the first column + + let maxIndex = 0; + + for (let j = 1; j < res2.length; j++) { + if (res2[maxIndex] < res2[j]) maxIndex = j; + } + + if (res2[maxIndex] > 0) { + let sqrtMaxValue = Math.sqrt(res2[maxIndex]); + + for (let j = 0; j < rows; j++) { + let value = residual.get(j, maxIndex) / sqrtMaxValue; + A.set(j, i, value); + } + + let temp = A.getColumnVector(i).transpose().mmul(residual); + + for (let j = 0; j < columns; j++) { + S.set(i, j, Math.max(temp.get(0, j), 0)); + } + + let subtracting = A.getColumnVector(i).mmul(S.getRowVector(i)); + residual = residual.sub(subtracting); + } + } + + return { + A, + S + }; + } + + function normBy(x, by = 'column') { + let norms = Matrix.mul(x, x).sum(by); + let length = norms.length; + + for (let i = 0; i < length; i++) { + norms[i] = Math.sqrt(norms[i]); + } + + return by === 'row' ? Matrix.from1DArray(length, 1, norms) : Matrix.from1DArray(1, length, norms); + } + + function normProj(X, normLimits) { + let norms; + let r = X.rows; + let c = X.columns; + + if (normLimits.rows === r) { + norms = normBy(X, 'row'); //select rows with norm > 0 then multiply twise by the min + + for (let i = 0; i < r; i++) { + if (norms.get(i, 0) <= 0) continue; + + for (let j = 0; j < c; j++) { + let value = X.get(i, j) * Math.min(norms.get(i, 0), normLimits.get(i, 0) / norms.get(i, 0)); + X.set(i, j, value); + } + } + } else { + norms = normBy(X, 'column'); + + for (let i = 0; i < c; i++) { + if (norms.get(0, i) <= 0) continue; + + for (let j = 0; j < r; j++) { + let value = X.get(j, i) * Math.min(norms.get(0, i), normLimits.get(0, i) / norms.get(0, i)); + X.set(j, i, value); + } + } + } + + return X; + } + + function updateMatrixA(Ainit, S, originalMatrix, options) { + let { + maxFBIteration, + toleranceFB, + normConstrained = false, + lambda + } = options; + let St = S.transpose(); + let H = S.mmul(St); + let YSt = originalMatrix.mmul(St); + let evd = new EigenvalueDecomposition(H, { + assumeSymmetric: true + }); + let L = Math.max(...evd.realEigenvalues); + let A = Ainit; + let prevA = A.clone(); + let t = 1; + + let gradient = a => a.mmul(H).sub(YSt); + + let proximal; + + if (normConstrained) { + let normLimits = normBy(Ainit, 'column'); + + proximal = (x, threshold) => normProj(zeroInsteadOfNegative(x.subS(threshold)), normLimits); + } else { + proximal = (x, threshold) => zeroInsteadOfNegative(x.subS(threshold)); + } + + for (let i = 0; i < maxFBIteration; i++) { + let tNext = (1 + Math.sqrt(1 + 4 * t * t)) / 2; + let w = (t - 1) / tNext; + t = tNext; + let B = Matrix.mul(A, w + 1).sub(Matrix.mul(prevA, w)); + prevA = A.clone(); + A = proximal(B.sub(gradient(B).divS(L)), lambda / L); + + if (Matrix.sub(prevA, A).norm() / A.norm() < toleranceFB) { + break; + } + } + + return A; + } + + function getMax(array = []) { + let max = Number.MIN_SAFE_INTEGER; + + for (let i = 0; i < array.length; i++) { + if (max < array[i]) max = array[i]; + } + + return max; + } + + function updateMatrixS(A, Sinit, originalMatrix, lambda, options) { + let { + maxFBIteration, + toleranceFB + } = options; + let At = A.transpose(); + let H = At.mmul(A); + let AtY = At.mmul(originalMatrix); + let evd = new EigenvalueDecomposition(H, { + assumeSymmetric: true + }); + let L = getMax(evd.realEigenvalues); + let t = 1; + let S = Sinit.clone(); + let prevS = S.clone(); + + let gradient = s => H.mmul(s).sub(AtY); + + let proximal = (x, threshold) => zeroInsteadOfNegative(x.subS(threshold)); + + for (let i = 0; i < maxFBIteration; i++) { + let tNext = (1 + Math.sqrt(1 + 4 * t * t)) / 2; + let w = (t - 1) / tNext; + t = tNext; // R = S_k + w [S_k - S_(k-1)] = (1 + w) .* S_k - w .* S_(k-1) + + let R = Matrix.mul(S, 1 + w).sub(Matrix.mul(prevS, w)); + prevS = S.clone(); + S = proximal(R.sub(gradient(R).divS(L)), lambda / L); + + if (Matrix.sub(prevS, S).norm() / S.norm() < toleranceFB) { + break; + } + } + + return S; + } + + function initialize(originalMatrix, options = {}) { + const { + rank, + randGenerator, + maxInitFBIteration, + toleranceFBInit, + maxFBIteration, + toleranceFB, + normConstrained + } = options; + let result = {}; + let rows = originalMatrix.rows; + result.A = Matrix.rand(rows, rank, { + random: randGenerator + }); + + for (let iter = 0; iter < maxInitFBIteration; iter++) { + //select columns with sum positive from A + let sumC = result.A.sum('column'); + + for (let i = 0; i < sumC.length; i++) { + while (sumC[i] === 0) { + sumC[i] = 0; + + for (let j = 0; j < rows; j++) { + result.A.set(j, i, randGenerator()); + sumC[i] += result.A.get(j, i); + } + } + } //resolve the system of equation Lx = D for x, then select just non negative values; + + + result.S = zeroInsteadOfNegative(solve(result.A, originalMatrix)); //select rows with positive sum by row + + let sumR = result.S.sum('row'); + let positiveSumRowIndexS = []; + let positiveSumRowS = []; + + for (let i = 0; i < sumR.length; i++) { + if (sumR[i] > 0) { + positiveSumRowIndexS.push(i); + positiveSumRowS.push(result.S.getRow(i)); + } + } + + positiveSumRowS = Matrix.checkMatrix(positiveSumRowS); // solve the system of linear equation xL = D for x. knowing that D/L = (L'\D')'. + + let candidateA = zeroInsteadOfNegative(solve(positiveSumRowS.transpose(), originalMatrix.transpose())); //then, set the columns of A with an index equal to the row index with sum > 0 into S + //this step complete the last transpose of D/L = (L'\D')'. + + for (let i = 0; i < positiveSumRowIndexS.length; i++) { + let colCandidate = candidateA.getRow(i); + + for (let j = 0; j < rows; j++) { + result.A.set(j, positiveSumRowIndexS[i], colCandidate[j]); + } + } + + let prevS = result.S.clone(); + result.S = updateMatrixS(result.A, result.S, originalMatrix, 0, { + maxFBIteration, + toleranceFB + }); + result = checkMatrixS(result, originalMatrix); + result.A = updateMatrixA(result.A, result.S, originalMatrix, 0); + + if (Matrix.sub(prevS, result.S).norm() / result.S.norm() < toleranceFBInit) { + break; + } + } + + return result; + } + + function normalize(data, options) { + const { + normOnA + } = options; + let DS = normBy(data.S.transpose(), 'column'); + let DA = normBy(data.A, 'column'); + let D = Matrix.mul(DS, DA); + let onS, onA; + + if (normOnA) { + onS = (index, c) => data.S.get(index, c) * D.get(0, index) / DS.get(0, index); + + onA = (index, r) => data.A.get(r, index) / DA.get(0, index); + } else { + onS = (index, c) => data.S.get(index, c) / DS.get(0, index); + + onA = (index, r) => data.A.get(r, index) * D.get(0, index) / DA.get(0, index); + } + + const sColumns = data.S.columns; + const aRows = data.A.rows; + + for (let index = 0; index < D.columns; index++) { + let valueForS, valueForA; + + if (D.get(0, index) > 0) { + valueForS = onS; + valueForA = onA; + } else { + valueForA = () => 0; + + valueForS = () => 0; + } + + for (let c = 0; c < sColumns; c++) { + data.S.set(index, c, valueForS(index, c)); + } + + for (let r = 0; r < aRows; r++) { + data.A.set(r, index, valueForA(index, r)); + } + } + + return data; + } + + function getMedians(X, by) { + let medians = []; + let rows = X.rows; + let columns = X.columns; + + switch (by) { + case 'column': + for (let i = 0; i < columns; i++) { + medians.push(medianQuickselect_min(X.getColumn(i))); + } + + medians = Matrix.from1DArray(1, columns, medians); + break; + + default: + for (let i = 0; i < rows; i++) { + medians.push(medianQuickselect_min(X.getRow(i))); + } + + medians = Matrix.from1DArray(rows, 1, medians); + } + + return medians; + } + + function dimMADstd(X, by) { + let medians = getMedians(X, by); + let matrix = X.clone(); + matrix = by === 'column' ? matrix.subRowVector(medians.to1DArray()) : matrix.subColumnVector(medians.to1DArray()); + return Matrix.mul(getMedians(matrix.abs(), by), 1.4826); + } + + function updateLambda(data, originalMatrix, options = {}) { + let { + refinementBeginning, + tauMAD + } = options; + let { + iteration, + lambda, + A, + S + } = data; + if (refinementBeginning <= iteration) return lambda; + let sigmaResidue; + + if (options.lambdaInf !== undefined) { + sigmaResidue = options.lambdaInf / options.tauMAD; + } else if (options.addStd !== undefined) { + sigmaResidue = options.addStd; + } else { + let alY = Matrix.sub(originalMatrix, A.mmul(S)).to1DArray(); + let result = dimMADstd(Matrix.from1DArray(1, alY.length, alY), 'row'); + sigmaResidue = result.get(0, 0); + } + + let nextLambda = Math.max(tauMAD * sigmaResidue, lambda - 1 / (refinementBeginning - iteration)); + return nextLambda; + } + + /** + * Performing non-negative matrix factorization solving argmin_(A >= 0, S >= 0) 1 / 2 * ||Y - AS||_2^2 + lambda * ||S||_1 + * @param {Matrix||Array} originalMatrix - Matrix to be separated. + * @param {Number} rank - The maximum number of linearly independent column/row vectors in the matrix. + * @param {Object} [options = {}] - Options of ngmca factorization method. + * @param {Number} [options.maximumIteration = 500] - Maximum number of iterations. + * @param {Number} [options.maxFBIteration = 80] - Maximum number of iterations of the Forward-Backward subroutine. + * @param {Object} [options.randGenerator = Math.random] - Random number generator for the subroutine of initialization. + * @param {Number} [options.maxInitFBIteration = 50] - Maximum number of iterations of the Forward-Backward subroutine at the initialization. + * @param {Number} [options.toleranceFB = 1e-5] - relative difference tolerance for convergence of the Forward-Backward sub-iterations. + * @param {Number} [options.toleranceFBInit = 0] - relative difference tolerance for convergence of the Forward-Backward sub-iterations at the initialization. + * @param {Number} [options.phaseRatio = 0.8] - transition between decreasing thresholding phase and refinement phase in percent of the iterations. + * @param {Number} [options.tauMAD = 1] - constant coefficient for the final threshold computation. + * @param {Boolean} [options.useTranspose = false] - if true the originalMatrix is transposed. + */ + + function nGMCA(originalMatrix, rank, options = {}) { + const { + maximumIteration = 500, + maxFBIteration = 80, + maxInitFBIteration = 50, + toleranceFBInit = 0, + toleranceFB = 0.00001, + phaseRatio = 0.8, + randGenerator = Math.random, + tauMAD = 1, + useTranspose = false + } = options; + let { + normConstrained = false + } = options; + originalMatrix = Matrix.checkMatrix(originalMatrix); + if (useTranspose) originalMatrix = originalMatrix.transpose(); + let refinementBeginning = Math.floor(phaseRatio * maximumIteration); + let data = initialize(originalMatrix, { + rank, + randGenerator, + maxInitFBIteration, + toleranceFBInit, + maxFBIteration, + toleranceFB + }); + data = normalize(data, { + normOnA: true + }); + data.lambda = data.A.transpose().mmul(data.A.mmul(data.S).sub(originalMatrix)).abs().max(); + + for (let iter = 0; iter < maximumIteration; iter++) { + data.iteration = iter; + data.S = updateMatrixS(data.A, data.S, originalMatrix, data.lambda, options); + data = checkMatrixS(data, originalMatrix); + data = normalize(data, { + normOnA: false + }); + if (iter > refinementBeginning) normConstrained = true; + data.A = updateMatrixA(data.A, data.S, originalMatrix, { + maxFBIteration, + toleranceFB, + normConstrained, + lambda: 0 + }); + data = normalize(data, { + normOnA: true + }); + data.lambda = updateLambda(data, originalMatrix, { + refinementBeginning, + tauMAD + }); + } + + if (useTranspose) { + let temp = data.A.transpose(); + data.A = data.S.transpose(); + data.S = temp; + } + + return data; + } + var acc = pred => { const l = pred.cutoffs.length; const result = new Array(l); @@ -19593,7 +20097,7 @@ ${indent}columns: ${matrix.columns} * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of a zone * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of a zone */ - function normalize(zones = [], options = {}) { + function normalize$1(zones = [], options = {}) { if (zones.length === 0) return []; let { from = Number.NEGATIVE_INFINITY, @@ -19647,7 +20151,7 @@ ${indent}columns: ${matrix.columns} to = Number.POSITIVE_INFINITY } = options; if (from > to) [from, to] = [to, from]; - exclusions = normalize(exclusions, { + exclusions = normalize$1(exclusions, { from, to }); @@ -19699,7 +20203,7 @@ ${indent}columns: ${matrix.columns} function zonesWithPoints(zones, numberOfPoints, options = {}) { if (zones.length === 0) return zones; - zones = normalize(zones, options); + zones = normalize$1(zones, options); const totalSize = zones.reduce((previous, current) => { return previous + (current.to - current.from); }, 0); @@ -20215,6 +20719,7 @@ ${indent}columns: ${matrix.columns} exports.binarySearch = binarySearch; exports.distanceMatrix = distanceMatrix; exports.levenbergMarquardt = levenbergMarquardt; + exports.nGMCA = nGMCA; exports.numSort = index$4; exports.padArray = src$2; exports.savitzkyGolay = savitzkyGolay; diff --git a/dist/ml.js.map b/dist/ml.js.map index 964f990..28acb8a 100644 --- a/dist/ml.js.map +++ b/dist/ml.js.map @@ -1 +1 @@ -{"version":3,"file":"ml.js","sources":["../node_modules/ml-array-rescale/node_modules/is-any-array/src/index.js","../node_modules/ml-array-rescale/node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-rescale/node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-rescale/lib-es6/index.js","../node_modules/ml-matrix/src/inspect.js","../node_modules/ml-matrix/src/mathOperations.js","../node_modules/ml-matrix/src/util.js","../node_modules/ml-matrix/src/stat.js","../node_modules/ml-matrix/src/matrix.js","../node_modules/ml-matrix/src/views/base.js","../node_modules/ml-matrix/src/views/column.js","../node_modules/ml-matrix/src/views/columnSelection.js","../node_modules/ml-matrix/src/views/flipColumn.js","../node_modules/ml-matrix/src/views/flipRow.js","../node_modules/ml-matrix/src/views/row.js","../node_modules/ml-matrix/src/views/rowSelection.js","../node_modules/ml-matrix/src/views/selection.js","../node_modules/ml-matrix/src/views/sub.js","../node_modules/ml-matrix/src/views/transpose.js","../node_modules/ml-matrix/src/wrap/WrapperMatrix1D.js","../node_modules/ml-matrix/src/wrap/WrapperMatrix2D.js","../node_modules/ml-matrix/src/wrap/wrap.js","../node_modules/ml-matrix/src/dc/lu.js","../node_modules/ml-matrix/src/dc/util.js","../node_modules/ml-matrix/src/dc/qr.js","../node_modules/ml-matrix/src/dc/svd.js","../node_modules/ml-matrix/src/decompositions.js","../node_modules/ml-matrix/src/determinant.js","../node_modules/ml-matrix/src/linearDependencies.js","../node_modules/ml-matrix/src/pseudoInverse.js","../node_modules/ml-matrix/src/covariance.js","../node_modules/ml-matrix/src/correlation.js","../node_modules/ml-matrix/src/dc/evd.js","../node_modules/ml-matrix/src/dc/cholesky.js","../node_modules/ml-matrix/src/dc/nipals.js","../node_modules/ml-array-sum/node_modules/is-any-array/src/index.js","../node_modules/ml-array-sum/lib-es6/index.js","../node_modules/ml-array-mean/lib-es6/index.js","../node_modules/ml-cart/src/utils.js","../node_modules/ml-cart/src/TreeNode.js","../node_modules/ml-cart/src/DecisionTreeClassifier.js","../node_modules/ml-cart/src/DecisionTreeRegression.js","../node_modules/random-js/dist/random-js.esm.js","../node_modules/ml-random-forest/src/utils.js","../node_modules/ml-random-forest/src/RandomForestBase.js","../node_modules/ml-random-forest/src/RandomForestClassifier.js","../node_modules/ml-array-median/node_modules/is-any-array/src/index.js","../node_modules/median-quickselect/lib/median-quickselect.min.js","../node_modules/ml-array-median/lib-es6/index.js","../node_modules/ml-random-forest/src/RandomForestRegression.js","../node_modules/ml-pca/src/pca.js","../node_modules/ml-distance-euclidean/lib-es6/euclidean.js","../node_modules/ml-distance-matrix/src/index.js","../node_modules/heap/lib/heap.js","../node_modules/heap/index.js","../node_modules/ml-hclust/src/Cluster.js","../node_modules/ml-hclust/src/agnes.js","../node_modules/ml-hclust/src/index.js","../node_modules/ml-nearest-vector/lib-es6/index.js","../node_modules/ml-kmeans/src/utils.js","../node_modules/ml-xsadd/lib-es6/xsadd.js","../node_modules/ml-random/lib-es6/choice.js","../node_modules/ml-random/lib-es6/index.js","../node_modules/ml-kmeans/src/initialization.js","../node_modules/ml-kmeans/src/KMeansResult.js","../node_modules/ml-kmeans/src/kmeans.js","../node_modules/ml-naivebayes/src/utils.js","../node_modules/ml-naivebayes/src/GaussianNB.js","../node_modules/ml-naivebayes/src/MultinomialNB.js","../node_modules/ml-knn/src/KDTree.js","../node_modules/ml-knn/src/index.js","../node_modules/ml-pls/src/util/utils.js","../node_modules/ml-pls/src/PLS.js","../node_modules/ml-pls/src/KOPLS.js","../node_modules/ml-confusion-matrix/src/index.js","../node_modules/ml-combinations/lib/index.js","../node_modules/ml-cross-validation/src/getFolds.js","../node_modules/ml-cross-validation/src/sampleAClass.js","../node_modules/ml-cross-validation/src/index.js","../node_modules/ml-pls/src/OPLSNipals.js","../node_modules/ml-pls/src/util/tss.js","../node_modules/ml-pls/src/OPLS.js","../node_modules/ml-fnn/FeedForwardNeuralNetwork.js","../node_modules/ml-som/src/node-square.js","../node_modules/ml-som/src/node-hexagonal.js","../node_modules/ml-som/src/index.js","../node_modules/ml-regression-base/src/maybeToPrecision.js","../node_modules/ml-regression-base/src/checkArrayLength.js","../node_modules/ml-regression-base/src/index.js","../node_modules/ml-regression-polynomial/src/index.js","../node_modules/ml-regression-simple-linear/src/index.js","../node_modules/ml-regression-exponential/src/index.js","../node_modules/ml-regression-power/src/index.js","../node_modules/ml-regression-multivariate-linear/src/index.js","../node_modules/ml-kernel-gaussian/gaussian-kernel.js","../node_modules/ml-kernel-polynomial/polynomial-kernel.js","../node_modules/ml-kernel-sigmoid/sigmoid-kernel.js","../node_modules/ml-kernel/src/kernels/anova-kernel.js","../node_modules/ml-kernel/src/kernels/cauchy-kernel.js","../node_modules/ml-kernel/src/kernels/exponential-kernel.js","../node_modules/ml-kernel/src/kernels/histogram-intersection-kernel.js","../node_modules/ml-kernel/src/kernels/laplacian-kernel.js","../node_modules/ml-kernel/src/kernels/multiquadratic-kernel.js","../node_modules/ml-kernel/src/kernels/rational-quadratic-kernel.js","../node_modules/ml-kernel/src/kernel.js","../node_modules/ml-regression-theil-sen/src/index.js","../node_modules/ml-regression-robust-polynomial/src/index.js","../node_modules/ml-levenberg-marquardt/node_modules/is-any-array/src/index.js","../node_modules/ml-levenberg-marquardt/src/errorCalculation.js","../node_modules/ml-levenberg-marquardt/src/step.js","../node_modules/ml-levenberg-marquardt/src/index.js","../node_modules/ml-fcnnls/src/util/selection.js","../node_modules/ml-fcnnls/src/util/sortCollectionSet.js","../node_modules/ml-fcnnls/src/cssls.js","../node_modules/ml-fcnnls/src/initialisation.js","../node_modules/ml-fcnnls/src/util/setDifference.js","../node_modules/ml-fcnnls/src/optimality.js","../node_modules/ml-fcnnls/src/fcnnls.js","../node_modules/ml-fcnnls/src/fcnnlsVector.js","../node_modules/binary-search/index.js","../node_modules/num-sort/index.js","../node_modules/ml-hash-table/src/primeFinder.js","../node_modules/ml-hash-table/src/HashTable.js","../node_modules/ml-sparse-matrix/src/index.js","../node_modules/ml-distance/src/distances/additiveSymmetric.js","../node_modules/ml-distance/src/distances/avg.js","../node_modules/ml-distance/src/distances/bhattacharyya.js","../node_modules/ml-distance/src/distances/canberra.js","../node_modules/ml-distance/src/distances/chebyshev.js","../node_modules/ml-distance/src/distances/clark.js","../node_modules/ml-distance/src/similarities/czekanowski.js","../node_modules/ml-distance/src/distances/czekanowski.js","../node_modules/ml-distance/src/distances/dice.js","../node_modules/ml-distance/src/distances/divergence.js","../node_modules/ml-distance/src/distances/fidelity.js","../node_modules/ml-distance/src/distances/gower.js","../node_modules/ml-distance/src/distances/harmonicMean.js","../node_modules/ml-distance/src/distances/hellinger.js","../node_modules/ml-distance/src/distances/innerProduct.js","../node_modules/ml-distance/src/distances/intersection.js","../node_modules/ml-distance/src/distances/jaccard.js","../node_modules/ml-distance/src/distances/jeffreys.js","../node_modules/ml-distance/src/distances/jensenDifference.js","../node_modules/ml-distance/src/distances/jensenShannon.js","../node_modules/ml-distance/src/distances/kdivergence.js","../node_modules/ml-distance/src/distances/kulczynski.js","../node_modules/ml-distance/src/distances/kullbackLeibler.js","../node_modules/ml-distance/src/distances/kumarHassebrook.js","../node_modules/ml-distance/src/distances/kumarJohnson.js","../node_modules/ml-distance/src/distances/lorentzian.js","../node_modules/ml-distance/src/distances/manhattan.js","../node_modules/ml-distance/src/distances/matusita.js","../node_modules/ml-distance/src/distances/minkowski.js","../node_modules/ml-distance/src/distances/motyka.js","../node_modules/ml-distance/src/distances/neyman.js","../node_modules/ml-distance/src/distances/pearson.js","../node_modules/ml-distance/src/distances/probabilisticSymmetric.js","../node_modules/ml-distance/src/distances/ruzicka.js","../node_modules/ml-distance/src/distances/soergel.js","../node_modules/ml-distance/src/distances/sorensen.js","../node_modules/ml-distance/src/distances/squared.js","../node_modules/ml-distance/src/distances/squaredChord.js","../node_modules/ml-distance/src/distances/taneja.js","../node_modules/ml-distance/src/similarities/tanimoto.js","../node_modules/ml-distance/src/distances/tanimoto.js","../node_modules/ml-distance/src/distances/topsoe.js","../node_modules/ml-distance/src/distances/waveHedges.js","../node_modules/ml-tree-similarity/src/createTree.js","../node_modules/ml-tree-similarity/src/getSimilarity.js","../node_modules/ml-tree-similarity/src/index.js","../node_modules/ml-distance/src/similarities/cosine.js","../node_modules/ml-distance/src/similarities/dice.js","../node_modules/ml-distance/src/similarities/intersection.js","../node_modules/ml-distance/src/similarities/jaccard.js","../node_modules/ml-distance/src/similarities/kulczynski.js","../node_modules/ml-distance/src/similarities/motyka.js","../node_modules/ml-distance/src/similarities/pearson.js","../node_modules/ml-distance/src/similarities/squaredChord.js","../node_modules/ml-performance/src/measures.js","../node_modules/ml-performance/src/index.js","../node_modules/ml-pad-array/src/index.js","../node_modules/ml-savitzky-golay/src/index.js","../node_modules/ml-bit-array/src/creator.js","../node_modules/ml-bit-array/src/index.js","../node_modules/ml-gsd/node_modules/ml-savitzky-golay-generalized/src/index.js","../node_modules/ml-gsd/src/gsd.js","../node_modules/ml-optimize-lorentzian/src/sumOfGaussians.js","../node_modules/ml-optimize-lorentzian/src/optimizeGaussianSum.js","../node_modules/ml-optimize-lorentzian/src/singleGaussian.js","../node_modules/ml-optimize-lorentzian/src/optimizeSingleGaussian.js","../node_modules/ml-optimize-lorentzian/src/sumOfLorentzians.js","../node_modules/ml-optimize-lorentzian/src/optimizeLorentzianSum.js","../node_modules/ml-optimize-lorentzian/src/singleLorentzian.js","../node_modules/ml-optimize-lorentzian/src/optimizeSingleLorentzian.js","../node_modules/ml-gsd/src/post/optimizePeaks.js","../node_modules/ml-gsd/src/post/joinBroadPeaks.js","../node_modules/ml-gsd/src/post/broadenPeaks.js","../node_modules/is-any-array/src/index.js","../node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-mode/lib-es6/index.js","../node_modules/ml-array-normed/node_modules/is-any-array/src/index.js","../node_modules/ml-array-normed/node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-normed/lib-es6/index.js","../node_modules/ml-array-sequential-fill/lib-es6/index.js","../node_modules/ml-array-variance/node_modules/is-any-array/src/index.js","../node_modules/ml-array-variance/lib-es6/index.js","../node_modules/ml-array-standard-deviation/lib-es6/index.js","../node_modules/ml-array-xy-centroids-merge/src/index.js","../node_modules/ml-arrayxy-closestx/src/index.js","../node_modules/ml-array-xy-covariance/src/index.js","../node_modules/ml-array-xy-max-merge/src/index.js","../node_modules/ml-array-xy-max-y/src/index.js","../node_modules/ml-array-xy-sort-x/src/index.js","../node_modules/ml-arrayxy-uniquex/src/index.js","../node_modules/ml-array-xy-weighted-merge/src/index.js","../node_modules/ml-zones/src/normalize.js","../node_modules/ml-zones/src/invert.js","../node_modules/ml-zones/src/zonesWithPoints.js","../node_modules/ml-array-xy-equally-spaced/src/integral.js","../node_modules/ml-array-xy-equally-spaced/src/equallySpacedSmooth.js","../node_modules/ml-array-xy-equally-spaced/src/equallySpacedSlot.js","../node_modules/ml-array-xy-equally-spaced/src/index.js","../node_modules/ml-array-xy-filter-x/src/getZones.js","../node_modules/ml-array-xy-filter-x/src/index.js","../src/index.js"],"sourcesContent":["const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\n\nfunction min(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var minValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import isArray from 'is-any-array';\nimport max from 'ml-array-max';\nimport min from 'ml-array-min';\n\nfunction rescale(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n } else if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var output;\n\n if (options.output !== undefined) {\n if (!isArray(options.output)) {\n throw new TypeError('output option must be an array if specified');\n }\n\n output = options.output;\n } else {\n output = new Array(input.length);\n }\n\n var currentMin = min(input);\n var currentMax = max(input);\n\n if (currentMin === currentMax) {\n throw new RangeError('minimum and maximum input values are equal. Cannot rescale a constant array');\n }\n\n var _options$min = options.min,\n minValue = _options$min === void 0 ? options.autoMinMax ? currentMin : 0 : _options$min,\n _options$max = options.max,\n maxValue = _options$max === void 0 ? options.autoMinMax ? currentMax : 1 : _options$max;\n\n if (minValue >= maxValue) {\n throw new RangeError('min option must be smaller than max option');\n }\n\n var factor = (maxValue - minValue) / (currentMax - currentMin);\n\n for (var i = 0; i < input.length; i++) {\n output[i] = (input[i] - currentMin) * factor + minValue;\n }\n\n return output;\n}\n\nexport default rescale;\n","const indent = ' '.repeat(2);\nconst indentData = ' '.repeat(4);\n\nexport function inspectMatrix() {\n return inspectMatrixWithOptions(this);\n}\n\nexport function inspectMatrixWithOptions(matrix, options = {}) {\n const { maxRows = 15, maxColumns = 10, maxNumSize = 8 } = options;\n return `${matrix.constructor.name} {\n${indent}[\n${indentData}${inspectData(matrix, maxRows, maxColumns, maxNumSize)}\n${indent}]\n${indent}rows: ${matrix.rows}\n${indent}columns: ${matrix.columns}\n}`;\n}\n\nfunction inspectData(matrix, maxRows, maxColumns, maxNumSize) {\n const { rows, columns } = matrix;\n const maxI = Math.min(rows, maxRows);\n const maxJ = Math.min(columns, maxColumns);\n const result = [];\n for (let i = 0; i < maxI; i++) {\n let line = [];\n for (let j = 0; j < maxJ; j++) {\n line.push(formatNumber(matrix.get(i, j), maxNumSize));\n }\n result.push(`${line.join(' ')}`);\n }\n if (maxJ !== columns) {\n result[result.length - 1] += ` ... ${columns - maxColumns} more columns`;\n }\n if (maxI !== rows) {\n result.push(`... ${rows - maxRows} more rows`);\n }\n return result.join(`\\n${indentData}`);\n}\n\nfunction formatNumber(num, maxNumSize) {\n const numStr = String(num);\n if (numStr.length <= maxNumSize) {\n return numStr.padEnd(maxNumSize, ' ');\n }\n const precise = num.toPrecision(maxNumSize - 2);\n if (precise.length <= maxNumSize) {\n return precise;\n }\n const exponential = num.toExponential(maxNumSize - 2);\n const eIndex = exponential.indexOf('e');\n const e = exponential.slice(eIndex);\n return exponential.slice(0, maxNumSize - e.length) + e;\n}\n","export function installMathOperations(AbstractMatrix, Matrix) {\r\n AbstractMatrix.prototype.add = function add(value) {\r\n if (typeof value === 'number') return this.addS(value);\r\n return this.addM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.addS = function addS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.addM = function addM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.add = function add(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.add(value);\r\n };\r\n\r\n AbstractMatrix.prototype.sub = function sub(value) {\r\n if (typeof value === 'number') return this.subS(value);\r\n return this.subM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.subS = function subS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.subM = function subM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sub = function sub(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sub(value);\r\n };\r\n AbstractMatrix.prototype.subtract = AbstractMatrix.prototype.sub;\r\n AbstractMatrix.prototype.subtractS = AbstractMatrix.prototype.subS;\r\n AbstractMatrix.prototype.subtractM = AbstractMatrix.prototype.subM;\r\n AbstractMatrix.subtract = AbstractMatrix.sub;\r\n\r\n AbstractMatrix.prototype.mul = function mul(value) {\r\n if (typeof value === 'number') return this.mulS(value);\r\n return this.mulM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.mulS = function mulS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.mulM = function mulM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.mul = function mul(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.mul(value);\r\n };\r\n AbstractMatrix.prototype.multiply = AbstractMatrix.prototype.mul;\r\n AbstractMatrix.prototype.multiplyS = AbstractMatrix.prototype.mulS;\r\n AbstractMatrix.prototype.multiplyM = AbstractMatrix.prototype.mulM;\r\n AbstractMatrix.multiply = AbstractMatrix.mul;\r\n\r\n AbstractMatrix.prototype.div = function div(value) {\r\n if (typeof value === 'number') return this.divS(value);\r\n return this.divM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.divS = function divS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.divM = function divM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.div = function div(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.div(value);\r\n };\r\n AbstractMatrix.prototype.divide = AbstractMatrix.prototype.div;\r\n AbstractMatrix.prototype.divideS = AbstractMatrix.prototype.divS;\r\n AbstractMatrix.prototype.divideM = AbstractMatrix.prototype.divM;\r\n AbstractMatrix.divide = AbstractMatrix.div;\r\n\r\n AbstractMatrix.prototype.mod = function mod(value) {\r\n if (typeof value === 'number') return this.modS(value);\r\n return this.modM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.modS = function modS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) % value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.modM = function modM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) % matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.mod = function mod(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.mod(value);\r\n };\r\n AbstractMatrix.prototype.modulus = AbstractMatrix.prototype.mod;\r\n AbstractMatrix.prototype.modulusS = AbstractMatrix.prototype.modS;\r\n AbstractMatrix.prototype.modulusM = AbstractMatrix.prototype.modM;\r\n AbstractMatrix.modulus = AbstractMatrix.mod;\r\n\r\n AbstractMatrix.prototype.and = function and(value) {\r\n if (typeof value === 'number') return this.andS(value);\r\n return this.andM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.andS = function andS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) & value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.andM = function andM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) & matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.and = function and(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.and(value);\r\n };\r\n\r\n AbstractMatrix.prototype.or = function or(value) {\r\n if (typeof value === 'number') return this.orS(value);\r\n return this.orM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.orS = function orS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) | value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.orM = function orM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) | matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.or = function or(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.or(value);\r\n };\r\n\r\n AbstractMatrix.prototype.xor = function xor(value) {\r\n if (typeof value === 'number') return this.xorS(value);\r\n return this.xorM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.xorS = function xorS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) ^ value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.xorM = function xorM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) ^ matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.xor = function xor(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.xor(value);\r\n };\r\n\r\n AbstractMatrix.prototype.leftShift = function leftShift(value) {\r\n if (typeof value === 'number') return this.leftShiftS(value);\r\n return this.leftShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.leftShiftS = function leftShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) << value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.leftShiftM = function leftShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) << matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.leftShift = function leftShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.leftShift(value);\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShift = function signPropagatingRightShift(value) {\r\n if (typeof value === 'number') return this.signPropagatingRightShiftS(value);\r\n return this.signPropagatingRightShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShiftS = function signPropagatingRightShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >> value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShiftM = function signPropagatingRightShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >> matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.signPropagatingRightShift = function signPropagatingRightShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.signPropagatingRightShift(value);\r\n };\r\n\r\n AbstractMatrix.prototype.rightShift = function rightShift(value) {\r\n if (typeof value === 'number') return this.rightShiftS(value);\r\n return this.rightShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.rightShiftS = function rightShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >>> value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.rightShiftM = function rightShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >>> matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.rightShift = function rightShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.rightShift(value);\r\n };\r\n AbstractMatrix.prototype.zeroFillRightShift = AbstractMatrix.prototype.rightShift;\r\n AbstractMatrix.prototype.zeroFillRightShiftS = AbstractMatrix.prototype.rightShiftS;\r\n AbstractMatrix.prototype.zeroFillRightShiftM = AbstractMatrix.prototype.rightShiftM;\r\n AbstractMatrix.zeroFillRightShift = AbstractMatrix.rightShift;\r\n\r\n AbstractMatrix.prototype.not = function not() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, ~(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.not = function not(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.not();\r\n };\r\n\r\n AbstractMatrix.prototype.abs = function abs() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.abs(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.abs = function abs(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.abs();\r\n };\r\n\r\n AbstractMatrix.prototype.acos = function acos() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.acos(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.acos = function acos(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.acos();\r\n };\r\n\r\n AbstractMatrix.prototype.acosh = function acosh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.acosh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.acosh = function acosh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.acosh();\r\n };\r\n\r\n AbstractMatrix.prototype.asin = function asin() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.asin(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.asin = function asin(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.asin();\r\n };\r\n\r\n AbstractMatrix.prototype.asinh = function asinh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.asinh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.asinh = function asinh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.asinh();\r\n };\r\n\r\n AbstractMatrix.prototype.atan = function atan() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.atan(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.atan = function atan(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.atan();\r\n };\r\n\r\n AbstractMatrix.prototype.atanh = function atanh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.atanh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.atanh = function atanh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.atanh();\r\n };\r\n\r\n AbstractMatrix.prototype.cbrt = function cbrt() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cbrt(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cbrt = function cbrt(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cbrt();\r\n };\r\n\r\n AbstractMatrix.prototype.ceil = function ceil() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.ceil(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.ceil = function ceil(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.ceil();\r\n };\r\n\r\n AbstractMatrix.prototype.clz32 = function clz32() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.clz32(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.clz32 = function clz32(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.clz32();\r\n };\r\n\r\n AbstractMatrix.prototype.cos = function cos() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cos(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cos = function cos(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cos();\r\n };\r\n\r\n AbstractMatrix.prototype.cosh = function cosh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cosh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cosh = function cosh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cosh();\r\n };\r\n\r\n AbstractMatrix.prototype.exp = function exp() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.exp(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.exp = function exp(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.exp();\r\n };\r\n\r\n AbstractMatrix.prototype.expm1 = function expm1() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.expm1(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.expm1 = function expm1(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.expm1();\r\n };\r\n\r\n AbstractMatrix.prototype.floor = function floor() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.floor(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.floor = function floor(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.floor();\r\n };\r\n\r\n AbstractMatrix.prototype.fround = function fround() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.fround(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.fround = function fround(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.fround();\r\n };\r\n\r\n AbstractMatrix.prototype.log = function log() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log = function log(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log();\r\n };\r\n\r\n AbstractMatrix.prototype.log1p = function log1p() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log1p(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log1p = function log1p(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log1p();\r\n };\r\n\r\n AbstractMatrix.prototype.log10 = function log10() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log10(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log10 = function log10(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log10();\r\n };\r\n\r\n AbstractMatrix.prototype.log2 = function log2() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log2(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log2 = function log2(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log2();\r\n };\r\n\r\n AbstractMatrix.prototype.round = function round() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.round(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.round = function round(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.round();\r\n };\r\n\r\n AbstractMatrix.prototype.sign = function sign() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sign(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sign = function sign(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sign();\r\n };\r\n\r\n AbstractMatrix.prototype.sin = function sin() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sin(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sin = function sin(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sin();\r\n };\r\n\r\n AbstractMatrix.prototype.sinh = function sinh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sinh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sinh = function sinh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sinh();\r\n };\r\n\r\n AbstractMatrix.prototype.sqrt = function sqrt() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sqrt(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sqrt = function sqrt(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sqrt();\r\n };\r\n\r\n AbstractMatrix.prototype.tan = function tan() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.tan(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.tan = function tan(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.tan();\r\n };\r\n\r\n AbstractMatrix.prototype.tanh = function tanh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.tanh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.tanh = function tanh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.tanh();\r\n };\r\n\r\n AbstractMatrix.prototype.trunc = function trunc() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.trunc(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.trunc = function trunc(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.trunc();\r\n };\r\n\r\n AbstractMatrix.pow = function pow(matrix, arg0) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.pow(arg0);\r\n };\r\n\r\n AbstractMatrix.prototype.pow = function pow(value) {\r\n if (typeof value === 'number') return this.powS(value);\r\n return this.powM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.powS = function powS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.pow(this.get(i, j), value));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.powM = function powM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n}\r\n","/**\n * @private\n * Check that a row index is not out of bounds\n * @param {Matrix} matrix\n * @param {number} index\n * @param {boolean} [outer]\n */\nexport function checkRowIndex(matrix, index, outer) {\n let max = outer ? matrix.rows : matrix.rows - 1;\n if (index < 0 || index > max) {\n throw new RangeError('Row index out of range');\n }\n}\n\n/**\n * @private\n * Check that a column index is not out of bounds\n * @param {Matrix} matrix\n * @param {number} index\n * @param {boolean} [outer]\n */\nexport function checkColumnIndex(matrix, index, outer) {\n let max = outer ? matrix.columns : matrix.columns - 1;\n if (index < 0 || index > max) {\n throw new RangeError('Column index out of range');\n }\n}\n\n/**\n * @private\n * Check that the provided vector is an array with the right length\n * @param {Matrix} matrix\n * @param {Array|Matrix} vector\n * @return {Array}\n * @throws {RangeError}\n */\nexport function checkRowVector(matrix, vector) {\n if (vector.to1DArray) {\n vector = vector.to1DArray();\n }\n if (vector.length !== matrix.columns) {\n throw new RangeError(\n 'vector size must be the same as the number of columns',\n );\n }\n return vector;\n}\n\n/**\n * @private\n * Check that the provided vector is an array with the right length\n * @param {Matrix} matrix\n * @param {Array|Matrix} vector\n * @return {Array}\n * @throws {RangeError}\n */\nexport function checkColumnVector(matrix, vector) {\n if (vector.to1DArray) {\n vector = vector.to1DArray();\n }\n if (vector.length !== matrix.rows) {\n throw new RangeError('vector size must be the same as the number of rows');\n }\n return vector;\n}\n\nexport function checkIndices(matrix, rowIndices, columnIndices) {\n return {\n row: checkRowIndices(matrix, rowIndices),\n column: checkColumnIndices(matrix, columnIndices),\n };\n}\n\nexport function checkRowIndices(matrix, rowIndices) {\n if (typeof rowIndices !== 'object') {\n throw new TypeError('unexpected type for row indices');\n }\n\n let rowOut = rowIndices.some((r) => {\n return r < 0 || r >= matrix.rows;\n });\n\n if (rowOut) {\n throw new RangeError('row indices are out of range');\n }\n\n if (!Array.isArray(rowIndices)) rowIndices = Array.from(rowIndices);\n\n return rowIndices;\n}\n\nexport function checkColumnIndices(matrix, columnIndices) {\n if (typeof columnIndices !== 'object') {\n throw new TypeError('unexpected type for column indices');\n }\n\n let columnOut = columnIndices.some((c) => {\n return c < 0 || c >= matrix.columns;\n });\n\n if (columnOut) {\n throw new RangeError('column indices are out of range');\n }\n if (!Array.isArray(columnIndices)) columnIndices = Array.from(columnIndices);\n\n return columnIndices;\n}\n\nexport function checkRange(matrix, startRow, endRow, startColumn, endColumn) {\n if (arguments.length !== 5) {\n throw new RangeError('expected 4 arguments');\n }\n checkNumber('startRow', startRow);\n checkNumber('endRow', endRow);\n checkNumber('startColumn', startColumn);\n checkNumber('endColumn', endColumn);\n if (\n startRow > endRow ||\n startColumn > endColumn ||\n startRow < 0 ||\n startRow >= matrix.rows ||\n endRow < 0 ||\n endRow >= matrix.rows ||\n startColumn < 0 ||\n startColumn >= matrix.columns ||\n endColumn < 0 ||\n endColumn >= matrix.columns\n ) {\n throw new RangeError('Submatrix indices are out of range');\n }\n}\n\nexport function newArray(length, value = 0) {\n let array = [];\n for (let i = 0; i < length; i++) {\n array.push(value);\n }\n return array;\n}\n\nfunction checkNumber(name, value) {\n if (typeof value !== 'number') {\n throw new TypeError(`${name} must be a number`);\n }\n}\n","import { newArray } from './util';\n\nexport function sumByRow(matrix) {\n let sum = newArray(matrix.rows);\n for (let i = 0; i < matrix.rows; ++i) {\n for (let j = 0; j < matrix.columns; ++j) {\n sum[i] += matrix.get(i, j);\n }\n }\n return sum;\n}\n\nexport function sumByColumn(matrix) {\n let sum = newArray(matrix.columns);\n for (let i = 0; i < matrix.rows; ++i) {\n for (let j = 0; j < matrix.columns; ++j) {\n sum[j] += matrix.get(i, j);\n }\n }\n return sum;\n}\n\nexport function sumAll(matrix) {\n let v = 0;\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n v += matrix.get(i, j);\n }\n }\n return v;\n}\n\nexport function productByRow(matrix) {\n let sum = newArray(matrix.rows, 1);\n for (let i = 0; i < matrix.rows; ++i) {\n for (let j = 0; j < matrix.columns; ++j) {\n sum[i] *= matrix.get(i, j);\n }\n }\n return sum;\n}\n\nexport function productByColumn(matrix) {\n let sum = newArray(matrix.columns, 1);\n for (let i = 0; i < matrix.rows; ++i) {\n for (let j = 0; j < matrix.columns; ++j) {\n sum[j] *= matrix.get(i, j);\n }\n }\n return sum;\n}\n\nexport function productAll(matrix) {\n let v = 1;\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n v *= matrix.get(i, j);\n }\n }\n return v;\n}\n\nexport function varianceByRow(matrix, unbiased, mean) {\n const rows = matrix.rows;\n const cols = matrix.columns;\n const variance = [];\n\n for (let i = 0; i < rows; i++) {\n let sum1 = 0;\n let sum2 = 0;\n let x = 0;\n for (let j = 0; j < cols; j++) {\n x = matrix.get(i, j) - mean[i];\n sum1 += x;\n sum2 += x * x;\n }\n if (unbiased) {\n variance.push((sum2 - (sum1 * sum1) / cols) / (cols - 1));\n } else {\n variance.push((sum2 - (sum1 * sum1) / cols) / cols);\n }\n }\n return variance;\n}\n\nexport function varianceByColumn(matrix, unbiased, mean) {\n const rows = matrix.rows;\n const cols = matrix.columns;\n const variance = [];\n\n for (let j = 0; j < cols; j++) {\n let sum1 = 0;\n let sum2 = 0;\n let x = 0;\n for (let i = 0; i < rows; i++) {\n x = matrix.get(i, j) - mean[j];\n sum1 += x;\n sum2 += x * x;\n }\n if (unbiased) {\n variance.push((sum2 - (sum1 * sum1) / rows) / (rows - 1));\n } else {\n variance.push((sum2 - (sum1 * sum1) / rows) / rows);\n }\n }\n return variance;\n}\n\nexport function varianceAll(matrix, unbiased, mean) {\n const rows = matrix.rows;\n const cols = matrix.columns;\n const size = rows * cols;\n\n let sum1 = 0;\n let sum2 = 0;\n let x = 0;\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < cols; j++) {\n x = matrix.get(i, j) - mean;\n sum1 += x;\n sum2 += x * x;\n }\n }\n if (unbiased) {\n return (sum2 - (sum1 * sum1) / size) / (size - 1);\n } else {\n return (sum2 - (sum1 * sum1) / size) / size;\n }\n}\n\nexport function centerByRow(matrix, mean) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) - mean[i]);\n }\n }\n}\n\nexport function centerByColumn(matrix, mean) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) - mean[j]);\n }\n }\n}\n\nexport function centerAll(matrix, mean) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) - mean);\n }\n }\n}\n\nexport function getScaleByRow(matrix) {\n const scale = [];\n for (let i = 0; i < matrix.rows; i++) {\n let sum = 0;\n for (let j = 0; j < matrix.columns; j++) {\n sum += Math.pow(matrix.get(i, j), 2) / (matrix.columns - 1);\n }\n scale.push(Math.sqrt(sum));\n }\n return scale;\n}\n\nexport function scaleByRow(matrix, scale) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) / scale[i]);\n }\n }\n}\n\nexport function getScaleByColumn(matrix) {\n const scale = [];\n for (let j = 0; j < matrix.columns; j++) {\n let sum = 0;\n for (let i = 0; i < matrix.rows; i++) {\n sum += Math.pow(matrix.get(i, j), 2) / (matrix.rows - 1);\n }\n scale.push(Math.sqrt(sum));\n }\n return scale;\n}\n\nexport function scaleByColumn(matrix, scale) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) / scale[j]);\n }\n }\n}\n\nexport function getScaleAll(matrix) {\n const divider = matrix.size - 1;\n let sum = 0;\n for (let j = 0; j < matrix.columns; j++) {\n for (let i = 0; i < matrix.rows; i++) {\n sum += Math.pow(matrix.get(i, j), 2) / divider;\n }\n }\n return Math.sqrt(sum);\n}\n\nexport function scaleAll(matrix, scale) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) / scale);\n }\n }\n}\n","import rescale from 'ml-array-rescale';\n\nimport { inspectMatrix, inspectMatrixWithOptions } from './inspect';\nimport { installMathOperations } from './mathOperations';\nimport {\n sumByRow,\n sumByColumn,\n sumAll,\n productByRow,\n productByColumn,\n productAll,\n varianceByRow,\n varianceByColumn,\n varianceAll,\n centerByRow,\n centerByColumn,\n centerAll,\n scaleByRow,\n scaleByColumn,\n scaleAll,\n getScaleByRow,\n getScaleByColumn,\n getScaleAll,\n} from './stat';\nimport {\n checkRowVector,\n checkRowIndex,\n checkColumnIndex,\n checkColumnVector,\n checkRange,\n checkIndices,\n} from './util';\n\nexport class AbstractMatrix {\n static from1DArray(newRows, newColumns, newData) {\n let length = newRows * newColumns;\n if (length !== newData.length) {\n throw new RangeError('data length does not match given dimensions');\n }\n let newMatrix = new Matrix(newRows, newColumns);\n for (let row = 0; row < newRows; row++) {\n for (let column = 0; column < newColumns; column++) {\n newMatrix.set(row, column, newData[row * newColumns + column]);\n }\n }\n return newMatrix;\n }\n\n static rowVector(newData) {\n let vector = new Matrix(1, newData.length);\n for (let i = 0; i < newData.length; i++) {\n vector.set(0, i, newData[i]);\n }\n return vector;\n }\n\n static columnVector(newData) {\n let vector = new Matrix(newData.length, 1);\n for (let i = 0; i < newData.length; i++) {\n vector.set(i, 0, newData[i]);\n }\n return vector;\n }\n\n static zeros(rows, columns) {\n return new Matrix(rows, columns);\n }\n\n static ones(rows, columns) {\n return new Matrix(rows, columns).fill(1);\n }\n\n static rand(rows, columns, options = {}) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { random = Math.random } = options;\n let matrix = new Matrix(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n matrix.set(i, j, random());\n }\n }\n return matrix;\n }\n\n static randInt(rows, columns, options = {}) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { min = 0, max = 1000, random = Math.random } = options;\n if (!Number.isInteger(min)) throw new TypeError('min must be an integer');\n if (!Number.isInteger(max)) throw new TypeError('max must be an integer');\n if (min >= max) throw new RangeError('min must be smaller than max');\n let interval = max - min;\n let matrix = new Matrix(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n let value = min + Math.round(random() * interval);\n matrix.set(i, j, value);\n }\n }\n return matrix;\n }\n\n static eye(rows, columns, value) {\n if (columns === undefined) columns = rows;\n if (value === undefined) value = 1;\n let min = Math.min(rows, columns);\n let matrix = this.zeros(rows, columns);\n for (let i = 0; i < min; i++) {\n matrix.set(i, i, value);\n }\n return matrix;\n }\n\n static diag(data, rows, columns) {\n let l = data.length;\n if (rows === undefined) rows = l;\n if (columns === undefined) columns = rows;\n let min = Math.min(l, rows, columns);\n let matrix = this.zeros(rows, columns);\n for (let i = 0; i < min; i++) {\n matrix.set(i, i, data[i]);\n }\n return matrix;\n }\n\n static min(matrix1, matrix2) {\n matrix1 = this.checkMatrix(matrix1);\n matrix2 = this.checkMatrix(matrix2);\n let rows = matrix1.rows;\n let columns = matrix1.columns;\n let result = new Matrix(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n result.set(i, j, Math.min(matrix1.get(i, j), matrix2.get(i, j)));\n }\n }\n return result;\n }\n\n static max(matrix1, matrix2) {\n matrix1 = this.checkMatrix(matrix1);\n matrix2 = this.checkMatrix(matrix2);\n let rows = matrix1.rows;\n let columns = matrix1.columns;\n let result = new this(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n result.set(i, j, Math.max(matrix1.get(i, j), matrix2.get(i, j)));\n }\n }\n return result;\n }\n\n static checkMatrix(value) {\n return AbstractMatrix.isMatrix(value) ? value : new Matrix(value);\n }\n\n static isMatrix(value) {\n return value != null && value.klass === 'Matrix';\n }\n\n get size() {\n return this.rows * this.columns;\n }\n\n apply(callback) {\n if (typeof callback !== 'function') {\n throw new TypeError('callback must be a function');\n }\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n callback.call(this, i, j);\n }\n }\n return this;\n }\n\n to1DArray() {\n let array = [];\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n array.push(this.get(i, j));\n }\n }\n return array;\n }\n\n to2DArray() {\n let copy = [];\n for (let i = 0; i < this.rows; i++) {\n copy.push([]);\n for (let j = 0; j < this.columns; j++) {\n copy[i].push(this.get(i, j));\n }\n }\n return copy;\n }\n\n toJSON() {\n return this.to2DArray();\n }\n\n isRowVector() {\n return this.rows === 1;\n }\n\n isColumnVector() {\n return this.columns === 1;\n }\n\n isVector() {\n return this.rows === 1 || this.columns === 1;\n }\n\n isSquare() {\n return this.rows === this.columns;\n }\n\n isSymmetric() {\n if (this.isSquare()) {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j <= i; j++) {\n if (this.get(i, j) !== this.get(j, i)) {\n return false;\n }\n }\n }\n return true;\n }\n return false;\n }\n\n isEchelonForm() {\n let i = 0;\n let j = 0;\n let previousColumn = -1;\n let isEchelonForm = true;\n let checked = false;\n while (i < this.rows && isEchelonForm) {\n j = 0;\n checked = false;\n while (j < this.columns && checked === false) {\n if (this.get(i, j) === 0) {\n j++;\n } else if (this.get(i, j) === 1 && j > previousColumn) {\n checked = true;\n previousColumn = j;\n } else {\n isEchelonForm = false;\n checked = true;\n }\n }\n i++;\n }\n return isEchelonForm;\n }\n\n isReducedEchelonForm() {\n let i = 0;\n let j = 0;\n let previousColumn = -1;\n let isReducedEchelonForm = true;\n let checked = false;\n while (i < this.rows && isReducedEchelonForm) {\n j = 0;\n checked = false;\n while (j < this.columns && checked === false) {\n if (this.get(i, j) === 0) {\n j++;\n } else if (this.get(i, j) === 1 && j > previousColumn) {\n checked = true;\n previousColumn = j;\n } else {\n isReducedEchelonForm = false;\n checked = true;\n }\n }\n for (let k = j + 1; k < this.rows; k++) {\n if (this.get(i, k) !== 0) {\n isReducedEchelonForm = false;\n }\n }\n i++;\n }\n return isReducedEchelonForm;\n }\n\n echelonForm() {\n let result = this.clone();\n let h = 0;\n let k = 0;\n while (h < result.rows && k < result.columns) {\n let iMax = h;\n for (let i = h; i < result.rows; i++) {\n if (result.get(i, k) > result.get(iMax, k)) {\n iMax = i;\n }\n }\n if (result.get(iMax, k) === 0) {\n k++;\n } else {\n result.swapRows(h, iMax);\n let tmp = result.get(h, k);\n for (let j = k; j < result.columns; j++) {\n result.set(h, j, result.get(h, j) / tmp);\n }\n for (let i = h + 1; i < result.rows; i++) {\n let factor = result.get(i, k) / result.get(h, k);\n result.set(i, k, 0);\n for (let j = k + 1; j < result.columns; j++) {\n result.set(i, j, result.get(i, j) - result.get(h, j) * factor);\n }\n }\n h++;\n k++;\n }\n }\n return result;\n }\n\n reducedEchelonForm() {\n let result = this.echelonForm();\n let m = result.columns;\n let n = result.rows;\n let h = n - 1;\n while (h >= 0) {\n if (result.maxRow(h) === 0) {\n h--;\n } else {\n let p = 0;\n let pivot = false;\n while (p < n && pivot === false) {\n if (result.get(h, p) === 1) {\n pivot = true;\n } else {\n p++;\n }\n }\n for (let i = 0; i < h; i++) {\n let factor = result.get(i, p);\n for (let j = p; j < m; j++) {\n let tmp = result.get(i, j) - factor * result.get(h, j);\n result.set(i, j, tmp);\n }\n }\n h--;\n }\n }\n return result;\n }\n\n set() {\n throw new Error('set method is unimplemented');\n }\n\n get() {\n throw new Error('get method is unimplemented');\n }\n\n repeat(options = {}) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { rows = 1, columns = 1 } = options;\n if (!Number.isInteger(rows) || rows <= 0) {\n throw new TypeError('rows must be a positive integer');\n }\n if (!Number.isInteger(columns) || columns <= 0) {\n throw new TypeError('columns must be a positive integer');\n }\n let matrix = new Matrix(this.rows * rows, this.columns * columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n matrix.setSubMatrix(this, this.rows * i, this.columns * j);\n }\n }\n return matrix;\n }\n\n fill(value) {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, value);\n }\n }\n return this;\n }\n\n neg() {\n return this.mulS(-1);\n }\n\n getRow(index) {\n checkRowIndex(this, index);\n let row = [];\n for (let i = 0; i < this.columns; i++) {\n row.push(this.get(index, i));\n }\n return row;\n }\n\n getRowVector(index) {\n return Matrix.rowVector(this.getRow(index));\n }\n\n setRow(index, array) {\n checkRowIndex(this, index);\n array = checkRowVector(this, array);\n for (let i = 0; i < this.columns; i++) {\n this.set(index, i, array[i]);\n }\n return this;\n }\n\n swapRows(row1, row2) {\n checkRowIndex(this, row1);\n checkRowIndex(this, row2);\n for (let i = 0; i < this.columns; i++) {\n let temp = this.get(row1, i);\n this.set(row1, i, this.get(row2, i));\n this.set(row2, i, temp);\n }\n return this;\n }\n\n getColumn(index) {\n checkColumnIndex(this, index);\n let column = [];\n for (let i = 0; i < this.rows; i++) {\n column.push(this.get(i, index));\n }\n return column;\n }\n\n getColumnVector(index) {\n return Matrix.columnVector(this.getColumn(index));\n }\n\n setColumn(index, array) {\n checkColumnIndex(this, index);\n array = checkColumnVector(this, array);\n for (let i = 0; i < this.rows; i++) {\n this.set(i, index, array[i]);\n }\n return this;\n }\n\n swapColumns(column1, column2) {\n checkColumnIndex(this, column1);\n checkColumnIndex(this, column2);\n for (let i = 0; i < this.rows; i++) {\n let temp = this.get(i, column1);\n this.set(i, column1, this.get(i, column2));\n this.set(i, column2, temp);\n }\n return this;\n }\n\n addRowVector(vector) {\n vector = checkRowVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) + vector[j]);\n }\n }\n return this;\n }\n\n subRowVector(vector) {\n vector = checkRowVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) - vector[j]);\n }\n }\n return this;\n }\n\n mulRowVector(vector) {\n vector = checkRowVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) * vector[j]);\n }\n }\n return this;\n }\n\n divRowVector(vector) {\n vector = checkRowVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) / vector[j]);\n }\n }\n return this;\n }\n\n addColumnVector(vector) {\n vector = checkColumnVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) + vector[i]);\n }\n }\n return this;\n }\n\n subColumnVector(vector) {\n vector = checkColumnVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) - vector[i]);\n }\n }\n return this;\n }\n\n mulColumnVector(vector) {\n vector = checkColumnVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) * vector[i]);\n }\n }\n return this;\n }\n\n divColumnVector(vector) {\n vector = checkColumnVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) / vector[i]);\n }\n }\n return this;\n }\n\n mulRow(index, value) {\n checkRowIndex(this, index);\n for (let i = 0; i < this.columns; i++) {\n this.set(index, i, this.get(index, i) * value);\n }\n return this;\n }\n\n mulColumn(index, value) {\n checkColumnIndex(this, index);\n for (let i = 0; i < this.rows; i++) {\n this.set(i, index, this.get(i, index) * value);\n }\n return this;\n }\n\n max() {\n let v = this.get(0, 0);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n if (this.get(i, j) > v) {\n v = this.get(i, j);\n }\n }\n }\n return v;\n }\n\n maxIndex() {\n let v = this.get(0, 0);\n let idx = [0, 0];\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n if (this.get(i, j) > v) {\n v = this.get(i, j);\n idx[0] = i;\n idx[1] = j;\n }\n }\n }\n return idx;\n }\n\n min() {\n let v = this.get(0, 0);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n if (this.get(i, j) < v) {\n v = this.get(i, j);\n }\n }\n }\n return v;\n }\n\n minIndex() {\n let v = this.get(0, 0);\n let idx = [0, 0];\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n if (this.get(i, j) < v) {\n v = this.get(i, j);\n idx[0] = i;\n idx[1] = j;\n }\n }\n }\n return idx;\n }\n\n maxRow(row) {\n checkRowIndex(this, row);\n let v = this.get(row, 0);\n for (let i = 1; i < this.columns; i++) {\n if (this.get(row, i) > v) {\n v = this.get(row, i);\n }\n }\n return v;\n }\n\n maxRowIndex(row) {\n checkRowIndex(this, row);\n let v = this.get(row, 0);\n let idx = [row, 0];\n for (let i = 1; i < this.columns; i++) {\n if (this.get(row, i) > v) {\n v = this.get(row, i);\n idx[1] = i;\n }\n }\n return idx;\n }\n\n minRow(row) {\n checkRowIndex(this, row);\n let v = this.get(row, 0);\n for (let i = 1; i < this.columns; i++) {\n if (this.get(row, i) < v) {\n v = this.get(row, i);\n }\n }\n return v;\n }\n\n minRowIndex(row) {\n checkRowIndex(this, row);\n let v = this.get(row, 0);\n let idx = [row, 0];\n for (let i = 1; i < this.columns; i++) {\n if (this.get(row, i) < v) {\n v = this.get(row, i);\n idx[1] = i;\n }\n }\n return idx;\n }\n\n maxColumn(column) {\n checkColumnIndex(this, column);\n let v = this.get(0, column);\n for (let i = 1; i < this.rows; i++) {\n if (this.get(i, column) > v) {\n v = this.get(i, column);\n }\n }\n return v;\n }\n\n maxColumnIndex(column) {\n checkColumnIndex(this, column);\n let v = this.get(0, column);\n let idx = [0, column];\n for (let i = 1; i < this.rows; i++) {\n if (this.get(i, column) > v) {\n v = this.get(i, column);\n idx[0] = i;\n }\n }\n return idx;\n }\n\n minColumn(column) {\n checkColumnIndex(this, column);\n let v = this.get(0, column);\n for (let i = 1; i < this.rows; i++) {\n if (this.get(i, column) < v) {\n v = this.get(i, column);\n }\n }\n return v;\n }\n\n minColumnIndex(column) {\n checkColumnIndex(this, column);\n let v = this.get(0, column);\n let idx = [0, column];\n for (let i = 1; i < this.rows; i++) {\n if (this.get(i, column) < v) {\n v = this.get(i, column);\n idx[0] = i;\n }\n }\n return idx;\n }\n\n diag() {\n let min = Math.min(this.rows, this.columns);\n let diag = [];\n for (let i = 0; i < min; i++) {\n diag.push(this.get(i, i));\n }\n return diag;\n }\n\n norm(type = 'frobenius') {\n let result = 0;\n if (type === 'max') {\n return this.max();\n } else if (type === 'frobenius') {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n result = result + this.get(i, j) * this.get(i, j);\n }\n }\n return Math.sqrt(result);\n } else {\n throw new RangeError(`unknown norm type: ${type}`);\n }\n }\n\n cumulativeSum() {\n let sum = 0;\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n sum += this.get(i, j);\n this.set(i, j, sum);\n }\n }\n return this;\n }\n\n dot(vector2) {\n if (AbstractMatrix.isMatrix(vector2)) vector2 = vector2.to1DArray();\n let vector1 = this.to1DArray();\n if (vector1.length !== vector2.length) {\n throw new RangeError('vectors do not have the same size');\n }\n let dot = 0;\n for (let i = 0; i < vector1.length; i++) {\n dot += vector1[i] * vector2[i];\n }\n return dot;\n }\n\n mmul(other) {\n other = Matrix.checkMatrix(other);\n\n let m = this.rows;\n let n = this.columns;\n let p = other.columns;\n\n let result = new Matrix(m, p);\n\n let Bcolj = new Float64Array(n);\n for (let j = 0; j < p; j++) {\n for (let k = 0; k < n; k++) {\n Bcolj[k] = other.get(k, j);\n }\n\n for (let i = 0; i < m; i++) {\n let s = 0;\n for (let k = 0; k < n; k++) {\n s += this.get(i, k) * Bcolj[k];\n }\n\n result.set(i, j, s);\n }\n }\n return result;\n }\n\n strassen2x2(other) {\n other = Matrix.checkMatrix(other);\n let result = new Matrix(2, 2);\n const a11 = this.get(0, 0);\n const b11 = other.get(0, 0);\n const a12 = this.get(0, 1);\n const b12 = other.get(0, 1);\n const a21 = this.get(1, 0);\n const b21 = other.get(1, 0);\n const a22 = this.get(1, 1);\n const b22 = other.get(1, 1);\n\n // Compute intermediate values.\n const m1 = (a11 + a22) * (b11 + b22);\n const m2 = (a21 + a22) * b11;\n const m3 = a11 * (b12 - b22);\n const m4 = a22 * (b21 - b11);\n const m5 = (a11 + a12) * b22;\n const m6 = (a21 - a11) * (b11 + b12);\n const m7 = (a12 - a22) * (b21 + b22);\n\n // Combine intermediate values into the output.\n const c00 = m1 + m4 - m5 + m7;\n const c01 = m3 + m5;\n const c10 = m2 + m4;\n const c11 = m1 - m2 + m3 + m6;\n\n result.set(0, 0, c00);\n result.set(0, 1, c01);\n result.set(1, 0, c10);\n result.set(1, 1, c11);\n return result;\n }\n\n strassen3x3(other) {\n other = Matrix.checkMatrix(other);\n let result = new Matrix(3, 3);\n\n const a00 = this.get(0, 0);\n const a01 = this.get(0, 1);\n const a02 = this.get(0, 2);\n const a10 = this.get(1, 0);\n const a11 = this.get(1, 1);\n const a12 = this.get(1, 2);\n const a20 = this.get(2, 0);\n const a21 = this.get(2, 1);\n const a22 = this.get(2, 2);\n\n const b00 = other.get(0, 0);\n const b01 = other.get(0, 1);\n const b02 = other.get(0, 2);\n const b10 = other.get(1, 0);\n const b11 = other.get(1, 1);\n const b12 = other.get(1, 2);\n const b20 = other.get(2, 0);\n const b21 = other.get(2, 1);\n const b22 = other.get(2, 2);\n\n const m1 = (a00 + a01 + a02 - a10 - a11 - a21 - a22) * b11;\n const m2 = (a00 - a10) * (-b01 + b11);\n const m3 = a11 * (-b00 + b01 + b10 - b11 - b12 - b20 + b22);\n const m4 = (-a00 + a10 + a11) * (b00 - b01 + b11);\n const m5 = (a10 + a11) * (-b00 + b01);\n const m6 = a00 * b00;\n const m7 = (-a00 + a20 + a21) * (b00 - b02 + b12);\n const m8 = (-a00 + a20) * (b02 - b12);\n const m9 = (a20 + a21) * (-b00 + b02);\n const m10 = (a00 + a01 + a02 - a11 - a12 - a20 - a21) * b12;\n const m11 = a21 * (-b00 + b02 + b10 - b11 - b12 - b20 + b21);\n const m12 = (-a02 + a21 + a22) * (b11 + b20 - b21);\n const m13 = (a02 - a22) * (b11 - b21);\n const m14 = a02 * b20;\n const m15 = (a21 + a22) * (-b20 + b21);\n const m16 = (-a02 + a11 + a12) * (b12 + b20 - b22);\n const m17 = (a02 - a12) * (b12 - b22);\n const m18 = (a11 + a12) * (-b20 + b22);\n const m19 = a01 * b10;\n const m20 = a12 * b21;\n const m21 = a10 * b02;\n const m22 = a20 * b01;\n const m23 = a22 * b22;\n\n const c00 = m6 + m14 + m19;\n const c01 = m1 + m4 + m5 + m6 + m12 + m14 + m15;\n const c02 = m6 + m7 + m9 + m10 + m14 + m16 + m18;\n const c10 = m2 + m3 + m4 + m6 + m14 + m16 + m17;\n const c11 = m2 + m4 + m5 + m6 + m20;\n const c12 = m14 + m16 + m17 + m18 + m21;\n const c20 = m6 + m7 + m8 + m11 + m12 + m13 + m14;\n const c21 = m12 + m13 + m14 + m15 + m22;\n const c22 = m6 + m7 + m8 + m9 + m23;\n\n result.set(0, 0, c00);\n result.set(0, 1, c01);\n result.set(0, 2, c02);\n result.set(1, 0, c10);\n result.set(1, 1, c11);\n result.set(1, 2, c12);\n result.set(2, 0, c20);\n result.set(2, 1, c21);\n result.set(2, 2, c22);\n return result;\n }\n\n mmulStrassen(y) {\n y = Matrix.checkMatrix(y);\n let x = this.clone();\n let r1 = x.rows;\n let c1 = x.columns;\n let r2 = y.rows;\n let c2 = y.columns;\n if (c1 !== r2) {\n // eslint-disable-next-line no-console\n console.warn(\n `Multiplying ${r1} x ${c1} and ${r2} x ${c2} matrix: dimensions do not match.`,\n );\n }\n\n // Put a matrix into the top left of a matrix of zeros.\n // `rows` and `cols` are the dimensions of the output matrix.\n function embed(mat, rows, cols) {\n let r = mat.rows;\n let c = mat.columns;\n if (r === rows && c === cols) {\n return mat;\n } else {\n let resultat = AbstractMatrix.zeros(rows, cols);\n resultat = resultat.setSubMatrix(mat, 0, 0);\n return resultat;\n }\n }\n\n // Make sure both matrices are the same size.\n // This is exclusively for simplicity:\n // this algorithm can be implemented with matrices of different sizes.\n\n let r = Math.max(r1, r2);\n let c = Math.max(c1, c2);\n x = embed(x, r, c);\n y = embed(y, r, c);\n\n // Our recursive multiplication function.\n function blockMult(a, b, rows, cols) {\n // For small matrices, resort to naive multiplication.\n if (rows <= 512 || cols <= 512) {\n return a.mmul(b); // a is equivalent to this\n }\n\n // Apply dynamic padding.\n if (rows % 2 === 1 && cols % 2 === 1) {\n a = embed(a, rows + 1, cols + 1);\n b = embed(b, rows + 1, cols + 1);\n } else if (rows % 2 === 1) {\n a = embed(a, rows + 1, cols);\n b = embed(b, rows + 1, cols);\n } else if (cols % 2 === 1) {\n a = embed(a, rows, cols + 1);\n b = embed(b, rows, cols + 1);\n }\n\n let halfRows = parseInt(a.rows / 2, 10);\n let halfCols = parseInt(a.columns / 2, 10);\n // Subdivide input matrices.\n let a11 = a.subMatrix(0, halfRows - 1, 0, halfCols - 1);\n let b11 = b.subMatrix(0, halfRows - 1, 0, halfCols - 1);\n\n let a12 = a.subMatrix(0, halfRows - 1, halfCols, a.columns - 1);\n let b12 = b.subMatrix(0, halfRows - 1, halfCols, b.columns - 1);\n\n let a21 = a.subMatrix(halfRows, a.rows - 1, 0, halfCols - 1);\n let b21 = b.subMatrix(halfRows, b.rows - 1, 0, halfCols - 1);\n\n let a22 = a.subMatrix(halfRows, a.rows - 1, halfCols, a.columns - 1);\n let b22 = b.subMatrix(halfRows, b.rows - 1, halfCols, b.columns - 1);\n\n // Compute intermediate values.\n let m1 = blockMult(\n AbstractMatrix.add(a11, a22),\n AbstractMatrix.add(b11, b22),\n halfRows,\n halfCols,\n );\n let m2 = blockMult(AbstractMatrix.add(a21, a22), b11, halfRows, halfCols);\n let m3 = blockMult(a11, AbstractMatrix.sub(b12, b22), halfRows, halfCols);\n let m4 = blockMult(a22, AbstractMatrix.sub(b21, b11), halfRows, halfCols);\n let m5 = blockMult(AbstractMatrix.add(a11, a12), b22, halfRows, halfCols);\n let m6 = blockMult(\n AbstractMatrix.sub(a21, a11),\n AbstractMatrix.add(b11, b12),\n halfRows,\n halfCols,\n );\n let m7 = blockMult(\n AbstractMatrix.sub(a12, a22),\n AbstractMatrix.add(b21, b22),\n halfRows,\n halfCols,\n );\n\n // Combine intermediate values into the output.\n let c11 = AbstractMatrix.add(m1, m4);\n c11.sub(m5);\n c11.add(m7);\n let c12 = AbstractMatrix.add(m3, m5);\n let c21 = AbstractMatrix.add(m2, m4);\n let c22 = AbstractMatrix.sub(m1, m2);\n c22.add(m3);\n c22.add(m6);\n\n // Crop output to the desired size (undo dynamic padding).\n let resultat = AbstractMatrix.zeros(2 * c11.rows, 2 * c11.columns);\n resultat = resultat.setSubMatrix(c11, 0, 0);\n resultat = resultat.setSubMatrix(c12, c11.rows, 0);\n resultat = resultat.setSubMatrix(c21, 0, c11.columns);\n resultat = resultat.setSubMatrix(c22, c11.rows, c11.columns);\n return resultat.subMatrix(0, rows - 1, 0, cols - 1);\n }\n return blockMult(x, y, r, c);\n }\n\n scaleRows(options = {}) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { min = 0, max = 1 } = options;\n if (!Number.isFinite(min)) throw new TypeError('min must be a number');\n if (!Number.isFinite(max)) throw new TypeError('max must be a number');\n if (min >= max) throw new RangeError('min must be smaller than max');\n let newMatrix = new Matrix(this.rows, this.columns);\n for (let i = 0; i < this.rows; i++) {\n const row = this.getRow(i);\n rescale(row, { min, max, output: row });\n newMatrix.setRow(i, row);\n }\n return newMatrix;\n }\n\n scaleColumns(options = {}) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { min = 0, max = 1 } = options;\n if (!Number.isFinite(min)) throw new TypeError('min must be a number');\n if (!Number.isFinite(max)) throw new TypeError('max must be a number');\n if (min >= max) throw new RangeError('min must be smaller than max');\n let newMatrix = new Matrix(this.rows, this.columns);\n for (let i = 0; i < this.columns; i++) {\n const column = this.getColumn(i);\n rescale(column, {\n min: min,\n max: max,\n output: column,\n });\n newMatrix.setColumn(i, column);\n }\n return newMatrix;\n }\n\n flipRows() {\n const middle = Math.ceil(this.columns / 2);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < middle; j++) {\n let first = this.get(i, j);\n let last = this.get(i, this.columns - 1 - j);\n this.set(i, j, last);\n this.set(i, this.columns - 1 - j, first);\n }\n }\n return this;\n }\n\n flipColumns() {\n const middle = Math.ceil(this.rows / 2);\n for (let j = 0; j < this.columns; j++) {\n for (let i = 0; i < middle; i++) {\n let first = this.get(i, j);\n let last = this.get(this.rows - 1 - i, j);\n this.set(i, j, last);\n this.set(this.rows - 1 - i, j, first);\n }\n }\n return this;\n }\n\n kroneckerProduct(other) {\n other = Matrix.checkMatrix(other);\n\n let m = this.rows;\n let n = this.columns;\n let p = other.rows;\n let q = other.columns;\n\n let result = new Matrix(m * p, n * q);\n for (let i = 0; i < m; i++) {\n for (let j = 0; j < n; j++) {\n for (let k = 0; k < p; k++) {\n for (let l = 0; l < q; l++) {\n result.set(p * i + k, q * j + l, this.get(i, j) * other.get(k, l));\n }\n }\n }\n }\n return result;\n }\n\n transpose() {\n let result = new Matrix(this.columns, this.rows);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n result.set(j, i, this.get(i, j));\n }\n }\n return result;\n }\n\n sortRows(compareFunction = compareNumbers) {\n for (let i = 0; i < this.rows; i++) {\n this.setRow(i, this.getRow(i).sort(compareFunction));\n }\n return this;\n }\n\n sortColumns(compareFunction = compareNumbers) {\n for (let i = 0; i < this.columns; i++) {\n this.setColumn(i, this.getColumn(i).sort(compareFunction));\n }\n return this;\n }\n\n subMatrix(startRow, endRow, startColumn, endColumn) {\n checkRange(this, startRow, endRow, startColumn, endColumn);\n let newMatrix = new Matrix(\n endRow - startRow + 1,\n endColumn - startColumn + 1,\n );\n for (let i = startRow; i <= endRow; i++) {\n for (let j = startColumn; j <= endColumn; j++) {\n newMatrix.set(i - startRow, j - startColumn, this.get(i, j));\n }\n }\n return newMatrix;\n }\n\n subMatrixRow(indices, startColumn, endColumn) {\n if (startColumn === undefined) startColumn = 0;\n if (endColumn === undefined) endColumn = this.columns - 1;\n if (\n startColumn > endColumn ||\n startColumn < 0 ||\n startColumn >= this.columns ||\n endColumn < 0 ||\n endColumn >= this.columns\n ) {\n throw new RangeError('Argument out of range');\n }\n\n let newMatrix = new Matrix(indices.length, endColumn - startColumn + 1);\n for (let i = 0; i < indices.length; i++) {\n for (let j = startColumn; j <= endColumn; j++) {\n if (indices[i] < 0 || indices[i] >= this.rows) {\n throw new RangeError(`Row index out of range: ${indices[i]}`);\n }\n newMatrix.set(i, j - startColumn, this.get(indices[i], j));\n }\n }\n return newMatrix;\n }\n\n subMatrixColumn(indices, startRow, endRow) {\n if (startRow === undefined) startRow = 0;\n if (endRow === undefined) endRow = this.rows - 1;\n if (\n startRow > endRow ||\n startRow < 0 ||\n startRow >= this.rows ||\n endRow < 0 ||\n endRow >= this.rows\n ) {\n throw new RangeError('Argument out of range');\n }\n\n let newMatrix = new Matrix(endRow - startRow + 1, indices.length);\n for (let i = 0; i < indices.length; i++) {\n for (let j = startRow; j <= endRow; j++) {\n if (indices[i] < 0 || indices[i] >= this.columns) {\n throw new RangeError(`Column index out of range: ${indices[i]}`);\n }\n newMatrix.set(j - startRow, i, this.get(j, indices[i]));\n }\n }\n return newMatrix;\n }\n\n setSubMatrix(matrix, startRow, startColumn) {\n matrix = Matrix.checkMatrix(matrix);\n let endRow = startRow + matrix.rows - 1;\n let endColumn = startColumn + matrix.columns - 1;\n checkRange(this, startRow, endRow, startColumn, endColumn);\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n this.set(startRow + i, startColumn + j, matrix.get(i, j));\n }\n }\n return this;\n }\n\n selection(rowIndices, columnIndices) {\n let indices = checkIndices(this, rowIndices, columnIndices);\n let newMatrix = new Matrix(rowIndices.length, columnIndices.length);\n for (let i = 0; i < indices.row.length; i++) {\n let rowIndex = indices.row[i];\n for (let j = 0; j < indices.column.length; j++) {\n let columnIndex = indices.column[j];\n newMatrix.set(i, j, this.get(rowIndex, columnIndex));\n }\n }\n return newMatrix;\n }\n\n trace() {\n let min = Math.min(this.rows, this.columns);\n let trace = 0;\n for (let i = 0; i < min; i++) {\n trace += this.get(i, i);\n }\n return trace;\n }\n\n clone() {\n let newMatrix = new Matrix(this.rows, this.columns);\n for (let row = 0; row < this.rows; row++) {\n for (let column = 0; column < this.columns; column++) {\n newMatrix.set(row, column, this.get(row, column));\n }\n }\n return newMatrix;\n }\n\n sum(by) {\n switch (by) {\n case 'row':\n return sumByRow(this);\n case 'column':\n return sumByColumn(this);\n case undefined:\n return sumAll(this);\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n product(by) {\n switch (by) {\n case 'row':\n return productByRow(this);\n case 'column':\n return productByColumn(this);\n case undefined:\n return productAll(this);\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n mean(by) {\n const sum = this.sum(by);\n switch (by) {\n case 'row': {\n for (let i = 0; i < this.rows; i++) {\n sum[i] /= this.columns;\n }\n return sum;\n }\n case 'column': {\n for (let i = 0; i < this.columns; i++) {\n sum[i] /= this.rows;\n }\n return sum;\n }\n case undefined:\n return sum / this.size;\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n variance(by, options = {}) {\n if (typeof by === 'object') {\n options = by;\n by = undefined;\n }\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { unbiased = true, mean = this.mean(by) } = options;\n if (typeof unbiased !== 'boolean') {\n throw new TypeError('unbiased must be a boolean');\n }\n switch (by) {\n case 'row': {\n if (!Array.isArray(mean)) {\n throw new TypeError('mean must be an array');\n }\n return varianceByRow(this, unbiased, mean);\n }\n case 'column': {\n if (!Array.isArray(mean)) {\n throw new TypeError('mean must be an array');\n }\n return varianceByColumn(this, unbiased, mean);\n }\n case undefined: {\n if (typeof mean !== 'number') {\n throw new TypeError('mean must be a number');\n }\n return varianceAll(this, unbiased, mean);\n }\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n standardDeviation(by, options) {\n if (typeof by === 'object') {\n options = by;\n by = undefined;\n }\n const variance = this.variance(by, options);\n if (by === undefined) {\n return Math.sqrt(variance);\n } else {\n for (let i = 0; i < variance.length; i++) {\n variance[i] = Math.sqrt(variance[i]);\n }\n return variance;\n }\n }\n\n center(by, options = {}) {\n if (typeof by === 'object') {\n options = by;\n by = undefined;\n }\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { center = this.mean(by) } = options;\n switch (by) {\n case 'row': {\n if (!Array.isArray(center)) {\n throw new TypeError('center must be an array');\n }\n centerByRow(this, center);\n return this;\n }\n case 'column': {\n if (!Array.isArray(center)) {\n throw new TypeError('center must be an array');\n }\n centerByColumn(this, center);\n return this;\n }\n case undefined: {\n if (typeof center !== 'number') {\n throw new TypeError('center must be a number');\n }\n centerAll(this, center);\n return this;\n }\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n scale(by, options = {}) {\n if (typeof by === 'object') {\n options = by;\n by = undefined;\n }\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n let scale = options.scale;\n switch (by) {\n case 'row': {\n if (scale === undefined) {\n scale = getScaleByRow(this);\n } else if (!Array.isArray(scale)) {\n throw new TypeError('scale must be an array');\n }\n scaleByRow(this, scale);\n return this;\n }\n case 'column': {\n if (scale === undefined) {\n scale = getScaleByColumn(this);\n } else if (!Array.isArray(scale)) {\n throw new TypeError('scale must be an array');\n }\n scaleByColumn(this, scale);\n return this;\n }\n case undefined: {\n if (scale === undefined) {\n scale = getScaleAll(this);\n } else if (typeof scale !== 'number') {\n throw new TypeError('scale must be a number');\n }\n scaleAll(this, scale);\n return this;\n }\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n toString(options) {\n return inspectMatrixWithOptions(this, options);\n }\n}\n\nAbstractMatrix.prototype.klass = 'Matrix';\nif (typeof Symbol !== 'undefined') {\n AbstractMatrix.prototype[\n Symbol.for('nodejs.util.inspect.custom')\n ] = inspectMatrix;\n}\n\nfunction compareNumbers(a, b) {\n return a - b;\n}\n\n// Synonyms\nAbstractMatrix.random = AbstractMatrix.rand;\nAbstractMatrix.randomInt = AbstractMatrix.randInt;\nAbstractMatrix.diagonal = AbstractMatrix.diag;\nAbstractMatrix.prototype.diagonal = AbstractMatrix.prototype.diag;\nAbstractMatrix.identity = AbstractMatrix.eye;\nAbstractMatrix.prototype.negate = AbstractMatrix.prototype.neg;\nAbstractMatrix.prototype.tensorProduct =\n AbstractMatrix.prototype.kroneckerProduct;\n\nexport default class Matrix extends AbstractMatrix {\n constructor(nRows, nColumns) {\n super();\n if (Matrix.isMatrix(nRows)) {\n return nRows.clone();\n } else if (Number.isInteger(nRows) && nRows > 0) {\n // Create an empty matrix\n this.data = [];\n if (Number.isInteger(nColumns) && nColumns > 0) {\n for (let i = 0; i < nRows; i++) {\n this.data.push(new Float64Array(nColumns));\n }\n } else {\n throw new TypeError('nColumns must be a positive integer');\n }\n } else if (Array.isArray(nRows)) {\n // Copy the values from the 2D array\n const arrayData = nRows;\n nRows = arrayData.length;\n nColumns = arrayData[0].length;\n if (typeof nColumns !== 'number' || nColumns === 0) {\n throw new TypeError(\n 'Data must be a 2D array with at least one element',\n );\n }\n this.data = [];\n for (let i = 0; i < nRows; i++) {\n if (arrayData[i].length !== nColumns) {\n throw new RangeError('Inconsistent array dimensions');\n }\n this.data.push(Float64Array.from(arrayData[i]));\n }\n } else {\n throw new TypeError(\n 'First argument must be a positive number or an array',\n );\n }\n this.rows = nRows;\n this.columns = nColumns;\n return this;\n }\n\n set(rowIndex, columnIndex, value) {\n this.data[rowIndex][columnIndex] = value;\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.data[rowIndex][columnIndex];\n }\n\n removeRow(index) {\n checkRowIndex(this, index);\n if (this.rows === 1) {\n throw new RangeError('A matrix cannot have less than one row');\n }\n this.data.splice(index, 1);\n this.rows -= 1;\n return this;\n }\n\n addRow(index, array) {\n if (array === undefined) {\n array = index;\n index = this.rows;\n }\n checkRowIndex(this, index, true);\n array = Float64Array.from(checkRowVector(this, array, true));\n this.data.splice(index, 0, array);\n this.rows += 1;\n return this;\n }\n\n removeColumn(index) {\n checkColumnIndex(this, index);\n if (this.columns === 1) {\n throw new RangeError('A matrix cannot have less than one column');\n }\n for (let i = 0; i < this.rows; i++) {\n const newRow = new Float64Array(this.columns - 1);\n for (let j = 0; j < index; j++) {\n newRow[j] = this.data[i][j];\n }\n for (let j = index + 1; j < this.columns; j++) {\n newRow[j - 1] = this.data[i][j];\n }\n this.data[i] = newRow;\n }\n this.columns -= 1;\n return this;\n }\n\n addColumn(index, array) {\n if (typeof array === 'undefined') {\n array = index;\n index = this.columns;\n }\n checkColumnIndex(this, index, true);\n array = checkColumnVector(this, array);\n for (let i = 0; i < this.rows; i++) {\n const newRow = new Float64Array(this.columns + 1);\n let j = 0;\n for (; j < index; j++) {\n newRow[j] = this.data[i][j];\n }\n newRow[j++] = array[i];\n for (; j < this.columns + 1; j++) {\n newRow[j] = this.data[i][j - 1];\n }\n this.data[i] = newRow;\n }\n this.columns += 1;\n return this;\n }\n}\n\ninstallMathOperations(AbstractMatrix, Matrix);\n","import { AbstractMatrix } from '../matrix';\n\nexport default class BaseView extends AbstractMatrix {\n constructor(matrix, rows, columns) {\n super();\n this.matrix = matrix;\n this.rows = rows;\n this.columns = columns;\n }\n}\n","import { checkColumnIndex } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixColumnView extends BaseView {\n constructor(matrix, column) {\n checkColumnIndex(matrix, column);\n super(matrix, matrix.rows, 1);\n this.column = column;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(rowIndex, this.column, value);\n return this;\n }\n\n get(rowIndex) {\n return this.matrix.get(rowIndex, this.column);\n }\n}\n","import { checkColumnIndices } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixColumnSelectionView extends BaseView {\n constructor(matrix, columnIndices) {\n columnIndices = checkColumnIndices(matrix, columnIndices);\n super(matrix, matrix.rows, columnIndices.length);\n this.columnIndices = columnIndices;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(rowIndex, this.columnIndices[columnIndex], value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(rowIndex, this.columnIndices[columnIndex]);\n }\n}\n","import BaseView from './base';\n\nexport default class MatrixFlipColumnView extends BaseView {\n constructor(matrix) {\n super(matrix, matrix.rows, matrix.columns);\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(rowIndex, this.columns - columnIndex - 1, value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(rowIndex, this.columns - columnIndex - 1);\n }\n}\n","import BaseView from './base';\n\nexport default class MatrixFlipRowView extends BaseView {\n constructor(matrix) {\n super(matrix, matrix.rows, matrix.columns);\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(this.rows - rowIndex - 1, columnIndex, value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(this.rows - rowIndex - 1, columnIndex);\n }\n}\n","import { checkRowIndex } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixRowView extends BaseView {\n constructor(matrix, row) {\n checkRowIndex(matrix, row);\n super(matrix, 1, matrix.columns);\n this.row = row;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(this.row, columnIndex, value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(this.row, columnIndex);\n }\n}\n","import { checkRowIndices } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixRowSelectionView extends BaseView {\n constructor(matrix, rowIndices) {\n rowIndices = checkRowIndices(matrix, rowIndices);\n super(matrix, rowIndices.length, matrix.columns);\n this.rowIndices = rowIndices;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(this.rowIndices[rowIndex], columnIndex, value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(this.rowIndices[rowIndex], columnIndex);\n }\n}\n","import { checkIndices } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixSelectionView extends BaseView {\n constructor(matrix, rowIndices, columnIndices) {\n let indices = checkIndices(matrix, rowIndices, columnIndices);\n super(matrix, indices.row.length, indices.column.length);\n this.rowIndices = indices.row;\n this.columnIndices = indices.column;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(\n this.rowIndices[rowIndex],\n this.columnIndices[columnIndex],\n value,\n );\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(\n this.rowIndices[rowIndex],\n this.columnIndices[columnIndex],\n );\n }\n}\n","import { checkRange } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixSubView extends BaseView {\n constructor(matrix, startRow, endRow, startColumn, endColumn) {\n checkRange(matrix, startRow, endRow, startColumn, endColumn);\n super(matrix, endRow - startRow + 1, endColumn - startColumn + 1);\n this.startRow = startRow;\n this.startColumn = startColumn;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(\n this.startRow + rowIndex,\n this.startColumn + columnIndex,\n value,\n );\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(\n this.startRow + rowIndex,\n this.startColumn + columnIndex,\n );\n }\n}\n","import BaseView from './base';\n\nexport default class MatrixTransposeView extends BaseView {\n constructor(matrix) {\n super(matrix, matrix.columns, matrix.rows);\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(columnIndex, rowIndex, value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(columnIndex, rowIndex);\n }\n}\n","import { AbstractMatrix } from '../matrix';\n\nexport default class WrapperMatrix1D extends AbstractMatrix {\n constructor(data, options = {}) {\n const { rows = 1 } = options;\n\n if (data.length % rows !== 0) {\n throw new Error('the data length is not divisible by the number of rows');\n }\n super();\n this.rows = rows;\n this.columns = data.length / rows;\n this.data = data;\n }\n\n set(rowIndex, columnIndex, value) {\n let index = this._calculateIndex(rowIndex, columnIndex);\n this.data[index] = value;\n return this;\n }\n\n get(rowIndex, columnIndex) {\n let index = this._calculateIndex(rowIndex, columnIndex);\n return this.data[index];\n }\n\n _calculateIndex(row, column) {\n return row * this.columns + column;\n }\n}\n","import { AbstractMatrix } from '../matrix';\n\nexport default class WrapperMatrix2D extends AbstractMatrix {\n constructor(data) {\n super();\n this.data = data;\n this.rows = data.length;\n this.columns = data[0].length;\n }\n\n set(rowIndex, columnIndex, value) {\n this.data[rowIndex][columnIndex] = value;\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.data[rowIndex][columnIndex];\n }\n}\n","import WrapperMatrix1D from './WrapperMatrix1D';\nimport WrapperMatrix2D from './WrapperMatrix2D';\n\nexport function wrap(array, options) {\n if (Array.isArray(array)) {\n if (array[0] && Array.isArray(array[0])) {\n return new WrapperMatrix2D(array);\n } else {\n return new WrapperMatrix1D(array, options);\n }\n } else {\n throw new Error('the argument is not an array');\n }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nexport default class LuDecomposition {\n constructor(matrix) {\n matrix = WrapperMatrix2D.checkMatrix(matrix);\n\n let lu = matrix.clone();\n let rows = lu.rows;\n let columns = lu.columns;\n let pivotVector = new Float64Array(rows);\n let pivotSign = 1;\n let i, j, k, p, s, t, v;\n let LUcolj, kmax;\n\n for (i = 0; i < rows; i++) {\n pivotVector[i] = i;\n }\n\n LUcolj = new Float64Array(rows);\n\n for (j = 0; j < columns; j++) {\n for (i = 0; i < rows; i++) {\n LUcolj[i] = lu.get(i, j);\n }\n\n for (i = 0; i < rows; i++) {\n kmax = Math.min(i, j);\n s = 0;\n for (k = 0; k < kmax; k++) {\n s += lu.get(i, k) * LUcolj[k];\n }\n LUcolj[i] -= s;\n lu.set(i, j, LUcolj[i]);\n }\n\n p = j;\n for (i = j + 1; i < rows; i++) {\n if (Math.abs(LUcolj[i]) > Math.abs(LUcolj[p])) {\n p = i;\n }\n }\n\n if (p !== j) {\n for (k = 0; k < columns; k++) {\n t = lu.get(p, k);\n lu.set(p, k, lu.get(j, k));\n lu.set(j, k, t);\n }\n\n v = pivotVector[p];\n pivotVector[p] = pivotVector[j];\n pivotVector[j] = v;\n\n pivotSign = -pivotSign;\n }\n\n if (j < rows && lu.get(j, j) !== 0) {\n for (i = j + 1; i < rows; i++) {\n lu.set(i, j, lu.get(i, j) / lu.get(j, j));\n }\n }\n }\n\n this.LU = lu;\n this.pivotVector = pivotVector;\n this.pivotSign = pivotSign;\n }\n\n isSingular() {\n let data = this.LU;\n let col = data.columns;\n for (let j = 0; j < col; j++) {\n if (data.get(j, j) === 0) {\n return true;\n }\n }\n return false;\n }\n\n solve(value) {\n value = Matrix.checkMatrix(value);\n\n let lu = this.LU;\n let rows = lu.rows;\n\n if (rows !== value.rows) {\n throw new Error('Invalid matrix dimensions');\n }\n if (this.isSingular()) {\n throw new Error('LU matrix is singular');\n }\n\n let count = value.columns;\n let X = value.subMatrixRow(this.pivotVector, 0, count - 1);\n let columns = lu.columns;\n let i, j, k;\n\n for (k = 0; k < columns; k++) {\n for (i = k + 1; i < columns; i++) {\n for (j = 0; j < count; j++) {\n X.set(i, j, X.get(i, j) - X.get(k, j) * lu.get(i, k));\n }\n }\n }\n for (k = columns - 1; k >= 0; k--) {\n for (j = 0; j < count; j++) {\n X.set(k, j, X.get(k, j) / lu.get(k, k));\n }\n for (i = 0; i < k; i++) {\n for (j = 0; j < count; j++) {\n X.set(i, j, X.get(i, j) - X.get(k, j) * lu.get(i, k));\n }\n }\n }\n return X;\n }\n\n get determinant() {\n let data = this.LU;\n if (!data.isSquare()) {\n throw new Error('Matrix must be square');\n }\n let determinant = this.pivotSign;\n let col = data.columns;\n for (let j = 0; j < col; j++) {\n determinant *= data.get(j, j);\n }\n return determinant;\n }\n\n get lowerTriangularMatrix() {\n let data = this.LU;\n let rows = data.rows;\n let columns = data.columns;\n let X = new Matrix(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n if (i > j) {\n X.set(i, j, data.get(i, j));\n } else if (i === j) {\n X.set(i, j, 1);\n } else {\n X.set(i, j, 0);\n }\n }\n }\n return X;\n }\n\n get upperTriangularMatrix() {\n let data = this.LU;\n let rows = data.rows;\n let columns = data.columns;\n let X = new Matrix(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n if (i <= j) {\n X.set(i, j, data.get(i, j));\n } else {\n X.set(i, j, 0);\n }\n }\n }\n return X;\n }\n\n get pivotPermutationVector() {\n return Array.from(this.pivotVector);\n }\n}\n","export function hypotenuse(a, b) {\n let r = 0;\n if (Math.abs(a) > Math.abs(b)) {\n r = b / a;\n return Math.abs(a) * Math.sqrt(1 + r * r);\n }\n if (b !== 0) {\n r = a / b;\n return Math.abs(b) * Math.sqrt(1 + r * r);\n }\n return 0;\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nimport { hypotenuse } from './util';\n\nexport default class QrDecomposition {\n constructor(value) {\n value = WrapperMatrix2D.checkMatrix(value);\n\n let qr = value.clone();\n let m = value.rows;\n let n = value.columns;\n let rdiag = new Float64Array(n);\n let i, j, k, s;\n\n for (k = 0; k < n; k++) {\n let nrm = 0;\n for (i = k; i < m; i++) {\n nrm = hypotenuse(nrm, qr.get(i, k));\n }\n if (nrm !== 0) {\n if (qr.get(k, k) < 0) {\n nrm = -nrm;\n }\n for (i = k; i < m; i++) {\n qr.set(i, k, qr.get(i, k) / nrm);\n }\n qr.set(k, k, qr.get(k, k) + 1);\n for (j = k + 1; j < n; j++) {\n s = 0;\n for (i = k; i < m; i++) {\n s += qr.get(i, k) * qr.get(i, j);\n }\n s = -s / qr.get(k, k);\n for (i = k; i < m; i++) {\n qr.set(i, j, qr.get(i, j) + s * qr.get(i, k));\n }\n }\n }\n rdiag[k] = -nrm;\n }\n\n this.QR = qr;\n this.Rdiag = rdiag;\n }\n\n solve(value) {\n value = Matrix.checkMatrix(value);\n\n let qr = this.QR;\n let m = qr.rows;\n\n if (value.rows !== m) {\n throw new Error('Matrix row dimensions must agree');\n }\n if (!this.isFullRank()) {\n throw new Error('Matrix is rank deficient');\n }\n\n let count = value.columns;\n let X = value.clone();\n let n = qr.columns;\n let i, j, k, s;\n\n for (k = 0; k < n; k++) {\n for (j = 0; j < count; j++) {\n s = 0;\n for (i = k; i < m; i++) {\n s += qr.get(i, k) * X.get(i, j);\n }\n s = -s / qr.get(k, k);\n for (i = k; i < m; i++) {\n X.set(i, j, X.get(i, j) + s * qr.get(i, k));\n }\n }\n }\n for (k = n - 1; k >= 0; k--) {\n for (j = 0; j < count; j++) {\n X.set(k, j, X.get(k, j) / this.Rdiag[k]);\n }\n for (i = 0; i < k; i++) {\n for (j = 0; j < count; j++) {\n X.set(i, j, X.get(i, j) - X.get(k, j) * qr.get(i, k));\n }\n }\n }\n\n return X.subMatrix(0, n - 1, 0, count - 1);\n }\n\n isFullRank() {\n let columns = this.QR.columns;\n for (let i = 0; i < columns; i++) {\n if (this.Rdiag[i] === 0) {\n return false;\n }\n }\n return true;\n }\n\n get upperTriangularMatrix() {\n let qr = this.QR;\n let n = qr.columns;\n let X = new Matrix(n, n);\n let i, j;\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n if (i < j) {\n X.set(i, j, qr.get(i, j));\n } else if (i === j) {\n X.set(i, j, this.Rdiag[i]);\n } else {\n X.set(i, j, 0);\n }\n }\n }\n return X;\n }\n\n get orthogonalMatrix() {\n let qr = this.QR;\n let rows = qr.rows;\n let columns = qr.columns;\n let X = new Matrix(rows, columns);\n let i, j, k, s;\n\n for (k = columns - 1; k >= 0; k--) {\n for (i = 0; i < rows; i++) {\n X.set(i, k, 0);\n }\n X.set(k, k, 1);\n for (j = k; j < columns; j++) {\n if (qr.get(k, k) !== 0) {\n s = 0;\n for (i = k; i < rows; i++) {\n s += qr.get(i, k) * X.get(i, j);\n }\n\n s = -s / qr.get(k, k);\n\n for (i = k; i < rows; i++) {\n X.set(i, j, X.get(i, j) + s * qr.get(i, k));\n }\n }\n }\n }\n return X;\n }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nimport { hypotenuse } from './util';\n\nexport default class SingularValueDecomposition {\n constructor(value, options = {}) {\n value = WrapperMatrix2D.checkMatrix(value);\n\n let m = value.rows;\n let n = value.columns;\n\n const {\n computeLeftSingularVectors = true,\n computeRightSingularVectors = true,\n autoTranspose = false,\n } = options;\n\n let wantu = Boolean(computeLeftSingularVectors);\n let wantv = Boolean(computeRightSingularVectors);\n\n let swapped = false;\n let a;\n if (m < n) {\n if (!autoTranspose) {\n a = value.clone();\n // eslint-disable-next-line no-console\n console.warn(\n 'Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose',\n );\n } else {\n a = value.transpose();\n m = a.rows;\n n = a.columns;\n swapped = true;\n let aux = wantu;\n wantu = wantv;\n wantv = aux;\n }\n } else {\n a = value.clone();\n }\n\n let nu = Math.min(m, n);\n let ni = Math.min(m + 1, n);\n let s = new Float64Array(ni);\n let U = new Matrix(m, nu);\n let V = new Matrix(n, n);\n\n let e = new Float64Array(n);\n let work = new Float64Array(m);\n\n let si = new Float64Array(ni);\n for (let i = 0; i < ni; i++) si[i] = i;\n\n let nct = Math.min(m - 1, n);\n let nrt = Math.max(0, Math.min(n - 2, m));\n let mrc = Math.max(nct, nrt);\n\n for (let k = 0; k < mrc; k++) {\n if (k < nct) {\n s[k] = 0;\n for (let i = k; i < m; i++) {\n s[k] = hypotenuse(s[k], a.get(i, k));\n }\n if (s[k] !== 0) {\n if (a.get(k, k) < 0) {\n s[k] = -s[k];\n }\n for (let i = k; i < m; i++) {\n a.set(i, k, a.get(i, k) / s[k]);\n }\n a.set(k, k, a.get(k, k) + 1);\n }\n s[k] = -s[k];\n }\n\n for (let j = k + 1; j < n; j++) {\n if (k < nct && s[k] !== 0) {\n let t = 0;\n for (let i = k; i < m; i++) {\n t += a.get(i, k) * a.get(i, j);\n }\n t = -t / a.get(k, k);\n for (let i = k; i < m; i++) {\n a.set(i, j, a.get(i, j) + t * a.get(i, k));\n }\n }\n e[j] = a.get(k, j);\n }\n\n if (wantu && k < nct) {\n for (let i = k; i < m; i++) {\n U.set(i, k, a.get(i, k));\n }\n }\n\n if (k < nrt) {\n e[k] = 0;\n for (let i = k + 1; i < n; i++) {\n e[k] = hypotenuse(e[k], e[i]);\n }\n if (e[k] !== 0) {\n if (e[k + 1] < 0) {\n e[k] = 0 - e[k];\n }\n for (let i = k + 1; i < n; i++) {\n e[i] /= e[k];\n }\n e[k + 1] += 1;\n }\n e[k] = -e[k];\n if (k + 1 < m && e[k] !== 0) {\n for (let i = k + 1; i < m; i++) {\n work[i] = 0;\n }\n for (let i = k + 1; i < m; i++) {\n for (let j = k + 1; j < n; j++) {\n work[i] += e[j] * a.get(i, j);\n }\n }\n for (let j = k + 1; j < n; j++) {\n let t = -e[j] / e[k + 1];\n for (let i = k + 1; i < m; i++) {\n a.set(i, j, a.get(i, j) + t * work[i]);\n }\n }\n }\n if (wantv) {\n for (let i = k + 1; i < n; i++) {\n V.set(i, k, e[i]);\n }\n }\n }\n }\n\n let p = Math.min(n, m + 1);\n if (nct < n) {\n s[nct] = a.get(nct, nct);\n }\n if (m < p) {\n s[p - 1] = 0;\n }\n if (nrt + 1 < p) {\n e[nrt] = a.get(nrt, p - 1);\n }\n e[p - 1] = 0;\n\n if (wantu) {\n for (let j = nct; j < nu; j++) {\n for (let i = 0; i < m; i++) {\n U.set(i, j, 0);\n }\n U.set(j, j, 1);\n }\n for (let k = nct - 1; k >= 0; k--) {\n if (s[k] !== 0) {\n for (let j = k + 1; j < nu; j++) {\n let t = 0;\n for (let i = k; i < m; i++) {\n t += U.get(i, k) * U.get(i, j);\n }\n t = -t / U.get(k, k);\n for (let i = k; i < m; i++) {\n U.set(i, j, U.get(i, j) + t * U.get(i, k));\n }\n }\n for (let i = k; i < m; i++) {\n U.set(i, k, -U.get(i, k));\n }\n U.set(k, k, 1 + U.get(k, k));\n for (let i = 0; i < k - 1; i++) {\n U.set(i, k, 0);\n }\n } else {\n for (let i = 0; i < m; i++) {\n U.set(i, k, 0);\n }\n U.set(k, k, 1);\n }\n }\n }\n\n if (wantv) {\n for (let k = n - 1; k >= 0; k--) {\n if (k < nrt && e[k] !== 0) {\n for (let j = k + 1; j < n; j++) {\n let t = 0;\n for (let i = k + 1; i < n; i++) {\n t += V.get(i, k) * V.get(i, j);\n }\n t = -t / V.get(k + 1, k);\n for (let i = k + 1; i < n; i++) {\n V.set(i, j, V.get(i, j) + t * V.get(i, k));\n }\n }\n }\n for (let i = 0; i < n; i++) {\n V.set(i, k, 0);\n }\n V.set(k, k, 1);\n }\n }\n\n let pp = p - 1;\n let iter = 0;\n let eps = Number.EPSILON;\n while (p > 0) {\n let k, kase;\n for (k = p - 2; k >= -1; k--) {\n if (k === -1) {\n break;\n }\n const alpha =\n Number.MIN_VALUE + eps * Math.abs(s[k] + Math.abs(s[k + 1]));\n if (Math.abs(e[k]) <= alpha || Number.isNaN(e[k])) {\n e[k] = 0;\n break;\n }\n }\n if (k === p - 2) {\n kase = 4;\n } else {\n let ks;\n for (ks = p - 1; ks >= k; ks--) {\n if (ks === k) {\n break;\n }\n let t =\n (ks !== p ? Math.abs(e[ks]) : 0) +\n (ks !== k + 1 ? Math.abs(e[ks - 1]) : 0);\n if (Math.abs(s[ks]) <= eps * t) {\n s[ks] = 0;\n break;\n }\n }\n if (ks === k) {\n kase = 3;\n } else if (ks === p - 1) {\n kase = 1;\n } else {\n kase = 2;\n k = ks;\n }\n }\n\n k++;\n\n switch (kase) {\n case 1: {\n let f = e[p - 2];\n e[p - 2] = 0;\n for (let j = p - 2; j >= k; j--) {\n let t = hypotenuse(s[j], f);\n let cs = s[j] / t;\n let sn = f / t;\n s[j] = t;\n if (j !== k) {\n f = -sn * e[j - 1];\n e[j - 1] = cs * e[j - 1];\n }\n if (wantv) {\n for (let i = 0; i < n; i++) {\n t = cs * V.get(i, j) + sn * V.get(i, p - 1);\n V.set(i, p - 1, -sn * V.get(i, j) + cs * V.get(i, p - 1));\n V.set(i, j, t);\n }\n }\n }\n break;\n }\n case 2: {\n let f = e[k - 1];\n e[k - 1] = 0;\n for (let j = k; j < p; j++) {\n let t = hypotenuse(s[j], f);\n let cs = s[j] / t;\n let sn = f / t;\n s[j] = t;\n f = -sn * e[j];\n e[j] = cs * e[j];\n if (wantu) {\n for (let i = 0; i < m; i++) {\n t = cs * U.get(i, j) + sn * U.get(i, k - 1);\n U.set(i, k - 1, -sn * U.get(i, j) + cs * U.get(i, k - 1));\n U.set(i, j, t);\n }\n }\n }\n break;\n }\n case 3: {\n const scale = Math.max(\n Math.abs(s[p - 1]),\n Math.abs(s[p - 2]),\n Math.abs(e[p - 2]),\n Math.abs(s[k]),\n Math.abs(e[k]),\n );\n const sp = s[p - 1] / scale;\n const spm1 = s[p - 2] / scale;\n const epm1 = e[p - 2] / scale;\n const sk = s[k] / scale;\n const ek = e[k] / scale;\n const b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2;\n const c = sp * epm1 * (sp * epm1);\n let shift = 0;\n if (b !== 0 || c !== 0) {\n if (b < 0) {\n shift = 0 - Math.sqrt(b * b + c);\n } else {\n shift = Math.sqrt(b * b + c);\n }\n shift = c / (b + shift);\n }\n let f = (sk + sp) * (sk - sp) + shift;\n let g = sk * ek;\n for (let j = k; j < p - 1; j++) {\n let t = hypotenuse(f, g);\n if (t === 0) t = Number.MIN_VALUE;\n let cs = f / t;\n let sn = g / t;\n if (j !== k) {\n e[j - 1] = t;\n }\n f = cs * s[j] + sn * e[j];\n e[j] = cs * e[j] - sn * s[j];\n g = sn * s[j + 1];\n s[j + 1] = cs * s[j + 1];\n if (wantv) {\n for (let i = 0; i < n; i++) {\n t = cs * V.get(i, j) + sn * V.get(i, j + 1);\n V.set(i, j + 1, -sn * V.get(i, j) + cs * V.get(i, j + 1));\n V.set(i, j, t);\n }\n }\n t = hypotenuse(f, g);\n if (t === 0) t = Number.MIN_VALUE;\n cs = f / t;\n sn = g / t;\n s[j] = t;\n f = cs * e[j] + sn * s[j + 1];\n s[j + 1] = -sn * e[j] + cs * s[j + 1];\n g = sn * e[j + 1];\n e[j + 1] = cs * e[j + 1];\n if (wantu && j < m - 1) {\n for (let i = 0; i < m; i++) {\n t = cs * U.get(i, j) + sn * U.get(i, j + 1);\n U.set(i, j + 1, -sn * U.get(i, j) + cs * U.get(i, j + 1));\n U.set(i, j, t);\n }\n }\n }\n e[p - 2] = f;\n iter = iter + 1;\n break;\n }\n case 4: {\n if (s[k] <= 0) {\n s[k] = s[k] < 0 ? -s[k] : 0;\n if (wantv) {\n for (let i = 0; i <= pp; i++) {\n V.set(i, k, -V.get(i, k));\n }\n }\n }\n while (k < pp) {\n if (s[k] >= s[k + 1]) {\n break;\n }\n let t = s[k];\n s[k] = s[k + 1];\n s[k + 1] = t;\n if (wantv && k < n - 1) {\n for (let i = 0; i < n; i++) {\n t = V.get(i, k + 1);\n V.set(i, k + 1, V.get(i, k));\n V.set(i, k, t);\n }\n }\n if (wantu && k < m - 1) {\n for (let i = 0; i < m; i++) {\n t = U.get(i, k + 1);\n U.set(i, k + 1, U.get(i, k));\n U.set(i, k, t);\n }\n }\n k++;\n }\n iter = 0;\n p--;\n break;\n }\n // no default\n }\n }\n\n if (swapped) {\n let tmp = V;\n V = U;\n U = tmp;\n }\n\n this.m = m;\n this.n = n;\n this.s = s;\n this.U = U;\n this.V = V;\n }\n\n solve(value) {\n let Y = value;\n let e = this.threshold;\n let scols = this.s.length;\n let Ls = Matrix.zeros(scols, scols);\n\n for (let i = 0; i < scols; i++) {\n if (Math.abs(this.s[i]) <= e) {\n Ls.set(i, i, 0);\n } else {\n Ls.set(i, i, 1 / this.s[i]);\n }\n }\n\n let U = this.U;\n let V = this.rightSingularVectors;\n\n let VL = V.mmul(Ls);\n let vrows = V.rows;\n let urows = U.rows;\n let VLU = Matrix.zeros(vrows, urows);\n\n for (let i = 0; i < vrows; i++) {\n for (let j = 0; j < urows; j++) {\n let sum = 0;\n for (let k = 0; k < scols; k++) {\n sum += VL.get(i, k) * U.get(j, k);\n }\n VLU.set(i, j, sum);\n }\n }\n\n return VLU.mmul(Y);\n }\n\n solveForDiagonal(value) {\n return this.solve(Matrix.diag(value));\n }\n\n inverse() {\n let V = this.V;\n let e = this.threshold;\n let vrows = V.rows;\n let vcols = V.columns;\n let X = new Matrix(vrows, this.s.length);\n\n for (let i = 0; i < vrows; i++) {\n for (let j = 0; j < vcols; j++) {\n if (Math.abs(this.s[j]) > e) {\n X.set(i, j, V.get(i, j) / this.s[j]);\n }\n }\n }\n\n let U = this.U;\n\n let urows = U.rows;\n let ucols = U.columns;\n let Y = new Matrix(vrows, urows);\n\n for (let i = 0; i < vrows; i++) {\n for (let j = 0; j < urows; j++) {\n let sum = 0;\n for (let k = 0; k < ucols; k++) {\n sum += X.get(i, k) * U.get(j, k);\n }\n Y.set(i, j, sum);\n }\n }\n\n return Y;\n }\n\n get condition() {\n return this.s[0] / this.s[Math.min(this.m, this.n) - 1];\n }\n\n get norm2() {\n return this.s[0];\n }\n\n get rank() {\n let tol = Math.max(this.m, this.n) * this.s[0] * Number.EPSILON;\n let r = 0;\n let s = this.s;\n for (let i = 0, ii = s.length; i < ii; i++) {\n if (s[i] > tol) {\n r++;\n }\n }\n return r;\n }\n\n get diagonal() {\n return Array.from(this.s);\n }\n\n get threshold() {\n return (Number.EPSILON / 2) * Math.max(this.m, this.n) * this.s[0];\n }\n\n get leftSingularVectors() {\n return this.U;\n }\n\n get rightSingularVectors() {\n return this.V;\n }\n\n get diagonalMatrix() {\n return Matrix.diag(this.s);\n }\n}\n","import LuDecomposition from './dc/lu';\nimport QrDecomposition from './dc/qr';\nimport SingularValueDecomposition from './dc/svd';\nimport Matrix from './matrix';\nimport WrapperMatrix2D from './wrap/WrapperMatrix2D';\n\nexport function inverse(matrix, useSVD = false) {\n matrix = WrapperMatrix2D.checkMatrix(matrix);\n if (useSVD) {\n return new SingularValueDecomposition(matrix).inverse();\n } else {\n return solve(matrix, Matrix.eye(matrix.rows));\n }\n}\n\nexport function solve(leftHandSide, rightHandSide, useSVD = false) {\n leftHandSide = WrapperMatrix2D.checkMatrix(leftHandSide);\n rightHandSide = WrapperMatrix2D.checkMatrix(rightHandSide);\n if (useSVD) {\n return new SingularValueDecomposition(leftHandSide).solve(rightHandSide);\n } else {\n return leftHandSide.isSquare()\n ? new LuDecomposition(leftHandSide).solve(rightHandSide)\n : new QrDecomposition(leftHandSide).solve(rightHandSide);\n }\n}\n","import LuDecomposition from './dc/lu';\nimport Matrix from './matrix';\nimport MatrixSelectionView from './views/selection';\n\nexport function determinant(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (matrix.isSquare()) {\n let a, b, c, d;\n if (matrix.columns === 2) {\n // 2 x 2 matrix\n a = matrix.get(0, 0);\n b = matrix.get(0, 1);\n c = matrix.get(1, 0);\n d = matrix.get(1, 1);\n\n return a * d - b * c;\n } else if (matrix.columns === 3) {\n // 3 x 3 matrix\n let subMatrix0, subMatrix1, subMatrix2;\n subMatrix0 = new MatrixSelectionView(matrix, [1, 2], [1, 2]);\n subMatrix1 = new MatrixSelectionView(matrix, [1, 2], [0, 2]);\n subMatrix2 = new MatrixSelectionView(matrix, [1, 2], [0, 1]);\n a = matrix.get(0, 0);\n b = matrix.get(0, 1);\n c = matrix.get(0, 2);\n\n return (\n a * determinant(subMatrix0) -\n b * determinant(subMatrix1) +\n c * determinant(subMatrix2)\n );\n } else {\n // general purpose determinant using the LU decomposition\n return new LuDecomposition(matrix).determinant;\n }\n } else {\n throw Error('determinant can only be calculated for a square matrix');\n }\n}\n","import SingularValueDecomposition from './dc/svd';\nimport Matrix from './matrix';\n\nfunction xrange(n, exception) {\n let range = [];\n for (let i = 0; i < n; i++) {\n if (i !== exception) {\n range.push(i);\n }\n }\n return range;\n}\n\nfunction dependenciesOneRow(\n error,\n matrix,\n index,\n thresholdValue = 10e-10,\n thresholdError = 10e-10,\n) {\n if (error > thresholdError) {\n return new Array(matrix.rows + 1).fill(0);\n } else {\n let returnArray = matrix.addRow(index, [0]);\n for (let i = 0; i < returnArray.rows; i++) {\n if (Math.abs(returnArray.get(i, 0)) < thresholdValue) {\n returnArray.set(i, 0, 0);\n }\n }\n return returnArray.to1DArray();\n }\n}\n\nexport function linearDependencies(matrix, options = {}) {\n const { thresholdValue = 10e-10, thresholdError = 10e-10 } = options;\n matrix = Matrix.checkMatrix(matrix);\n\n let n = matrix.rows;\n let results = new Matrix(n, n);\n\n for (let i = 0; i < n; i++) {\n let b = Matrix.columnVector(matrix.getRow(i));\n let Abis = matrix.subMatrixRow(xrange(n, i)).transpose();\n let svd = new SingularValueDecomposition(Abis);\n let x = svd.solve(b);\n let error = Matrix.sub(b, Abis.mmul(x)).abs().max();\n results.setRow(\n i,\n dependenciesOneRow(error, x, i, thresholdValue, thresholdError),\n );\n }\n return results;\n}\n","import SVD from './dc/svd';\nimport Matrix from './matrix';\n\nexport function pseudoInverse(matrix, threshold = Number.EPSILON) {\n matrix = Matrix.checkMatrix(matrix);\n let svdSolution = new SVD(matrix, { autoTranspose: true });\n\n let U = svdSolution.leftSingularVectors;\n let V = svdSolution.rightSingularVectors;\n let s = svdSolution.diagonal;\n\n for (let i = 0; i < s.length; i++) {\n if (Math.abs(s[i]) > threshold) {\n s[i] = 1.0 / s[i];\n } else {\n s[i] = 0.0;\n }\n }\n\n return V.mmul(Matrix.diag(s).mmul(U.transpose()));\n}\n","import Matrix from './matrix';\n\nexport function covariance(xMatrix, yMatrix = xMatrix, options = {}) {\n xMatrix = new Matrix(xMatrix);\n let yIsSame = false;\n if (\n typeof yMatrix === 'object' &&\n !Matrix.isMatrix(yMatrix) &&\n !Array.isArray(yMatrix)\n ) {\n options = yMatrix;\n yMatrix = xMatrix;\n yIsSame = true;\n } else {\n yMatrix = new Matrix(yMatrix);\n }\n if (xMatrix.rows !== yMatrix.rows) {\n throw new TypeError('Both matrices must have the same number of rows');\n }\n const { center = true } = options;\n if (center) {\n xMatrix = xMatrix.center('column');\n if (!yIsSame) {\n yMatrix = yMatrix.center('column');\n }\n }\n const cov = xMatrix.transpose().mmul(yMatrix);\n for (let i = 0; i < cov.rows; i++) {\n for (let j = 0; j < cov.columns; j++) {\n cov.set(i, j, cov.get(i, j) * (1 / (xMatrix.rows - 1)));\n }\n }\n return cov;\n}\n","import Matrix from './matrix';\n\nexport function correlation(xMatrix, yMatrix = xMatrix, options = {}) {\n xMatrix = new Matrix(xMatrix);\n let yIsSame = false;\n if (\n typeof yMatrix === 'object' &&\n !Matrix.isMatrix(yMatrix) &&\n !Array.isArray(yMatrix)\n ) {\n options = yMatrix;\n yMatrix = xMatrix;\n yIsSame = true;\n } else {\n yMatrix = new Matrix(yMatrix);\n }\n if (xMatrix.rows !== yMatrix.rows) {\n throw new TypeError('Both matrices must have the same number of rows');\n }\n\n const { center = true, scale = true } = options;\n if (center) {\n xMatrix.center('column');\n if (!yIsSame) {\n yMatrix.center('column');\n }\n }\n if (scale) {\n xMatrix.scale('column');\n if (!yIsSame) {\n yMatrix.scale('column');\n }\n }\n\n const sdx = xMatrix.standardDeviation('column', { unbiased: true });\n const sdy = yIsSame\n ? sdx\n : yMatrix.standardDeviation('column', { unbiased: true });\n\n const corr = xMatrix.transpose().mmul(yMatrix);\n for (let i = 0; i < corr.rows; i++) {\n for (let j = 0; j < corr.columns; j++) {\n corr.set(\n i,\n j,\n corr.get(i, j) * (1 / (sdx[i] * sdy[j])) * (1 / (xMatrix.rows - 1)),\n );\n }\n }\n return corr;\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nimport { hypotenuse } from './util';\n\nexport default class EigenvalueDecomposition {\n constructor(matrix, options = {}) {\n const { assumeSymmetric = false } = options;\n\n matrix = WrapperMatrix2D.checkMatrix(matrix);\n if (!matrix.isSquare()) {\n throw new Error('Matrix is not a square matrix');\n }\n\n let n = matrix.columns;\n let V = new Matrix(n, n);\n let d = new Float64Array(n);\n let e = new Float64Array(n);\n let value = matrix;\n let i, j;\n\n let isSymmetric = false;\n if (assumeSymmetric) {\n isSymmetric = true;\n } else {\n isSymmetric = matrix.isSymmetric();\n }\n\n if (isSymmetric) {\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n V.set(i, j, value.get(i, j));\n }\n }\n tred2(n, e, d, V);\n tql2(n, e, d, V);\n } else {\n let H = new Matrix(n, n);\n let ort = new Float64Array(n);\n for (j = 0; j < n; j++) {\n for (i = 0; i < n; i++) {\n H.set(i, j, value.get(i, j));\n }\n }\n orthes(n, H, ort, V);\n hqr2(n, e, d, V, H);\n }\n\n this.n = n;\n this.e = e;\n this.d = d;\n this.V = V;\n }\n\n get realEigenvalues() {\n return Array.from(this.d);\n }\n\n get imaginaryEigenvalues() {\n return Array.from(this.e);\n }\n\n get eigenvectorMatrix() {\n return this.V;\n }\n\n get diagonalMatrix() {\n let n = this.n;\n let e = this.e;\n let d = this.d;\n let X = new Matrix(n, n);\n let i, j;\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n X.set(i, j, 0);\n }\n X.set(i, i, d[i]);\n if (e[i] > 0) {\n X.set(i, i + 1, e[i]);\n } else if (e[i] < 0) {\n X.set(i, i - 1, e[i]);\n }\n }\n return X;\n }\n}\n\nfunction tred2(n, e, d, V) {\n let f, g, h, i, j, k, hh, scale;\n\n for (j = 0; j < n; j++) {\n d[j] = V.get(n - 1, j);\n }\n\n for (i = n - 1; i > 0; i--) {\n scale = 0;\n h = 0;\n for (k = 0; k < i; k++) {\n scale = scale + Math.abs(d[k]);\n }\n\n if (scale === 0) {\n e[i] = d[i - 1];\n for (j = 0; j < i; j++) {\n d[j] = V.get(i - 1, j);\n V.set(i, j, 0);\n V.set(j, i, 0);\n }\n } else {\n for (k = 0; k < i; k++) {\n d[k] /= scale;\n h += d[k] * d[k];\n }\n\n f = d[i - 1];\n g = Math.sqrt(h);\n if (f > 0) {\n g = -g;\n }\n\n e[i] = scale * g;\n h = h - f * g;\n d[i - 1] = f - g;\n for (j = 0; j < i; j++) {\n e[j] = 0;\n }\n\n for (j = 0; j < i; j++) {\n f = d[j];\n V.set(j, i, f);\n g = e[j] + V.get(j, j) * f;\n for (k = j + 1; k <= i - 1; k++) {\n g += V.get(k, j) * d[k];\n e[k] += V.get(k, j) * f;\n }\n e[j] = g;\n }\n\n f = 0;\n for (j = 0; j < i; j++) {\n e[j] /= h;\n f += e[j] * d[j];\n }\n\n hh = f / (h + h);\n for (j = 0; j < i; j++) {\n e[j] -= hh * d[j];\n }\n\n for (j = 0; j < i; j++) {\n f = d[j];\n g = e[j];\n for (k = j; k <= i - 1; k++) {\n V.set(k, j, V.get(k, j) - (f * e[k] + g * d[k]));\n }\n d[j] = V.get(i - 1, j);\n V.set(i, j, 0);\n }\n }\n d[i] = h;\n }\n\n for (i = 0; i < n - 1; i++) {\n V.set(n - 1, i, V.get(i, i));\n V.set(i, i, 1);\n h = d[i + 1];\n if (h !== 0) {\n for (k = 0; k <= i; k++) {\n d[k] = V.get(k, i + 1) / h;\n }\n\n for (j = 0; j <= i; j++) {\n g = 0;\n for (k = 0; k <= i; k++) {\n g += V.get(k, i + 1) * V.get(k, j);\n }\n for (k = 0; k <= i; k++) {\n V.set(k, j, V.get(k, j) - g * d[k]);\n }\n }\n }\n\n for (k = 0; k <= i; k++) {\n V.set(k, i + 1, 0);\n }\n }\n\n for (j = 0; j < n; j++) {\n d[j] = V.get(n - 1, j);\n V.set(n - 1, j, 0);\n }\n\n V.set(n - 1, n - 1, 1);\n e[0] = 0;\n}\n\nfunction tql2(n, e, d, V) {\n let g, h, i, j, k, l, m, p, r, dl1, c, c2, c3, el1, s, s2, iter;\n\n for (i = 1; i < n; i++) {\n e[i - 1] = e[i];\n }\n\n e[n - 1] = 0;\n\n let f = 0;\n let tst1 = 0;\n let eps = Number.EPSILON;\n\n for (l = 0; l < n; l++) {\n tst1 = Math.max(tst1, Math.abs(d[l]) + Math.abs(e[l]));\n m = l;\n while (m < n) {\n if (Math.abs(e[m]) <= eps * tst1) {\n break;\n }\n m++;\n }\n\n if (m > l) {\n iter = 0;\n do {\n iter = iter + 1;\n\n g = d[l];\n p = (d[l + 1] - g) / (2 * e[l]);\n r = hypotenuse(p, 1);\n if (p < 0) {\n r = -r;\n }\n\n d[l] = e[l] / (p + r);\n d[l + 1] = e[l] * (p + r);\n dl1 = d[l + 1];\n h = g - d[l];\n for (i = l + 2; i < n; i++) {\n d[i] -= h;\n }\n\n f = f + h;\n\n p = d[m];\n c = 1;\n c2 = c;\n c3 = c;\n el1 = e[l + 1];\n s = 0;\n s2 = 0;\n for (i = m - 1; i >= l; i--) {\n c3 = c2;\n c2 = c;\n s2 = s;\n g = c * e[i];\n h = c * p;\n r = hypotenuse(p, e[i]);\n e[i + 1] = s * r;\n s = e[i] / r;\n c = p / r;\n p = c * d[i] - s * g;\n d[i + 1] = h + s * (c * g + s * d[i]);\n\n for (k = 0; k < n; k++) {\n h = V.get(k, i + 1);\n V.set(k, i + 1, s * V.get(k, i) + c * h);\n V.set(k, i, c * V.get(k, i) - s * h);\n }\n }\n\n p = (-s * s2 * c3 * el1 * e[l]) / dl1;\n e[l] = s * p;\n d[l] = c * p;\n } while (Math.abs(e[l]) > eps * tst1);\n }\n d[l] = d[l] + f;\n e[l] = 0;\n }\n\n for (i = 0; i < n - 1; i++) {\n k = i;\n p = d[i];\n for (j = i + 1; j < n; j++) {\n if (d[j] < p) {\n k = j;\n p = d[j];\n }\n }\n\n if (k !== i) {\n d[k] = d[i];\n d[i] = p;\n for (j = 0; j < n; j++) {\n p = V.get(j, i);\n V.set(j, i, V.get(j, k));\n V.set(j, k, p);\n }\n }\n }\n}\n\nfunction orthes(n, H, ort, V) {\n let low = 0;\n let high = n - 1;\n let f, g, h, i, j, m;\n let scale;\n\n for (m = low + 1; m <= high - 1; m++) {\n scale = 0;\n for (i = m; i <= high; i++) {\n scale = scale + Math.abs(H.get(i, m - 1));\n }\n\n if (scale !== 0) {\n h = 0;\n for (i = high; i >= m; i--) {\n ort[i] = H.get(i, m - 1) / scale;\n h += ort[i] * ort[i];\n }\n\n g = Math.sqrt(h);\n if (ort[m] > 0) {\n g = -g;\n }\n\n h = h - ort[m] * g;\n ort[m] = ort[m] - g;\n\n for (j = m; j < n; j++) {\n f = 0;\n for (i = high; i >= m; i--) {\n f += ort[i] * H.get(i, j);\n }\n\n f = f / h;\n for (i = m; i <= high; i++) {\n H.set(i, j, H.get(i, j) - f * ort[i]);\n }\n }\n\n for (i = 0; i <= high; i++) {\n f = 0;\n for (j = high; j >= m; j--) {\n f += ort[j] * H.get(i, j);\n }\n\n f = f / h;\n for (j = m; j <= high; j++) {\n H.set(i, j, H.get(i, j) - f * ort[j]);\n }\n }\n\n ort[m] = scale * ort[m];\n H.set(m, m - 1, scale * g);\n }\n }\n\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n V.set(i, j, i === j ? 1 : 0);\n }\n }\n\n for (m = high - 1; m >= low + 1; m--) {\n if (H.get(m, m - 1) !== 0) {\n for (i = m + 1; i <= high; i++) {\n ort[i] = H.get(i, m - 1);\n }\n\n for (j = m; j <= high; j++) {\n g = 0;\n for (i = m; i <= high; i++) {\n g += ort[i] * V.get(i, j);\n }\n\n g = g / ort[m] / H.get(m, m - 1);\n for (i = m; i <= high; i++) {\n V.set(i, j, V.get(i, j) + g * ort[i]);\n }\n }\n }\n }\n}\n\nfunction hqr2(nn, e, d, V, H) {\n let n = nn - 1;\n let low = 0;\n let high = nn - 1;\n let eps = Number.EPSILON;\n let exshift = 0;\n let norm = 0;\n let p = 0;\n let q = 0;\n let r = 0;\n let s = 0;\n let z = 0;\n let iter = 0;\n let i, j, k, l, m, t, w, x, y;\n let ra, sa, vr, vi;\n let notlast, cdivres;\n\n for (i = 0; i < nn; i++) {\n if (i < low || i > high) {\n d[i] = H.get(i, i);\n e[i] = 0;\n }\n\n for (j = Math.max(i - 1, 0); j < nn; j++) {\n norm = norm + Math.abs(H.get(i, j));\n }\n }\n\n while (n >= low) {\n l = n;\n while (l > low) {\n s = Math.abs(H.get(l - 1, l - 1)) + Math.abs(H.get(l, l));\n if (s === 0) {\n s = norm;\n }\n if (Math.abs(H.get(l, l - 1)) < eps * s) {\n break;\n }\n l--;\n }\n\n if (l === n) {\n H.set(n, n, H.get(n, n) + exshift);\n d[n] = H.get(n, n);\n e[n] = 0;\n n--;\n iter = 0;\n } else if (l === n - 1) {\n w = H.get(n, n - 1) * H.get(n - 1, n);\n p = (H.get(n - 1, n - 1) - H.get(n, n)) / 2;\n q = p * p + w;\n z = Math.sqrt(Math.abs(q));\n H.set(n, n, H.get(n, n) + exshift);\n H.set(n - 1, n - 1, H.get(n - 1, n - 1) + exshift);\n x = H.get(n, n);\n\n if (q >= 0) {\n z = p >= 0 ? p + z : p - z;\n d[n - 1] = x + z;\n d[n] = d[n - 1];\n if (z !== 0) {\n d[n] = x - w / z;\n }\n e[n - 1] = 0;\n e[n] = 0;\n x = H.get(n, n - 1);\n s = Math.abs(x) + Math.abs(z);\n p = x / s;\n q = z / s;\n r = Math.sqrt(p * p + q * q);\n p = p / r;\n q = q / r;\n\n for (j = n - 1; j < nn; j++) {\n z = H.get(n - 1, j);\n H.set(n - 1, j, q * z + p * H.get(n, j));\n H.set(n, j, q * H.get(n, j) - p * z);\n }\n\n for (i = 0; i <= n; i++) {\n z = H.get(i, n - 1);\n H.set(i, n - 1, q * z + p * H.get(i, n));\n H.set(i, n, q * H.get(i, n) - p * z);\n }\n\n for (i = low; i <= high; i++) {\n z = V.get(i, n - 1);\n V.set(i, n - 1, q * z + p * V.get(i, n));\n V.set(i, n, q * V.get(i, n) - p * z);\n }\n } else {\n d[n - 1] = x + p;\n d[n] = x + p;\n e[n - 1] = z;\n e[n] = -z;\n }\n\n n = n - 2;\n iter = 0;\n } else {\n x = H.get(n, n);\n y = 0;\n w = 0;\n if (l < n) {\n y = H.get(n - 1, n - 1);\n w = H.get(n, n - 1) * H.get(n - 1, n);\n }\n\n if (iter === 10) {\n exshift += x;\n for (i = low; i <= n; i++) {\n H.set(i, i, H.get(i, i) - x);\n }\n s = Math.abs(H.get(n, n - 1)) + Math.abs(H.get(n - 1, n - 2));\n x = y = 0.75 * s;\n w = -0.4375 * s * s;\n }\n\n if (iter === 30) {\n s = (y - x) / 2;\n s = s * s + w;\n if (s > 0) {\n s = Math.sqrt(s);\n if (y < x) {\n s = -s;\n }\n s = x - w / ((y - x) / 2 + s);\n for (i = low; i <= n; i++) {\n H.set(i, i, H.get(i, i) - s);\n }\n exshift += s;\n x = y = w = 0.964;\n }\n }\n\n iter = iter + 1;\n\n m = n - 2;\n while (m >= l) {\n z = H.get(m, m);\n r = x - z;\n s = y - z;\n p = (r * s - w) / H.get(m + 1, m) + H.get(m, m + 1);\n q = H.get(m + 1, m + 1) - z - r - s;\n r = H.get(m + 2, m + 1);\n s = Math.abs(p) + Math.abs(q) + Math.abs(r);\n p = p / s;\n q = q / s;\n r = r / s;\n if (m === l) {\n break;\n }\n if (\n Math.abs(H.get(m, m - 1)) * (Math.abs(q) + Math.abs(r)) <\n eps *\n (Math.abs(p) *\n (Math.abs(H.get(m - 1, m - 1)) +\n Math.abs(z) +\n Math.abs(H.get(m + 1, m + 1))))\n ) {\n break;\n }\n m--;\n }\n\n for (i = m + 2; i <= n; i++) {\n H.set(i, i - 2, 0);\n if (i > m + 2) {\n H.set(i, i - 3, 0);\n }\n }\n\n for (k = m; k <= n - 1; k++) {\n notlast = k !== n - 1;\n if (k !== m) {\n p = H.get(k, k - 1);\n q = H.get(k + 1, k - 1);\n r = notlast ? H.get(k + 2, k - 1) : 0;\n x = Math.abs(p) + Math.abs(q) + Math.abs(r);\n if (x !== 0) {\n p = p / x;\n q = q / x;\n r = r / x;\n }\n }\n\n if (x === 0) {\n break;\n }\n\n s = Math.sqrt(p * p + q * q + r * r);\n if (p < 0) {\n s = -s;\n }\n\n if (s !== 0) {\n if (k !== m) {\n H.set(k, k - 1, -s * x);\n } else if (l !== m) {\n H.set(k, k - 1, -H.get(k, k - 1));\n }\n\n p = p + s;\n x = p / s;\n y = q / s;\n z = r / s;\n q = q / p;\n r = r / p;\n\n for (j = k; j < nn; j++) {\n p = H.get(k, j) + q * H.get(k + 1, j);\n if (notlast) {\n p = p + r * H.get(k + 2, j);\n H.set(k + 2, j, H.get(k + 2, j) - p * z);\n }\n\n H.set(k, j, H.get(k, j) - p * x);\n H.set(k + 1, j, H.get(k + 1, j) - p * y);\n }\n\n for (i = 0; i <= Math.min(n, k + 3); i++) {\n p = x * H.get(i, k) + y * H.get(i, k + 1);\n if (notlast) {\n p = p + z * H.get(i, k + 2);\n H.set(i, k + 2, H.get(i, k + 2) - p * r);\n }\n\n H.set(i, k, H.get(i, k) - p);\n H.set(i, k + 1, H.get(i, k + 1) - p * q);\n }\n\n for (i = low; i <= high; i++) {\n p = x * V.get(i, k) + y * V.get(i, k + 1);\n if (notlast) {\n p = p + z * V.get(i, k + 2);\n V.set(i, k + 2, V.get(i, k + 2) - p * r);\n }\n\n V.set(i, k, V.get(i, k) - p);\n V.set(i, k + 1, V.get(i, k + 1) - p * q);\n }\n }\n }\n }\n }\n\n if (norm === 0) {\n return;\n }\n\n for (n = nn - 1; n >= 0; n--) {\n p = d[n];\n q = e[n];\n\n if (q === 0) {\n l = n;\n H.set(n, n, 1);\n for (i = n - 1; i >= 0; i--) {\n w = H.get(i, i) - p;\n r = 0;\n for (j = l; j <= n; j++) {\n r = r + H.get(i, j) * H.get(j, n);\n }\n\n if (e[i] < 0) {\n z = w;\n s = r;\n } else {\n l = i;\n if (e[i] === 0) {\n H.set(i, n, w !== 0 ? -r / w : -r / (eps * norm));\n } else {\n x = H.get(i, i + 1);\n y = H.get(i + 1, i);\n q = (d[i] - p) * (d[i] - p) + e[i] * e[i];\n t = (x * s - z * r) / q;\n H.set(i, n, t);\n H.set(\n i + 1,\n n,\n Math.abs(x) > Math.abs(z) ? (-r - w * t) / x : (-s - y * t) / z,\n );\n }\n\n t = Math.abs(H.get(i, n));\n if (eps * t * t > 1) {\n for (j = i; j <= n; j++) {\n H.set(j, n, H.get(j, n) / t);\n }\n }\n }\n }\n } else if (q < 0) {\n l = n - 1;\n\n if (Math.abs(H.get(n, n - 1)) > Math.abs(H.get(n - 1, n))) {\n H.set(n - 1, n - 1, q / H.get(n, n - 1));\n H.set(n - 1, n, -(H.get(n, n) - p) / H.get(n, n - 1));\n } else {\n cdivres = cdiv(0, -H.get(n - 1, n), H.get(n - 1, n - 1) - p, q);\n H.set(n - 1, n - 1, cdivres[0]);\n H.set(n - 1, n, cdivres[1]);\n }\n\n H.set(n, n - 1, 0);\n H.set(n, n, 1);\n for (i = n - 2; i >= 0; i--) {\n ra = 0;\n sa = 0;\n for (j = l; j <= n; j++) {\n ra = ra + H.get(i, j) * H.get(j, n - 1);\n sa = sa + H.get(i, j) * H.get(j, n);\n }\n\n w = H.get(i, i) - p;\n\n if (e[i] < 0) {\n z = w;\n r = ra;\n s = sa;\n } else {\n l = i;\n if (e[i] === 0) {\n cdivres = cdiv(-ra, -sa, w, q);\n H.set(i, n - 1, cdivres[0]);\n H.set(i, n, cdivres[1]);\n } else {\n x = H.get(i, i + 1);\n y = H.get(i + 1, i);\n vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q;\n vi = (d[i] - p) * 2 * q;\n if (vr === 0 && vi === 0) {\n vr =\n eps *\n norm *\n (Math.abs(w) +\n Math.abs(q) +\n Math.abs(x) +\n Math.abs(y) +\n Math.abs(z));\n }\n cdivres = cdiv(\n x * r - z * ra + q * sa,\n x * s - z * sa - q * ra,\n vr,\n vi,\n );\n H.set(i, n - 1, cdivres[0]);\n H.set(i, n, cdivres[1]);\n if (Math.abs(x) > Math.abs(z) + Math.abs(q)) {\n H.set(\n i + 1,\n n - 1,\n (-ra - w * H.get(i, n - 1) + q * H.get(i, n)) / x,\n );\n H.set(\n i + 1,\n n,\n (-sa - w * H.get(i, n) - q * H.get(i, n - 1)) / x,\n );\n } else {\n cdivres = cdiv(\n -r - y * H.get(i, n - 1),\n -s - y * H.get(i, n),\n z,\n q,\n );\n H.set(i + 1, n - 1, cdivres[0]);\n H.set(i + 1, n, cdivres[1]);\n }\n }\n\n t = Math.max(Math.abs(H.get(i, n - 1)), Math.abs(H.get(i, n)));\n if (eps * t * t > 1) {\n for (j = i; j <= n; j++) {\n H.set(j, n - 1, H.get(j, n - 1) / t);\n H.set(j, n, H.get(j, n) / t);\n }\n }\n }\n }\n }\n }\n\n for (i = 0; i < nn; i++) {\n if (i < low || i > high) {\n for (j = i; j < nn; j++) {\n V.set(i, j, H.get(i, j));\n }\n }\n }\n\n for (j = nn - 1; j >= low; j--) {\n for (i = low; i <= high; i++) {\n z = 0;\n for (k = low; k <= Math.min(j, high); k++) {\n z = z + V.get(i, k) * H.get(k, j);\n }\n V.set(i, j, z);\n }\n }\n}\n\nfunction cdiv(xr, xi, yr, yi) {\n let r, d;\n if (Math.abs(yr) > Math.abs(yi)) {\n r = yi / yr;\n d = yr + r * yi;\n return [(xr + r * xi) / d, (xi - r * xr) / d];\n } else {\n r = yr / yi;\n d = yi + r * yr;\n return [(r * xr + xi) / d, (r * xi - xr) / d];\n }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nexport default class CholeskyDecomposition {\n constructor(value) {\n value = WrapperMatrix2D.checkMatrix(value);\n if (!value.isSymmetric()) {\n throw new Error('Matrix is not symmetric');\n }\n\n let a = value;\n let dimension = a.rows;\n let l = new Matrix(dimension, dimension);\n let positiveDefinite = true;\n let i, j, k;\n\n for (j = 0; j < dimension; j++) {\n let d = 0;\n for (k = 0; k < j; k++) {\n let s = 0;\n for (i = 0; i < k; i++) {\n s += l.get(k, i) * l.get(j, i);\n }\n s = (a.get(j, k) - s) / l.get(k, k);\n l.set(j, k, s);\n d = d + s * s;\n }\n\n d = a.get(j, j) - d;\n\n positiveDefinite &= d > 0;\n l.set(j, j, Math.sqrt(Math.max(d, 0)));\n for (k = j + 1; k < dimension; k++) {\n l.set(j, k, 0);\n }\n }\n\n this.L = l;\n this.positiveDefinite = Boolean(positiveDefinite);\n }\n\n isPositiveDefinite() {\n return this.positiveDefinite;\n }\n\n solve(value) {\n value = WrapperMatrix2D.checkMatrix(value);\n\n let l = this.L;\n let dimension = l.rows;\n\n if (value.rows !== dimension) {\n throw new Error('Matrix dimensions do not match');\n }\n if (this.isPositiveDefinite() === false) {\n throw new Error('Matrix is not positive definite');\n }\n\n let count = value.columns;\n let B = value.clone();\n let i, j, k;\n\n for (k = 0; k < dimension; k++) {\n for (j = 0; j < count; j++) {\n for (i = 0; i < k; i++) {\n B.set(k, j, B.get(k, j) - B.get(i, j) * l.get(k, i));\n }\n B.set(k, j, B.get(k, j) / l.get(k, k));\n }\n }\n\n for (k = dimension - 1; k >= 0; k--) {\n for (j = 0; j < count; j++) {\n for (i = k + 1; i < dimension; i++) {\n B.set(k, j, B.get(k, j) - B.get(i, j) * l.get(i, k));\n }\n B.set(k, j, B.get(k, j) / l.get(k, k));\n }\n }\n\n return B;\n }\n\n get lowerTriangularMatrix() {\n return this.L;\n }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nexport default class nipals {\n constructor(X, options = {}) {\n X = WrapperMatrix2D.checkMatrix(X);\n let { Y } = options;\n const {\n scaleScores = false,\n maxIterations = 1000,\n terminationCriteria = 1e-10,\n } = options;\n\n let u;\n if (Y) {\n if (Array.isArray(Y) && typeof Y[0] === 'number') {\n Y = Matrix.columnVector(Y);\n } else {\n Y = WrapperMatrix2D.checkMatrix(Y);\n }\n if (!Y.isColumnVector() || Y.rows !== X.rows) {\n throw new Error('Y must be a column vector of length X.rows');\n }\n u = Y;\n } else {\n u = X.getColumnVector(0);\n }\n\n let diff = 1;\n let t, q, w, tOld;\n\n for (\n let counter = 0;\n counter < maxIterations && diff > terminationCriteria;\n counter++\n ) {\n w = X.transpose().mmul(u).div(u.transpose().mmul(u).get(0, 0));\n w = w.div(w.norm());\n\n t = X.mmul(w).div(w.transpose().mmul(w).get(0, 0));\n\n if (counter > 0) {\n diff = t.clone().sub(tOld).pow(2).sum();\n }\n tOld = t.clone();\n\n if (Y) {\n q = Y.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\n q = q.div(q.norm());\n\n u = Y.mmul(q).div(q.transpose().mmul(q).get(0, 0));\n } else {\n u = t;\n }\n }\n\n if (Y) {\n let p = X.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\n p = p.div(p.norm());\n let xResidual = X.clone().sub(t.clone().mmul(p.transpose()));\n let residual = u.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\n let yResidual = Y.clone().sub(\n t.clone().mulS(residual.get(0, 0)).mmul(q.transpose()),\n );\n\n this.t = t;\n this.p = p.transpose();\n this.w = w.transpose();\n this.q = q;\n this.u = u;\n this.s = t.transpose().mmul(t);\n this.xResidual = xResidual;\n this.yResidual = yResidual;\n this.betas = residual;\n } else {\n this.w = w.transpose();\n this.s = t.transpose().mmul(t).sqrt();\n if (scaleScores) {\n this.t = t.clone().div(this.s.get(0, 0));\n } else {\n this.t = t;\n }\n this.xResidual = X.sub(t.mmul(w.transpose()));\n }\n }\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction sum(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var sumValue = 0;\n\n for (var i = 0; i < input.length; i++) {\n sumValue += input[i];\n }\n\n return sumValue;\n}\n\nexport default sum;\n","import sum from 'ml-array-sum';\n\nfunction mean(input) {\n return sum(input) / input.length;\n}\n\nexport default mean;\n","import Matrix from 'ml-matrix';\nimport meanArray from 'ml-array-mean';\n\n/**\n * @private\n * return an array of probabilities of each class\n * @param {Array} array - contains the classes\n * @param {number} numberOfClasses\n * @return {Matrix} - rowVector of probabilities.\n */\nexport function toDiscreteDistribution(array, numberOfClasses) {\n let counts = new Array(numberOfClasses).fill(0);\n for (let i = 0; i < array.length; ++i) {\n counts[array[i]] += 1 / array.length;\n }\n\n return Matrix.rowVector(counts);\n}\n\n/**\n * @private\n * Retrieves the impurity of array of predictions\n * @param {Array} array - predictions.\n * @return {number} Gini impurity\n */\nexport function giniImpurity(array) {\n if (array.length === 0) {\n return 0;\n }\n\n let probabilities = toDiscreteDistribution(\n array,\n getNumberOfClasses(array),\n ).getRow(0);\n\n let sum = 0.0;\n for (let i = 0; i < probabilities.length; ++i) {\n sum += probabilities[i] * probabilities[i];\n }\n\n return 1 - sum;\n}\n\n/**\n * @private\n * Return the number of classes given the array of predictions.\n * @param {Array} array - predictions.\n * @return {number} Number of classes.\n */\nexport function getNumberOfClasses(array) {\n return array\n .filter(function(val, i, arr) {\n return arr.indexOf(val) === i;\n })\n .map((val) => val + 1)\n .reduce((a, b) => Math.max(a, b));\n}\n\n/**\n * @private\n * Calculates the Gini Gain of an array of predictions and those predictions splitted by a feature.\n * @param {Array} array - Predictions\n * @param {object} splitted - Object with elements \"greater\" and \"lesser\" that contains an array of predictions splitted.\n * @return {number} - Gini Gain.\n */\n\nexport function giniGain(array, splitted) {\n let splitsImpurity = 0.0;\n let splits = ['greater', 'lesser'];\n\n for (let i = 0; i < splits.length; ++i) {\n let currentSplit = splitted[splits[i]];\n splitsImpurity +=\n (giniImpurity(currentSplit) * currentSplit.length) / array.length;\n }\n\n return giniImpurity(array) - splitsImpurity;\n}\n\n/**\n * @private\n * Calculates the squared error of a predictions values.\n * @param {Array} array - predictions values\n * @return {number} squared error.\n */\nexport function squaredError(array) {\n let l = array.length;\n\n let m = meanArray(array);\n let error = 0.0;\n\n for (let i = 0; i < l; ++i) {\n let currentElement = array[i];\n error += (currentElement - m) * (currentElement - m);\n }\n\n return error;\n}\n\n/**\n * @private\n * Calculates the sum of squared error of the two arrays that contains the splitted values.\n * @param {Array} array - this argument is no necessary but is used to fit with the main interface.\n * @param {object} splitted - Object with elements \"greater\" and \"lesser\" that contains an array of predictions splitted.\n * @return {number} - sum of squared errors.\n */\nexport function regressionError(array, splitted) {\n let error = 0.0;\n let splits = ['greater', 'lesser'];\n\n for (let i = 0; i < splits.length; ++i) {\n let currentSplit = splitted[splits[i]];\n error += squaredError(currentSplit);\n }\n return error;\n}\n\n/**\n * @private\n * Split the training set and values from a given column of the training set if is less than a value\n * @param {Matrix} X - Training set.\n * @param {Array} y - Training values.\n * @param {number} column - Column to split.\n * @param {number} value - value to split the Training set and values.\n * @return {object} - Object that contains the splitted values.\n */\nexport function matrixSplitter(X, y, column, value) {\n let lesserX = [];\n let greaterX = [];\n let lesserY = [];\n let greaterY = [];\n\n for (let i = 0; i < X.rows; ++i) {\n if (X.get(i, column) < value) {\n lesserX.push(X.getRow(i));\n lesserY.push(y[i]);\n } else {\n greaterX.push(X.getRow(i));\n greaterY.push(y[i]);\n }\n }\n\n return {\n greaterX: greaterX,\n greaterY: greaterY,\n lesserX: lesserX,\n lesserY: lesserY,\n };\n}\n\n/**\n * @private\n * Calculates the mean between two values\n * @param {number} a\n * @param {number} b\n * @return {number}\n */\nexport function mean(a, b) {\n return (a + b) / 2;\n}\n\n/**\n * @private\n * Returns a list of tuples that contains the i-th element of each array.\n * @param {Array} a\n * @param {Array} b\n * @return {Array} list of tuples.\n */\nexport function zip(a, b) {\n if (a.length !== b.length) {\n throw new TypeError(\n `Error on zip: the size of a: ${a.length} is different from b: ${b.length}`,\n );\n }\n\n let ret = new Array(a.length);\n for (let i = 0; i < a.length; ++i) {\n ret[i] = [a[i], b[i]];\n }\n\n return ret;\n}\n","import Matrix from 'ml-matrix';\nimport mean from 'ml-array-mean';\n\nimport * as Utils from './utils';\n\nconst gainFunctions = {\n gini: Utils.giniGain,\n regression: Utils.regressionError,\n};\n\nconst splitFunctions = {\n mean: Utils.mean,\n};\n\nexport default class TreeNode {\n /**\n * @private\n * Constructor for a tree node given the options received on the main classes (DecisionTreeClassifier, DecisionTreeRegression)\n * @param {object|TreeNode} options for loading\n * @constructor\n */\n constructor(options) {\n // options parameters\n this.kind = options.kind;\n this.gainFunction = options.gainFunction;\n this.splitFunction = options.splitFunction;\n this.minNumSamples = options.minNumSamples;\n this.maxDepth = options.maxDepth;\n }\n\n /**\n * @private\n * Function that retrieve the best feature to make the split.\n * @param {Matrix} XTranspose - Training set transposed\n * @param {Array} y - labels or values (depending of the decision tree)\n * @return {object} - return tree values, the best gain, column and the split value.\n */\n bestSplit(XTranspose, y) {\n // Depending in the node tree class, we set the variables to check information gain (to classify)\n // or error (for regression)\n\n let bestGain = this.kind === 'classifier' ? -Infinity : Infinity;\n let check = this.kind === 'classifier' ? (a, b) => a > b : (a, b) => a < b;\n\n let maxColumn;\n let maxValue;\n\n for (let i = 0; i < XTranspose.rows; ++i) {\n let currentFeature = XTranspose.getRow(i);\n let splitValues = this.featureSplit(currentFeature, y);\n for (let j = 0; j < splitValues.length; ++j) {\n let currentSplitVal = splitValues[j];\n let splitted = this.split(currentFeature, y, currentSplitVal);\n\n let gain = gainFunctions[this.gainFunction](y, splitted);\n if (check(gain, bestGain)) {\n maxColumn = i;\n maxValue = currentSplitVal;\n bestGain = gain;\n }\n }\n }\n\n return {\n maxGain: bestGain,\n maxColumn: maxColumn,\n maxValue: maxValue,\n };\n }\n\n /**\n * @private\n * Makes the split of the training labels or values from the training set feature given a split value.\n * @param {Array} x - Training set feature\n * @param {Array} y - Training set value or label\n * @param {number} splitValue\n * @return {object}\n */\n split(x, y, splitValue) {\n let lesser = [];\n let greater = [];\n\n for (let i = 0; i < x.length; ++i) {\n if (x[i] < splitValue) {\n lesser.push(y[i]);\n } else {\n greater.push(y[i]);\n }\n }\n\n return {\n greater: greater,\n lesser: lesser,\n };\n }\n\n /**\n * @private\n * Calculates the possible points to split over the tree given a training set feature and corresponding labels or values.\n * @param {Array} x - Training set feature\n * @param {Array} y - Training set value or label\n * @return {Array} possible split values.\n */\n featureSplit(x, y) {\n let splitValues = [];\n let arr = Utils.zip(x, y);\n arr.sort(function(a, b) {\n return a[0] - b[0];\n });\n\n for (let i = 1; i < arr.length; ++i) {\n if (arr[i - 1][1] !== arr[i][1]) {\n splitValues.push(\n splitFunctions[this.splitFunction](arr[i - 1][0], arr[i][0]),\n );\n }\n }\n\n return splitValues;\n }\n\n /**\n * @private\n * Calculate the predictions of a leaf tree node given the training labels or values\n * @param {Array} y\n */\n calculatePrediction(y) {\n if (this.kind === 'classifier') {\n this.distribution = Utils.toDiscreteDistribution(\n y,\n Utils.getNumberOfClasses(y),\n );\n if (this.distribution.columns === 0) {\n throw new TypeError('Error on calculate the prediction');\n }\n } else {\n this.distribution = mean(y);\n }\n }\n\n /**\n * @private\n * Train a node given the training set and labels, because it trains recursively, it also receive\n * the current depth of the node, parent gain to avoid infinite recursion and boolean value to check if\n * the training set is transposed.\n * @param {Matrix} X - Training set (could be transposed or not given transposed).\n * @param {Array} y - Training labels or values.\n * @param {number} currentDepth - Current depth of the node.\n * @param {number} parentGain - parent node gain or error.\n */\n train(X, y, currentDepth, parentGain) {\n if (X.rows <= this.minNumSamples) {\n this.calculatePrediction(y);\n return;\n }\n if (parentGain === undefined) parentGain = 0.0;\n\n let XTranspose = X.transpose();\n let split = this.bestSplit(XTranspose, y);\n\n this.splitValue = split.maxValue;\n this.splitColumn = split.maxColumn;\n this.gain = split.maxGain;\n\n let splittedMatrix = Utils.matrixSplitter(\n X,\n y,\n this.splitColumn,\n this.splitValue,\n );\n\n if (\n currentDepth < this.maxDepth &&\n (this.gain > 0.01 && this.gain !== parentGain) &&\n (splittedMatrix.lesserX.length > 0 && splittedMatrix.greaterX.length > 0)\n ) {\n this.left = new TreeNode(this);\n this.right = new TreeNode(this);\n\n let lesserX = new Matrix(splittedMatrix.lesserX);\n let greaterX = new Matrix(splittedMatrix.greaterX);\n\n this.left.train(\n lesserX,\n splittedMatrix.lesserY,\n currentDepth + 1,\n this.gain,\n );\n this.right.train(\n greaterX,\n splittedMatrix.greaterY,\n currentDepth + 1,\n this.gain,\n );\n } else {\n this.calculatePrediction(y);\n }\n }\n\n /**\n * @private\n * Calculates the prediction of a given element.\n * @param {Array} row\n * @return {number|Array} prediction\n * * if a node is a classifier returns an array of probabilities of each class.\n * * if a node is for regression returns a number with the prediction.\n */\n classify(row) {\n if (this.right && this.left) {\n if (row[this.splitColumn] < this.splitValue) {\n return this.left.classify(row);\n } else {\n return this.right.classify(row);\n }\n }\n\n return this.distribution;\n }\n\n /**\n * @private\n * Set the parameter of the current node and their children.\n * @param {object} node - parameters of the current node and the children.\n */\n setNodeParameters(node) {\n if (node.distribution !== undefined) {\n this.distribution =\n node.distribution.constructor === Array\n ? new Matrix(node.distribution)\n : node.distribution;\n } else {\n this.distribution = undefined;\n this.splitValue = node.splitValue;\n this.splitColumn = node.splitColumn;\n this.gain = node.gain;\n\n this.left = new TreeNode(this);\n this.right = new TreeNode(this);\n\n if (node.left !== {}) {\n this.left.setNodeParameters(node.left);\n }\n if (node.right !== {}) {\n this.right.setNodeParameters(node.right);\n }\n }\n }\n}\n","import Matrix from 'ml-matrix';\n\nimport Tree from './TreeNode';\n\nconst defaultOptions = {\n gainFunction: 'gini',\n splitFunction: 'mean',\n minNumSamples: 3,\n maxDepth: Infinity,\n};\n\nexport class DecisionTreeClassifier {\n /**\n * Create new Decision Tree Classifier with CART implementation with the given options\n * @param {object} options\n * @param {string} [options.gainFunction=\"gini\"] - gain function to get the best split, \"gini\" the only one supported.\n * @param {string} [options.splitFunction=\"mean\"] - given two integers from a split feature, get the value to split, \"mean\" the only one supported.\n * @param {number} [options.minNumSamples=3] - minimum number of samples to create a leaf node to decide a class.\n * @param {number} [options.maxDepth=Infinity] - Max depth of the tree.\n * @param {object} model - for load purposes.\n * @constructor\n */\n constructor(options, model) {\n if (options === true) {\n this.options = model.options;\n this.root = new Tree(model.options);\n this.root.setNodeParameters(model.root);\n } else {\n this.options = Object.assign({}, defaultOptions, options);\n this.options.kind = 'classifier';\n }\n }\n\n /**\n * Train the decision tree with the given training set and labels.\n * @param {Matrix|MatrixTransposeView|Array} trainingSet\n * @param {Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n this.root = new Tree(this.options);\n trainingSet = Matrix.checkMatrix(trainingSet);\n this.root.train(trainingSet, trainingLabels, 0, null);\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|MatrixTransposeView|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n toPredict = Matrix.checkMatrix(toPredict);\n let predictions = new Array(toPredict.rows);\n\n for (let i = 0; i < toPredict.rows; ++i) {\n predictions[i] = this.root\n .classify(toPredict.getRow(i))\n .maxRowIndex(0)[1];\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n options: this.options,\n root: this.root,\n name: 'DTClassifier',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {DecisionTreeClassifier}\n */\n static load(model) {\n if (model.name !== 'DTClassifier') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new DecisionTreeClassifier(true, model);\n }\n}\n","import Matrix from 'ml-matrix';\n\nimport Tree from './TreeNode';\n\nconst defaultOptions = {\n gainFunction: 'regression',\n splitFunction: 'mean',\n minNumSamples: 3,\n maxDepth: Infinity,\n};\n\nexport class DecisionTreeRegression {\n /**\n * Create new Decision Tree Regression with CART implementation with the given options.\n * @param {object} options\n * @param {string} [options.gainFunction=\"regression\"] - gain function to get the best split, \"regression\" the only one supported.\n * @param {string} [options.splitFunction=\"mean\"] - given two integers from a split feature, get the value to split, \"mean\" the only one supported.\n * @param {number} [options.minNumSamples=3] - minimum number of samples to create a leaf node to decide a class.\n * @param {number} [options.maxDepth=Infinity] - Max depth of the tree.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.options = model.options;\n this.root = new Tree(model.options);\n this.root.setNodeParameters(model.root);\n } else {\n this.options = Object.assign({}, defaultOptions, options);\n this.options.kind = 'regression';\n }\n }\n\n /**\n * Train the decision tree with the given training set and values.\n * @param {Matrix|MatrixTransposeView|Array} trainingSet\n * @param {Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n this.root = new Tree(this.options);\n\n if (\n typeof trainingSet[0] !== 'undefined' &&\n trainingSet[0].length === undefined\n ) {\n trainingSet = Matrix.columnVector(trainingSet);\n } else {\n trainingSet = Matrix.checkMatrix(trainingSet);\n }\n this.root.train(trainingSet, trainingValues, 0);\n }\n\n /**\n * Predicts the values given the matrix to predict.\n * @param {Matrix|MatrixTransposeView|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n if (\n typeof toPredict[0] !== 'undefined' &&\n toPredict[0].length === undefined\n ) {\n toPredict = Matrix.columnVector(toPredict);\n }\n toPredict = Matrix.checkMatrix(toPredict);\n\n let predictions = new Array(toPredict.rows);\n for (let i = 0; i < toPredict.rows; ++i) {\n predictions[i] = this.root.classify(toPredict.getRow(i));\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n options: this.options,\n root: this.root,\n name: 'DTRegression',\n };\n }\n\n /**\n * Load a Decision tree regression with the given model.\n * @param {object} model\n * @return {DecisionTreeRegression}\n */\n static load(model) {\n if (model.name !== 'DTRegression') {\n throw new RangeError(`Invalid model:${model.name}`);\n }\n\n return new DecisionTreeRegression(true, model);\n }\n}\n","const SMALLEST_UNSAFE_INTEGER = 0x20000000000000;\r\nconst LARGEST_SAFE_INTEGER = SMALLEST_UNSAFE_INTEGER - 1;\r\nconst UINT32_MAX = -1 >>> 0;\r\nconst UINT32_SIZE = UINT32_MAX + 1;\r\nconst INT32_SIZE = UINT32_SIZE / 2;\r\nconst INT32_MAX = INT32_SIZE - 1;\r\nconst UINT21_SIZE = 1 << 21;\r\nconst UINT21_MAX = UINT21_SIZE - 1;\n\n/**\r\n * Returns a value within [-0x80000000, 0x7fffffff]\r\n */\r\nfunction int32(engine) {\r\n return engine.next() | 0;\r\n}\n\nfunction add(distribution, addend) {\r\n if (addend === 0) {\r\n return distribution;\r\n }\r\n else {\r\n return engine => distribution(engine) + addend;\r\n }\r\n}\n\n/**\r\n * Returns a value within [-0x20000000000000, 0x1fffffffffffff]\r\n */\r\nfunction int53(engine) {\r\n const high = engine.next() | 0;\r\n const low = engine.next() >>> 0;\r\n return ((high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0));\r\n}\n\n/**\r\n * Returns a value within [-0x20000000000000, 0x20000000000000]\r\n */\r\nfunction int53Full(engine) {\r\n while (true) {\r\n const high = engine.next() | 0;\r\n if (high & 0x400000) {\r\n if ((high & 0x7fffff) === 0x400000 && (engine.next() | 0) === 0) {\r\n return SMALLEST_UNSAFE_INTEGER;\r\n }\r\n }\r\n else {\r\n const low = engine.next() >>> 0;\r\n return ((high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0));\r\n }\r\n }\r\n}\n\n/**\r\n * Returns a value within [0, 0xffffffff]\r\n */\r\nfunction uint32(engine) {\r\n return engine.next() >>> 0;\r\n}\n\n/**\r\n * Returns a value within [0, 0x1fffffffffffff]\r\n */\r\nfunction uint53(engine) {\r\n const high = engine.next() & UINT21_MAX;\r\n const low = engine.next() >>> 0;\r\n return high * UINT32_SIZE + low;\r\n}\n\n/**\r\n * Returns a value within [0, 0x20000000000000]\r\n */\r\nfunction uint53Full(engine) {\r\n while (true) {\r\n const high = engine.next() | 0;\r\n if (high & UINT21_SIZE) {\r\n if ((high & UINT21_MAX) === 0 && (engine.next() | 0) === 0) {\r\n return SMALLEST_UNSAFE_INTEGER;\r\n }\r\n }\r\n else {\r\n const low = engine.next() >>> 0;\r\n return (high & UINT21_MAX) * UINT32_SIZE + low;\r\n }\r\n }\r\n}\n\nfunction isPowerOfTwoMinusOne(value) {\r\n return ((value + 1) & value) === 0;\r\n}\r\nfunction bitmask(masking) {\r\n return (engine) => engine.next() & masking;\r\n}\r\nfunction downscaleToLoopCheckedRange(range) {\r\n const extendedRange = range + 1;\r\n const maximum = extendedRange * Math.floor(UINT32_SIZE / extendedRange);\r\n return engine => {\r\n let value = 0;\r\n do {\r\n value = engine.next() >>> 0;\r\n } while (value >= maximum);\r\n return value % extendedRange;\r\n };\r\n}\r\nfunction downscaleToRange(range) {\r\n if (isPowerOfTwoMinusOne(range)) {\r\n return bitmask(range);\r\n }\r\n else {\r\n return downscaleToLoopCheckedRange(range);\r\n }\r\n}\r\nfunction isEvenlyDivisibleByMaxInt32(value) {\r\n return (value | 0) === 0;\r\n}\r\nfunction upscaleWithHighMasking(masking) {\r\n return engine => {\r\n const high = engine.next() & masking;\r\n const low = engine.next() >>> 0;\r\n return high * UINT32_SIZE + low;\r\n };\r\n}\r\nfunction upscaleToLoopCheckedRange(extendedRange) {\r\n const maximum = extendedRange * Math.floor(SMALLEST_UNSAFE_INTEGER / extendedRange);\r\n return engine => {\r\n let ret = 0;\r\n do {\r\n const high = engine.next() & UINT21_MAX;\r\n const low = engine.next() >>> 0;\r\n ret = high * UINT32_SIZE + low;\r\n } while (ret >= maximum);\r\n return ret % extendedRange;\r\n };\r\n}\r\nfunction upscaleWithinU53(range) {\r\n const extendedRange = range + 1;\r\n if (isEvenlyDivisibleByMaxInt32(extendedRange)) {\r\n const highRange = ((extendedRange / UINT32_SIZE) | 0) - 1;\r\n if (isPowerOfTwoMinusOne(highRange)) {\r\n return upscaleWithHighMasking(highRange);\r\n }\r\n }\r\n return upscaleToLoopCheckedRange(extendedRange);\r\n}\r\nfunction upscaleWithinI53AndLoopCheck(min, max) {\r\n return engine => {\r\n let ret = 0;\r\n do {\r\n const high = engine.next() | 0;\r\n const low = engine.next() >>> 0;\r\n ret =\r\n (high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0);\r\n } while (ret < min || ret > max);\r\n return ret;\r\n };\r\n}\r\n/**\r\n * Returns a Distribution to return a value within [min, max]\r\n * @param min The minimum integer value, inclusive. No less than -0x20000000000000.\r\n * @param max The maximum integer value, inclusive. No greater than 0x20000000000000.\r\n */\r\nfunction integer(min, max) {\r\n min = Math.floor(min);\r\n max = Math.floor(max);\r\n if (min < -SMALLEST_UNSAFE_INTEGER || !isFinite(min)) {\r\n throw new RangeError(`Expected min to be at least ${-SMALLEST_UNSAFE_INTEGER}`);\r\n }\r\n else if (max > SMALLEST_UNSAFE_INTEGER || !isFinite(max)) {\r\n throw new RangeError(`Expected max to be at most ${SMALLEST_UNSAFE_INTEGER}`);\r\n }\r\n const range = max - min;\r\n if (range <= 0 || !isFinite(range)) {\r\n return () => min;\r\n }\r\n else if (range === UINT32_MAX) {\r\n if (min === 0) {\r\n return uint32;\r\n }\r\n else {\r\n return add(int32, min + INT32_SIZE);\r\n }\r\n }\r\n else if (range < UINT32_MAX) {\r\n return add(downscaleToRange(range), min);\r\n }\r\n else if (range === LARGEST_SAFE_INTEGER) {\r\n return add(uint53, min);\r\n }\r\n else if (range < LARGEST_SAFE_INTEGER) {\r\n return add(upscaleWithinU53(range), min);\r\n }\r\n else if (max - 1 - min === LARGEST_SAFE_INTEGER) {\r\n return add(uint53Full, min);\r\n }\r\n else if (min === -SMALLEST_UNSAFE_INTEGER &&\r\n max === SMALLEST_UNSAFE_INTEGER) {\r\n return int53Full;\r\n }\r\n else if (min === -SMALLEST_UNSAFE_INTEGER && max === LARGEST_SAFE_INTEGER) {\r\n return int53;\r\n }\r\n else if (min === -LARGEST_SAFE_INTEGER && max === SMALLEST_UNSAFE_INTEGER) {\r\n return add(int53, 1);\r\n }\r\n else if (max === SMALLEST_UNSAFE_INTEGER) {\r\n return add(upscaleWithinI53AndLoopCheck(min - 1, max - 1), 1);\r\n }\r\n else {\r\n return upscaleWithinI53AndLoopCheck(min, max);\r\n }\r\n}\n\nfunction isLeastBitTrue(engine) {\r\n return (engine.next() & 1) === 1;\r\n}\r\nfunction lessThan(distribution, value) {\r\n return engine => distribution(engine) < value;\r\n}\r\nfunction probability(percentage) {\r\n if (percentage <= 0) {\r\n return () => false;\r\n }\r\n else if (percentage >= 1) {\r\n return () => true;\r\n }\r\n else {\r\n const scaled = percentage * UINT32_SIZE;\r\n if (scaled % 1 === 0) {\r\n return lessThan(int32, (scaled - INT32_SIZE) | 0);\r\n }\r\n else {\r\n return lessThan(uint53, Math.round(percentage * SMALLEST_UNSAFE_INTEGER));\r\n }\r\n }\r\n}\r\nfunction bool(numerator, denominator) {\r\n if (denominator == null) {\r\n if (numerator == null) {\r\n return isLeastBitTrue;\r\n }\r\n return probability(numerator);\r\n }\r\n else {\r\n if (numerator <= 0) {\r\n return () => false;\r\n }\r\n else if (numerator >= denominator) {\r\n return () => true;\r\n }\r\n return lessThan(integer(0, denominator - 1), numerator);\r\n }\r\n}\n\n/**\r\n * Returns a Distribution that returns a random `Date` within the inclusive\r\n * range of [`start`, `end`].\r\n * @param start The minimum `Date`\r\n * @param end The maximum `Date`\r\n */\r\nfunction date(start, end) {\r\n const distribution = integer(+start, +end);\r\n return engine => new Date(distribution(engine));\r\n}\n\n/**\r\n * Returns a Distribution to return a value within [1, sideCount]\r\n * @param sideCount The number of sides of the die\r\n */\r\nfunction die(sideCount) {\r\n return integer(1, sideCount);\r\n}\n\n/**\r\n * Returns a distribution that returns an array of length `dieCount` of values\r\n * within [1, `sideCount`]\r\n * @param sideCount The number of sides of each die\r\n * @param dieCount The number of dice\r\n */\r\nfunction dice(sideCount, dieCount) {\r\n const distribution = die(sideCount);\r\n return engine => {\r\n const result = [];\r\n for (let i = 0; i < dieCount; ++i) {\r\n result.push(distribution(engine));\r\n }\r\n return result;\r\n };\r\n}\n\n// tslint:disable:unified-signatures\r\n// has 2**x chars, for faster uniform distribution\r\nconst DEFAULT_STRING_POOL = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\";\r\nfunction string(pool = DEFAULT_STRING_POOL) {\r\n const poolLength = pool.length;\r\n if (!poolLength) {\r\n throw new Error(\"Expected pool not to be an empty string\");\r\n }\r\n const distribution = integer(0, poolLength - 1);\r\n return (engine, length) => {\r\n let result = \"\";\r\n for (let i = 0; i < length; ++i) {\r\n const j = distribution(engine);\r\n result += pool.charAt(j);\r\n }\r\n return result;\r\n };\r\n}\n\nconst LOWER_HEX_POOL = \"0123456789abcdef\";\r\nconst lowerHex = string(LOWER_HEX_POOL);\r\nconst upperHex = string(LOWER_HEX_POOL.toUpperCase());\r\n/**\r\n * Returns a Distribution that returns a random string comprised of numbers\r\n * or the characters `abcdef` (or `ABCDEF`) of length `length`.\r\n * @param length Length of the result string\r\n * @param uppercase Whether the string should use `ABCDEF` instead of `abcdef`\r\n */\r\nfunction hex(uppercase) {\r\n if (uppercase) {\r\n return upperHex;\r\n }\r\n else {\r\n return lowerHex;\r\n }\r\n}\n\nfunction convertSliceArgument(value, length) {\r\n if (value < 0) {\r\n return Math.max(value + length, 0);\r\n }\r\n else {\r\n return Math.min(value, length);\r\n }\r\n}\n\nfunction toInteger(value) {\r\n const num = +value;\r\n if (num < 0) {\r\n return Math.ceil(num);\r\n }\r\n else {\r\n return Math.floor(num);\r\n }\r\n}\n\n/**\r\n * Returns a random value within the provided `source` within the sliced\r\n * bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\nfunction pick(engine, source, begin, end) {\r\n const length = source.length;\r\n if (length === 0) {\r\n throw new RangeError(\"Cannot pick from an empty array\");\r\n }\r\n const start = begin == null ? 0 : convertSliceArgument(toInteger(begin), length);\r\n const finish = end === void 0 ? length : convertSliceArgument(toInteger(end), length);\r\n if (start >= finish) {\r\n throw new RangeError(`Cannot pick between bounds ${start} and ${finish}`);\r\n }\r\n const distribution = integer(start, finish - 1);\r\n return source[distribution(engine)];\r\n}\n\nfunction multiply(distribution, multiplier) {\r\n if (multiplier === 1) {\r\n return distribution;\r\n }\r\n else if (multiplier === 0) {\r\n return () => 0;\r\n }\r\n else {\r\n return engine => distribution(engine) * multiplier;\r\n }\r\n}\n\n/**\r\n * Returns a floating-point value within [0.0, 1.0)\r\n */\r\nfunction realZeroToOneExclusive(engine) {\r\n return uint53(engine) / SMALLEST_UNSAFE_INTEGER;\r\n}\n\n/**\r\n * Returns a floating-point value within [0.0, 1.0]\r\n */\r\nfunction realZeroToOneInclusive(engine) {\r\n return uint53Full(engine) / SMALLEST_UNSAFE_INTEGER;\r\n}\n\n/**\r\n * Returns a floating-point value within [min, max) or [min, max]\r\n * @param min The minimum floating-point value, inclusive.\r\n * @param max The maximum floating-point value.\r\n * @param inclusive If true, `max` will be inclusive.\r\n */\r\nfunction real(min, max, inclusive = false) {\r\n if (!isFinite(min)) {\r\n throw new RangeError(\"Expected min to be a finite number\");\r\n }\r\n else if (!isFinite(max)) {\r\n throw new RangeError(\"Expected max to be a finite number\");\r\n }\r\n return add(multiply(inclusive ? realZeroToOneInclusive : realZeroToOneExclusive, max - min), min);\r\n}\n\nconst sliceArray = Array.prototype.slice;\n\n/**\r\n * Shuffles an array in-place\r\n * @param engine The Engine to use when choosing random values\r\n * @param array The array to shuffle\r\n * @param downTo minimum index to shuffle. Only used internally.\r\n */\r\nfunction shuffle(engine, array, downTo = 0) {\r\n const length = array.length;\r\n if (length) {\r\n for (let i = (length - 1) >>> 0; i > downTo; --i) {\r\n const distribution = integer(0, i);\r\n const j = distribution(engine);\r\n if (i !== j) {\r\n const tmp = array[i];\r\n array[i] = array[j];\r\n array[j] = tmp;\r\n }\r\n }\r\n }\r\n return array;\r\n}\n\n/**\r\n * From the population array, produce an array with sampleSize elements that\r\n * are randomly chosen without repeats.\r\n * @param engine The Engine to use when choosing random values\r\n * @param population An array that has items to choose a sample from\r\n * @param sampleSize The size of the result array\r\n */\r\nfunction sample(engine, population, sampleSize) {\r\n if (sampleSize < 0 ||\r\n sampleSize > population.length ||\r\n !isFinite(sampleSize)) {\r\n throw new RangeError(\"Expected sampleSize to be within 0 and the length of the population\");\r\n }\r\n if (sampleSize === 0) {\r\n return [];\r\n }\r\n const clone = sliceArray.call(population);\r\n const length = clone.length;\r\n if (length === sampleSize) {\r\n return shuffle(engine, clone, 0);\r\n }\r\n const tailLength = length - sampleSize;\r\n return shuffle(engine, clone, tailLength - 1).slice(tailLength);\r\n}\n\nconst stringRepeat = (() => {\r\n try {\r\n if (\"x\".repeat(3) === \"xxx\") {\r\n return (pattern, count) => pattern.repeat(count);\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n return (pattern, count) => {\r\n let result = \"\";\r\n while (count > 0) {\r\n if (count & 1) {\r\n result += pattern;\r\n }\r\n count >>= 1;\r\n pattern += pattern;\r\n }\r\n return result;\r\n };\r\n})();\n\nfunction zeroPad(text, zeroCount) {\r\n return stringRepeat(\"0\", zeroCount - text.length) + text;\r\n}\r\n/**\r\n * Returns a Universally Unique Identifier Version 4.\r\n *\r\n * See http://en.wikipedia.org/wiki/Universally_unique_identifier\r\n */\r\nfunction uuid4(engine) {\r\n const a = engine.next() >>> 0;\r\n const b = engine.next() | 0;\r\n const c = engine.next() | 0;\r\n const d = engine.next() >>> 0;\r\n return (zeroPad(a.toString(16), 8) +\r\n \"-\" +\r\n zeroPad((b & 0xffff).toString(16), 4) +\r\n \"-\" +\r\n zeroPad((((b >> 4) & 0x0fff) | 0x4000).toString(16), 4) +\r\n \"-\" +\r\n zeroPad(((c & 0x3fff) | 0x8000).toString(16), 4) +\r\n \"-\" +\r\n zeroPad(((c >> 4) & 0xffff).toString(16), 4) +\r\n zeroPad(d.toString(16), 8));\r\n}\n\n/**\r\n * An int32-producing Engine that uses `Math.random()`\r\n */\r\nconst nativeMath = {\r\n next() {\r\n return (Math.random() * UINT32_SIZE) | 0;\r\n }\r\n};\n\n// tslint:disable:unified-signatures\r\n/**\r\n * A wrapper around an Engine that provides easy-to-use methods for\r\n * producing values based on known distributions\r\n */\r\nclass Random {\r\n /**\r\n * Creates a new Random wrapper\r\n * @param engine The engine to use (defaults to a `Math.random`-based implementation)\r\n */\r\n constructor(engine = nativeMath) {\r\n this.engine = engine;\r\n }\r\n /**\r\n * Returns a value within [-0x80000000, 0x7fffffff]\r\n */\r\n int32() {\r\n return int32(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0xffffffff]\r\n */\r\n uint32() {\r\n return uint32(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0x1fffffffffffff]\r\n */\r\n uint53() {\r\n return uint53(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0x20000000000000]\r\n */\r\n uint53Full() {\r\n return uint53Full(this.engine);\r\n }\r\n /**\r\n * Returns a value within [-0x20000000000000, 0x1fffffffffffff]\r\n */\r\n int53() {\r\n return int53(this.engine);\r\n }\r\n /**\r\n * Returns a value within [-0x20000000000000, 0x20000000000000]\r\n */\r\n int53Full() {\r\n return int53Full(this.engine);\r\n }\r\n /**\r\n * Returns a value within [min, max]\r\n * @param min The minimum integer value, inclusive. No less than -0x20000000000000.\r\n * @param max The maximum integer value, inclusive. No greater than 0x20000000000000.\r\n */\r\n integer(min, max) {\r\n return integer(min, max)(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [0.0, 1.0]\r\n */\r\n realZeroToOneInclusive() {\r\n return realZeroToOneInclusive(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [0.0, 1.0)\r\n */\r\n realZeroToOneExclusive() {\r\n return realZeroToOneExclusive(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [min, max) or [min, max]\r\n * @param min The minimum floating-point value, inclusive.\r\n * @param max The maximum floating-point value.\r\n * @param inclusive If true, `max` will be inclusive.\r\n */\r\n real(min, max, inclusive = false) {\r\n return real(min, max, inclusive)(this.engine);\r\n }\r\n bool(numerator, denominator) {\r\n return bool(numerator, denominator)(this.engine);\r\n }\r\n /**\r\n * Return a random value within the provided `source` within the sliced\r\n * bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\n pick(source, begin, end) {\r\n return pick(this.engine, source, begin, end);\r\n }\r\n /**\r\n * Shuffles an array in-place\r\n * @param array The array to shuffle\r\n */\r\n shuffle(array) {\r\n return shuffle(this.engine, array);\r\n }\r\n /**\r\n * From the population array, returns an array with sampleSize elements that\r\n * are randomly chosen without repeats.\r\n * @param population An array that has items to choose a sample from\r\n * @param sampleSize The size of the result array\r\n */\r\n sample(population, sampleSize) {\r\n return sample(this.engine, population, sampleSize);\r\n }\r\n /**\r\n * Returns a value within [1, sideCount]\r\n * @param sideCount The number of sides of the die\r\n */\r\n die(sideCount) {\r\n return die(sideCount)(this.engine);\r\n }\r\n /**\r\n * Returns an array of length `dieCount` of values within [1, sideCount]\r\n * @param sideCount The number of sides of each die\r\n * @param dieCount The number of dice\r\n */\r\n dice(sideCount, dieCount) {\r\n return dice(sideCount, dieCount)(this.engine);\r\n }\r\n /**\r\n * Returns a Universally Unique Identifier Version 4.\r\n *\r\n * See http://en.wikipedia.org/wiki/Universally_unique_identifier\r\n */\r\n uuid4() {\r\n return uuid4(this.engine);\r\n }\r\n string(length, pool) {\r\n return string(pool)(this.engine, length);\r\n }\r\n /**\r\n * Returns a random string comprised of numbers or the characters `abcdef`\r\n * (or `ABCDEF`) of length `length`.\r\n * @param length Length of the result string\r\n * @param uppercase Whether the string should use `ABCDEF` instead of `abcdef`\r\n */\r\n hex(length, uppercase) {\r\n return hex(uppercase)(this.engine, length);\r\n }\r\n /**\r\n * Returns a random `Date` within the inclusive range of [`start`, `end`].\r\n * @param start The minimum `Date`\r\n * @param end The maximum `Date`\r\n */\r\n date(start, end) {\r\n return date(start, end)(this.engine);\r\n }\r\n}\n\n/**\r\n * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array\r\n */\r\nconst I32Array = (() => {\r\n try {\r\n const buffer = new ArrayBuffer(4);\r\n const view = new Int32Array(buffer);\r\n view[0] = INT32_SIZE;\r\n if (view[0] === -INT32_SIZE) {\r\n return Int32Array;\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n return Array;\r\n})();\n\nlet data = null;\r\nconst COUNT = 128;\r\nlet index = COUNT;\r\n/**\r\n * An Engine that relies on the globally-available `crypto.getRandomValues`,\r\n * which is typically available in modern browsers.\r\n *\r\n * See https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues\r\n *\r\n * If unavailable or otherwise non-functioning, then `browserCrypto` will\r\n * likely `throw` on the first call to `next()`.\r\n */\r\nconst browserCrypto = {\r\n next() {\r\n if (index >= COUNT) {\r\n if (data === null) {\r\n data = new I32Array(COUNT);\r\n }\r\n crypto.getRandomValues(data);\r\n index = 0;\r\n }\r\n return data[index++] | 0;\r\n }\r\n};\n\n/**\r\n * Returns an array of random int32 values, based on current time\r\n * and a random number engine\r\n *\r\n * @param engine an Engine to pull random values from, default `nativeMath`\r\n * @param length the length of the Array, minimum 1, default 16\r\n */\r\nfunction createEntropy(engine = nativeMath, length = 16) {\r\n const array = [];\r\n array.push(new Date().getTime() | 0);\r\n for (let i = 1; i < length; ++i) {\r\n array[i] = engine.next() | 0;\r\n }\r\n return array;\r\n}\n\n/**\r\n * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul\r\n */\r\nconst imul = (() => {\r\n try {\r\n if (Math.imul(UINT32_MAX, 5) === -5) {\r\n return Math.imul;\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n const UINT16_MAX = 0xffff;\r\n return (a, b) => {\r\n const ah = (a >>> 16) & UINT16_MAX;\r\n const al = a & UINT16_MAX;\r\n const bh = (b >>> 16) & UINT16_MAX;\r\n const bl = b & UINT16_MAX;\r\n // the shift by 0 fixes the sign on the high part\r\n // the final |0 converts the unsigned value into a signed value\r\n return (al * bl + (((ah * bl + al * bh) << 16) >>> 0)) | 0;\r\n };\r\n})();\n\nconst ARRAY_SIZE = 624;\r\nconst ARRAY_MAX = ARRAY_SIZE - 1;\r\nconst M = 397;\r\nconst ARRAY_SIZE_MINUS_M = ARRAY_SIZE - M;\r\nconst A = 0x9908b0df;\r\n/**\r\n * An Engine that is a pseudorandom number generator using the Mersenne\r\n * Twister algorithm based on the prime 2**19937 − 1\r\n *\r\n * See http://en.wikipedia.org/wiki/Mersenne_twister\r\n */\r\nclass MersenneTwister19937 {\r\n /**\r\n * MersenneTwister19937 should not be instantiated directly.\r\n * Instead, use the static methods `seed`, `seedWithArray`, or `autoSeed`.\r\n */\r\n constructor() {\r\n this.data = new I32Array(ARRAY_SIZE);\r\n this.index = 0; // integer within [0, 624]\r\n this.uses = 0;\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with an initial int32 value\r\n * @param initial the initial seed value\r\n */\r\n static seed(initial) {\r\n return new MersenneTwister19937().seed(initial);\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with zero or more int32 values\r\n * @param source A series of int32 values\r\n */\r\n static seedWithArray(source) {\r\n return new MersenneTwister19937().seedWithArray(source);\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with the current time and\r\n * a series of natively-generated random values\r\n */\r\n static autoSeed() {\r\n return MersenneTwister19937.seedWithArray(createEntropy());\r\n }\r\n /**\r\n * Returns the next int32 value of the sequence\r\n */\r\n next() {\r\n if ((this.index | 0) >= ARRAY_SIZE) {\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n const value = this.data[this.index];\r\n this.index = (this.index + 1) | 0;\r\n this.uses += 1;\r\n return temper(value) | 0;\r\n }\r\n /**\r\n * Returns the number of times that the Engine has been used.\r\n *\r\n * This can be provided to an unused MersenneTwister19937 with the same\r\n * seed, bringing it to the exact point that was left off.\r\n */\r\n getUseCount() {\r\n return this.uses;\r\n }\r\n /**\r\n * Discards one or more items from the engine\r\n * @param count The count of items to discard\r\n */\r\n discard(count) {\r\n if (count <= 0) {\r\n return this;\r\n }\r\n this.uses += count;\r\n if ((this.index | 0) >= ARRAY_SIZE) {\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n while (count + this.index > ARRAY_SIZE) {\r\n count -= ARRAY_SIZE - this.index;\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n this.index = (this.index + count) | 0;\r\n return this;\r\n }\r\n seed(initial) {\r\n let previous = 0;\r\n this.data[0] = previous = initial | 0;\r\n for (let i = 1; i < ARRAY_SIZE; i = (i + 1) | 0) {\r\n this.data[i] = previous =\r\n (imul(previous ^ (previous >>> 30), 0x6c078965) + i) | 0;\r\n }\r\n this.index = ARRAY_SIZE;\r\n this.uses = 0;\r\n return this;\r\n }\r\n seedWithArray(source) {\r\n this.seed(0x012bd6aa);\r\n seedWithArray(this.data, source);\r\n return this;\r\n }\r\n}\r\nfunction refreshData(data) {\r\n let k = 0;\r\n let tmp = 0;\r\n for (; (k | 0) < ARRAY_SIZE_MINUS_M; k = (k + 1) | 0) {\r\n tmp = (data[k] & INT32_SIZE) | (data[(k + 1) | 0] & INT32_MAX);\r\n data[k] = data[(k + M) | 0] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n }\r\n for (; (k | 0) < ARRAY_MAX; k = (k + 1) | 0) {\r\n tmp = (data[k] & INT32_SIZE) | (data[(k + 1) | 0] & INT32_MAX);\r\n data[k] =\r\n data[(k - ARRAY_SIZE_MINUS_M) | 0] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n }\r\n tmp = (data[ARRAY_MAX] & INT32_SIZE) | (data[0] & INT32_MAX);\r\n data[ARRAY_MAX] = data[M - 1] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n}\r\nfunction temper(value) {\r\n value ^= value >>> 11;\r\n value ^= (value << 7) & 0x9d2c5680;\r\n value ^= (value << 15) & 0xefc60000;\r\n return value ^ (value >>> 18);\r\n}\r\nfunction seedWithArray(data, source) {\r\n let i = 1;\r\n let j = 0;\r\n const sourceLength = source.length;\r\n let k = Math.max(sourceLength, ARRAY_SIZE) | 0;\r\n let previous = data[0] | 0;\r\n for (; (k | 0) > 0; --k) {\r\n data[i] = previous =\r\n ((data[i] ^ imul(previous ^ (previous >>> 30), 0x0019660d)) +\r\n (source[j] | 0) +\r\n (j | 0)) |\r\n 0;\r\n i = (i + 1) | 0;\r\n ++j;\r\n if ((i | 0) > ARRAY_MAX) {\r\n data[0] = data[ARRAY_MAX];\r\n i = 1;\r\n }\r\n if (j >= sourceLength) {\r\n j = 0;\r\n }\r\n }\r\n for (k = ARRAY_MAX; (k | 0) > 0; --k) {\r\n data[i] = previous =\r\n ((data[i] ^ imul(previous ^ (previous >>> 30), 0x5d588b65)) - i) | 0;\r\n i = (i + 1) | 0;\r\n if ((i | 0) > ARRAY_MAX) {\r\n data[0] = data[ARRAY_MAX];\r\n i = 1;\r\n }\r\n }\r\n data[0] = INT32_SIZE;\r\n}\n\nlet data$1 = null;\r\nconst COUNT$1 = 128;\r\nlet index$1 = COUNT$1;\r\n/**\r\n * An Engine that relies on the node-available\r\n * `require('crypto').randomBytes`, which has been available since 0.58.\r\n *\r\n * See https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback\r\n *\r\n * If unavailable or otherwise non-functioning, then `nodeCrypto` will\r\n * likely `throw` on the first call to `next()`.\r\n */\r\nconst nodeCrypto = {\r\n next() {\r\n if (index$1 >= COUNT$1) {\r\n data$1 = new Int32Array(new Int8Array(require(\"crypto\").randomBytes(4 * COUNT$1)).buffer);\r\n index$1 = 0;\r\n }\r\n return data$1[index$1++] | 0;\r\n }\r\n};\n\n/**\r\n * Returns a Distribution to random value within the provided `source`\r\n * within the sliced bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\nfunction picker(source, begin, end) {\r\n const clone = sliceArray.call(source, begin, end);\r\n if (clone.length === 0) {\r\n throw new RangeError(`Cannot pick from a source with no items`);\r\n }\r\n const distribution = integer(0, clone.length - 1);\r\n return engine => clone[distribution(engine)];\r\n}\n\nexport { Random, browserCrypto, nativeMath, MersenneTwister19937, nodeCrypto, bool, date, dice, die, hex, int32, int53, int53Full, integer, pick, picker, real, realZeroToOneExclusive, realZeroToOneInclusive, sample, shuffle, string, uint32, uint53, uint53Full, uuid4, createEntropy };\n//# sourceMappingURL=random-js.esm.js.map\n","import * as Random from 'random-js';\nimport Matrix from 'ml-matrix';\n\nexport function checkFloat(n) {\n return n > 0.0 && n <= 1.0;\n}\n\n/**\n * Select n with replacement elements on the training set and values, where n is the size of the training set.\n * @ignore\n * @param {Matrix} trainingSet\n * @param {Array} trainingValue\n * @param {number} seed - seed for the random selection, must be a 32-bit integer.\n * @return {object} with new X and y.\n */\nexport function examplesBaggingWithReplacement(\n trainingSet,\n trainingValue,\n seed,\n) {\n let engine;\n let distribution = Random.integer(0, trainingSet.rows - 1);\n if (seed === undefined) {\n engine = Random.MersenneTwister19937.autoSeed();\n } else if (Number.isInteger(seed)) {\n engine = Random.MersenneTwister19937.seed(seed);\n } else {\n throw new RangeError(\n `Expected seed must be undefined or integer not ${seed}`,\n );\n }\n\n let Xr = new Array(trainingSet.rows);\n let yr = new Array(trainingSet.rows);\n\n for (let i = 0; i < trainingSet.rows; ++i) {\n let index = distribution(engine);\n Xr[i] = trainingSet.getRow(index);\n yr[i] = trainingValue[index];\n }\n\n return {\n X: new Matrix(Xr),\n y: yr,\n };\n}\n\n/**\n * selects n features from the training set with or without replacement, returns the new training set and the indexes used.\n * @ignore\n * @param {Matrix} trainingSet\n * @param {number} n - features.\n * @param {boolean} replacement\n * @param {number} seed - seed for the random selection, must be a 32-bit integer.\n * @return {object}\n */\nexport function featureBagging(trainingSet, n, replacement, seed) {\n if (trainingSet.columns < n) {\n throw new RangeError(\n 'N should be less or equal to the number of columns of X',\n );\n }\n\n let distribution = Random.integer(0, trainingSet.columns - 1);\n let engine;\n if (seed === undefined) {\n engine = Random.MersenneTwister19937.autoSeed();\n } else if (Number.isInteger(seed)) {\n engine = Random.MersenneTwister19937.seed(seed);\n } else {\n throw new RangeError(\n `Expected seed must be undefined or integer not ${seed}`,\n );\n }\n\n let toRet = new Matrix(trainingSet.rows, n);\n\n let usedIndex;\n let index;\n if (replacement) {\n usedIndex = new Array(n);\n for (let i = 0; i < n; ++i) {\n index = distribution(engine);\n usedIndex[i] = index;\n toRet.setColumn(i, trainingSet.getColumn(index));\n }\n } else {\n usedIndex = new Set();\n index = distribution(engine);\n for (let i = 0; i < n; ++i) {\n while (usedIndex.has(index)) {\n index = distribution(engine);\n }\n toRet.setColumn(i, trainingSet.getColumn(index));\n usedIndex.add(index);\n }\n usedIndex = Array.from(usedIndex);\n }\n\n return {\n X: toRet,\n usedIndex: usedIndex,\n };\n}\n","import {\n DecisionTreeClassifier as DTClassifier,\n DecisionTreeRegression as DTRegression,\n} from 'ml-cart';\nimport {\n Matrix,\n WrapperMatrix2D,\n MatrixTransposeView,\n MatrixColumnSelectionView,\n} from 'ml-matrix';\n\nimport * as Utils from './utils';\n\n/**\n * @class RandomForestBase\n */\nexport class RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number|String} [options.maxFeatures] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement] - use replacement over the sample features.\n * @param {number} [options.seed] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators] - number of estimator to use.\n * @param {object} [options.treeOptions] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {boolean} [options.isClassifier] - boolean to check if is a classifier or regression model (used by subclasses).\n * @param {boolean} [options.useSampleBagging] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.replacement = model.replacement;\n this.maxFeatures = model.maxFeatures;\n this.nEstimators = model.nEstimators;\n this.treeOptions = model.treeOptions;\n this.isClassifier = model.isClassifier;\n this.seed = model.seed;\n this.n = model.n;\n this.indexes = model.indexes;\n this.useSampleBagging = model.useSampleBagging;\n\n let Estimator = this.isClassifier ? DTClassifier : DTRegression;\n this.estimators = model.estimators.map((est) => Estimator.load(est));\n } else {\n this.replacement = options.replacement;\n this.maxFeatures = options.maxFeatures;\n this.nEstimators = options.nEstimators;\n this.treeOptions = options.treeOptions;\n this.isClassifier = options.isClassifier;\n this.seed = options.seed;\n this.useSampleBagging = options.useSampleBagging;\n }\n }\n\n /**\n * Train the decision tree with the given training set and labels.\n * @param {Matrix|Array} trainingSet\n * @param {Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n this.maxFeatures = this.maxFeatures || trainingSet.columns;\n\n if (Utils.checkFloat(this.maxFeatures)) {\n this.n = Math.floor(trainingSet.columns * this.maxFeatures);\n } else if (Number.isInteger(this.maxFeatures)) {\n if (this.maxFeatures > trainingSet.columns) {\n throw new RangeError(\n `The maxFeatures parameter should be less than ${trainingSet.columns}`,\n );\n } else {\n this.n = this.maxFeatures;\n }\n } else {\n throw new RangeError(\n `Cannot process the maxFeatures parameter ${this.maxFeatures}`,\n );\n }\n\n let Estimator;\n if (this.isClassifier) {\n Estimator = DTClassifier;\n } else {\n Estimator = DTRegression;\n }\n\n this.estimators = new Array(this.nEstimators);\n this.indexes = new Array(this.nEstimators);\n\n for (let i = 0; i < this.nEstimators; ++i) {\n let res = this.useSampleBagging\n ? Utils.examplesBaggingWithReplacement(\n trainingSet,\n trainingValues,\n this.seed,\n )\n : { X: trainingSet, y: trainingValues };\n let X = res.X;\n let y = res.y;\n\n res = Utils.featureBagging(X, this.n, this.replacement, this.seed);\n X = res.X;\n\n this.indexes[i] = res.usedIndex;\n this.estimators[i] = new Estimator(this.treeOptions);\n this.estimators[i].train(X, y);\n }\n }\n\n /**\n * Method that returns the way the algorithm generates the predictions, for example, in classification\n * you can return the mode of all predictions retrieved by the trees, or in case of regression you can\n * use the mean or the median.\n * @abstract\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction.\n */\n // eslint-disable-next-line no-unused-vars\n selection(values) {\n throw new Error(\"Abstract method 'selection' not implemented!\");\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n let predictionValues = new Array(this.nEstimators);\n toPredict = Matrix.checkMatrix(toPredict);\n for (let i = 0; i < this.nEstimators; ++i) {\n let X = new MatrixColumnSelectionView(toPredict, this.indexes[i]); // get features for estimator\n predictionValues[i] = this.estimators[i].predict(X);\n }\n\n predictionValues = new MatrixTransposeView(\n new WrapperMatrix2D(predictionValues),\n );\n let predictions = new Array(predictionValues.rows);\n for (let i = 0; i < predictionValues.rows; ++i) {\n predictions[i] = this.selection(predictionValues.getRow(i));\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n indexes: this.indexes,\n n: this.n,\n replacement: this.replacement,\n maxFeatures: this.maxFeatures,\n nEstimators: this.nEstimators,\n treeOptions: this.treeOptions,\n isClassifier: this.isClassifier,\n seed: this.seed,\n estimators: this.estimators.map((est) => est.toJSON()),\n useSampleBagging: this.useSampleBagging,\n };\n }\n}\n","import { RandomForestBase } from './RandomForestBase';\n\nconst defaultOptions = {\n maxFeatures: 1.0,\n replacement: true,\n nEstimators: 10,\n seed: 42,\n useSampleBagging: false,\n};\n\n/**\n * @class RandomForestClassifier\n * @augments RandomForestBase\n */\nexport class RandomForestClassifier extends RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number} [options.maxFeatures=1.0] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement=true] - use replacement over the sample features.\n * @param {number} [options.seed=42] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators=10] - number of estimator to use.\n * @param {object} [options.treeOptions={}] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {boolean} [options.useSampleBagging=false] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n super(true, model.baseModel);\n } else {\n options = Object.assign({}, defaultOptions, options);\n options.isClassifier = true;\n super(options);\n }\n }\n\n /**\n * retrieve the prediction given the selection method.\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction\n */\n selection(values) {\n return mode(values);\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n let baseModel = super.toJSON();\n return {\n baseModel: baseModel,\n name: 'RFClassifier',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {RandomForestClassifier}\n */\n static load(model) {\n if (model.name !== 'RFClassifier') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new RandomForestClassifier(true, model);\n }\n}\n\n/**\n * Return the most repeated element on the array.\n * @param {Array} arr\n * @return {number} mode\n */\nfunction mode(arr) {\n return arr\n .sort(\n (a, b) =>\n arr.filter((v) => v === a).length - arr.filter((v) => v === b).length,\n )\n .pop();\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","(function(){function a(d){for(var e=0,f=d.length-1,g=void 0,h=void 0,i=void 0,j=c(e,f);!0;){if(f<=e)return d[j];if(f==e+1)return d[e]>d[f]&&b(d,e,f),d[j];for(g=c(e,f),d[g]>d[f]&&b(d,g,f),d[e]>d[f]&&b(d,e,f),d[g]>d[e]&&b(d,g,e),b(d,g,e+1),h=e+1,i=f;!0;){do h++;while(d[e]>d[h]);do i--;while(d[i]>d[e]);if(i=j&&(f=i-1)}}var b=function b(d,e,f){var _ref;return _ref=[d[f],d[e]],d[e]=_ref[0],d[f]=_ref[1],_ref},c=function c(d,e){return~~((d+e)/2)};'undefined'!=typeof module&&module.exports?module.exports=a:window.median=a})();\n","import isArray from 'is-any-array';\nimport quickSelectMedian from 'median-quickselect';\n\nfunction median(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n return quickSelectMedian(input.slice());\n}\n\nexport default median;\n","import arrayMean from 'ml-array-mean';\nimport arrayMedian from 'ml-array-median';\n\nimport { RandomForestBase } from './RandomForestBase';\n\nconst selectionMethods = {\n mean: arrayMean,\n median: arrayMedian,\n};\n\nconst defaultOptions = {\n maxFeatures: 1.0,\n replacement: false,\n nEstimators: 10,\n treeOptions: {},\n selectionMethod: 'mean',\n seed: 42,\n useSampleBagging: false,\n};\n\n/**\n * @class RandomForestRegression\n * @augments RandomForestBase\n */\nexport class RandomForestRegression extends RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number} [options.maxFeatures=1.0] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement=true] - use replacement over the sample features.\n * @param {number} [options.seed=42] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators=10] - number of estimator to use.\n * @param {object} [options.treeOptions={}] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {string} [options.selectionMethod=\"mean\"] - the way to calculate the prediction from estimators, \"mean\" and \"median\" are supported.\n * @param {boolean} [options.useSampleBagging=false] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n super(true, model.baseModel);\n this.selectionMethod = model.selectionMethod;\n } else {\n options = Object.assign({}, defaultOptions, options);\n\n if (\n !(\n options.selectionMethod === 'mean' ||\n options.selectionMethod === 'median'\n )\n ) {\n throw new RangeError(\n `Unsupported selection method ${options.selectionMethod}`,\n );\n }\n\n options.isClassifier = false;\n\n super(options);\n this.selectionMethod = options.selectionMethod;\n }\n }\n\n /**\n * retrieve the prediction given the selection method.\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction\n */\n selection(values) {\n return selectionMethods[this.selectionMethod](values);\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n let baseModel = super.toJSON();\n return {\n baseModel: baseModel,\n selectionMethod: this.selectionMethod,\n name: 'RFRegression',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {RandomForestRegression}\n */\n static load(model) {\n if (model.name !== 'RFRegression') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new RandomForestRegression(true, model);\n }\n}\n","import { Matrix, MatrixTransposeView, EVD, SVD, NIPALS } from 'ml-matrix';\n\n/**\n * Creates new PCA (Principal Component Analysis) from the dataset\n * @param {Matrix} dataset - dataset or covariance matrix.\n * @param {Object} [options]\n * @param {boolean} [options.isCovarianceMatrix=false] - true if the dataset is a covariance matrix.\n * @param {string} [options.method='SVD'] - select which method to use: SVD (default), covarianceMatrirx or NIPALS.\n * @param {number} [options.nCompNIPALS=2] - number of components to be computed with NIPALS.\n * @param {boolean} [options.center=true] - should the data be centered (subtract the mean).\n * @param {boolean} [options.scale=false] - should the data be scaled (divide by the standard deviation).\n * @param {boolean} [options.ignoreZeroVariance=false] - ignore columns with zero variance if `scale` is `true`.\n * */\nexport class PCA {\n constructor(dataset, options = {}) {\n if (dataset === true) {\n const model = options;\n this.center = model.center;\n this.scale = model.scale;\n this.means = model.means;\n this.stdevs = model.stdevs;\n this.U = Matrix.checkMatrix(model.U);\n this.S = model.S;\n this.R = model.R;\n this.excludedFeatures = model.excludedFeatures || [];\n return;\n }\n\n dataset = new Matrix(dataset);\n\n const {\n isCovarianceMatrix = false,\n method = 'SVD',\n nCompNIPALS = 2,\n center = true,\n scale = false,\n ignoreZeroVariance = false,\n } = options;\n\n this.center = center;\n this.scale = scale;\n this.means = null;\n this.stdevs = null;\n this.excludedFeatures = [];\n\n if (isCovarianceMatrix) {\n // User provided a covariance matrix instead of dataset.\n this._computeFromCovarianceMatrix(dataset);\n return;\n }\n\n this._adjust(dataset, ignoreZeroVariance);\n switch (method) {\n case 'covarianceMatrix': {\n // User provided a dataset but wants us to compute and use the covariance matrix.\n const covarianceMatrix = new MatrixTransposeView(dataset)\n .mmul(dataset)\n .div(dataset.rows - 1);\n this._computeFromCovarianceMatrix(covarianceMatrix);\n break;\n }\n case 'NIPALS': {\n this._computeWithNIPALS(dataset, nCompNIPALS);\n break;\n }\n case 'SVD': {\n const svd = new SVD(dataset, {\n computeLeftSingularVectors: false,\n computeRightSingularVectors: true,\n autoTranspose: true,\n });\n\n this.U = svd.rightSingularVectors;\n\n const singularValues = svd.diagonal;\n const eigenvalues = [];\n for (const singularValue of singularValues) {\n eigenvalues.push((singularValue * singularValue) / (dataset.rows - 1));\n }\n this.S = eigenvalues;\n break;\n }\n default: {\n throw new Error(`unknown method: ${method}`);\n }\n }\n }\n\n /**\n * Load a PCA model from JSON\n * @param {Object} model\n * @return {PCA}\n */\n static load(model) {\n if (typeof model.name !== 'string') {\n throw new TypeError('model must have a name property');\n }\n if (model.name !== 'PCA') {\n throw new RangeError(`invalid model: ${model.name}`);\n }\n return new PCA(true, model);\n }\n\n /**\n * Project the dataset into the PCA space\n * @param {Matrix} dataset\n * @param {Object} options\n * @return {Matrix} dataset projected in the PCA space\n */\n predict(dataset, options = {}) {\n const { nComponents = this.U.columns } = options;\n dataset = new Matrix(dataset);\n if (this.center) {\n dataset.subRowVector(this.means);\n if (this.scale) {\n for (let i of this.excludedFeatures) {\n dataset.removeColumn(i);\n }\n dataset.divRowVector(this.stdevs);\n }\n }\n var predictions = dataset.mmul(this.U);\n return predictions.subMatrix(0, predictions.rows - 1, 0, nComponents - 1);\n }\n\n /**\n * Calculates the inverse PCA transform\n * @param {Matrix} dataset\n * @return {Matrix} dataset projected in the PCA space\n */\n invert(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n\n var inverse = dataset.mmul(this.U.transpose());\n\n if (this.center) {\n if (this.scale) {\n inverse.mulRowVector(this.stdevs);\n }\n inverse.addRowVector(this.means);\n }\n\n return inverse;\n }\n\n\n /**\n * Returns the proportion of variance for each component\n * @return {[number]}\n */\n getExplainedVariance() {\n var sum = 0;\n for (const s of this.S) {\n sum += s;\n }\n return this.S.map((value) => value / sum);\n }\n\n /**\n * Returns the cumulative proportion of variance\n * @return {[number]}\n */\n getCumulativeVariance() {\n var explained = this.getExplainedVariance();\n for (var i = 1; i < explained.length; i++) {\n explained[i] += explained[i - 1];\n }\n return explained;\n }\n\n /**\n * Returns the Eigenvectors of the covariance matrix\n * @returns {Matrix}\n */\n getEigenvectors() {\n return this.U;\n }\n\n /**\n * Returns the Eigenvalues (on the diagonal)\n * @returns {[number]}\n */\n getEigenvalues() {\n return this.S;\n }\n\n /**\n * Returns the standard deviations of the principal components\n * @returns {[number]}\n */\n getStandardDeviations() {\n return this.S.map((x) => Math.sqrt(x));\n }\n\n /**\n * Returns the loadings matrix\n * @return {Matrix}\n */\n getLoadings() {\n return this.U.transpose();\n }\n\n /**\n * Export the current model to a JSON object\n * @return {Object} model\n */\n toJSON() {\n return {\n name: 'PCA',\n center: this.center,\n scale: this.scale,\n means: this.means,\n stdevs: this.stdevs,\n U: this.U,\n S: this.S,\n excludedFeatures: this.excludedFeatures,\n };\n }\n\n _adjust(dataset, ignoreZeroVariance) {\n if (this.center) {\n const mean = dataset.mean('column');\n const stdevs = this.scale\n ? dataset.standardDeviation('column', { mean })\n : null;\n this.means = mean;\n dataset.subRowVector(mean);\n if (this.scale) {\n for (let i = 0; i < stdevs.length; i++) {\n if (stdevs[i] === 0) {\n if (ignoreZeroVariance) {\n dataset.removeColumn(i);\n stdevs.splice(i, 1);\n this.excludedFeatures.push(i);\n i--;\n } else {\n throw new RangeError(\n `Cannot scale the dataset (standard deviation is zero at index ${i}`,\n );\n }\n }\n }\n this.stdevs = stdevs;\n dataset.divRowVector(stdevs);\n }\n }\n }\n\n _computeFromCovarianceMatrix(dataset) {\n const evd = new EVD(dataset, { assumeSymmetric: true });\n this.U = evd.eigenvectorMatrix;\n this.U.flipRows();\n this.S = evd.realEigenvalues;\n this.S.reverse();\n }\n\n _computeWithNIPALS(dataset, nCompNIPALS) {\n this.U = new Matrix(nCompNIPALS, dataset.columns);\n this.S = [];\n\n let x = dataset;\n for (let i = 0; i < nCompNIPALS; i++) {\n let dc = new NIPALS(x);\n\n this.U.setRow(i, dc.w.transpose());\n this.S.push(Math.pow(dc.s.get(0, 0), 2));\n\n x = dc.xResidual;\n }\n this.U = this.U.transpose(); // to be compatible with API\n }\n}\n","export function squaredEuclidean(p, q) {\r\n let d = 0;\r\n for (let i = 0; i < p.length; i++) {\r\n d += (p[i] - q[i]) * (p[i] - q[i]);\r\n }\r\n return d;\r\n}\r\nexport function euclidean(p, q) {\r\n return Math.sqrt(squaredEuclidean(p, q));\r\n}\r\n","/**\n * Computes a distance/similarity matrix given an array of data and a distance/similarity function.\n * @param {Array} data An array of data\n * @param {function} distanceFn A function that accepts two arguments and computes a distance/similarity between them\n * @return {Array} The distance/similarity matrix. The matrix is square and has a size equal to the length of\n * the data array\n */\nexport default function distanceMatrix(data, distanceFn) {\n const result = getMatrix(data.length);\n\n // Compute upper distance matrix\n for (let i = 0; i < data.length; i++) {\n for (let j = 0; j <= i; j++) {\n result[i][j] = distanceFn(data[i], data[j]);\n result[j][i] = result[i][j];\n }\n }\n\n return result;\n}\n\nfunction getMatrix(size) {\n const matrix = [];\n for (let i = 0; i < size; i++) {\n const row = [];\n matrix.push(row);\n for (let j = 0; j < size; j++) {\n row.push(0);\n }\n }\n return matrix;\n}\n","// Generated by CoffeeScript 1.8.0\n(function() {\n var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup;\n\n floor = Math.floor, min = Math.min;\n\n\n /*\n Default comparison function to be used\n */\n\n defaultCmp = function(x, y) {\n if (x < y) {\n return -1;\n }\n if (x > y) {\n return 1;\n }\n return 0;\n };\n\n\n /*\n Insert item x in list a, and keep it sorted assuming a is sorted.\n \n If x is already in a, insert it to the right of the rightmost x.\n \n Optional args lo (default 0) and hi (default a.length) bound the slice\n of a to be searched.\n */\n\n insort = function(a, x, lo, hi, cmp) {\n var mid;\n if (lo == null) {\n lo = 0;\n }\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (lo < 0) {\n throw new Error('lo must be non-negative');\n }\n if (hi == null) {\n hi = a.length;\n }\n while (lo < hi) {\n mid = floor((lo + hi) / 2);\n if (cmp(x, a[mid]) < 0) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n return ([].splice.apply(a, [lo, lo - lo].concat(x)), x);\n };\n\n\n /*\n Push item onto heap, maintaining the heap invariant.\n */\n\n heappush = function(array, item, cmp) {\n if (cmp == null) {\n cmp = defaultCmp;\n }\n array.push(item);\n return _siftdown(array, 0, array.length - 1, cmp);\n };\n\n\n /*\n Pop the smallest item off the heap, maintaining the heap invariant.\n */\n\n heappop = function(array, cmp) {\n var lastelt, returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n lastelt = array.pop();\n if (array.length) {\n returnitem = array[0];\n array[0] = lastelt;\n _siftup(array, 0, cmp);\n } else {\n returnitem = lastelt;\n }\n return returnitem;\n };\n\n\n /*\n Pop and return the current smallest value, and add the new item.\n \n This is more efficient than heappop() followed by heappush(), and can be\n more appropriate when using a fixed size heap. Note that the value\n returned may be larger than item! That constrains reasonable use of\n this routine unless written as part of a conditional replacement:\n if item > array[0]\n item = heapreplace(array, item)\n */\n\n heapreplace = function(array, item, cmp) {\n var returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n returnitem = array[0];\n array[0] = item;\n _siftup(array, 0, cmp);\n return returnitem;\n };\n\n\n /*\n Fast version of a heappush followed by a heappop.\n */\n\n heappushpop = function(array, item, cmp) {\n var _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (array.length && cmp(array[0], item) < 0) {\n _ref = [array[0], item], item = _ref[0], array[0] = _ref[1];\n _siftup(array, 0, cmp);\n }\n return item;\n };\n\n\n /*\n Transform list into a heap, in-place, in O(array.length) time.\n */\n\n heapify = function(array, cmp) {\n var i, _i, _j, _len, _ref, _ref1, _results, _results1;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n _ref1 = (function() {\n _results1 = [];\n for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); }\n return _results1;\n }).apply(this).reverse();\n _results = [];\n for (_i = 0, _len = _ref1.length; _i < _len; _i++) {\n i = _ref1[_i];\n _results.push(_siftup(array, i, cmp));\n }\n return _results;\n };\n\n\n /*\n Update the position of the given item in the heap.\n This function should be called every time the item is being modified.\n */\n\n updateItem = function(array, item, cmp) {\n var pos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n pos = array.indexOf(item);\n if (pos === -1) {\n return;\n }\n _siftdown(array, 0, pos, cmp);\n return _siftup(array, pos, cmp);\n };\n\n\n /*\n Find the n largest elements in a dataset.\n */\n\n nlargest = function(array, n, cmp) {\n var elem, result, _i, _len, _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n result = array.slice(0, n);\n if (!result.length) {\n return result;\n }\n heapify(result, cmp);\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n heappushpop(result, elem, cmp);\n }\n return result.sort(cmp).reverse();\n };\n\n\n /*\n Find the n smallest elements in a dataset.\n */\n\n nsmallest = function(array, n, cmp) {\n var elem, i, los, result, _i, _j, _len, _ref, _ref1, _results;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (n * 10 <= array.length) {\n result = array.slice(0, n).sort(cmp);\n if (!result.length) {\n return result;\n }\n los = result[result.length - 1];\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n if (cmp(elem, los) < 0) {\n insort(result, elem, 0, null, cmp);\n result.pop();\n los = result[result.length - 1];\n }\n }\n return result;\n }\n heapify(array, cmp);\n _results = [];\n for (i = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {\n _results.push(heappop(array, cmp));\n }\n return _results;\n };\n\n _siftdown = function(array, startpos, pos, cmp) {\n var newitem, parent, parentpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n newitem = array[pos];\n while (pos > startpos) {\n parentpos = (pos - 1) >> 1;\n parent = array[parentpos];\n if (cmp(newitem, parent) < 0) {\n array[pos] = parent;\n pos = parentpos;\n continue;\n }\n break;\n }\n return array[pos] = newitem;\n };\n\n _siftup = function(array, pos, cmp) {\n var childpos, endpos, newitem, rightpos, startpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n endpos = array.length;\n startpos = pos;\n newitem = array[pos];\n childpos = 2 * pos + 1;\n while (childpos < endpos) {\n rightpos = childpos + 1;\n if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {\n childpos = rightpos;\n }\n array[pos] = array[childpos];\n pos = childpos;\n childpos = 2 * pos + 1;\n }\n array[pos] = newitem;\n return _siftdown(array, startpos, pos, cmp);\n };\n\n Heap = (function() {\n Heap.push = heappush;\n\n Heap.pop = heappop;\n\n Heap.replace = heapreplace;\n\n Heap.pushpop = heappushpop;\n\n Heap.heapify = heapify;\n\n Heap.updateItem = updateItem;\n\n Heap.nlargest = nlargest;\n\n Heap.nsmallest = nsmallest;\n\n function Heap(cmp) {\n this.cmp = cmp != null ? cmp : defaultCmp;\n this.nodes = [];\n }\n\n Heap.prototype.push = function(x) {\n return heappush(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pop = function() {\n return heappop(this.nodes, this.cmp);\n };\n\n Heap.prototype.peek = function() {\n return this.nodes[0];\n };\n\n Heap.prototype.contains = function(x) {\n return this.nodes.indexOf(x) !== -1;\n };\n\n Heap.prototype.replace = function(x) {\n return heapreplace(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pushpop = function(x) {\n return heappushpop(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.heapify = function() {\n return heapify(this.nodes, this.cmp);\n };\n\n Heap.prototype.updateItem = function(x) {\n return updateItem(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.clear = function() {\n return this.nodes = [];\n };\n\n Heap.prototype.empty = function() {\n return this.nodes.length === 0;\n };\n\n Heap.prototype.size = function() {\n return this.nodes.length;\n };\n\n Heap.prototype.clone = function() {\n var heap;\n heap = new Heap();\n heap.nodes = this.nodes.slice(0);\n return heap;\n };\n\n Heap.prototype.toArray = function() {\n return this.nodes.slice(0);\n };\n\n Heap.prototype.insert = Heap.prototype.push;\n\n Heap.prototype.top = Heap.prototype.peek;\n\n Heap.prototype.front = Heap.prototype.peek;\n\n Heap.prototype.has = Heap.prototype.contains;\n\n Heap.prototype.copy = Heap.prototype.clone;\n\n return Heap;\n\n })();\n\n (function(root, factory) {\n if (typeof define === 'function' && define.amd) {\n return define([], factory);\n } else if (typeof exports === 'object') {\n return module.exports = factory();\n } else {\n return root.Heap = factory();\n }\n })(this, function() {\n return Heap;\n });\n\n}).call(this);\n","module.exports = require('./lib/heap');\n","import Heap from 'heap';\n\nexport default class Cluster {\n constructor() {\n this.children = [];\n this.height = 0;\n this.size = 1;\n this.index = -1;\n this.isLeaf = false;\n }\n\n /**\n * Creates an array of clusters where the maximum height is smaller than the threshold\n * @param {number} threshold\n * @return {Array}\n */\n cut(threshold) {\n if (typeof threshold !== 'number') {\n throw new TypeError('threshold must be a number');\n }\n if (threshold < 0) {\n throw new RangeError('threshold must be a positive number');\n }\n let list = [this];\n const ans = [];\n while (list.length > 0) {\n const aux = list.shift();\n if (threshold >= aux.height) {\n ans.push(aux);\n } else {\n list = list.concat(aux.children);\n }\n }\n return ans;\n }\n\n /**\n * Merge the leaves in the minimum way to have `groups` number of clusters.\n * @param {number} groups - Them number of children the first level of the tree should have.\n * @return {Cluster}\n */\n group(groups) {\n if (!Number.isInteger(groups) || groups < 1) {\n throw new RangeError('groups must be a positive integer');\n }\n\n const heap = new Heap((a, b) => {\n return b.height - a.height;\n });\n\n heap.push(this);\n\n while (heap.size() < groups) {\n var first = heap.pop();\n if (first.children.length === 0) {\n break;\n }\n first.children.forEach((child) => heap.push(child));\n }\n\n var root = new Cluster();\n root.children = heap.toArray();\n root.height = this.height;\n\n return root;\n }\n\n /**\n * Traverses the tree depth-first and calls the provided callback with each individual node\n * @param {function} cb - The callback to be called on each node encounter\n */\n traverse(cb) {\n function visit(root, callback) {\n callback(root);\n if (root.children) {\n for (const child of root.children) {\n visit(child, callback);\n }\n }\n }\n visit(this, cb);\n }\n\n /**\n * Returns a list of indices for all the leaves of this cluster.\n * The list is ordered in such a way that a dendrogram could be drawn without crossing branches.\n * @returns {Array}\n */\n indices() {\n const result = [];\n this.traverse((cluster) => {\n if (cluster.isLeaf) {\n result.push(cluster.index);\n }\n });\n return result;\n }\n}\n","import { euclidean } from 'ml-distance-euclidean';\nimport getDistanceMatrix from 'ml-distance-matrix';\nimport { Matrix } from 'ml-matrix';\n\nimport Cluster from './Cluster';\n\nfunction singleLink(dKI, dKJ) {\n return Math.min(dKI, dKJ);\n}\n\nfunction completeLink(dKI, dKJ) {\n return Math.max(dKI, dKJ);\n}\n\nfunction averageLink(dKI, dKJ, dIJ, ni, nj) {\n const ai = ni / (ni + nj);\n const aj = nj / (ni + nj);\n return ai * dKI + aj * dKJ;\n}\n\nfunction weightedAverageLink(dKI, dKJ) {\n return (dKI + dKJ) / 2;\n}\n\nfunction centroidLink(dKI, dKJ, dIJ, ni, nj) {\n const ai = ni / (ni + nj);\n const aj = nj / (ni + nj);\n const b = -(ni * nj) / (ni + nj) ** 2;\n return ai * dKI + aj * dKJ + b * dIJ;\n}\n\nfunction medianLink(dKI, dKJ, dIJ) {\n return dKI / 2 + dKJ / 2 - dIJ / 4;\n}\n\nfunction wardLink(dKI, dKJ, dIJ, ni, nj, nk) {\n const ai = (ni + nk) / (ni + nj + nk);\n const aj = (nj + nk) / (ni + nj + nk);\n const b = -nk / (ni + nj + nk);\n return ai * dKI + aj * dKJ + b * dIJ;\n}\n\nfunction wardLink2(dKI, dKJ, dIJ, ni, nj, nk) {\n const ai = (ni + nk) / (ni + nj + nk);\n const aj = (nj + nk) / (ni + nj + nk);\n const b = -nk / (ni + nj + nk);\n return Math.sqrt(ai * dKI * dKI + aj * dKJ * dKJ + b * dIJ * dIJ);\n}\n\n/**\n * Continuously merge nodes that have the least dissimilarity\n * @param {Array>} data - Array of points to be clustered\n * @param {object} [options]\n * @param {Function} [options.distanceFunction]\n * @param {string} [options.method] - Default: `'complete'`\n * @param {boolean} [options.isDistanceMatrix] - Is the input already a distance matrix?\n * @constructor\n */\nexport function agnes(data, options = {}) {\n const {\n distanceFunction = euclidean,\n method = 'complete',\n isDistanceMatrix = false,\n } = options;\n\n let updateFunc;\n if (!isDistanceMatrix) {\n data = getDistanceMatrix(data, distanceFunction);\n }\n let distanceMatrix = new Matrix(data);\n const numLeaves = distanceMatrix.rows;\n\n // allows to use a string or a given function\n if (typeof method === 'string') {\n switch (method.toLowerCase()) {\n case 'single':\n updateFunc = singleLink;\n break;\n case 'complete':\n updateFunc = completeLink;\n break;\n case 'average':\n case 'upgma':\n updateFunc = averageLink;\n break;\n case 'wpgma':\n updateFunc = weightedAverageLink;\n break;\n case 'centroid':\n case 'upgmc':\n updateFunc = centroidLink;\n break;\n case 'median':\n case 'wpgmc':\n updateFunc = medianLink;\n break;\n case 'ward':\n updateFunc = wardLink;\n break;\n case 'ward2':\n updateFunc = wardLink2;\n break;\n default:\n throw new RangeError(`unknown clustering method: ${method}`);\n }\n } else if (typeof method !== 'function') {\n throw new TypeError('method must be a string or function');\n }\n\n let clusters = [];\n for (let i = 0; i < numLeaves; i++) {\n const cluster = new Cluster();\n cluster.isLeaf = true;\n cluster.index = i;\n clusters.push(cluster);\n }\n\n for (let n = 0; n < numLeaves - 1; n++) {\n const [row, column, distance] = getSmallestDistance(distanceMatrix);\n const cluster1 = clusters[row];\n const cluster2 = clusters[column];\n const newCluster = new Cluster();\n newCluster.size = cluster1.size + cluster2.size;\n newCluster.children.push(cluster1, cluster2);\n newCluster.height = distance;\n\n const newClusters = [newCluster];\n const newDistanceMatrix = new Matrix(\n distanceMatrix.rows - 1,\n distanceMatrix.rows - 1,\n );\n const previous = (newIndex) =>\n getPreviousIndex(newIndex, Math.min(row, column), Math.max(row, column));\n\n for (let i = 1; i < newDistanceMatrix.rows; i++) {\n const prevI = previous(i);\n const prevICluster = clusters[prevI];\n newClusters.push(prevICluster);\n for (let j = 0; j < i; j++) {\n if (j === 0) {\n const dKI = distanceMatrix.get(row, prevI);\n const dKJ = distanceMatrix.get(prevI, column);\n const val = updateFunc(\n dKI,\n dKJ,\n distance,\n cluster1.size,\n cluster2.size,\n prevICluster.size,\n );\n newDistanceMatrix.set(i, j, val);\n newDistanceMatrix.set(j, i, val);\n } else {\n // Just copy distance from previous matrix\n const val = distanceMatrix.get(prevI, previous(j));\n newDistanceMatrix.set(i, j, val);\n newDistanceMatrix.set(j, i, val);\n }\n }\n }\n\n clusters = newClusters;\n distanceMatrix = newDistanceMatrix;\n }\n\n return clusters[0];\n}\n\nfunction getSmallestDistance(distance) {\n let smallest = Infinity;\n let smallestI = 0;\n let smallestJ = 0;\n for (let i = 1; i < distance.rows; i++) {\n for (let j = 0; j < i; j++) {\n if (distance.get(i, j) < smallest) {\n smallest = distance.get(i, j);\n smallestI = i;\n smallestJ = j;\n }\n }\n }\n return [smallestI, smallestJ, smallest];\n}\n\nfunction getPreviousIndex(newIndex, prev1, prev2) {\n newIndex -= 1;\n if (newIndex >= prev1) newIndex++;\n if (newIndex >= prev2) newIndex++;\n return newIndex;\n}\n","export * from './agnes';\n// export * from './diana';\n// export * from './birch';\n// export * './cure';\n// export * from './chameleon';\n","'use strict';\nimport { squaredEuclidean } from 'ml-distance-euclidean';\nconst defaultOptions = {\n distanceFunction: squaredEuclidean\n};\nexport default function nearestVector(listVectors, vector, options = defaultOptions) {\n const distanceFunction = options.distanceFunction || defaultOptions.distanceFunction;\n const similarityFunction = options.similarityFunction || defaultOptions.similarityFunction;\n let vectorIndex = -1;\n if (typeof similarityFunction === 'function') {\n // maximum similarity\n let maxSim = Number.MIN_VALUE;\n for (let j = 0; j < listVectors.length; j++) {\n const sim = similarityFunction(vector, listVectors[j]);\n if (sim > maxSim) {\n maxSim = sim;\n vectorIndex = j;\n }\n }\n }\n else if (typeof distanceFunction === 'function') {\n // minimum distance\n let minDist = Number.MAX_VALUE;\n for (let i = 0; i < listVectors.length; i++) {\n const dist = distanceFunction(vector, listVectors[i]);\n if (dist < minDist) {\n minDist = dist;\n vectorIndex = i;\n }\n }\n }\n else {\n throw new Error(\"A similarity or distance function it's required\");\n }\n return vectorIndex;\n}\nexport function findNearestVector(vectorList, vector, options = defaultOptions) {\n const index = nearestVector(vectorList, vector, options);\n return vectorList[index];\n}\n","import nearestVector from 'ml-nearest-vector';\n\n/**\n * Calculates the distance matrix for a given array of points\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @param {function} distance - Distance function to use between the points\n * @return {Array>} - matrix with the distance values\n */\nexport function calculateDistanceMatrix(data, distance) {\n var distanceMatrix = new Array(data.length);\n for (var i = 0; i < data.length; ++i) {\n for (var j = i; j < data.length; ++j) {\n if (!distanceMatrix[i]) {\n distanceMatrix[i] = new Array(data.length);\n }\n if (!distanceMatrix[j]) {\n distanceMatrix[j] = new Array(data.length);\n }\n const dist = distance(data[i], data[j]);\n distanceMatrix[i][j] = dist;\n distanceMatrix[j][i] = dist;\n }\n }\n return distanceMatrix;\n}\n\n/**\n * Updates the cluster identifier based in the new data\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @param {Array>} centers - the K centers in format [x,y,z,...]\n * @param {Array } clusterID - the cluster identifier for each data dot\n * @param {function} distance - Distance function to use between the points\n * @return {Array} the cluster identifier for each data dot\n */\nexport function updateClusterID(data, centers, clusterID, distance) {\n for (var i = 0; i < data.length; i++) {\n clusterID[i] = nearestVector(centers, data[i], {\n distanceFunction: distance\n });\n }\n return clusterID;\n}\n\n/**\n * Update the center values based in the new configurations of the clusters\n * @ignore\n * @param {Array>} prevCenters - Centroids from the previous iteration\n * @param {Array >} data - the [x,y,z,...] points to cluster\n * @param {Array } clusterID - the cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @return {Array} he K centers in format [x,y,z,...]\n */\nexport function updateCenters(prevCenters, data, clusterID, K) {\n const nDim = data[0].length;\n\n // copy previous centers\n var centers = new Array(K);\n var centersLen = new Array(K);\n for (var i = 0; i < K; i++) {\n centers[i] = new Array(nDim);\n centersLen[i] = 0;\n for (var j = 0; j < nDim; j++) {\n centers[i][j] = 0;\n }\n }\n\n // add the value for all dimensions of the point\n for (var l = 0; l < data.length; l++) {\n centersLen[clusterID[l]]++;\n for (var dim = 0; dim < nDim; dim++) {\n centers[clusterID[l]][dim] += data[l][dim];\n }\n }\n\n // divides by length\n for (var id = 0; id < K; id++) {\n for (var d = 0; d < nDim; d++) {\n if (centersLen[id]) {\n centers[id][d] /= centersLen[id];\n } else {\n centers[id][d] = prevCenters[id][d];\n }\n }\n }\n return centers;\n}\n\n/**\n * The centers have moved more than the tolerance value?\n * @ignore\n * @param {Array>} centers - the K centers in format [x,y,z,...]\n * @param {Array>} oldCenters - the K old centers in format [x,y,z,...]\n * @param {function} distanceFunction - Distance function to use between the points\n * @param {number} tolerance - Allowed distance for the centroids to move\n * @return {boolean}\n */\nexport function hasConverged(centers, oldCenters, distanceFunction, tolerance) {\n for (var i = 0; i < centers.length; i++) {\n if (distanceFunction(centers[i], oldCenters[i]) > tolerance) {\n return false;\n }\n }\n return true;\n}\n","const LOOP = 8;\nconst FLOAT_MUL = 1 / 16777216;\nconst sh1 = 15;\nconst sh2 = 18;\nconst sh3 = 11;\nfunction multiply_uint32(n, m) {\n n >>>= 0;\n m >>>= 0;\n const nlo = n & 0xffff;\n const nhi = n - nlo;\n return (((nhi * m) >>> 0) + nlo * m) >>> 0;\n}\nexport default class XSadd {\n constructor(seed = Date.now()) {\n this.state = new Uint32Array(4);\n this.init(seed);\n this.random = this.getFloat.bind(this);\n }\n /**\n * Returns a 32-bit integer r (0 <= r < 2^32)\n */\n getUint32() {\n this.nextState();\n return (this.state[3] + this.state[2]) >>> 0;\n }\n /**\n * Returns a floating point number r (0.0 <= r < 1.0)\n */\n getFloat() {\n return (this.getUint32() >>> 8) * FLOAT_MUL;\n }\n init(seed) {\n if (!Number.isInteger(seed)) {\n throw new TypeError('seed must be an integer');\n }\n this.state[0] = seed;\n this.state[1] = 0;\n this.state[2] = 0;\n this.state[3] = 0;\n for (let i = 1; i < LOOP; i++) {\n this.state[i & 3] ^=\n (i +\n multiply_uint32(1812433253, this.state[(i - 1) & 3] ^ ((this.state[(i - 1) & 3] >>> 30) >>> 0))) >>>\n 0;\n }\n this.periodCertification();\n for (let i = 0; i < LOOP; i++) {\n this.nextState();\n }\n }\n periodCertification() {\n if (this.state[0] === 0 &&\n this.state[1] === 0 &&\n this.state[2] === 0 &&\n this.state[3] === 0) {\n this.state[0] = 88; // X\n this.state[1] = 83; // S\n this.state[2] = 65; // A\n this.state[3] = 68; // D\n }\n }\n nextState() {\n let t = this.state[0];\n t ^= t << sh1;\n t ^= t >>> sh2;\n t ^= this.state[3] << sh3;\n this.state[0] = this.state[1];\n this.state[1] = this.state[2];\n this.state[2] = this.state[3];\n this.state[3] = t;\n }\n}\n","const PROB_TOLERANCE = 0.00000001;\nfunction randomChoice(values, options = {}, random = Math.random) {\n const { size = 1, replace = false, probabilities } = options;\n let valuesArr;\n let cumSum;\n if (typeof values === 'number') {\n valuesArr = getArray(values);\n }\n else {\n valuesArr = values.slice();\n }\n if (probabilities) {\n if (!replace) {\n throw new Error('choice with probabilities and no replacement is not implemented');\n }\n // check input is sane\n if (probabilities.length !== valuesArr.length) {\n throw new Error('the length of probabilities option should be equal to the number of choices');\n }\n cumSum = [probabilities[0]];\n for (let i = 1; i < probabilities.length; i++) {\n cumSum[i] = cumSum[i - 1] + probabilities[i];\n }\n if (Math.abs(1 - cumSum[cumSum.length - 1]) > PROB_TOLERANCE) {\n throw new Error(`probabilities should sum to 1, but instead sums to ${cumSum[cumSum.length - 1]}`);\n }\n }\n if (replace === false && size > valuesArr.length) {\n throw new Error('size option is too large');\n }\n const result = [];\n for (let i = 0; i < size; i++) {\n const index = randomIndex(valuesArr.length, random, cumSum);\n result.push(valuesArr[index]);\n if (!replace) {\n valuesArr.splice(index, 1);\n }\n }\n return result;\n}\nfunction getArray(n) {\n const arr = [];\n for (let i = 0; i < n; i++) {\n arr.push(i);\n }\n return arr;\n}\nfunction randomIndex(n, random, cumSum) {\n const rand = random();\n if (!cumSum) {\n return Math.floor(rand * n);\n }\n else {\n let idx = 0;\n while (rand > cumSum[idx]) {\n idx++;\n }\n return idx;\n }\n}\nexport default randomChoice;\n","// tslint:disable-next-line\nimport XSAdd from 'ml-xsadd';\nimport choice from './choice';\n/**\n * @classdesc Random class\n */\nexport default class Random {\n /**\n * @param [seedOrRandom=Math.random] - Control the random number generator used by the Random class instance. Pass a random number generator function with a uniform distribution over the half-open interval [0, 1[. If seed will pass it to ml-xsadd to create a seeded random number generator. If undefined will use Math.random.\n */\n constructor(seedOrRandom = Math.random) {\n if (typeof seedOrRandom === 'number') {\n const xsadd = new XSAdd(seedOrRandom);\n this.randomGenerator = xsadd.random;\n }\n else {\n this.randomGenerator = seedOrRandom;\n }\n }\n choice(values, options) {\n if (typeof values === 'number') {\n return choice(values, options, this.randomGenerator);\n }\n return choice(values, options, this.randomGenerator);\n }\n /**\n * Draw a random number from a uniform distribution on [0,1)\n * @return The random number\n */\n random() {\n return this.randomGenerator();\n }\n /**\n * Draw a random integer from a uniform distribution on [low, high). If only low is specified, the number is drawn on [0, low)\n * @param low - The lower bound of the uniform distribution interval.\n * @param high - The higher bound of the uniform distribution interval.\n */\n randInt(low, high) {\n if (high === undefined) {\n high = low;\n low = 0;\n }\n return low + Math.floor(this.randomGenerator() * (high - low));\n }\n /**\n * Draw several random number from a uniform distribution on [0, 1)\n * @param size - The number of number to draw\n * @return - The list of drawn numbers.\n */\n randomSample(size) {\n const result = [];\n for (let i = 0; i < size; i++) {\n result.push(this.random());\n }\n return result;\n }\n}\n","import Random from 'ml-random';\nimport { squaredEuclidean } from 'ml-distance-euclidean';\nimport { Matrix } from 'ml-matrix';\n\n/**\n * Choose K different random points from the original data\n * @ignore\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - number of clusters\n * @param {number} seed - seed for random number generation\n * @return {Array>} - Initial random points\n */\nexport function random(data, K, seed) {\n const random = new Random(seed);\n return random.choice(data, { size: K });\n}\n\n/**\n * Chooses the most distant points to a first random pick\n * @ignore\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - number of clusters\n * @param {Array>} distanceMatrix - matrix with the distance values\n * @param {number} seed - seed for random number generation\n * @return {Array>} - Initial random points\n */\nexport function mostDistant(data, K, distanceMatrix, seed) {\n const random = new Random(seed);\n var ans = new Array(K);\n // chooses a random point as initial cluster\n ans[0] = Math.floor(random.random() * data.length);\n\n if (K > 1) {\n // chooses the more distant point\n var maxDist = { dist: -1, index: -1 };\n for (var l = 0; l < data.length; ++l) {\n if (distanceMatrix[ans[0]][l] > maxDist.dist) {\n maxDist.dist = distanceMatrix[ans[0]][l];\n maxDist.index = l;\n }\n }\n ans[1] = maxDist.index;\n\n if (K > 2) {\n // chooses the set of points that maximises the min distance\n for (var k = 2; k < K; ++k) {\n var center = { dist: -1, index: -1 };\n for (var m = 0; m < data.length; ++m) {\n // minimum distance to centers\n var minDistCent = { dist: Number.MAX_VALUE, index: -1 };\n for (var n = 0; n < k; ++n) {\n if (\n distanceMatrix[n][m] < minDistCent.dist &&\n ans.indexOf(m) === -1\n ) {\n minDistCent = {\n dist: distanceMatrix[n][m],\n index: m\n };\n }\n }\n\n if (\n minDistCent.dist !== Number.MAX_VALUE &&\n minDistCent.dist > center.dist\n ) {\n center = Object.assign({}, minDistCent);\n }\n }\n\n ans[k] = center.index;\n }\n }\n }\n\n return ans.map((index) => data[index]);\n}\n\n// Implementation inspired from scikit\nexport function kmeanspp(X, K, options = {}) {\n X = new Matrix(X);\n const nSamples = X.rows;\n const random = new Random(options.seed);\n // Set the number of trials\n const centers = [];\n const localTrials = options.localTrials || 2 + Math.floor(Math.log(K));\n\n // Pick the first center at random from the dataset\n const firstCenterIdx = random.randInt(nSamples);\n centers.push(X.getRow(firstCenterIdx));\n\n // Init closest distances\n let closestDistSquared = new Matrix(1, X.rows);\n for (let i = 0; i < X.rows; i++) {\n closestDistSquared.set(0, i, squaredEuclidean(X.getRow(i), centers[0]));\n }\n let cumSumClosestDistSquared = [cumSum(closestDistSquared.getRow(0))];\n const factor = 1 / cumSumClosestDistSquared[0][nSamples - 1];\n let probabilities = Matrix.mul(closestDistSquared, factor);\n\n // Iterate over the remaining centers\n for (let i = 1; i < K; i++) {\n const candidateIdx = random.choice(nSamples, {\n replace: true,\n size: localTrials,\n probabilities: probabilities[0]\n });\n\n const candidates = X.selection(candidateIdx, range(X.columns));\n const distanceToCandidates = euclideanDistances(candidates, X);\n\n let bestCandidate;\n let bestPot;\n let bestDistSquared;\n\n for (let j = 0; j < localTrials; j++) {\n const newDistSquared = Matrix.min(closestDistSquared, [distanceToCandidates.getRow(j)]);\n const newPot = newDistSquared.sum();\n if (bestCandidate === undefined || newPot < bestPot) {\n bestCandidate = candidateIdx[j];\n bestPot = newPot;\n bestDistSquared = newDistSquared;\n }\n }\n centers[i] = X.getRow(bestCandidate);\n closestDistSquared = bestDistSquared;\n cumSumClosestDistSquared = [cumSum(closestDistSquared.getRow(0))];\n probabilities = Matrix.mul(\n closestDistSquared,\n 1 / cumSumClosestDistSquared[0][nSamples - 1]\n );\n }\n return centers;\n}\n\nfunction euclideanDistances(A, B) {\n const result = new Matrix(A.rows, B.rows);\n for (let i = 0; i < A.rows; i++) {\n for (let j = 0; j < B.rows; j++) {\n result.set(i, j, squaredEuclidean(A.getRow(i), B.getRow(j)));\n }\n }\n return result;\n}\n\nfunction range(l) {\n let r = [];\n for (let i = 0; i < l; i++) {\n r.push(i);\n }\n return r;\n}\n\nfunction cumSum(arr) {\n let cumSum = [arr[0]];\n for (let i = 1; i < arr.length; i++) {\n cumSum[i] = cumSum[i - 1] + arr[i];\n }\n return cumSum;\n}\n","import { updateClusterID } from './utils';\n\nconst distanceSymbol = Symbol('distance');\n\nexport default class KMeansResult {\n /**\n * Result of the kmeans algorithm\n * @param {Array} clusters - the cluster identifier for each data dot\n * @param {Array>} centroids - the K centers in format [x,y,z,...], the error and size of the cluster\n * @param {boolean} converged - Converge criteria satisfied\n * @param {number} iterations - Current number of iterations\n * @param {function} distance - (*Private*) Distance function to use between the points\n * @constructor\n */\n constructor(clusters, centroids, converged, iterations, distance) {\n this.clusters = clusters;\n this.centroids = centroids;\n this.converged = converged;\n this.iterations = iterations;\n this[distanceSymbol] = distance;\n }\n\n /**\n * Allows to compute for a new array of points their cluster id\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @return {Array} - cluster id for each point\n */\n nearest(data) {\n const clusterID = new Array(data.length);\n const centroids = this.centroids.map(function (centroid) {\n return centroid.centroid;\n });\n return updateClusterID(data, centroids, clusterID, this[distanceSymbol]);\n }\n\n /**\n * Returns a KMeansResult with the error and size of the cluster\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @return {KMeansResult}\n */\n computeInformation(data) {\n var enrichedCentroids = this.centroids.map(function (centroid) {\n return {\n centroid: centroid,\n error: 0,\n size: 0\n };\n });\n\n for (var i = 0; i < data.length; i++) {\n enrichedCentroids[this.clusters[i]].error += this[distanceSymbol](\n data[i],\n this.centroids[this.clusters[i]]\n );\n enrichedCentroids[this.clusters[i]].size++;\n }\n\n for (var j = 0; j < this.centroids.length; j++) {\n if (enrichedCentroids[j].size) {\n enrichedCentroids[j].error /= enrichedCentroids[j].size;\n } else {\n enrichedCentroids[j].error = null;\n }\n }\n\n return new KMeansResult(\n this.clusters,\n enrichedCentroids,\n this.converged,\n this.iterations,\n this[distanceSymbol]\n );\n }\n}\n","import { squaredEuclidean } from 'ml-distance-euclidean';\n\nimport {\n updateClusterID,\n updateCenters,\n hasConverged,\n calculateDistanceMatrix\n} from './utils';\nimport { mostDistant, random, kmeanspp } from './initialization';\nimport KMeansResult from './KMeansResult';\n\nconst defaultOptions = {\n maxIterations: 100,\n tolerance: 1e-6,\n withIterations: false,\n initialization: 'kmeans++',\n distanceFunction: squaredEuclidean\n};\n\n/**\n * Each step operation for kmeans\n * @ignore\n * @param {Array>} centers - K centers in format [x,y,z,...]\n * @param {Array>} data - Points [x,y,z,...] to cluster\n * @param {Array} clusterID - Cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n * @param {number} iterations - Current number of iterations\n * @return {KMeansResult}\n */\nfunction step(centers, data, clusterID, K, options, iterations) {\n clusterID = updateClusterID(\n data,\n centers,\n clusterID,\n options.distanceFunction\n );\n var newCenters = updateCenters(centers, data, clusterID, K);\n var converged = hasConverged(\n newCenters,\n centers,\n options.distanceFunction,\n options.tolerance\n );\n return new KMeansResult(\n clusterID,\n newCenters,\n converged,\n iterations,\n options.distanceFunction\n );\n}\n\n/**\n * Generator version for the algorithm\n * @ignore\n * @param {Array>} centers - K centers in format [x,y,z,...]\n * @param {Array>} data - Points [x,y,z,...] to cluster\n * @param {Array} clusterID - Cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n */\nfunction* kmeansGenerator(centers, data, clusterID, K, options) {\n var converged = false;\n var stepNumber = 0;\n var stepResult;\n while (!converged && stepNumber < options.maxIterations) {\n stepResult = step(centers, data, clusterID, K, options, ++stepNumber);\n yield stepResult.computeInformation(data);\n converged = stepResult.converged;\n centers = stepResult.centroids;\n }\n}\n\n/**\n * K-means algorithm\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n * @param {number} [options.maxIterations = 100] - Maximum of iterations allowed\n * @param {number} [options.tolerance = 1e-6] - Error tolerance\n * @param {boolean} [options.withIterations = false] - Store clusters and centroids for each iteration\n * @param {function} [options.distanceFunction = squaredDistance] - Distance function to use between the points\n * @param {number} [options.seed] - Seed for random initialization.\n * @param {string|Array>} [options.initialization = 'kmeans++'] - K centers in format [x,y,z,...] or a method for initialize the data:\n * * You can either specify your custom start centroids, or select one of the following initialization method:\n * * `'kmeans++'` will use the kmeans++ method as described by http://ilpubs.stanford.edu:8090/778/1/2006-13.pdf\n * * `'random'` will choose K random different values.\n * * `'mostDistant'` will choose the more distant points to a first random pick\n * @return {KMeansResult} - Cluster identifier for each data dot and centroids with the following fields:\n * * `'clusters'`: Array of indexes for the clusters.\n * * `'centroids'`: Array with the resulting centroids.\n * * `'iterations'`: Number of iterations that took to converge\n */\nexport default function kmeans(data, K, options) {\n options = Object.assign({}, defaultOptions, options);\n\n if (K <= 0 || K > data.length || !Number.isInteger(K)) {\n throw new Error(\n 'K should be a positive integer smaller than the number of points'\n );\n }\n\n var centers;\n if (Array.isArray(options.initialization)) {\n if (options.initialization.length !== K) {\n throw new Error('The initial centers should have the same length as K');\n } else {\n centers = options.initialization;\n }\n } else {\n switch (options.initialization) {\n case 'kmeans++':\n centers = kmeanspp(data, K, options);\n break;\n case 'random':\n centers = random(data, K, options.seed);\n break;\n case 'mostDistant':\n centers = mostDistant(\n data,\n K,\n calculateDistanceMatrix(data, options.distanceFunction),\n options.seed\n );\n break;\n default:\n throw new Error(\n `Unknown initialization method: \"${options.initialization}\"`\n );\n }\n }\n\n // infinite loop until convergence\n if (options.maxIterations === 0) {\n options.maxIterations = Number.MAX_VALUE;\n }\n\n var clusterID = new Array(data.length);\n if (options.withIterations) {\n return kmeansGenerator(centers, data, clusterID, K, options);\n } else {\n var converged = false;\n var stepNumber = 0;\n var stepResult;\n while (!converged && stepNumber < options.maxIterations) {\n stepResult = step(centers, data, clusterID, K, options, ++stepNumber);\n converged = stepResult.converged;\n centers = stepResult.centroids;\n }\n return stepResult.computeInformation(data);\n }\n}\n","import Matrix from 'ml-matrix';\n\n/**\n * @private\n * Function that retuns an array of matrices of the cases that belong to each class.\n * @param {Matrix} X - dataset\n * @param {Array} y - predictions\n * @return {Array}\n */\nexport function separateClasses(X, y) {\n var features = X.columns;\n\n var classes = 0;\n var totalPerClasses = new Array(10000); // max upperbound of classes\n for (var i = 0; i < y.length; i++) {\n if (totalPerClasses[y[i]] === undefined) {\n totalPerClasses[y[i]] = 0;\n classes++;\n }\n totalPerClasses[y[i]]++;\n }\n var separatedClasses = new Array(classes);\n var currentIndex = new Array(classes);\n for (i = 0; i < classes; ++i) {\n separatedClasses[i] = new Matrix(totalPerClasses[i], features);\n currentIndex[i] = 0;\n }\n for (i = 0; i < X.rows; ++i) {\n separatedClasses[y[i]].setRow(currentIndex[y[i]], X.getRow(i));\n currentIndex[y[i]]++;\n }\n return separatedClasses;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { separateClasses } from './utils';\n\nexport class GaussianNB {\n /**\n * Constructor for the Gaussian Naive Bayes classifier, the parameters here is just for loading purposes.\n * @constructor\n * @param {boolean} reload\n * @param {object} model\n */\n constructor(reload, model) {\n if (reload) {\n this.means = model.means;\n this.calculateProbabilities = model.calculateProbabilities;\n }\n }\n\n /**\n * Function that trains the classifier with a matrix that represents the training set and an array that\n * represents the label of each row in the training set. the labels must be numbers between 0 to n-1 where\n * n represents the number of classes.\n *\n * WARNING: in the case that one class, all the cases in one or more features have the same value, the\n * Naive Bayes classifier will not work well.\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n var C1 = Math.sqrt(2 * Math.PI); // constant to precalculate the squared root\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n if (trainingSet.rows !== trainingLabels.length) {\n throw new RangeError(\n 'the size of the training set and the training labels must be the same.'\n );\n }\n\n var separatedClasses = separateClasses(trainingSet, trainingLabels);\n var calculateProbabilities = new Array(separatedClasses.length);\n this.means = new Array(separatedClasses.length);\n for (var i = 0; i < separatedClasses.length; ++i) {\n var means = separatedClasses[i].mean('column');\n var std = separatedClasses[i].standardDeviation('column', {\n mean: means\n });\n\n var logPriorProbability = Math.log(\n separatedClasses[i].rows / trainingSet.rows\n );\n calculateProbabilities[i] = new Array(means.length + 1);\n\n calculateProbabilities[i][0] = logPriorProbability;\n for (var j = 1; j < means.length + 1; ++j) {\n var currentStd = std[j - 1];\n calculateProbabilities[i][j] = [\n 1 / (C1 * currentStd),\n -2 * currentStd * currentStd\n ];\n }\n\n this.means[i] = means;\n }\n\n this.calculateProbabilities = calculateProbabilities;\n }\n\n /**\n * function that predicts each row of the dataset (must be a matrix).\n *\n * @param {Matrix|Array} dataset\n * @return {Array}\n */\n predict(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n if (dataset.rows === this.calculateProbabilities[0].length) {\n throw new RangeError(\n 'the dataset must have the same features as the training set'\n );\n }\n\n var predictions = new Array(dataset.rows);\n\n for (var i = 0; i < predictions.length; ++i) {\n predictions[i] = getCurrentClass(\n dataset.getRow(i),\n this.means,\n this.calculateProbabilities\n );\n }\n\n return predictions;\n }\n\n /**\n * Function that export the NaiveBayes model.\n * @return {object}\n */\n toJSON() {\n return {\n modelName: 'NaiveBayes',\n means: this.means,\n calculateProbabilities: this.calculateProbabilities\n };\n }\n\n /**\n * Function that create a GaussianNB classifier with the given model.\n * @param {object} model\n * @return {GaussianNB}\n */\n static load(model) {\n if (model.modelName !== 'NaiveBayes') {\n throw new RangeError(\n 'The current model is not a Multinomial Naive Bayes, current model:',\n model.name\n );\n }\n\n return new GaussianNB(true, model);\n }\n}\n\n/**\n * @private\n * Function the retrieves a prediction with one case.\n *\n * @param {Array} currentCase\n * @param {Array} mean - Precalculated means of each class trained\n * @param {Array} classes - Precalculated value of each class (Prior probability and probability function of each feature)\n * @return {number}\n */\nfunction getCurrentClass(currentCase, mean, classes) {\n var maxProbability = 0;\n var predictedClass = -1;\n\n // going through all precalculated values for the classes\n for (var i = 0; i < classes.length; ++i) {\n var currentProbability = classes[i][0]; // initialize with the prior probability\n for (var j = 1; j < classes[0][1].length + 1; ++j) {\n currentProbability += calculateLogProbability(\n currentCase[j - 1],\n mean[i][j - 1],\n classes[i][j][0],\n classes[i][j][1]\n );\n }\n\n currentProbability = Math.exp(currentProbability);\n if (currentProbability > maxProbability) {\n maxProbability = currentProbability;\n predictedClass = i;\n }\n }\n\n return predictedClass;\n}\n\n/**\n * @private\n * function that retrieves the probability of the feature given the class.\n * @param {number} value - value of the feature.\n * @param {number} mean - mean of the feature for the given class.\n * @param {number} C1 - precalculated value of (1 / (sqrt(2*pi) * std)).\n * @param {number} C2 - precalculated value of (2 * std^2) for the denominator of the exponential.\n * @return {number}\n */\nfunction calculateLogProbability(value, mean, C1, C2) {\n value = value - mean;\n return Math.log(C1 * Math.exp((value * value) / C2));\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { separateClasses } from './utils';\n\nexport class MultinomialNB {\n /**\n * Constructor for Multinomial Naive Bayes, the model parameter is for load purposes.\n * @constructor\n * @param {object} model - for load purposes.\n */\n constructor(model) {\n if (model) {\n this.conditionalProbability = Matrix.checkMatrix(\n model.conditionalProbability\n );\n this.priorProbability = Matrix.checkMatrix(model.priorProbability);\n }\n }\n\n /**\n * Train the classifier with the current training set and labels, the labels must be numbers between 0 and n.\n * @param {Matrix|Array} trainingSet\n * @param {Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n if (trainingSet.rows !== trainingLabels.length) {\n throw new RangeError(\n 'the size of the training set and the training labels must be the same.'\n );\n }\n\n var separateClass = separateClasses(trainingSet, trainingLabels);\n\n this.priorProbability = new Matrix(separateClass.length, 1);\n\n for (var i = 0; i < separateClass.length; ++i) {\n this.priorProbability.set(i, 0, Math.log(\n separateClass[i].rows / trainingSet.rows\n ));\n }\n\n var features = trainingSet.columns;\n this.conditionalProbability = new Matrix(separateClass.length, features);\n for (i = 0; i < separateClass.length; ++i) {\n var classValues = Matrix.checkMatrix(separateClass[i]);\n var total = classValues.sum();\n var divisor = total + features;\n this.conditionalProbability.setRow(\n i,\n Matrix.rowVector(classValues\n .sum('column'))\n .add(1)\n .div(divisor)\n .apply(matrixLog)\n );\n }\n }\n\n /**\n * Retrieves the predictions for the dataset with the current model.\n * @param {Matrix|Array} dataset\n * @return {Array} - predictions from the dataset.\n */\n predict(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n var predictions = new Array(dataset.rows);\n for (var i = 0; i < dataset.rows; ++i) {\n var currentElement = dataset.getRowVector(i);\n const v = Matrix.columnVector(this.conditionalProbability\n .clone()\n .mulRowVector(currentElement)\n .sum('row'));\n predictions[i] = v\n .add(this.priorProbability)\n .maxIndex()[0];\n }\n\n return predictions;\n }\n\n /**\n * Function that saves the current model.\n * @return {object} - model in JSON format.\n */\n toJSON() {\n return {\n name: 'MultinomialNB',\n priorProbability: this.priorProbability,\n conditionalProbability: this.conditionalProbability\n };\n }\n\n /**\n * Creates a new MultinomialNB from the given model\n * @param {object} model\n * @return {MultinomialNB}\n */\n static load(model) {\n if (model.name !== 'MultinomialNB') {\n throw new RangeError(`${model.name} is not a Multinomial Naive Bayes`);\n }\n\n return new MultinomialNB(model);\n }\n}\n\nfunction matrixLog(i, j) {\n this.set(i, j, Math.log(this.get(i, j)));\n}\n","/*\n * Original code from:\n *\n * k-d Tree JavaScript - V 1.01\n *\n * https://github.com/ubilabs/kd-tree-javascript\n *\n * @author Mircea Pricop , 2012\n * @author Martin Kleppe , 2012\n * @author Ubilabs http://ubilabs.net, 2012\n * @license MIT License \n */\n\nfunction Node(obj, dimension, parent) {\n this.obj = obj;\n this.left = null;\n this.right = null;\n this.parent = parent;\n this.dimension = dimension;\n}\n\nexport default class KDTree {\n constructor(points, metric) {\n // If points is not an array, assume we're loading a pre-built tree\n if (!Array.isArray(points)) {\n this.dimensions = points.dimensions;\n this.root = points;\n restoreParent(this.root);\n } else {\n this.dimensions = new Array(points[0].length);\n for (var i = 0; i < this.dimensions.length; i++) {\n this.dimensions[i] = i;\n }\n this.root = buildTree(points, 0, null, this.dimensions);\n }\n this.metric = metric;\n }\n\n // Convert to a JSON serializable structure; this just requires removing\n // the `parent` property\n toJSON() {\n const result = toJSONImpl(this.root, true);\n result.dimensions = this.dimensions;\n return result;\n }\n\n nearest(point, maxNodes, maxDistance) {\n const metric = this.metric;\n const dimensions = this.dimensions;\n var i;\n\n const bestNodes = new BinaryHeap(function (e) {\n return -e[1];\n });\n\n function nearestSearch(node) {\n const dimension = dimensions[node.dimension];\n const ownDistance = metric(point, node.obj);\n const linearPoint = {};\n var bestChild, linearDistance, otherChild, i;\n\n function saveNode(node, distance) {\n bestNodes.push([node, distance]);\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop();\n }\n }\n\n for (i = 0; i < dimensions.length; i += 1) {\n if (i === node.dimension) {\n linearPoint[dimensions[i]] = point[dimensions[i]];\n } else {\n linearPoint[dimensions[i]] = node.obj[dimensions[i]];\n }\n }\n\n linearDistance = metric(linearPoint, node.obj);\n\n if (node.right === null && node.left === null) {\n if (bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1]) {\n saveNode(node, ownDistance);\n }\n return;\n }\n\n if (node.right === null) {\n bestChild = node.left;\n } else if (node.left === null) {\n bestChild = node.right;\n } else {\n if (point[dimension] < node.obj[dimension]) {\n bestChild = node.left;\n } else {\n bestChild = node.right;\n }\n }\n\n nearestSearch(bestChild);\n\n if (bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1]) {\n saveNode(node, ownDistance);\n }\n\n if (\n bestNodes.size() < maxNodes ||\n Math.abs(linearDistance) < bestNodes.peek()[1]\n ) {\n if (bestChild === node.left) {\n otherChild = node.right;\n } else {\n otherChild = node.left;\n }\n if (otherChild !== null) {\n nearestSearch(otherChild);\n }\n }\n }\n\n if (maxDistance) {\n for (i = 0; i < maxNodes; i += 1) {\n bestNodes.push([null, maxDistance]);\n }\n }\n\n if (this.root) {\n nearestSearch(this.root);\n }\n\n const result = [];\n for (i = 0; i < Math.min(maxNodes, bestNodes.content.length); i += 1) {\n if (bestNodes.content[i][0]) {\n result.push([bestNodes.content[i][0].obj, bestNodes.content[i][1]]);\n }\n }\n return result;\n }\n}\n\nfunction toJSONImpl(src) {\n const dest = new Node(src.obj, src.dimension, null);\n if (src.left) dest.left = toJSONImpl(src.left);\n if (src.right) dest.right = toJSONImpl(src.right);\n return dest;\n}\n\nfunction buildTree(points, depth, parent, dimensions) {\n const dim = depth % dimensions.length;\n\n if (points.length === 0) {\n return null;\n }\n if (points.length === 1) {\n return new Node(points[0], dim, parent);\n }\n\n points.sort((a, b) => a[dimensions[dim]] - b[dimensions[dim]]);\n\n const median = Math.floor(points.length / 2);\n const node = new Node(points[median], dim, parent);\n node.left = buildTree(points.slice(0, median), depth + 1, node, dimensions);\n node.right = buildTree(points.slice(median + 1), depth + 1, node, dimensions);\n\n return node;\n}\n\nfunction restoreParent(root) {\n if (root.left) {\n root.left.parent = root;\n restoreParent(root.left);\n }\n\n if (root.right) {\n root.right.parent = root;\n restoreParent(root.right);\n }\n}\n\n// Binary heap implementation from:\n// http://eloquentjavascript.net/appendix2.html\nclass BinaryHeap {\n constructor(scoreFunction) {\n this.content = [];\n this.scoreFunction = scoreFunction;\n }\n\n push(element) {\n // Add the new element to the end of the array.\n this.content.push(element);\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1);\n }\n\n pop() {\n // Store the first element so we can return it later.\n var result = this.content[0];\n // Get the element at the end of the array.\n var end = this.content.pop();\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (this.content.length > 0) {\n this.content[0] = end;\n this.sinkDown(0);\n }\n return result;\n }\n\n peek() {\n return this.content[0];\n }\n\n size() {\n return this.content.length;\n }\n\n bubbleUp(n) {\n // Fetch the element that has to be moved.\n var element = this.content[n];\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1;\n const parent = this.content[parentN];\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[parentN] = element;\n this.content[n] = parent;\n // Update 'n' to continue at the new position.\n n = parentN;\n } else {\n // Found a parent that is less, no need to move it further.\n break;\n }\n }\n }\n\n sinkDown(n) {\n // Look up the target element and its score.\n var length = this.content.length;\n var element = this.content[n];\n var elemScore = this.scoreFunction(element);\n\n while (true) {\n // Compute the indices of the child elements.\n var child2N = (n + 1) * 2;\n var child1N = child2N - 1;\n // This is used to store the new position of the element,\n // if any.\n var swap = null;\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n var child1 = this.content[child1N];\n var child1Score = this.scoreFunction(child1);\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) {\n swap = child1N;\n }\n }\n // Do the same checks for the other child.\n if (child2N < length) {\n var child2 = this.content[child2N];\n var child2Score = this.scoreFunction(child2);\n if (child2Score < (swap === null ? elemScore : child1Score)) {\n swap = child2N;\n }\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[n] = this.content[swap];\n this.content[swap] = element;\n n = swap;\n } else {\n // Otherwise, we are done.\n break;\n }\n }\n }\n}\n","import { euclidean as euclideanDistance } from 'ml-distance-euclidean';\n\nimport KDTree from './KDTree';\n\nexport default class KNN {\n /**\n * @param {Array} dataset\n * @param {Array} labels\n * @param {object} options\n * @param {number} [options.k=numberOfClasses + 1] - Number of neighbors to classify.\n * @param {function} [options.distance=euclideanDistance] - Distance function that takes two parameters.\n */\n constructor(dataset, labels, options = {}) {\n if (dataset === true) {\n const model = labels;\n this.kdTree = new KDTree(model.kdTree, options);\n this.k = model.k;\n this.classes = new Set(model.classes);\n this.isEuclidean = model.isEuclidean;\n return;\n }\n\n const classes = new Set(labels);\n\n const { distance = euclideanDistance, k = classes.size + 1 } = options;\n\n const points = new Array(dataset.length);\n for (var i = 0; i < points.length; ++i) {\n points[i] = dataset[i].slice();\n }\n\n for (i = 0; i < labels.length; ++i) {\n points[i].push(labels[i]);\n }\n\n this.kdTree = new KDTree(points, distance);\n this.k = k;\n this.classes = classes;\n this.isEuclidean = distance === euclideanDistance;\n }\n\n /**\n * Create a new KNN instance with the given model.\n * @param {object} model\n * @param {function} distance=euclideanDistance - distance function must be provided if the model wasn't trained with euclidean distance.\n * @return {KNN}\n */\n static load(model, distance = euclideanDistance) {\n if (model.name !== 'KNN') {\n throw new Error(`invalid model: ${model.name}`);\n }\n if (!model.isEuclidean && distance === euclideanDistance) {\n throw new Error(\n 'a custom distance function was used to create the model. Please provide it again'\n );\n }\n if (model.isEuclidean && distance !== euclideanDistance) {\n throw new Error(\n 'the model was created with the default distance function. Do not load it with another one'\n );\n }\n return new KNN(true, model, distance);\n }\n\n /**\n * Return a JSON containing the kd-tree model.\n * @return {object} JSON KNN model.\n */\n toJSON() {\n return {\n name: 'KNN',\n kdTree: this.kdTree,\n k: this.k,\n classes: Array.from(this.classes),\n isEuclidean: this.isEuclidean\n };\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Array} dataset\n * @return {Array} predictions\n */\n predict(dataset) {\n if (Array.isArray(dataset)) {\n if (typeof dataset[0] === 'number') {\n return getSinglePrediction(this, dataset);\n } else if (\n Array.isArray(dataset[0]) &&\n typeof dataset[0][0] === 'number'\n ) {\n const predictions = new Array(dataset.length);\n for (var i = 0; i < dataset.length; i++) {\n predictions[i] = getSinglePrediction(this, dataset[i]);\n }\n return predictions;\n }\n }\n throw new TypeError('dataset to predict must be an array or a matrix');\n }\n}\n\nfunction getSinglePrediction(knn, currentCase) {\n var nearestPoints = knn.kdTree.nearest(currentCase, knn.k);\n var pointsPerClass = {};\n var predictedClass = -1;\n var maxPoints = -1;\n var lastElement = nearestPoints[0][0].length - 1;\n\n for (var element of knn.classes) {\n pointsPerClass[element] = 0;\n }\n\n for (var i = 0; i < nearestPoints.length; ++i) {\n var currentClass = nearestPoints[i][0][lastElement];\n var currentPoints = ++pointsPerClass[currentClass];\n if (currentPoints > maxPoints) {\n predictedClass = currentClass;\n maxPoints = currentPoints;\n }\n }\n\n return predictedClass;\n}\n","import Matrix from 'ml-matrix';\n\n/**\n * @private\n * Function that given vector, returns its norm\n * @param {Vector} X\n * @return {number} Norm of the vector\n */\nexport function norm(X) {\n return Math.sqrt(\n X.clone()\n .apply(pow2array)\n .sum(),\n );\n}\n\n/**\n * @private\n * Function that pow 2 each element of a Matrix or a Vector,\n * used in the apply method of the Matrix object\n * @param {number} i - index i.\n * @param {number} j - index j.\n * @return {Matrix} The Matrix object modified at the index i, j.\n * */\nexport function pow2array(i, j) {\n this.set(i, j, this.get(i, j) ** 2);\n}\n\n/**\n * @private\n * Function that normalize the dataset and return the means and\n * standard deviation of each feature.\n * @param {Matrix} dataset\n * @return {object} dataset normalized, means and standard deviations\n */\nexport function featureNormalize(dataset) {\n let means = dataset.mean('column');\n let std = dataset.standardDeviation('column', {\n mean: means,\n unbiased: true,\n });\n let result = Matrix.checkMatrix(dataset).subRowVector(means);\n return { result: result.divRowVector(std), means: means, std: std };\n}\n\n/**\n * @private\n * Function that initialize an array of matrices.\n * @param {Array} array\n * @param {boolean} isMatrix\n * @return {Array} array with the matrices initialized.\n */\nexport function initializeMatrices(array, isMatrix) {\n if (isMatrix) {\n for (let i = 0; i < array.length; ++i) {\n for (let j = 0; j < array[i].length; ++j) {\n let elem = array[i][j];\n array[i][j] = elem !== null ? new Matrix(array[i][j]) : undefined;\n }\n }\n } else {\n for (let i = 0; i < array.length; ++i) {\n array[i] = new Matrix(array[i]);\n }\n }\n\n return array;\n}\n","import Matrix from 'ml-matrix';\n\nimport * as Utils from './util/utils';\n\n/**\n * @class PLS\n */\nexport class PLS {\n /**\n * Constructor for Partial Least Squares (PLS)\n * @param {object} options\n * @param {number} [options.latentVectors] - Number of latent vector to get (if the algorithm doesn't find a good model below the tolerance)\n * @param {number} [options.tolerance=1e-5]\n * @param {boolean} [options.scale=true] - rescale dataset using mean.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.meanX = model.meanX;\n this.stdDevX = model.stdDevX;\n this.meanY = model.meanY;\n this.stdDevY = model.stdDevY;\n this.PBQ = Matrix.checkMatrix(model.PBQ);\n this.R2X = model.R2X;\n this.scale = model.scale;\n this.scaleMethod = model.scaleMethod;\n this.tolerance = model.tolerance;\n } else {\n let { tolerance = 1e-5, scale = true } = options;\n this.tolerance = tolerance;\n this.scale = scale;\n this.latentVectors = options.latentVectors;\n }\n }\n\n /**\n * Fits the model with the given data and predictions, in this function is calculated the\n * following outputs:\n *\n * T - Score matrix of X\n * P - Loading matrix of X\n * U - Score matrix of Y\n * Q - Loading matrix of Y\n * B - Matrix of regression coefficient\n * W - Weight matrix of X\n *\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n trainingValues = Matrix.checkMatrix(trainingValues);\n\n if (trainingSet.length !== trainingValues.length) {\n throw new RangeError(\n 'The number of X rows must be equal to the number of Y rows',\n );\n }\n\n this.meanX = trainingSet.mean('column');\n this.stdDevX = trainingSet.standardDeviation('column', {\n mean: this.meanX,\n unbiased: true,\n });\n this.meanY = trainingValues.mean('column');\n this.stdDevY = trainingValues.standardDeviation('column', {\n mean: this.meanY,\n unbiased: true,\n });\n\n if (this.scale) {\n trainingSet = trainingSet\n .clone()\n .subRowVector(this.meanX)\n .divRowVector(this.stdDevX);\n trainingValues = trainingValues\n .clone()\n .subRowVector(this.meanY)\n .divRowVector(this.stdDevY);\n }\n\n if (this.latentVectors === undefined) {\n this.latentVectors = Math.min(trainingSet.rows - 1, trainingSet.columns);\n }\n\n let rx = trainingSet.rows;\n let cx = trainingSet.columns;\n let ry = trainingValues.rows;\n let cy = trainingValues.columns;\n\n let ssqXcal = trainingSet\n .clone()\n .mul(trainingSet)\n .sum(); // for the r²\n let sumOfSquaresY = trainingValues\n .clone()\n .mul(trainingValues)\n .sum();\n\n let tolerance = this.tolerance;\n let n = this.latentVectors;\n let T = Matrix.zeros(rx, n);\n let P = Matrix.zeros(cx, n);\n let U = Matrix.zeros(ry, n);\n let Q = Matrix.zeros(cy, n);\n let B = Matrix.zeros(n, n);\n let W = P.clone();\n let k = 0;\n let t;\n let w;\n let q;\n let p;\n\n while (Utils.norm(trainingValues) > tolerance && k < n) {\n let transposeX = trainingSet.transpose();\n let transposeY = trainingValues.transpose();\n\n let tIndex = maxSumColIndex(trainingSet.clone().mul(trainingSet));\n let uIndex = maxSumColIndex(trainingValues.clone().mul(trainingValues));\n\n let t1 = trainingSet.getColumnVector(tIndex);\n let u = trainingValues.getColumnVector(uIndex);\n t = Matrix.zeros(rx, 1);\n\n while (Utils.norm(t1.clone().sub(t)) > tolerance) {\n w = transposeX.mmul(u);\n w.div(Utils.norm(w));\n t = t1;\n t1 = trainingSet.mmul(w);\n q = transposeY.mmul(t1);\n q.div(Utils.norm(q));\n u = trainingValues.mmul(q);\n }\n\n t = t1;\n let num = transposeX.mmul(t);\n let den = t\n .transpose()\n .mmul(t)\n .get(0, 0);\n p = num.div(den);\n let pnorm = Utils.norm(p);\n p.div(pnorm);\n t.mul(pnorm);\n w.mul(pnorm);\n\n num = u.transpose().mmul(t);\n den = t\n .transpose()\n .mmul(t)\n .get(0, 0);\n let b = num.div(den).get(0, 0);\n trainingSet.sub(t.mmul(p.transpose()));\n trainingValues.sub(\n t\n .clone()\n .mul(b)\n .mmul(q.transpose()),\n );\n\n T.setColumn(k, t);\n P.setColumn(k, p);\n U.setColumn(k, u);\n Q.setColumn(k, q);\n W.setColumn(k, w);\n\n B.set(k, k, b);\n k++;\n }\n\n k--;\n T = T.subMatrix(0, T.rows - 1, 0, k);\n P = P.subMatrix(0, P.rows - 1, 0, k);\n U = U.subMatrix(0, U.rows - 1, 0, k);\n Q = Q.subMatrix(0, Q.rows - 1, 0, k);\n W = W.subMatrix(0, W.rows - 1, 0, k);\n B = B.subMatrix(0, k, 0, k);\n\n this.ssqYcal = sumOfSquaresY;\n this.E = trainingSet;\n this.F = trainingValues;\n this.T = T;\n this.P = P;\n this.U = U;\n this.Q = Q;\n this.W = W;\n this.B = B;\n this.PBQ = P.mmul(B).mmul(Q.transpose());\n this.R2X = t\n .transpose()\n .mmul(t)\n .mmul(p.transpose().mmul(p))\n .div(ssqXcal)\n .get(0, 0);\n }\n\n /**\n * Predicts the behavior of the given dataset.\n * @param {Matrix|Array} dataset - data to be predicted.\n * @return {Matrix} - predictions of each element of the dataset.\n */\n predict(dataset) {\n let X = Matrix.checkMatrix(dataset);\n if (this.scale) {\n X = X.subRowVector(this.meanX).divRowVector(this.stdDevX);\n }\n let Y = X.mmul(this.PBQ);\n Y = Y.mulRowVector(this.stdDevY).addRowVector(this.meanY);\n return Y;\n }\n\n /**\n * Returns the explained variance on training of the PLS model\n * @return {number}\n */\n getExplainedVariance() {\n return this.R2X;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n name: 'PLS',\n R2X: this.R2X,\n meanX: this.meanX,\n stdDevX: this.stdDevX,\n meanY: this.meanY,\n stdDevY: this.stdDevY,\n PBQ: this.PBQ,\n tolerance: this.tolerance,\n scale: this.scale,\n };\n }\n\n /**\n * Load a PLS model from a JSON Object\n * @param {object} model\n * @return {PLS} - PLS object from the given model\n */\n static load(model) {\n if (model.name !== 'PLS') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n return new PLS(true, model);\n }\n}\n\n/**\n * @private\n * Function that returns the index where the sum of each\n * column vector is maximum.\n * @param {Matrix} data\n * @return {number} index of the maximum\n */\nfunction maxSumColIndex(data) {\n return Matrix.rowVector(data.sum('column')).maxIndex()[0];\n}\n","import { Matrix, SingularValueDecomposition, inverse } from 'ml-matrix';\n\nimport { initializeMatrices } from './util/utils';\n\n/**\n * @class KOPLS\n */\nexport class KOPLS {\n /**\n * Constructor for Kernel-based Orthogonal Projections to Latent Structures (K-OPLS)\n * @param {object} options\n * @param {number} [options.predictiveComponents] - Number of predictive components to use.\n * @param {number} [options.orthogonalComponents] - Number of Y-Orthogonal components.\n * @param {Kernel} [options.kernel] - Kernel object to apply, see [ml-kernel](https://github.com/mljs/kernel).\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.trainingSet = new Matrix(model.trainingSet);\n this.YLoadingMat = new Matrix(model.YLoadingMat);\n this.SigmaPow = new Matrix(model.SigmaPow);\n this.YScoreMat = new Matrix(model.YScoreMat);\n this.predScoreMat = initializeMatrices(model.predScoreMat, false);\n this.YOrthLoadingVec = initializeMatrices(model.YOrthLoadingVec, false);\n this.YOrthEigen = model.YOrthEigen;\n this.YOrthScoreMat = initializeMatrices(model.YOrthScoreMat, false);\n this.toNorm = initializeMatrices(model.toNorm, false);\n this.TURegressionCoeff = initializeMatrices(\n model.TURegressionCoeff,\n false,\n );\n this.kernelX = initializeMatrices(model.kernelX, true);\n this.kernel = model.kernel;\n this.orthogonalComp = model.orthogonalComp;\n this.predictiveComp = model.predictiveComp;\n } else {\n if (options.predictiveComponents === undefined) {\n throw new RangeError('no predictive components found!');\n }\n if (options.orthogonalComponents === undefined) {\n throw new RangeError('no orthogonal components found!');\n }\n if (options.kernel === undefined) {\n throw new RangeError('no kernel found!');\n }\n\n this.orthogonalComp = options.orthogonalComponents;\n this.predictiveComp = options.predictiveComponents;\n this.kernel = options.kernel;\n }\n }\n\n /**\n * Train the K-OPLS model with the given training set and labels.\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n trainingValues = Matrix.checkMatrix(trainingValues);\n\n // to save and compute kernel with the prediction dataset.\n this.trainingSet = trainingSet.clone();\n\n let kernelX = this.kernel.compute(trainingSet);\n\n let Identity = Matrix.eye(kernelX.rows, kernelX.rows, 1);\n let temp = kernelX;\n kernelX = new Array(this.orthogonalComp + 1);\n for (let i = 0; i < this.orthogonalComp + 1; i++) {\n kernelX[i] = new Array(this.orthogonalComp + 1);\n }\n kernelX[0][0] = temp;\n\n let result = new SingularValueDecomposition(\n trainingValues\n .transpose()\n .mmul(kernelX[0][0])\n .mmul(trainingValues),\n {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false,\n },\n );\n let YLoadingMat = result.leftSingularVectors;\n let Sigma = result.diagonalMatrix;\n\n YLoadingMat = YLoadingMat.subMatrix(\n 0,\n YLoadingMat.rows - 1,\n 0,\n this.predictiveComp - 1,\n );\n Sigma = Sigma.subMatrix(\n 0,\n this.predictiveComp - 1,\n 0,\n this.predictiveComp - 1,\n );\n\n let YScoreMat = trainingValues.mmul(YLoadingMat);\n\n let predScoreMat = new Array(this.orthogonalComp + 1);\n let TURegressionCoeff = new Array(this.orthogonalComp + 1);\n let YOrthScoreMat = new Array(this.orthogonalComp);\n let YOrthLoadingVec = new Array(this.orthogonalComp);\n let YOrthEigen = new Array(this.orthogonalComp);\n let YOrthScoreNorm = new Array(this.orthogonalComp);\n\n let SigmaPow = Matrix.pow(Sigma, -0.5);\n // to avoid errors, check infinity\n SigmaPow.apply(function(i, j) {\n if (this.get(i, j) === Infinity) {\n this.set(i, j, 0);\n }\n });\n\n for (let i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = kernelX[0][i]\n .transpose()\n .mmul(YScoreMat)\n .mmul(SigmaPow);\n\n let TpiPrime = predScoreMat[i].transpose();\n TURegressionCoeff[i] = inverse(TpiPrime.mmul(predScoreMat[i]))\n .mmul(TpiPrime)\n .mmul(YScoreMat);\n\n result = new SingularValueDecomposition(\n TpiPrime.mmul(\n Matrix.sub(kernelX[i][i], predScoreMat[i].mmul(TpiPrime)),\n ).mmul(predScoreMat[i]),\n {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false,\n },\n );\n let CoTemp = result.leftSingularVectors;\n let SoTemp = result.diagonalMatrix;\n\n YOrthLoadingVec[i] = CoTemp.subMatrix(0, CoTemp.rows - 1, 0, 0);\n YOrthEigen[i] = SoTemp.get(0, 0);\n\n YOrthScoreMat[i] = Matrix.sub(\n kernelX[i][i],\n predScoreMat[i].mmul(TpiPrime),\n )\n .mmul(predScoreMat[i])\n .mmul(YOrthLoadingVec[i])\n .mul(Math.pow(YOrthEigen[i], -0.5));\n\n let toiPrime = YOrthScoreMat[i].transpose();\n YOrthScoreNorm[i] = Matrix.sqrt(toiPrime.mmul(YOrthScoreMat[i]));\n\n YOrthScoreMat[i] = YOrthScoreMat[i].divRowVector(YOrthScoreNorm[i]);\n\n let ITo = Matrix.sub(\n Identity,\n YOrthScoreMat[i].mmul(YOrthScoreMat[i].transpose()),\n );\n\n kernelX[0][i + 1] = kernelX[0][i].mmul(ITo);\n kernelX[i + 1][i + 1] = ITo.mmul(kernelX[i][i]).mmul(ITo);\n }\n\n let lastScoreMat = (predScoreMat[this.orthogonalComp] = kernelX[0][\n this.orthogonalComp\n ]\n .transpose()\n .mmul(YScoreMat)\n .mmul(SigmaPow));\n\n let lastTpPrime = lastScoreMat.transpose();\n TURegressionCoeff[this.orthogonalComp] = inverse(\n lastTpPrime.mmul(lastScoreMat),\n )\n .mmul(lastTpPrime)\n .mmul(YScoreMat);\n\n this.YLoadingMat = YLoadingMat;\n this.SigmaPow = SigmaPow;\n this.YScoreMat = YScoreMat;\n this.predScoreMat = predScoreMat;\n this.YOrthLoadingVec = YOrthLoadingVec;\n this.YOrthEigen = YOrthEigen;\n this.YOrthScoreMat = YOrthScoreMat;\n this.toNorm = YOrthScoreNorm;\n this.TURegressionCoeff = TURegressionCoeff;\n this.kernelX = kernelX;\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|Array} toPredict\n * @return {{y: Matrix, predScoreMat: Array, predYOrthVectors: Array}} predictions\n */\n predict(toPredict) {\n let KTestTrain = this.kernel.compute(toPredict, this.trainingSet);\n\n let temp = KTestTrain;\n KTestTrain = new Array(this.orthogonalComp + 1);\n for (let i = 0; i < this.orthogonalComp + 1; i++) {\n KTestTrain[i] = new Array(this.orthogonalComp + 1);\n }\n KTestTrain[0][0] = temp;\n\n let YOrthScoreVector = new Array(this.orthogonalComp);\n let predScoreMat = new Array(this.orthogonalComp);\n\n let i;\n for (i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = KTestTrain[i][0]\n .mmul(this.YScoreMat)\n .mmul(this.SigmaPow);\n\n YOrthScoreVector[i] = Matrix.sub(\n KTestTrain[i][i],\n predScoreMat[i].mmul(this.predScoreMat[i].transpose()),\n )\n .mmul(this.predScoreMat[i])\n .mmul(this.YOrthLoadingVec[i])\n .mul(Math.pow(this.YOrthEigen[i], -0.5));\n\n YOrthScoreVector[i] = YOrthScoreVector[i].divRowVector(this.toNorm[i]);\n\n let scoreMatPrime = this.YOrthScoreMat[i].transpose();\n KTestTrain[i + 1][0] = Matrix.sub(\n KTestTrain[i][0],\n YOrthScoreVector[i]\n .mmul(scoreMatPrime)\n .mmul(this.kernelX[0][i].transpose()),\n );\n\n let p1 = Matrix.sub(\n KTestTrain[i][0],\n KTestTrain[i][i].mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime),\n );\n let p2 = YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[i][i]);\n let p3 = p2.mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime);\n\n KTestTrain[i + 1][i + 1] = p1.sub(p2).add(p3);\n }\n\n predScoreMat[i] = KTestTrain[i][0].mmul(this.YScoreMat).mmul(this.SigmaPow);\n let prediction = predScoreMat[i]\n .mmul(this.TURegressionCoeff[i])\n .mmul(this.YLoadingMat.transpose());\n\n return {\n prediction: prediction,\n predScoreMat: predScoreMat,\n predYOrthVectors: YOrthScoreVector,\n };\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n name: 'K-OPLS',\n YLoadingMat: this.YLoadingMat,\n SigmaPow: this.SigmaPow,\n YScoreMat: this.YScoreMat,\n predScoreMat: this.predScoreMat,\n YOrthLoadingVec: this.YOrthLoadingVec,\n YOrthEigen: this.YOrthEigen,\n YOrthScoreMat: this.YOrthScoreMat,\n toNorm: this.toNorm,\n TURegressionCoeff: this.TURegressionCoeff,\n kernelX: this.kernelX,\n trainingSet: this.trainingSet,\n orthogonalComp: this.orthogonalComp,\n predictiveComp: this.predictiveComp,\n };\n }\n\n /**\n * Load a K-OPLS with the given model.\n * @param {object} model\n * @param {Kernel} kernel - kernel used on the model, see [ml-kernel](https://github.com/mljs/kernel).\n * @return {KOPLS}\n */\n static load(model, kernel) {\n if (model.name !== 'K-OPLS') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n if (!kernel) {\n throw new RangeError('You must provide a kernel for the model!');\n }\n\n model.kernel = kernel;\n return new KOPLS(true, model);\n }\n}\n","/**\n * Constructs a confusion matrix\n * @class ConfusionMatrix\n * @example\n * const CM = new ConfusionMatrix([[13, 2], [10, 5]], ['cat', 'dog'])\n * @param {Array>} matrix - The confusion matrix, a 2D Array. Rows represent the actual label and columns\n * the predicted label.\n * @param {Array} labels - Labels of the confusion matrix, a 1D Array\n */\nexport default class ConfusionMatrix {\n constructor(matrix, labels) {\n if (matrix.length !== matrix[0].length) {\n throw new Error('Confusion matrix must be square');\n }\n if (labels.length !== matrix.length) {\n throw new Error(\n 'Confusion matrix and labels should have the same length',\n );\n }\n this.labels = labels;\n this.matrix = matrix;\n }\n\n /**\n * Construct confusion matrix from the predicted and actual labels (classes). Be sure to provide the arguments in\n * the correct order!\n * @param {Array} actual - The predicted labels of the classification\n * @param {Array} predicted - The actual labels of the classification. Has to be of same length as\n * predicted.\n * @param {object} [options] - Additional options\n * @param {Array} [options.labels] - The list of labels that should be used. If not provided the distinct set\n * of labels present in predicted and actual is used. Labels are compared using the strict equality operator\n * '==='\n * @return {ConfusionMatrix} - Confusion matrix\n */\n static fromLabels(actual, predicted, options = {}) {\n if (predicted.length !== actual.length) {\n throw new Error('predicted and actual must have the same length');\n }\n let distinctLabels;\n if (options.labels) {\n distinctLabels = new Set(options.labels);\n } else {\n distinctLabels = new Set([...actual, ...predicted]);\n }\n distinctLabels = Array.from(distinctLabels);\n if (options.sort) {\n distinctLabels.sort(options.sort);\n }\n\n // Create confusion matrix and fill with 0's\n const matrix = Array.from({ length: distinctLabels.length });\n for (let i = 0; i < matrix.length; i++) {\n matrix[i] = new Array(matrix.length);\n matrix[i].fill(0);\n }\n\n for (let i = 0; i < predicted.length; i++) {\n const actualIdx = distinctLabels.indexOf(actual[i]);\n const predictedIdx = distinctLabels.indexOf(predicted[i]);\n if (actualIdx >= 0 && predictedIdx >= 0) {\n matrix[actualIdx][predictedIdx]++;\n }\n }\n\n return new ConfusionMatrix(matrix, distinctLabels);\n }\n\n /**\n * Get the confusion matrix\n * @return {Array >}\n */\n getMatrix() {\n return this.matrix;\n }\n\n getLabels() {\n return this.labels;\n }\n\n /**\n * Get the total number of samples\n * @return {number}\n */\n getTotalCount() {\n let predicted = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n predicted += this.matrix[i][j];\n }\n }\n return predicted;\n }\n\n /**\n * Get the total number of true predictions\n * @return {number}\n */\n getTrueCount() {\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n count += this.matrix[i][i];\n }\n return count;\n }\n\n /**\n * Get the total number of false predictions.\n * @return {number}\n */\n getFalseCount() {\n return this.getTotalCount() - this.getTrueCount();\n }\n\n /**\n * Get the number of true positive predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTruePositiveCount(label) {\n const index = this.getIndex(label);\n return this.matrix[index][index];\n }\n\n /**\n * Get the number of true negative predictions\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTrueNegativeCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n if (i !== index && j !== index) {\n count += this.matrix[i][j];\n }\n }\n }\n return count;\n }\n\n /**\n * Get the number of false positive predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalsePositiveCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n if (i !== index) {\n count += this.matrix[i][index];\n }\n }\n return count;\n }\n\n /**\n * Get the number of false negative predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseNegativeCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n if (i !== index) {\n count += this.matrix[index][i];\n }\n }\n return count;\n }\n\n /**\n * Get the number of real positive samples.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getPositiveCount(label) {\n return this.getTruePositiveCount(label) + this.getFalseNegativeCount(label);\n }\n\n /**\n * Get the number of real negative samples.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getNegativeCount(label) {\n return this.getTrueNegativeCount(label) + this.getFalsePositiveCount(label);\n }\n\n /**\n * Get the index in the confusion matrix that corresponds to the given label\n * @param {any} label - The label to search for\n * @throws if the label is not found\n * @return {number}\n */\n getIndex(label) {\n const index = this.labels.indexOf(label);\n if (index === -1) throw new Error('The label does not exist');\n return index;\n }\n\n /**\n * Get the true positive rate a.k.a. sensitivity. Computes the ratio between the number of true positive predictions and the total number of positive samples.\n * {@link https://en.wikipedia.org/wiki/Sensitivity_and_specificity}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number} - The true positive rate [0-1]\n */\n getTruePositiveRate(label) {\n return this.getTruePositiveCount(label) / this.getPositiveCount(label);\n }\n\n /**\n * Get the true negative rate a.k.a. specificity. Computes the ration between the number of true negative predictions and the total number of negative samples.\n * {@link https://en.wikipedia.org/wiki/Sensitivity_and_specificity}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTrueNegativeRate(label) {\n return this.getTrueNegativeCount(label) / this.getNegativeCount(label);\n }\n\n /**\n * Get the positive predictive value a.k.a. precision. Computes TP / (TP + FP)\n * {@link https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getPositivePredictiveValue(label) {\n const TP = this.getTruePositiveCount(label);\n return TP / (TP + this.getFalsePositiveCount(label));\n }\n\n /**\n * Negative predictive value\n * {@link https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getNegativePredictiveValue(label) {\n const TN = this.getTrueNegativeCount(label);\n return TN / (TN + this.getFalseNegativeCount(label));\n }\n\n /**\n * False negative rate a.k.a. miss rate.\n * {@link https://en.wikipedia.org/wiki/Type_I_and_type_II_errors#False_positive_and_false_negative_rates}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseNegativeRate(label) {\n return 1 - this.getTruePositiveRate(label);\n }\n\n /**\n * False positive rate a.k.a. fall-out rate.\n * {@link https://en.wikipedia.org/wiki/Type_I_and_type_II_errors#False_positive_and_false_negative_rates}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalsePositiveRate(label) {\n return 1 - this.getTrueNegativeRate(label);\n }\n\n /**\n * False discovery rate (FDR)\n * {@link https://en.wikipedia.org/wiki/False_discovery_rate}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseDiscoveryRate(label) {\n const FP = this.getFalsePositiveCount(label);\n return FP / (FP + this.getTruePositiveCount(label));\n }\n\n /**\n * False omission rate (FOR)\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseOmissionRate(label) {\n const FN = this.getFalseNegativeCount(label);\n return FN / (FN + this.getTruePositiveCount(label));\n }\n\n /**\n * F1 score\n * {@link https://en.wikipedia.org/wiki/F1_score}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getF1Score(label) {\n const TP = this.getTruePositiveCount(label);\n return (\n (2 * TP) /\n (2 * TP +\n this.getFalsePositiveCount(label) +\n this.getFalseNegativeCount(label))\n );\n }\n\n /**\n * Matthews correlation coefficient (MCC)\n * {@link https://en.wikipedia.org/wiki/Matthews_correlation_coefficient}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getMatthewsCorrelationCoefficient(label) {\n const TP = this.getTruePositiveCount(label);\n const TN = this.getTrueNegativeCount(label);\n const FP = this.getFalsePositiveCount(label);\n const FN = this.getFalseNegativeCount(label);\n return (\n (TP * TN - FP * FN) /\n Math.sqrt((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN))\n );\n }\n\n /**\n * Informedness\n * {@link https://en.wikipedia.org/wiki/Youden%27s_J_statistic}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getInformedness(label) {\n return (\n this.getTruePositiveRate(label) + this.getTrueNegativeRate(label) - 1\n );\n }\n\n /**\n * Markedness\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getMarkedness(label) {\n return (\n this.getPositivePredictiveValue(label) +\n this.getNegativePredictiveValue(label) -\n 1\n );\n }\n\n /**\n * Get the confusion table.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {Array >} - The 2x2 confusion table. [[TP, FN], [FP, TN]]\n */\n getConfusionTable(label) {\n return [\n [this.getTruePositiveCount(label), this.getFalseNegativeCount(label)],\n [this.getFalsePositiveCount(label), this.getTrueNegativeCount(label)],\n ];\n }\n\n /**\n * Get total accuracy.\n * @return {number} - The ratio between the number of true predictions and total number of classifications ([0-1])\n */\n getAccuracy() {\n let correct = 0;\n let incorrect = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n if (i === j) correct += this.matrix[i][j];\n else incorrect += this.matrix[i][j];\n }\n }\n return correct / (correct + incorrect);\n }\n\n /**\n * Returns the element in the confusion matrix that corresponds to the given actual and predicted labels.\n * @param {any} actual - The true label\n * @param {any} predicted - The predicted label\n * @return {number} - The element in the confusion matrix\n */\n getCount(actual, predicted) {\n const actualIndex = this.getIndex(actual);\n const predictedIndex = this.getIndex(predicted);\n return this.matrix[actualIndex][predictedIndex];\n }\n\n /**\n * Compute the general prediction accuracy\n * @deprecated Use getAccuracy\n * @return {number} - The prediction accuracy ([0-1]\n */\n get accuracy() {\n return this.getAccuracy();\n }\n\n /**\n * Compute the number of predicted observations\n * @deprecated Use getTotalCount\n * @return {number}\n */\n get total() {\n return this.getTotalCount();\n }\n}\n","(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(factory());\n}(this, (function () { 'use strict';\n\n\tfunction createCommonjsModule(fn, module) {\n\t\treturn module = { exports: {} }, fn(module, module.exports), module.exports;\n\t}\n\n\tvar runtime = createCommonjsModule(function (module) {\n\t/**\n\t * Copyright (c) 2014-present, Facebook, Inc.\n\t *\n\t * This source code is licensed under the MIT license found in the\n\t * LICENSE file in the root directory of this source tree.\n\t */\n\n\t!(function(global) {\n\n\t var Op = Object.prototype;\n\t var hasOwn = Op.hasOwnProperty;\n\t var undefined; // More compressible than void 0.\n\t var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n\t var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n\t var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n\t var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\t var runtime = global.regeneratorRuntime;\n\t if (runtime) {\n\t {\n\t // If regeneratorRuntime is defined globally and we're in a module,\n\t // make the exports object identical to regeneratorRuntime.\n\t module.exports = runtime;\n\t }\n\t // Don't bother evaluating the rest of this file if the runtime was\n\t // already defined globally.\n\t return;\n\t }\n\n\t // Define the runtime globally (as expected by generated code) as either\n\t // module.exports (if we're in a module) or a new, empty object.\n\t runtime = global.regeneratorRuntime = module.exports;\n\n\t function wrap(innerFn, outerFn, self, tryLocsList) {\n\t // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n\t var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n\t var generator = Object.create(protoGenerator.prototype);\n\t var context = new Context(tryLocsList || []);\n\n\t // The ._invoke method unifies the implementations of the .next,\n\t // .throw, and .return methods.\n\t generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n\t return generator;\n\t }\n\t runtime.wrap = wrap;\n\n\t // Try/catch helper to minimize deoptimizations. Returns a completion\n\t // record like context.tryEntries[i].completion. This interface could\n\t // have been (and was previously) designed to take a closure to be\n\t // invoked without arguments, but in all the cases we care about we\n\t // already have an existing method we want to call, so there's no need\n\t // to create a new function object. We can even get away with assuming\n\t // the method takes exactly one argument, since that happens to be true\n\t // in every case, so we don't have to touch the arguments object. The\n\t // only additional allocation required is the completion record, which\n\t // has a stable shape and so hopefully should be cheap to allocate.\n\t function tryCatch(fn, obj, arg) {\n\t try {\n\t return { type: \"normal\", arg: fn.call(obj, arg) };\n\t } catch (err) {\n\t return { type: \"throw\", arg: err };\n\t }\n\t }\n\n\t var GenStateSuspendedStart = \"suspendedStart\";\n\t var GenStateSuspendedYield = \"suspendedYield\";\n\t var GenStateExecuting = \"executing\";\n\t var GenStateCompleted = \"completed\";\n\n\t // Returning this object from the innerFn has the same effect as\n\t // breaking out of the dispatch switch statement.\n\t var ContinueSentinel = {};\n\n\t // Dummy constructor functions that we use as the .constructor and\n\t // .constructor.prototype properties for functions that return Generator\n\t // objects. For full spec compliance, you may wish to configure your\n\t // minifier not to mangle the names of these two functions.\n\t function Generator() {}\n\t function GeneratorFunction() {}\n\t function GeneratorFunctionPrototype() {}\n\n\t // This is a polyfill for %IteratorPrototype% for environments that\n\t // don't natively support it.\n\t var IteratorPrototype = {};\n\t IteratorPrototype[iteratorSymbol] = function () {\n\t return this;\n\t };\n\n\t var getProto = Object.getPrototypeOf;\n\t var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n\t if (NativeIteratorPrototype &&\n\t NativeIteratorPrototype !== Op &&\n\t hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n\t // This environment has a native %IteratorPrototype%; use it instead\n\t // of the polyfill.\n\t IteratorPrototype = NativeIteratorPrototype;\n\t }\n\n\t var Gp = GeneratorFunctionPrototype.prototype =\n\t Generator.prototype = Object.create(IteratorPrototype);\n\t GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n\t GeneratorFunctionPrototype.constructor = GeneratorFunction;\n\t GeneratorFunctionPrototype[toStringTagSymbol] =\n\t GeneratorFunction.displayName = \"GeneratorFunction\";\n\n\t // Helper for defining the .next, .throw, and .return methods of the\n\t // Iterator interface in terms of a single ._invoke method.\n\t function defineIteratorMethods(prototype) {\n\t [\"next\", \"throw\", \"return\"].forEach(function(method) {\n\t prototype[method] = function(arg) {\n\t return this._invoke(method, arg);\n\t };\n\t });\n\t }\n\n\t runtime.isGeneratorFunction = function(genFun) {\n\t var ctor = typeof genFun === \"function\" && genFun.constructor;\n\t return ctor\n\t ? ctor === GeneratorFunction ||\n\t // For the native GeneratorFunction constructor, the best we can\n\t // do is to check its .name property.\n\t (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n\t : false;\n\t };\n\n\t runtime.mark = function(genFun) {\n\t if (Object.setPrototypeOf) {\n\t Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n\t } else {\n\t genFun.__proto__ = GeneratorFunctionPrototype;\n\t if (!(toStringTagSymbol in genFun)) {\n\t genFun[toStringTagSymbol] = \"GeneratorFunction\";\n\t }\n\t }\n\t genFun.prototype = Object.create(Gp);\n\t return genFun;\n\t };\n\n\t // Within the body of any async function, `await x` is transformed to\n\t // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n\t // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n\t // meant to be awaited.\n\t runtime.awrap = function(arg) {\n\t return { __await: arg };\n\t };\n\n\t function AsyncIterator(generator) {\n\t function invoke(method, arg, resolve, reject) {\n\t var record = tryCatch(generator[method], generator, arg);\n\t if (record.type === \"throw\") {\n\t reject(record.arg);\n\t } else {\n\t var result = record.arg;\n\t var value = result.value;\n\t if (value &&\n\t typeof value === \"object\" &&\n\t hasOwn.call(value, \"__await\")) {\n\t return Promise.resolve(value.__await).then(function(value) {\n\t invoke(\"next\", value, resolve, reject);\n\t }, function(err) {\n\t invoke(\"throw\", err, resolve, reject);\n\t });\n\t }\n\n\t return Promise.resolve(value).then(function(unwrapped) {\n\t // When a yielded Promise is resolved, its final value becomes\n\t // the .value of the Promise<{value,done}> result for the\n\t // current iteration. If the Promise is rejected, however, the\n\t // result for this iteration will be rejected with the same\n\t // reason. Note that rejections of yielded Promises are not\n\t // thrown back into the generator function, as is the case\n\t // when an awaited Promise is rejected. This difference in\n\t // behavior between yield and await is important, because it\n\t // allows the consumer to decide what to do with the yielded\n\t // rejection (swallow it and continue, manually .throw it back\n\t // into the generator, abandon iteration, whatever). With\n\t // await, by contrast, there is no opportunity to examine the\n\t // rejection reason outside the generator function, so the\n\t // only option is to throw it from the await expression, and\n\t // let the generator function handle the exception.\n\t result.value = unwrapped;\n\t resolve(result);\n\t }, reject);\n\t }\n\t }\n\n\t var previousPromise;\n\n\t function enqueue(method, arg) {\n\t function callInvokeWithMethodAndArg() {\n\t return new Promise(function(resolve, reject) {\n\t invoke(method, arg, resolve, reject);\n\t });\n\t }\n\n\t return previousPromise =\n\t // If enqueue has been called before, then we want to wait until\n\t // all previous Promises have been resolved before calling invoke,\n\t // so that results are always delivered in the correct order. If\n\t // enqueue has not been called before, then it is important to\n\t // call invoke immediately, without waiting on a callback to fire,\n\t // so that the async generator function has the opportunity to do\n\t // any necessary setup in a predictable way. This predictability\n\t // is why the Promise constructor synchronously invokes its\n\t // executor callback, and why async functions synchronously\n\t // execute code before the first await. Since we implement simple\n\t // async functions in terms of async generators, it is especially\n\t // important to get this right, even though it requires care.\n\t previousPromise ? previousPromise.then(\n\t callInvokeWithMethodAndArg,\n\t // Avoid propagating failures to Promises returned by later\n\t // invocations of the iterator.\n\t callInvokeWithMethodAndArg\n\t ) : callInvokeWithMethodAndArg();\n\t }\n\n\t // Define the unified helper method that is used to implement .next,\n\t // .throw, and .return (see defineIteratorMethods).\n\t this._invoke = enqueue;\n\t }\n\n\t defineIteratorMethods(AsyncIterator.prototype);\n\t AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n\t return this;\n\t };\n\t runtime.AsyncIterator = AsyncIterator;\n\n\t // Note that simple async functions are implemented on top of\n\t // AsyncIterator objects; they just return a Promise for the value of\n\t // the final result produced by the iterator.\n\t runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n\t var iter = new AsyncIterator(\n\t wrap(innerFn, outerFn, self, tryLocsList)\n\t );\n\n\t return runtime.isGeneratorFunction(outerFn)\n\t ? iter // If outerFn is a generator, return the full iterator.\n\t : iter.next().then(function(result) {\n\t return result.done ? result.value : iter.next();\n\t });\n\t };\n\n\t function makeInvokeMethod(innerFn, self, context) {\n\t var state = GenStateSuspendedStart;\n\n\t return function invoke(method, arg) {\n\t if (state === GenStateExecuting) {\n\t throw new Error(\"Generator is already running\");\n\t }\n\n\t if (state === GenStateCompleted) {\n\t if (method === \"throw\") {\n\t throw arg;\n\t }\n\n\t // Be forgiving, per 25.3.3.3.3 of the spec:\n\t // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n\t return doneResult();\n\t }\n\n\t context.method = method;\n\t context.arg = arg;\n\n\t while (true) {\n\t var delegate = context.delegate;\n\t if (delegate) {\n\t var delegateResult = maybeInvokeDelegate(delegate, context);\n\t if (delegateResult) {\n\t if (delegateResult === ContinueSentinel) continue;\n\t return delegateResult;\n\t }\n\t }\n\n\t if (context.method === \"next\") {\n\t // Setting context._sent for legacy support of Babel's\n\t // function.sent implementation.\n\t context.sent = context._sent = context.arg;\n\n\t } else if (context.method === \"throw\") {\n\t if (state === GenStateSuspendedStart) {\n\t state = GenStateCompleted;\n\t throw context.arg;\n\t }\n\n\t context.dispatchException(context.arg);\n\n\t } else if (context.method === \"return\") {\n\t context.abrupt(\"return\", context.arg);\n\t }\n\n\t state = GenStateExecuting;\n\n\t var record = tryCatch(innerFn, self, context);\n\t if (record.type === \"normal\") {\n\t // If an exception is thrown from innerFn, we leave state ===\n\t // GenStateExecuting and loop back for another invocation.\n\t state = context.done\n\t ? GenStateCompleted\n\t : GenStateSuspendedYield;\n\n\t if (record.arg === ContinueSentinel) {\n\t continue;\n\t }\n\n\t return {\n\t value: record.arg,\n\t done: context.done\n\t };\n\n\t } else if (record.type === \"throw\") {\n\t state = GenStateCompleted;\n\t // Dispatch the exception by looping back around to the\n\t // context.dispatchException(context.arg) call above.\n\t context.method = \"throw\";\n\t context.arg = record.arg;\n\t }\n\t }\n\t };\n\t }\n\n\t // Call delegate.iterator[context.method](context.arg) and handle the\n\t // result, either by returning a { value, done } result from the\n\t // delegate iterator, or by modifying context.method and context.arg,\n\t // setting context.delegate to null, and returning the ContinueSentinel.\n\t function maybeInvokeDelegate(delegate, context) {\n\t var method = delegate.iterator[context.method];\n\t if (method === undefined) {\n\t // A .throw or .return when the delegate iterator has no .throw\n\t // method always terminates the yield* loop.\n\t context.delegate = null;\n\n\t if (context.method === \"throw\") {\n\t if (delegate.iterator.return) {\n\t // If the delegate iterator has a return method, give it a\n\t // chance to clean up.\n\t context.method = \"return\";\n\t context.arg = undefined;\n\t maybeInvokeDelegate(delegate, context);\n\n\t if (context.method === \"throw\") {\n\t // If maybeInvokeDelegate(context) changed context.method from\n\t // \"return\" to \"throw\", let that override the TypeError below.\n\t return ContinueSentinel;\n\t }\n\t }\n\n\t context.method = \"throw\";\n\t context.arg = new TypeError(\n\t \"The iterator does not provide a 'throw' method\");\n\t }\n\n\t return ContinueSentinel;\n\t }\n\n\t var record = tryCatch(method, delegate.iterator, context.arg);\n\n\t if (record.type === \"throw\") {\n\t context.method = \"throw\";\n\t context.arg = record.arg;\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t var info = record.arg;\n\n\t if (! info) {\n\t context.method = \"throw\";\n\t context.arg = new TypeError(\"iterator result is not an object\");\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t if (info.done) {\n\t // Assign the result of the finished delegate to the temporary\n\t // variable specified by delegate.resultName (see delegateYield).\n\t context[delegate.resultName] = info.value;\n\n\t // Resume execution at the desired location (see delegateYield).\n\t context.next = delegate.nextLoc;\n\n\t // If context.method was \"throw\" but the delegate handled the\n\t // exception, let the outer generator proceed normally. If\n\t // context.method was \"next\", forget context.arg since it has been\n\t // \"consumed\" by the delegate iterator. If context.method was\n\t // \"return\", allow the original .return call to continue in the\n\t // outer generator.\n\t if (context.method !== \"return\") {\n\t context.method = \"next\";\n\t context.arg = undefined;\n\t }\n\n\t } else {\n\t // Re-yield the result returned by the delegate method.\n\t return info;\n\t }\n\n\t // The delegate iterator is finished, so forget it and continue with\n\t // the outer generator.\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t // Define Generator.prototype.{next,throw,return} in terms of the\n\t // unified ._invoke helper method.\n\t defineIteratorMethods(Gp);\n\n\t Gp[toStringTagSymbol] = \"Generator\";\n\n\t // A Generator should always return itself as the iterator object when the\n\t // @@iterator function is called on it. Some browsers' implementations of the\n\t // iterator prototype chain incorrectly implement this, causing the Generator\n\t // object to not be returned from this call. This ensures that doesn't happen.\n\t // See https://github.com/facebook/regenerator/issues/274 for more details.\n\t Gp[iteratorSymbol] = function() {\n\t return this;\n\t };\n\n\t Gp.toString = function() {\n\t return \"[object Generator]\";\n\t };\n\n\t function pushTryEntry(locs) {\n\t var entry = { tryLoc: locs[0] };\n\n\t if (1 in locs) {\n\t entry.catchLoc = locs[1];\n\t }\n\n\t if (2 in locs) {\n\t entry.finallyLoc = locs[2];\n\t entry.afterLoc = locs[3];\n\t }\n\n\t this.tryEntries.push(entry);\n\t }\n\n\t function resetTryEntry(entry) {\n\t var record = entry.completion || {};\n\t record.type = \"normal\";\n\t delete record.arg;\n\t entry.completion = record;\n\t }\n\n\t function Context(tryLocsList) {\n\t // The root entry object (effectively a try statement without a catch\n\t // or a finally block) gives us a place to store values thrown from\n\t // locations where there is no enclosing try statement.\n\t this.tryEntries = [{ tryLoc: \"root\" }];\n\t tryLocsList.forEach(pushTryEntry, this);\n\t this.reset(true);\n\t }\n\n\t runtime.keys = function(object) {\n\t var keys = [];\n\t for (var key in object) {\n\t keys.push(key);\n\t }\n\t keys.reverse();\n\n\t // Rather than returning an object with a next method, we keep\n\t // things simple and return the next function itself.\n\t return function next() {\n\t while (keys.length) {\n\t var key = keys.pop();\n\t if (key in object) {\n\t next.value = key;\n\t next.done = false;\n\t return next;\n\t }\n\t }\n\n\t // To avoid creating an additional object, we just hang the .value\n\t // and .done properties off the next function object itself. This\n\t // also ensures that the minifier will not anonymize the function.\n\t next.done = true;\n\t return next;\n\t };\n\t };\n\n\t function values(iterable) {\n\t if (iterable) {\n\t var iteratorMethod = iterable[iteratorSymbol];\n\t if (iteratorMethod) {\n\t return iteratorMethod.call(iterable);\n\t }\n\n\t if (typeof iterable.next === \"function\") {\n\t return iterable;\n\t }\n\n\t if (!isNaN(iterable.length)) {\n\t var i = -1, next = function next() {\n\t while (++i < iterable.length) {\n\t if (hasOwn.call(iterable, i)) {\n\t next.value = iterable[i];\n\t next.done = false;\n\t return next;\n\t }\n\t }\n\n\t next.value = undefined;\n\t next.done = true;\n\n\t return next;\n\t };\n\n\t return next.next = next;\n\t }\n\t }\n\n\t // Return an iterator with no values.\n\t return { next: doneResult };\n\t }\n\t runtime.values = values;\n\n\t function doneResult() {\n\t return { value: undefined, done: true };\n\t }\n\n\t Context.prototype = {\n\t constructor: Context,\n\n\t reset: function(skipTempReset) {\n\t this.prev = 0;\n\t this.next = 0;\n\t // Resetting context._sent for legacy support of Babel's\n\t // function.sent implementation.\n\t this.sent = this._sent = undefined;\n\t this.done = false;\n\t this.delegate = null;\n\n\t this.method = \"next\";\n\t this.arg = undefined;\n\n\t this.tryEntries.forEach(resetTryEntry);\n\n\t if (!skipTempReset) {\n\t for (var name in this) {\n\t // Not sure about the optimal order of these conditions:\n\t if (name.charAt(0) === \"t\" &&\n\t hasOwn.call(this, name) &&\n\t !isNaN(+name.slice(1))) {\n\t this[name] = undefined;\n\t }\n\t }\n\t }\n\t },\n\n\t stop: function() {\n\t this.done = true;\n\n\t var rootEntry = this.tryEntries[0];\n\t var rootRecord = rootEntry.completion;\n\t if (rootRecord.type === \"throw\") {\n\t throw rootRecord.arg;\n\t }\n\n\t return this.rval;\n\t },\n\n\t dispatchException: function(exception) {\n\t if (this.done) {\n\t throw exception;\n\t }\n\n\t var context = this;\n\t function handle(loc, caught) {\n\t record.type = \"throw\";\n\t record.arg = exception;\n\t context.next = loc;\n\n\t if (caught) {\n\t // If the dispatched exception was caught by a catch block,\n\t // then let that catch block handle the exception normally.\n\t context.method = \"next\";\n\t context.arg = undefined;\n\t }\n\n\t return !! caught;\n\t }\n\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t var record = entry.completion;\n\n\t if (entry.tryLoc === \"root\") {\n\t // Exception thrown outside of any try block that could handle\n\t // it, so set the completion value of the entire function to\n\t // throw the exception.\n\t return handle(\"end\");\n\t }\n\n\t if (entry.tryLoc <= this.prev) {\n\t var hasCatch = hasOwn.call(entry, \"catchLoc\");\n\t var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n\t if (hasCatch && hasFinally) {\n\t if (this.prev < entry.catchLoc) {\n\t return handle(entry.catchLoc, true);\n\t } else if (this.prev < entry.finallyLoc) {\n\t return handle(entry.finallyLoc);\n\t }\n\n\t } else if (hasCatch) {\n\t if (this.prev < entry.catchLoc) {\n\t return handle(entry.catchLoc, true);\n\t }\n\n\t } else if (hasFinally) {\n\t if (this.prev < entry.finallyLoc) {\n\t return handle(entry.finallyLoc);\n\t }\n\n\t } else {\n\t throw new Error(\"try statement without catch or finally\");\n\t }\n\t }\n\t }\n\t },\n\n\t abrupt: function(type, arg) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.tryLoc <= this.prev &&\n\t hasOwn.call(entry, \"finallyLoc\") &&\n\t this.prev < entry.finallyLoc) {\n\t var finallyEntry = entry;\n\t break;\n\t }\n\t }\n\n\t if (finallyEntry &&\n\t (type === \"break\" ||\n\t type === \"continue\") &&\n\t finallyEntry.tryLoc <= arg &&\n\t arg <= finallyEntry.finallyLoc) {\n\t // Ignore the finally entry if control is not jumping to a\n\t // location outside the try/catch block.\n\t finallyEntry = null;\n\t }\n\n\t var record = finallyEntry ? finallyEntry.completion : {};\n\t record.type = type;\n\t record.arg = arg;\n\n\t if (finallyEntry) {\n\t this.method = \"next\";\n\t this.next = finallyEntry.finallyLoc;\n\t return ContinueSentinel;\n\t }\n\n\t return this.complete(record);\n\t },\n\n\t complete: function(record, afterLoc) {\n\t if (record.type === \"throw\") {\n\t throw record.arg;\n\t }\n\n\t if (record.type === \"break\" ||\n\t record.type === \"continue\") {\n\t this.next = record.arg;\n\t } else if (record.type === \"return\") {\n\t this.rval = this.arg = record.arg;\n\t this.method = \"return\";\n\t this.next = \"end\";\n\t } else if (record.type === \"normal\" && afterLoc) {\n\t this.next = afterLoc;\n\t }\n\n\t return ContinueSentinel;\n\t },\n\n\t finish: function(finallyLoc) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.finallyLoc === finallyLoc) {\n\t this.complete(entry.completion, entry.afterLoc);\n\t resetTryEntry(entry);\n\t return ContinueSentinel;\n\t }\n\t }\n\t },\n\n\t \"catch\": function(tryLoc) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.tryLoc === tryLoc) {\n\t var record = entry.completion;\n\t if (record.type === \"throw\") {\n\t var thrown = record.arg;\n\t resetTryEntry(entry);\n\t }\n\t return thrown;\n\t }\n\t }\n\n\t // The context.catch method must only be called with a location\n\t // argument that corresponds to a known catch block.\n\t throw new Error(\"illegal catch attempt\");\n\t },\n\n\t delegateYield: function(iterable, resultName, nextLoc) {\n\t this.delegate = {\n\t iterator: values(iterable),\n\t resultName: resultName,\n\t nextLoc: nextLoc\n\t };\n\n\t if (this.method === \"next\") {\n\t // Deliberately forget the last sent value so that we don't\n\t // accidentally pass it on to the delegate.\n\t this.arg = undefined;\n\t }\n\n\t return ContinueSentinel;\n\t }\n\t };\n\t})(\n\t // In sloppy mode, unbound `this` refers to the global object, fallback to\n\t // Function constructor if we're in global strict mode. That is sadly a form\n\t // of indirect eval which violates Content Security Policy.\n\t (function() { return this })() || Function(\"return this\")()\n\t);\n\t});\n\n\t/**\n\t * Copyright (c) 2014-present, Facebook, Inc.\n\t *\n\t * This source code is licensed under the MIT license found in the\n\t * LICENSE file in the root directory of this source tree.\n\t */\n\n\t// This method of obtaining a reference to the global object needs to be\n\t// kept identical to the way it is obtained in runtime.js\n\tvar g = (function() { return this })() || Function(\"return this\")();\n\n\t// Use `getOwnPropertyNames` because not all browsers support calling\n\t// `hasOwnProperty` on the global `self` object in a worker. See #183.\n\tvar hadRuntime = g.regeneratorRuntime &&\n\t Object.getOwnPropertyNames(g).indexOf(\"regeneratorRuntime\") >= 0;\n\n\t// Save the old regeneratorRuntime in case it needs to be restored later.\n\tvar oldRuntime = hadRuntime && g.regeneratorRuntime;\n\n\t// Force reevalutation of runtime.js.\n\tg.regeneratorRuntime = undefined;\n\n\tvar runtimeModule = runtime;\n\n\tif (hadRuntime) {\n\t // Restore the original runtime.\n\t g.regeneratorRuntime = oldRuntime;\n\t} else {\n\t // Remove the global property added by runtime.js.\n\t try {\n\t delete g.regeneratorRuntime;\n\t } catch(e) {\n\t g.regeneratorRuntime = undefined;\n\t }\n\t}\n\n\tvar regenerator = runtimeModule;\n\n\tvar defaultOptions = {\n\t mode: 'index'\n\t};\n\n\tmodule.exports = /*#__PURE__*/regenerator.mark(function _callee(M, N, options) {\n\t var a, c, b, p, x, y, z, i, twiddle;\n\t return regenerator.wrap(function _callee$(_context) {\n\t while (1) {\n\t switch (_context.prev = _context.next) {\n\t case 0:\n\t twiddle = function twiddle() {\n\t var i, j, k;\n\t j = 1;\n\t while (p[j] <= 0) {\n\t j++;\n\t }\n\t if (p[j - 1] === 0) {\n\t for (i = j - 1; i !== 1; i--) {\n\t p[i] = -1;\n\t }\n\t p[j] = 0;\n\t x = z = 0;\n\t p[1] = 1;\n\t y = j - 1;\n\t } else {\n\t if (j > 1) {\n\t p[j - 1] = 0;\n\t }\n\t do {\n\t j++;\n\t } while (p[j] > 0);\n\t k = j - 1;\n\t i = j;\n\t while (p[i] === 0) {\n\t p[i++] = -1;\n\t }\n\t if (p[i] === -1) {\n\t p[i] = p[k];\n\t z = p[k] - 1;\n\t x = i - 1;\n\t y = k - 1;\n\t p[k] = -1;\n\t } else {\n\t if (i === p[0]) {\n\t return 0;\n\t } else {\n\t p[j] = p[i];\n\t z = p[i] - 1;\n\t p[i] = 0;\n\t x = j - 1;\n\t y = i - 1;\n\t }\n\t }\n\t }\n\t return 1;\n\t };\n\n\t options = Object.assign({}, defaultOptions, options);\n\t a = new Array(N);\n\t c = new Array(M);\n\t b = new Array(N);\n\t p = new Array(N + 2);\n\n\n\t // init a and b\n\t for (i = 0; i < N; i++) {\n\t a[i] = i;\n\t if (i < N - M) b[i] = 0;else b[i] = 1;\n\t }\n\n\t // init c\n\t for (i = 0; i < M; i++) {\n\t c[i] = N - M + i;\n\t }\n\n\t // init p\n\t for (i = 0; i < p.length; i++) {\n\t if (i === 0) p[i] = N + 1;else if (i <= N - M) p[i] = 0;else if (i <= N) p[i] = i - N + M;else p[i] = -2;\n\t }\n\n\t if (!(options.mode === 'index')) {\n\t _context.next = 20;\n\t break;\n\t }\n\n\t _context.next = 12;\n\t return c.slice();\n\n\t case 12:\n\t if (!twiddle()) {\n\t _context.next = 18;\n\t break;\n\t }\n\n\t c[z] = a[x];\n\t _context.next = 16;\n\t return c.slice();\n\n\t case 16:\n\t _context.next = 12;\n\t break;\n\n\t case 18:\n\t _context.next = 33;\n\t break;\n\n\t case 20:\n\t if (!(options.mode === 'mask')) {\n\t _context.next = 32;\n\t break;\n\t }\n\n\t _context.next = 23;\n\t return b.slice();\n\n\t case 23:\n\t if (!twiddle()) {\n\t _context.next = 30;\n\t break;\n\t }\n\n\t b[x] = 1;\n\t b[y] = 0;\n\t _context.next = 28;\n\t return b.slice();\n\n\t case 28:\n\t _context.next = 23;\n\t break;\n\n\t case 30:\n\t _context.next = 33;\n\t break;\n\n\t case 32:\n\t throw new Error('Invalid mode');\n\n\t case 33:\n\t case 'end':\n\t return _context.stop();\n\t }\n\t }\n\t }, _callee, this);\n\t});\n\n})));\n","/**\n * get folds indexes\n * @param {Array} features\n * @param {Number} k - number of folds, a\n */\nexport function getFolds(features, k = 5) {\n let N = features.length;\n let allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n\n let l = Math.floor(N / k);\n // create random k-folds\n let current = [];\n let folds = [];\n while (allIdx.length) {\n let randi = Math.floor(Math.random() * allIdx.length);\n current.push(allIdx[randi]);\n allIdx.splice(randi, 1);\n if (current.length === l) {\n folds.push(current);\n current = [];\n }\n }\n // we push the remaining to the last fold so that the total length is\n // preserved. Otherwise the Q2 will fail.\n if (current.length) current.forEach((e) => folds[k - 1].push(e));\n folds = folds.slice(0, k);\n\n let foldsIndex = folds.map((x, idx) => ({\n testIndex: x,\n trainIndex: [].concat(...folds.filter((el, idx2) => idx2 !== idx)),\n }));\n return foldsIndex;\n}\n","/**\n * A function to sample a dataset maintaining classes equilibrated\n * @param {Array} classVector - an array containing class or group information\n * @param {Number} fraction - a fraction of the class to sample\n * @return {Object} - an object with indexes\n */\n\nexport function sampleAClass(classVector, fraction) {\n // sort the vector\n let classVectorSorted = JSON.parse(JSON.stringify(classVector));\n let result = Array.from(Array(classVectorSorted.length).keys()).sort((a, b) =>\n classVectorSorted[a] < classVectorSorted[b]\n ? -1\n : (classVectorSorted[b] < classVectorSorted[a]) | 0,\n );\n classVectorSorted.sort((a, b) => (a < b ? -1 : (b < a) | 0));\n\n // counts the class elements\n let counts = {};\n classVectorSorted.forEach((x) => (counts[x] = (counts[x] || 0) + 1));\n\n // pick a few per class\n let indexOfSelected = [];\n\n Object.keys(counts).forEach((e, i) => {\n let shift = [];\n Object.values(counts).reduce((a, c, item) => (shift[item] = a + c), 0);\n\n let arr = [...Array(counts[e]).keys()];\n\n let r = [];\n for (let j = 0; j < Math.floor(counts[e] * fraction); j++) {\n let n = arr[Math.floor(Math.random() * arr.length)];\n r.push(n);\n let ind = arr.indexOf(n);\n arr.splice(ind, 1);\n }\n\n if (i === 0) {\n indexOfSelected = indexOfSelected.concat(r);\n } else {\n indexOfSelected = indexOfSelected.concat(r.map((x) => x + shift[i - 1]));\n }\n });\n\n // sort back the index\n let trainIndex = [];\n indexOfSelected.forEach((e) => trainIndex.push(result[e]));\n\n let testIndex = [];\n let mask = [];\n classVector.forEach((el, idx) => {\n if (trainIndex.includes(idx)) {\n mask.push(true);\n } else {\n mask.push(false);\n testIndex.push(idx);\n }\n });\n return { trainIndex, testIndex, mask };\n}\n","import ConfusionMatrix from 'ml-confusion-matrix';\nimport combinations from 'ml-combinations';\n\nimport { getFolds } from './getFolds.js';\n\nexport { sampleAClass } from './sampleAClass.js';\nexport { getFolds } from './getFolds.js';\n\n/**\n * Performs a leave-one-out cross-validation (LOO-CV) of the given samples. In LOO-CV, 1 observation is used as the\n * validation set while the rest is used as the training set. This is repeated once for each observation. LOO-CV is a\n * special case of LPO-CV. @see leavePout\n * @param {function} Classifier - The classifier's constructor to use for the cross validation. Expect ml-classifier\n * api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\n\nexport function leaveOneOut(Classifier, features, labels, classifierOptions) {\n if (typeof labels === 'function') {\n let callback = labels;\n labels = features;\n features = Classifier;\n return leavePOut(features, labels, 1, callback);\n }\n return leavePOut(Classifier, features, labels, classifierOptions, 1);\n}\n\n/**\n * Performs a leave-p-out cross-validation (LPO-CV) of the given samples. In LPO-CV, p observations are used as the\n * validation set while the rest is used as the training set. This is repeated as many times as there are possible\n * ways to combine p observations from the set (unordered without replacement). Be aware that for relatively small\n * data-set size this can require a very large number of training and testing to do!\n * @param {function} Classifier - The classifier's constructor to use for the cross validation. Expect ml-classifier\n * api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @param {number} p - The size of the validation sub-samples' set\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\nexport function leavePOut(Classifier, features, labels, classifierOptions, p) {\n let callback;\n if (typeof classifierOptions === 'function') {\n callback = classifierOptions;\n p = labels;\n labels = features;\n features = Classifier;\n }\n check(features, labels);\n const distinct = getDistinct(labels);\n const confusionMatrix = initMatrix(distinct.length, distinct.length);\n\n let N = features.length;\n let gen = combinations(p, N);\n let allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n for (const testIdx of gen) {\n let trainIdx = allIdx.slice();\n\n for (let i = testIdx.length - 1; i >= 0; i--) {\n trainIdx.splice(testIdx[i], 1);\n }\n\n if (callback) {\n validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n );\n } else {\n validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n );\n }\n }\n\n return new ConfusionMatrix(confusionMatrix, distinct);\n}\n\n/**\n * Performs k-fold cross-validation (KF-CV). KF-CV separates the data-set into k random equally sized partitions, and\n * uses each as a validation set, with all other partitions used in the training set. Observations left over from if k\n * does not divide the number of observations are left out of the cross-validation process.\n * @param {function} Classifier - The classifier's to use for the cross validation. Expect ml-classifier api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @param {number} k - The number of partitions to create\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\nexport function kFold(Classifier, features, labels, classifierOptions, k) {\n let callback;\n if (typeof classifierOptions === 'function') {\n callback = classifierOptions;\n k = labels;\n labels = features;\n features = Classifier;\n }\n check(features, labels);\n const distinct = getDistinct(labels);\n const confusionMatrix = initMatrix(distinct.length, distinct.length);\n\n let folds = getFolds(features, k);\n\n for (let i = 0; i < folds.length; i++) {\n let testIdx = folds[i].testIndex;\n let trainIdx = folds[i].trainIndex;\n\n if (callback) {\n validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n );\n } else {\n validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n );\n }\n }\n\n return new ConfusionMatrix(confusionMatrix, distinct);\n}\n\nfunction check(features, labels) {\n if (features.length !== labels.length) {\n throw new Error('features and labels should have the same length');\n }\n}\n\nfunction initMatrix(rows, columns) {\n return new Array(rows).fill(0).map(() => new Array(columns).fill(0));\n}\n\nfunction getDistinct(arr) {\n let s = new Set();\n for (let i = 0; i < arr.length; i++) {\n s.add(arr[i]);\n }\n return Array.from(s);\n}\n\nfunction validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n) {\n const { testFeatures, trainFeatures, testLabels, trainLabels } = getTrainTest(\n features,\n labels,\n testIdx,\n trainIdx,\n );\n\n let classifier;\n if (Classifier.prototype.train) {\n classifier = new Classifier(classifierOptions);\n classifier.train(trainFeatures, trainLabels);\n } else {\n classifier = new Classifier(trainFeatures, trainLabels, classifierOptions);\n }\n\n let predictedLabels = classifier.predict(testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n) {\n const { testFeatures, trainFeatures, testLabels, trainLabels } = getTrainTest(\n features,\n labels,\n testIdx,\n trainIdx,\n );\n const predictedLabels = callback(trainFeatures, trainLabels, testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction updateConfusionMatrix(\n confusionMatrix,\n testLabels,\n predictedLabels,\n distinct,\n) {\n for (let i = 0; i < predictedLabels.length; i++) {\n const actualIdx = distinct.indexOf(testLabels[i]);\n const predictedIdx = distinct.indexOf(predictedLabels[i]);\n if (actualIdx < 0 || predictedIdx < 0) {\n // eslint-disable-next-line no-console\n console.warn(`ignore unknown predicted label ${predictedLabels[i]}`);\n }\n confusionMatrix[actualIdx][predictedIdx]++;\n }\n}\n\nexport function getTrainTest(features, labels, testIdx, trainIdx) {\n return {\n testFeatures: testIdx.map(function(index) {\n return features[index];\n }),\n trainFeatures: trainIdx.map(function(index) {\n return features[index];\n }),\n testLabels: testIdx.map(function(index) {\n return labels[index];\n }),\n trainLabels: trainIdx.map(function(index) {\n return labels[index];\n }),\n };\n}\n","import Matrix from 'ml-matrix';\n\nimport { norm } from './util/utils.js';\n\n/**\n * OPLS loop\n * @param {Array} x a matrix with features\n * @param {Array} y an array of labels (dependent variable)\n * @param {Object} options an object with options\n * @return {Object} an object with model (filteredX: err,\n loadingsXOrtho: pOrtho,\n scoresXOrtho: tOrtho,\n weightsXOrtho: wOrtho,\n weightsPred: w,\n loadingsXpred: p,\n scoresXpred: t,\n loadingsY:)\n */\nexport function OPLSNipals(x, y, options = {}) {\n const { numberOSC = 100 } = options;\n\n let X = Matrix.checkMatrix(x);\n let Y = Matrix.checkMatrix(y);\n\n let u = Y.getColumnVector(0);\n\n let diff = 1;\n let t, c, w, uNew;\n for (let i = 0; i < numberOSC && diff > 1e-10; i++) {\n w = u\n .transpose()\n .mmul(X)\n .div(\n u\n .transpose()\n .mmul(u)\n .get(0, 0),\n );\n w = w.transpose().div(norm(w));\n\n t = X.mmul(w).div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n ); // t_h paso 3\n\n // calc loading\n c = t\n .transpose()\n .mmul(Y)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n\n // calc new u and compare with one in previus iteration (stop criterion)\n uNew = Y.mmul(c.transpose());\n uNew = uNew.div(\n c\n .transpose()\n .mmul(c)\n .get(0, 0),\n );\n\n if (i > 0) {\n diff =\n uNew\n .clone()\n .sub(u)\n .pow(2)\n .sum() /\n uNew\n .clone()\n .pow(2)\n .sum();\n }\n\n u = uNew.clone();\n }\n\n // calc loadings\n let p = t\n .transpose()\n .mmul(X)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n\n let wOrtho = p.clone().sub(\n w\n .transpose()\n .mmul(p.transpose())\n .div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n )\n .mmul(w.transpose()),\n );\n wOrtho.div(norm(wOrtho));\n\n // orthogonal scores\n let tOrtho = X.mmul(wOrtho.transpose()).div(\n wOrtho.mmul(wOrtho.transpose()).get(0, 0),\n );\n\n // orthogonal loadings\n let pOrtho = tOrtho\n .transpose()\n .mmul(X)\n .div(\n tOrtho\n .transpose()\n .mmul(tOrtho)\n .get(0, 0),\n );\n\n // filtered data\n let err = X.clone().sub(tOrtho.mmul(pOrtho));\n return {\n filteredX: err,\n weightsXOrtho: wOrtho,\n loadingsXOrtho: pOrtho,\n scoresXOrtho: tOrtho,\n weightsXPred: w,\n loadingsXpred: p,\n scoresXpred: t,\n loadingsY: c,\n };\n}\n","import { Matrix } from 'ml-matrix';\n\n/**\n * Get total sum of square\n * @param {Array} x an array\n * @return {Number} - the sum of the squares\n */\nexport function tss(x) {\n return Matrix.mul(x, x).sum();\n}\n","import { Matrix, NIPALS } from 'ml-matrix';\nimport ConfusionMatrix from 'ml-confusion-matrix';\nimport { getFolds } from 'ml-cross-validation';\n\nimport { OPLSNipals } from './OPLSNipals.js';\nimport { tss } from './util/tss.js';\n\n/**\n * Creates new OPLS (orthogonal partial latent structures) from features and labels.\n * @param {Matrix} data - matrix containing data (X).\n * @param {Array} labels - 1D Array containing metadata (Y).\n * @param {Object} [options]\n * @param {number} [options.nComp = 3] - number of latent structures computed.\n * @param {boolean} [options.center = true] - should the data be centered (subtract the mean).\n * @param {boolean} [options.scale = false] - should the data be scaled (divide by the standard deviation).\n * @param {Array} [options.cvFolds = []] - allows to provide folds as 2D array for testing purpose.\n * */\n\nexport class OPLS {\n constructor(data, labels, options = {}) {\n if (data === true) {\n const opls = options;\n this.center = opls.center;\n this.scale = opls.scale;\n this.means = opls.means;\n this.meansY = opls.meansY;\n this.stdevs = opls.stdevs;\n this.stdevs = opls.stdevsY;\n this.model = opls.model;\n this.tCV = opls.tCV;\n this.tOrthCV = opls.tOrthCV;\n this.yHatCV = opls.yHatCV;\n this.mode = opls.mode;\n return;\n }\n\n let features = data.clone();\n // set default values\n // cvFolds allows to define folds for testing purpose\n const { nComp = 3, center = true, scale = true, cvFolds = [] } = options;\n\n let group;\n if (typeof labels[0] === 'number') {\n // numeric labels: OPLS regression is used\n this.mode = 'regression';\n group = Matrix.from1DArray(labels.length, 1, labels);\n } else if (typeof labels[0] === 'string') {\n // non-numeric labels: OPLS-DA is used\n this.mode = 'discriminantAnalysis';\n group = labels;\n throw new Error('discriminant analysis is not yet supported');\n }\n\n // check types of features and labels\n if (features.constructor.name !== 'Matrix') {\n throw new TypeError('features must be of class Matrix');\n }\n // getting center and scale the features (all)\n this.center = center;\n if (this.center) {\n this.means = features.mean('column');\n this.meansY = group.mean('column');\n } else {\n this.stdevs = null;\n }\n this.scale = scale;\n if (this.scale) {\n this.stdevs = features.standardDeviation('column');\n this.stdevsY = group.standardDeviation('column');\n } else {\n this.means = null;\n }\n\n // check and remove for features with sd = 0 TODO here\n // check opls.R line 70\n\n let folds;\n if (cvFolds.length > 0) {\n folds = cvFolds;\n } else {\n folds = getFolds(labels, 5);\n }\n\n let Q2 = [];\n this.model = [];\n\n this.tCV = [];\n this.tOrthCV = [];\n this.yHatCV = [];\n let oplsCV = [];\n\n let modelNC = [];\n\n // this code could be made more efficient by reverting the order of the loops\n // this is a legacy loop to be consistent with R code from MetaboMate package\n // this allows for having statistic (R2) from CV to decide wether to continue\n // with more latent structures\n let nc;\n for (nc = 0; nc < nComp; nc++) {\n let yHatk = new Matrix(group.rows, 1);\n let tPredk = new Matrix(group.rows, 1);\n let tOrthk = new Matrix(group.rows, 1);\n let oplsk = [];\n\n let f = 0;\n for (let fold of folds) {\n let trainTest = this._getTrainTest(features, group, fold);\n let testXk = trainTest.testFeatures;\n let Xk = trainTest.trainFeatures;\n let Yk = trainTest.trainLabels;\n\n // determine center and scale of training set\n let dataCenter = Xk.mean('column');\n let dataSD = Xk.standardDeviation('column');\n\n // center and scale training set\n if (center) {\n Xk.center('column');\n Yk.center('column');\n }\n\n if (scale) {\n Xk.scale('column');\n Yk.scale('column');\n }\n\n // perform opls\n if (nc === 0) {\n oplsk[f] = OPLSNipals(Xk, Yk);\n } else {\n oplsk[f] = OPLSNipals(oplsCV[nc - 1][f].filteredX, Yk);\n }\n // store model for next component\n oplsCV[nc] = oplsk;\n\n let plsCV = new NIPALS(oplsk[f].filteredX, { Y: Yk });\n\n // scaling the test dataset with respect to the train\n testXk.center('column', { center: dataCenter });\n testXk.scale('column', { scale: dataSD });\n\n let Eh = testXk;\n // removing the orthogonal components from PLS\n let scores;\n for (let idx = 0; idx < nc + 1; idx++) {\n scores = Eh.mmul(oplsCV[idx][f].weightsXOrtho.transpose()); // ok\n Eh.sub(scores.mmul(oplsCV[idx][f].loadingsXOrtho));\n }\n\n // prediction\n let tPred = Eh.mmul(plsCV.w.transpose());\n // this should be summed over ncomp (pls_prediction.R line 23)\n let yHat = tPred.mmul(plsCV.betas); // ok\n\n // adding all prediction from all folds\n for (let i = 0; i < fold.testIndex.length; i++) {\n yHatk.setRow(fold.testIndex[i], [yHat.get(i, 0)]);\n tPredk.setRow(fold.testIndex[i], [tPred.get(i, 0)]);\n tOrthk.setRow(fold.testIndex[i], [scores.get(i, 0)]);\n }\n f++;\n } // end of loop over folds\n\n this.tCV.push(tPredk);\n this.tOrthCV.push(tOrthk);\n this.yHatCV.push(yHatk);\n\n // calculate Q2y for all the prediction (all folds)\n // ROC for DA is not implemented (check opls.R line 183) TODO\n if (this.mode === 'regression') {\n let tssy = tss(group.center('column').scale('column'));\n let press = tss(group.clone().sub(yHatk));\n let Q2y = 1 - press / tssy;\n Q2.push(Q2y);\n } else if (this.mode === 'discriminantAnalysis') {\n throw new Error('discriminant analysis is not yet supported');\n }\n\n // calculate the R2y for the complete data\n if (nc === 0) {\n modelNC = this._predictAll(features, group);\n } else {\n modelNC = this._predictAll(\n modelNC.xRes,\n group,\n (options = { scale: false, center: false }),\n );\n }\n\n // adding the predictive statistics from CV\n modelNC.Q2y = Q2;\n // store the model for each component\n this.model.push(modelNC);\n // console.warn(`OPLS iteration over # of Components: ${nc + 1}`);\n } // end of loop over nc\n\n // store scores from CV\n let tCV = this.tCV;\n let tOrthCV = this.tOrthCV;\n\n let m = this.model[nc - 1];\n let XOrth = m.XOrth;\n let FeaturesCS = features.center('column').scale('column');\n let labelsCS = group.center('column').scale('column');\n let Xres = FeaturesCS.clone().sub(XOrth);\n let plsCall = new NIPALS(Xres, { Y: labelsCS });\n let E = Xres.clone().sub(plsCall.t.mmul(plsCall.p));\n\n let R2x = this.model.map((x) => x.R2x);\n let R2y = this.model.map((x) => x.R2y);\n\n this.output = {\n Q2y: Q2,\n R2x,\n R2y,\n tPred: m.plsC.t,\n pPred: m.plsC.p,\n wPred: m.plsC.w,\n betasPred: m.plsC.betas,\n Qpc: m.plsC.q,\n tCV,\n tOrthCV,\n tOrth: m.tOrth,\n pOrth: m.pOrth,\n wOrth: m.wOrth,\n XOrth,\n yHat: m.totalPred,\n Yres: m.plsC.yResidual,\n E,\n };\n }\n\n /**\n * get access to all the computed elements\n * Mainly for debug and testing\n * @return {Object} output object\n */\n getLogs() {\n return this.output;\n }\n\n getScores() {\n let scoresX = this.tCV.map((x) => x.to1DArray());\n let scoresY = this.tOrthCV.map((x) => x.to1DArray());\n return { scoresX, scoresY };\n }\n\n /**\n * Load an OPLS model from JSON\n * @param {Object} model\n * @return {OPLS}\n */\n static load(model) {\n if (typeof model.name !== 'string') {\n throw new TypeError('model must have a name property');\n }\n if (model.name !== 'OPLS') {\n throw new RangeError(`invalid model: ${model.name}`);\n }\n return new OPLS(true, [], model);\n }\n\n /**\n * Export the current model to a JSON object\n * @return {Object} model\n */\n toJSON() {\n return {\n name: 'OPLS',\n center: this.center,\n scale: this.scale,\n means: this.means,\n stdevs: this.stdevs,\n model: this.model,\n tCV: this.tCV,\n tOrthCV: this.tOrthCV,\n yHatCV: this.yHatCV,\n };\n }\n\n /**\n * Predict scores for new data\n * @param {Matrix} features - a matrix containing new data\n * @param {Object} [options]\n * @param {Array} [options.trueLabel] - an array with true values to compute confusion matrix\n * @param {Number} [options.nc] - the number of components to be used\n * @return {Object} - predictions\n */\n predict(newData, options = {}) {\n let { trueLabels = [], nc = 1 } = options;\n let labels = [];\n if (trueLabels.length > 0) {\n trueLabels = Matrix.from1DArray(trueLabels.length, 1, trueLabels);\n labels = trueLabels.clone();\n }\n\n let features = newData.clone();\n\n // scaling the test dataset with respect to the train\n if (this.center) {\n features.center('column', { center: this.means });\n if (labels.rows > 0 && this.mode === 'regression') {\n labels.center('column', { center: this.meansY });\n }\n }\n if (this.scale) {\n features.scale('column', { scale: this.stdevs });\n if (labels.rows > 0 && this.mode === 'regression') {\n labels.scale('column', { scale: this.stdevsY });\n }\n }\n\n let Eh = features.clone();\n // removing the orthogonal components from PLS\n let tOrth;\n let wOrth;\n let pOrth;\n let yHat;\n let tPred;\n\n for (let idx = 0; idx < nc; idx++) {\n wOrth = this.model[idx].wOrth.transpose();\n pOrth = this.model[idx].pOrth;\n tOrth = Eh.mmul(wOrth);\n Eh.sub(tOrth.mmul(pOrth));\n // prediction\n tPred = Eh.mmul(this.model[idx].plsC.w.transpose());\n // this should be summed over ncomp (pls_prediction.R line 23)\n yHat = tPred.mmul(this.model[idx].plsC.betas);\n }\n\n if (labels.rows > 0) {\n if (this.mode === 'regression') {\n let tssy = tss(labels);\n let press = tss(labels.clone().sub(yHat));\n let Q2y = 1 - press / tssy;\n\n return { tPred, tOrth, yHat, Q2y };\n } else if (this.mode === 'discriminantAnalysis') {\n let confusionMatrix = [];\n confusionMatrix = ConfusionMatrix.fromLabels(\n trueLabels.to1DArray(),\n yHat.to1DArray(),\n );\n\n return { tPred, tOrth, yHat, confusionMatrix };\n }\n } else {\n return { tPred, tOrth, yHat };\n }\n }\n\n _predictAll(features, labels, options = {}) {\n // cannot use the global this.center here\n // since it is used in the NC loop and\n // centering and scaling should only be\n // performed once\n const { center = true, scale = true } = options;\n\n if (center) {\n features.center('column');\n labels.center('column');\n }\n\n if (scale) {\n features.scale('column');\n labels.scale('column');\n // reevaluate tssy and tssx after scaling\n // must be global because re-used for next nc iteration\n // tssx is only evaluate the first time\n this.tssy = tss(labels);\n this.tssx = tss(features);\n }\n\n let oplsC = OPLSNipals(features, labels);\n let plsC = new NIPALS(oplsC.filteredX, { Y: labels });\n\n let tPred = oplsC.filteredX.mmul(plsC.w.transpose());\n let yHat = tPred.mmul(plsC.betas);\n\n let rss = tss(labels.clone().sub(yHat));\n let R2y = 1 - rss / this.tssy;\n\n let xEx = plsC.t.mmul(plsC.p);\n let rssx = tss(xEx);\n let R2x = rssx / this.tssx;\n\n return {\n R2y,\n R2x,\n xRes: oplsC.filteredX,\n tOrth: oplsC.scoresXOrtho,\n pOrth: oplsC.loadingsXOrtho,\n wOrth: oplsC.weightsXOrtho,\n tPred: tPred,\n totalPred: yHat,\n XOrth: oplsC.scoresXOrtho.mmul(oplsC.loadingsXOrtho),\n oplsC,\n plsC,\n };\n }\n /**\n *\n * @param {*} X - dataset matrix object\n * @param {*} group - labels matrix object\n * @param {*} index - train and test index (output from getFold())\n */\n _getTrainTest(X, group, index) {\n let testFeatures = new Matrix(index.testIndex.length, X.columns);\n let testLabels = new Matrix(index.testIndex.length, 1);\n index.testIndex.forEach((el, idx) => {\n testFeatures.setRow(idx, X.getRow(el));\n testLabels.setRow(idx, group.getRow(el));\n });\n\n let trainFeatures = new Matrix(index.trainIndex.length, X.columns);\n let trainLabels = new Matrix(index.trainIndex.length, 1);\n index.trainIndex.forEach((el, idx) => {\n trainFeatures.setRow(idx, X.getRow(el));\n trainLabels.setRow(idx, group.getRow(el));\n });\n\n return {\n trainFeatures,\n testFeatures,\n trainLabels,\n testLabels,\n };\n }\n}\n","'use strict';\n\nvar mlMatrix = require('ml-matrix');\n\nfunction logistic(val) {\n return 1 / (1 + Math.exp(-val));\n}\n\nfunction expELU(val, param) {\n return val < 0 ? param * (Math.exp(val) - 1) : val;\n}\n\nfunction softExponential(val, param) {\n if (param < 0) {\n return -Math.log(1 - param * (val + param)) / param;\n }\n if (param > 0) {\n return ((Math.exp(param * val) - 1) / param) + param;\n }\n return val;\n}\n\nfunction softExponentialPrime(val, param) {\n if (param < 0) {\n return 1 / (1 - param * (param + val));\n } else {\n return Math.exp(param * val);\n }\n}\n\nconst ACTIVATION_FUNCTIONS = {\n tanh: {\n activation: Math.tanh,\n derivate: (val) => 1 - (val * val)\n },\n identity: {\n activation: (val) => val,\n derivate: () => 1\n },\n logistic: {\n activation: logistic,\n derivate: (val) => logistic(val) * (1 - logistic(val))\n },\n arctan: {\n activation: Math.atan,\n derivate: (val) => 1 / (val * val + 1)\n },\n softsign: {\n activation: (val) => val / (1 + Math.abs(val)),\n derivate: (val) => 1 / ((1 + Math.abs(val)) * (1 + Math.abs(val)))\n },\n relu: {\n activation: (val) => (val < 0 ? 0 : val),\n derivate: (val) => (val < 0 ? 0 : 1)\n },\n softplus: {\n activation: (val) => Math.log(1 + Math.exp(val)),\n derivate: (val) => 1 / (1 + Math.exp(-val))\n },\n bent: {\n activation: (val) => ((Math.sqrt(val * val + 1) - 1) / 2) + val,\n derivate: (val) => (val / (2 * Math.sqrt(val * val + 1))) + 1\n },\n sinusoid: {\n activation: Math.sin,\n derivate: Math.cos\n },\n sinc: {\n activation: (val) => (val === 0 ? 1 : Math.sin(val) / val),\n derivate: (val) => (val === 0 ? 0 : (Math.cos(val) / val) - (Math.sin(val) / (val * val)))\n },\n gaussian: {\n activation: (val) => Math.exp(-(val * val)),\n derivate: (val) => -2 * val * Math.exp(-(val * val))\n },\n 'parametric-relu': {\n activation: (val, param) => (val < 0 ? param * val : val),\n derivate: (val, param) => (val < 0 ? param : 1)\n },\n 'exponential-elu': {\n activation: expELU,\n derivate: (val, param) => (val < 0 ? expELU(val, param) + param : 1)\n },\n 'soft-exponential': {\n activation: softExponential,\n derivate: softExponentialPrime\n }\n};\n\nclass Layer {\n /**\n * @private\n * Create a new layer with the given options\n * @param {object} options\n * @param {number} [options.inputSize] - Number of conections that enter the neurons.\n * @param {number} [options.outputSize] - Number of conections that leave the neurons.\n * @param {number} [options.regularization] - Regularization parameter.\n * @param {number} [options.epsilon] - Learning rate parameter.\n * @param {string} [options.activation] - Activation function parameter from the FeedForwardNeuralNetwork class.\n * @param {number} [options.activationParam] - Activation parameter if needed.\n */\n constructor(options) {\n this.inputSize = options.inputSize;\n this.outputSize = options.outputSize;\n this.regularization = options.regularization;\n this.epsilon = options.epsilon;\n this.activation = options.activation;\n this.activationParam = options.activationParam;\n\n var selectedFunction = ACTIVATION_FUNCTIONS[options.activation];\n var params = selectedFunction.activation.length;\n\n var actFunction = params > 1 ? (val) => selectedFunction.activation(val, options.activationParam) : selectedFunction.activation;\n var derFunction = params > 1 ? (val) => selectedFunction.derivate(val, options.activationParam) : selectedFunction.derivate;\n\n this.activationFunction = function (i, j) {\n this.set(i, j, actFunction(this.get(i, j)));\n };\n this.derivate = function (i, j) {\n this.set(i, j, derFunction(this.get(i, j)));\n };\n\n if (options.model) {\n // load model\n this.W = mlMatrix.Matrix.checkMatrix(options.W);\n this.b = mlMatrix.Matrix.checkMatrix(options.b);\n } else {\n // default constructor\n this.W = mlMatrix.Matrix.rand(this.inputSize, this.outputSize);\n this.b = mlMatrix.Matrix.zeros(1, this.outputSize);\n\n this.W.apply(function (i, j) {\n this.set(i, j, this.get(i, j) / Math.sqrt(options.inputSize));\n });\n }\n }\n\n /**\n * @private\n * propagate the given input through the current layer.\n * @param {Matrix} X - input.\n * @return {Matrix} output at the current layer.\n */\n forward(X) {\n var z = X.mmul(this.W).addRowVector(this.b);\n z.apply(this.activationFunction);\n this.a = z.clone();\n return z;\n }\n\n /**\n * @private\n * apply backpropagation algorithm at the current layer\n * @param {Matrix} delta - delta values estimated at the following layer.\n * @param {Matrix} a - 'a' values from the following layer.\n * @return {Matrix} the new delta values for the next layer.\n */\n backpropagation(delta, a) {\n this.dW = a.transpose().mmul(delta);\n this.db = mlMatrix.Matrix.rowVector(delta.sum('column'));\n\n var aCopy = a.clone();\n return delta.mmul(this.W.transpose()).mul(aCopy.apply(this.derivate));\n }\n\n /**\n * @private\n * Function that updates the weights at the current layer with the derivatives.\n */\n update() {\n this.dW.add(this.W.clone().mul(this.regularization));\n this.W.add(this.dW.mul(-this.epsilon));\n this.b.add(this.db.mul(-this.epsilon));\n }\n\n /**\n * @private\n * Export the current layer to JSON.\n * @return {object} model\n */\n toJSON() {\n return {\n model: 'Layer',\n inputSize: this.inputSize,\n outputSize: this.outputSize,\n regularization: this.regularization,\n epsilon: this.epsilon,\n activation: this.activation,\n W: this.W,\n b: this.b\n };\n }\n\n /**\n * @private\n * Creates a new Layer with the given model.\n * @param {object} model\n * @return {Layer}\n */\n static load(model) {\n if (model.model !== 'Layer') {\n throw new RangeError('the current model is not a Layer model');\n }\n return new Layer(model);\n }\n}\n\nclass OutputLayer extends Layer {\n constructor(options) {\n super(options);\n\n this.activationFunction = function (i, j) {\n this.set(i, j, Math.exp(this.get(i, j)));\n };\n }\n\n static load(model) {\n if (model.model !== 'Layer') {\n throw new RangeError('the current model is not a Layer model');\n }\n\n return new OutputLayer(model);\n }\n}\n\nclass FeedForwardNeuralNetworks {\n /**\n * Create a new Feedforward neural network model.\n * @class FeedForwardNeuralNetworks\n * @param {object} [options]\n * @param {Array} [options.hiddenLayers=[10]] - Array that contains the sizes of the hidden layers.\n * @param {number} [options.iterations=50] - Number of iterations at the training step.\n * @param {number} [options.learningRate=0.01] - Learning rate of the neural net (also known as epsilon).\n * @param {number} [options.regularization=0.01] - Regularization parameter af the neural net.\n * @param {string} [options.activation='tanh'] - activation function to be used. (options: 'tanh'(default),\n * 'identity', 'logistic', 'arctan', 'softsign', 'relu', 'softplus', 'bent', 'sinusoid', 'sinc', 'gaussian').\n * (single-parametric options: 'parametric-relu', 'exponential-relu', 'soft-exponential').\n * @param {number} [options.activationParam=1] - if the selected activation function needs a parameter.\n */\n constructor(options) {\n options = options || {};\n if (options.model) {\n // load network\n this.hiddenLayers = options.hiddenLayers;\n this.iterations = options.iterations;\n this.learningRate = options.learningRate;\n this.regularization = options.regularization;\n this.dicts = options.dicts;\n this.activation = options.activation;\n this.activationParam = options.activationParam;\n this.model = new Array(options.layers.length);\n\n for (var i = 0; i < this.model.length - 1; ++i) {\n this.model[i] = Layer.load(options.layers[i]);\n }\n this.model[this.model.length - 1] = OutputLayer.load(options.layers[this.model.length - 1]);\n } else {\n // default constructor\n this.hiddenLayers = options.hiddenLayers || [10];\n this.iterations = options.iterations || 50;\n\n this.learningRate = options.learningRate || 0.01;\n this.regularization = options.regularization || 0.01;\n\n this.activation = options.activation || 'tanh';\n this.activationParam = options.activationParam || 1;\n if (!(this.activation in Object.keys(ACTIVATION_FUNCTIONS))) {\n this.activation = 'tanh';\n }\n }\n }\n\n /**\n * @private\n * Function that build and initialize the neural net.\n * @param {number} inputSize - total of features to fit.\n * @param {number} outputSize - total of labels of the prediction set.\n */\n buildNetwork(inputSize, outputSize) {\n var size = 2 + (this.hiddenLayers.length - 1);\n this.model = new Array(size);\n\n // input layer\n this.model[0] = new Layer({\n inputSize: inputSize,\n outputSize: this.hiddenLayers[0],\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n\n // hidden layers\n for (var i = 1; i < this.hiddenLayers.length; ++i) {\n this.model[i] = new Layer({\n inputSize: this.hiddenLayers[i - 1],\n outputSize: this.hiddenLayers[i],\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n }\n\n // output layer\n this.model[size - 1] = new OutputLayer({\n inputSize: this.hiddenLayers[this.hiddenLayers.length - 1],\n outputSize: outputSize,\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n }\n\n /**\n * Train the neural net with the given features and labels.\n * @param {Matrix|Array} features\n * @param {Matrix|Array} labels\n */\n train(features, labels) {\n features = mlMatrix.Matrix.checkMatrix(features);\n this.dicts = dictOutputs(labels);\n\n var inputSize = features.columns;\n var outputSize = Object.keys(this.dicts.inputs).length;\n\n if (!this.model) {\n this.buildNetwork(inputSize, outputSize);\n }\n\n for (var i = 0; i < this.iterations; ++i) {\n var probabilities = this.propagate(features);\n this.backpropagation(features, labels, probabilities);\n }\n }\n\n /**\n * @private\n * Propagate the input(training set) and retrives the probabilities of each class.\n * @param {Matrix} X\n * @return {Matrix} probabilities of each class.\n */\n propagate(X) {\n var input = X;\n for (var i = 0; i < this.model.length; ++i) {\n input = this.model[i].forward(input);\n }\n\n // get probabilities\n return input.divColumnVector(input.sum('row'));\n }\n\n /**\n * @private\n * Function that applies the backpropagation algorithm on each layer of the network\n * in order to fit the features and labels.\n * @param {Matrix} features\n * @param {Array} labels\n * @param {Matrix} probabilities - probabilities of each class of the feature set.\n */\n backpropagation(features, labels, probabilities) {\n for (var i = 0; i < probabilities.rows; ++i) {\n probabilities.set(i, this.dicts.inputs[labels[i]], probabilities.get(i, this.dicts.inputs[labels[i]]) - 1);\n }\n\n // remember, the last delta doesn't matter\n var delta = probabilities;\n for (i = this.model.length - 1; i >= 0; --i) {\n var a = i > 0 ? this.model[i - 1].a : features;\n delta = this.model[i].backpropagation(delta, a);\n }\n\n for (i = 0; i < this.model.length; ++i) {\n this.model[i].update();\n }\n }\n\n /**\n * Predict the output given the feature set.\n * @param {Array|Matrix} features\n * @return {Array}\n */\n predict(features) {\n features = mlMatrix.Matrix.checkMatrix(features);\n var outputs = new Array(features.rows);\n var probabilities = this.propagate(features);\n for (var i = 0; i < features.rows; ++i) {\n outputs[i] = this.dicts.outputs[probabilities.maxRowIndex(i)[1]];\n }\n\n return outputs;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} model\n */\n toJSON() {\n var model = {\n model: 'FNN',\n hiddenLayers: this.hiddenLayers,\n iterations: this.iterations,\n learningRate: this.learningRate,\n regularization: this.regularization,\n activation: this.activation,\n activationParam: this.activationParam,\n dicts: this.dicts,\n layers: new Array(this.model.length)\n };\n\n for (var i = 0; i < this.model.length; ++i) {\n model.layers[i] = this.model[i].toJSON();\n }\n\n return model;\n }\n\n /**\n * Load a Feedforward Neural Network with the current model.\n * @param {object} model\n * @return {FeedForwardNeuralNetworks}\n */\n static load(model) {\n if (model.model !== 'FNN') {\n throw new RangeError('the current model is not a feed forward network');\n }\n\n return new FeedForwardNeuralNetworks(model);\n }\n}\n\n/**\n * @private\n * Method that given an array of labels(predictions), returns two dictionaries, one to transform from labels to\n * numbers and other in the reverse way\n * @param {Array} array\n * @return {object}\n */\nfunction dictOutputs(array) {\n var inputs = {};\n var outputs = {};\n var index = 0;\n for (var i = 0; i < array.length; i += 1) {\n if (inputs[array[i]] === undefined) {\n inputs[array[i]] = index;\n outputs[index] = array[i];\n index++;\n }\n }\n\n return {\n inputs: inputs,\n outputs: outputs\n };\n}\n\nmodule.exports = FeedForwardNeuralNetworks;\n","function NodeSquare(x, y, weights, som) {\n this.x = x;\n this.y = y;\n this.weights = weights;\n this.som = som;\n this.neighbors = {};\n}\n\nNodeSquare.prototype.adjustWeights = function adjustWeights(target, learningRate, influence) {\n for (var i = 0, ii = this.weights.length; i < ii; i++) {\n this.weights[i] += learningRate * influence * (target[i] - this.weights[i]);\n }\n};\n\nNodeSquare.prototype.getDistance = function getDistance(otherNode) {\n return Math.max(Math.abs(this.x - otherNode.x), Math.abs(this.y - otherNode.y));\n};\n\nNodeSquare.prototype.getDistanceTorus = function getDistanceTorus(otherNode) {\n var distX = Math.abs(this.x - otherNode.x),\n distY = Math.abs(this.y - otherNode.y);\n return Math.max(Math.min(distX, this.som.gridDim.x - distX), Math.min(distY, this.som.gridDim.y - distY));\n};\n\nNodeSquare.prototype.getNeighbors = function getNeighbors(xy) {\n if (!this.neighbors[xy]) {\n this.neighbors[xy] = new Array(2);\n\n // left or bottom neighbor\n var v;\n if (this[xy] > 0) {\n v = this[xy] - 1;\n } else if (this.som.torus) {\n v = this.som.gridDim[xy] - 1\n }\n if (typeof v !== 'undefined') {\n var x, y;\n if (xy === 'x') {\n x = v;\n y = this.y;\n } else {\n x = this.x;\n y = v;\n }\n this.neighbors[xy][0] = this.som.nodes[x][y];\n }\n\n // top or right neighbor\n var w;\n if (this[xy] < (this.som.gridDim[xy] - 1)) {\n w = this[xy] + 1;\n } else if (this.som.torus) {\n w = 0;\n }\n if (typeof w !== 'undefined') {\n if (xy === 'x') {\n x = w;\n y = this.y;\n } else {\n x = this.x;\n y = w;\n }\n this.neighbors[xy][1] = this.som.nodes[x][y];\n }\n }\n return this.neighbors[xy];\n};\n\nNodeSquare.prototype.getPos = function getPos(xy, element) {\n var neighbors = this.getNeighbors(xy),\n distance = this.som.distance,\n bestNeighbor,\n direction;\n if(neighbors[0]) {\n if (neighbors[1]) {\n var dist1 = distance(element, neighbors[0].weights),\n dist2 = distance(element, neighbors[1].weights);\n if(dist1 < dist2) {\n bestNeighbor = neighbors[0];\n direction = -1;\n } else {\n bestNeighbor = neighbors[1];\n direction = 1;\n }\n } else {\n bestNeighbor = neighbors[0];\n direction = -1;\n }\n } else {\n bestNeighbor = neighbors[1];\n direction = 1;\n }\n var simA = 1 - distance(element, this.weights),\n simB = 1 - distance(element, bestNeighbor.weights);\n var factor = ((simA - simB) / (2 - simA - simB));\n return 0.5 + 0.5 * factor * direction;\n};\n\nNodeSquare.prototype.getPosition = function getPosition(element) {\n return [\n this.getPos('x', element),\n this.getPos('y', element)\n ];\n};\n\nmodule.exports = NodeSquare;","var NodeSquare = require('./node-square');\n\nfunction NodeHexagonal(x, y, weights, som) {\n\n NodeSquare.call(this, x, y, weights, som);\n\n this.hX = x - Math.floor(y / 2);\n this.z = 0 - this.hX - y;\n\n}\n\nNodeHexagonal.prototype = new NodeSquare;\nNodeHexagonal.prototype.constructor = NodeHexagonal;\n\nNodeHexagonal.prototype.getDistance = function getDistanceHexagonal(otherNode) {\n return Math.max(Math.abs(this.hX - otherNode.hX), Math.abs(this.y - otherNode.y), Math.abs(this.z - otherNode.z));\n};\n\nNodeHexagonal.prototype.getDistanceTorus = function getDistanceTorus(otherNode) {\n var distX = Math.abs(this.hX - otherNode.hX),\n distY = Math.abs(this.y - otherNode.y),\n distZ = Math.abs(this.z - otherNode.z);\n return Math.max(Math.min(distX, this.som.gridDim.x - distX), Math.min(distY, this.som.gridDim.y - distY), Math.min(distZ, this.som.gridDim.z - distZ));\n};\n\nNodeHexagonal.prototype.getPosition = function getPosition() {\n throw new Error('Unimplemented : cannot get position of the points for hexagonal grid');\n};\n\nmodule.exports = NodeHexagonal;","'use strict';\n\nvar NodeSquare = require('./node-square'),\n NodeHexagonal = require('./node-hexagonal');\n\nvar defaultOptions = {\n fields: 3,\n randomizer: Math.random,\n distance: squareEuclidean,\n iterations: 10,\n learningRate: 0.1,\n gridType: 'rect',\n torus: true,\n method: 'random'\n};\n\nfunction SOM(x, y, options, reload) {\n\n this.x = x;\n this.y = y;\n\n options = options || {};\n this.options = {};\n for (var i in defaultOptions) {\n if (options.hasOwnProperty(i)) {\n this.options[i] = options[i];\n } else {\n this.options[i] = defaultOptions[i];\n }\n }\n\n if (typeof this.options.fields === 'number') {\n this.numWeights = this.options.fields;\n } else if (Array.isArray(this.options.fields)) {\n this.numWeights = this.options.fields.length;\n var converters = getConverters(this.options.fields);\n this.extractor = converters.extractor;\n this.creator = converters.creator;\n } else {\n throw new Error('Invalid fields definition');\n }\n\n if (this.options.gridType === 'rect') {\n this.nodeType = NodeSquare;\n this.gridDim = {\n x: x,\n y: y\n };\n } else {\n this.nodeType = NodeHexagonal;\n var hx = this.x - Math.floor(this.y / 2);\n this.gridDim = {\n x: hx,\n y: this.y,\n z: -(0 - hx - this.y)\n };\n }\n\n this.torus = this.options.torus;\n this.distanceMethod = this.torus ? 'getDistanceTorus' : 'getDistance';\n\n this.distance = this.options.distance;\n\n this.maxDistance = getMaxDistance(this.distance, this.numWeights);\n\n if (reload === true) { // For model loading\n this.done = true;\n return;\n }\n if (!(x > 0 && y > 0)) {\n throw new Error('x and y must be positive');\n }\n\n this.times = {\n findBMU: 0,\n adjust: 0\n };\n\n this.randomizer = this.options.randomizer;\n\n this.iterationCount = 0;\n this.iterations = this.options.iterations;\n\n this.startLearningRate = this.learningRate = this.options.learningRate;\n\n this.mapRadius = Math.floor(Math.max(x, y) / 2);\n\n this.algorithmMethod = this.options.method;\n\n this._initNodes();\n\n this.done = false;\n}\n\nSOM.load = function loadModel(model, distance) {\n if (model.name === 'SOM') {\n var x = model.data.length,\n y = model.data[0].length;\n if (distance) {\n model.options.distance = distance;\n } else if (model.options.distance) {\n model.options.distance = eval('(' + model.options.distance + ')');\n }\n var som = new SOM(x, y, model.options, true);\n som.nodes = new Array(x);\n for (var i = 0; i < x; i++) {\n som.nodes[i] = new Array(y);\n for (var j = 0; j < y; j++) {\n som.nodes[i][j] = new som.nodeType(i, j, model.data[i][j], som);\n }\n }\n return som;\n } else {\n throw new Error('expecting a SOM model');\n }\n};\n\nSOM.prototype.export = function exportModel(includeDistance) {\n if (!this.done) {\n throw new Error('model is not ready yet');\n }\n var model = {\n name: 'SOM'\n };\n model.options = {\n fields: this.options.fields,\n gridType: this.options.gridType,\n torus: this.options.torus\n };\n model.data = new Array(this.x);\n for (var i = 0; i < this.x; i++) {\n model.data[i] = new Array(this.y);\n for (var j = 0; j < this.y; j++) {\n model.data[i][j] = this.nodes[i][j].weights;\n }\n }\n if (includeDistance) {\n model.options.distance = this.distance.toString();\n }\n return model;\n};\n\nSOM.prototype._initNodes = function initNodes() {\n var now = Date.now(),\n i, j, k;\n this.nodes = new Array(this.x);\n for (i = 0; i < this.x; i++) {\n this.nodes[i] = new Array(this.y);\n for (j = 0; j < this.y; j++) {\n var weights = new Array(this.numWeights);\n for (k = 0; k < this.numWeights; k++) {\n weights[k] = this.randomizer();\n }\n this.nodes[i][j] = new this.nodeType(i, j, weights, this);\n }\n }\n this.times.initNodes = Date.now() - now;\n};\n\nSOM.prototype.setTraining = function setTraining(trainingSet) {\n if (this.trainingSet) {\n throw new Error('training set has already been set');\n }\n var now = Date.now();\n var convertedSet = trainingSet;\n var i, l = trainingSet.length;\n if (this.extractor) {\n convertedSet = new Array(l);\n for (i = 0; i < l; i++) {\n convertedSet[i] = this.extractor(trainingSet[i]);\n }\n }\n this.numIterations = this.iterations * l;\n\n if (this.algorithmMethod === 'random') {\n this.timeConstant = this.numIterations / Math.log(this.mapRadius);\n } else {\n this.timeConstant = l / Math.log(this.mapRadius);\n }\n this.trainingSet = convertedSet;\n this.times.setTraining = Date.now() - now;\n};\n\nSOM.prototype.trainOne = function trainOne() {\n if (this.done) {\n\n return false;\n\n } else if (this.numIterations-- > 0) {\n\n var neighbourhoodRadius,\n trainingValue,\n trainingSetFactor;\n\n if (this.algorithmMethod === 'random') { // Pick a random value of the training set at each step\n neighbourhoodRadius = this.mapRadius * Math.exp(-this.iterationCount / this.timeConstant);\n trainingValue = getRandomValue(this.trainingSet, this.randomizer);\n this._adjust(trainingValue, neighbourhoodRadius);\n this.learningRate = this.startLearningRate * Math.exp(-this.iterationCount / this.numIterations);\n } else { // Get next input vector\n trainingSetFactor = -Math.floor(this.iterationCount / this.trainingSet.length);\n neighbourhoodRadius = this.mapRadius * Math.exp(trainingSetFactor / this.timeConstant);\n trainingValue = this.trainingSet[this.iterationCount % this.trainingSet.length];\n this._adjust(trainingValue, neighbourhoodRadius);\n if (((this.iterationCount + 1) % this.trainingSet.length) === 0) {\n this.learningRate = this.startLearningRate * Math.exp(trainingSetFactor / Math.floor(this.numIterations / this.trainingSet.length));\n }\n }\n\n this.iterationCount++;\n\n return true;\n\n } else {\n\n this.done = true;\n return false;\n\n }\n};\n\nSOM.prototype._adjust = function adjust(trainingValue, neighbourhoodRadius) {\n var now = Date.now(),\n x, y, dist, influence;\n\n var bmu = this._findBestMatchingUnit(trainingValue);\n\n var now2 = Date.now();\n this.times.findBMU += now2 - now;\n\n var radiusLimit = Math.floor(neighbourhoodRadius);\n var xMin = bmu.x - radiusLimit,\n xMax = bmu.x + radiusLimit,\n yMin = bmu.y - radiusLimit,\n yMax = bmu.y + radiusLimit;\n\n for (x = xMin; x <= xMax; x++) {\n var theX = x;\n if (x < 0) {\n theX += this.x;\n } else if (x >= this.x) {\n theX -= this.x;\n }\n for (y = yMin; y <= yMax; y++) {\n var theY = y;\n if (y < 0) {\n theY += this.y;\n } else if (y >= this.y) {\n theY -= this.y;\n }\n\n dist = bmu[this.distanceMethod](this.nodes[theX][theY]);\n\n if (dist < neighbourhoodRadius) {\n influence = Math.exp(-dist / (2 * neighbourhoodRadius));\n this.nodes[theX][theY].adjustWeights(trainingValue, this.learningRate, influence);\n }\n\n }\n }\n\n this.times.adjust += (Date.now() - now2);\n\n};\n\nSOM.prototype.train = function train(trainingSet) {\n if (!this.done) {\n this.setTraining(trainingSet);\n while (this.trainOne()) {\n }\n }\n};\n\nSOM.prototype.getConvertedNodes = function getConvertedNodes() {\n var result = new Array(this.x);\n for (var i = 0; i < this.x; i++) {\n result[i] = new Array(this.y);\n for (var j = 0; j < this.y; j++) {\n var node = this.nodes[i][j];\n result[i][j] = this.creator ? this.creator(node.weights) : node.weights;\n }\n }\n return result;\n};\n\nSOM.prototype._findBestMatchingUnit = function findBestMatchingUnit(candidate) {\n\n var bmu,\n lowest = Infinity,\n dist;\n\n for (var i = 0; i < this.x; i++) {\n for (var j = 0; j < this.y; j++) {\n dist = this.distance(this.nodes[i][j].weights, candidate);\n if (dist < lowest) {\n lowest = dist;\n bmu = this.nodes[i][j];\n }\n }\n }\n\n return bmu;\n\n};\n\nSOM.prototype.predict = function predict(data, computePosition) {\n if (typeof data === 'boolean') {\n computePosition = data;\n data = null;\n }\n if (!data) {\n data = this.trainingSet;\n }\n if (Array.isArray(data) && (Array.isArray(data[0]) || (typeof data[0] === 'object'))) { // predict a dataset\n var self = this;\n return data.map(function (element) {\n return self._predict(element, computePosition);\n });\n } else { // predict a single element\n return this._predict(data, computePosition);\n }\n};\n\nSOM.prototype._predict = function _predict(element, computePosition) {\n if (!Array.isArray(element)) {\n element = this.extractor(element);\n }\n var bmu = this._findBestMatchingUnit(element);\n var result = [bmu.x, bmu.y];\n if (computePosition) {\n result[2] = bmu.getPosition(element);\n }\n return result;\n};\n\n// As seen in http://www.scholarpedia.org/article/Kohonen_network\nSOM.prototype.getQuantizationError = function getQuantizationError() {\n var fit = this.getFit(),\n l = fit.length,\n sum = 0;\n for (var i = 0; i < l; i++) {\n sum += fit[i];\n }\n return sum / l;\n};\n\nSOM.prototype.getFit = function getFit(dataset) {\n if (!dataset) {\n dataset = this.trainingSet;\n }\n var l = dataset.length,\n bmu,\n result = new Array(l);\n for (var i = 0; i < l; i++) {\n bmu = this._findBestMatchingUnit(dataset[i]);\n result[i] = Math.sqrt(this.distance(dataset[i], bmu.weights));\n }\n return result;\n};\n\nfunction getConverters(fields) {\n var l = fields.length,\n normalizers = new Array(l),\n denormalizers = new Array(l);\n for (var i = 0; i < l; i++) {\n normalizers[i] = getNormalizer(fields[i].range);\n denormalizers[i] = getDenormalizer(fields[i].range);\n }\n return {\n extractor: function extractor(value) {\n var result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = normalizers[i](value[fields[i].name]);\n }\n return result;\n },\n creator: function creator(value) {\n var result = {};\n for (var i = 0; i < l; i++) {\n result[fields[i].name] = denormalizers[i](value[i]);\n }\n return result;\n }\n };\n}\n\nfunction getNormalizer(minMax) {\n return function normalizer(value) {\n return (value - minMax[0]) / (minMax[1] - minMax[0]);\n };\n}\n\nfunction getDenormalizer(minMax) {\n return function denormalizer(value) {\n return (minMax[0] + value * (minMax[1] - minMax[0]));\n };\n}\n\nfunction squareEuclidean(a, b) {\n var d = 0;\n for (var i = 0, ii = a.length; i < ii; i++) {\n d += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return d;\n}\n\nfunction getRandomValue(arr, randomizer) {\n return arr[Math.floor(randomizer() * arr.length)];\n}\n\nfunction getMaxDistance(distance, numWeights) {\n var zero = new Array(numWeights),\n one = new Array(numWeights);\n for (var i = 0; i < numWeights; i++) {\n zero[i] = 0;\n one[i] = 1;\n }\n return distance(zero, one);\n}\n\nmodule.exports = SOM;","export default function maybeToPrecision(value, digits) {\n if (value < 0) {\n value = 0 - value;\n if (typeof digits === 'number') {\n return `- ${value.toPrecision(digits)}`;\n } else {\n return `- ${value.toString()}`;\n }\n } else {\n if (typeof digits === 'number') {\n return value.toPrecision(digits);\n } else {\n return value.toString();\n }\n }\n}\n","export default function checkArraySize(x, y) {\n if (!Array.isArray(x) || !Array.isArray(y)) {\n throw new TypeError('x and y must be arrays');\n }\n if (x.length !== y.length) {\n throw new RangeError('x and y arrays must have the same length');\n }\n}\n","export { default as maybeToPrecision } from './maybeToPrecision';\nexport { default as checkArrayLength } from './checkArrayLength';\n\nexport default class BaseRegression {\n constructor() {\n if (new.target === BaseRegression) {\n throw new Error('BaseRegression must be subclassed');\n }\n }\n\n predict(x) {\n if (typeof x === 'number') {\n return this._predict(x);\n } else if (Array.isArray(x)) {\n const y = [];\n for (let i = 0; i < x.length; i++) {\n y.push(this._predict(x[i]));\n }\n return y;\n } else {\n throw new TypeError('x must be a number or array');\n }\n }\n\n _predict() {\n throw new Error('_predict must be implemented');\n }\n\n train() {\n // Do nothing for this package\n }\n\n toString() {\n return '';\n }\n\n toLaTeX() {\n return '';\n }\n\n /**\n * Return the correlation coefficient of determination (r) and chi-square.\n * @param {Array} x\n * @param {Array} y\n * @return {object}\n */\n score(x, y) {\n if (!Array.isArray(x) || !Array.isArray(y) || x.length !== y.length) {\n throw new Error('x and y must be arrays of the same length');\n }\n\n const n = x.length;\n const y2 = new Array(n);\n for (let i = 0; i < n; i++) {\n y2[i] = this._predict(x[i]);\n }\n\n let xSum = 0;\n let ySum = 0;\n let chi2 = 0;\n let rmsd = 0;\n let xSquared = 0;\n let ySquared = 0;\n let xY = 0;\n for (let i = 0; i < n; i++) {\n xSum += y2[i];\n ySum += y[i];\n xSquared += y2[i] * y2[i];\n ySquared += y[i] * y[i];\n xY += y2[i] * y[i];\n if (y[i] !== 0) {\n chi2 += ((y[i] - y2[i]) * (y[i] - y2[i])) / y[i];\n }\n rmsd += (y[i] - y2[i]) * (y[i] - y2[i]);\n }\n\n const r =\n (n * xY - xSum * ySum) /\n Math.sqrt((n * xSquared - xSum * xSum) * (n * ySquared - ySum * ySum));\n\n return {\n r: r,\n r2: r * r,\n chi2: chi2,\n rmsd: Math.sqrt(rmsd / n)\n };\n }\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport { Matrix, MatrixTransposeView, solve } from 'ml-matrix';\n\nexport default class PolynomialRegression extends BaseRegression {\n constructor(x, y, degree) {\n super();\n if (x === true) {\n this.degree = y.degree;\n this.powers = y.powers;\n this.coefficients = y.coefficients;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y, degree);\n }\n }\n\n _predict(x) {\n let y = 0;\n for (let k = 0; k < this.powers.length; k++) {\n y += this.coefficients[k] * Math.pow(x, this.powers[k]);\n }\n return y;\n }\n\n toJSON() {\n return {\n name: 'polynomialRegression',\n degree: this.degree,\n powers: this.powers,\n coefficients: this.coefficients\n };\n }\n\n toString(precision) {\n return this._toFormula(precision, false);\n }\n\n toLaTeX(precision) {\n return this._toFormula(precision, true);\n }\n\n _toFormula(precision, isLaTeX) {\n let sup = '^';\n let closeSup = '';\n let times = ' * ';\n if (isLaTeX) {\n sup = '^{';\n closeSup = '}';\n times = '';\n }\n\n let fn = '';\n let str = '';\n for (let k = 0; k < this.coefficients.length; k++) {\n str = '';\n if (this.coefficients[k] !== 0) {\n if (this.powers[k] === 0) {\n str = maybeToPrecision(this.coefficients[k], precision);\n } else {\n if (this.powers[k] === 1) {\n str =\n `${maybeToPrecision(this.coefficients[k], precision) + times}x`;\n } else {\n str =\n `${maybeToPrecision(this.coefficients[k], precision) +\n times\n }x${\n sup\n }${this.powers[k]\n }${closeSup}`;\n }\n }\n\n if (this.coefficients[k] > 0 && k !== this.coefficients.length - 1) {\n str = ` + ${str}`;\n } else if (k !== this.coefficients.length - 1) {\n str = ` ${str}`;\n }\n }\n fn = str + fn;\n }\n if (fn.charAt(0) === '+') {\n fn = fn.slice(1);\n }\n\n return `f(x) = ${fn}`;\n }\n\n static load(json) {\n if (json.name !== 'polynomialRegression') {\n throw new TypeError('not a polynomial regression model');\n }\n return new PolynomialRegression(true, json);\n }\n}\n\nfunction regress(pr, x, y, degree) {\n const n = x.length;\n let powers;\n if (Array.isArray(degree)) {\n powers = degree;\n degree = powers.length;\n } else {\n degree++;\n powers = new Array(degree);\n for (let k = 0; k < degree; k++) {\n powers[k] = k;\n }\n }\n const F = new Matrix(n, degree);\n const Y = new Matrix([y]);\n for (let k = 0; k < degree; k++) {\n for (let i = 0; i < n; i++) {\n if (powers[k] === 0) {\n F.set(i, k, 1);\n } else {\n F.set(i, k, Math.pow(x[i], powers[k]));\n }\n }\n }\n\n const FT = new MatrixTransposeView(F);\n const A = FT.mmul(F);\n const B = FT.mmul(new MatrixTransposeView(Y));\n\n pr.degree = degree - 1;\n pr.powers = powers;\n pr.coefficients = solve(A, B).to1DArray();\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\n\nexport default class SimpleLinearRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n this.slope = y.slope;\n this.intercept = y.intercept;\n this.coefficients = [y.intercept, y.slope];\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n toJSON() {\n return {\n name: 'simpleLinearRegression',\n slope: this.slope,\n intercept: this.intercept\n };\n }\n\n _predict(x) {\n return this.slope * x + this.intercept;\n }\n\n computeX(y) {\n return (y - this.intercept) / this.slope;\n }\n\n toString(precision) {\n let result = 'f(x) = ';\n if (this.slope !== 0) {\n const xFactor = maybeToPrecision(this.slope, precision);\n result += `${xFactor === '1' ? '' : `${xFactor} * `}x`;\n if (this.intercept !== 0) {\n const absIntercept = Math.abs(this.intercept);\n const operator = absIntercept === this.intercept ? '+' : '-';\n result += ` ${operator} ${maybeToPrecision(absIntercept, precision)}`;\n }\n } else {\n result += maybeToPrecision(this.intercept, precision);\n }\n return result;\n }\n\n toLaTeX(precision) {\n return this.toString(precision);\n }\n\n static load(json) {\n if (json.name !== 'simpleLinearRegression') {\n throw new TypeError('not a SLR model');\n }\n return new SimpleLinearRegression(true, json);\n }\n}\n\nfunction regress(slr, x, y) {\n const n = x.length;\n let xSum = 0;\n let ySum = 0;\n\n let xSquared = 0;\n let xY = 0;\n\n for (let i = 0; i < n; i++) {\n xSum += x[i];\n ySum += y[i];\n xSquared += x[i] * x[i];\n xY += x[i] * y[i];\n }\n\n const numerator = n * xY - xSum * ySum;\n slr.slope = numerator / (n * xSquared - xSum * xSum);\n slr.intercept = (1 / n) * ySum - slr.slope * (1 / n) * xSum;\n slr.coefficients = [slr.intercept, slr.slope];\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport SimpleLinearRegression from 'ml-regression-simple-linear';\n\nexport default class ExponentialRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n this.A = y.A;\n this.B = y.B;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n _predict(input) {\n return this.B * Math.exp(input * this.A);\n }\n\n toJSON() {\n return {\n name: 'exponentialRegression',\n A: this.A,\n B: this.B\n };\n }\n\n toString(precision) {\n return (\n `f(x) = ${\n maybeToPrecision(this.B, precision)\n } * e^(${\n maybeToPrecision(this.A, precision)\n } * x)`\n );\n }\n\n toLaTeX(precision) {\n if (this.A >= 0) {\n return (\n `f(x) = ${\n maybeToPrecision(this.B, precision)\n }e^{${\n maybeToPrecision(this.A, precision)\n }x}`\n );\n } else {\n return (\n `f(x) = \\\\frac{${\n maybeToPrecision(this.B, precision)\n }}{e^{${\n maybeToPrecision(-this.A, precision)\n }x}}`\n );\n }\n }\n\n static load(json) {\n if (json.name !== 'exponentialRegression') {\n throw new TypeError('not a exponential regression model');\n }\n return new ExponentialRegression(true, json);\n }\n}\n\nfunction regress(er, x, y) {\n const n = x.length;\n const yl = new Array(n);\n for (let i = 0; i < n; i++) {\n yl[i] = Math.log(y[i]);\n }\n\n const linear = new SimpleLinearRegression(x, yl);\n er.A = linear.slope;\n er.B = Math.exp(linear.intercept);\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport SimpleLinearRegression from 'ml-regression-simple-linear';\n\nexport default class PowerRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n // reloading model\n this.A = y.A;\n this.B = y.B;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n _predict(newInputs) {\n return this.A * Math.pow(newInputs, this.B);\n }\n\n toJSON() {\n return {\n name: 'powerRegression',\n A: this.A,\n B: this.B\n };\n }\n\n toString(precision) {\n return `f(x) = ${maybeToPrecision(\n this.A,\n precision\n )} * x^${maybeToPrecision(this.B, precision)}`;\n }\n\n toLaTeX(precision) {\n let latex = '';\n if (this.B >= 0) {\n latex = `f(x) = ${maybeToPrecision(\n this.A,\n precision\n )}x^{${maybeToPrecision(this.B, precision)}}`;\n } else {\n latex = `f(x) = \\\\frac{${maybeToPrecision(\n this.A,\n precision\n )}}{x^{${maybeToPrecision(-this.B, precision)}}}`;\n }\n latex = latex.replace(/e([+-]?[0-9]+)/g, 'e^{$1}');\n return latex;\n }\n\n static load(json) {\n if (json.name !== 'powerRegression') {\n throw new TypeError('not a power regression model');\n }\n return new PowerRegression(true, json);\n }\n}\n\nfunction regress(pr, x, y) {\n const n = x.length;\n const xl = new Array(n);\n const yl = new Array(n);\n for (let i = 0; i < n; i++) {\n xl[i] = Math.log(x[i]);\n yl[i] = Math.log(y[i]);\n }\n\n const linear = new SimpleLinearRegression(xl, yl);\n pr.A = Math.exp(linear.intercept);\n pr.B = linear.slope;\n}\n","import Matrix, { SVD, pseudoInverse } from 'ml-matrix';\n\nexport default class MultivariateLinearRegression {\n constructor(x, y, options = {}) {\n const { intercept = true, statistics = true } = options;\n this.statistics = statistics;\n if (x === true) {\n this.weights = y.weights;\n this.inputs = y.inputs;\n this.outputs = y.outputs;\n this.intercept = y.intercept;\n } else {\n x = new Matrix(x);\n y = new Matrix(y);\n if (intercept) {\n x.addColumn(new Array(x.rows).fill(1));\n }\n let xt = x.transpose();\n const xx = xt\n .mmul(x);\n const xy = xt\n .mmul(y);\n const invxx = new SVD(xx)\n .inverse();\n const beta = xy\n .transpose()\n .mmul(invxx)\n .transpose();\n this.weights = beta.to2DArray();\n this.inputs = x.columns;\n this.outputs = y.columns;\n if (intercept) this.inputs--;\n this.intercept = intercept;\n if (statistics) {\n /*\n * Let's add some basic statistics about the beta's to be able to interpret them.\n * source: http://dept.stat.lsa.umich.edu/~kshedden/Courses/Stat401/Notes/401-multreg.pdf\n * validated against Excel Regression AddIn\n * test: \"datamining statistics test\"\n */\n const fittedValues = x.mmul(beta);\n const residuals = y.clone().addM(fittedValues.neg());\n const variance =\n residuals\n .to2DArray()\n .map((ri) => Math.pow(ri[0], 2))\n .reduce((a, b) => a + b) /\n (y.rows - x.columns);\n this.stdError = Math.sqrt(variance);\n this.stdErrorMatrix = pseudoInverse(xx).mul(variance);\n this.stdErrors = this.stdErrorMatrix\n .diagonal()\n .map((d) => Math.sqrt(d));\n this.tStats = this.weights.map((d, i) =>\n (this.stdErrors[i] === 0 ? 0 : d[0] / this.stdErrors[i])\n );\n }\n }\n }\n\n predict(x) {\n if (Array.isArray(x)) {\n if (typeof x[0] === 'number') {\n return this._predict(x);\n } else if (Array.isArray(x[0])) {\n const y = new Array(x.length);\n for (let i = 0; i < x.length; i++) {\n y[i] = this._predict(x[i]);\n }\n return y;\n }\n } else if (Matrix.isMatrix(x)) {\n const y = new Matrix(x.rows, this.outputs);\n for (let i = 0; i < x.rows; i++) {\n y.setRow(i, this._predict(x.getRow(i)));\n }\n return y;\n }\n throw new TypeError('x must be a matrix or array of numbers');\n }\n\n _predict(x) {\n const result = new Array(this.outputs);\n if (this.intercept) {\n for (let i = 0; i < this.outputs; i++) {\n result[i] = this.weights[this.inputs][i];\n }\n } else {\n result.fill(0);\n }\n for (let i = 0; i < this.inputs; i++) {\n for (let j = 0; j < this.outputs; j++) {\n result[j] += this.weights[i][j] * x[i];\n }\n }\n return result;\n }\n\n score() {\n throw new Error('score method is not implemented yet');\n }\n\n toJSON() {\n return {\n name: 'multivariateLinearRegression',\n weights: this.weights,\n inputs: this.inputs,\n outputs: this.outputs,\n intercept: this.intercept,\n summary: this.statistics\n ? {\n regressionStatistics: {\n standardError: this.stdError,\n observations: this.outputs\n },\n variables: this.weights.map((d, i) => {\n return {\n label:\n i === this.weights.length - 1\n ? 'Intercept'\n : `X Variable ${i + 1}`,\n coefficients: d,\n standardError: this.stdErrors[i],\n tStat: this.tStats[i]\n };\n })\n }\n : undefined\n };\n }\n\n static load(model) {\n if (model.name !== 'multivariateLinearRegression') {\n throw new Error('not a MLR model');\n }\n return new MultivariateLinearRegression(true, model);\n }\n}\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass GaussianKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.divisor = 2 * options.sigma * options.sigma;\n }\n compute(x, y) {\n const distance = squaredEuclidean(x, y);\n return Math.exp(-distance / this.divisor);\n }\n}\n\nmodule.exports = GaussianKernel;\n","'use strict';\n\nconst defaultOptions = {\n degree: 1,\n constant: 1,\n scale: 1\n};\n\nclass PolynomialKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n\n this.degree = options.degree;\n this.constant = options.constant;\n this.scale = options.scale;\n }\n\n compute(x, y) {\n var sum = 0;\n for (var i = 0; i < x.length; i++) {\n sum += x[i] * y[i];\n }\n return Math.pow(this.scale * sum + this.constant, this.degree);\n }\n}\n\nmodule.exports = PolynomialKernel;\n","'use strict';\n\nconst defaultOptions = {\n alpha: 0.01,\n constant: -Math.E\n};\n\nclass SigmoidKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.alpha = options.alpha;\n this.constant = options.constant;\n }\n\n compute(x, y) {\n var sum = 0;\n for (var i = 0; i < x.length; i++) {\n sum += x[i] * y[i];\n }\n return Math.tanh(this.alpha * sum + this.constant);\n }\n}\n\nmodule.exports = SigmoidKernel;\n","'use strict';\n\nconst defaultOptions = {\n sigma: 1,\n degree: 1\n};\n\nclass ANOVAKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.degree = options.degree;\n }\n\n compute(x, y) {\n var sum = 0;\n var len = Math.min(x.length, y.length);\n for (var i = 1; i <= len; ++i) {\n sum += Math.pow(\n Math.exp(\n -this.sigma *\n Math.pow(Math.pow(x[i - 1], i) - Math.pow(y[i - 1], i), 2)\n ),\n this.degree\n );\n }\n return sum;\n }\n}\n\nmodule.exports = ANOVAKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass CauchyKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n }\n\n compute(x, y) {\n return 1 / (1 + squaredEuclidean(x, y) / (this.sigma * this.sigma));\n }\n}\n\nmodule.exports = CauchyKernel;\n","'use strict';\n\nconst { euclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass ExponentialKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.divisor = 2 * options.sigma * options.sigma;\n }\n\n compute(x, y) {\n const distance = euclidean(x, y);\n return Math.exp(-distance / this.divisor);\n }\n}\n\nmodule.exports = ExponentialKernel;\n","'use strict';\n\nclass HistogramIntersectionKernel {\n compute(x, y) {\n var min = Math.min(x.length, y.length);\n var sum = 0;\n for (var i = 0; i < min; ++i) {\n sum += Math.min(x[i], y[i]);\n }\n\n return sum;\n }\n}\n\nmodule.exports = HistogramIntersectionKernel;\n","'use strict';\n\nconst { euclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass LaplacianKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n }\n\n compute(x, y) {\n const distance = euclidean(x, y);\n return Math.exp(-distance / this.sigma);\n }\n}\n\nmodule.exports = LaplacianKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n constant: 1\n};\n\nclass MultiquadraticKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.constant = options.constant;\n }\n\n compute(x, y) {\n return Math.sqrt(squaredEuclidean(x, y) + this.constant * this.constant);\n }\n}\n\nmodule.exports = MultiquadraticKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n constant: 1\n};\n\nclass RationalQuadraticKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.constant = options.constant;\n }\n\n compute(x, y) {\n const distance = squaredEuclidean(x, y);\n return 1 - distance / (distance + this.constant);\n }\n}\n\nmodule.exports = RationalQuadraticKernel;\n","'use strict';\n\nconst { Matrix, MatrixTransposeView } = require('ml-matrix');\nconst GaussianKernel = require('ml-kernel-gaussian');\nconst PolynomialKernel = require('ml-kernel-polynomial');\nconst SigmoidKernel = require('ml-kernel-sigmoid');\n\nconst ANOVAKernel = require('./kernels/anova-kernel');\nconst CauchyKernel = require('./kernels/cauchy-kernel');\nconst ExponentialKernel = require('./kernels/exponential-kernel');\nconst HistogramKernel = require('./kernels/histogram-intersection-kernel');\nconst LaplacianKernel = require('./kernels/laplacian-kernel');\nconst MultiquadraticKernel = require('./kernels/multiquadratic-kernel');\nconst RationalKernel = require('./kernels/rational-quadratic-kernel');\n\nconst kernelType = {\n gaussian: GaussianKernel,\n rbf: GaussianKernel,\n polynomial: PolynomialKernel,\n poly: PolynomialKernel,\n anova: ANOVAKernel,\n cauchy: CauchyKernel,\n exponential: ExponentialKernel,\n histogram: HistogramKernel,\n min: HistogramKernel,\n laplacian: LaplacianKernel,\n multiquadratic: MultiquadraticKernel,\n rational: RationalKernel,\n sigmoid: SigmoidKernel,\n mlp: SigmoidKernel\n};\n\nclass Kernel {\n constructor(type, options) {\n this.kernelType = type;\n if (type === 'linear') return;\n\n if (typeof type === 'string') {\n type = type.toLowerCase();\n\n var KernelConstructor = kernelType[type];\n if (KernelConstructor) {\n this.kernelFunction = new KernelConstructor(options);\n } else {\n throw new Error(`unsupported kernel type: ${type}`);\n }\n } else if (typeof type === 'object' && typeof type.compute === 'function') {\n this.kernelFunction = type;\n } else {\n throw new TypeError(\n 'first argument must be a valid kernel type or instance'\n );\n }\n }\n\n compute(inputs, landmarks) {\n inputs = Matrix.checkMatrix(inputs);\n if (landmarks === undefined) {\n landmarks = inputs;\n } else {\n landmarks = Matrix.checkMatrix(landmarks);\n }\n if (this.kernelType === 'linear') {\n return inputs.mmul(new MatrixTransposeView(landmarks));\n }\n\n const kernelMatrix = new Matrix(inputs.rows, landmarks.rows);\n if (inputs === landmarks) {\n // fast path, matrix is symmetric\n for (let i = 0; i < inputs.rows; i++) {\n for (let j = i; j < inputs.rows; j++) {\n const value = this.kernelFunction.compute(\n inputs.getRow(i),\n inputs.getRow(j)\n );\n kernelMatrix.set(i, j, value);\n kernelMatrix.set(j, i, value);\n }\n }\n } else {\n for (let i = 0; i < inputs.rows; i++) {\n for (let j = 0; j < landmarks.rows; j++) {\n kernelMatrix.set(\n i,\n j,\n this.kernelFunction.compute(inputs.getRow(i), landmarks.getRow(j))\n );\n }\n }\n }\n return kernelMatrix;\n }\n}\n\nmodule.exports = Kernel;\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport median from 'ml-array-median';\n\nexport default class TheilSenRegression extends BaseRegression {\n /**\n * Theil–Sen estimator\n * https://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator\n * @param {Array|boolean} x\n * @param {Array|object} y\n * @constructor\n */\n constructor(x, y) {\n super();\n if (x === true) {\n // loads the model\n this.slope = y.slope;\n this.intercept = y.intercept;\n this.coefficients = y.coefficients;\n } else {\n // creates the model\n checkArrayLength(x, y);\n theilSen(this, x, y);\n }\n }\n\n toJSON() {\n return {\n name: 'TheilSenRegression',\n slope: this.slope,\n intercept: this.intercept\n };\n }\n\n _predict(input) {\n return this.slope * input + this.intercept;\n }\n\n computeX(input) {\n return (input - this.intercept) / this.slope;\n }\n\n toString(precision) {\n var result = 'f(x) = ';\n if (this.slope) {\n var xFactor = maybeToPrecision(this.slope, precision);\n result += `${Math.abs(xFactor - 1) < 1e-5 ? '' : `${xFactor} * `}x`;\n if (this.intercept) {\n var absIntercept = Math.abs(this.intercept);\n var operator = absIntercept === this.intercept ? '+' : '-';\n result +=\n ` ${operator} ${maybeToPrecision(absIntercept, precision)}`;\n }\n } else {\n result += maybeToPrecision(this.intercept, precision);\n }\n return result;\n }\n\n toLaTeX(precision) {\n return this.toString(precision);\n }\n\n static load(json) {\n if (json.name !== 'TheilSenRegression') {\n throw new TypeError('not a Theil-Sen model');\n }\n return new TheilSenRegression(true, json);\n }\n}\n\nfunction theilSen(regression, x, y) {\n let len = x.length;\n let slopes = new Array(len * len);\n let count = 0;\n for (let i = 0; i < len; ++i) {\n for (let j = i + 1; j < len; ++j) {\n if (x[i] !== x[j]) {\n slopes[count++] = (y[j] - y[i]) / (x[j] - x[i]);\n }\n }\n }\n slopes.length = count;\n let medianSlope = median(slopes);\n\n let cuts = new Array(len);\n for (let i = 0; i < len; ++i) {\n cuts[i] = y[i] - medianSlope * x[i];\n }\n\n regression.slope = medianSlope;\n regression.intercept = median(cuts);\n regression.coefficients = [regression.intercept, regression.slope];\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport { solve } from 'ml-matrix';\n\n/**\n * @class RobustPolynomialRegression\n * @param {Array} x\n * @param {Array} y\n * @param {number} degree - polynomial degree\n */\nexport default class RobustPolynomialRegression extends BaseRegression {\n constructor(x, y, degree) {\n super();\n if (x === true) {\n this.degree = y.degree;\n this.powers = y.powers;\n this.coefficients = y.coefficients;\n } else {\n checkArrayLength(x, y);\n robustPolynomial(this, x, y, degree);\n }\n }\n\n toJSON() {\n return {\n name: 'robustPolynomialRegression',\n degree: this.degree,\n powers: this.powers,\n coefficients: this.coefficients\n };\n }\n\n _predict(x) {\n return predict(x, this.powers, this.coefficients);\n }\n\n /**\n * Display the formula\n * @param {number} precision - precision for the numbers\n * @return {string}\n */\n toString(precision) {\n return this._toFormula(precision, false);\n }\n\n /**\n * Display the formula in LaTeX format\n * @param {number} precision - precision for the numbers\n * @return {string}\n */\n toLaTeX(precision) {\n return this._toFormula(precision, true);\n }\n\n _toFormula(precision, isLaTeX) {\n let sup = '^';\n let closeSup = '';\n let times = ' * ';\n if (isLaTeX) {\n sup = '^{';\n closeSup = '}';\n times = '';\n }\n\n let fn = '';\n let str = '';\n for (let k = 0; k < this.coefficients.length; k++) {\n str = '';\n if (this.coefficients[k] !== 0) {\n if (this.powers[k] === 0) {\n str = maybeToPrecision(this.coefficients[k], precision);\n } else {\n if (this.powers[k] === 1) {\n str = `${maybeToPrecision(this.coefficients[k], precision) +\n times}x`;\n } else {\n str = `${maybeToPrecision(this.coefficients[k], precision) +\n times}x${sup}${this.powers[k]}${closeSup}`;\n }\n }\n\n if (this.coefficients[k] > 0 && k !== this.coefficients.length - 1) {\n str = ` + ${str}`;\n } else if (k !== this.coefficients.length - 1) {\n str = ` ${str}`;\n }\n }\n fn = str + fn;\n }\n if (fn.charAt(0) === '+') {\n fn = fn.slice(1);\n }\n\n return `f(x) = ${fn}`;\n }\n\n static load(json) {\n if (json.name !== 'robustPolynomialRegression') {\n throw new TypeError('not a RobustPolynomialRegression model');\n }\n return new RobustPolynomialRegression(true, json);\n }\n}\n\nfunction robustPolynomial(regression, x, y, degree) {\n let powers = Array(degree)\n .fill(0)\n .map((_, index) => index);\n\n const tuples = getRandomTuples(x, y, degree);\n\n var min;\n for (var i = 0; i < tuples.length; i++) {\n var tuple = tuples[i];\n var coefficients = calcCoefficients(tuple, powers);\n\n var residuals = x.slice();\n for (var j = 0; j < x.length; j++) {\n residuals[j] = y[j] - predict(x[j], powers, coefficients);\n residuals[j] = {\n residual: residuals[j] * residuals[j],\n coefficients\n };\n }\n\n var median = residualsMedian(residuals);\n if (!min || median.residual < min.residual) {\n min = median;\n }\n }\n\n regression.degree = degree;\n regression.powers = powers;\n regression.coefficients = min.coefficients;\n}\n\n/**\n * @ignore\n * @param {Array} x\n * @param {Array} y\n * @param {number} degree\n * @return {Array<{x:number,y:number}>}\n */\nfunction getRandomTuples(x, y, degree) {\n var len = Math.floor(x.length / degree);\n var tuples = new Array(len);\n\n for (var i = 0; i < x.length; i++) {\n var pos = Math.floor(Math.random() * len);\n\n var counter = 0;\n while (counter < x.length) {\n if (!tuples[pos]) {\n tuples[pos] = [\n {\n x: x[i],\n y: y[i]\n }\n ];\n break;\n } else if (tuples[pos].length < degree) {\n tuples[pos].push({\n x: x[i],\n y: y[i]\n });\n break;\n } else {\n counter++;\n pos = (pos + 1) % len;\n }\n }\n\n if (counter === x.length) {\n return tuples;\n }\n }\n return tuples;\n}\n\n/**\n * @ignore\n * @param {{x:number,y:number}} tuple\n * @param {Array} powers\n * @return {Array}\n */\nfunction calcCoefficients(tuple, powers) {\n var X = tuple.slice();\n var Y = tuple.slice();\n for (var i = 0; i < X.length; i++) {\n Y[i] = [tuple[i].y];\n X[i] = new Array(powers.length);\n for (var j = 0; j < powers.length; j++) {\n X[i][j] = Math.pow(tuple[i].x, powers[j]);\n }\n }\n\n return solve(X, Y).to1DArray();\n}\n\nfunction predict(x, powers, coefficients) {\n let y = 0;\n for (let k = 0; k < powers.length; k++) {\n y += coefficients[k] * Math.pow(x, powers[k]);\n }\n return y;\n}\n\nfunction residualsMedian(residuals) {\n residuals.sort((a, b) => a.residual - b.residual);\n\n var l = residuals.length;\n var half = Math.floor(l / 2);\n return l % 2 === 0 ? residuals[half - 1] : residuals[half];\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","/**\n * Calculate current error\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} parameters - Array of current parameter values\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {number}\n */\nexport default function errorCalculation(\n data,\n parameters,\n parameterizedFunction,\n) {\n let error = 0;\n const func = parameterizedFunction(parameters);\n\n for (let i = 0; i < data.x.length; i++) {\n error += Math.abs(data.y[i] - func(data.x[i]));\n }\n\n return error;\n}\n","import { inverse, Matrix } from 'ml-matrix';\n\n/**\n * Difference of the matrix function over the parameters\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} evaluatedData - Array of previous evaluated function values\n * @param {Array} params - Array of previous parameter values\n * @param {number} gradientDifference - Adjustment for decrease the damping parameter\n * @param {function} paramFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {Matrix}\n */\nfunction gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n paramFunction,\n) {\n const n = params.length;\n const m = data.x.length;\n\n let ans = new Array(n);\n\n for (let param = 0; param < n; param++) {\n ans[param] = new Array(m);\n let auxParams = params.slice();\n auxParams[param] += gradientDifference;\n let funcParam = paramFunction(auxParams);\n\n for (let point = 0; point < m; point++) {\n ans[param][point] = evaluatedData[point] - funcParam(data.x[point]);\n }\n }\n return new Matrix(ans);\n}\n\n/**\n * Matrix function over the samples\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} evaluatedData - Array of previous evaluated function values\n * @return {Matrix}\n */\nfunction matrixFunction(data, evaluatedData) {\n const m = data.x.length;\n\n let ans = new Array(m);\n\n for (let point = 0; point < m; point++) {\n ans[point] = [data.y[point] - evaluatedData[point]];\n }\n\n return new Matrix(ans);\n}\n\n/**\n * Iteration for Levenberg-Marquardt\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} params - Array of previous parameter values\n * @param {number} damping - Levenberg-Marquardt parameter\n * @param {number} gradientDifference - Adjustment for decrease the damping parameter\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {Array}\n */\nexport default function step(\n data,\n params,\n damping,\n gradientDifference,\n parameterizedFunction,\n) {\n let value = damping * gradientDifference * gradientDifference;\n let identity = Matrix.eye(params.length, params.length, value);\n\n const func = parameterizedFunction(params);\n\n let evaluatedData = new Float64Array(data.x.length);\n for (let i = 0; i < data.x.length; i++) {\n evaluatedData[i] = func(data.x[i]);\n }\n\n let gradientFunc = gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n parameterizedFunction,\n );\n let matrixFunc = matrixFunction(data, evaluatedData);\n let inverseMatrix = inverse(\n identity.add(gradientFunc.mmul(gradientFunc.transpose())),\n );\n\n params = new Matrix([params]);\n params = params.sub(\n inverseMatrix\n .mmul(gradientFunc)\n .mmul(matrixFunc)\n .mul(gradientDifference)\n .transpose(),\n );\n\n return params.to1DArray();\n}\n","import isArray from 'is-any-array';\n\nimport errorCalculation from './errorCalculation';\nimport step from './step';\n\n/**\n * Curve fitting algorithm\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @param {object} [options] - Options object\n * @param {number} [options.damping] - Levenberg-Marquardt parameter\n * @param {number} [options.gradientDifference = 10e-2] - Adjustment for decrease the damping parameter\n * @param {Array} [options.minValues] - Minimum allowed values for parameters\n * @param {Array} [options.maxValues] - Maximum allowed values for parameters\n * @param {Array} [options.initialValues] - Array of initial parameter values\n * @param {number} [options.maxIterations = 100] - Maximum of allowed iterations\n * @param {number} [options.errorTolerance = 10e-3] - Minimum uncertainty allowed for each point\n * @return {{parameterValues: Array, parameterError: number, iterations: number}}\n */\nexport default function levenbergMarquardt(\n data,\n parameterizedFunction,\n options = {},\n) {\n let {\n maxIterations = 100,\n gradientDifference = 10e-2,\n damping = 0,\n errorTolerance = 10e-3,\n minValues,\n maxValues,\n initialValues,\n } = options;\n\n if (damping <= 0) {\n throw new Error('The damping option must be a positive number');\n } else if (!data.x || !data.y) {\n throw new Error('The data parameter must have x and y elements');\n } else if (\n !isArray(data.x) ||\n data.x.length < 2 ||\n !isArray(data.y) ||\n data.y.length < 2\n ) {\n throw new Error(\n 'The data parameter elements must be an array with more than 2 points',\n );\n } else if (data.x.length !== data.y.length) {\n throw new Error('The data parameter elements must have the same size');\n }\n\n let parameters =\n initialValues || new Array(parameterizedFunction.length).fill(1);\n let parLen = parameters.length;\n maxValues = maxValues || new Array(parLen).fill(Number.MAX_SAFE_INTEGER);\n minValues = minValues || new Array(parLen).fill(Number.MIN_SAFE_INTEGER);\n\n if (maxValues.length !== minValues.length) {\n throw new Error('minValues and maxValues must be the same size');\n }\n\n if (!isArray(parameters)) {\n throw new Error('initialValues must be an array');\n }\n\n let error = errorCalculation(data, parameters, parameterizedFunction);\n\n let converged = error <= errorTolerance;\n\n let iteration;\n for (iteration = 0; iteration < maxIterations && !converged; iteration++) {\n parameters = step(\n data,\n parameters,\n damping,\n gradientDifference,\n parameterizedFunction,\n );\n\n for (let k = 0; k < parLen; k++) {\n parameters[k] = Math.min(\n Math.max(minValues[k], parameters[k]),\n maxValues[k],\n );\n }\n\n error = errorCalculation(data, parameters, parameterizedFunction);\n if (isNaN(error)) break;\n converged = error <= errorTolerance;\n }\n\n return {\n parameterValues: parameters,\n parameterError: error,\n iterations: iteration,\n };\n}\n","/**\n * Returns a new array based on extraction of specific indices of an array\n * @private\n * @param {Array} vector\n * @param {Array} indices\n */\nexport default function selection(vector, indices) {\n let u = []; //new Float64Array(indices.length);\n for (let i = 0; i < indices.length; i++) {\n u[i] = vector[indices[i]];\n }\n return u;\n}\n","/**\n *\n * @private\n * @param {Array of arrays} collection\n */\nexport default function sortCollectionSet(collection) {\n let objectCollection = collection\n .map((value, index) => {\n let key = BigInt(0);\n value.forEach((item) => (key |= BigInt(1) << BigInt(item)));\n return { value, index, key };\n })\n .sort((a, b) => {\n if (a.key - b.key < 0) return -1;\n return 1;\n });\n\n let sorted = [];\n let indices = [];\n\n let key;\n for (let set of objectCollection) {\n if (set.key !== key) {\n key = set.key;\n indices.push([]);\n sorted.push(set.value);\n }\n indices[indices.length - 1].push(set.index);\n }\n\n let result = {\n values: sorted,\n indices: indices,\n };\n return result;\n}\n","import {\n Matrix,\n LuDecomposition,\n solve,\n CholeskyDecomposition,\n} from 'ml-matrix';\n\nimport sortCollectionSet from './util/sortCollectionSet';\n\n/**\n * (Combinatorial Subspace Least Squares) - subfunction for the FC-NNLS\n * @private\n * @param {Matrix} XtX\n * @param {Matrix} XtY\n * @param {Array} Pset\n * @param {Numbers} l\n * @param {Numbers} p\n */\nexport default function cssls(XtX, XtY, Pset, l, p) {\n // Solves the set of equation XtX*K = XtY for the variables in Pset\n // if XtX (or XtX(vars,vars)) is singular, performs the svd and find pseudoinverse, otherwise (even if ill-conditioned) finds inverse with LU decomposition and solves the set of equation\n // it is consistent with matlab results for ill-conditioned matrices (at least consistent with test 'ill-conditionned square X rank 2, Y 3x1' in cssls.test)\n\n let K = Matrix.zeros(l, p);\n if (Pset === null) {\n let choXtX = new CholeskyDecomposition(XtX);\n if (choXtX.isPositiveDefinite() === true) {\n K = choXtX.solve(XtY);\n } else {\n let luXtX = new LuDecomposition(XtX);\n if (luXtX.isSingular() === false) {\n K = luXtX.solve(Matrix.eye(l)).mmul(XtY);\n } else {\n K = solve(XtX, XtY, { useSVD: true });\n }\n }\n } else {\n let sortedPset = sortCollectionSet(Pset).values;\n let sortedEset = sortCollectionSet(Pset).indices;\n if (\n sortedPset.length === 1 &&\n sortedPset[0].length === 0 &&\n sortedEset[0].length === p\n ) {\n return K;\n } else if (\n sortedPset.length === 1 &&\n sortedPset[0].length === l &&\n sortedEset[0].length === p\n ) {\n let choXtX = new CholeskyDecomposition(XtX);\n if (choXtX.isPositiveDefinite() === true) {\n K = choXtX.solve(XtY);\n } else {\n let luXtX = new LuDecomposition(XtX);\n if (luXtX.isSingular() === false) {\n K = luXtX.solve(Matrix.eye(l)).mmul(XtY);\n } else {\n K = solve(XtX, XtY, { useSVD: true });\n }\n }\n } else {\n for (let k = 0; k < sortedPset.length; k++) {\n let cols2Solve = sortedEset[k];\n let vars = sortedPset[k];\n let L;\n let choXtX = new CholeskyDecomposition(XtX.selection(vars, vars));\n if (choXtX.isPositiveDefinite() === true) {\n L = choXtX.solve(XtY.selection(vars, cols2Solve));\n } else {\n let luXtX = new LuDecomposition(XtX.selection(vars, vars));\n if (luXtX.isSingular() === false) {\n L = luXtX\n .solve(Matrix.eye(vars.length))\n .mmul(XtY.selection(vars, cols2Solve));\n } else {\n L = solve(\n XtX.selection(vars, vars),\n XtY.selection(vars, cols2Solve),\n { useSVD: true },\n );\n }\n }\n for (let i = 0; i < L.rows; i++) {\n for (let j = 0; j < L.columns; j++) {\n K.set(vars[i], cols2Solve[j], L.get(i, j));\n }\n }\n }\n }\n }\n return K;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport cssls from './cssls';\n\nexport default function initialisation(X, Y) {\n let n = X.rows;\n let l = X.columns;\n let p = Y.columns;\n let iter = 0;\n\n if (Y.rows !== n) throw new Error('ERROR: matrix size not compatible');\n\n let W = Matrix.zeros(l, p);\n\n // precomputes part of pseudoinverse\n let XtX = X.transpose().mmul(X);\n let XtY = X.transpose().mmul(Y);\n\n let K = cssls(XtX, XtY, null, l, p); // K is lxp\n let Pset = [];\n for (let j = 0; j < p; j++) {\n Pset[j] = [];\n for (let i = 0; i < l; i++) {\n if (K.get(i, j) > 0) {\n Pset[j].push(i);\n } else {\n K.set(i, j, 0);\n } //This is our initial solution, it's the solution found by overwriting the unconstrained least square solution\n }\n }\n let Fset = [];\n for (let j = 0; j < p; j++) {\n if (Pset[j].length !== l) {\n Fset.push(j);\n }\n }\n\n let D = K.clone();\n\n return { n, l, p, iter, W, XtX, XtY, K, Pset, Fset, D };\n}\n","/**\n * Computes the set difference A\\B\n * @private\n * @param {A} set A as an array\n * @param {B} set B as an array\n */\nexport default function setDifference(A, B) {\n let C = [];\n for (let i of A) {\n if (!B.includes(i)) C.push(i);\n }\n return C;\n}\n","import setDifference from './util/setDifference';\n\n// Makes sure the solution has converged\nexport default function optimality(\n iter,\n maxIter,\n XtX,\n XtY,\n Fset,\n Pset,\n W,\n K,\n l,\n p,\n D,\n) {\n if (iter === maxIter) {\n throw new Error('Maximum number of iterations exceeded');\n }\n\n // Check solution for optimality\n let V = XtY.subMatrixColumn(Fset).subtract(XtX.mmul(K.subMatrixColumn(Fset)));\n for (let j = 0; j < Fset.length; j++) {\n W.setColumn(Fset[j], V.subMatrixColumn([j]));\n }\n let Jset = [];\n let fullSet = [];\n for (let i = 0; i < l; i++) {\n fullSet.push(i);\n }\n for (let j = 0; j < Fset.length; j++) {\n let notPset = setDifference(fullSet, Pset[Fset[j]]);\n if (notPset.length === 0) {\n Jset.push(Fset[j]);\n } else if (W.selection(notPset, [Fset[j]]).max() <= 0) {\n Jset.push(Fset[j]);\n }\n }\n Fset = setDifference(Fset, Jset);\n\n // For non-optimal solutions, add the appropriate variables to Pset\n if (Fset.length !== 0) {\n for (let j = 0; j < Fset.length; j++) {\n for (let i = 0; i < l; i++) {\n if (Pset[Fset[j]].includes(i)) W.set(i, Fset[j], -Infinity);\n }\n Pset[Fset[j]].push(W.subMatrixColumn(Fset).maxColumnIndex(j)[0]);\n }\n for (let j = 0; j < Fset.length; j++) {\n D.setColumn(Fset[j], K.getColumn(Fset[j]));\n }\n }\n for (let j = 0; j < p; j++) {\n Pset[j].sort((a, b) => a - b);\n }\n return { Pset, Fset, W };\n}\n","import { Matrix } from 'ml-matrix';\n\nimport selection from './util/selection';\nimport cssls from './cssls';\nimport initialisation from './initialisation';\nimport optimality from './optimality';\n\n/**\n * Fast Combinatorial Non-negative Least Squares with multiple Right Hand Side\n * @param {Matrix|number[][]} X\n * @param {Matrix|number[][]} Y\n * @param {object} [options={}]\n * @param {number} [options.maxIterations] if empty maxIterations is set at 3 times the number of columns of X\n * @returns {Matrix} K\n */\nexport default function fcnnls(X, Y, options = {}) {\n X = Matrix.checkMatrix(X);\n Y = Matrix.checkMatrix(Y);\n let { l, p, iter, W, XtX, XtY, K, Pset, Fset, D } = initialisation(X, Y);\n const { maxIterations = X.columns * 3 } = options;\n\n // Active set algorithm for NNLS main loop\n while (Fset.length > 0) {\n // Solves for the passive variables (uses subroutine below)\n let L = cssls(\n XtX,\n XtY.subMatrixColumn(Fset),\n selection(Pset, Fset),\n l,\n Fset.length,\n );\n for (let i = 0; i < l; i++) {\n for (let j = 0; j < Fset.length; j++) {\n K.set(i, Fset[j], L.get(i, j));\n }\n }\n\n // Finds any infeasible solutions\n let infeasIndex = [];\n for (let j = 0; j < Fset.length; j++) {\n for (let i = 0; i < l; i++) {\n if (L.get(i, j) < 0) {\n infeasIndex.push(j);\n break;\n }\n }\n }\n let Hset = selection(Fset, infeasIndex);\n\n // Makes infeasible solutions feasible (standard NNLS inner loop)\n if (Hset.length > 0) {\n let m = Hset.length;\n let alpha = Matrix.ones(l, m);\n\n while (m > 0 && iter < maxIterations) {\n iter++;\n\n alpha.mul(Infinity);\n\n // Finds indices of negative variables in passive set\n let hRowColIdx = [[], []]; // Indexes work in pairs, each pair reprensents a single element, first array is row index, second array is column index\n let negRowColIdx = [[], []]; // Same as before\n for (let j = 0; j < m; j++) {\n for (let i = 0; i < Pset[Hset[j]].length; i++) {\n if (K.get(Pset[Hset[j]][i], Hset[j]) < 0) {\n hRowColIdx[0].push(Pset[Hset[j]][i]); // i\n hRowColIdx[1].push(j);\n negRowColIdx[0].push(Pset[Hset[j]][i]); // i\n negRowColIdx[1].push(Hset[j]);\n } // Compared to matlab, here we keep the row/column indexing (we are not taking the linear indexing)\n }\n }\n\n for (let k = 0; k < hRowColIdx[0].length; k++) {\n // could be hRowColIdx[1].length as well\n alpha.set(\n hRowColIdx[0][k],\n hRowColIdx[1][k],\n D.get(negRowColIdx[0][k], negRowColIdx[1][k]) /\n (D.get(negRowColIdx[0][k], negRowColIdx[1][k]) -\n K.get(negRowColIdx[0][k], negRowColIdx[1][k])),\n );\n }\n\n let alphaMin = [];\n let minIdx = [];\n for (let j = 0; j < m; j++) {\n alphaMin[j] = alpha.minColumn(j);\n minIdx[j] = alpha.minColumnIndex(j)[0];\n }\n\n alphaMin = Matrix.rowVector(alphaMin);\n for (let i = 0; i < l; i++) {\n alpha.setSubMatrix(alphaMin, i, 0);\n }\n\n let E = new Matrix(l, m);\n E = D.subMatrixColumn(Hset).subtract(\n alpha\n .subMatrix(0, l - 1, 0, m - 1)\n .mul(D.subMatrixColumn(Hset).subtract(K.subMatrixColumn(Hset))),\n );\n for (let j = 0; j < m; j++) {\n D.setColumn(Hset[j], E.subMatrixColumn([j]));\n }\n\n let idx2zero = [minIdx, Hset];\n for (let k = 0; k < m; k++) {\n D.set(idx2zero[0][k], idx2zero[1][k], 0);\n }\n\n for (let j = 0; j < m; j++) {\n Pset[Hset[j]].splice(\n Pset[Hset[j]].findIndex((item) => item === minIdx[j]),\n 1,\n );\n }\n\n L = cssls(XtX, XtY.subMatrixColumn(Hset), selection(Pset, Hset), l, m);\n for (let j = 0; j < m; j++) {\n K.setColumn(Hset[j], L.subMatrixColumn([j]));\n }\n\n Hset = [];\n for (let j = 0; j < K.columns; j++) {\n for (let i = 0; i < l; i++) {\n if (K.get(i, j) < 0) {\n Hset.push(j);\n\n break;\n }\n }\n }\n m = Hset.length;\n }\n }\n\n let newParam = optimality(\n iter,\n maxIterations,\n XtX,\n XtY,\n Fset,\n Pset,\n W,\n K,\n l,\n p,\n D,\n );\n Pset = newParam.Pset;\n Fset = newParam.Fset;\n W = newParam.W;\n }\n\n return K;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport fcnnls from './fcnnls';\n\n/**\n * Fast Combinatorial Non-negative Least Squares with single Right Hand Side\n * @param {Matrix|number[][]} X\n * @param {number[]} y\n * @param {object} [options={}]\n * @param {boolean} [maxIterations] if true or empty maxIterations is set at 3 times the number of columns of X\n * @returns {Array} k\n */\nexport default function fcnnlsVector(X, y, options = {}) {\n if (Array.isArray(y) === false) {\n throw new TypeError('y must be a 1D Array');\n }\n let Y = Matrix.columnVector(y);\n let K = fcnnls(X, Y, options);\n let k = K.to1DArray();\n return k;\n}\n","module.exports = function(haystack, needle, comparator, low, high) {\n var mid, cmp;\n\n if(low === undefined)\n low = 0;\n\n else {\n low = low|0;\n if(low < 0 || low >= haystack.length)\n throw new RangeError(\"invalid lower bound\");\n }\n\n if(high === undefined)\n high = haystack.length - 1;\n\n else {\n high = high|0;\n if(high < low || high >= haystack.length)\n throw new RangeError(\"invalid upper bound\");\n }\n\n while(low <= high) {\n // The naive `low + high >>> 1` could fail for array lengths > 2**31\n // because `>>>` converts its operands to int32. `low + (high - low >>> 1)`\n // works for array lengths <= 2**32-1 which is also Javascript's max array\n // length.\n mid = low + ((high - low) >>> 1);\n cmp = +comparator(haystack[mid], needle, mid, haystack);\n\n // Too low.\n if(cmp < 0.0)\n low = mid + 1;\n\n // Too high.\n else if(cmp > 0.0)\n high = mid - 1;\n\n // Key found.\n else\n return mid;\n }\n\n // Key not found.\n return ~low;\n}\n","'use strict';\n\nfunction assertNumber(number) {\n\tif (typeof number !== 'number') {\n\t\tthrow new TypeError('Expected a number');\n\t}\n}\n\nexports.ascending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\n\tif (Number.isNaN(left)) {\n\t\treturn -1;\n\t}\n\n\tif (Number.isNaN(right)) {\n\t\treturn 1;\n\t}\n\n\treturn left - right;\n};\n\nexports.descending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\n\tif (Number.isNaN(left)) {\n\t\treturn 1;\n\t}\n\n\tif (Number.isNaN(right)) {\n\t\treturn -1;\n\t}\n\n\treturn right - left;\n};\n","import binarySearch from 'binary-search';\nimport { ascending } from 'num-sort';\n\nexport const largestPrime = 0x7fffffff;\n\nconst primeNumbers = [\n // chunk #0\n largestPrime, // 2^31-1\n\n // chunk #1\n 5,\n 11,\n 23,\n 47,\n 97,\n 197,\n 397,\n 797,\n 1597,\n 3203,\n 6421,\n 12853,\n 25717,\n 51437,\n 102877,\n 205759,\n 411527,\n 823117,\n 1646237,\n 3292489,\n 6584983,\n 13169977,\n 26339969,\n 52679969,\n 105359939,\n 210719881,\n 421439783,\n 842879579,\n 1685759167,\n\n // chunk #2\n 433,\n 877,\n 1759,\n 3527,\n 7057,\n 14143,\n 28289,\n 56591,\n 113189,\n 226379,\n 452759,\n 905551,\n 1811107,\n 3622219,\n 7244441,\n 14488931,\n 28977863,\n 57955739,\n 115911563,\n 231823147,\n 463646329,\n 927292699,\n 1854585413,\n\n // chunk #3\n 953,\n 1907,\n 3821,\n 7643,\n 15287,\n 30577,\n 61169,\n 122347,\n 244703,\n 489407,\n 978821,\n 1957651,\n 3915341,\n 7830701,\n 15661423,\n 31322867,\n 62645741,\n 125291483,\n 250582987,\n 501165979,\n 1002331963,\n 2004663929,\n\n // chunk #4\n 1039,\n 2081,\n 4177,\n 8363,\n 16729,\n 33461,\n 66923,\n 133853,\n 267713,\n 535481,\n 1070981,\n 2141977,\n 4283963,\n 8567929,\n 17135863,\n 34271747,\n 68543509,\n 137087021,\n 274174111,\n 548348231,\n 1096696463,\n\n // chunk #5\n 31,\n 67,\n 137,\n 277,\n 557,\n 1117,\n 2237,\n 4481,\n 8963,\n 17929,\n 35863,\n 71741,\n 143483,\n 286973,\n 573953,\n 1147921,\n 2295859,\n 4591721,\n 9183457,\n 18366923,\n 36733847,\n 73467739,\n 146935499,\n 293871013,\n 587742049,\n 1175484103,\n\n // chunk #6\n 599,\n 1201,\n 2411,\n 4831,\n 9677,\n 19373,\n 38747,\n 77509,\n 155027,\n 310081,\n 620171,\n 1240361,\n 2480729,\n 4961459,\n 9922933,\n 19845871,\n 39691759,\n 79383533,\n 158767069,\n 317534141,\n 635068283,\n 1270136683,\n\n // chunk #7\n 311,\n 631,\n 1277,\n 2557,\n 5119,\n 10243,\n 20507,\n 41017,\n 82037,\n 164089,\n 328213,\n 656429,\n 1312867,\n 2625761,\n 5251529,\n 10503061,\n 21006137,\n 42012281,\n 84024581,\n 168049163,\n 336098327,\n 672196673,\n 1344393353,\n\n // chunk #8\n 3,\n 7,\n 17,\n 37,\n 79,\n 163,\n 331,\n 673,\n 1361,\n 2729,\n 5471,\n 10949,\n 21911,\n 43853,\n 87719,\n 175447,\n 350899,\n 701819,\n 1403641,\n 2807303,\n 5614657,\n 11229331,\n 22458671,\n 44917381,\n 89834777,\n 179669557,\n 359339171,\n 718678369,\n 1437356741,\n\n // chunk #9\n 43,\n 89,\n 179,\n 359,\n 719,\n 1439,\n 2879,\n 5779,\n 11579,\n 23159,\n 46327,\n 92657,\n 185323,\n 370661,\n 741337,\n 1482707,\n 2965421,\n 5930887,\n 11861791,\n 23723597,\n 47447201,\n 94894427,\n 189788857,\n 379577741,\n 759155483,\n 1518310967,\n\n // chunk #10\n 379,\n 761,\n 1523,\n 3049,\n 6101,\n 12203,\n 24407,\n 48817,\n 97649,\n 195311,\n 390647,\n 781301,\n 1562611,\n 3125257,\n 6250537,\n 12501169,\n 25002389,\n 50004791,\n 100009607,\n 200019221,\n 400038451,\n 800076929,\n 1600153859,\n\n // chunk #11\n 13,\n 29,\n 59,\n 127,\n 257,\n 521,\n 1049,\n 2099,\n 4201,\n 8419,\n 16843,\n 33703,\n 67409,\n 134837,\n 269683,\n 539389,\n 1078787,\n 2157587,\n 4315183,\n 8630387,\n 17260781,\n 34521589,\n 69043189,\n 138086407,\n 276172823,\n 552345671,\n 1104691373,\n\n // chunk #12\n 19,\n 41,\n 83,\n 167,\n 337,\n 677,\n 1361,\n 2729,\n 5471,\n 10949,\n 21911,\n 43853,\n 87719,\n 175447,\n 350899,\n 701819,\n 1403641,\n 2807303,\n 5614657,\n 11229331,\n 22458671,\n 44917381,\n 89834777,\n 179669557,\n 359339171,\n 718678369,\n 1437356741,\n\n // chunk #13\n 53,\n 107,\n 223,\n 449,\n 907,\n 1823,\n 3659,\n 7321,\n 14653,\n 29311,\n 58631,\n 117269,\n 234539,\n 469099,\n 938207,\n 1876417,\n 3752839,\n 7505681,\n 15011389,\n 30022781,\n 60045577,\n 120091177,\n 240182359,\n 480364727,\n 960729461,\n 1921458943\n];\n\nprimeNumbers.sort(ascending);\n\nexport function nextPrime(value) {\n let index = binarySearch(primeNumbers, value, ascending);\n if (index < 0) {\n index = ~index;\n }\n return primeNumbers[index];\n}\n","import { largestPrime, nextPrime } from './primeFinder';\n\nconst FREE = 0;\nconst FULL = 1;\nconst REMOVED = 2;\n\nconst defaultInitialCapacity = 150;\nconst defaultMinLoadFactor = 1 / 6;\nconst defaultMaxLoadFactor = 2 / 3;\n\nexport default class HashTable {\n constructor(options = {}) {\n if (options instanceof HashTable) {\n this.table = options.table.slice();\n this.values = options.values.slice();\n this.state = options.state.slice();\n this.minLoadFactor = options.minLoadFactor;\n this.maxLoadFactor = options.maxLoadFactor;\n this.distinct = options.distinct;\n this.freeEntries = options.freeEntries;\n this.lowWaterMark = options.lowWaterMark;\n this.highWaterMark = options.maxLoadFactor;\n return;\n }\n\n const initialCapacity =\n options.initialCapacity === undefined\n ? defaultInitialCapacity\n : options.initialCapacity;\n if (initialCapacity < 0) {\n throw new RangeError(\n `initial capacity must not be less than zero: ${initialCapacity}`\n );\n }\n\n const minLoadFactor =\n options.minLoadFactor === undefined\n ? defaultMinLoadFactor\n : options.minLoadFactor;\n const maxLoadFactor =\n options.maxLoadFactor === undefined\n ? defaultMaxLoadFactor\n : options.maxLoadFactor;\n if (minLoadFactor < 0 || minLoadFactor >= 1) {\n throw new RangeError(`invalid minLoadFactor: ${minLoadFactor}`);\n }\n if (maxLoadFactor <= 0 || maxLoadFactor >= 1) {\n throw new RangeError(`invalid maxLoadFactor: ${maxLoadFactor}`);\n }\n if (minLoadFactor >= maxLoadFactor) {\n throw new RangeError(\n `minLoadFactor (${minLoadFactor}) must be smaller than maxLoadFactor (${maxLoadFactor})`\n );\n }\n\n let capacity = initialCapacity;\n // User wants to put at least capacity elements. We need to choose the size based on the maxLoadFactor to\n // avoid the need to rehash before this capacity is reached.\n // actualCapacity * maxLoadFactor >= capacity\n capacity = (capacity / maxLoadFactor) | 0;\n capacity = nextPrime(capacity);\n if (capacity === 0) capacity = 1;\n\n this.table = newArray(capacity);\n this.values = newArray(capacity);\n this.state = newArray(capacity);\n\n this.minLoadFactor = minLoadFactor;\n if (capacity === largestPrime) {\n this.maxLoadFactor = 1;\n } else {\n this.maxLoadFactor = maxLoadFactor;\n }\n\n this.distinct = 0;\n this.freeEntries = capacity;\n\n this.lowWaterMark = 0;\n this.highWaterMark = chooseHighWaterMark(capacity, this.maxLoadFactor);\n }\n\n clone() {\n return new HashTable(this);\n }\n\n get size() {\n return this.distinct;\n }\n\n get(key) {\n const i = this.indexOfKey(key);\n if (i < 0) return 0;\n return this.values[i];\n }\n\n set(key, value) {\n let i = this.indexOfInsertion(key);\n if (i < 0) {\n i = -i - 1;\n this.values[i] = value;\n return false;\n }\n\n if (this.distinct > this.highWaterMark) {\n const newCapacity = chooseGrowCapacity(\n this.distinct + 1,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n return this.set(key, value);\n }\n\n this.table[i] = key;\n this.values[i] = value;\n if (this.state[i] === FREE) this.freeEntries--;\n this.state[i] = FULL;\n this.distinct++;\n\n if (this.freeEntries < 1) {\n const newCapacity = chooseGrowCapacity(\n this.distinct + 1,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n }\n\n return true;\n }\n\n remove(key, noRehash) {\n const i = this.indexOfKey(key);\n if (i < 0) return false;\n\n this.state[i] = REMOVED;\n this.distinct--;\n\n if (!noRehash) this.maybeShrinkCapacity();\n\n return true;\n }\n\n delete(key, noRehash) {\n const i = this.indexOfKey(key);\n if (i < 0) return false;\n\n this.state[i] = FREE;\n this.distinct--;\n\n if (!noRehash) this.maybeShrinkCapacity();\n\n return true;\n }\n\n maybeShrinkCapacity() {\n if (this.distinct < this.lowWaterMark) {\n const newCapacity = chooseShrinkCapacity(\n this.distinct,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n }\n }\n\n containsKey(key) {\n return this.indexOfKey(key) >= 0;\n }\n\n indexOfKey(key) {\n const table = this.table;\n const state = this.state;\n const length = this.table.length;\n\n const hash = key & 0x7fffffff;\n let i = hash % length;\n let decrement = hash % (length - 2);\n if (decrement === 0) decrement = 1;\n\n while (state[i] !== FREE && (state[i] === REMOVED || table[i] !== key)) {\n i -= decrement;\n if (i < 0) i += length;\n }\n\n if (state[i] === FREE) return -1;\n return i;\n }\n\n containsValue(value) {\n return this.indexOfValue(value) >= 0;\n }\n\n indexOfValue(value) {\n const values = this.values;\n const state = this.state;\n\n for (var i = 0; i < state.length; i++) {\n if (state[i] === FULL && values[i] === value) {\n return i;\n }\n }\n\n return -1;\n }\n\n indexOfInsertion(key) {\n const table = this.table;\n const state = this.state;\n const length = table.length;\n\n const hash = key & 0x7fffffff;\n let i = hash % length;\n let decrement = hash % (length - 2);\n if (decrement === 0) decrement = 1;\n\n while (state[i] === FULL && table[i] !== key) {\n i -= decrement;\n if (i < 0) i += length;\n }\n\n if (state[i] === REMOVED) {\n const j = i;\n while (state[i] !== FREE && (state[i] === REMOVED || table[i] !== key)) {\n i -= decrement;\n if (i < 0) i += length;\n }\n if (state[i] === FREE) i = j;\n }\n\n if (state[i] === FULL) {\n return -i - 1;\n }\n\n return i;\n }\n\n ensureCapacity(minCapacity) {\n if (this.table.length < minCapacity) {\n const newCapacity = nextPrime(minCapacity);\n this.rehash(newCapacity);\n }\n }\n\n rehash(newCapacity) {\n const oldCapacity = this.table.length;\n\n if (newCapacity <= this.distinct) throw new Error('Unexpected');\n\n const oldTable = this.table;\n const oldValues = this.values;\n const oldState = this.state;\n\n const newTable = newArray(newCapacity);\n const newValues = newArray(newCapacity);\n const newState = newArray(newCapacity);\n\n this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor);\n this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor);\n\n this.table = newTable;\n this.values = newValues;\n this.state = newState;\n this.freeEntries = newCapacity - this.distinct;\n\n for (var i = 0; i < oldCapacity; i++) {\n if (oldState[i] === FULL) {\n var element = oldTable[i];\n var index = this.indexOfInsertion(element);\n newTable[index] = element;\n newValues[index] = oldValues[i];\n newState[index] = FULL;\n }\n }\n }\n\n forEachKey(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.table[i])) return false;\n }\n }\n return true;\n }\n\n forEachValue(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.values[i])) return false;\n }\n }\n return true;\n }\n\n forEachPair(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.table[i], this.values[i])) return false;\n }\n }\n return true;\n }\n}\n\nfunction chooseLowWaterMark(capacity, minLoad) {\n return (capacity * minLoad) | 0;\n}\n\nfunction chooseHighWaterMark(capacity, maxLoad) {\n return Math.min(capacity - 2, (capacity * maxLoad) | 0);\n}\n\nfunction chooseGrowCapacity(size, minLoad, maxLoad) {\n return nextPrime(\n Math.max(size + 1, ((4 * size) / (3 * minLoad + maxLoad)) | 0)\n );\n}\n\nfunction chooseShrinkCapacity(size, minLoad, maxLoad) {\n return nextPrime(\n Math.max(size + 1, ((4 * size) / (minLoad + 3 * maxLoad)) | 0)\n );\n}\n\nfunction newArray(size) {\n return Array(size).fill(0);\n}\n","import HashTable from 'ml-hash-table';\n\nexport class SparseMatrix {\n constructor(rows, columns, options = {}) {\n if (rows instanceof SparseMatrix) {\n // clone\n const other = rows;\n this._init(\n other.rows,\n other.columns,\n other.elements.clone(),\n other.threshold\n );\n return;\n }\n\n if (Array.isArray(rows)) {\n const matrix = rows;\n rows = matrix.length;\n options = columns || {};\n columns = matrix[0].length;\n this._init(rows, columns, new HashTable(options), options.threshold);\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n var value = matrix[i][j];\n if (this.threshold && Math.abs(value) < this.threshold) value = 0;\n if (value !== 0) {\n this.elements.set(i * columns + j, matrix[i][j]);\n }\n }\n }\n } else {\n this._init(rows, columns, new HashTable(options), options.threshold);\n }\n }\n\n _init(rows, columns, elements, threshold) {\n this.rows = rows;\n this.columns = columns;\n this.elements = elements;\n this.threshold = threshold || 0;\n }\n\n static eye(rows = 1, columns = rows) {\n const min = Math.min(rows, columns);\n const matrix = new SparseMatrix(rows, columns, { initialCapacity: min });\n for (var i = 0; i < min; i++) {\n matrix.set(i, i, 1);\n }\n return matrix;\n }\n\n clone() {\n return new SparseMatrix(this);\n }\n\n to2DArray() {\n const copy = new Array(this.rows);\n for (var i = 0; i < this.rows; i++) {\n copy[i] = new Array(this.columns);\n for (var j = 0; j < this.columns; j++) {\n copy[i][j] = this.get(i, j);\n }\n }\n return copy;\n }\n\n isSquare() {\n return this.rows === this.columns;\n }\n\n isSymmetric() {\n if (!this.isSquare()) return false;\n\n var symmetric = true;\n this.forEachNonZero((i, j, v) => {\n if (this.get(j, i) !== v) {\n symmetric = false;\n return false;\n }\n return v;\n });\n return symmetric;\n }\n\n /**\n * Search for the wither band in the main diagonals\n * @return {number}\n */\n bandWidth() {\n let min = this.columns;\n let max = -1;\n this.forEachNonZero((i, j, v) => {\n let diff = i - j;\n min = Math.min(min, diff);\n max = Math.max(max, diff);\n return v;\n });\n return max - min;\n }\n\n /**\n * Test if a matrix is consider banded using a threshold\n * @param {number} width\n * @return {boolean}\n */\n isBanded(width) {\n let bandWidth = this.bandWidth();\n return bandWidth <= width;\n }\n\n get cardinality() {\n return this.elements.size;\n }\n\n get size() {\n return this.rows * this.columns;\n }\n\n get(row, column) {\n return this.elements.get(row * this.columns + column);\n }\n\n set(row, column, value) {\n if (this.threshold && Math.abs(value) < this.threshold) value = 0;\n if (value === 0) {\n this.elements.remove(row * this.columns + column);\n } else {\n this.elements.set(row * this.columns + column, value);\n }\n return this;\n }\n\n mmul(other) {\n if (this.columns !== other.rows) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Number of columns of left matrix are not equal to number of rows of right matrix.'\n );\n }\n\n const m = this.rows;\n const p = other.columns;\n\n const result = new SparseMatrix(m, p);\n this.forEachNonZero((i, j, v1) => {\n other.forEachNonZero((k, l, v2) => {\n if (j === k) {\n result.set(i, l, result.get(i, l) + v1 * v2);\n }\n return v2;\n });\n return v1;\n });\n return result;\n }\n\n kroneckerProduct(other) {\n const m = this.rows;\n const n = this.columns;\n const p = other.rows;\n const q = other.columns;\n\n const result = new SparseMatrix(m * p, n * q, {\n initialCapacity: this.cardinality * other.cardinality\n });\n this.forEachNonZero((i, j, v1) => {\n other.forEachNonZero((k, l, v2) => {\n result.set(p * i + k, q * j + l, v1 * v2);\n return v2;\n });\n return v1;\n });\n return result;\n }\n\n forEachNonZero(callback) {\n this.elements.forEachPair((key, value) => {\n const i = (key / this.columns) | 0;\n const j = key % this.columns;\n let r = callback(i, j, value);\n if (r === false) return false; // stop iteration\n if (this.threshold && Math.abs(r) < this.threshold) r = 0;\n if (r !== value) {\n if (r === 0) {\n this.elements.remove(key, true);\n } else {\n this.elements.set(key, r);\n }\n }\n return true;\n });\n this.elements.maybeShrinkCapacity();\n return this;\n }\n\n getNonZeros() {\n const cardinality = this.cardinality;\n const rows = new Array(cardinality);\n const columns = new Array(cardinality);\n const values = new Array(cardinality);\n var idx = 0;\n this.forEachNonZero((i, j, value) => {\n rows[idx] = i;\n columns[idx] = j;\n values[idx] = value;\n idx++;\n return value;\n });\n return { rows, columns, values };\n }\n\n setThreshold(newThreshold) {\n if (newThreshold !== 0 && newThreshold !== this.threshold) {\n this.threshold = newThreshold;\n this.forEachNonZero((i, j, v) => v);\n }\n return this;\n }\n\n /**\n * @return {SparseMatrix} - New transposed sparse matrix\n */\n transpose() {\n let trans = new SparseMatrix(this.columns, this.rows, {\n initialCapacity: this.cardinality\n });\n this.forEachNonZero((i, j, value) => {\n trans.set(j, i, value);\n return value;\n });\n return trans;\n }\n}\n\nSparseMatrix.prototype.klass = 'Matrix';\n\nSparseMatrix.identity = SparseMatrix.eye;\nSparseMatrix.prototype.tensorProduct = SparseMatrix.prototype.kroneckerProduct;\n\n/*\n Add dynamically instance and static methods for mathematical operations\n */\n\nvar inplaceOperator = `\n(function %name%(value) {\n if (typeof value === 'number') return this.%name%S(value);\n return this.%name%M(value);\n})\n`;\n\nvar inplaceOperatorScalar = `\n(function %name%S(value) {\n this.forEachNonZero((i, j, v) => v %op% value);\n return this;\n})\n`;\n\nvar inplaceOperatorMatrix = `\n(function %name%M(matrix) {\n matrix.forEachNonZero((i, j, v) => {\n this.set(i, j, this.get(i, j) %op% v);\n return v;\n });\n return this;\n})\n`;\n\nvar staticOperator = `\n(function %name%(matrix, value) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%(value);\n})\n`;\n\nvar inplaceMethod = `\n(function %name%() {\n this.forEachNonZero((i, j, v) => %method%(v));\n return this;\n})\n`;\n\nvar staticMethod = `\n(function %name%(matrix) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%();\n})\n`;\n\nconst operators = [\n // Arithmetic operators\n ['+', 'add'],\n ['-', 'sub', 'subtract'],\n ['*', 'mul', 'multiply'],\n ['/', 'div', 'divide'],\n ['%', 'mod', 'modulus'],\n // Bitwise operators\n ['&', 'and'],\n ['|', 'or'],\n ['^', 'xor'],\n ['<<', 'leftShift'],\n ['>>', 'signPropagatingRightShift'],\n ['>>>', 'rightShift', 'zeroFillRightShift']\n];\n\nfor (const operator of operators) {\n for (let i = 1; i < operator.length; i++) {\n SparseMatrix.prototype[operator[i]] = eval(\n fillTemplateFunction(inplaceOperator, {\n name: operator[i],\n op: operator[0]\n })\n );\n SparseMatrix.prototype[`${operator[i]}S`] = eval(\n fillTemplateFunction(inplaceOperatorScalar, {\n name: `${operator[i]}S`,\n op: operator[0]\n })\n );\n SparseMatrix.prototype[`${operator[i]}M`] = eval(\n fillTemplateFunction(inplaceOperatorMatrix, {\n name: `${operator[i]}M`,\n op: operator[0]\n })\n );\n\n SparseMatrix[operator[i]] = eval(\n fillTemplateFunction(staticOperator, { name: operator[i] })\n );\n }\n}\n\nvar methods = [['~', 'not']];\n\n[\n 'abs',\n 'acos',\n 'acosh',\n 'asin',\n 'asinh',\n 'atan',\n 'atanh',\n 'cbrt',\n 'ceil',\n 'clz32',\n 'cos',\n 'cosh',\n 'exp',\n 'expm1',\n 'floor',\n 'fround',\n 'log',\n 'log1p',\n 'log10',\n 'log2',\n 'round',\n 'sign',\n 'sin',\n 'sinh',\n 'sqrt',\n 'tan',\n 'tanh',\n 'trunc'\n].forEach(function (mathMethod) {\n methods.push([`Math.${mathMethod}`, mathMethod]);\n});\n\nfor (const method of methods) {\n for (let i = 1; i < method.length; i++) {\n SparseMatrix.prototype[method[i]] = eval(\n fillTemplateFunction(inplaceMethod, {\n name: method[i],\n method: method[0]\n })\n );\n SparseMatrix[method[i]] = eval(\n fillTemplateFunction(staticMethod, { name: method[i] })\n );\n }\n}\n\nfunction fillTemplateFunction(template, values) {\n for (const i in values) {\n template = template.replace(new RegExp(`%${i}%`, 'g'), values[i]);\n }\n return template;\n}\n","export default function additiveSymmetric(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i]) * (a[i] + b[i])) / (a[i] * b[i]);\n }\n return 2 * d;\n}\n","export default function avg(a, b) {\n var ii = a.length;\n var max = 0;\n var ans = 0;\n var aux = 0;\n for (var i = 0; i < ii; i++) {\n aux = Math.abs(a[i] - b[i]);\n ans += aux;\n if (max < aux) {\n max = aux;\n }\n }\n return (max + ans) / 2;\n}\n","export default function bhattacharyya(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return -Math.log(ans);\n}\n","export default function canberra(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.abs(a[i] - b[i]) / (a[i] + b[i]);\n }\n return ans;\n}\n","export default function chebyshev(a, b) {\n var ii = a.length;\n var max = 0;\n var aux = 0;\n for (var i = 0; i < ii; i++) {\n aux = Math.abs(a[i] - b[i]);\n if (max < aux) {\n max = aux;\n }\n }\n return max;\n}\n","export default function clark(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.sqrt(\n ((a[i] - b[i]) * (a[i] - b[i])) / ((a[i] + b[i]) * (a[i] + b[i]))\n );\n }\n return 2 * d;\n}\n","export default function czekanowskiSimilarity(a, b) {\n var up = 0;\n var down = 0;\n for (var i = 0; i < a.length; i++) {\n up += Math.min(a[i], b[i]);\n down += a[i] + b[i];\n }\n return (2 * up) / down;\n}\n","import czekanowskiSimilarity from '../similarities/czekanowski';\n\nexport default function czekanowskiDistance(a, b) {\n return 1 - czekanowskiSimilarity(a, b);\n}\n","export default function dice(a, b) {\n var ii = a.length;\n var p = 0;\n var q1 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * a[i];\n q1 += b[i] * b[i];\n q2 += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return q2 / (p + q1);\n}\n","export default function divergence(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / ((a[i] + b[i]) * (a[i] + b[i]));\n }\n return 2 * d;\n}\n","export default function fidelity(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return ans;\n}\n","export default function gower(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.abs(a[i] - b[i]);\n }\n return ans / ii;\n}\n","export default function harmonicMean(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += (a[i] * b[i]) / (a[i] + b[i]);\n }\n return 2 * ans;\n}\n","export default function hellinger(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return 2 * Math.sqrt(1 - ans);\n}\n","export default function innerProduct(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * b[i];\n }\n return ans;\n}\n","export default function intersection(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.min(a[i], b[i]);\n }\n return 1 - ans;\n}\n","export default function jaccard(a, b) {\n var ii = a.length;\n var p1 = 0;\n var p2 = 0;\n var q1 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p1 += a[i] * b[i];\n p2 += a[i] * a[i];\n q1 += b[i] * b[i];\n q2 += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return q2 / (p2 + q1 - p1);\n}\n","export default function jeffreys(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += (a[i] - b[i]) * Math.log(a[i] / b[i]);\n }\n return ans;\n}\n","export default function jensenDifference(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n (a[i] * Math.log(a[i]) + b[i] * Math.log(b[i])) / 2 -\n ((a[i] + b[i]) / 2) * Math.log((a[i] + b[i]) / 2);\n }\n return ans;\n}\n","export default function jensenShannon(a, b) {\n var ii = a.length;\n var p = 0;\n var q = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * Math.log((2 * a[i]) / (a[i] + b[i]));\n q += b[i] * Math.log((2 * b[i]) / (a[i] + b[i]));\n }\n return (p + q) / 2;\n}\n","export default function kdivergence(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * Math.log((2 * a[i]) / (a[i] + b[i]));\n }\n return ans;\n}\n","export default function kulczynski(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += Math.min(a[i], b[i]);\n }\n return up / down;\n}\n","export default function kullbackLeibler(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * Math.log(a[i] / b[i]);\n }\n return ans;\n}\n","export default function kumarHassebrook(a, b) {\n var ii = a.length;\n var p = 0;\n var p2 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * b[i];\n p2 += a[i] * a[i];\n q2 += b[i] * b[i];\n }\n return p / (p2 + q2 - p);\n}\n","export default function kumarJohnson(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n Math.pow(a[i] * a[i] - b[i] * b[i], 2) / (2 * Math.pow(a[i] * b[i], 1.5));\n }\n return ans;\n}\n","export default function lorentzian(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.log(Math.abs(a[i] - b[i]) + 1);\n }\n return ans;\n}\n","export default function manhattan(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.abs(a[i] - b[i]);\n }\n return d;\n}\n","export default function matusita(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return Math.sqrt(2 - 2 * ans);\n}\n","export default function minkowski(a, b, p) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.pow(Math.abs(a[i] - b[i]), p);\n }\n return Math.pow(d, 1 / p);\n}\n","export default function motyka(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.min(a[i], b[i]);\n down += a[i] + b[i];\n }\n return 1 - up / down;\n}\n","export default function neyman(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / a[i];\n }\n return d;\n}\n","export default function pearson(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / b[i];\n }\n return d;\n}\n","export default function probabilisticSymmetric(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / (a[i] + b[i]);\n }\n return 2 * d;\n}\n","export default function ruzicka(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.min(a[i], b[i]);\n down += Math.max(a[i], b[i]);\n }\n return up / down;\n}\n","export default function soergel(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += Math.max(a[i], b[i]);\n }\n return up / down;\n}\n","export default function sorensen(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += a[i] + b[i];\n }\n return up / down;\n}\n","export default function squared(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / (a[i] + b[i]);\n }\n return d;\n}\n","export default function squaredChord(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n (Math.sqrt(a[i]) - Math.sqrt(b[i])) * (Math.sqrt(a[i]) - Math.sqrt(b[i]));\n }\n return ans;\n}\n","export default function taneja(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n ((a[i] + b[i]) / 2) *\n Math.log((a[i] + b[i]) / (2 * Math.sqrt(a[i] * b[i])));\n }\n return ans;\n}\n","export default function tanimoto(a, b, bitvector) {\n if (bitvector) {\n var inter = 0;\n var union = 0;\n for (var j = 0; j < a.length; j++) {\n inter += a[j] && b[j];\n union += a[j] || b[j];\n }\n if (union === 0) {\n return 1;\n }\n return inter / union;\n } else {\n var ii = a.length;\n var p = 0;\n var q = 0;\n var m = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i];\n q += b[i];\n m += Math.min(a[i], b[i]);\n }\n return 1 - (p + q - 2 * m) / (p + q - m);\n }\n}\n","import tanimotoS from '../similarities/tanimoto';\n\nexport default function tanimoto(a, b, bitvector) {\n if (bitvector) {\n return 1 - tanimotoS(a, b, bitvector);\n } else {\n var ii = a.length;\n var p = 0;\n var q = 0;\n var m = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i];\n q += b[i];\n m += Math.min(a[i], b[i]);\n }\n return (p + q - 2 * m) / (p + q - m);\n }\n}\n","export default function topsoe(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n a[i] * Math.log((2 * a[i]) / (a[i] + b[i])) +\n b[i] * Math.log((2 * b[i]) / (a[i] + b[i]));\n }\n return ans;\n}\n","export default function waveHedges(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += 1 - Math.min(a[i], b[i]) / Math.max(a[i], b[i]);\n }\n return ans;\n}\n","import binarySearch from 'binary-search';\nimport { ascending } from 'num-sort';\n\n/**\n * Function that creates the tree\n * @param {Array>} spectrum\n * @param {object} [options]\n * @return {Tree|null}\n * left and right have the same structure than the parent,\n * or are null if they are leaves\n */\nexport function createTree(spectrum, options = {}) {\n var X = spectrum[0];\n const {\n minWindow = 0.16,\n threshold = 0.01,\n from = X[0],\n to = X[X.length - 1]\n } = options;\n\n return mainCreateTree(\n spectrum[0],\n spectrum[1],\n from,\n to,\n minWindow,\n threshold\n );\n}\n\nfunction mainCreateTree(X, Y, from, to, minWindow, threshold) {\n if (to - from < minWindow) {\n return null;\n }\n\n // search first point\n var start = binarySearch(X, from, ascending);\n if (start < 0) {\n start = ~start;\n }\n\n // stop at last point\n var sum = 0;\n var center = 0;\n for (var i = start; i < X.length; i++) {\n if (X[i] >= to) {\n break;\n }\n sum += Y[i];\n center += X[i] * Y[i];\n }\n\n if (sum < threshold) {\n return null;\n }\n\n center /= sum;\n if (center - from < 1e-6 || to - center < 1e-6) {\n return null;\n }\n if (center - from < minWindow / 4) {\n return mainCreateTree(X, Y, center, to, minWindow, threshold);\n } else {\n if (to - center < minWindow / 4) {\n return mainCreateTree(X, Y, from, center, minWindow, threshold);\n } else {\n return new Tree(\n sum,\n center,\n mainCreateTree(X, Y, from, center, minWindow, threshold),\n mainCreateTree(X, Y, center, to, minWindow, threshold)\n );\n }\n }\n}\n\nclass Tree {\n constructor(sum, center, left, right) {\n this.sum = sum;\n this.center = center;\n this.left = left;\n this.right = right;\n }\n}\n","import { createTree } from './createTree';\n\n/**\n * Similarity between two nodes\n * @param {Tree|Array>} a - tree A node\n * @param {Tree|Array>} b - tree B node\n * @param {object} [options]\n * @return {number} similarity measure between tree nodes\n */\nexport function getSimilarity(a, b, options = {}) {\n const { alpha = 0.1, beta = 0.33, gamma = 0.001 } = options;\n\n if (a === null || b === null) {\n return 0;\n }\n if (Array.isArray(a)) {\n a = createTree(a);\n }\n if (Array.isArray(b)) {\n b = createTree(b);\n }\n\n var C =\n (alpha * Math.min(a.sum, b.sum)) / Math.max(a.sum, b.sum) +\n (1 - alpha) * Math.exp(-gamma * Math.abs(a.center - b.center));\n\n return (\n beta * C +\n ((1 - beta) *\n (getSimilarity(a.left, b.left, options) +\n getSimilarity(a.right, b.right, options))) /\n 2\n );\n}\n","import { getSimilarity } from './getSimilarity';\n\nexport { createTree } from './createTree';\n\nexport function treeSimilarity(A, B, options = {}) {\n return getSimilarity(A, B, options);\n}\n\nexport function getFunction(options = {}) {\n return (A, B) => getSimilarity(A, B, options);\n}\n","export default function cosine(a, b) {\n var ii = a.length;\n var p = 0;\n var p2 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * b[i];\n p2 += a[i] * a[i];\n q2 += b[i] * b[i];\n }\n return p / (Math.sqrt(p2) * Math.sqrt(q2));\n}\n","import diceD from '../distances/dice';\n\nexport default function dice(a, b) {\n return 1 - diceD(a, b);\n}\n","import intersectionD from '../distances/intersection';\n\nexport default function intersection(a, b) {\n return 1 - intersectionD(a, b);\n}\n","import jaccardD from '../distances/jaccard';\n\nexport default function jaccard(a, b) {\n return 1 - jaccardD(a, b);\n}\n","import kulczynskiD from '../distances/kulczynski';\n\nexport default function kulczynski(a, b) {\n return 1 / kulczynskiD(a, b);\n}\n","import motykaD from '../distances/motyka';\n\nexport default function motyka(a, b) {\n return 1 - motykaD(a, b);\n}\n","import mean from 'ml-array-mean';\n\nimport cosine from './cosine';\n\nexport default function pearson(a, b) {\n var avgA = mean(a);\n var avgB = mean(b);\n\n var newA = new Array(a.length);\n var newB = new Array(b.length);\n for (var i = 0; i < newA.length; i++) {\n newA[i] = a[i] - avgA;\n newB[i] = b[i] - avgB;\n }\n\n return cosine(newA, newB);\n}\n","import squaredChordD from '../distances/squaredChord';\n\nexport default function squaredChord(a, b) {\n return 1 - squaredChordD(a, b);\n}\n","'use strict';\n\n// Accuracy\nexports.acc = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.tn[i] + pred.tp[i]) / (l - 1);\n }\n return result;\n};\n\n// Error rate\nexports.err = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.fp[i] / (l - 1));\n }\n return result;\n};\n\n// False positive rate\nexports.fpr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.fp[i] / pred.nNeg;\n }\n return result;\n};\n\n// True positive rate\nexports.tpr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.tp[i] / pred.nPos;\n }\n return result;\n};\n\n// False negative rate\nexports.fnr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.fn[i] / pred.nPos;\n }\n return result;\n};\n\n// True negative rate\nexports.tnr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.tn[i] / pred.nNeg;\n }\n return result;\n};\n\n// Positive predictive value\nexports.ppv = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fp[i] + pred.tp[i] !== 0) ? (pred.tp[i] / (pred.fp[i] + pred.tp[i])) : 0;\n }\n return result;\n};\n\n// Negative predictive value\nexports.npv = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.tn[i] !== 0) ? (pred.tn[i] / (pred.fn[i] + pred.tn[i])) : 0;\n }\n return result;\n};\n\n// Prediction conditioned fallout\nexports.pcfall = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fp[i] + pred.tp[i] !== 0) ? 1 - (pred.tp[i] / (pred.fp[i] + pred.tp[i])) : 1;\n }\n return result;\n};\n\n// Prediction conditioned miss\nexports.pcmiss = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.tn[i] !== 0) ? 1 - (pred.tn[i] / (pred.fn[i] + pred.tn[i])) : 1;\n }\n return result;\n};\n\n// Lift value\nexports.lift = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.nPosPred[i] !== 0) ? ((pred.tp[i] / pred.nPos) / (pred.nPosPred[i] / pred.nSamples)) : 0;\n }\n return result;\n};\n\n// Rate of positive predictions\nexports.rpp = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.nPosPred[i] / pred.nSamples;\n }\n return result;\n};\n\n// Rate of negative predictions\nexports.rnp = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.nNegPred[i] / pred.nSamples;\n }\n return result;\n};\n\n// Threshold\nexports.threshold = pred => {\n const clone = pred.cutoffs.slice();\n clone[0] = clone[1]; // Remove the infinite value\n return clone;\n};\n","'use strict';\n\nconst measures = require('./measures');\n\nclass Performance {\n /**\n *\n * @param prediction - The prediction matrix\n * @param target - The target matrix (values: truthy for same class, falsy for different class)\n * @param options\n *\n * @option all True if the entire matrix must be used. False to ignore the diagonal and lower part (default is false, for similarity/distance matrices)\n * @option max True if the max value corresponds to a perfect match (like in similarity matrices), false if it is the min value (default is false, like in distance matrices. All values will be multiplied by -1)\n */\n constructor(prediction, target, options) {\n options = options || {};\n if (prediction.length !== target.length || prediction[0].length !== target[0].length) {\n throw new Error('dimensions of prediction and target do not match');\n }\n const rows = prediction.length;\n const columns = prediction[0].length;\n const isDistance = !options.max;\n\n const predP = [];\n\n if (options.all) {\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n predP.push({\n pred: prediction[i][j],\n targ: target[i][j]\n });\n }\n }\n } else {\n if (rows < 3 || rows !== columns) {\n throw new Error('When \"all\" option is false, the prediction matrix must be square and have at least 3 columns');\n }\n for (var i = 0; i < rows - 1; i++) {\n for (var j = i + 1; j < columns; j++) {\n predP.push({\n pred: prediction[i][j],\n targ: target[i][j]\n });\n }\n }\n }\n\n if (isDistance) {\n predP.sort((a, b) => a.pred - b.pred);\n } else {\n predP.sort((a, b) => b.pred - a.pred);\n }\n \n const cutoffs = this.cutoffs = [isDistance ? Number.MIN_VALUE : Number.MAX_VALUE];\n const fp = this.fp = [0];\n const tp = this.tp = [0];\n\n var nPos = 0;\n var nNeg = 0;\n\n var currentPred = predP[0].pred;\n var nTp = 0;\n var nFp = 0;\n for (var i = 0; i < predP.length; i++) {\n if (predP[i].pred !== currentPred) {\n cutoffs.push(currentPred);\n fp.push(nFp);\n tp.push(nTp);\n currentPred = predP[i].pred;\n }\n if (predP[i].targ) {\n nPos++;\n nTp++;\n } else {\n nNeg++;\n nFp++;\n }\n }\n cutoffs.push(currentPred);\n fp.push(nFp);\n tp.push(nTp);\n\n const l = cutoffs.length;\n const fn = this.fn = new Array(l);\n const tn = this.tn = new Array(l);\n const nPosPred = this.nPosPred = new Array(l);\n const nNegPred = this.nNegPred = new Array(l);\n\n for (var i = 0; i < l; i++) {\n fn[i] = nPos - tp[i];\n tn[i] = nNeg - fp[i];\n\n nPosPred[i] = tp[i] + fp[i];\n nNegPred[i] = tn[i] + fn[i];\n }\n\n this.nPos = nPos;\n this.nNeg = nNeg;\n this.nSamples = nPos + nNeg;\n }\n\n /**\n * Computes a measure from the prediction object.\n *\n * Many measures are available and can be combined :\n * To create a ROC curve, you need fpr and tpr\n * To create a DET curve, you need fnr and fpr\n * To create a Lift chart, you need rpp and lift\n *\n * Possible measures are : threshold (Threshold), acc (Accuracy), err (Error rate),\n * fpr (False positive rate), tpr (True positive rate), fnr (False negative rate), tnr (True negative rate), ppv (Positive predictive value),\n * npv (Negative predictive value), pcfall (Prediction-conditioned fallout), pcmiss (Prediction-conditioned miss), lift (Lift value), rpp (Rate of positive predictions), rnp (Rate of negative predictions)\n *\n * @param measure - The short name of the measure\n *\n * @return [number]\n */\n getMeasure(measure) {\n if (typeof measure !== 'string') {\n throw new Error('No measure specified');\n }\n if (!measures[measure]) {\n throw new Error(`The specified measure (${measure}) does not exist`);\n }\n return measures[measure](this);\n }\n\n /**\n * Returns the area under the ROC curve\n */\n getAURC() {\n const l = this.cutoffs.length;\n const x = new Array(l);\n const y = new Array(l);\n for (var i = 0; i < l; i++) {\n x[i] = this.fp[i] / this.nNeg;\n y[i] = this.tp[i] / this.nPos;\n }\n var auc = 0;\n for (i = 1; i < l; i++) {\n auc += 0.5 * (x[i] - x[i - 1]) * (y[i] + y[i - 1]);\n }\n return auc;\n }\n\n /**\n * Returns the area under the DET curve\n */\n getAUDC() {\n const l = this.cutoffs.length;\n const x = new Array(l);\n const y = new Array(l);\n for (var i = 0; i < l; i++) {\n x[i] = this.fn[i] / this.nPos;\n y[i] = this.fp[i] / this.nNeg;\n }\n var auc = 0;\n for (i = 1; i < l; i++) {\n auc += 0.5 * (x[i] + x[i - 1]) * (y[i] - y[i - 1]);\n }\n return auc;\n }\n\n getDistribution(options) {\n options = options || {};\n var cutLength = this.cutoffs.length;\n var cutLow = options.xMin || Math.floor(this.cutoffs[cutLength - 1] * 100) / 100;\n var cutHigh = options.xMax || Math.ceil(this.cutoffs[1] * 100) / 100;\n var interval = options.interval || Math.floor(((cutHigh - cutLow) / 20 * 10000000) - 1) / 10000000; // Trick to avoid the precision problem of float numbers\n\n var xLabels = [];\n var interValues = [];\n var intraValues = [];\n var interCumPercent = [];\n var intraCumPercent = [];\n\n var nTP = this.tp[cutLength - 1], currentTP = 0;\n var nFP = this.fp[cutLength - 1], currentFP = 0;\n\n for (var i = cutLow, j = (cutLength - 1); i <= cutHigh; i += interval) {\n while (this.cutoffs[j] < i)\n j--;\n\n xLabels.push(i);\n\n var thisTP = nTP - currentTP - this.tp[j];\n var thisFP = nFP - currentFP - this.fp[j];\n\n currentTP += thisTP;\n currentFP += thisFP;\n\n interValues.push(thisFP);\n intraValues.push(thisTP);\n\n interCumPercent.push(100 - (nFP - this.fp[j]) / nFP * 100);\n intraCumPercent.push(100 - (nTP - this.tp[j]) / nTP * 100);\n }\n\n return {\n xLabels: xLabels,\n interValues: interValues,\n intraValues: intraValues,\n interCumPercent: interCumPercent,\n intraCumPercent: intraCumPercent\n };\n }\n}\n\nPerformance.names = {\n acc: 'Accuracy',\n err: 'Error rate',\n fpr: 'False positive rate',\n tpr: 'True positive rate',\n fnr: 'False negative rate',\n tnr: 'True negative rate',\n ppv: 'Positive predictive value',\n npv: 'Negative predictive value',\n pcfall: 'Prediction-conditioned fallout',\n pcmiss: 'Prediction-conditioned miss',\n lift: 'Lift value',\n rpp: 'Rate of positive predictions',\n rnp: 'Rate of negative predictions',\n threshold: 'Threshold'\n};\n\nmodule.exports = Performance;\n","'use strict';\n\nvar defaultOptions = {\n size: 1,\n value: 0\n};\n\n/**\n * Case when the entry is an array\n * @param data\n * @param options\n * @returns {Array}\n */\nfunction arrayCase(data, options) {\n var len = data.length;\n if (typeof options.size === 'number') {\n options.size = [options.size, options.size];\n }\n\n var cond = len + options.size[0] + options.size[1];\n\n var output;\n if (options.output) {\n if (options.output.length !== cond) {\n throw new RangeError('Wrong output size');\n }\n output = options.output;\n } else {\n output = new Array(cond);\n }\n\n var i;\n if (options.value === 'circular') {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) {\n output[i] = data[(len - (options.size[0] % len) + i) % len];\n } else if (i < options.size[0] + len) {\n output[i] = data[i - options.size[0]];\n } else {\n output[i] = data[(i - options.size[0]) % len];\n }\n }\n } else if (options.value === 'replicate') {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = data[0];\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = data[len - 1];\n }\n } else if (options.value === 'symmetric') {\n if (options.size[0] > len || options.size[1] > len) {\n throw new RangeError(\n 'expanded value should not be bigger than the data length'\n );\n }\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = data[options.size[0] - 1 - i];\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = data[2 * len + options.size[0] - i - 1];\n }\n } else {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = options.value;\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = options.value;\n }\n }\n\n return output;\n}\n\n/**\n * Case when the entry is a matrix\n * @param data\n * @param options\n * @returns {Array}\n */\nfunction matrixCase(data, options) {\n // var row = data.length;\n // var col = data[0].length;\n if (options.size[0] === undefined) {\n options.size = [options.size, options.size, options.size, options.size];\n }\n throw new Error('matrix not supported yet, sorry');\n}\n\n/**\n * Pads and array\n * @param {Array } data\n * @param {object} options\n */\nfunction padArray(data, options) {\n options = Object.assign({}, defaultOptions, options);\n if (Array.isArray(data)) {\n if (Array.isArray(data[0])) return matrixCase(data, options);\n else return arrayCase(data, options);\n } else {\n throw new TypeError('data should be an array');\n }\n}\n\nmodule.exports = padArray;\n","import { Matrix, MatrixTransposeView, inverse } from 'ml-matrix';\nimport padArray from 'ml-pad-array';\n\n/**\n * Factorial of a number\n * @ignore\n * @param n\n * @return {number}\n */\nfunction factorial(n) {\n let r = 1;\n while (n > 0) r *= n--;\n return r;\n}\n\nconst defaultOptions = {\n windowSize: 5,\n derivative: 1,\n polynomial: 2,\n pad: 'none',\n padValue: 'replicate',\n};\n\n/**\n * Savitzky-Golay filter\n * @param {Array } data\n * @param {number} h\n * @param {Object} options\n * @returns {Array}\n */\nexport default function savitzkyGolay(data, h, options) {\n options = Object.assign({}, defaultOptions, options);\n if (\n options.windowSize % 2 === 0 ||\n options.windowSize < 5 ||\n !Number.isInteger(options.windowSize)\n ) {\n throw new RangeError(\n 'Invalid window size (should be odd and at least 5 integer number)',\n );\n }\n if (options.derivative < 0 || !Number.isInteger(options.derivative)) {\n throw new RangeError('Derivative should be a positive integer');\n }\n if (options.polynomial < 1 || !Number.isInteger(options.polynomial)) {\n throw new RangeError('Polynomial should be a positive integer');\n }\n\n let C, norm;\n let step = Math.floor(options.windowSize / 2);\n\n if (options.pad === 'pre') {\n data = padArray(data, { size: step, value: options.padValue });\n }\n\n let ans = new Array(data.length - 2 * step);\n\n if (\n options.windowSize === 5 &&\n options.polynomial === 2 &&\n (options.derivative === 1 || options.derivative === 2)\n ) {\n if (options.derivative === 1) {\n C = [-2, -1, 0, 1, 2];\n norm = 10;\n } else {\n C = [2, -1, -2, -1, 2];\n norm = 7;\n }\n } else {\n let J = Matrix.ones(options.windowSize, options.polynomial + 1);\n let inic = -(options.windowSize - 1) / 2;\n for (let i = 0; i < J.rows; i++) {\n for (let j = 0; j < J.columns; j++) {\n if (inic + 1 !== 0 || j !== 0) J.set(i, j, Math.pow(inic + i, j));\n }\n }\n let Jtranspose = new MatrixTransposeView(J);\n let Jinv = inverse(Jtranspose.mmul(J));\n C = Jinv.mmul(Jtranspose);\n C = C.getRow(options.derivative);\n norm = 1 / factorial(options.derivative);\n }\n let det = norm * Math.pow(h, options.derivative);\n for (let k = step; k < data.length - step; k++) {\n let d = 0;\n for (let l = 0; l < C.length; l++) d += (C[l] * data[l + k - step]) / det;\n ans[k - step] = d;\n }\n\n if (options.pad === 'post') {\n ans = padArray(ans, { size: step, value: options.padValue });\n }\n\n return ans;\n}\n","// auxiliary file to create the 256 look at table elements\n\nvar ans = new Array(256);\nfor (var i = 0; i < 256; i++) {\n var num = i;\n var c = 0;\n while (num) {\n num = num & (num - 1);\n c++;\n }\n ans[i] = c;\n}\n\nmodule.exports = ans;","'use strict';\n\nvar eightBits = require('./creator');\n\n/**\n * Count the number of true values in an array\n * @param {Array} arr\n * @return {number}\n */\nfunction count(arr) {\n var c = 0;\n for (var i = 0; i < arr.length; i++) {\n c += eightBits[arr[i] & 0xff] + eightBits[(arr[i] >> 8) & 0xff] + eightBits[(arr[i] >> 16) & 0xff] + eightBits[(arr[i] >> 24) & 0xff];\n }\n return c;\n}\n\n/**\n * Logical AND operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction and(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] & arr2[i];\n return ans;\n}\n\n/**\n * Logical OR operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction or(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] | arr2[i];\n return ans;\n}\n\n/**\n * Logical XOR operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction xor(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] ^ arr2[i];\n return ans;\n}\n\n/**\n * Logical NOT operation\n * @param {Array} arr\n * @return {Array}\n */\nfunction not(arr) {\n var ans = new Array(arr.length);\n for (var i = 0; i < ans.length; i++)\n ans[i] = ~arr[i];\n return ans;\n}\n\n/**\n * Gets the n value of array arr\n * @param {Array} arr\n * @param {number} n\n * @return {boolean}\n */\nfunction getBit(arr, n) {\n var index = n >> 5; // Same as Math.floor(n/32)\n var mask = 1 << (31 - n % 32);\n return Boolean(arr[index] & mask);\n}\n\n/**\n * Sets the n value of array arr to the value val\n * @param {Array} arr\n * @param {number} n\n * @param {boolean} val\n * @return {Array}\n */\nfunction setBit(arr, n, val) {\n var index = n >> 5; // Same as Math.floor(n/32)\n var mask = 1 << (31 - n % 32);\n if (val)\n arr[index] = mask | arr[index];\n else\n arr[index] = ~mask & arr[index];\n return arr;\n}\n\n/**\n * Translates an array of numbers to a string of bits\n * @param {Array} arr\n * @returns {string}\n */\nfunction toBinaryString(arr) {\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n var obj = (arr[i] >>> 0).toString(2);\n str += '00000000000000000000000000000000'.substr(obj.length) + obj;\n }\n return str;\n}\n\n/**\n * Creates an array of numbers based on a string of bits\n * @param {string} str\n * @returns {Array}\n */\nfunction parseBinaryString(str) {\n var len = str.length / 32;\n var ans = new Array(len);\n for (var i = 0; i < len; i++) {\n ans[i] = parseInt(str.substr(i*32, 32), 2) | 0;\n }\n return ans;\n}\n\n/**\n * Translates an array of numbers to a hex string\n * @param {Array} arr\n * @returns {string}\n */\nfunction toHexString(arr) {\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n var obj = (arr[i] >>> 0).toString(16);\n str += '00000000'.substr(obj.length) + obj;\n }\n return str;\n}\n\n/**\n * Creates an array of numbers based on a hex string\n * @param {string} str\n * @returns {Array}\n */\nfunction parseHexString(str) {\n var len = str.length / 8;\n var ans = new Array(len);\n for (var i = 0; i < len; i++) {\n ans[i] = parseInt(str.substr(i*8, 8), 16) | 0;\n }\n return ans;\n}\n\n/**\n * Creates a human readable string of the array\n * @param {Array} arr\n * @returns {string}\n */\nfunction toDebug(arr) {\n var binary = toBinaryString(arr);\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n str += '0000'.substr((i * 32).toString(16).length) + (i * 32).toString(16) + ':';\n for (var j = 0; j < 32; j += 4) {\n str += ' ' + binary.substr(i * 32 + j, 4);\n }\n if (i < arr.length - 1) str += '\\n';\n }\n return str\n}\n\nmodule.exports = {\n count: count,\n and: and,\n or: or,\n xor: xor,\n not: not,\n getBit: getBit,\n setBit: setBit,\n toBinaryString: toBinaryString,\n parseBinaryString: parseBinaryString,\n toHexString: toHexString,\n parseHexString: parseHexString,\n toDebug: toDebug\n};\n","export default function SavitzkyGolay(data, h, options = {}) {\n let { windowSize = 9, derivative = 0, polynomial = 3 } = options;\n\n if (windowSize % 2 === 0 || windowSize < 5 || !Number.isInteger(windowSize)) {\n throw new RangeError(\n 'Invalid window size (should be odd and at least 5 integer number)',\n );\n }\n if (windowSize > data.length) {\n throw new RangeError(\n `Window size is higher than the data length ${windowSize}>${data.length}`,\n );\n }\n if (derivative < 0 || !Number.isInteger(derivative)) {\n throw new RangeError('Derivative should be a positive integer');\n }\n if (polynomial < 1 || !Number.isInteger(polynomial)) {\n throw new RangeError('Polynomial should be a positive integer');\n }\n if (polynomial >= 6) {\n // eslint-disable-next-line no-console\n console.warn(\n 'You should not use polynomial grade higher than 5 if you are' +\n ' not sure that your data arises from such a model. Possible polynomial oscillation problems',\n );\n }\n\n let half = Math.floor(windowSize / 2);\n let np = data.length;\n let ans = new Array(np);\n let weights = fullWeights(windowSize, polynomial, derivative);\n let hs = 0;\n let constantH = true;\n if (Array.isArray(h)) {\n constantH = false;\n } else {\n hs = Math.pow(h, derivative);\n }\n\n //For the borders\n for (let i = 0; i < half; i++) {\n let wg1 = weights[half - i - 1];\n let wg2 = weights[half + i + 1];\n let d1 = 0;\n let d2 = 0;\n for (let l = 0; l < windowSize; l++) {\n d1 += wg1[l] * data[l];\n d2 += wg2[l] * data[np - windowSize + l];\n }\n if (constantH) {\n ans[half - i - 1] = d1 / hs;\n ans[np - half + i] = d2 / hs;\n } else {\n hs = getHs(h, half - i - 1, half, derivative);\n ans[half - i - 1] = d1 / hs;\n hs = getHs(h, np - half + i, half, derivative);\n ans[np - half + i] = d2 / hs;\n }\n }\n\n //For the internal points\n let wg = weights[half];\n for (let i = windowSize; i <= np; i++) {\n let d = 0;\n for (let l = 0; l < windowSize; l++) d += wg[l] * data[l + i - windowSize];\n if (!constantH) hs = getHs(h, i - half - 1, half, derivative);\n ans[i - half - 1] = d / hs;\n }\n return ans;\n}\n\nfunction getHs(h, center, half, derivative) {\n let hs = 0;\n let count = 0;\n for (let i = center - half; i < center + half; i++) {\n if (i >= 0 && i < h.length - 1) {\n hs += h[i + 1] - h[i];\n count++;\n }\n }\n return Math.pow(hs / count, derivative);\n}\n\nfunction GramPoly(i, m, k, s) {\n let Grampoly = 0;\n if (k > 0) {\n Grampoly =\n ((4 * k - 2) / (k * (2 * m - k + 1))) *\n (i * GramPoly(i, m, k - 1, s) + s * GramPoly(i, m, k - 1, s - 1)) -\n (((k - 1) * (2 * m + k)) / (k * (2 * m - k + 1))) *\n GramPoly(i, m, k - 2, s);\n } else {\n if (k === 0 && s === 0) {\n Grampoly = 1;\n } else {\n Grampoly = 0;\n }\n }\n return Grampoly;\n}\n\nfunction GenFact(a, b) {\n let gf = 1;\n if (a >= b) {\n for (let j = a - b + 1; j <= a; j++) {\n gf *= j;\n }\n }\n return gf;\n}\n\nfunction Weight(i, t, m, n, s) {\n let sum = 0;\n for (let k = 0; k <= n; k++) {\n //console.log(k);\n sum +=\n (2 * k + 1) *\n (GenFact(2 * m, k) / GenFact(2 * m + k + 1, k + 1)) *\n GramPoly(i, m, k, 0) *\n GramPoly(t, m, k, s);\n }\n return sum;\n}\n\n/**\n *\n * @param m Number of points\n * @param n Polynomial grade\n * @param s Derivative\n */\nfunction fullWeights(m, n, s) {\n let weights = new Array(m);\n let np = Math.floor(m / 2);\n for (let t = -np; t <= np; t++) {\n weights[t + np] = new Array(m);\n for (let j = -np; j <= np; j++) {\n weights[t + np][j + np] = Weight(j, t, np, n, s);\n }\n }\n return weights;\n}\n\n/*function entropy(data,h,options){\n var trend = SavitzkyGolay(data,h,trendOptions);\n var copy = new Array(data.length);\n var sum = 0;\n var max = 0;\n for(var i=0;i} x - Independent variable\n * @param {Array} yIn - Dependent variable\n * @param {object} [options] - Options object\n * @param {object} [options.sgOptions] - Options object for Savitzky-Golay filter. See https://github.com/mljs/savitzky-golay-generalized#options\n * @param {number} [options.sgOptions.windowSize = 9] - points to use in the approximations\n * @param {number} [options.sgOptions.polynomial = 3] - degree of the polynomial to use in the approximations\n * @param {number} [options.minMaxRatio = 0.00025] - Threshold to determine if a given peak should be considered as a noise\n * @param {number} [options.broadRatio = 0.00] - If `broadRatio` is higher than 0, then all the peaks which second derivative\n * smaller than `broadRatio * maxAbsSecondDerivative` will be marked with the soft mask equal to true.\n * @param {number} [options.noiseLevel = 0] - Noise threshold in spectrum units\n * @param {boolean} [options.maxCriteria = true] - Peaks are local maximum(true) or minimum(false)\n * @param {boolean} [options.smoothY = true] - Select the peak intensities from a smoothed version of the independent variables\n * @param {boolean} [options.realTopDetection = false] - Use a quadratic optimizations with the peak and its 3 closest neighbors\n * to determine the true x,y values of the peak?\n * @param {number} [options.heightFactor = 0] - Factor to multiply the calculated height (usually 2)\n * @param {number} [options.derivativeThreshold = -1] - Filters based on the amplitude of the first derivative\n * @return {Array}\n */\nexport function gsd(x, yIn, options = {}) {\n let {\n noiseLevel,\n sgOptions = {\n windowSize: 9,\n polynomial: 3,\n },\n smoothY = true,\n heightFactor = 0,\n broadRatio = 0.0,\n maxCriteria = true,\n minMaxRatio = 0.00025,\n derivativeThreshold = -1,\n realTopDetection = false,\n } = options;\n\n const y = yIn.slice();\n let equalSpaced = isEqualSpaced(x);\n\n if (noiseLevel === undefined) {\n noiseLevel = equalSpaced ? getNoiseLevel(y) : 0;\n }\n\n const yCorrection = { m: 1, b: noiseLevel };\n\n if (!maxCriteria) {\n yCorrection.m = -1;\n yCorrection.b *= -1;\n }\n\n for (let i = 0; i < y.length; i++) {\n y[i] = yCorrection.m * y[i] - yCorrection.b;\n }\n\n for (let i = 0; i < y.length; i++) {\n if (y[i] < 0) {\n y[i] = 0;\n }\n }\n // If the max difference between delta x is less than 5%, then,\n // we can assume it to be equally spaced variable\n let yData = y;\n let dY, ddY;\n const { windowSize, polynomial } = sgOptions;\n\n if (equalSpaced) {\n if (smoothY) {\n yData = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 0,\n });\n }\n dY = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 1,\n });\n ddY = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 2,\n });\n } else {\n if (smoothY) {\n yData = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 0,\n });\n }\n dY = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 1,\n });\n ddY = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 2,\n });\n }\n\n const xData = x;\n const dX = x[1] - x[0];\n let maxDdy = 0;\n let maxY = 0;\n for (let i = 0; i < yData.length; i++) {\n if (Math.abs(ddY[i]) > maxDdy) {\n maxDdy = Math.abs(ddY[i]);\n }\n if (Math.abs(yData[i]) > maxY) {\n maxY = Math.abs(yData[i]);\n }\n }\n\n let lastMax = null;\n let lastMin = null;\n let minddY = new Array(yData.length - 2);\n let intervalL = new Array(yData.length);\n let intervalR = new Array(yData.length);\n let broadMask = new Array(yData.length - 2);\n let minddYLen = 0;\n let intervalLLen = 0;\n let intervalRLen = 0;\n let broadMaskLen = 0;\n // By the intermediate value theorem We cannot find 2 consecutive maximum or minimum\n for (let i = 1; i < yData.length - 1; ++i) {\n // filter based on derivativeThreshold\n // console.log('pasa', y[i], dY[i], ddY[i]);\n if (Math.abs(dY[i]) > derivativeThreshold) {\n // Minimum in first derivative\n if (\n (dY[i] < dY[i - 1] && dY[i] <= dY[i + 1]) ||\n (dY[i] <= dY[i - 1] && dY[i] < dY[i + 1])\n ) {\n lastMin = {\n x: xData[i],\n index: i,\n };\n if (dX > 0 && lastMax !== null) {\n intervalL[intervalLLen++] = lastMax;\n intervalR[intervalRLen++] = lastMin;\n }\n }\n\n // Maximum in first derivative\n if (\n (dY[i] >= dY[i - 1] && dY[i] > dY[i + 1]) ||\n (dY[i] > dY[i - 1] && dY[i] >= dY[i + 1])\n ) {\n lastMax = {\n x: xData[i],\n index: i,\n };\n if (dX < 0 && lastMin !== null) {\n intervalL[intervalLLen++] = lastMax;\n intervalR[intervalRLen++] = lastMin;\n }\n }\n }\n\n // Minimum in second derivative\n if (ddY[i] < ddY[i - 1] && ddY[i] < ddY[i + 1]) {\n // TODO should we change this to have 3 arrays ? Huge overhead creating arrays\n minddY[minddYLen++] = i; // ( [xData[i], yData[i], i] );\n broadMask[broadMaskLen++] = Math.abs(ddY[i]) <= broadRatio * maxDdy;\n }\n }\n minddY.length = minddYLen;\n intervalL.length = intervalLLen;\n intervalR.length = intervalRLen;\n broadMask.length = broadMaskLen;\n\n let signals = new Array(minddY.length);\n let signalsLen = 0;\n let lastK = -1;\n let possible, frequency, distanceJ, minDistance, gettingCloser;\n for (let j = 0; j < minddY.length; ++j) {\n frequency = xData[minddY[j]];\n possible = -1;\n let k = lastK + 1;\n minDistance = Number.MAX_VALUE;\n distanceJ = 0;\n gettingCloser = true;\n while (possible === -1 && k < intervalL.length && gettingCloser) {\n distanceJ = Math.abs(frequency - (intervalL[k].x + intervalR[k].x) / 2);\n\n // Still getting closer?\n if (distanceJ < minDistance) {\n minDistance = distanceJ;\n } else {\n gettingCloser = false;\n }\n if (distanceJ < Math.abs(intervalL[k].x - intervalR[k].x) / 2) {\n possible = k;\n lastK = k;\n }\n ++k;\n }\n\n if (possible !== -1) {\n if (Math.abs(yData[minddY[j]]) > minMaxRatio * maxY) {\n signals[signalsLen++] = {\n index: minddY[j],\n x: frequency,\n y: (yData[minddY[j]] + yCorrection.b) / yCorrection.m,\n width: Math.abs(intervalR[possible].x - intervalL[possible].x), // widthCorrection\n soft: broadMask[j],\n };\n\n signals[signalsLen - 1].left = intervalL[possible];\n signals[signalsLen - 1].right = intervalR[possible];\n\n if (heightFactor) {\n let yLeft = yData[intervalL[possible].index];\n let yRight = yData[intervalR[possible].index];\n signals[signalsLen - 1].height =\n heightFactor * (signals[signalsLen - 1].y - (yLeft + yRight) / 2);\n }\n }\n }\n }\n signals.length = signalsLen;\n\n if (realTopDetection) {\n determineRealTop(signals, xData, yData);\n }\n\n // Correct the values to fit the original spectra data\n for (let j = 0; j < signals.length; j++) {\n signals[j].base = noiseLevel;\n }\n\n signals.sort(function (a, b) {\n return a.x - b.x;\n });\n\n return signals;\n}\n\nconst isEqualSpaced = (x) => {\n let tmp;\n let maxDx = 0;\n let minDx = Number.MAX_SAFE_INTEGER;\n for (let i = 0; i < x.length - 1; ++i) {\n tmp = Math.abs(x[i + 1] - x[i]);\n if (tmp < minDx) {\n minDx = tmp;\n }\n if (tmp > maxDx) {\n maxDx = tmp;\n }\n }\n return (maxDx - minDx) / maxDx < 0.05;\n};\n\nconst getNoiseLevel = (y) => {\n let mean = 0;\n\n let stddev = 0;\n let length = y.length;\n for (let i = 0; i < length; ++i) {\n mean += y[i];\n }\n mean /= length;\n let averageDeviations = new Array(length);\n for (let i = 0; i < length; ++i) {\n averageDeviations[i] = Math.abs(y[i] - mean);\n }\n averageDeviations.sort((a, b) => a - b);\n if (length % 2 === 1) {\n stddev = averageDeviations[(length - 1) / 2] / 0.6745;\n } else {\n stddev =\n (0.5 *\n (averageDeviations[length / 2] + averageDeviations[length / 2 - 1])) /\n 0.6745;\n }\n\n return stddev;\n};\n\nconst determineRealTop = (peakList, x, y) => {\n let alpha, beta, gamma, p, currentPoint;\n for (let j = 0; j < peakList.length; j++) {\n currentPoint = peakList[j].index; // peakList[j][2];\n // The detected peak could be moved 1 or 2 units to left or right.\n if (\n y[currentPoint - 1] >= y[currentPoint - 2] &&\n y[currentPoint - 1] >= y[currentPoint]\n ) {\n currentPoint--;\n } else {\n if (\n y[currentPoint + 1] >= y[currentPoint] &&\n y[currentPoint + 1] >= y[currentPoint + 2]\n ) {\n currentPoint++;\n } else {\n if (\n y[currentPoint - 2] >= y[currentPoint - 3] &&\n y[currentPoint - 2] >= y[currentPoint - 1]\n ) {\n currentPoint -= 2;\n } else {\n if (\n y[currentPoint + 2] >= y[currentPoint + 1] &&\n y[currentPoint + 2] >= y[currentPoint + 3]\n ) {\n currentPoint += 2;\n }\n }\n }\n }\n // interpolation to a sin() function\n if (\n y[currentPoint - 1] > 0 &&\n y[currentPoint + 1] > 0 &&\n y[currentPoint] >= y[currentPoint - 1] &&\n y[currentPoint] >= y[currentPoint + 1] &&\n (y[currentPoint] !== y[currentPoint - 1] ||\n y[currentPoint] !== y[currentPoint + 1])\n ) {\n alpha = 20 * Math.log10(y[currentPoint - 1]);\n beta = 20 * Math.log10(y[currentPoint]);\n gamma = 20 * Math.log10(y[currentPoint + 1]);\n p = (0.5 * (alpha - gamma)) / (alpha - 2 * beta + gamma);\n // console.log(alpha, beta, gamma, `p: ${p}`);\n // console.log(x[currentPoint]+\" \"+tmp+\" \"+currentPoint);\n peakList[j].x =\n x[currentPoint] + (x[currentPoint] - x[currentPoint - 1]) * p;\n peakList[j].y =\n y[currentPoint] -\n 0.25 * (y[currentPoint - 1] - y[currentPoint + 1]) * p;\n }\n }\n};\n","/**\n * This function calculates the spectrum as a sum of gaussian functions. The Gaussian\n * parameters are divided in 3 batches. 1st: centers; 2nd: height; 3th: std's;\n * @param t Ordinate values\n * @param p Gaussian parameters\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\nexport function sumOfGaussians(p) {\n return function (t) {\n let nL = p.length / 3;\n let factor;\n let rows = t.length;\n let result = rows === undefined ? 0 : new Float64Array(rows).fill(0);\n for (let i = 0; i < nL; i++) {\n factor = Math.pow(p[i + nL * 2], 2) * 2;\n if (rows === undefined) {\n result += p[i + nL] * Math.exp(-Math.pow(t - p[i], 2) / factor);\n } else {\n for (let j = 0; j < rows; j++) {\n result[j] += p[i + nL] * Math.exp(-Math.pow(t[j] - p[i], 2) / factor);\n }\n }\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { sumOfGaussians } from './sumOfGaussians';\n\n/**\n *\n * @param xy A two column matrix containing the x and y data to be fitted\n * @param group A set of initial lorentzian parameters to be optimized [center, heigth, half_width_at_half_height]\n * @returns {Array} A set of final lorentzian parameters [center, heigth, hwhh*2]\n */\nexport function optimizeGaussianSum(xy, group, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let nL = group.length;\n let pInit = new Float64Array(nL * 3);\n let pMin = new Float64Array(nL * 3);\n let pMax = new Float64Array(nL * 3);\n let dt = Math.abs(t[0] - t[1]);\n\n for (let i = 0; i < nL; i++) {\n pInit[i] = group[i].x;\n pInit[i + nL] = group[i].y / maxY;\n pInit[i + 2 * nL] = group[i].width;\n\n pMin[i] = group[i].x - dt;\n pMin[i + nL] = 0;\n pMin[i + 2 * nL] = group[i].width / 4;\n\n pMax[i] = group[i].x + dt;\n pMax[i + nL] = (group[i].y * 1.2) / maxY;\n pMax[i + 2 * nL] = group[i].width * 4;\n }\n\n let data = {\n x: t,\n y: yData,\n };\n let result = new Array(nL);\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n\n let pFit = LM(data, sumOfGaussians, opts);\n for (let i = 0; i < nL; i++) {\n result[i] = {\n parameters: [\n pFit.parameterValues[i],\n pFit.parameterValues[i + nL] * maxY,\n pFit.parameterValues[i + nL * 2],\n ],\n error: pFit.parameterError,\n };\n }\n return result;\n}\n","/**\n * Single 3 parameter gaussian function\n * @param t Ordinate values\n * @param p Gaussian parameters [mean, height, std]\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\n\nexport function singleGaussian(p) {\n return function (t) {\n let factor2 = (p[2] * p[2]) / 2;\n let rows = t.length;\n if (!rows) return p[1] * Math.exp((-(t - p[0]) * (t - p[0])) / factor2);\n let result = new Float64Array(t.length);\n for (let i = 0; i < t.length; i++) {\n result[i] = p[1] * Math.exp((-(t[i] - p[0]) * (t[i] - p[0])) / factor2);\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { singleGaussian } from './singleGaussian';\n\n/**\n * Fits a set of points to a gaussian bell. Returns the mean of the peak, the std and the height of the signal.\n * @param data,[y]\n * @returns {*[]}\n */\nexport function optimizeSingleGaussian(xy, peak, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let dt = Math.abs(t[0] - t[1]);\n let pInit = new Float64Array([peak.x, 1, peak.width]);\n let pMin = new Float64Array([peak.x - dt, 0, peak.width / 4]);\n let pMax = new Float64Array([peak.x + dt, 1.25, peak.width * 4]);\n\n let data = {\n x: t,\n y: yData,\n };\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n let pFit = LM(data, singleGaussian, opts);\n return {\n parameters: [\n pFit.parameterValues[0],\n pFit.parameterValues[1] * maxY,\n pFit.parameterValues[2],\n ],\n error: pFit.parameterError,\n };\n}\n","/**\n * This function calculates the spectrum as a sum of lorentzian functions. The Lorentzian\n * parameters are divided in 3 batches. 1st: centers; 2nd: heights; 3th: widths;\n * @param t Ordinate values\n * @param p Lorentzian parameters\n * @returns {*}\n */\n\nexport function sumOfLorentzians(p) {\n return function (t) {\n let nL = p.length / 3;\n let factor;\n let p2;\n let rows = t.length;\n let result = rows === undefined ? 0 : new Float64Array(rows).fill(0);\n for (let i = 0; i < nL; i++) {\n p2 = Math.pow(p[i + nL * 2] / 2, 2);\n factor = p[i + nL] * p2;\n if (rows === undefined) {\n result += factor / (Math.pow(t - p[i], 2) + p2);\n } else {\n for (let j = 0; j < rows; j++) {\n result[j] += factor / (Math.pow(t[j] - p[i], 2) + p2);\n }\n }\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { sumOfLorentzians } from './sumOfLorentzians';\n\n/**\n *\n * @param xy A two column matrix containing the x and y data to be fitted\n * @param group A set of initial lorentzian parameters to be optimized [center, heigth, half_width_at_half_height]\n * @returns {Array} A set of final lorentzian parameters [center, heigth, hwhh*2]\n */\nexport function optimizeLorentzianSum(xy, group, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n\n let nL = group.length;\n let pInit = new Float64Array(nL * 3);\n let pMin = new Float64Array(nL * 3);\n let pMax = new Float64Array(nL * 3);\n let dt = Math.abs(t[0] - t[1]);\n\n for (let i = 0; i < nL; i++) {\n pInit[i] = group[i].x;\n pInit[i + nL] = 1;\n pInit[i + 2 * nL] = group[i].width;\n\n pMin[i] = group[i].x - dt;\n pMin[i + nL] = 0;\n pMin[i + 2 * nL] = group[i].width / 4;\n\n pMax[i] = group[i].x + dt;\n pMax[i + nL] = 1.5;\n pMax[i + 2 * nL] = group[i].width * 4;\n }\n\n let data = {\n x: t,\n y: yData,\n };\n\n let result = new Array(nL);\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n\n let pFit = LM(data, sumOfLorentzians, opts);\n for (let i = 0; i < nL; i++) {\n result[i] = {\n parameters: [\n pFit.parameterValues[i],\n pFit.parameterValues[i + nL] * maxY,\n pFit.parameterValues[i + nL * 2],\n ],\n error: pFit.parameterError,\n };\n }\n return result;\n}\n","/**\n * Single 4 parameter lorentzian function\n * @param t Ordinate values\n * @param p Lorentzian parameters\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\n\nexport function singleLorentzian(p) {\n return function (t) {\n let factor = p[1] * Math.pow(p[2] / 2, 2);\n let rows = t.length;\n if (!rows) return factor / (Math.pow(t - p[0], 2) + Math.pow(p[2] / 2, 2));\n let result = new Float64Array(rows);\n for (let i = 0; i < rows; i++) {\n result[i] = factor / (Math.pow(t[i] - p[0], 2) + Math.pow(p[2] / 2, 2));\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { singleLorentzian } from './singleLorentzian';\n\n/**\n * * Fits a set of points to a Lorentzian function. Returns the center of the peak, the width at half height, and the height of the signal.\n * @param data,[y]\n * @returns {*[]}\n */\nexport function optimizeSingleLorentzian(xy, peak, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let dt = Math.abs(t[0] - t[1]);\n let pInit = new Float64Array([peak.x, 1, peak.width]);\n let pMin = new Float64Array([peak.x - dt, 0.75, peak.width / 4]);\n let pMax = new Float64Array([peak.x + dt, 1.25, peak.width * 4]);\n\n let data = {\n x: t,\n y: yData,\n };\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n opts = Object.assign({}, lmOptions, opts);\n let pFit = LM(data, singleLorentzian, opts);\n return {\n parameters: [\n pFit.parameterValues[0],\n pFit.parameterValues[1] * maxY,\n pFit.parameterValues[2],\n ],\n error: pFit.parameterError,\n };\n}\n","import {\n optimizeGaussianSum,\n optimizeLorentzianSum,\n optimizeSingleGaussian,\n optimizeSingleLorentzian,\n} from 'ml-optimize-lorentzian';\n\nexport function optimizePeaks(peakList, x, y, options = {}) {\n const {\n functionName = 'gaussian',\n factorWidth = 4,\n optimizationOptions = {\n damping: 1.5,\n maxIterations: 100,\n errorTolerance: 10e-5,\n },\n } = options;\n\n let lastIndex = [0];\n let groups = groupPeaks(peakList, factorWidth);\n let result = [];\n let factor = 1;\n if (functionName === 'gaussian') {\n factor = 1.17741;\n } // From https://en.wikipedia.org/wiki/Gaussian_function#Properties\n let sampling;\n for (let i = 0; i < groups.length; i++) {\n let peaks = groups[i].group;\n if (peaks.length > 1) {\n // Multiple peaks\n sampling = sampleFunction(\n groups[i].limits[0] - groups[i].limits[1],\n groups[i].limits[0] + groups[i].limits[1],\n x,\n y,\n lastIndex,\n );\n if (sampling[0].length > 5) {\n let optPeaks = [];\n if (functionName === 'gaussian') {\n optPeaks = optimizeGaussianSum(sampling, peaks, optimizationOptions);\n } else {\n if (functionName === 'lorentzian') {\n optPeaks = optimizeLorentzianSum(\n sampling,\n peaks,\n optimizationOptions,\n );\n }\n }\n\n for (let j = 0; j < optPeaks.length; j++) {\n let { parameters } = optPeaks[j];\n result.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2] * factor,\n index: peaks[j].index,\n });\n }\n }\n } else {\n // Single peak\n peaks = peaks[0];\n sampling = sampleFunction(\n peaks.x - factorWidth * peaks.width,\n peaks.x + factorWidth * peaks.width,\n x,\n y,\n lastIndex,\n );\n\n if (sampling[0].length > 5) {\n let fitResult = [];\n if (functionName === 'gaussian') {\n fitResult = optimizeSingleGaussian(\n [sampling[0], sampling[1]],\n peaks,\n optimizationOptions,\n );\n } else {\n if (functionName === 'lorentzian') {\n fitResult = optimizeSingleLorentzian(\n [sampling[0], sampling[1]],\n peaks,\n optimizationOptions,\n );\n }\n }\n\n let { parameters } = fitResult;\n result.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2] * factor,\n index: peaks.index,\n }); // From https://en.wikipedia.org/wiki/Gaussian_function#Properties}\n }\n }\n }\n return result;\n}\n\nfunction sampleFunction(from, to, x, y, lastIndex) {\n let nbPoints = x.length;\n let sampleX = [];\n let sampleY = [];\n let direction = Math.sign(x[1] - x[0]); // Direction of the derivative\n if (direction === -1) {\n lastIndex[0] = x.length - 1;\n }\n\n let delta = Math.abs(to - from) / 2;\n let mid = (from + to) / 2;\n let stop = false;\n let index = lastIndex[0];\n while (!stop && index < nbPoints && index >= 0) {\n if (Math.abs(x[index] - mid) <= delta) {\n sampleX.push(x[index]);\n sampleY.push(y[index]);\n index += direction;\n } else {\n // It is outside the range.\n if (Math.sign(mid - x[index]) === 1) {\n // We'll reach the mid going in the current direction\n index += direction;\n } else {\n // There is not more peaks in the current range\n stop = true;\n }\n }\n }\n lastIndex[0] = index;\n return [sampleX, sampleY];\n}\n\nfunction groupPeaks(peakList, nL) {\n let group = [];\n let groups = [];\n let limits = [peakList[0].x, nL * peakList[0].width];\n let upperLimit, lowerLimit;\n // Merge forward\n for (let i = 0; i < peakList.length; i++) {\n // If the 2 things overlaps\n if (\n Math.abs(peakList[i].x - limits[0]) <\n nL * peakList[i].width + limits[1]\n ) {\n // Add the peak to the group\n group.push(peakList[i]);\n // Update the group limits\n upperLimit = limits[0] + limits[1];\n if (peakList[i].x + nL * peakList[i].width > upperLimit) {\n upperLimit = peakList[i].x + nL * peakList[i].width;\n }\n lowerLimit = limits[0] - limits[1];\n if (peakList[i].x - nL * peakList[i].width < lowerLimit) {\n lowerLimit = peakList[i].x - nL * peakList[i].width;\n }\n limits = [\n (upperLimit + lowerLimit) / 2,\n Math.abs(upperLimit - lowerLimit) / 2,\n ];\n } else {\n groups.push({ limits: limits, group: group });\n // var optmimalPeak = fitSpectrum(group,limits,spectrum);\n group = [peakList[i]];\n limits = [peakList[i].x, nL * peakList[i].width];\n }\n }\n groups.push({ limits: limits, group: group });\n // Merge backward\n for (let i = groups.length - 2; i >= 0; i--) {\n // The groups overlaps\n if (\n Math.abs(groups[i].limits[0] - groups[i + 1].limits[0]) <\n (groups[i].limits[1] + groups[i + 1].limits[1]) / 2\n ) {\n for (let j = 0; j < groups[i + 1].group.length; j++) {\n groups[i].group.push(groups[i + 1].group[j]);\n }\n upperLimit = groups[i].limits[0] + groups[i].limits[1];\n if (groups[i + 1].limits[0] + groups[i + 1].limits[1] > upperLimit) {\n upperLimit = groups[i + 1].limits[0] + groups[i + 1].limits[1];\n }\n lowerLimit = groups[i].limits[0] - groups[i].limits[1];\n if (groups[i + 1].limits[0] - groups[i + 1].limits[1] < lowerLimit) {\n lowerLimit = groups[i + 1].limits[0] - groups[i + 1].limits[1];\n }\n\n groups[i].limits = [\n (upperLimit + lowerLimit) / 2,\n Math.abs(upperLimit - lowerLimit) / 2,\n ];\n\n groups.splice(i + 1, 1);\n }\n }\n return groups;\n}\n","import { optimizeSingleLorentzian } from 'ml-optimize-lorentzian';\n\n/**\n * This function try to join the peaks that seems to belong to a broad signal in a single broad peak.\n * @param peakList\n * @param options\n */\nexport function joinBroadPeaks(peakList, options = {}) {\n let width = options.width;\n let broadLines = [];\n // Optimize the possible broad lines\n let max = 0;\n\n let maxI = 0;\n\n let count = 1;\n for (let i = peakList.length - 1; i >= 0; i--) {\n if (peakList[i].soft) {\n broadLines.push(peakList.splice(i, 1)[0]);\n }\n }\n // Push a feke peak\n broadLines.push({ x: Number.MAX_VALUE });\n\n let candidates = [[broadLines[0].x, broadLines[0].y]];\n let indexes = [broadLines[0].index];\n\n for (let i = 1; i < broadLines.length; i++) {\n // console.log(broadLines[i-1].x+\" \"+broadLines[i].x);\n if (Math.abs(broadLines[i - 1].x - broadLines[i].x) < width) {\n candidates.push([broadLines[i].x, broadLines[i].y]);\n if (broadLines[i].y > max) {\n max = broadLines[i].y;\n maxI = i;\n }\n indexes.push(broadLines[i].index);\n count++;\n } else {\n if (count > 2) {\n let fitted = optimizeSingleLorentzian(candidates, {\n x: broadLines[maxI].x,\n y: max,\n width: Math.abs(\n candidates[0][0] - candidates[candidates.length - 1][0],\n ),\n });\n let { parameters } = fitted;\n peakList.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2],\n index: Math.floor(\n indexes.reduce((a, b) => a + b, 0) / indexes.length,\n ),\n soft: false,\n });\n } else {\n // Put back the candidates to the signals list\n indexes.forEach((index) => {\n peakList.push(broadLines[index]);\n });\n }\n candidates = [[broadLines[i].x, broadLines[i].y]];\n indexes = [i];\n max = broadLines[i].y;\n maxI = i;\n count = 1;\n }\n }\n\n peakList.sort(function (a, b) {\n return a.x - b.x;\n });\n\n return peakList;\n}\n","/**\n * This method will allow to enlarge peaks and prevent overlap between peaks\n * Because peaks may not be symmetric after we add 2 properties, from and to.\n * @param {Array} peakList\n * @param {object} [options={}]\n * @param {number} [factor=2]\n * @param {boolean} [overlap=false] by default we don't allow overlap\n * @return {Array} peakList\n */\nexport function broadenPeaks(peakList, options = {}) {\n const { factor = 2, overlap = false } = options;\n\n for (let peak of peakList) {\n if (!peak.right || !peak.left) {\n peak.from = peak.x - (peak.width / 2) * factor;\n peak.to = peak.x + (peak.width / 2) * factor;\n } else {\n peak.from = peak.x - (peak.x - peak.left.x) * factor;\n peak.to = peak.x + (peak.right.x - peak.x) * factor;\n }\n }\n\n if (!overlap) {\n for (let i = 0; i < peakList.length - 1; i++) {\n let peak = peakList[i];\n let nextPeak = peakList[i + 1];\n if (peak.to > nextPeak.from) {\n peak.to = nextPeak.from = (peak.to + nextPeak.from) / 2;\n }\n }\n }\n\n for (let peak of peakList) {\n peak.width = peak.to - peak.from;\n }\n\n return peakList;\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction min(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var minValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\n\nfunction mode(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var maxValue = 0;\n var maxCount = 0;\n var count = 0;\n var counts = {};\n\n for (var i = 0; i < input.length; ++i) {\n var element = input[i];\n count = counts[element];\n\n if (count) {\n counts[element]++;\n count++;\n } else {\n counts[element] = count = 1;\n }\n\n if (count > maxCount) {\n maxCount = count;\n maxValue = input[i];\n }\n }\n\n return maxValue;\n}\n\nexport default mode;\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\nimport max from 'ml-array-max';\nimport sum from 'ml-array-sum';\n\nfunction norm(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var _options$algorithm = options.algorithm,\n algorithm = _options$algorithm === void 0 ? 'absolute' : _options$algorithm,\n _options$sumValue = options.sumValue,\n sumValue = _options$sumValue === void 0 ? 1 : _options$sumValue,\n _options$maxValue = options.maxValue,\n maxValue = _options$maxValue === void 0 ? 1 : _options$maxValue;\n\n if (!isArray(input)) {\n throw new Error('input must be an array');\n }\n\n var output;\n\n if (options.output !== undefined) {\n if (!isArray(options.output)) {\n throw new TypeError('output option must be an array if specified');\n }\n\n output = options.output;\n } else {\n output = new Array(input.length);\n }\n\n if (input.length === 0) {\n throw new Error('input must not be empty');\n }\n\n switch (algorithm.toLowerCase()) {\n case 'absolute':\n {\n var absoluteSumValue = absoluteSum(input) / sumValue;\n if (absoluteSumValue === 0) return input.slice(0);\n\n for (var i = 0; i < input.length; i++) {\n output[i] = input[i] / absoluteSumValue;\n }\n\n return output;\n }\n\n case 'max':\n {\n var currentMaxValue = max(input);\n if (currentMaxValue === 0) return input.slice(0);\n var factor = maxValue / currentMaxValue;\n\n for (var _i = 0; _i < input.length; _i++) {\n output[_i] = input[_i] * factor;\n }\n\n return output;\n }\n\n case 'sum':\n {\n var sumFactor = sum(input) / sumValue;\n if (sumFactor === 0) return input.slice(0);\n\n for (var _i2 = 0; _i2 < input.length; _i2++) {\n output[_i2] = input[_i2] / sumFactor;\n }\n\n return output;\n }\n\n default:\n throw new Error(\"norm: unknown algorithm: \".concat(algorithm));\n }\n}\n\nfunction absoluteSum(input) {\n var sumValue = 0;\n\n for (var i = 0; i < input.length; i++) {\n sumValue += Math.abs(input[i]);\n }\n\n return sumValue;\n}\n\nexport default norm;\n","import isArray from 'is-any-array';\n\nfunction _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n _typeof = function (obj) {\n return typeof obj;\n };\n } else {\n _typeof = function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n }\n\n return _typeof(obj);\n}\n\n/**\r\n * Fill an array with sequential numbers\r\n * @param {Array} [input] - optional destination array (if not provided a new array will be created)\r\n * @param {object} [options={}]\r\n * @param {number} [options.from=0] - first value in the array\r\n * @param {number} [options.to=10] - last value in the array\r\n * @param {number} [options.size=input.length] - size of the array (if not provided calculated from step)\r\n * @param {number} [options.step] - if not provided calculated from size\r\n * @return {Array}\r\n */\n\nfunction sequentialFill() {\n var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (_typeof(input) === 'object' && !isArray(input)) {\n options = input;\n input = [];\n }\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n var _options = options,\n _options$from = _options.from,\n from = _options$from === void 0 ? 0 : _options$from,\n _options$to = _options.to,\n to = _options$to === void 0 ? 10 : _options$to,\n _options$size = _options.size,\n size = _options$size === void 0 ? input.length : _options$size,\n step = _options.step;\n\n if (size !== 0 && step) {\n throw new Error('step is defined by the array size');\n }\n\n if (!size) {\n if (step) {\n size = Math.floor((to - from) / step) + 1;\n } else {\n size = to - from + 1;\n }\n }\n\n if (!step && size) {\n step = (to - from) / (size - 1);\n }\n\n if (Array.isArray(input)) {\n // only works with normal array\n input.length = 0;\n\n for (var i = 0; i < size; i++) {\n input.push(from);\n from += step;\n }\n } else {\n if (input.length !== size) {\n throw new Error('sequentialFill typed array must have the correct length');\n }\n\n for (var _i = 0; _i < size; _i++) {\n input[_i] = from;\n from += step;\n }\n }\n\n return input;\n}\n\nexport default sequentialFill;\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\nimport arrayMean from 'ml-array-mean';\n\nfunction variance(values) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(values)) {\n throw new TypeError('input must be an array');\n }\n\n var _options$unbiased = options.unbiased,\n unbiased = _options$unbiased === void 0 ? true : _options$unbiased,\n _options$mean = options.mean,\n mean = _options$mean === void 0 ? arrayMean(values) : _options$mean;\n var sqrError = 0;\n\n for (var i = 0; i < values.length; i++) {\n var x = values[i] - mean;\n sqrError += x * x;\n }\n\n if (unbiased) {\n return sqrError / (values.length - 1);\n } else {\n return sqrError / values.length;\n }\n}\n\nexport default variance;\n","import variance from 'ml-array-variance';\n\nfunction standardDeviation(values) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return Math.sqrt(variance(values, options));\n}\n\nexport default standardDeviation;\n","/**\n * Merge abscissa values if the ordinate value is in a list of centroids\n * @param {object} originalPoints\n * @param {Array} originalPoints.x\n * @param {Array} originalPoints.y\n * @param {Array} centroids\n * @param {object} [options]\n * @param {number} [options.window = 0.01] - has to be a positive number\n * @return {{x: Array, y: Array}}\n */\nexport default function mergeByCentroids(\n originalPoints,\n centroids,\n options = {}\n) {\n const { window = 0.01 } = options;\n\n var mergedPoints = {\n x: centroids.slice(),\n y: new Array(centroids.length).fill(0)\n };\n\n var originalIndex = 0;\n var mergedIndex = 0;\n while (\n originalIndex < originalPoints.x.length &&\n mergedIndex < centroids.length\n ) {\n var diff = originalPoints.x[originalIndex] - centroids[mergedIndex];\n if (Math.abs(diff) < window) {\n mergedPoints.y[mergedIndex] += originalPoints.y[originalIndex++];\n } else if (diff < 0) {\n originalIndex++;\n } else {\n mergedIndex++;\n }\n }\n\n return mergedPoints;\n}\n","import binarySearch from 'binary-search';\nimport { ascending, descending } from 'num-sort';\n\n/**\n *\n * @param {object} points\n * @param {Array} originalPoints.x\n * @param {Array} originalPoints.y\n * @param {*} options\n * @return {{x: Array, y: Array}}\n */\nexport default function closestX(points, options) {\n const { x, y } = points;\n const { target = x[0], reverse = false } = options;\n\n let index;\n if (reverse) {\n index = binarySearch(x, target, descending);\n } else {\n index = binarySearch(x, target, ascending);\n }\n\n if (index >= 0) {\n return {\n x: x[index],\n y: y[index]\n };\n } else {\n index = ~index;\n if (\n (index !== 0 && Math.abs(x[index] - target) > 0.5) ||\n index === x.length\n ) {\n return {\n x: x[index - 1],\n y: y[index - 1]\n };\n } else {\n return {\n x: x[index],\n y: y[index]\n };\n }\n }\n}\n","import mean from 'ml-array-mean';\n\n/**\n *\n * @param {object} points\n * @param {Array} points.x\n * @param {Array} points.y\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @return {number}\n */\nexport default function covariance(points, options = {}) {\n const { x, y } = points;\n const { unbiased = true } = options;\n\n const meanX = mean(x);\n const meanY = mean(y);\n\n var error = 0;\n\n for (let i = 0; i < x.length; i++) {\n error += (x[i] - meanX) * (y[i] - meanY);\n }\n\n if (unbiased) {\n return error / (x.length - 1);\n } else {\n return error / x.length;\n }\n}\n","/**\n * Merge abscissas values on similar ordinates and weight the group of abscissas\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {number} [options.groupWidth = 0.001] - window for abscissas to merge\n * @return {{x: Array, y: Array}}\n */\nexport default function maxMerge(points, options = {}) {\n const { x, y } = points;\n const { groupWidth = 0.001 } = options;\n\n var merged = { x: [], y: [] };\n var maxAbscissa = { x: [], y: [] };\n var size = 0;\n var index = 0;\n\n while (index < x.length) {\n if (size === 0 || x[index] - merged.x[size - 1] > groupWidth) {\n maxAbscissa.x.push(x[index]);\n maxAbscissa.y.push(y[index]);\n merged.x.push(x[index]);\n merged.y.push(y[index]);\n index++;\n size++;\n } else {\n if (y[index] > maxAbscissa.y[size - 1]) {\n maxAbscissa.x[size - 1] = x[index];\n maxAbscissa.y[size - 1] = y[index];\n }\n merged.x[size - 1] = x[index];\n merged.y[size - 1] += y[index];\n index++;\n }\n }\n\n merged.x = maxAbscissa.x.slice();\n\n return merged;\n}\n","import binarySearch from 'binary-search';\nimport { ascending, descending } from 'num-sort';\n\n/**\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {object} [options.from = {index: 0}]\n * @param {object} [options.to = {index: x.length-1}]\n * @param {boolean} [options.reverse = false]\n * @return {{index: number, value: number}}\n */\nexport default function maxY(points, options = {}) {\n const { x, y } = points;\n let {\n from = { index: 0 },\n to = { index: x.length },\n reverse = false\n } = options;\n\n if (from.value !== undefined && from.index === undefined) {\n from.index = calculateIndex(from.value, x, reverse);\n }\n\n if (to.value !== undefined && to.index === undefined) {\n to.index = calculateIndex(to.value, x, reverse);\n }\n\n var currentMax = Number.MIN_VALUE;\n var currentIndex;\n for (var i = from.index; i < to.index; i++) {\n if (currentMax < y[i]) {\n currentMax = y[i];\n currentIndex = i;\n }\n }\n\n return {\n index: currentIndex,\n value: currentMax\n };\n}\n\n/**\n * @param {number} value\n * @param {Array} x\n * @param {boolean} reverse\n * @return {number} index of the value in the array\n */\nfunction calculateIndex(value, x, reverse) {\n let index;\n if (reverse) {\n index = binarySearch(x, value, descending);\n } else {\n index = binarySearch(x, value, ascending);\n }\n\n if (index < 0) {\n throw new Error(`the value ${value} doesn't belongs to the abscissa value`);\n }\n\n return index;\n}\n","export default function sortX(points, options = {}) {\n const { x, y } = points;\n const { reverse = false } = options;\n\n var sortFunc;\n if (!reverse) {\n sortFunc = (a, b) => a.x - b.x;\n } else {\n sortFunc = (a, b) => b.x - a.x;\n }\n\n var grouped = x\n .map((val, index) => ({\n x: val,\n y: y[index]\n }))\n .sort(sortFunc);\n\n var response = { x: x.slice(), y: y.slice() };\n for (var i = 0; i < x.length; i++) {\n response.x[i] = grouped[i].x;\n response.y[i] = grouped[i].y;\n }\n\n return response;\n}\n","\n/**\n * In place modification of the 2 arrays to make X unique and sum the Y if X has the same value\n * @param {object} [points={}] : Object of points contains property x (an array) and y (an array)\n * @return points\n */\n\nexport default function uniqueX(points = {}) {\n const { x, y } = points;\n if (x.length < 2) return;\n if (x.length !== y.length) {\n throw new Error('The X and Y arrays mush have the same length');\n }\n\n let current = x[0];\n let counter = 0;\n\n for (let i = 1; i < x.length; i++) {\n if (current !== x[i]) {\n counter++;\n current = x[i];\n x[counter] = x[i];\n if (i !== counter) {\n y[counter] = 0;\n }\n }\n if (i !== counter) {\n y[counter] += y[i];\n }\n }\n\n x.length = counter + 1;\n y.length = counter + 1;\n}\n","/**\n * Merge abscissas values on similar ordinates and weight the group of abscissas\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {number} [options.groupWidth = 0.001] - window for abscissas to merge\n * @return {{x: Array, y: Array}}\n */\nexport default function weightedMerge(points, options = {}) {\n const { x, y } = points;\n const { groupWidth = 0.001 } = options;\n\n var merged = { x: [], y: [] };\n var weightedAbscissa = { x: [], y: [] };\n var size = 0;\n var index = 0;\n\n while (index < x.length) {\n if (size === 0 || x[index] - merged.x[size - 1] > groupWidth) {\n weightedAbscissa.x.push(x[index] * y[index]);\n weightedAbscissa.y.push(y[index]);\n merged.x.push(x[index]);\n merged.y.push(y[index]);\n index++;\n size++;\n } else {\n weightedAbscissa.x[size - 1] += x[index] * y[index];\n weightedAbscissa.y[size - 1] += y[index];\n merged.x[size - 1] = x[index];\n merged.y[size - 1] += y[index];\n index++;\n }\n }\n\n for (var i = 0; i < merged.x.length; i++) {\n merged.x[i] = weightedAbscissa.x[i] / weightedAbscissa.y[i];\n }\n\n return merged;\n}\n","/**\n * Normalize an array of zones:\n * - ensure than from < to\n * - merge overlapping zones\n *\n * The method will always check if from if lower than to and will swap if required.\n * @param {Array} [zones=[]]\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of a zone\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of a zone\n */\n\nexport function normalize(zones = [], options = {}) {\n if (zones.length === 0) return [];\n let {\n from = Number.NEGATIVE_INFINITY,\n to = Number.POSITIVE_INFINITY,\n } = options;\n if (from > to) [from, to] = [to, from];\n\n zones = JSON.parse(JSON.stringify(zones)).map((zone) =>\n zone.from > zone.to ? { from: zone.to, to: zone.from } : zone,\n );\n zones = zones.sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return a.to - b.to;\n });\n\n zones.forEach((zone) => {\n if (from > zone.from) zone.from = from;\n if (to < zone.to) zone.to = to;\n });\n\n zones = zones.filter((zone) => zone.from <= zone.to);\n if (zones.length === 0) return [];\n\n let currentZone = zones[0];\n let result = [currentZone];\n for (let i = 1; i < zones.length; i++) {\n let zone = zones[i];\n if (zone.from <= currentZone.to) {\n currentZone.to = zone.to;\n } else {\n currentZone = zone;\n result.push(currentZone);\n }\n }\n return result;\n}\n","import { normalize } from './normalize';\n\n/**\n * Convert an array of exclusions and keep only from / to\n *\n * The method will always check if from if lower than to and will swap if required.\n * @param {Array} [exclusions=[]]\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of zones (after inversion)\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of zones (after inversion)\n */\n\nexport function invert(exclusions = [], options = {}) {\n let {\n from = Number.NEGATIVE_INFINITY,\n to = Number.POSITIVE_INFINITY,\n } = options;\n if (from > to) [from, to] = [to, from];\n\n exclusions = normalize(exclusions, { from, to });\n if (exclusions.length === 0) return [{ from, to }];\n\n let zones = [];\n for (let i = 0; i < exclusions.length; i++) {\n let exclusion = exclusions[i];\n let nextExclusion = exclusions[i + 1];\n if (i === 0) {\n if (exclusion.from > from) {\n zones.push({ from, to: exclusion.from });\n }\n }\n if (i === exclusions.length - 1) {\n if (exclusion.to < to) {\n zones.push({ from: exclusion.to, to });\n }\n } else {\n zones.push({ from: exclusion.to, to: nextExclusion.from });\n }\n }\n\n return zones;\n}\n","import { normalize } from './normalize';\n\n/**\n * Add the number of points per zone to reach a specified total\n * @param {Array} [zones=[]]\n * @param {number} [numberOfPoints] Total number of points to distribute between zones\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of a zone\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of a zone\n */\n\nexport function zonesWithPoints(zones, numberOfPoints, options = {}) {\n if (zones.length === 0) return zones;\n zones = normalize(zones, options);\n\n const totalSize = zones.reduce((previous, current) => {\n return previous + (current.to - current.from);\n }, 0);\n\n let unitsPerPoint = totalSize / numberOfPoints;\n let currentTotal = 0;\n for (let i = 0; i < zones.length - 1; i++) {\n let zone = zones[i];\n zone.numberOfPoints = Math.min(\n Math.round((zone.to - zone.from) / unitsPerPoint),\n numberOfPoints - currentTotal,\n );\n currentTotal += zone.numberOfPoints;\n }\n\n zones[zones.length - 1].numberOfPoints = numberOfPoints - currentTotal;\n\n return zones;\n}\n","/**\n * Function that calculates the integral of the line between two\n * x-coordinates, given the slope and intercept of the line.\n * @param {number} x0\n * @param {number} x1\n * @param {number} slope\n * @param {number} intercept\n * @return {number} integral value.\n */\nexport default function integral(x0, x1, slope, intercept) {\n return (\n 0.5 * slope * x1 * x1 +\n intercept * x1 -\n (0.5 * slope * x0 * x0 + intercept * x0)\n );\n}\n","import integral from './integral';\n\n/**\n * function that retrieves the getEquallySpacedData with the variant \"smooth\"\n *\n * @param {Array} x\n * @param {Array} y\n * @param {number} from - Initial point\n * @param {number} to - Final point\n * @param {number} numberOfPoints\n * @return {Array} - Array of y's equally spaced with the variant \"smooth\"\n */\nexport default function equallySpacedSmooth(x, y, from, to, numberOfPoints) {\n let xLength = x.length;\n\n let step = (to - from) / (numberOfPoints - 1);\n let halfStep = step / 2;\n\n let output = new Array(numberOfPoints);\n\n let initialOriginalStep = x[1] - x[0];\n let lastOriginalStep = x[xLength - 1] - x[xLength - 2];\n\n // Init main variables\n let min = from - halfStep;\n let max = from + halfStep;\n\n let previousX = Number.MIN_VALUE;\n let previousY = 0;\n let nextX = x[0] - initialOriginalStep;\n let nextY = 0;\n\n let currentValue = 0;\n let slope = 0;\n let intercept = 0;\n let sumAtMin = 0;\n let sumAtMax = 0;\n\n let i = 0; // index of input\n let j = 0; // index of output\n\n function getSlope(x0, y0, x1, y1) {\n return (y1 - y0) / (x1 - x0);\n }\n\n let add = 0;\n main: while (true) {\n if (previousX <= min && min <= nextX) {\n add = integral(0, min - previousX, slope, previousY);\n sumAtMin = currentValue + add;\n }\n\n while (nextX - max >= 0) {\n // no overlap with original point, just consume current value\n add = integral(0, max - previousX, slope, previousY);\n sumAtMax = currentValue + add;\n\n output[j++] = (sumAtMax - sumAtMin) / step;\n\n if (j === numberOfPoints) {\n break main;\n }\n\n min = max;\n max += step;\n sumAtMin = sumAtMax;\n }\n\n currentValue += integral(previousX, nextX, slope, intercept);\n\n previousX = nextX;\n previousY = nextY;\n\n if (i < xLength) {\n nextX = x[i];\n nextY = y[i];\n i++;\n } else if (i === xLength) {\n nextX += lastOriginalStep;\n nextY = 0;\n }\n\n slope = getSlope(previousX, previousY, nextX, nextY);\n intercept = -slope * previousX + previousY;\n }\n\n return output;\n}\n","/**\n * function that retrieves the getEquallySpacedData with the variant \"slot\"\n *\n * @param {Array} x\n * @param {Array} y\n * @param {number} from - Initial point\n * @param {number} to - Final point\n * @param {number} numberOfPoints\n * @return {Array} - Array of y's equally spaced with the variant \"slot\"\n */\nexport default function equallySpacedSlot(x, y, from, to, numberOfPoints) {\n let xLength = x.length;\n\n let step = (to - from) / (numberOfPoints - 1);\n let halfStep = step / 2;\n let lastStep = x[x.length - 1] - x[x.length - 2];\n\n let start = from - halfStep;\n let output = new Array(numberOfPoints);\n\n // Init main variables\n let min = start;\n let max = start + step;\n\n let previousX = -Number.MAX_VALUE;\n let previousY = 0;\n let nextX = x[0];\n let nextY = y[0];\n let frontOutsideSpectra = 0;\n let backOutsideSpectra = true;\n\n let currentValue = 0;\n\n // for slot algorithm\n let currentPoints = 0;\n\n let i = 1; // index of input\n let j = 0; // index of output\n\n main: while (true) {\n if (previousX >= nextX) throw new Error('x must be an increasing serie');\n while (previousX - max > 0) {\n // no overlap with original point, just consume current value\n if (backOutsideSpectra) {\n currentPoints++;\n backOutsideSpectra = false;\n }\n\n output[j] = currentPoints <= 0 ? 0 : currentValue / currentPoints;\n j++;\n\n if (j === numberOfPoints) {\n break main;\n }\n\n min = max;\n max += step;\n currentValue = 0;\n currentPoints = 0;\n }\n\n if (previousX > min) {\n currentValue += previousY;\n currentPoints++;\n }\n\n if (previousX === -Number.MAX_VALUE || frontOutsideSpectra > 1) {\n currentPoints--;\n }\n\n previousX = nextX;\n previousY = nextY;\n\n if (i < xLength) {\n nextX = x[i];\n nextY = y[i];\n i++;\n } else {\n nextX += lastStep;\n nextY = 0;\n frontOutsideSpectra++;\n }\n }\n\n return output;\n}\n","import sequentialFill from 'ml-array-sequential-fill';\nimport { zonesWithPoints, invert } from 'ml-zones';\n\nimport equallySpacedSmooth from './equallySpacedSmooth';\nimport equallySpacedSlot from './equallySpacedSlot';\n\n/**\n * Function that returns a Number array of equally spaced numberOfPoints\n * containing a representation of intensities of the spectra arguments x\n * and y.\n *\n * The options parameter contains an object in the following form:\n * from: starting point\n * to: last point\n * numberOfPoints: number of points between from and to\n * variant: \"slot\" or \"smooth\" - smooth is the default option\n *\n * The slot variant consist that each point in the new array is calculated\n * averaging the existing points between the slot that belongs to the current\n * value. The smooth variant is the same but takes the integral of the range\n * of the slot and divide by the step size between two points in the new array.\n *\n * If exclusions zone are present, zones are ignored !\n * @param {object} [arrayXY={}] - object containing 2 properties x and y (both an array)\n * @param {object} [options={}]\n * @param {number} [options.from=x[0]]\n * @param {number} [options.to=x[x.length-1]]\n * @param {string} [options.variant='smooth']\n * @param {number} [options.numberOfPoints=100]\n * @param {Array} [options.exclusions=[]] array of from / to that should be skipped for the generation of the points\n * @param {Array} [options.zones=[]] array of from / to that should be kept\n * @return {object} new object with x / y array with the equally spaced data.\n */\n\nexport default function equallySpaced(arrayXY = {}, options = {}) {\n let { x, y } = arrayXY;\n let xLength = x.length;\n let reverse = false;\n if (x.length > 1 && x[0] > x[1]) {\n x = x.slice().reverse();\n y = y.slice().reverse();\n reverse = true;\n }\n\n let {\n from = x[0],\n to = x[xLength - 1],\n variant = 'smooth',\n numberOfPoints = 100,\n exclusions = [],\n zones = [],\n } = options;\n\n if (xLength !== y.length) {\n throw new RangeError(\"the x and y vector doesn't have the same size.\");\n }\n\n if (typeof from !== 'number' || isNaN(from)) {\n throw new RangeError(\"'from' option must be a number\");\n }\n\n if (typeof to !== 'number' || isNaN(to)) {\n throw new RangeError(\"'to' option must be a number\");\n }\n\n if (typeof numberOfPoints !== 'number' || isNaN(numberOfPoints)) {\n throw new RangeError(\"'numberOfPoints' option must be a number\");\n }\n\n if (numberOfPoints < 2) {\n throw new RangeError(\"'numberOfPoints' option must be greater than 1\");\n }\n\n if (zones.length === 0) {\n zones = invert(exclusions, { from, to });\n }\n\n zones = zonesWithPoints(zones, numberOfPoints, { from, to });\n\n let xResult = [];\n let yResult = [];\n for (let zone of zones) {\n let zoneResult = processZone(\n x,\n y,\n zone.from,\n zone.to,\n zone.numberOfPoints,\n variant,\n reverse,\n );\n\n xResult = xResult.concat(zoneResult.x);\n yResult = yResult.concat(zoneResult.y);\n }\n if (reverse) {\n if (from < to) {\n return { x: xResult.reverse(), y: yResult.reverse() };\n } else {\n return { x: xResult, y: yResult };\n }\n } else {\n if (from < to) {\n return { x: xResult, y: yResult };\n } else {\n return { x: xResult.reverse(), y: yResult.reverse() };\n }\n }\n}\n\nfunction processZone(x, y, from, to, numberOfPoints, variant) {\n if (numberOfPoints < 1) {\n throw new RangeError('the number of points must be at least 1');\n }\n\n let output =\n variant === 'slot'\n ? equallySpacedSlot(x, y, from, to, numberOfPoints)\n : equallySpacedSmooth(x, y, from, to, numberOfPoints);\n\n return {\n x: sequentialFill({\n from,\n to,\n size: numberOfPoints,\n }),\n y: output,\n };\n}\n","export default function getZones(from, to, exclusions = []) {\n if (from > to) {\n [from, to] = [to, from];\n }\n\n // in exclusions from and to have to be defined\n exclusions = exclusions.filter(\n (exclusion) => exclusion.from !== undefined && exclusion.to !== undefined\n );\n\n exclusions = JSON.parse(JSON.stringify(exclusions));\n // we ensure that from before to\n exclusions.forEach((exclusion) => {\n if (exclusion.from > exclusion.to) {\n [exclusion.to, exclusion.from] = [exclusion.from, exclusion.to];\n }\n });\n\n exclusions.sort((a, b) => a.from - b.from);\n\n // we will rework the exclusions in order to remove overlap and outside range (from / to)\n exclusions.forEach((exclusion) => {\n if (exclusion.from < from) exclusion.from = from;\n if (exclusion.to > to) exclusion.to = to;\n });\n for (let i = 0; i < exclusions.length - 1; i++) {\n if (exclusions[i].to > exclusions[i + 1].from) {\n exclusions[i].to = exclusions[i + 1].from;\n }\n }\n exclusions = exclusions.filter((exclusion) => exclusion.from < exclusion.to);\n\n if (!exclusions || exclusions.length === 0) {\n return [{ from, to }];\n }\n\n let zones = [];\n let currentFrom = from;\n for (let exclusion of exclusions) {\n if (currentFrom < exclusion.from) {\n zones.push({\n from: currentFrom,\n to: exclusion.from\n });\n }\n\n currentFrom = exclusion.to;\n }\n if (currentFrom < to) {\n zones.push({\n from: currentFrom,\n to: to\n });\n }\n\n return zones;\n}\n","import getZones from './getZones';\n\n/**\n * Filter an array x/y based on various criteria\n * x points are expected to be sorted\n *\n * @param {object} points\n * @param {object} [options={}]\n * @param {array} [options.from]\n * @param {array} [options.to]\n * @param {array} [options.exclusions=[]]\n * @return {{x: Array, y: Array}}\n */\n\nexport default function filterX(points, options = {}) {\n const { x, y } = points;\n const { from = x[0], to = x[x.length - 1], exclusions = [] } = options;\n\n let zones = getZones(from, to, exclusions);\n\n\n let currentZoneIndex = 0;\n let newX = [];\n let newY = [];\n let position = 0;\n while (position < x.length) {\n if (\n x[position] <= zones[currentZoneIndex].to &&\n x[position] >= zones[currentZoneIndex].from\n ) {\n newX.push(x[position]);\n newY.push(y[position]);\n } else {\n if (x[position] > zones[currentZoneIndex].to) {\n currentZoneIndex++;\n if (!zones[currentZoneIndex]) break;\n }\n }\n position++;\n }\n\n return {\n x: newX,\n y: newY\n };\n}\n","import { DecisionTreeClassifier, DecisionTreeRegression } from \"ml-cart\";\nimport {\n RandomForestClassifier,\n RandomForestRegression\n} from \"ml-random-forest\";\n\n// Try to keep this list in the same structure as the README.\n\n// Unsupervised learning\nexport { PCA } from \"ml-pca\";\nimport * as HClust from \"ml-hclust\";\nexport { HClust };\nexport { default as KMeans } from \"ml-kmeans\";\n\n// Supervised learning\nimport * as NaiveBayes from \"ml-naivebayes\";\nexport { NaiveBayes };\nexport { default as KNN } from \"ml-knn\";\nexport { PLS, KOPLS, OPLS, OPLSNipals } from \"ml-pls\";\nimport * as CrossValidation from \"ml-cross-validation\";\nexport { CrossValidation };\nexport { default as ConfusionMatrix } from \"ml-confusion-matrix\";\nexport { DecisionTreeClassifier };\nexport { RandomForestClassifier };\n\n// Artificial neural networks\nexport { default as FNN } from \"ml-fnn\";\nexport { default as SOM } from \"ml-som\";\n\n// Regression\nexport {\n SimpleLinearRegression,\n PolynomialRegression,\n MultivariateLinearRegression,\n PowerRegression,\n ExponentialRegression,\n TheilSenRegression,\n RobustPolynomialRegression\n} from \"ml-regression\";\nexport { DecisionTreeRegression };\nexport { RandomForestRegression };\n\n// Optimization\nexport { default as levenbergMarquardt } from \"ml-levenberg-marquardt\";\nimport * as FCNNLS from \"ml-fcnnls\";\nexport { FCNNLS };\n\n// Math\nimport * as MatrixLib from \"ml-matrix\";\nconst {\n Matrix,\n SVD,\n EVD,\n CholeskyDecomposition,\n LuDecomposition,\n QrDecomposition\n} = MatrixLib;\nexport {\n MatrixLib,\n Matrix,\n SVD,\n EVD,\n CholeskyDecomposition,\n LuDecomposition,\n QrDecomposition\n};\n\nexport { SparseMatrix } from \"ml-sparse-matrix\";\nexport { default as Kernel } from \"ml-kernel\";\nimport { distance, similarity } from \"ml-distance\";\nexport { distance as Distance, similarity as Similarity };\nexport { default as distanceMatrix } from \"ml-distance-matrix\";\nexport { default as XSadd } from \"ml-xsadd\";\n\n// Statistics\nexport { default as Performance } from \"ml-performance\";\n\n// Data preprocessing\nexport { default as savitzkyGolay } from \"ml-savitzky-golay\";\n\n// Utility\nexport { default as BitArray } from \"ml-bit-array\";\nexport { default as HashTable } from \"ml-hash-table\";\nexport { default as padArray } from \"ml-pad-array\";\nexport { default as binarySearch } from \"binary-search\";\nimport * as numSort from \"num-sort\";\nexport { numSort };\nexport { default as Random } from \"ml-random\";\nimport * as GSD from 'ml-gsd';\nexport { GSD };\n\nimport min from \"ml-array-min\";\nimport max from \"ml-array-max\";\nimport median from \"ml-array-median\";\nimport mean from \"ml-array-mean\";\nimport mode from \"ml-array-mode\";\nimport normed from \"ml-array-normed\";\nimport rescale from \"ml-array-rescale\";\nimport sequentialFill from \"ml-array-sequential-fill\";\nimport sum from \"ml-array-sum\";\nimport standardDeviation from \"ml-array-standard-deviation\";\nimport variance from \"ml-array-variance\";\nexport const Array = {\n min,\n max,\n median,\n mean,\n mode,\n normed,\n rescale,\n sequentialFill,\n standardDeviation,\n sum,\n variance\n};\n\nimport centroidsMerge from \"ml-array-xy-centroids-merge\";\nimport closestX from \"ml-arrayxy-closestx\";\nimport covariance from \"ml-array-xy-covariance\";\nimport maxMerge from \"ml-array-xy-max-merge\";\nimport maxY from \"ml-array-xy-max-y\";\nimport sortX from \"ml-array-xy-sort-x\";\nimport uniqueX from \"ml-arrayxy-uniquex\";\nimport weightedMerge from \"ml-array-xy-weighted-merge\";\nimport equallySpaced from \"ml-array-xy-equally-spaced\";\nimport filterX from \"ml-array-xy-filter-x\";\nexport const ArrayXY = {\n centroidsMerge,\n closestX,\n covariance,\n maxMerge,\n maxY,\n sortX,\n uniqueX,\n weightedMerge,\n equallySpaced,\n filterX\n};\n"],"names":["toString","Object","prototype","isAnyArray","object","call","endsWith","max","input","options","arguments","length","undefined","isArray","TypeError","_options$fromIndex","fromIndex","_options$toIndex","toIndex","Number","isInteger","Error","maxValue","i","min","minValue","rescale","output","Array","currentMin","currentMax","RangeError","_options$min","autoMinMax","_options$max","factor","indent","repeat","indentData","inspectMatrix","inspectMatrixWithOptions","matrix","maxRows","maxColumns","maxNumSize","constructor","name","inspectData","rows","columns","maxI","Math","maxJ","result","line","j","push","formatNumber","get","join","num","numStr","String","padEnd","precise","toPrecision","exponential","toExponential","eIndex","indexOf","e","slice","installMathOperations","AbstractMatrix","Matrix","add","value","addS","addM","set","checkMatrix","newMatrix","sub","subS","subM","subtract","subtractS","subtractM","mul","mulS","mulM","multiply","multiplyS","multiplyM","div","divS","divM","divide","divideS","divideM","mod","modS","modM","modulus","modulusS","modulusM","and","andS","andM","or","orS","orM","xor","xorS","xorM","leftShift","leftShiftS","leftShiftM","signPropagatingRightShift","signPropagatingRightShiftS","signPropagatingRightShiftM","rightShift","rightShiftS","rightShiftM","zeroFillRightShift","zeroFillRightShiftS","zeroFillRightShiftM","not","abs","acos","acosh","asin","asinh","atan","atanh","cbrt","ceil","clz32","cos","cosh","exp","expm1","floor","fround","log","log1p","log10","log2","round","sign","sin","sinh","sqrt","tan","tanh","trunc","pow","arg0","powS","powM","checkRowIndex","index","outer","checkColumnIndex","checkRowVector","vector","to1DArray","checkColumnVector","checkIndices","rowIndices","columnIndices","row","checkRowIndices","column","checkColumnIndices","rowOut","some","r","from","columnOut","c","checkRange","startRow","endRow","startColumn","endColumn","checkNumber","newArray","array","sumByRow","sum","sumByColumn","sumAll","v","productByRow","productByColumn","productAll","varianceByRow","unbiased","mean","cols","variance","sum1","sum2","x","varianceByColumn","varianceAll","size","centerByRow","centerByColumn","centerAll","getScaleByRow","scale","scaleByRow","getScaleByColumn","scaleByColumn","getScaleAll","divider","scaleAll","from1DArray","newRows","newColumns","newData","rowVector","columnVector","zeros","ones","fill","rand","random","randInt","interval","eye","diag","data","l","matrix1","matrix2","isMatrix","klass","apply","callback","to2DArray","copy","toJSON","isRowVector","isColumnVector","isVector","isSquare","isSymmetric","isEchelonForm","previousColumn","checked","isReducedEchelonForm","k","echelonForm","clone","h","iMax","swapRows","tmp","reducedEchelonForm","m","n","maxRow","p","pivot","setSubMatrix","neg","getRow","getRowVector","setRow","row1","row2","temp","getColumn","getColumnVector","setColumn","swapColumns","column1","column2","addRowVector","subRowVector","mulRowVector","divRowVector","addColumnVector","subColumnVector","mulColumnVector","divColumnVector","mulRow","mulColumn","maxIndex","idx","minIndex","maxRowIndex","minRow","minRowIndex","maxColumn","maxColumnIndex","minColumn","minColumnIndex","norm","type","cumulativeSum","dot","vector2","vector1","mmul","other","Bcolj","Float64Array","s","strassen2x2","a11","b11","a12","b12","a21","b21","a22","b22","m1","m2","m3","m4","m5","m6","m7","c00","c01","c10","c11","strassen3x3","a00","a01","a02","a10","a20","b00","b01","b02","b10","b20","m8","m9","m10","m11","m12","m13","m14","m15","m16","m17","m18","m19","m20","m21","m22","m23","c02","c12","c20","c21","c22","mmulStrassen","y","r1","c1","r2","c2","console","warn","embed","mat","resultat","blockMult","a","b","halfRows","parseInt","halfCols","subMatrix","scaleRows","isFinite","scaleColumns","flipRows","middle","first","last","flipColumns","kroneckerProduct","q","transpose","sortRows","compareFunction","compareNumbers","sort","sortColumns","subMatrixRow","indices","subMatrixColumn","selection","rowIndex","columnIndex","trace","by","product","standardDeviation","center","Symbol","for","randomInt","diagonal","identity","negate","tensorProduct","nRows","nColumns","arrayData","removeRow","splice","addRow","removeColumn","newRow","addColumn","BaseView","MatrixColumnView","MatrixColumnSelectionView","MatrixFlipColumnView","MatrixFlipRowView","MatrixRowView","MatrixRowSelectionView","MatrixSelectionView","MatrixSubView","MatrixTransposeView","WrapperMatrix1D","_calculateIndex","WrapperMatrix2D","wrap","LuDecomposition","lu","pivotVector","pivotSign","t","LUcolj","kmax","LU","isSingular","col","solve","count","X","determinant","lowerTriangularMatrix","upperTriangularMatrix","pivotPermutationVector","hypotenuse","QrDecomposition","qr","rdiag","nrm","QR","Rdiag","isFullRank","orthogonalMatrix","SingularValueDecomposition","computeLeftSingularVectors","computeRightSingularVectors","autoTranspose","wantu","Boolean","wantv","swapped","aux","nu","ni","U","V","work","si","nct","nrt","mrc","pp","eps","EPSILON","kase","alpha","MIN_VALUE","isNaN","ks","f","cs","sn","sp","spm1","epm1","sk","ek","shift","g","Y","threshold","scols","Ls","rightSingularVectors","VL","vrows","urows","VLU","solveForDiagonal","inverse","vcols","ucols","condition","norm2","rank","tol","ii","leftSingularVectors","diagonalMatrix","useSVD","leftHandSide","rightHandSide","d","subMatrix0","subMatrix1","subMatrix2","xrange","exception","range","dependenciesOneRow","error","thresholdValue","thresholdError","returnArray","linearDependencies","results","Abis","svd","pseudoInverse","svdSolution","SVD","covariance","xMatrix","yMatrix","yIsSame","cov","correlation","sdx","sdy","corr","EigenvalueDecomposition","assumeSymmetric","tred2","tql2","H","ort","orthes","hqr2","realEigenvalues","imaginaryEigenvalues","eigenvectorMatrix","hh","dl1","c3","el1","s2","tst1","low","high","nn","exshift","z","iter","w","ra","sa","vr","vi","notlast","cdivres","cdiv","xr","xi","yr","yi","CholeskyDecomposition","dimension","positiveDefinite","L","isPositiveDefinite","B","nipals","scaleScores","maxIterations","terminationCriteria","u","diff","tOld","counter","xResidual","residual","yResidual","betas","sumValue","toDiscreteDistribution","numberOfClasses","counts","giniImpurity","probabilities","getNumberOfClasses","filter","val","arr","map","reduce","giniGain","splitted","splitsImpurity","splits","currentSplit","squaredError","meanArray","currentElement","regressionError","matrixSplitter","lesserX","greaterX","lesserY","greaterY","zip","ret","gainFunctions","gini","Utils","regression","splitFunctions","TreeNode","kind","gainFunction","splitFunction","minNumSamples","maxDepth","bestSplit","XTranspose","bestGain","Infinity","check","currentFeature","splitValues","featureSplit","currentSplitVal","split","gain","maxGain","splitValue","lesser","greater","calculatePrediction","distribution","train","currentDepth","parentGain","splitColumn","splittedMatrix","left","right","classify","setNodeParameters","node","defaultOptions","DecisionTreeClassifier","model","root","Tree","assign","trainingSet","trainingLabels","predict","toPredict","predictions","load","DecisionTreeRegression","trainingValues","checkFloat","examplesBaggingWithReplacement","trainingValue","seed","engine","Random","autoSeed","Xr","featureBagging","replacement","toRet","usedIndex","Set","has","RandomForestBase","maxFeatures","nEstimators","treeOptions","isClassifier","indexes","useSampleBagging","Estimator","DTClassifier","DTRegression","estimators","est","res","values","predictionValues","RandomForestClassifier","baseModel","mode","pop","_ref","module","exports","window","median","quickSelectMedian","selectionMethods","arrayMean","arrayMedian","selectionMethod","RandomForestRegression","PCA","dataset","means","stdevs","S","R","excludedFeatures","isCovarianceMatrix","method","nCompNIPALS","ignoreZeroVariance","_computeFromCovarianceMatrix","_adjust","covarianceMatrix","_computeWithNIPALS","singularValues","eigenvalues","singularValue","nComponents","invert","getExplainedVariance","getCumulativeVariance","explained","getEigenvectors","getEigenvalues","getStandardDeviations","getLoadings","evd","EVD","reverse","dc","NIPALS","squaredEuclidean","euclidean","distanceMatrix","distanceFn","getMatrix","Heap","defaultCmp","heapify","heappop","heappush","heappushpop","heapreplace","insort","nlargest","nsmallest","updateItem","_siftdown","_siftup","lo","hi","cmp","mid","concat","item","lastelt","returnitem","_i","_len","_ref1","_results","_results1","_j","pos","elem","los","startpos","newitem","parent","parentpos","childpos","endpos","rightpos","replace","pushpop","nodes","peek","contains","clear","empty","heap","toArray","insert","top","front","factory","this","require$$0","Cluster","children","height","isLeaf","cut","list","ans","group","groups","forEach","child","traverse","cb","visit","cluster","singleLink","dKI","dKJ","completeLink","averageLink","dIJ","nj","ai","aj","weightedAverageLink","centroidLink","medianLink","wardLink","nk","wardLink2","agnes","distanceFunction","isDistanceMatrix","updateFunc","getDistanceMatrix","numLeaves","toLowerCase","clusters","distance","getSmallestDistance","cluster1","cluster2","newCluster","newClusters","newDistanceMatrix","previous","newIndex","getPreviousIndex","prevI","prevICluster","smallest","smallestI","smallestJ","prev1","prev2","nearestVector","listVectors","similarityFunction","vectorIndex","maxSim","sim","minDist","MAX_VALUE","dist","calculateDistanceMatrix","updateClusterID","centers","clusterID","updateCenters","prevCenters","K","nDim","centersLen","dim","id","hasConverged","oldCenters","tolerance","LOOP","FLOAT_MUL","sh1","sh2","sh3","multiply_uint32","nlo","nhi","XSadd","Date","now","state","Uint32Array","init","getFloat","bind","getUint32","nextState","periodCertification","PROB_TOLERANCE","randomChoice","valuesArr","cumSum","getArray","randomIndex","seedOrRandom","xsadd","XSAdd","randomGenerator","choice","randomSample","mostDistant","maxDist","minDistCent","kmeanspp","nSamples","localTrials","firstCenterIdx","closestDistSquared","cumSumClosestDistSquared","candidateIdx","candidates","distanceToCandidates","euclideanDistances","bestCandidate","bestPot","bestDistSquared","newDistSquared","newPot","A","distanceSymbol","KMeansResult","centroids","converged","iterations","nearest","centroid","computeInformation","enrichedCentroids","withIterations","initialization","step","newCenters","kmeansGenerator","stepNumber","stepResult","kmeans","separateClasses","features","classes","totalPerClasses","separatedClasses","currentIndex","GaussianNB","reload","calculateProbabilities","C1","PI","std","logPriorProbability","currentStd","getCurrentClass","modelName","currentCase","maxProbability","predictedClass","currentProbability","calculateLogProbability","C2","MultinomialNB","conditionalProbability","priorProbability","separateClass","classValues","total","divisor","matrixLog","Node","obj","KDTree","points","metric","dimensions","restoreParent","buildTree","toJSONImpl","point","maxNodes","maxDistance","bestNodes","BinaryHeap","nearestSearch","ownDistance","linearPoint","bestChild","linearDistance","otherChild","saveNode","content","src","dest","depth","scoreFunction","element","bubbleUp","end","sinkDown","parentN","elemScore","child2N","child1N","swap","child1","child1Score","child2","child2Score","KNN","labels","kdTree","isEuclidean","euclideanDistance","getSinglePrediction","knn","nearestPoints","pointsPerClass","maxPoints","lastElement","currentClass","currentPoints","pow2array","initializeMatrices","PLS","meanX","stdDevX","meanY","stdDevY","PBQ","R2X","scaleMethod","latentVectors","rx","cx","ry","cy","ssqXcal","sumOfSquaresY","T","P","Q","W","transposeX","transposeY","tIndex","maxSumColIndex","uIndex","t1","den","pnorm","ssqYcal","E","F","KOPLS","YLoadingMat","SigmaPow","YScoreMat","predScoreMat","YOrthLoadingVec","YOrthEigen","YOrthScoreMat","toNorm","TURegressionCoeff","kernelX","kernel","orthogonalComp","predictiveComp","predictiveComponents","orthogonalComponents","compute","Identity","Sigma","YOrthScoreNorm","TpiPrime","CoTemp","SoTemp","toiPrime","ITo","lastScoreMat","lastTpPrime","KTestTrain","YOrthScoreVector","scoreMatPrime","p1","p2","p3","prediction","predYOrthVectors","ConfusionMatrix","fromLabels","actual","predicted","distinctLabels","actualIdx","predictedIdx","getLabels","getTotalCount","getTrueCount","getFalseCount","getTruePositiveCount","label","getIndex","getTrueNegativeCount","getFalsePositiveCount","getFalseNegativeCount","getPositiveCount","getNegativeCount","getTruePositiveRate","getTrueNegativeRate","getPositivePredictiveValue","TP","getNegativePredictiveValue","TN","getFalseNegativeRate","getFalsePositiveRate","getFalseDiscoveryRate","FP","getFalseOmissionRate","FN","getF1Score","getMatthewsCorrelationCoefficient","getInformedness","getMarkedness","getConfusionTable","getAccuracy","correct","incorrect","getCount","actualIndex","predictedIndex","accuracy","global","createCommonjsModule","fn","runtime","Op","hasOwn","hasOwnProperty","$Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","regeneratorRuntime","innerFn","outerFn","self","tryLocsList","protoGenerator","Generator","generator","create","context","Context","_invoke","makeInvokeMethod","tryCatch","arg","err","GenStateSuspendedStart","GenStateSuspendedYield","GenStateExecuting","GenStateCompleted","ContinueSentinel","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","getProto","getPrototypeOf","NativeIteratorPrototype","Gp","displayName","defineIteratorMethods","isGeneratorFunction","genFun","ctor","mark","setPrototypeOf","__proto__","awrap","__await","AsyncIterator","invoke","resolve","reject","record","Promise","then","unwrapped","previousPromise","enqueue","callInvokeWithMethodAndArg","async","next","done","doneResult","delegate","delegateResult","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","return","info","resultName","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","resetTryEntry","completion","reset","keys","key","iterable","iteratorMethod","skipTempReset","prev","charAt","stop","rootEntry","rootRecord","rval","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","thrown","delegateYield","Function","hadRuntime","getOwnPropertyNames","oldRuntime","runtimeModule","regenerator","_callee","M","N","twiddle","_callee$","_context","getFolds","allIdx","current","folds","randi","foldsIndex","testIndex","trainIndex","el","idx2","sampleAClass","classVector","fraction","classVectorSorted","JSON","parse","stringify","indexOfSelected","ind","mask","includes","leaveOneOut","Classifier","classifierOptions","leavePOut","distinct","getDistinct","confusionMatrix","initMatrix","gen","combinations","testIdx","trainIdx","validateWithCallback","validate","kFold","testFeatures","trainFeatures","testLabels","trainLabels","getTrainTest","classifier","predictedLabels","updateConfusionMatrix","OPLSNipals","numberOSC","uNew","wOrtho","tOrtho","pOrtho","filteredX","weightsXOrtho","loadingsXOrtho","scoresXOrtho","weightsXPred","loadingsXpred","scoresXpred","loadingsY","tss","OPLS","opls","meansY","stdevsY","tCV","tOrthCV","yHatCV","nComp","cvFolds","Q2","oplsCV","modelNC","nc","yHatk","tPredk","tOrthk","oplsk","fold","trainTest","_getTrainTest","testXk","Xk","Yk","dataCenter","dataSD","plsCV","Eh","scores","tPred","yHat","tssy","press","Q2y","_predictAll","xRes","XOrth","FeaturesCS","labelsCS","Xres","plsCall","R2x","R2y","plsC","pPred","wPred","betasPred","Qpc","tOrth","pOrth","wOrth","totalPred","Yres","getLogs","getScores","scoresX","scoresY","trueLabels","tssx","oplsC","rss","xEx","rssx","logistic","expELU","param","softExponential","softExponentialPrime","ACTIVATION_FUNCTIONS","activation","derivate","arctan","softsign","relu","softplus","bent","sinusoid","sinc","gaussian","Layer","inputSize","outputSize","regularization","epsilon","activationParam","selectedFunction","params","actFunction","derFunction","activationFunction","mlMatrix","forward","backpropagation","delta","dW","db","aCopy","update","OutputLayer","FeedForwardNeuralNetworks","hiddenLayers","learningRate","dicts","layers","buildNetwork","dictOutputs","inputs","propagate","outputs","NodeSquare","weights","som","neighbors","adjustWeights","target","influence","getDistance","otherNode","getDistanceTorus","distX","distY","gridDim","getNeighbors","xy","torus","getPos","bestNeighbor","direction","dist1","dist2","simA","simB","getPosition","NodeHexagonal","hX","getDistanceHexagonal","distZ","fields","randomizer","squareEuclidean","gridType","SOM","numWeights","converters","getConverters","extractor","creator","nodeType","hx","distanceMethod","getMaxDistance","times","findBMU","adjust","iterationCount","startLearningRate","mapRadius","algorithmMethod","_initNodes","loadModel","eval","export","exportModel","includeDistance","initNodes","setTraining","convertedSet","numIterations","timeConstant","trainOne","neighbourhoodRadius","trainingSetFactor","getRandomValue","bmu","_findBestMatchingUnit","now2","radiusLimit","xMin","xMax","yMin","yMax","theX","theY","getConvertedNodes","findBestMatchingUnit","candidate","lowest","computePosition","_predict","getQuantizationError","fit","getFit","normalizers","denormalizers","getNormalizer","getDenormalizer","minMax","normalizer","denormalizer","zero","one","maybeToPrecision","digits","checkArraySize","BaseRegression","new","toLaTeX","score","y2","xSum","ySum","chi2","rmsd","xSquared","ySquared","xY","PolynomialRegression","degree","powers","coefficients","checkArrayLength","regress","precision","_toFormula","isLaTeX","sup","closeSup","str","json","pr","FT","SimpleLinearRegression","slope","intercept","computeX","xFactor","absIntercept","operator","slr","numerator","ExponentialRegression","er","yl","linear","PowerRegression","newInputs","latex","xl","MultivariateLinearRegression","statistics","xt","xx","invxx","beta","fittedValues","residuals","ri","stdError","stdErrorMatrix","stdErrors","tStats","summary","regressionStatistics","standardError","observations","variables","tStat","sigma","GaussianKernel","constant","PolynomialKernel","SigmoidKernel","ANOVAKernel","len","CauchyKernel","ExponentialKernel","HistogramIntersectionKernel","LaplacianKernel","MultiquadraticKernel","RationalQuadraticKernel","kernelType","rbf","polynomial","poly","anova","cauchy","histogram","HistogramKernel","laplacian","multiquadratic","rational","RationalKernel","sigmoid","mlp","Kernel","KernelConstructor","kernelFunction","landmarks","kernelMatrix","TheilSenRegression","theilSen","slopes","medianSlope","cuts","RobustPolynomialRegression","robustPolynomial","_","tuples","getRandomTuples","tuple","calcCoefficients","residualsMedian","half","errorCalculation","parameters","parameterizedFunction","func","gradientFunction","evaluatedData","gradientDifference","paramFunction","auxParams","funcParam","matrixFunction","damping","gradientFunc","matrixFunc","inverseMatrix","levenbergMarquardt","errorTolerance","minValues","maxValues","initialValues","parLen","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","iteration","parameterValues","parameterError","sortCollectionSet","collection","objectCollection","BigInt","sorted","cssls","XtX","XtY","Pset","choXtX","luXtX","sortedPset","sortedEset","cols2Solve","vars","initialisation","Fset","D","setDifference","C","optimality","maxIter","Jset","fullSet","notPset","fcnnls","infeasIndex","Hset","hRowColIdx","negRowColIdx","alphaMin","minIdx","idx2zero","findIndex","newParam","fcnnlsVector","haystack","needle","comparator","assertNumber","number","largestPrime","primeNumbers","ascending","nextPrime","binarySearch","FREE","FULL","REMOVED","defaultInitialCapacity","defaultMinLoadFactor","defaultMaxLoadFactor","HashTable","table","minLoadFactor","maxLoadFactor","freeEntries","lowWaterMark","highWaterMark","initialCapacity","capacity","chooseHighWaterMark","indexOfKey","indexOfInsertion","newCapacity","chooseGrowCapacity","rehash","remove","noRehash","maybeShrinkCapacity","delete","chooseShrinkCapacity","containsKey","hash","decrement","containsValue","indexOfValue","ensureCapacity","minCapacity","oldCapacity","oldTable","oldValues","oldState","newTable","newValues","newState","chooseLowWaterMark","forEachKey","forEachValue","forEachPair","minLoad","maxLoad","SparseMatrix","_init","elements","symmetric","forEachNonZero","bandWidth","isBanded","width","cardinality","v1","v2","getNonZeros","setThreshold","newThreshold","trans","inplaceOperator","inplaceOperatorScalar","inplaceOperatorMatrix","staticOperator","inplaceMethod","staticMethod","operators","fillTemplateFunction","op","methods","mathMethod","template","RegExp","additiveSymmetric","avg","bhattacharyya","canberra","chebyshev","clark","czekanowskiSimilarity","up","down","czekanowskiDistance","dice","q1","q2","divergence","fidelity","gower","harmonicMean","hellinger","innerProduct","intersection","jaccard","jeffreys","jensenDifference","jensenShannon","kdivergence","kulczynski","kullbackLeibler","kumarHassebrook","kumarJohnson","lorentzian","manhattan","matusita","minkowski","motyka","neyman","pearson","probabilisticSymmetric","ruzicka","soergel","sorensen","squared","squaredChord","taneja","tanimoto","bitvector","inter","union","tanimotoS","topsoe","waveHedges","createTree","spectrum","minWindow","to","mainCreateTree","start","getSimilarity","gamma","treeSimilarity","getFunction","cosine","diceD","intersectionD","jaccardD","kulczynskiD","motykaD","avgA","avgB","newA","newB","squaredChordD","pred","cutoffs","tn","tp","fp","nNeg","nPos","nPosPred","nNegPred","Performance","isDistance","predP","all","targ","currentPred","nTp","nFp","getMeasure","measure","measures","getAURC","auc","getAUDC","getDistribution","cutLength","cutLow","cutHigh","xLabels","interValues","intraValues","interCumPercent","intraCumPercent","nTP","currentTP","nFP","currentFP","thisTP","thisFP","names","acc","fpr","tpr","fnr","tnr","ppv","npv","pcfall","pcmiss","lift","rpp","rnp","arrayCase","cond","matrixCase","padArray","factorial","windowSize","derivative","pad","padValue","savitzkyGolay","J","inic","Jtranspose","Jinv","det","eightBits","arr1","arr2","getBit","setBit","toBinaryString","substr","parseBinaryString","toHexString","parseHexString","toDebug","binary","SavitzkyGolay","np","fullWeights","hs","constantH","wg1","wg2","d1","d2","getHs","wg","GramPoly","Grampoly","GenFact","gf","Weight","gsd","yIn","noiseLevel","sgOptions","smoothY","heightFactor","broadRatio","maxCriteria","minMaxRatio","derivativeThreshold","realTopDetection","equalSpaced","isEqualSpaced","getNoiseLevel","yCorrection","yData","dY","ddY","SG","xData","dX","maxDdy","maxY","lastMax","lastMin","minddY","intervalL","intervalR","broadMask","minddYLen","intervalLLen","intervalRLen","broadMaskLen","signals","signalsLen","lastK","possible","frequency","distanceJ","minDistance","gettingCloser","soft","yLeft","yRight","determineRealTop","base","maxDx","minDx","stddev","averageDeviations","peakList","currentPoint","sumOfGaussians","nL","optimizeGaussianSum","opts","pInit","pMin","pMax","dt","lmOptions","pFit","LM","singleGaussian","factor2","optimizeSingleGaussian","peak","sumOfLorentzians","optimizeLorentzianSum","singleLorentzian","optimizeSingleLorentzian","optimizePeaks","functionName","factorWidth","optimizationOptions","lastIndex","groupPeaks","sampling","peaks","sampleFunction","limits","optPeaks","fitResult","nbPoints","sampleX","sampleY","upperLimit","lowerLimit","joinBroadPeaks","broadLines","fitted","broadenPeaks","overlap","nextPeak","maxCount","_options$algorithm","algorithm","_options$sumValue","_options$maxValue","absoluteSumValue","absoluteSum","currentMaxValue","sumFactor","_i2","_typeof","sequentialFill","_options","_options$from","_options$to","_options$size","_options$unbiased","_options$mean","sqrError","mergeByCentroids","originalPoints","mergedPoints","originalIndex","mergedIndex","closestX","descending","maxMerge","groupWidth","merged","maxAbscissa","calculateIndex","sortX","sortFunc","grouped","response","uniqueX","weightedMerge","weightedAbscissa","normalize","zones","NEGATIVE_INFINITY","POSITIVE_INFINITY","zone","currentZone","exclusions","exclusion","nextExclusion","zonesWithPoints","numberOfPoints","totalSize","unitsPerPoint","currentTotal","integral","x0","x1","equallySpacedSmooth","xLength","halfStep","initialOriginalStep","lastOriginalStep","previousX","previousY","nextX","nextY","currentValue","sumAtMin","sumAtMax","getSlope","y0","y1","main","equallySpacedSlot","lastStep","frontOutsideSpectra","backOutsideSpectra","equallySpaced","arrayXY","variant","xResult","yResult","zoneResult","processZone","getZones","currentFrom","filterX","currentZoneI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EAAAA,IAJmB;EAKnBqgB,QAAAA,MALmB;EAMnBm5C,UAAAA,MANmB;EAOnBrkE,EAAAA,OAPmB;EAQnBs/D,EAAAA,cARmB;EASnBznD,EAAAA,iBATmB;EAUnBzN,EAAAA,GAVmB;EAWnBW,EAAAA;EAXmB;QAwBRu5D,OAAO,GAAG;EACrBC,kBAAAA,gBADqB;EAErBpE,EAAAA,QAFqB;EAGrB9/C,cAAAA,YAHqB;EAIrBggD,EAAAA,QAJqB;EAKrBlG,EAAAA,IALqB;EAMrBuG,EAAAA,KANqB;EAOrBI,EAAAA,OAPqB;EAQrBC,EAAAA,aARqB;EASrBuC,EAAAA,aATqB;EAUrBS,EAAAA;EAVqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"ml.js","sources":["../node_modules/ml-array-rescale/node_modules/is-any-array/src/index.js","../node_modules/ml-array-rescale/node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-rescale/node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-rescale/lib-es6/index.js","../node_modules/ml-matrix/src/inspect.js","../node_modules/ml-matrix/src/mathOperations.js","../node_modules/ml-matrix/src/util.js","../node_modules/ml-matrix/src/stat.js","../node_modules/ml-matrix/src/matrix.js","../node_modules/ml-matrix/src/views/base.js","../node_modules/ml-matrix/src/views/column.js","../node_modules/ml-matrix/src/views/columnSelection.js","../node_modules/ml-matrix/src/views/flipColumn.js","../node_modules/ml-matrix/src/views/flipRow.js","../node_modules/ml-matrix/src/views/row.js","../node_modules/ml-matrix/src/views/rowSelection.js","../node_modules/ml-matrix/src/views/selection.js","../node_modules/ml-matrix/src/views/sub.js","../node_modules/ml-matrix/src/views/transpose.js","../node_modules/ml-matrix/src/wrap/WrapperMatrix1D.js","../node_modules/ml-matrix/src/wrap/WrapperMatrix2D.js","../node_modules/ml-matrix/src/wrap/wrap.js","../node_modules/ml-matrix/src/dc/lu.js","../node_modules/ml-matrix/src/dc/util.js","../node_modules/ml-matrix/src/dc/qr.js","../node_modules/ml-matrix/src/dc/svd.js","../node_modules/ml-matrix/src/decompositions.js","../node_modules/ml-matrix/src/determinant.js","../node_modules/ml-matrix/src/linearDependencies.js","../node_modules/ml-matrix/src/pseudoInverse.js","../node_modules/ml-matrix/src/covariance.js","../node_modules/ml-matrix/src/correlation.js","../node_modules/ml-matrix/src/dc/evd.js","../node_modules/ml-matrix/src/dc/cholesky.js","../node_modules/ml-matrix/src/dc/nipals.js","../node_modules/ml-array-sum/node_modules/is-any-array/src/index.js","../node_modules/ml-array-sum/lib-es6/index.js","../node_modules/ml-array-mean/lib-es6/index.js","../node_modules/ml-cart/src/utils.js","../node_modules/ml-cart/src/TreeNode.js","../node_modules/ml-cart/src/DecisionTreeClassifier.js","../node_modules/ml-cart/src/DecisionTreeRegression.js","../node_modules/random-js/dist/random-js.esm.js","../node_modules/ml-random-forest/src/utils.js","../node_modules/ml-random-forest/src/RandomForestBase.js","../node_modules/ml-random-forest/src/RandomForestClassifier.js","../node_modules/ml-array-median/node_modules/is-any-array/src/index.js","../node_modules/median-quickselect/lib/median-quickselect.min.js","../node_modules/ml-array-median/lib-es6/index.js","../node_modules/ml-random-forest/src/RandomForestRegression.js","../node_modules/ml-pca/src/pca.js","../node_modules/ml-distance-euclidean/lib-es6/euclidean.js","../node_modules/ml-distance-matrix/src/index.js","../node_modules/heap/lib/heap.js","../node_modules/heap/index.js","../node_modules/ml-hclust/src/Cluster.js","../node_modules/ml-hclust/src/agnes.js","../node_modules/ml-hclust/src/index.js","../node_modules/ml-nearest-vector/lib-es6/index.js","../node_modules/ml-kmeans/src/utils.js","../node_modules/ml-xsadd/lib-es6/xsadd.js","../node_modules/ml-random/lib-es6/choice.js","../node_modules/ml-random/lib-es6/index.js","../node_modules/ml-kmeans/src/initialization.js","../node_modules/ml-kmeans/src/KMeansResult.js","../node_modules/ml-kmeans/src/kmeans.js","../node_modules/ml-naivebayes/src/utils.js","../node_modules/ml-naivebayes/src/GaussianNB.js","../node_modules/ml-naivebayes/src/MultinomialNB.js","../node_modules/ml-knn/src/KDTree.js","../node_modules/ml-knn/src/index.js","../node_modules/ml-pls/src/util/utils.js","../node_modules/ml-pls/src/PLS.js","../node_modules/ml-pls/src/KOPLS.js","../node_modules/ml-confusion-matrix/src/index.js","../node_modules/ml-combinations/lib/index.js","../node_modules/ml-cross-validation/src/getFolds.js","../node_modules/ml-cross-validation/src/sampleAClass.js","../node_modules/ml-cross-validation/src/index.js","../node_modules/ml-pls/src/OPLSNipals.js","../node_modules/ml-pls/src/util/tss.js","../node_modules/ml-pls/src/OPLS.js","../node_modules/ml-fnn/FeedForwardNeuralNetwork.js","../node_modules/ml-som/src/node-square.js","../node_modules/ml-som/src/node-hexagonal.js","../node_modules/ml-som/src/index.js","../node_modules/ml-regression-base/src/maybeToPrecision.js","../node_modules/ml-regression-base/src/checkArrayLength.js","../node_modules/ml-regression-base/src/index.js","../node_modules/ml-regression-polynomial/src/index.js","../node_modules/ml-regression-simple-linear/src/index.js","../node_modules/ml-regression-exponential/src/index.js","../node_modules/ml-regression-power/src/index.js","../node_modules/ml-regression-multivariate-linear/src/index.js","../node_modules/ml-kernel-gaussian/gaussian-kernel.js","../node_modules/ml-kernel-polynomial/polynomial-kernel.js","../node_modules/ml-kernel-sigmoid/sigmoid-kernel.js","../node_modules/ml-kernel/src/kernels/anova-kernel.js","../node_modules/ml-kernel/src/kernels/cauchy-kernel.js","../node_modules/ml-kernel/src/kernels/exponential-kernel.js","../node_modules/ml-kernel/src/kernels/histogram-intersection-kernel.js","../node_modules/ml-kernel/src/kernels/laplacian-kernel.js","../node_modules/ml-kernel/src/kernels/multiquadratic-kernel.js","../node_modules/ml-kernel/src/kernels/rational-quadratic-kernel.js","../node_modules/ml-kernel/src/kernel.js","../node_modules/ml-regression-theil-sen/src/index.js","../node_modules/ml-regression-robust-polynomial/src/index.js","../node_modules/ml-levenberg-marquardt/node_modules/is-any-array/src/index.js","../node_modules/ml-levenberg-marquardt/src/errorCalculation.js","../node_modules/ml-levenberg-marquardt/src/step.js","../node_modules/ml-levenberg-marquardt/src/index.js","../node_modules/ml-fcnnls/src/util/selection.js","../node_modules/ml-fcnnls/src/util/sortCollectionSet.js","../node_modules/ml-fcnnls/src/cssls.js","../node_modules/ml-fcnnls/src/initialisation.js","../node_modules/ml-fcnnls/src/util/setDifference.js","../node_modules/ml-fcnnls/src/optimality.js","../node_modules/ml-fcnnls/src/fcnnls.js","../node_modules/ml-fcnnls/src/fcnnlsVector.js","../node_modules/binary-search/index.js","../node_modules/num-sort/index.js","../node_modules/ml-hash-table/src/primeFinder.js","../node_modules/ml-hash-table/src/HashTable.js","../node_modules/ml-sparse-matrix/src/index.js","../node_modules/ml-distance/src/distances/additiveSymmetric.js","../node_modules/ml-distance/src/distances/avg.js","../node_modules/ml-distance/src/distances/bhattacharyya.js","../node_modules/ml-distance/src/distances/canberra.js","../node_modules/ml-distance/src/distances/chebyshev.js","../node_modules/ml-distance/src/distances/clark.js","../node_modules/ml-distance/src/similarities/czekanowski.js","../node_modules/ml-distance/src/distances/czekanowski.js","../node_modules/ml-distance/src/distances/dice.js","../node_modules/ml-distance/src/distances/divergence.js","../node_modules/ml-distance/src/distances/fidelity.js","../node_modules/ml-distance/src/distances/gower.js","../node_modules/ml-distance/src/distances/harmonicMean.js","../node_modules/ml-distance/src/distances/hellinger.js","../node_modules/ml-distance/src/distances/innerProduct.js","../node_modules/ml-distance/src/distances/intersection.js","../node_modules/ml-distance/src/distances/jaccard.js","../node_modules/ml-distance/src/distances/jeffreys.js","../node_modules/ml-distance/src/distances/jensenDifference.js","../node_modules/ml-distance/src/distances/jensenShannon.js","../node_modules/ml-distance/src/distances/kdivergence.js","../node_modules/ml-distance/src/distances/kulczynski.js","../node_modules/ml-distance/src/distances/kullbackLeibler.js","../node_modules/ml-distance/src/distances/kumarHassebrook.js","../node_modules/ml-distance/src/distances/kumarJohnson.js","../node_modules/ml-distance/src/distances/lorentzian.js","../node_modules/ml-distance/src/distances/manhattan.js","../node_modules/ml-distance/src/distances/matusita.js","../node_modules/ml-distance/src/distances/minkowski.js","../node_modules/ml-distance/src/distances/motyka.js","../node_modules/ml-distance/src/distances/neyman.js","../node_modules/ml-distance/src/distances/pearson.js","../node_modules/ml-distance/src/distances/probabilisticSymmetric.js","../node_modules/ml-distance/src/distances/ruzicka.js","../node_modules/ml-distance/src/distances/soergel.js","../node_modules/ml-distance/src/distances/sorensen.js","../node_modules/ml-distance/src/distances/squared.js","../node_modules/ml-distance/src/distances/squaredChord.js","../node_modules/ml-distance/src/distances/taneja.js","../node_modules/ml-distance/src/similarities/tanimoto.js","../node_modules/ml-distance/src/distances/tanimoto.js","../node_modules/ml-distance/src/distances/topsoe.js","../node_modules/ml-distance/src/distances/waveHedges.js","../node_modules/ml-tree-similarity/src/createTree.js","../node_modules/ml-tree-similarity/src/getSimilarity.js","../node_modules/ml-tree-similarity/src/index.js","../node_modules/ml-distance/src/similarities/cosine.js","../node_modules/ml-distance/src/similarities/dice.js","../node_modules/ml-distance/src/similarities/intersection.js","../node_modules/ml-distance/src/similarities/jaccard.js","../node_modules/ml-distance/src/similarities/kulczynski.js","../node_modules/ml-distance/src/similarities/motyka.js","../node_modules/ml-distance/src/similarities/pearson.js","../node_modules/ml-distance/src/similarities/squaredChord.js","../node_modules/ml-ngmca/src/util/zeroInsteadOfNegative.js","../node_modules/ml-ngmca/src/stages/checkMatrixS.js","../node_modules/ml-ngmca/src/util/normBy.js","../node_modules/ml-ngmca/src/util/normProj.js","../node_modules/ml-ngmca/src/stages/updateMatrixA.js","../node_modules/ml-ngmca/src/util/getMax.js","../node_modules/ml-ngmca/src/stages/updateMatrixS.js","../node_modules/ml-ngmca/src/stages/initialize.js","../node_modules/ml-ngmca/src/stages/normalize.js","../node_modules/ml-ngmca/src/util/getMedians.js","../node_modules/ml-ngmca/src/util/dimMADstd.js","../node_modules/ml-ngmca/src/stages/updateLambda.js","../node_modules/ml-ngmca/src/nGMCA.js","../node_modules/ml-performance/src/measures.js","../node_modules/ml-performance/src/index.js","../node_modules/ml-pad-array/src/index.js","../node_modules/ml-savitzky-golay/src/index.js","../node_modules/ml-bit-array/src/creator.js","../node_modules/ml-bit-array/src/index.js","../node_modules/ml-gsd/node_modules/ml-savitzky-golay-generalized/src/index.js","../node_modules/ml-gsd/src/gsd.js","../node_modules/ml-optimize-lorentzian/src/sumOfGaussians.js","../node_modules/ml-optimize-lorentzian/src/optimizeGaussianSum.js","../node_modules/ml-optimize-lorentzian/src/singleGaussian.js","../node_modules/ml-optimize-lorentzian/src/optimizeSingleGaussian.js","../node_modules/ml-optimize-lorentzian/src/sumOfLorentzians.js","../node_modules/ml-optimize-lorentzian/src/optimizeLorentzianSum.js","../node_modules/ml-optimize-lorentzian/src/singleLorentzian.js","../node_modules/ml-optimize-lorentzian/src/optimizeSingleLorentzian.js","../node_modules/ml-gsd/src/post/optimizePeaks.js","../node_modules/ml-gsd/src/post/joinBroadPeaks.js","../node_modules/ml-gsd/src/post/broadenPeaks.js","../node_modules/is-any-array/src/index.js","../node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-mode/lib-es6/index.js","../node_modules/ml-array-normed/node_modules/is-any-array/src/index.js","../node_modules/ml-array-normed/node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-normed/lib-es6/index.js","../node_modules/ml-array-sequential-fill/lib-es6/index.js","../node_modules/ml-array-variance/node_modules/is-any-array/src/index.js","../node_modules/ml-array-variance/lib-es6/index.js","../node_modules/ml-array-standard-deviation/lib-es6/index.js","../node_modules/ml-array-xy-centroids-merge/src/index.js","../node_modules/ml-arrayxy-closestx/src/index.js","../node_modules/ml-array-xy-covariance/src/index.js","../node_modules/ml-array-xy-max-merge/src/index.js","../node_modules/ml-array-xy-max-y/src/index.js","../node_modules/ml-array-xy-sort-x/src/index.js","../node_modules/ml-arrayxy-uniquex/src/index.js","../node_modules/ml-array-xy-weighted-merge/src/index.js","../node_modules/ml-zones/src/normalize.js","../node_modules/ml-zones/src/invert.js","../node_modules/ml-zones/src/zonesWithPoints.js","../node_modules/ml-array-xy-equally-spaced/src/integral.js","../node_modules/ml-array-xy-equally-spaced/src/equallySpacedSmooth.js","../node_modules/ml-array-xy-equally-spaced/src/equallySpacedSlot.js","../node_modules/ml-array-xy-equally-spaced/src/index.js","../node_modules/ml-array-xy-filter-x/src/getZones.js","../node_modules/ml-array-xy-filter-x/src/index.js","../src/index.js"],"sourcesContent":["const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\n\nfunction min(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var minValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import isArray from 'is-any-array';\nimport max from 'ml-array-max';\nimport min from 'ml-array-min';\n\nfunction rescale(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n } else if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var output;\n\n if (options.output !== undefined) {\n if (!isArray(options.output)) {\n throw new TypeError('output option must be an array if specified');\n }\n\n output = options.output;\n } else {\n output = new Array(input.length);\n }\n\n var currentMin = min(input);\n var currentMax = max(input);\n\n if (currentMin === currentMax) {\n throw new RangeError('minimum and maximum input values are equal. Cannot rescale a constant array');\n }\n\n var _options$min = options.min,\n minValue = _options$min === void 0 ? options.autoMinMax ? currentMin : 0 : _options$min,\n _options$max = options.max,\n maxValue = _options$max === void 0 ? options.autoMinMax ? currentMax : 1 : _options$max;\n\n if (minValue >= maxValue) {\n throw new RangeError('min option must be smaller than max option');\n }\n\n var factor = (maxValue - minValue) / (currentMax - currentMin);\n\n for (var i = 0; i < input.length; i++) {\n output[i] = (input[i] - currentMin) * factor + minValue;\n }\n\n return output;\n}\n\nexport default rescale;\n","const indent = ' '.repeat(2);\r\nconst indentData = ' '.repeat(4);\r\n\r\nexport function inspectMatrix() {\r\n return inspectMatrixWithOptions(this);\r\n}\r\n\r\nexport function inspectMatrixWithOptions(matrix, options = {}) {\r\n const { maxRows = 15, maxColumns = 10, maxNumSize = 8 } = options;\r\n return `${matrix.constructor.name} {\r\n${indent}[\r\n${indentData}${inspectData(matrix, maxRows, maxColumns, maxNumSize)}\r\n${indent}]\r\n${indent}rows: ${matrix.rows}\r\n${indent}columns: ${matrix.columns}\r\n}`;\r\n}\r\n\r\nfunction inspectData(matrix, maxRows, maxColumns, maxNumSize) {\r\n const { rows, columns } = matrix;\r\n const maxI = Math.min(rows, maxRows);\r\n const maxJ = Math.min(columns, maxColumns);\r\n const result = [];\r\n for (let i = 0; i < maxI; i++) {\r\n let line = [];\r\n for (let j = 0; j < maxJ; j++) {\r\n line.push(formatNumber(matrix.get(i, j), maxNumSize));\r\n }\r\n result.push(`${line.join(' ')}`);\r\n }\r\n if (maxJ !== columns) {\r\n result[result.length - 1] += ` ... ${columns - maxColumns} more columns`;\r\n }\r\n if (maxI !== rows) {\r\n result.push(`... ${rows - maxRows} more rows`);\r\n }\r\n return result.join(`\\n${indentData}`);\r\n}\r\n\r\nfunction formatNumber(num, maxNumSize) {\r\n const numStr = String(num);\r\n if (numStr.length <= maxNumSize) {\r\n return numStr.padEnd(maxNumSize, ' ');\r\n }\r\n const precise = num.toPrecision(maxNumSize - 2);\r\n if (precise.length <= maxNumSize) {\r\n return precise;\r\n }\r\n const exponential = num.toExponential(maxNumSize - 2);\r\n const eIndex = exponential.indexOf('e');\r\n const e = exponential.slice(eIndex);\r\n return exponential.slice(0, maxNumSize - e.length) + e;\r\n}\r\n","export function installMathOperations(AbstractMatrix, Matrix) {\r\n AbstractMatrix.prototype.add = function add(value) {\r\n if (typeof value === 'number') return this.addS(value);\r\n return this.addM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.addS = function addS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.addM = function addM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.add = function add(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.add(value);\r\n };\r\n\r\n AbstractMatrix.prototype.sub = function sub(value) {\r\n if (typeof value === 'number') return this.subS(value);\r\n return this.subM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.subS = function subS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.subM = function subM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sub = function sub(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sub(value);\r\n };\r\n AbstractMatrix.prototype.subtract = AbstractMatrix.prototype.sub;\r\n AbstractMatrix.prototype.subtractS = AbstractMatrix.prototype.subS;\r\n AbstractMatrix.prototype.subtractM = AbstractMatrix.prototype.subM;\r\n AbstractMatrix.subtract = AbstractMatrix.sub;\r\n\r\n AbstractMatrix.prototype.mul = function mul(value) {\r\n if (typeof value === 'number') return this.mulS(value);\r\n return this.mulM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.mulS = function mulS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.mulM = function mulM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.mul = function mul(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.mul(value);\r\n };\r\n AbstractMatrix.prototype.multiply = AbstractMatrix.prototype.mul;\r\n AbstractMatrix.prototype.multiplyS = AbstractMatrix.prototype.mulS;\r\n AbstractMatrix.prototype.multiplyM = AbstractMatrix.prototype.mulM;\r\n AbstractMatrix.multiply = AbstractMatrix.mul;\r\n\r\n AbstractMatrix.prototype.div = function div(value) {\r\n if (typeof value === 'number') return this.divS(value);\r\n return this.divM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.divS = function divS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.divM = function divM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.div = function div(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.div(value);\r\n };\r\n AbstractMatrix.prototype.divide = AbstractMatrix.prototype.div;\r\n AbstractMatrix.prototype.divideS = AbstractMatrix.prototype.divS;\r\n AbstractMatrix.prototype.divideM = AbstractMatrix.prototype.divM;\r\n AbstractMatrix.divide = AbstractMatrix.div;\r\n\r\n AbstractMatrix.prototype.mod = function mod(value) {\r\n if (typeof value === 'number') return this.modS(value);\r\n return this.modM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.modS = function modS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) % value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.modM = function modM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) % matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.mod = function mod(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.mod(value);\r\n };\r\n AbstractMatrix.prototype.modulus = AbstractMatrix.prototype.mod;\r\n AbstractMatrix.prototype.modulusS = AbstractMatrix.prototype.modS;\r\n AbstractMatrix.prototype.modulusM = AbstractMatrix.prototype.modM;\r\n AbstractMatrix.modulus = AbstractMatrix.mod;\r\n\r\n AbstractMatrix.prototype.and = function and(value) {\r\n if (typeof value === 'number') return this.andS(value);\r\n return this.andM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.andS = function andS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) & value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.andM = function andM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) & matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.and = function and(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.and(value);\r\n };\r\n\r\n AbstractMatrix.prototype.or = function or(value) {\r\n if (typeof value === 'number') return this.orS(value);\r\n return this.orM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.orS = function orS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) | value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.orM = function orM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) | matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.or = function or(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.or(value);\r\n };\r\n\r\n AbstractMatrix.prototype.xor = function xor(value) {\r\n if (typeof value === 'number') return this.xorS(value);\r\n return this.xorM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.xorS = function xorS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) ^ value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.xorM = function xorM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) ^ matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.xor = function xor(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.xor(value);\r\n };\r\n\r\n AbstractMatrix.prototype.leftShift = function leftShift(value) {\r\n if (typeof value === 'number') return this.leftShiftS(value);\r\n return this.leftShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.leftShiftS = function leftShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) << value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.leftShiftM = function leftShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) << matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.leftShift = function leftShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.leftShift(value);\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShift = function signPropagatingRightShift(value) {\r\n if (typeof value === 'number') return this.signPropagatingRightShiftS(value);\r\n return this.signPropagatingRightShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShiftS = function signPropagatingRightShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >> value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShiftM = function signPropagatingRightShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >> matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.signPropagatingRightShift = function signPropagatingRightShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.signPropagatingRightShift(value);\r\n };\r\n\r\n AbstractMatrix.prototype.rightShift = function rightShift(value) {\r\n if (typeof value === 'number') return this.rightShiftS(value);\r\n return this.rightShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.rightShiftS = function rightShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >>> value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.rightShiftM = function rightShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >>> matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.rightShift = function rightShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.rightShift(value);\r\n };\r\n AbstractMatrix.prototype.zeroFillRightShift = AbstractMatrix.prototype.rightShift;\r\n AbstractMatrix.prototype.zeroFillRightShiftS = AbstractMatrix.prototype.rightShiftS;\r\n AbstractMatrix.prototype.zeroFillRightShiftM = AbstractMatrix.prototype.rightShiftM;\r\n AbstractMatrix.zeroFillRightShift = AbstractMatrix.rightShift;\r\n\r\n AbstractMatrix.prototype.not = function not() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, ~(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.not = function not(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.not();\r\n };\r\n\r\n AbstractMatrix.prototype.abs = function abs() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.abs(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.abs = function abs(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.abs();\r\n };\r\n\r\n AbstractMatrix.prototype.acos = function acos() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.acos(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.acos = function acos(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.acos();\r\n };\r\n\r\n AbstractMatrix.prototype.acosh = function acosh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.acosh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.acosh = function acosh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.acosh();\r\n };\r\n\r\n AbstractMatrix.prototype.asin = function asin() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.asin(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.asin = function asin(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.asin();\r\n };\r\n\r\n AbstractMatrix.prototype.asinh = function asinh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.asinh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.asinh = function asinh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.asinh();\r\n };\r\n\r\n AbstractMatrix.prototype.atan = function atan() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.atan(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.atan = function atan(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.atan();\r\n };\r\n\r\n AbstractMatrix.prototype.atanh = function atanh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.atanh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.atanh = function atanh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.atanh();\r\n };\r\n\r\n AbstractMatrix.prototype.cbrt = function cbrt() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cbrt(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cbrt = function cbrt(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cbrt();\r\n };\r\n\r\n AbstractMatrix.prototype.ceil = function ceil() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.ceil(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.ceil = function ceil(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.ceil();\r\n };\r\n\r\n AbstractMatrix.prototype.clz32 = function clz32() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.clz32(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.clz32 = function clz32(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.clz32();\r\n };\r\n\r\n AbstractMatrix.prototype.cos = function cos() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cos(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cos = function cos(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cos();\r\n };\r\n\r\n AbstractMatrix.prototype.cosh = function cosh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cosh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cosh = function cosh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cosh();\r\n };\r\n\r\n AbstractMatrix.prototype.exp = function exp() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.exp(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.exp = function exp(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.exp();\r\n };\r\n\r\n AbstractMatrix.prototype.expm1 = function expm1() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.expm1(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.expm1 = function expm1(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.expm1();\r\n };\r\n\r\n AbstractMatrix.prototype.floor = function floor() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.floor(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.floor = function floor(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.floor();\r\n };\r\n\r\n AbstractMatrix.prototype.fround = function fround() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.fround(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.fround = function fround(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.fround();\r\n };\r\n\r\n AbstractMatrix.prototype.log = function log() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log = function log(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log();\r\n };\r\n\r\n AbstractMatrix.prototype.log1p = function log1p() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log1p(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log1p = function log1p(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log1p();\r\n };\r\n\r\n AbstractMatrix.prototype.log10 = function log10() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log10(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log10 = function log10(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log10();\r\n };\r\n\r\n AbstractMatrix.prototype.log2 = function log2() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log2(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log2 = function log2(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log2();\r\n };\r\n\r\n AbstractMatrix.prototype.round = function round() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.round(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.round = function round(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.round();\r\n };\r\n\r\n AbstractMatrix.prototype.sign = function sign() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sign(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sign = function sign(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sign();\r\n };\r\n\r\n AbstractMatrix.prototype.sin = function sin() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sin(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sin = function sin(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sin();\r\n };\r\n\r\n AbstractMatrix.prototype.sinh = function sinh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sinh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sinh = function sinh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sinh();\r\n };\r\n\r\n AbstractMatrix.prototype.sqrt = function sqrt() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sqrt(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sqrt = function sqrt(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sqrt();\r\n };\r\n\r\n AbstractMatrix.prototype.tan = function tan() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.tan(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.tan = function tan(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.tan();\r\n };\r\n\r\n AbstractMatrix.prototype.tanh = function tanh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.tanh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.tanh = function tanh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.tanh();\r\n };\r\n\r\n AbstractMatrix.prototype.trunc = function trunc() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.trunc(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.trunc = function trunc(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.trunc();\r\n };\r\n\r\n AbstractMatrix.pow = function pow(matrix, arg0) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.pow(arg0);\r\n };\r\n\r\n AbstractMatrix.prototype.pow = function pow(value) {\r\n if (typeof value === 'number') return this.powS(value);\r\n return this.powM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.powS = function powS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.pow(this.get(i, j), value));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.powM = function powM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n}\r\n","/**\r\n * @private\r\n * Check that a row index is not out of bounds\r\n * @param {Matrix} matrix\r\n * @param {number} index\r\n * @param {boolean} [outer]\r\n */\r\nexport function checkRowIndex(matrix, index, outer) {\r\n let max = outer ? matrix.rows : matrix.rows - 1;\r\n if (index < 0 || index > max) {\r\n throw new RangeError('Row index out of range');\r\n }\r\n}\r\n\r\n/**\r\n * @private\r\n * Check that a column index is not out of bounds\r\n * @param {Matrix} matrix\r\n * @param {number} index\r\n * @param {boolean} [outer]\r\n */\r\nexport function checkColumnIndex(matrix, index, outer) {\r\n let max = outer ? matrix.columns : matrix.columns - 1;\r\n if (index < 0 || index > max) {\r\n throw new RangeError('Column index out of range');\r\n }\r\n}\r\n\r\n/**\r\n * @private\r\n * Check that the provided vector is an array with the right length\r\n * @param {Matrix} matrix\r\n * @param {Array|Matrix} vector\r\n * @return {Array}\r\n * @throws {RangeError}\r\n */\r\nexport function checkRowVector(matrix, vector) {\r\n if (vector.to1DArray) {\r\n vector = vector.to1DArray();\r\n }\r\n if (vector.length !== matrix.columns) {\r\n throw new RangeError(\r\n 'vector size must be the same as the number of columns',\r\n );\r\n }\r\n return vector;\r\n}\r\n\r\n/**\r\n * @private\r\n * Check that the provided vector is an array with the right length\r\n * @param {Matrix} matrix\r\n * @param {Array|Matrix} vector\r\n * @return {Array}\r\n * @throws {RangeError}\r\n */\r\nexport function checkColumnVector(matrix, vector) {\r\n if (vector.to1DArray) {\r\n vector = vector.to1DArray();\r\n }\r\n if (vector.length !== matrix.rows) {\r\n throw new RangeError('vector size must be the same as the number of rows');\r\n }\r\n return vector;\r\n}\r\n\r\nexport function checkIndices(matrix, rowIndices, columnIndices) {\r\n return {\r\n row: checkRowIndices(matrix, rowIndices),\r\n column: checkColumnIndices(matrix, columnIndices),\r\n };\r\n}\r\n\r\nexport function checkRowIndices(matrix, rowIndices) {\r\n if (typeof rowIndices !== 'object') {\r\n throw new TypeError('unexpected type for row indices');\r\n }\r\n\r\n let rowOut = rowIndices.some((r) => {\r\n return r < 0 || r >= matrix.rows;\r\n });\r\n\r\n if (rowOut) {\r\n throw new RangeError('row indices are out of range');\r\n }\r\n\r\n if (!Array.isArray(rowIndices)) rowIndices = Array.from(rowIndices);\r\n\r\n return rowIndices;\r\n}\r\n\r\nexport function checkColumnIndices(matrix, columnIndices) {\r\n if (typeof columnIndices !== 'object') {\r\n throw new TypeError('unexpected type for column indices');\r\n }\r\n\r\n let columnOut = columnIndices.some((c) => {\r\n return c < 0 || c >= matrix.columns;\r\n });\r\n\r\n if (columnOut) {\r\n throw new RangeError('column indices are out of range');\r\n }\r\n if (!Array.isArray(columnIndices)) columnIndices = Array.from(columnIndices);\r\n\r\n return columnIndices;\r\n}\r\n\r\nexport function checkRange(matrix, startRow, endRow, startColumn, endColumn) {\r\n if (arguments.length !== 5) {\r\n throw new RangeError('expected 4 arguments');\r\n }\r\n checkNumber('startRow', startRow);\r\n checkNumber('endRow', endRow);\r\n checkNumber('startColumn', startColumn);\r\n checkNumber('endColumn', endColumn);\r\n if (\r\n startRow > endRow ||\r\n startColumn > endColumn ||\r\n startRow < 0 ||\r\n startRow >= matrix.rows ||\r\n endRow < 0 ||\r\n endRow >= matrix.rows ||\r\n startColumn < 0 ||\r\n startColumn >= matrix.columns ||\r\n endColumn < 0 ||\r\n endColumn >= matrix.columns\r\n ) {\r\n throw new RangeError('Submatrix indices are out of range');\r\n }\r\n}\r\n\r\nexport function newArray(length, value = 0) {\r\n let array = [];\r\n for (let i = 0; i < length; i++) {\r\n array.push(value);\r\n }\r\n return array;\r\n}\r\n\r\nfunction checkNumber(name, value) {\r\n if (typeof value !== 'number') {\r\n throw new TypeError(`${name} must be a number`);\r\n }\r\n}\r\n","import { newArray } from './util';\r\n\r\nexport function sumByRow(matrix) {\r\n let sum = newArray(matrix.rows);\r\n for (let i = 0; i < matrix.rows; ++i) {\r\n for (let j = 0; j < matrix.columns; ++j) {\r\n sum[i] += matrix.get(i, j);\r\n }\r\n }\r\n return sum;\r\n}\r\n\r\nexport function sumByColumn(matrix) {\r\n let sum = newArray(matrix.columns);\r\n for (let i = 0; i < matrix.rows; ++i) {\r\n for (let j = 0; j < matrix.columns; ++j) {\r\n sum[j] += matrix.get(i, j);\r\n }\r\n }\r\n return sum;\r\n}\r\n\r\nexport function sumAll(matrix) {\r\n let v = 0;\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n v += matrix.get(i, j);\r\n }\r\n }\r\n return v;\r\n}\r\n\r\nexport function productByRow(matrix) {\r\n let sum = newArray(matrix.rows, 1);\r\n for (let i = 0; i < matrix.rows; ++i) {\r\n for (let j = 0; j < matrix.columns; ++j) {\r\n sum[i] *= matrix.get(i, j);\r\n }\r\n }\r\n return sum;\r\n}\r\n\r\nexport function productByColumn(matrix) {\r\n let sum = newArray(matrix.columns, 1);\r\n for (let i = 0; i < matrix.rows; ++i) {\r\n for (let j = 0; j < matrix.columns; ++j) {\r\n sum[j] *= matrix.get(i, j);\r\n }\r\n }\r\n return sum;\r\n}\r\n\r\nexport function productAll(matrix) {\r\n let v = 1;\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n v *= matrix.get(i, j);\r\n }\r\n }\r\n return v;\r\n}\r\n\r\nexport function varianceByRow(matrix, unbiased, mean) {\r\n const rows = matrix.rows;\r\n const cols = matrix.columns;\r\n const variance = [];\r\n\r\n for (let i = 0; i < rows; i++) {\r\n let sum1 = 0;\r\n let sum2 = 0;\r\n let x = 0;\r\n for (let j = 0; j < cols; j++) {\r\n x = matrix.get(i, j) - mean[i];\r\n sum1 += x;\r\n sum2 += x * x;\r\n }\r\n if (unbiased) {\r\n variance.push((sum2 - (sum1 * sum1) / cols) / (cols - 1));\r\n } else {\r\n variance.push((sum2 - (sum1 * sum1) / cols) / cols);\r\n }\r\n }\r\n return variance;\r\n}\r\n\r\nexport function varianceByColumn(matrix, unbiased, mean) {\r\n const rows = matrix.rows;\r\n const cols = matrix.columns;\r\n const variance = [];\r\n\r\n for (let j = 0; j < cols; j++) {\r\n let sum1 = 0;\r\n let sum2 = 0;\r\n let x = 0;\r\n for (let i = 0; i < rows; i++) {\r\n x = matrix.get(i, j) - mean[j];\r\n sum1 += x;\r\n sum2 += x * x;\r\n }\r\n if (unbiased) {\r\n variance.push((sum2 - (sum1 * sum1) / rows) / (rows - 1));\r\n } else {\r\n variance.push((sum2 - (sum1 * sum1) / rows) / rows);\r\n }\r\n }\r\n return variance;\r\n}\r\n\r\nexport function varianceAll(matrix, unbiased, mean) {\r\n const rows = matrix.rows;\r\n const cols = matrix.columns;\r\n const size = rows * cols;\r\n\r\n let sum1 = 0;\r\n let sum2 = 0;\r\n let x = 0;\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < cols; j++) {\r\n x = matrix.get(i, j) - mean;\r\n sum1 += x;\r\n sum2 += x * x;\r\n }\r\n }\r\n if (unbiased) {\r\n return (sum2 - (sum1 * sum1) / size) / (size - 1);\r\n } else {\r\n return (sum2 - (sum1 * sum1) / size) / size;\r\n }\r\n}\r\n\r\nexport function centerByRow(matrix, mean) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) - mean[i]);\r\n }\r\n }\r\n}\r\n\r\nexport function centerByColumn(matrix, mean) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) - mean[j]);\r\n }\r\n }\r\n}\r\n\r\nexport function centerAll(matrix, mean) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) - mean);\r\n }\r\n }\r\n}\r\n\r\nexport function getScaleByRow(matrix) {\r\n const scale = [];\r\n for (let i = 0; i < matrix.rows; i++) {\r\n let sum = 0;\r\n for (let j = 0; j < matrix.columns; j++) {\r\n sum += Math.pow(matrix.get(i, j), 2) / (matrix.columns - 1);\r\n }\r\n scale.push(Math.sqrt(sum));\r\n }\r\n return scale;\r\n}\r\n\r\nexport function scaleByRow(matrix, scale) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) / scale[i]);\r\n }\r\n }\r\n}\r\n\r\nexport function getScaleByColumn(matrix) {\r\n const scale = [];\r\n for (let j = 0; j < matrix.columns; j++) {\r\n let sum = 0;\r\n for (let i = 0; i < matrix.rows; i++) {\r\n sum += Math.pow(matrix.get(i, j), 2) / (matrix.rows - 1);\r\n }\r\n scale.push(Math.sqrt(sum));\r\n }\r\n return scale;\r\n}\r\n\r\nexport function scaleByColumn(matrix, scale) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) / scale[j]);\r\n }\r\n }\r\n}\r\n\r\nexport function getScaleAll(matrix) {\r\n const divider = matrix.size - 1;\r\n let sum = 0;\r\n for (let j = 0; j < matrix.columns; j++) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n sum += Math.pow(matrix.get(i, j), 2) / divider;\r\n }\r\n }\r\n return Math.sqrt(sum);\r\n}\r\n\r\nexport function scaleAll(matrix, scale) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) / scale);\r\n }\r\n }\r\n}\r\n","import rescale from 'ml-array-rescale';\r\n\r\nimport { inspectMatrix, inspectMatrixWithOptions } from './inspect';\r\nimport { installMathOperations } from './mathOperations';\r\nimport {\r\n sumByRow,\r\n sumByColumn,\r\n sumAll,\r\n productByRow,\r\n productByColumn,\r\n productAll,\r\n varianceByRow,\r\n varianceByColumn,\r\n varianceAll,\r\n centerByRow,\r\n centerByColumn,\r\n centerAll,\r\n scaleByRow,\r\n scaleByColumn,\r\n scaleAll,\r\n getScaleByRow,\r\n getScaleByColumn,\r\n getScaleAll,\r\n} from './stat';\r\nimport {\r\n checkRowVector,\r\n checkRowIndex,\r\n checkColumnIndex,\r\n checkColumnVector,\r\n checkRange,\r\n checkIndices,\r\n} from './util';\r\n\r\nexport class AbstractMatrix {\r\n static from1DArray(newRows, newColumns, newData) {\r\n let length = newRows * newColumns;\r\n if (length !== newData.length) {\r\n throw new RangeError('data length does not match given dimensions');\r\n }\r\n let newMatrix = new Matrix(newRows, newColumns);\r\n for (let row = 0; row < newRows; row++) {\r\n for (let column = 0; column < newColumns; column++) {\r\n newMatrix.set(row, column, newData[row * newColumns + column]);\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n static rowVector(newData) {\r\n let vector = new Matrix(1, newData.length);\r\n for (let i = 0; i < newData.length; i++) {\r\n vector.set(0, i, newData[i]);\r\n }\r\n return vector;\r\n }\r\n\r\n static columnVector(newData) {\r\n let vector = new Matrix(newData.length, 1);\r\n for (let i = 0; i < newData.length; i++) {\r\n vector.set(i, 0, newData[i]);\r\n }\r\n return vector;\r\n }\r\n\r\n static zeros(rows, columns) {\r\n return new Matrix(rows, columns);\r\n }\r\n\r\n static ones(rows, columns) {\r\n return new Matrix(rows, columns).fill(1);\r\n }\r\n\r\n static rand(rows, columns, options = {}) {\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { random = Math.random } = options;\r\n let matrix = new Matrix(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n matrix.set(i, j, random());\r\n }\r\n }\r\n return matrix;\r\n }\r\n\r\n static randInt(rows, columns, options = {}) {\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { min = 0, max = 1000, random = Math.random } = options;\r\n if (!Number.isInteger(min)) throw new TypeError('min must be an integer');\r\n if (!Number.isInteger(max)) throw new TypeError('max must be an integer');\r\n if (min >= max) throw new RangeError('min must be smaller than max');\r\n let interval = max - min;\r\n let matrix = new Matrix(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n let value = min + Math.round(random() * interval);\r\n matrix.set(i, j, value);\r\n }\r\n }\r\n return matrix;\r\n }\r\n\r\n static eye(rows, columns, value) {\r\n if (columns === undefined) columns = rows;\r\n if (value === undefined) value = 1;\r\n let min = Math.min(rows, columns);\r\n let matrix = this.zeros(rows, columns);\r\n for (let i = 0; i < min; i++) {\r\n matrix.set(i, i, value);\r\n }\r\n return matrix;\r\n }\r\n\r\n static diag(data, rows, columns) {\r\n let l = data.length;\r\n if (rows === undefined) rows = l;\r\n if (columns === undefined) columns = rows;\r\n let min = Math.min(l, rows, columns);\r\n let matrix = this.zeros(rows, columns);\r\n for (let i = 0; i < min; i++) {\r\n matrix.set(i, i, data[i]);\r\n }\r\n return matrix;\r\n }\r\n\r\n static min(matrix1, matrix2) {\r\n matrix1 = this.checkMatrix(matrix1);\r\n matrix2 = this.checkMatrix(matrix2);\r\n let rows = matrix1.rows;\r\n let columns = matrix1.columns;\r\n let result = new Matrix(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n result.set(i, j, Math.min(matrix1.get(i, j), matrix2.get(i, j)));\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n static max(matrix1, matrix2) {\r\n matrix1 = this.checkMatrix(matrix1);\r\n matrix2 = this.checkMatrix(matrix2);\r\n let rows = matrix1.rows;\r\n let columns = matrix1.columns;\r\n let result = new this(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n result.set(i, j, Math.max(matrix1.get(i, j), matrix2.get(i, j)));\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n static checkMatrix(value) {\r\n return AbstractMatrix.isMatrix(value) ? value : new Matrix(value);\r\n }\r\n\r\n static isMatrix(value) {\r\n return value != null && value.klass === 'Matrix';\r\n }\r\n\r\n get size() {\r\n return this.rows * this.columns;\r\n }\r\n\r\n apply(callback) {\r\n if (typeof callback !== 'function') {\r\n throw new TypeError('callback must be a function');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n callback.call(this, i, j);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n to1DArray() {\r\n let array = [];\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n array.push(this.get(i, j));\r\n }\r\n }\r\n return array;\r\n }\r\n\r\n to2DArray() {\r\n let copy = [];\r\n for (let i = 0; i < this.rows; i++) {\r\n copy.push([]);\r\n for (let j = 0; j < this.columns; j++) {\r\n copy[i].push(this.get(i, j));\r\n }\r\n }\r\n return copy;\r\n }\r\n\r\n toJSON() {\r\n return this.to2DArray();\r\n }\r\n\r\n isRowVector() {\r\n return this.rows === 1;\r\n }\r\n\r\n isColumnVector() {\r\n return this.columns === 1;\r\n }\r\n\r\n isVector() {\r\n return this.rows === 1 || this.columns === 1;\r\n }\r\n\r\n isSquare() {\r\n return this.rows === this.columns;\r\n }\r\n\r\n isSymmetric() {\r\n if (this.isSquare()) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j <= i; j++) {\r\n if (this.get(i, j) !== this.get(j, i)) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n isEchelonForm() {\r\n let i = 0;\r\n let j = 0;\r\n let previousColumn = -1;\r\n let isEchelonForm = true;\r\n let checked = false;\r\n while (i < this.rows && isEchelonForm) {\r\n j = 0;\r\n checked = false;\r\n while (j < this.columns && checked === false) {\r\n if (this.get(i, j) === 0) {\r\n j++;\r\n } else if (this.get(i, j) === 1 && j > previousColumn) {\r\n checked = true;\r\n previousColumn = j;\r\n } else {\r\n isEchelonForm = false;\r\n checked = true;\r\n }\r\n }\r\n i++;\r\n }\r\n return isEchelonForm;\r\n }\r\n\r\n isReducedEchelonForm() {\r\n let i = 0;\r\n let j = 0;\r\n let previousColumn = -1;\r\n let isReducedEchelonForm = true;\r\n let checked = false;\r\n while (i < this.rows && isReducedEchelonForm) {\r\n j = 0;\r\n checked = false;\r\n while (j < this.columns && checked === false) {\r\n if (this.get(i, j) === 0) {\r\n j++;\r\n } else if (this.get(i, j) === 1 && j > previousColumn) {\r\n checked = true;\r\n previousColumn = j;\r\n } else {\r\n isReducedEchelonForm = false;\r\n checked = true;\r\n }\r\n }\r\n for (let k = j + 1; k < this.rows; k++) {\r\n if (this.get(i, k) !== 0) {\r\n isReducedEchelonForm = false;\r\n }\r\n }\r\n i++;\r\n }\r\n return isReducedEchelonForm;\r\n }\r\n\r\n echelonForm() {\r\n let result = this.clone();\r\n let h = 0;\r\n let k = 0;\r\n while (h < result.rows && k < result.columns) {\r\n let iMax = h;\r\n for (let i = h; i < result.rows; i++) {\r\n if (result.get(i, k) > result.get(iMax, k)) {\r\n iMax = i;\r\n }\r\n }\r\n if (result.get(iMax, k) === 0) {\r\n k++;\r\n } else {\r\n result.swapRows(h, iMax);\r\n let tmp = result.get(h, k);\r\n for (let j = k; j < result.columns; j++) {\r\n result.set(h, j, result.get(h, j) / tmp);\r\n }\r\n for (let i = h + 1; i < result.rows; i++) {\r\n let factor = result.get(i, k) / result.get(h, k);\r\n result.set(i, k, 0);\r\n for (let j = k + 1; j < result.columns; j++) {\r\n result.set(i, j, result.get(i, j) - result.get(h, j) * factor);\r\n }\r\n }\r\n h++;\r\n k++;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n reducedEchelonForm() {\r\n let result = this.echelonForm();\r\n let m = result.columns;\r\n let n = result.rows;\r\n let h = n - 1;\r\n while (h >= 0) {\r\n if (result.maxRow(h) === 0) {\r\n h--;\r\n } else {\r\n let p = 0;\r\n let pivot = false;\r\n while (p < n && pivot === false) {\r\n if (result.get(h, p) === 1) {\r\n pivot = true;\r\n } else {\r\n p++;\r\n }\r\n }\r\n for (let i = 0; i < h; i++) {\r\n let factor = result.get(i, p);\r\n for (let j = p; j < m; j++) {\r\n let tmp = result.get(i, j) - factor * result.get(h, j);\r\n result.set(i, j, tmp);\r\n }\r\n }\r\n h--;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n set() {\r\n throw new Error('set method is unimplemented');\r\n }\r\n\r\n get() {\r\n throw new Error('get method is unimplemented');\r\n }\r\n\r\n repeat(options = {}) {\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { rows = 1, columns = 1 } = options;\r\n if (!Number.isInteger(rows) || rows <= 0) {\r\n throw new TypeError('rows must be a positive integer');\r\n }\r\n if (!Number.isInteger(columns) || columns <= 0) {\r\n throw new TypeError('columns must be a positive integer');\r\n }\r\n let matrix = new Matrix(this.rows * rows, this.columns * columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n matrix.setSubMatrix(this, this.rows * i, this.columns * j);\r\n }\r\n }\r\n return matrix;\r\n }\r\n\r\n fill(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, value);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n neg() {\r\n return this.mulS(-1);\r\n }\r\n\r\n getRow(index) {\r\n checkRowIndex(this, index);\r\n let row = [];\r\n for (let i = 0; i < this.columns; i++) {\r\n row.push(this.get(index, i));\r\n }\r\n return row;\r\n }\r\n\r\n getRowVector(index) {\r\n return Matrix.rowVector(this.getRow(index));\r\n }\r\n\r\n setRow(index, array) {\r\n checkRowIndex(this, index);\r\n array = checkRowVector(this, array);\r\n for (let i = 0; i < this.columns; i++) {\r\n this.set(index, i, array[i]);\r\n }\r\n return this;\r\n }\r\n\r\n swapRows(row1, row2) {\r\n checkRowIndex(this, row1);\r\n checkRowIndex(this, row2);\r\n for (let i = 0; i < this.columns; i++) {\r\n let temp = this.get(row1, i);\r\n this.set(row1, i, this.get(row2, i));\r\n this.set(row2, i, temp);\r\n }\r\n return this;\r\n }\r\n\r\n getColumn(index) {\r\n checkColumnIndex(this, index);\r\n let column = [];\r\n for (let i = 0; i < this.rows; i++) {\r\n column.push(this.get(i, index));\r\n }\r\n return column;\r\n }\r\n\r\n getColumnVector(index) {\r\n return Matrix.columnVector(this.getColumn(index));\r\n }\r\n\r\n setColumn(index, array) {\r\n checkColumnIndex(this, index);\r\n array = checkColumnVector(this, array);\r\n for (let i = 0; i < this.rows; i++) {\r\n this.set(i, index, array[i]);\r\n }\r\n return this;\r\n }\r\n\r\n swapColumns(column1, column2) {\r\n checkColumnIndex(this, column1);\r\n checkColumnIndex(this, column2);\r\n for (let i = 0; i < this.rows; i++) {\r\n let temp = this.get(i, column1);\r\n this.set(i, column1, this.get(i, column2));\r\n this.set(i, column2, temp);\r\n }\r\n return this;\r\n }\r\n\r\n addRowVector(vector) {\r\n vector = checkRowVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + vector[j]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n subRowVector(vector) {\r\n vector = checkRowVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - vector[j]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n mulRowVector(vector) {\r\n vector = checkRowVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * vector[j]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n divRowVector(vector) {\r\n vector = checkRowVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / vector[j]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n addColumnVector(vector) {\r\n vector = checkColumnVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + vector[i]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n subColumnVector(vector) {\r\n vector = checkColumnVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - vector[i]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n mulColumnVector(vector) {\r\n vector = checkColumnVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * vector[i]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n divColumnVector(vector) {\r\n vector = checkColumnVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / vector[i]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n mulRow(index, value) {\r\n checkRowIndex(this, index);\r\n for (let i = 0; i < this.columns; i++) {\r\n this.set(index, i, this.get(index, i) * value);\r\n }\r\n return this;\r\n }\r\n\r\n mulColumn(index, value) {\r\n checkColumnIndex(this, index);\r\n for (let i = 0; i < this.rows; i++) {\r\n this.set(i, index, this.get(i, index) * value);\r\n }\r\n return this;\r\n }\r\n\r\n max() {\r\n let v = this.get(0, 0);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n if (this.get(i, j) > v) {\r\n v = this.get(i, j);\r\n }\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n maxIndex() {\r\n let v = this.get(0, 0);\r\n let idx = [0, 0];\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n if (this.get(i, j) > v) {\r\n v = this.get(i, j);\r\n idx[0] = i;\r\n idx[1] = j;\r\n }\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n min() {\r\n let v = this.get(0, 0);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n if (this.get(i, j) < v) {\r\n v = this.get(i, j);\r\n }\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n minIndex() {\r\n let v = this.get(0, 0);\r\n let idx = [0, 0];\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n if (this.get(i, j) < v) {\r\n v = this.get(i, j);\r\n idx[0] = i;\r\n idx[1] = j;\r\n }\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n maxRow(row) {\r\n checkRowIndex(this, row);\r\n let v = this.get(row, 0);\r\n for (let i = 1; i < this.columns; i++) {\r\n if (this.get(row, i) > v) {\r\n v = this.get(row, i);\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n maxRowIndex(row) {\r\n checkRowIndex(this, row);\r\n let v = this.get(row, 0);\r\n let idx = [row, 0];\r\n for (let i = 1; i < this.columns; i++) {\r\n if (this.get(row, i) > v) {\r\n v = this.get(row, i);\r\n idx[1] = i;\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n minRow(row) {\r\n checkRowIndex(this, row);\r\n let v = this.get(row, 0);\r\n for (let i = 1; i < this.columns; i++) {\r\n if (this.get(row, i) < v) {\r\n v = this.get(row, i);\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n minRowIndex(row) {\r\n checkRowIndex(this, row);\r\n let v = this.get(row, 0);\r\n let idx = [row, 0];\r\n for (let i = 1; i < this.columns; i++) {\r\n if (this.get(row, i) < v) {\r\n v = this.get(row, i);\r\n idx[1] = i;\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n maxColumn(column) {\r\n checkColumnIndex(this, column);\r\n let v = this.get(0, column);\r\n for (let i = 1; i < this.rows; i++) {\r\n if (this.get(i, column) > v) {\r\n v = this.get(i, column);\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n maxColumnIndex(column) {\r\n checkColumnIndex(this, column);\r\n let v = this.get(0, column);\r\n let idx = [0, column];\r\n for (let i = 1; i < this.rows; i++) {\r\n if (this.get(i, column) > v) {\r\n v = this.get(i, column);\r\n idx[0] = i;\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n minColumn(column) {\r\n checkColumnIndex(this, column);\r\n let v = this.get(0, column);\r\n for (let i = 1; i < this.rows; i++) {\r\n if (this.get(i, column) < v) {\r\n v = this.get(i, column);\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n minColumnIndex(column) {\r\n checkColumnIndex(this, column);\r\n let v = this.get(0, column);\r\n let idx = [0, column];\r\n for (let i = 1; i < this.rows; i++) {\r\n if (this.get(i, column) < v) {\r\n v = this.get(i, column);\r\n idx[0] = i;\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n diag() {\r\n let min = Math.min(this.rows, this.columns);\r\n let diag = [];\r\n for (let i = 0; i < min; i++) {\r\n diag.push(this.get(i, i));\r\n }\r\n return diag;\r\n }\r\n\r\n norm(type = 'frobenius') {\r\n let result = 0;\r\n if (type === 'max') {\r\n return this.max();\r\n } else if (type === 'frobenius') {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n result = result + this.get(i, j) * this.get(i, j);\r\n }\r\n }\r\n return Math.sqrt(result);\r\n } else {\r\n throw new RangeError(`unknown norm type: ${type}`);\r\n }\r\n }\r\n\r\n cumulativeSum() {\r\n let sum = 0;\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n sum += this.get(i, j);\r\n this.set(i, j, sum);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n dot(vector2) {\r\n if (AbstractMatrix.isMatrix(vector2)) vector2 = vector2.to1DArray();\r\n let vector1 = this.to1DArray();\r\n if (vector1.length !== vector2.length) {\r\n throw new RangeError('vectors do not have the same size');\r\n }\r\n let dot = 0;\r\n for (let i = 0; i < vector1.length; i++) {\r\n dot += vector1[i] * vector2[i];\r\n }\r\n return dot;\r\n }\r\n\r\n mmul(other) {\r\n other = Matrix.checkMatrix(other);\r\n\r\n let m = this.rows;\r\n let n = this.columns;\r\n let p = other.columns;\r\n\r\n let result = new Matrix(m, p);\r\n\r\n let Bcolj = new Float64Array(n);\r\n for (let j = 0; j < p; j++) {\r\n for (let k = 0; k < n; k++) {\r\n Bcolj[k] = other.get(k, j);\r\n }\r\n\r\n for (let i = 0; i < m; i++) {\r\n let s = 0;\r\n for (let k = 0; k < n; k++) {\r\n s += this.get(i, k) * Bcolj[k];\r\n }\r\n\r\n result.set(i, j, s);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n strassen2x2(other) {\r\n other = Matrix.checkMatrix(other);\r\n let result = new Matrix(2, 2);\r\n const a11 = this.get(0, 0);\r\n const b11 = other.get(0, 0);\r\n const a12 = this.get(0, 1);\r\n const b12 = other.get(0, 1);\r\n const a21 = this.get(1, 0);\r\n const b21 = other.get(1, 0);\r\n const a22 = this.get(1, 1);\r\n const b22 = other.get(1, 1);\r\n\r\n // Compute intermediate values.\r\n const m1 = (a11 + a22) * (b11 + b22);\r\n const m2 = (a21 + a22) * b11;\r\n const m3 = a11 * (b12 - b22);\r\n const m4 = a22 * (b21 - b11);\r\n const m5 = (a11 + a12) * b22;\r\n const m6 = (a21 - a11) * (b11 + b12);\r\n const m7 = (a12 - a22) * (b21 + b22);\r\n\r\n // Combine intermediate values into the output.\r\n const c00 = m1 + m4 - m5 + m7;\r\n const c01 = m3 + m5;\r\n const c10 = m2 + m4;\r\n const c11 = m1 - m2 + m3 + m6;\r\n\r\n result.set(0, 0, c00);\r\n result.set(0, 1, c01);\r\n result.set(1, 0, c10);\r\n result.set(1, 1, c11);\r\n return result;\r\n }\r\n\r\n strassen3x3(other) {\r\n other = Matrix.checkMatrix(other);\r\n let result = new Matrix(3, 3);\r\n\r\n const a00 = this.get(0, 0);\r\n const a01 = this.get(0, 1);\r\n const a02 = this.get(0, 2);\r\n const a10 = this.get(1, 0);\r\n const a11 = this.get(1, 1);\r\n const a12 = this.get(1, 2);\r\n const a20 = this.get(2, 0);\r\n const a21 = this.get(2, 1);\r\n const a22 = this.get(2, 2);\r\n\r\n const b00 = other.get(0, 0);\r\n const b01 = other.get(0, 1);\r\n const b02 = other.get(0, 2);\r\n const b10 = other.get(1, 0);\r\n const b11 = other.get(1, 1);\r\n const b12 = other.get(1, 2);\r\n const b20 = other.get(2, 0);\r\n const b21 = other.get(2, 1);\r\n const b22 = other.get(2, 2);\r\n\r\n const m1 = (a00 + a01 + a02 - a10 - a11 - a21 - a22) * b11;\r\n const m2 = (a00 - a10) * (-b01 + b11);\r\n const m3 = a11 * (-b00 + b01 + b10 - b11 - b12 - b20 + b22);\r\n const m4 = (-a00 + a10 + a11) * (b00 - b01 + b11);\r\n const m5 = (a10 + a11) * (-b00 + b01);\r\n const m6 = a00 * b00;\r\n const m7 = (-a00 + a20 + a21) * (b00 - b02 + b12);\r\n const m8 = (-a00 + a20) * (b02 - b12);\r\n const m9 = (a20 + a21) * (-b00 + b02);\r\n const m10 = (a00 + a01 + a02 - a11 - a12 - a20 - a21) * b12;\r\n const m11 = a21 * (-b00 + b02 + b10 - b11 - b12 - b20 + b21);\r\n const m12 = (-a02 + a21 + a22) * (b11 + b20 - b21);\r\n const m13 = (a02 - a22) * (b11 - b21);\r\n const m14 = a02 * b20;\r\n const m15 = (a21 + a22) * (-b20 + b21);\r\n const m16 = (-a02 + a11 + a12) * (b12 + b20 - b22);\r\n const m17 = (a02 - a12) * (b12 - b22);\r\n const m18 = (a11 + a12) * (-b20 + b22);\r\n const m19 = a01 * b10;\r\n const m20 = a12 * b21;\r\n const m21 = a10 * b02;\r\n const m22 = a20 * b01;\r\n const m23 = a22 * b22;\r\n\r\n const c00 = m6 + m14 + m19;\r\n const c01 = m1 + m4 + m5 + m6 + m12 + m14 + m15;\r\n const c02 = m6 + m7 + m9 + m10 + m14 + m16 + m18;\r\n const c10 = m2 + m3 + m4 + m6 + m14 + m16 + m17;\r\n const c11 = m2 + m4 + m5 + m6 + m20;\r\n const c12 = m14 + m16 + m17 + m18 + m21;\r\n const c20 = m6 + m7 + m8 + m11 + m12 + m13 + m14;\r\n const c21 = m12 + m13 + m14 + m15 + m22;\r\n const c22 = m6 + m7 + m8 + m9 + m23;\r\n\r\n result.set(0, 0, c00);\r\n result.set(0, 1, c01);\r\n result.set(0, 2, c02);\r\n result.set(1, 0, c10);\r\n result.set(1, 1, c11);\r\n result.set(1, 2, c12);\r\n result.set(2, 0, c20);\r\n result.set(2, 1, c21);\r\n result.set(2, 2, c22);\r\n return result;\r\n }\r\n\r\n mmulStrassen(y) {\r\n y = Matrix.checkMatrix(y);\r\n let x = this.clone();\r\n let r1 = x.rows;\r\n let c1 = x.columns;\r\n let r2 = y.rows;\r\n let c2 = y.columns;\r\n if (c1 !== r2) {\r\n // eslint-disable-next-line no-console\r\n console.warn(\r\n `Multiplying ${r1} x ${c1} and ${r2} x ${c2} matrix: dimensions do not match.`,\r\n );\r\n }\r\n\r\n // Put a matrix into the top left of a matrix of zeros.\r\n // `rows` and `cols` are the dimensions of the output matrix.\r\n function embed(mat, rows, cols) {\r\n let r = mat.rows;\r\n let c = mat.columns;\r\n if (r === rows && c === cols) {\r\n return mat;\r\n } else {\r\n let resultat = AbstractMatrix.zeros(rows, cols);\r\n resultat = resultat.setSubMatrix(mat, 0, 0);\r\n return resultat;\r\n }\r\n }\r\n\r\n // Make sure both matrices are the same size.\r\n // This is exclusively for simplicity:\r\n // this algorithm can be implemented with matrices of different sizes.\r\n\r\n let r = Math.max(r1, r2);\r\n let c = Math.max(c1, c2);\r\n x = embed(x, r, c);\r\n y = embed(y, r, c);\r\n\r\n // Our recursive multiplication function.\r\n function blockMult(a, b, rows, cols) {\r\n // For small matrices, resort to naive multiplication.\r\n if (rows <= 512 || cols <= 512) {\r\n return a.mmul(b); // a is equivalent to this\r\n }\r\n\r\n // Apply dynamic padding.\r\n if (rows % 2 === 1 && cols % 2 === 1) {\r\n a = embed(a, rows + 1, cols + 1);\r\n b = embed(b, rows + 1, cols + 1);\r\n } else if (rows % 2 === 1) {\r\n a = embed(a, rows + 1, cols);\r\n b = embed(b, rows + 1, cols);\r\n } else if (cols % 2 === 1) {\r\n a = embed(a, rows, cols + 1);\r\n b = embed(b, rows, cols + 1);\r\n }\r\n\r\n let halfRows = parseInt(a.rows / 2, 10);\r\n let halfCols = parseInt(a.columns / 2, 10);\r\n // Subdivide input matrices.\r\n let a11 = a.subMatrix(0, halfRows - 1, 0, halfCols - 1);\r\n let b11 = b.subMatrix(0, halfRows - 1, 0, halfCols - 1);\r\n\r\n let a12 = a.subMatrix(0, halfRows - 1, halfCols, a.columns - 1);\r\n let b12 = b.subMatrix(0, halfRows - 1, halfCols, b.columns - 1);\r\n\r\n let a21 = a.subMatrix(halfRows, a.rows - 1, 0, halfCols - 1);\r\n let b21 = b.subMatrix(halfRows, b.rows - 1, 0, halfCols - 1);\r\n\r\n let a22 = a.subMatrix(halfRows, a.rows - 1, halfCols, a.columns - 1);\r\n let b22 = b.subMatrix(halfRows, b.rows - 1, halfCols, b.columns - 1);\r\n\r\n // Compute intermediate values.\r\n let m1 = blockMult(\r\n AbstractMatrix.add(a11, a22),\r\n AbstractMatrix.add(b11, b22),\r\n halfRows,\r\n halfCols,\r\n );\r\n let m2 = blockMult(AbstractMatrix.add(a21, a22), b11, halfRows, halfCols);\r\n let m3 = blockMult(a11, AbstractMatrix.sub(b12, b22), halfRows, halfCols);\r\n let m4 = blockMult(a22, AbstractMatrix.sub(b21, b11), halfRows, halfCols);\r\n let m5 = blockMult(AbstractMatrix.add(a11, a12), b22, halfRows, halfCols);\r\n let m6 = blockMult(\r\n AbstractMatrix.sub(a21, a11),\r\n AbstractMatrix.add(b11, b12),\r\n halfRows,\r\n halfCols,\r\n );\r\n let m7 = blockMult(\r\n AbstractMatrix.sub(a12, a22),\r\n AbstractMatrix.add(b21, b22),\r\n halfRows,\r\n halfCols,\r\n );\r\n\r\n // Combine intermediate values into the output.\r\n let c11 = AbstractMatrix.add(m1, m4);\r\n c11.sub(m5);\r\n c11.add(m7);\r\n let c12 = AbstractMatrix.add(m3, m5);\r\n let c21 = AbstractMatrix.add(m2, m4);\r\n let c22 = AbstractMatrix.sub(m1, m2);\r\n c22.add(m3);\r\n c22.add(m6);\r\n\r\n // Crop output to the desired size (undo dynamic padding).\r\n let resultat = AbstractMatrix.zeros(2 * c11.rows, 2 * c11.columns);\r\n resultat = resultat.setSubMatrix(c11, 0, 0);\r\n resultat = resultat.setSubMatrix(c12, c11.rows, 0);\r\n resultat = resultat.setSubMatrix(c21, 0, c11.columns);\r\n resultat = resultat.setSubMatrix(c22, c11.rows, c11.columns);\r\n return resultat.subMatrix(0, rows - 1, 0, cols - 1);\r\n }\r\n return blockMult(x, y, r, c);\r\n }\r\n\r\n scaleRows(options = {}) {\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { min = 0, max = 1 } = options;\r\n if (!Number.isFinite(min)) throw new TypeError('min must be a number');\r\n if (!Number.isFinite(max)) throw new TypeError('max must be a number');\r\n if (min >= max) throw new RangeError('min must be smaller than max');\r\n let newMatrix = new Matrix(this.rows, this.columns);\r\n for (let i = 0; i < this.rows; i++) {\r\n const row = this.getRow(i);\r\n rescale(row, { min, max, output: row });\r\n newMatrix.setRow(i, row);\r\n }\r\n return newMatrix;\r\n }\r\n\r\n scaleColumns(options = {}) {\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { min = 0, max = 1 } = options;\r\n if (!Number.isFinite(min)) throw new TypeError('min must be a number');\r\n if (!Number.isFinite(max)) throw new TypeError('max must be a number');\r\n if (min >= max) throw new RangeError('min must be smaller than max');\r\n let newMatrix = new Matrix(this.rows, this.columns);\r\n for (let i = 0; i < this.columns; i++) {\r\n const column = this.getColumn(i);\r\n rescale(column, {\r\n min: min,\r\n max: max,\r\n output: column,\r\n });\r\n newMatrix.setColumn(i, column);\r\n }\r\n return newMatrix;\r\n }\r\n\r\n flipRows() {\r\n const middle = Math.ceil(this.columns / 2);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < middle; j++) {\r\n let first = this.get(i, j);\r\n let last = this.get(i, this.columns - 1 - j);\r\n this.set(i, j, last);\r\n this.set(i, this.columns - 1 - j, first);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n flipColumns() {\r\n const middle = Math.ceil(this.rows / 2);\r\n for (let j = 0; j < this.columns; j++) {\r\n for (let i = 0; i < middle; i++) {\r\n let first = this.get(i, j);\r\n let last = this.get(this.rows - 1 - i, j);\r\n this.set(i, j, last);\r\n this.set(this.rows - 1 - i, j, first);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n kroneckerProduct(other) {\r\n other = Matrix.checkMatrix(other);\r\n\r\n let m = this.rows;\r\n let n = this.columns;\r\n let p = other.rows;\r\n let q = other.columns;\r\n\r\n let result = new Matrix(m * p, n * q);\r\n for (let i = 0; i < m; i++) {\r\n for (let j = 0; j < n; j++) {\r\n for (let k = 0; k < p; k++) {\r\n for (let l = 0; l < q; l++) {\r\n result.set(p * i + k, q * j + l, this.get(i, j) * other.get(k, l));\r\n }\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n transpose() {\r\n let result = new Matrix(this.columns, this.rows);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n result.set(j, i, this.get(i, j));\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n sortRows(compareFunction = compareNumbers) {\r\n for (let i = 0; i < this.rows; i++) {\r\n this.setRow(i, this.getRow(i).sort(compareFunction));\r\n }\r\n return this;\r\n }\r\n\r\n sortColumns(compareFunction = compareNumbers) {\r\n for (let i = 0; i < this.columns; i++) {\r\n this.setColumn(i, this.getColumn(i).sort(compareFunction));\r\n }\r\n return this;\r\n }\r\n\r\n subMatrix(startRow, endRow, startColumn, endColumn) {\r\n checkRange(this, startRow, endRow, startColumn, endColumn);\r\n let newMatrix = new Matrix(\r\n endRow - startRow + 1,\r\n endColumn - startColumn + 1,\r\n );\r\n for (let i = startRow; i <= endRow; i++) {\r\n for (let j = startColumn; j <= endColumn; j++) {\r\n newMatrix.set(i - startRow, j - startColumn, this.get(i, j));\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n subMatrixRow(indices, startColumn, endColumn) {\r\n if (startColumn === undefined) startColumn = 0;\r\n if (endColumn === undefined) endColumn = this.columns - 1;\r\n if (\r\n startColumn > endColumn ||\r\n startColumn < 0 ||\r\n startColumn >= this.columns ||\r\n endColumn < 0 ||\r\n endColumn >= this.columns\r\n ) {\r\n throw new RangeError('Argument out of range');\r\n }\r\n\r\n let newMatrix = new Matrix(indices.length, endColumn - startColumn + 1);\r\n for (let i = 0; i < indices.length; i++) {\r\n for (let j = startColumn; j <= endColumn; j++) {\r\n if (indices[i] < 0 || indices[i] >= this.rows) {\r\n throw new RangeError(`Row index out of range: ${indices[i]}`);\r\n }\r\n newMatrix.set(i, j - startColumn, this.get(indices[i], j));\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n subMatrixColumn(indices, startRow, endRow) {\r\n if (startRow === undefined) startRow = 0;\r\n if (endRow === undefined) endRow = this.rows - 1;\r\n if (\r\n startRow > endRow ||\r\n startRow < 0 ||\r\n startRow >= this.rows ||\r\n endRow < 0 ||\r\n endRow >= this.rows\r\n ) {\r\n throw new RangeError('Argument out of range');\r\n }\r\n\r\n let newMatrix = new Matrix(endRow - startRow + 1, indices.length);\r\n for (let i = 0; i < indices.length; i++) {\r\n for (let j = startRow; j <= endRow; j++) {\r\n if (indices[i] < 0 || indices[i] >= this.columns) {\r\n throw new RangeError(`Column index out of range: ${indices[i]}`);\r\n }\r\n newMatrix.set(j - startRow, i, this.get(j, indices[i]));\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n setSubMatrix(matrix, startRow, startColumn) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n let endRow = startRow + matrix.rows - 1;\r\n let endColumn = startColumn + matrix.columns - 1;\r\n checkRange(this, startRow, endRow, startColumn, endColumn);\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n this.set(startRow + i, startColumn + j, matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n selection(rowIndices, columnIndices) {\r\n let indices = checkIndices(this, rowIndices, columnIndices);\r\n let newMatrix = new Matrix(rowIndices.length, columnIndices.length);\r\n for (let i = 0; i < indices.row.length; i++) {\r\n let rowIndex = indices.row[i];\r\n for (let j = 0; j < indices.column.length; j++) {\r\n let columnIndex = indices.column[j];\r\n newMatrix.set(i, j, this.get(rowIndex, columnIndex));\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n trace() {\r\n let min = Math.min(this.rows, this.columns);\r\n let trace = 0;\r\n for (let i = 0; i < min; i++) {\r\n trace += this.get(i, i);\r\n }\r\n return trace;\r\n }\r\n\r\n clone() {\r\n let newMatrix = new Matrix(this.rows, this.columns);\r\n for (let row = 0; row < this.rows; row++) {\r\n for (let column = 0; column < this.columns; column++) {\r\n newMatrix.set(row, column, this.get(row, column));\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n sum(by) {\r\n switch (by) {\r\n case 'row':\r\n return sumByRow(this);\r\n case 'column':\r\n return sumByColumn(this);\r\n case undefined:\r\n return sumAll(this);\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n product(by) {\r\n switch (by) {\r\n case 'row':\r\n return productByRow(this);\r\n case 'column':\r\n return productByColumn(this);\r\n case undefined:\r\n return productAll(this);\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n mean(by) {\r\n const sum = this.sum(by);\r\n switch (by) {\r\n case 'row': {\r\n for (let i = 0; i < this.rows; i++) {\r\n sum[i] /= this.columns;\r\n }\r\n return sum;\r\n }\r\n case 'column': {\r\n for (let i = 0; i < this.columns; i++) {\r\n sum[i] /= this.rows;\r\n }\r\n return sum;\r\n }\r\n case undefined:\r\n return sum / this.size;\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n variance(by, options = {}) {\r\n if (typeof by === 'object') {\r\n options = by;\r\n by = undefined;\r\n }\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { unbiased = true, mean = this.mean(by) } = options;\r\n if (typeof unbiased !== 'boolean') {\r\n throw new TypeError('unbiased must be a boolean');\r\n }\r\n switch (by) {\r\n case 'row': {\r\n if (!Array.isArray(mean)) {\r\n throw new TypeError('mean must be an array');\r\n }\r\n return varianceByRow(this, unbiased, mean);\r\n }\r\n case 'column': {\r\n if (!Array.isArray(mean)) {\r\n throw new TypeError('mean must be an array');\r\n }\r\n return varianceByColumn(this, unbiased, mean);\r\n }\r\n case undefined: {\r\n if (typeof mean !== 'number') {\r\n throw new TypeError('mean must be a number');\r\n }\r\n return varianceAll(this, unbiased, mean);\r\n }\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n standardDeviation(by, options) {\r\n if (typeof by === 'object') {\r\n options = by;\r\n by = undefined;\r\n }\r\n const variance = this.variance(by, options);\r\n if (by === undefined) {\r\n return Math.sqrt(variance);\r\n } else {\r\n for (let i = 0; i < variance.length; i++) {\r\n variance[i] = Math.sqrt(variance[i]);\r\n }\r\n return variance;\r\n }\r\n }\r\n\r\n center(by, options = {}) {\r\n if (typeof by === 'object') {\r\n options = by;\r\n by = undefined;\r\n }\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { center = this.mean(by) } = options;\r\n switch (by) {\r\n case 'row': {\r\n if (!Array.isArray(center)) {\r\n throw new TypeError('center must be an array');\r\n }\r\n centerByRow(this, center);\r\n return this;\r\n }\r\n case 'column': {\r\n if (!Array.isArray(center)) {\r\n throw new TypeError('center must be an array');\r\n }\r\n centerByColumn(this, center);\r\n return this;\r\n }\r\n case undefined: {\r\n if (typeof center !== 'number') {\r\n throw new TypeError('center must be a number');\r\n }\r\n centerAll(this, center);\r\n return this;\r\n }\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n scale(by, options = {}) {\r\n if (typeof by === 'object') {\r\n options = by;\r\n by = undefined;\r\n }\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n let scale = options.scale;\r\n switch (by) {\r\n case 'row': {\r\n if (scale === undefined) {\r\n scale = getScaleByRow(this);\r\n } else if (!Array.isArray(scale)) {\r\n throw new TypeError('scale must be an array');\r\n }\r\n scaleByRow(this, scale);\r\n return this;\r\n }\r\n case 'column': {\r\n if (scale === undefined) {\r\n scale = getScaleByColumn(this);\r\n } else if (!Array.isArray(scale)) {\r\n throw new TypeError('scale must be an array');\r\n }\r\n scaleByColumn(this, scale);\r\n return this;\r\n }\r\n case undefined: {\r\n if (scale === undefined) {\r\n scale = getScaleAll(this);\r\n } else if (typeof scale !== 'number') {\r\n throw new TypeError('scale must be a number');\r\n }\r\n scaleAll(this, scale);\r\n return this;\r\n }\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n toString(options) {\r\n return inspectMatrixWithOptions(this, options);\r\n }\r\n}\r\n\r\nAbstractMatrix.prototype.klass = 'Matrix';\r\nif (typeof Symbol !== 'undefined') {\r\n AbstractMatrix.prototype[\r\n Symbol.for('nodejs.util.inspect.custom')\r\n ] = inspectMatrix;\r\n}\r\n\r\nfunction compareNumbers(a, b) {\r\n return a - b;\r\n}\r\n\r\n// Synonyms\r\nAbstractMatrix.random = AbstractMatrix.rand;\r\nAbstractMatrix.randomInt = AbstractMatrix.randInt;\r\nAbstractMatrix.diagonal = AbstractMatrix.diag;\r\nAbstractMatrix.prototype.diagonal = AbstractMatrix.prototype.diag;\r\nAbstractMatrix.identity = AbstractMatrix.eye;\r\nAbstractMatrix.prototype.negate = AbstractMatrix.prototype.neg;\r\nAbstractMatrix.prototype.tensorProduct =\r\n AbstractMatrix.prototype.kroneckerProduct;\r\n\r\nexport default class Matrix extends AbstractMatrix {\r\n constructor(nRows, nColumns) {\r\n super();\r\n if (Matrix.isMatrix(nRows)) {\r\n return nRows.clone();\r\n } else if (Number.isInteger(nRows) && nRows > 0) {\r\n // Create an empty matrix\r\n this.data = [];\r\n if (Number.isInteger(nColumns) && nColumns > 0) {\r\n for (let i = 0; i < nRows; i++) {\r\n this.data.push(new Float64Array(nColumns));\r\n }\r\n } else {\r\n throw new TypeError('nColumns must be a positive integer');\r\n }\r\n } else if (Array.isArray(nRows)) {\r\n // Copy the values from the 2D array\r\n const arrayData = nRows;\r\n nRows = arrayData.length;\r\n nColumns = arrayData[0].length;\r\n if (typeof nColumns !== 'number' || nColumns === 0) {\r\n throw new TypeError(\r\n 'Data must be a 2D array with at least one element',\r\n );\r\n }\r\n this.data = [];\r\n for (let i = 0; i < nRows; i++) {\r\n if (arrayData[i].length !== nColumns) {\r\n throw new RangeError('Inconsistent array dimensions');\r\n }\r\n this.data.push(Float64Array.from(arrayData[i]));\r\n }\r\n } else {\r\n throw new TypeError(\r\n 'First argument must be a positive number or an array',\r\n );\r\n }\r\n this.rows = nRows;\r\n this.columns = nColumns;\r\n return this;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.data[rowIndex][columnIndex] = value;\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.data[rowIndex][columnIndex];\r\n }\r\n\r\n removeRow(index) {\r\n checkRowIndex(this, index);\r\n if (this.rows === 1) {\r\n throw new RangeError('A matrix cannot have less than one row');\r\n }\r\n this.data.splice(index, 1);\r\n this.rows -= 1;\r\n return this;\r\n }\r\n\r\n addRow(index, array) {\r\n if (array === undefined) {\r\n array = index;\r\n index = this.rows;\r\n }\r\n checkRowIndex(this, index, true);\r\n array = Float64Array.from(checkRowVector(this, array, true));\r\n this.data.splice(index, 0, array);\r\n this.rows += 1;\r\n return this;\r\n }\r\n\r\n removeColumn(index) {\r\n checkColumnIndex(this, index);\r\n if (this.columns === 1) {\r\n throw new RangeError('A matrix cannot have less than one column');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n const newRow = new Float64Array(this.columns - 1);\r\n for (let j = 0; j < index; j++) {\r\n newRow[j] = this.data[i][j];\r\n }\r\n for (let j = index + 1; j < this.columns; j++) {\r\n newRow[j - 1] = this.data[i][j];\r\n }\r\n this.data[i] = newRow;\r\n }\r\n this.columns -= 1;\r\n return this;\r\n }\r\n\r\n addColumn(index, array) {\r\n if (typeof array === 'undefined') {\r\n array = index;\r\n index = this.columns;\r\n }\r\n checkColumnIndex(this, index, true);\r\n array = checkColumnVector(this, array);\r\n for (let i = 0; i < this.rows; i++) {\r\n const newRow = new Float64Array(this.columns + 1);\r\n let j = 0;\r\n for (; j < index; j++) {\r\n newRow[j] = this.data[i][j];\r\n }\r\n newRow[j++] = array[i];\r\n for (; j < this.columns + 1; j++) {\r\n newRow[j] = this.data[i][j - 1];\r\n }\r\n this.data[i] = newRow;\r\n }\r\n this.columns += 1;\r\n return this;\r\n }\r\n}\r\n\r\ninstallMathOperations(AbstractMatrix, Matrix);\r\n","import { AbstractMatrix } from '../matrix';\r\n\r\nexport default class BaseView extends AbstractMatrix {\r\n constructor(matrix, rows, columns) {\r\n super();\r\n this.matrix = matrix;\r\n this.rows = rows;\r\n this.columns = columns;\r\n }\r\n}\r\n","import { checkColumnIndex } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixColumnView extends BaseView {\r\n constructor(matrix, column) {\r\n checkColumnIndex(matrix, column);\r\n super(matrix, matrix.rows, 1);\r\n this.column = column;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(rowIndex, this.column, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex) {\r\n return this.matrix.get(rowIndex, this.column);\r\n }\r\n}\r\n","import { checkColumnIndices } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixColumnSelectionView extends BaseView {\r\n constructor(matrix, columnIndices) {\r\n columnIndices = checkColumnIndices(matrix, columnIndices);\r\n super(matrix, matrix.rows, columnIndices.length);\r\n this.columnIndices = columnIndices;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(rowIndex, this.columnIndices[columnIndex], value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(rowIndex, this.columnIndices[columnIndex]);\r\n }\r\n}\r\n","import BaseView from './base';\r\n\r\nexport default class MatrixFlipColumnView extends BaseView {\r\n constructor(matrix) {\r\n super(matrix, matrix.rows, matrix.columns);\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(rowIndex, this.columns - columnIndex - 1, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(rowIndex, this.columns - columnIndex - 1);\r\n }\r\n}\r\n","import BaseView from './base';\r\n\r\nexport default class MatrixFlipRowView extends BaseView {\r\n constructor(matrix) {\r\n super(matrix, matrix.rows, matrix.columns);\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(this.rows - rowIndex - 1, columnIndex, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(this.rows - rowIndex - 1, columnIndex);\r\n }\r\n}\r\n","import { checkRowIndex } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixRowView extends BaseView {\r\n constructor(matrix, row) {\r\n checkRowIndex(matrix, row);\r\n super(matrix, 1, matrix.columns);\r\n this.row = row;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(this.row, columnIndex, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(this.row, columnIndex);\r\n }\r\n}\r\n","import { checkRowIndices } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixRowSelectionView extends BaseView {\r\n constructor(matrix, rowIndices) {\r\n rowIndices = checkRowIndices(matrix, rowIndices);\r\n super(matrix, rowIndices.length, matrix.columns);\r\n this.rowIndices = rowIndices;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(this.rowIndices[rowIndex], columnIndex, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(this.rowIndices[rowIndex], columnIndex);\r\n }\r\n}\r\n","import { checkIndices } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixSelectionView extends BaseView {\r\n constructor(matrix, rowIndices, columnIndices) {\r\n let indices = checkIndices(matrix, rowIndices, columnIndices);\r\n super(matrix, indices.row.length, indices.column.length);\r\n this.rowIndices = indices.row;\r\n this.columnIndices = indices.column;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(\r\n this.rowIndices[rowIndex],\r\n this.columnIndices[columnIndex],\r\n value,\r\n );\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(\r\n this.rowIndices[rowIndex],\r\n this.columnIndices[columnIndex],\r\n );\r\n }\r\n}\r\n","import { checkRange } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixSubView extends BaseView {\r\n constructor(matrix, startRow, endRow, startColumn, endColumn) {\r\n checkRange(matrix, startRow, endRow, startColumn, endColumn);\r\n super(matrix, endRow - startRow + 1, endColumn - startColumn + 1);\r\n this.startRow = startRow;\r\n this.startColumn = startColumn;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(\r\n this.startRow + rowIndex,\r\n this.startColumn + columnIndex,\r\n value,\r\n );\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(\r\n this.startRow + rowIndex,\r\n this.startColumn + columnIndex,\r\n );\r\n }\r\n}\r\n","import BaseView from './base';\r\n\r\nexport default class MatrixTransposeView extends BaseView {\r\n constructor(matrix) {\r\n super(matrix, matrix.columns, matrix.rows);\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(columnIndex, rowIndex, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(columnIndex, rowIndex);\r\n }\r\n}\r\n","import { AbstractMatrix } from '../matrix';\r\n\r\nexport default class WrapperMatrix1D extends AbstractMatrix {\r\n constructor(data, options = {}) {\r\n const { rows = 1 } = options;\r\n\r\n if (data.length % rows !== 0) {\r\n throw new Error('the data length is not divisible by the number of rows');\r\n }\r\n super();\r\n this.rows = rows;\r\n this.columns = data.length / rows;\r\n this.data = data;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n let index = this._calculateIndex(rowIndex, columnIndex);\r\n this.data[index] = value;\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n let index = this._calculateIndex(rowIndex, columnIndex);\r\n return this.data[index];\r\n }\r\n\r\n _calculateIndex(row, column) {\r\n return row * this.columns + column;\r\n }\r\n}\r\n","import { AbstractMatrix } from '../matrix';\r\n\r\nexport default class WrapperMatrix2D extends AbstractMatrix {\r\n constructor(data) {\r\n super();\r\n this.data = data;\r\n this.rows = data.length;\r\n this.columns = data[0].length;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.data[rowIndex][columnIndex] = value;\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.data[rowIndex][columnIndex];\r\n }\r\n}\r\n","import WrapperMatrix1D from './WrapperMatrix1D';\r\nimport WrapperMatrix2D from './WrapperMatrix2D';\r\n\r\nexport function wrap(array, options) {\r\n if (Array.isArray(array)) {\r\n if (array[0] && Array.isArray(array[0])) {\r\n return new WrapperMatrix2D(array);\r\n } else {\r\n return new WrapperMatrix1D(array, options);\r\n }\r\n } else {\r\n throw new Error('the argument is not an array');\r\n }\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nexport default class LuDecomposition {\r\n constructor(matrix) {\r\n matrix = WrapperMatrix2D.checkMatrix(matrix);\r\n\r\n let lu = matrix.clone();\r\n let rows = lu.rows;\r\n let columns = lu.columns;\r\n let pivotVector = new Float64Array(rows);\r\n let pivotSign = 1;\r\n let i, j, k, p, s, t, v;\r\n let LUcolj, kmax;\r\n\r\n for (i = 0; i < rows; i++) {\r\n pivotVector[i] = i;\r\n }\r\n\r\n LUcolj = new Float64Array(rows);\r\n\r\n for (j = 0; j < columns; j++) {\r\n for (i = 0; i < rows; i++) {\r\n LUcolj[i] = lu.get(i, j);\r\n }\r\n\r\n for (i = 0; i < rows; i++) {\r\n kmax = Math.min(i, j);\r\n s = 0;\r\n for (k = 0; k < kmax; k++) {\r\n s += lu.get(i, k) * LUcolj[k];\r\n }\r\n LUcolj[i] -= s;\r\n lu.set(i, j, LUcolj[i]);\r\n }\r\n\r\n p = j;\r\n for (i = j + 1; i < rows; i++) {\r\n if (Math.abs(LUcolj[i]) > Math.abs(LUcolj[p])) {\r\n p = i;\r\n }\r\n }\r\n\r\n if (p !== j) {\r\n for (k = 0; k < columns; k++) {\r\n t = lu.get(p, k);\r\n lu.set(p, k, lu.get(j, k));\r\n lu.set(j, k, t);\r\n }\r\n\r\n v = pivotVector[p];\r\n pivotVector[p] = pivotVector[j];\r\n pivotVector[j] = v;\r\n\r\n pivotSign = -pivotSign;\r\n }\r\n\r\n if (j < rows && lu.get(j, j) !== 0) {\r\n for (i = j + 1; i < rows; i++) {\r\n lu.set(i, j, lu.get(i, j) / lu.get(j, j));\r\n }\r\n }\r\n }\r\n\r\n this.LU = lu;\r\n this.pivotVector = pivotVector;\r\n this.pivotSign = pivotSign;\r\n }\r\n\r\n isSingular() {\r\n let data = this.LU;\r\n let col = data.columns;\r\n for (let j = 0; j < col; j++) {\r\n if (data.get(j, j) === 0) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n solve(value) {\r\n value = Matrix.checkMatrix(value);\r\n\r\n let lu = this.LU;\r\n let rows = lu.rows;\r\n\r\n if (rows !== value.rows) {\r\n throw new Error('Invalid matrix dimensions');\r\n }\r\n if (this.isSingular()) {\r\n throw new Error('LU matrix is singular');\r\n }\r\n\r\n let count = value.columns;\r\n let X = value.subMatrixRow(this.pivotVector, 0, count - 1);\r\n let columns = lu.columns;\r\n let i, j, k;\r\n\r\n for (k = 0; k < columns; k++) {\r\n for (i = k + 1; i < columns; i++) {\r\n for (j = 0; j < count; j++) {\r\n X.set(i, j, X.get(i, j) - X.get(k, j) * lu.get(i, k));\r\n }\r\n }\r\n }\r\n for (k = columns - 1; k >= 0; k--) {\r\n for (j = 0; j < count; j++) {\r\n X.set(k, j, X.get(k, j) / lu.get(k, k));\r\n }\r\n for (i = 0; i < k; i++) {\r\n for (j = 0; j < count; j++) {\r\n X.set(i, j, X.get(i, j) - X.get(k, j) * lu.get(i, k));\r\n }\r\n }\r\n }\r\n return X;\r\n }\r\n\r\n get determinant() {\r\n let data = this.LU;\r\n if (!data.isSquare()) {\r\n throw new Error('Matrix must be square');\r\n }\r\n let determinant = this.pivotSign;\r\n let col = data.columns;\r\n for (let j = 0; j < col; j++) {\r\n determinant *= data.get(j, j);\r\n }\r\n return determinant;\r\n }\r\n\r\n get lowerTriangularMatrix() {\r\n let data = this.LU;\r\n let rows = data.rows;\r\n let columns = data.columns;\r\n let X = new Matrix(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n if (i > j) {\r\n X.set(i, j, data.get(i, j));\r\n } else if (i === j) {\r\n X.set(i, j, 1);\r\n } else {\r\n X.set(i, j, 0);\r\n }\r\n }\r\n }\r\n return X;\r\n }\r\n\r\n get upperTriangularMatrix() {\r\n let data = this.LU;\r\n let rows = data.rows;\r\n let columns = data.columns;\r\n let X = new Matrix(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n if (i <= j) {\r\n X.set(i, j, data.get(i, j));\r\n } else {\r\n X.set(i, j, 0);\r\n }\r\n }\r\n }\r\n return X;\r\n }\r\n\r\n get pivotPermutationVector() {\r\n return Array.from(this.pivotVector);\r\n }\r\n}\r\n","export function hypotenuse(a, b) {\r\n let r = 0;\r\n if (Math.abs(a) > Math.abs(b)) {\r\n r = b / a;\r\n return Math.abs(a) * Math.sqrt(1 + r * r);\r\n }\r\n if (b !== 0) {\r\n r = a / b;\r\n return Math.abs(b) * Math.sqrt(1 + r * r);\r\n }\r\n return 0;\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nimport { hypotenuse } from './util';\r\n\r\nexport default class QrDecomposition {\r\n constructor(value) {\r\n value = WrapperMatrix2D.checkMatrix(value);\r\n\r\n let qr = value.clone();\r\n let m = value.rows;\r\n let n = value.columns;\r\n let rdiag = new Float64Array(n);\r\n let i, j, k, s;\r\n\r\n for (k = 0; k < n; k++) {\r\n let nrm = 0;\r\n for (i = k; i < m; i++) {\r\n nrm = hypotenuse(nrm, qr.get(i, k));\r\n }\r\n if (nrm !== 0) {\r\n if (qr.get(k, k) < 0) {\r\n nrm = -nrm;\r\n }\r\n for (i = k; i < m; i++) {\r\n qr.set(i, k, qr.get(i, k) / nrm);\r\n }\r\n qr.set(k, k, qr.get(k, k) + 1);\r\n for (j = k + 1; j < n; j++) {\r\n s = 0;\r\n for (i = k; i < m; i++) {\r\n s += qr.get(i, k) * qr.get(i, j);\r\n }\r\n s = -s / qr.get(k, k);\r\n for (i = k; i < m; i++) {\r\n qr.set(i, j, qr.get(i, j) + s * qr.get(i, k));\r\n }\r\n }\r\n }\r\n rdiag[k] = -nrm;\r\n }\r\n\r\n this.QR = qr;\r\n this.Rdiag = rdiag;\r\n }\r\n\r\n solve(value) {\r\n value = Matrix.checkMatrix(value);\r\n\r\n let qr = this.QR;\r\n let m = qr.rows;\r\n\r\n if (value.rows !== m) {\r\n throw new Error('Matrix row dimensions must agree');\r\n }\r\n if (!this.isFullRank()) {\r\n throw new Error('Matrix is rank deficient');\r\n }\r\n\r\n let count = value.columns;\r\n let X = value.clone();\r\n let n = qr.columns;\r\n let i, j, k, s;\r\n\r\n for (k = 0; k < n; k++) {\r\n for (j = 0; j < count; j++) {\r\n s = 0;\r\n for (i = k; i < m; i++) {\r\n s += qr.get(i, k) * X.get(i, j);\r\n }\r\n s = -s / qr.get(k, k);\r\n for (i = k; i < m; i++) {\r\n X.set(i, j, X.get(i, j) + s * qr.get(i, k));\r\n }\r\n }\r\n }\r\n for (k = n - 1; k >= 0; k--) {\r\n for (j = 0; j < count; j++) {\r\n X.set(k, j, X.get(k, j) / this.Rdiag[k]);\r\n }\r\n for (i = 0; i < k; i++) {\r\n for (j = 0; j < count; j++) {\r\n X.set(i, j, X.get(i, j) - X.get(k, j) * qr.get(i, k));\r\n }\r\n }\r\n }\r\n\r\n return X.subMatrix(0, n - 1, 0, count - 1);\r\n }\r\n\r\n isFullRank() {\r\n let columns = this.QR.columns;\r\n for (let i = 0; i < columns; i++) {\r\n if (this.Rdiag[i] === 0) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n get upperTriangularMatrix() {\r\n let qr = this.QR;\r\n let n = qr.columns;\r\n let X = new Matrix(n, n);\r\n let i, j;\r\n for (i = 0; i < n; i++) {\r\n for (j = 0; j < n; j++) {\r\n if (i < j) {\r\n X.set(i, j, qr.get(i, j));\r\n } else if (i === j) {\r\n X.set(i, j, this.Rdiag[i]);\r\n } else {\r\n X.set(i, j, 0);\r\n }\r\n }\r\n }\r\n return X;\r\n }\r\n\r\n get orthogonalMatrix() {\r\n let qr = this.QR;\r\n let rows = qr.rows;\r\n let columns = qr.columns;\r\n let X = new Matrix(rows, columns);\r\n let i, j, k, s;\r\n\r\n for (k = columns - 1; k >= 0; k--) {\r\n for (i = 0; i < rows; i++) {\r\n X.set(i, k, 0);\r\n }\r\n X.set(k, k, 1);\r\n for (j = k; j < columns; j++) {\r\n if (qr.get(k, k) !== 0) {\r\n s = 0;\r\n for (i = k; i < rows; i++) {\r\n s += qr.get(i, k) * X.get(i, j);\r\n }\r\n\r\n s = -s / qr.get(k, k);\r\n\r\n for (i = k; i < rows; i++) {\r\n X.set(i, j, X.get(i, j) + s * qr.get(i, k));\r\n }\r\n }\r\n }\r\n }\r\n return X;\r\n }\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nimport { hypotenuse } from './util';\r\n\r\nexport default class SingularValueDecomposition {\r\n constructor(value, options = {}) {\r\n value = WrapperMatrix2D.checkMatrix(value);\r\n\r\n let m = value.rows;\r\n let n = value.columns;\r\n\r\n const {\r\n computeLeftSingularVectors = true,\r\n computeRightSingularVectors = true,\r\n autoTranspose = false,\r\n } = options;\r\n\r\n let wantu = Boolean(computeLeftSingularVectors);\r\n let wantv = Boolean(computeRightSingularVectors);\r\n\r\n let swapped = false;\r\n let a;\r\n if (m < n) {\r\n if (!autoTranspose) {\r\n a = value.clone();\r\n // eslint-disable-next-line no-console\r\n console.warn(\r\n 'Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose',\r\n );\r\n } else {\r\n a = value.transpose();\r\n m = a.rows;\r\n n = a.columns;\r\n swapped = true;\r\n let aux = wantu;\r\n wantu = wantv;\r\n wantv = aux;\r\n }\r\n } else {\r\n a = value.clone();\r\n }\r\n\r\n let nu = Math.min(m, n);\r\n let ni = Math.min(m + 1, n);\r\n let s = new Float64Array(ni);\r\n let U = new Matrix(m, nu);\r\n let V = new Matrix(n, n);\r\n\r\n let e = new Float64Array(n);\r\n let work = new Float64Array(m);\r\n\r\n let si = new Float64Array(ni);\r\n for (let i = 0; i < ni; i++) si[i] = i;\r\n\r\n let nct = Math.min(m - 1, n);\r\n let nrt = Math.max(0, Math.min(n - 2, m));\r\n let mrc = Math.max(nct, nrt);\r\n\r\n for (let k = 0; k < mrc; k++) {\r\n if (k < nct) {\r\n s[k] = 0;\r\n for (let i = k; i < m; i++) {\r\n s[k] = hypotenuse(s[k], a.get(i, k));\r\n }\r\n if (s[k] !== 0) {\r\n if (a.get(k, k) < 0) {\r\n s[k] = -s[k];\r\n }\r\n for (let i = k; i < m; i++) {\r\n a.set(i, k, a.get(i, k) / s[k]);\r\n }\r\n a.set(k, k, a.get(k, k) + 1);\r\n }\r\n s[k] = -s[k];\r\n }\r\n\r\n for (let j = k + 1; j < n; j++) {\r\n if (k < nct && s[k] !== 0) {\r\n let t = 0;\r\n for (let i = k; i < m; i++) {\r\n t += a.get(i, k) * a.get(i, j);\r\n }\r\n t = -t / a.get(k, k);\r\n for (let i = k; i < m; i++) {\r\n a.set(i, j, a.get(i, j) + t * a.get(i, k));\r\n }\r\n }\r\n e[j] = a.get(k, j);\r\n }\r\n\r\n if (wantu && k < nct) {\r\n for (let i = k; i < m; i++) {\r\n U.set(i, k, a.get(i, k));\r\n }\r\n }\r\n\r\n if (k < nrt) {\r\n e[k] = 0;\r\n for (let i = k + 1; i < n; i++) {\r\n e[k] = hypotenuse(e[k], e[i]);\r\n }\r\n if (e[k] !== 0) {\r\n if (e[k + 1] < 0) {\r\n e[k] = 0 - e[k];\r\n }\r\n for (let i = k + 1; i < n; i++) {\r\n e[i] /= e[k];\r\n }\r\n e[k + 1] += 1;\r\n }\r\n e[k] = -e[k];\r\n if (k + 1 < m && e[k] !== 0) {\r\n for (let i = k + 1; i < m; i++) {\r\n work[i] = 0;\r\n }\r\n for (let i = k + 1; i < m; i++) {\r\n for (let j = k + 1; j < n; j++) {\r\n work[i] += e[j] * a.get(i, j);\r\n }\r\n }\r\n for (let j = k + 1; j < n; j++) {\r\n let t = -e[j] / e[k + 1];\r\n for (let i = k + 1; i < m; i++) {\r\n a.set(i, j, a.get(i, j) + t * work[i]);\r\n }\r\n }\r\n }\r\n if (wantv) {\r\n for (let i = k + 1; i < n; i++) {\r\n V.set(i, k, e[i]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n let p = Math.min(n, m + 1);\r\n if (nct < n) {\r\n s[nct] = a.get(nct, nct);\r\n }\r\n if (m < p) {\r\n s[p - 1] = 0;\r\n }\r\n if (nrt + 1 < p) {\r\n e[nrt] = a.get(nrt, p - 1);\r\n }\r\n e[p - 1] = 0;\r\n\r\n if (wantu) {\r\n for (let j = nct; j < nu; j++) {\r\n for (let i = 0; i < m; i++) {\r\n U.set(i, j, 0);\r\n }\r\n U.set(j, j, 1);\r\n }\r\n for (let k = nct - 1; k >= 0; k--) {\r\n if (s[k] !== 0) {\r\n for (let j = k + 1; j < nu; j++) {\r\n let t = 0;\r\n for (let i = k; i < m; i++) {\r\n t += U.get(i, k) * U.get(i, j);\r\n }\r\n t = -t / U.get(k, k);\r\n for (let i = k; i < m; i++) {\r\n U.set(i, j, U.get(i, j) + t * U.get(i, k));\r\n }\r\n }\r\n for (let i = k; i < m; i++) {\r\n U.set(i, k, -U.get(i, k));\r\n }\r\n U.set(k, k, 1 + U.get(k, k));\r\n for (let i = 0; i < k - 1; i++) {\r\n U.set(i, k, 0);\r\n }\r\n } else {\r\n for (let i = 0; i < m; i++) {\r\n U.set(i, k, 0);\r\n }\r\n U.set(k, k, 1);\r\n }\r\n }\r\n }\r\n\r\n if (wantv) {\r\n for (let k = n - 1; k >= 0; k--) {\r\n if (k < nrt && e[k] !== 0) {\r\n for (let j = k + 1; j < n; j++) {\r\n let t = 0;\r\n for (let i = k + 1; i < n; i++) {\r\n t += V.get(i, k) * V.get(i, j);\r\n }\r\n t = -t / V.get(k + 1, k);\r\n for (let i = k + 1; i < n; i++) {\r\n V.set(i, j, V.get(i, j) + t * V.get(i, k));\r\n }\r\n }\r\n }\r\n for (let i = 0; i < n; i++) {\r\n V.set(i, k, 0);\r\n }\r\n V.set(k, k, 1);\r\n }\r\n }\r\n\r\n let pp = p - 1;\r\n let iter = 0;\r\n let eps = Number.EPSILON;\r\n while (p > 0) {\r\n let k, kase;\r\n for (k = p - 2; k >= -1; k--) {\r\n if (k === -1) {\r\n break;\r\n }\r\n const alpha =\r\n Number.MIN_VALUE + eps * Math.abs(s[k] + Math.abs(s[k + 1]));\r\n if (Math.abs(e[k]) <= alpha || Number.isNaN(e[k])) {\r\n e[k] = 0;\r\n break;\r\n }\r\n }\r\n if (k === p - 2) {\r\n kase = 4;\r\n } else {\r\n let ks;\r\n for (ks = p - 1; ks >= k; ks--) {\r\n if (ks === k) {\r\n break;\r\n }\r\n let t =\r\n (ks !== p ? Math.abs(e[ks]) : 0) +\r\n (ks !== k + 1 ? Math.abs(e[ks - 1]) : 0);\r\n if (Math.abs(s[ks]) <= eps * t) {\r\n s[ks] = 0;\r\n break;\r\n }\r\n }\r\n if (ks === k) {\r\n kase = 3;\r\n } else if (ks === p - 1) {\r\n kase = 1;\r\n } else {\r\n kase = 2;\r\n k = ks;\r\n }\r\n }\r\n\r\n k++;\r\n\r\n switch (kase) {\r\n case 1: {\r\n let f = e[p - 2];\r\n e[p - 2] = 0;\r\n for (let j = p - 2; j >= k; j--) {\r\n let t = hypotenuse(s[j], f);\r\n let cs = s[j] / t;\r\n let sn = f / t;\r\n s[j] = t;\r\n if (j !== k) {\r\n f = -sn * e[j - 1];\r\n e[j - 1] = cs * e[j - 1];\r\n }\r\n if (wantv) {\r\n for (let i = 0; i < n; i++) {\r\n t = cs * V.get(i, j) + sn * V.get(i, p - 1);\r\n V.set(i, p - 1, -sn * V.get(i, j) + cs * V.get(i, p - 1));\r\n V.set(i, j, t);\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n case 2: {\r\n let f = e[k - 1];\r\n e[k - 1] = 0;\r\n for (let j = k; j < p; j++) {\r\n let t = hypotenuse(s[j], f);\r\n let cs = s[j] / t;\r\n let sn = f / t;\r\n s[j] = t;\r\n f = -sn * e[j];\r\n e[j] = cs * e[j];\r\n if (wantu) {\r\n for (let i = 0; i < m; i++) {\r\n t = cs * U.get(i, j) + sn * U.get(i, k - 1);\r\n U.set(i, k - 1, -sn * U.get(i, j) + cs * U.get(i, k - 1));\r\n U.set(i, j, t);\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n case 3: {\r\n const scale = Math.max(\r\n Math.abs(s[p - 1]),\r\n Math.abs(s[p - 2]),\r\n Math.abs(e[p - 2]),\r\n Math.abs(s[k]),\r\n Math.abs(e[k]),\r\n );\r\n const sp = s[p - 1] / scale;\r\n const spm1 = s[p - 2] / scale;\r\n const epm1 = e[p - 2] / scale;\r\n const sk = s[k] / scale;\r\n const ek = e[k] / scale;\r\n const b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2;\r\n const c = sp * epm1 * (sp * epm1);\r\n let shift = 0;\r\n if (b !== 0 || c !== 0) {\r\n if (b < 0) {\r\n shift = 0 - Math.sqrt(b * b + c);\r\n } else {\r\n shift = Math.sqrt(b * b + c);\r\n }\r\n shift = c / (b + shift);\r\n }\r\n let f = (sk + sp) * (sk - sp) + shift;\r\n let g = sk * ek;\r\n for (let j = k; j < p - 1; j++) {\r\n let t = hypotenuse(f, g);\r\n if (t === 0) t = Number.MIN_VALUE;\r\n let cs = f / t;\r\n let sn = g / t;\r\n if (j !== k) {\r\n e[j - 1] = t;\r\n }\r\n f = cs * s[j] + sn * e[j];\r\n e[j] = cs * e[j] - sn * s[j];\r\n g = sn * s[j + 1];\r\n s[j + 1] = cs * s[j + 1];\r\n if (wantv) {\r\n for (let i = 0; i < n; i++) {\r\n t = cs * V.get(i, j) + sn * V.get(i, j + 1);\r\n V.set(i, j + 1, -sn * V.get(i, j) + cs * V.get(i, j + 1));\r\n V.set(i, j, t);\r\n }\r\n }\r\n t = hypotenuse(f, g);\r\n if (t === 0) t = Number.MIN_VALUE;\r\n cs = f / t;\r\n sn = g / t;\r\n s[j] = t;\r\n f = cs * e[j] + sn * s[j + 1];\r\n s[j + 1] = -sn * e[j] + cs * s[j + 1];\r\n g = sn * e[j + 1];\r\n e[j + 1] = cs * e[j + 1];\r\n if (wantu && j < m - 1) {\r\n for (let i = 0; i < m; i++) {\r\n t = cs * U.get(i, j) + sn * U.get(i, j + 1);\r\n U.set(i, j + 1, -sn * U.get(i, j) + cs * U.get(i, j + 1));\r\n U.set(i, j, t);\r\n }\r\n }\r\n }\r\n e[p - 2] = f;\r\n iter = iter + 1;\r\n break;\r\n }\r\n case 4: {\r\n if (s[k] <= 0) {\r\n s[k] = s[k] < 0 ? -s[k] : 0;\r\n if (wantv) {\r\n for (let i = 0; i <= pp; i++) {\r\n V.set(i, k, -V.get(i, k));\r\n }\r\n }\r\n }\r\n while (k < pp) {\r\n if (s[k] >= s[k + 1]) {\r\n break;\r\n }\r\n let t = s[k];\r\n s[k] = s[k + 1];\r\n s[k + 1] = t;\r\n if (wantv && k < n - 1) {\r\n for (let i = 0; i < n; i++) {\r\n t = V.get(i, k + 1);\r\n V.set(i, k + 1, V.get(i, k));\r\n V.set(i, k, t);\r\n }\r\n }\r\n if (wantu && k < m - 1) {\r\n for (let i = 0; i < m; i++) {\r\n t = U.get(i, k + 1);\r\n U.set(i, k + 1, U.get(i, k));\r\n U.set(i, k, t);\r\n }\r\n }\r\n k++;\r\n }\r\n iter = 0;\r\n p--;\r\n break;\r\n }\r\n // no default\r\n }\r\n }\r\n\r\n if (swapped) {\r\n let tmp = V;\r\n V = U;\r\n U = tmp;\r\n }\r\n\r\n this.m = m;\r\n this.n = n;\r\n this.s = s;\r\n this.U = U;\r\n this.V = V;\r\n }\r\n\r\n solve(value) {\r\n let Y = value;\r\n let e = this.threshold;\r\n let scols = this.s.length;\r\n let Ls = Matrix.zeros(scols, scols);\r\n\r\n for (let i = 0; i < scols; i++) {\r\n if (Math.abs(this.s[i]) <= e) {\r\n Ls.set(i, i, 0);\r\n } else {\r\n Ls.set(i, i, 1 / this.s[i]);\r\n }\r\n }\r\n\r\n let U = this.U;\r\n let V = this.rightSingularVectors;\r\n\r\n let VL = V.mmul(Ls);\r\n let vrows = V.rows;\r\n let urows = U.rows;\r\n let VLU = Matrix.zeros(vrows, urows);\r\n\r\n for (let i = 0; i < vrows; i++) {\r\n for (let j = 0; j < urows; j++) {\r\n let sum = 0;\r\n for (let k = 0; k < scols; k++) {\r\n sum += VL.get(i, k) * U.get(j, k);\r\n }\r\n VLU.set(i, j, sum);\r\n }\r\n }\r\n\r\n return VLU.mmul(Y);\r\n }\r\n\r\n solveForDiagonal(value) {\r\n return this.solve(Matrix.diag(value));\r\n }\r\n\r\n inverse() {\r\n let V = this.V;\r\n let e = this.threshold;\r\n let vrows = V.rows;\r\n let vcols = V.columns;\r\n let X = new Matrix(vrows, this.s.length);\r\n\r\n for (let i = 0; i < vrows; i++) {\r\n for (let j = 0; j < vcols; j++) {\r\n if (Math.abs(this.s[j]) > e) {\r\n X.set(i, j, V.get(i, j) / this.s[j]);\r\n }\r\n }\r\n }\r\n\r\n let U = this.U;\r\n\r\n let urows = U.rows;\r\n let ucols = U.columns;\r\n let Y = new Matrix(vrows, urows);\r\n\r\n for (let i = 0; i < vrows; i++) {\r\n for (let j = 0; j < urows; j++) {\r\n let sum = 0;\r\n for (let k = 0; k < ucols; k++) {\r\n sum += X.get(i, k) * U.get(j, k);\r\n }\r\n Y.set(i, j, sum);\r\n }\r\n }\r\n\r\n return Y;\r\n }\r\n\r\n get condition() {\r\n return this.s[0] / this.s[Math.min(this.m, this.n) - 1];\r\n }\r\n\r\n get norm2() {\r\n return this.s[0];\r\n }\r\n\r\n get rank() {\r\n let tol = Math.max(this.m, this.n) * this.s[0] * Number.EPSILON;\r\n let r = 0;\r\n let s = this.s;\r\n for (let i = 0, ii = s.length; i < ii; i++) {\r\n if (s[i] > tol) {\r\n r++;\r\n }\r\n }\r\n return r;\r\n }\r\n\r\n get diagonal() {\r\n return Array.from(this.s);\r\n }\r\n\r\n get threshold() {\r\n return (Number.EPSILON / 2) * Math.max(this.m, this.n) * this.s[0];\r\n }\r\n\r\n get leftSingularVectors() {\r\n return this.U;\r\n }\r\n\r\n get rightSingularVectors() {\r\n return this.V;\r\n }\r\n\r\n get diagonalMatrix() {\r\n return Matrix.diag(this.s);\r\n }\r\n}\r\n","import LuDecomposition from './dc/lu';\r\nimport QrDecomposition from './dc/qr';\r\nimport SingularValueDecomposition from './dc/svd';\r\nimport Matrix from './matrix';\r\nimport WrapperMatrix2D from './wrap/WrapperMatrix2D';\r\n\r\nexport function inverse(matrix, useSVD = false) {\r\n matrix = WrapperMatrix2D.checkMatrix(matrix);\r\n if (useSVD) {\r\n return new SingularValueDecomposition(matrix).inverse();\r\n } else {\r\n return solve(matrix, Matrix.eye(matrix.rows));\r\n }\r\n}\r\n\r\nexport function solve(leftHandSide, rightHandSide, useSVD = false) {\r\n leftHandSide = WrapperMatrix2D.checkMatrix(leftHandSide);\r\n rightHandSide = WrapperMatrix2D.checkMatrix(rightHandSide);\r\n if (useSVD) {\r\n return new SingularValueDecomposition(leftHandSide).solve(rightHandSide);\r\n } else {\r\n return leftHandSide.isSquare()\r\n ? new LuDecomposition(leftHandSide).solve(rightHandSide)\r\n : new QrDecomposition(leftHandSide).solve(rightHandSide);\r\n }\r\n}\r\n","import LuDecomposition from './dc/lu';\r\nimport Matrix from './matrix';\r\nimport MatrixSelectionView from './views/selection';\r\n\r\nexport function determinant(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (matrix.isSquare()) {\r\n let a, b, c, d;\r\n if (matrix.columns === 2) {\r\n // 2 x 2 matrix\r\n a = matrix.get(0, 0);\r\n b = matrix.get(0, 1);\r\n c = matrix.get(1, 0);\r\n d = matrix.get(1, 1);\r\n\r\n return a * d - b * c;\r\n } else if (matrix.columns === 3) {\r\n // 3 x 3 matrix\r\n let subMatrix0, subMatrix1, subMatrix2;\r\n subMatrix0 = new MatrixSelectionView(matrix, [1, 2], [1, 2]);\r\n subMatrix1 = new MatrixSelectionView(matrix, [1, 2], [0, 2]);\r\n subMatrix2 = new MatrixSelectionView(matrix, [1, 2], [0, 1]);\r\n a = matrix.get(0, 0);\r\n b = matrix.get(0, 1);\r\n c = matrix.get(0, 2);\r\n\r\n return (\r\n a * determinant(subMatrix0) -\r\n b * determinant(subMatrix1) +\r\n c * determinant(subMatrix2)\r\n );\r\n } else {\r\n // general purpose determinant using the LU decomposition\r\n return new LuDecomposition(matrix).determinant;\r\n }\r\n } else {\r\n throw Error('determinant can only be calculated for a square matrix');\r\n }\r\n}\r\n","import SingularValueDecomposition from './dc/svd';\r\nimport Matrix from './matrix';\r\n\r\nfunction xrange(n, exception) {\r\n let range = [];\r\n for (let i = 0; i < n; i++) {\r\n if (i !== exception) {\r\n range.push(i);\r\n }\r\n }\r\n return range;\r\n}\r\n\r\nfunction dependenciesOneRow(\r\n error,\r\n matrix,\r\n index,\r\n thresholdValue = 10e-10,\r\n thresholdError = 10e-10,\r\n) {\r\n if (error > thresholdError) {\r\n return new Array(matrix.rows + 1).fill(0);\r\n } else {\r\n let returnArray = matrix.addRow(index, [0]);\r\n for (let i = 0; i < returnArray.rows; i++) {\r\n if (Math.abs(returnArray.get(i, 0)) < thresholdValue) {\r\n returnArray.set(i, 0, 0);\r\n }\r\n }\r\n return returnArray.to1DArray();\r\n }\r\n}\r\n\r\nexport function linearDependencies(matrix, options = {}) {\r\n const { thresholdValue = 10e-10, thresholdError = 10e-10 } = options;\r\n matrix = Matrix.checkMatrix(matrix);\r\n\r\n let n = matrix.rows;\r\n let results = new Matrix(n, n);\r\n\r\n for (let i = 0; i < n; i++) {\r\n let b = Matrix.columnVector(matrix.getRow(i));\r\n let Abis = matrix.subMatrixRow(xrange(n, i)).transpose();\r\n let svd = new SingularValueDecomposition(Abis);\r\n let x = svd.solve(b);\r\n let error = Matrix.sub(b, Abis.mmul(x)).abs().max();\r\n results.setRow(\r\n i,\r\n dependenciesOneRow(error, x, i, thresholdValue, thresholdError),\r\n );\r\n }\r\n return results;\r\n}\r\n","import SVD from './dc/svd';\r\nimport Matrix from './matrix';\r\n\r\nexport function pseudoInverse(matrix, threshold = Number.EPSILON) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n let svdSolution = new SVD(matrix, { autoTranspose: true });\r\n\r\n let U = svdSolution.leftSingularVectors;\r\n let V = svdSolution.rightSingularVectors;\r\n let s = svdSolution.diagonal;\r\n\r\n for (let i = 0; i < s.length; i++) {\r\n if (Math.abs(s[i]) > threshold) {\r\n s[i] = 1.0 / s[i];\r\n } else {\r\n s[i] = 0.0;\r\n }\r\n }\r\n\r\n return V.mmul(Matrix.diag(s).mmul(U.transpose()));\r\n}\r\n","import Matrix from './matrix';\r\n\r\nexport function covariance(xMatrix, yMatrix = xMatrix, options = {}) {\r\n xMatrix = new Matrix(xMatrix);\r\n let yIsSame = false;\r\n if (\r\n typeof yMatrix === 'object' &&\r\n !Matrix.isMatrix(yMatrix) &&\r\n !Array.isArray(yMatrix)\r\n ) {\r\n options = yMatrix;\r\n yMatrix = xMatrix;\r\n yIsSame = true;\r\n } else {\r\n yMatrix = new Matrix(yMatrix);\r\n }\r\n if (xMatrix.rows !== yMatrix.rows) {\r\n throw new TypeError('Both matrices must have the same number of rows');\r\n }\r\n const { center = true } = options;\r\n if (center) {\r\n xMatrix = xMatrix.center('column');\r\n if (!yIsSame) {\r\n yMatrix = yMatrix.center('column');\r\n }\r\n }\r\n const cov = xMatrix.transpose().mmul(yMatrix);\r\n for (let i = 0; i < cov.rows; i++) {\r\n for (let j = 0; j < cov.columns; j++) {\r\n cov.set(i, j, cov.get(i, j) * (1 / (xMatrix.rows - 1)));\r\n }\r\n }\r\n return cov;\r\n}\r\n","import Matrix from './matrix';\r\n\r\nexport function correlation(xMatrix, yMatrix = xMatrix, options = {}) {\r\n xMatrix = new Matrix(xMatrix);\r\n let yIsSame = false;\r\n if (\r\n typeof yMatrix === 'object' &&\r\n !Matrix.isMatrix(yMatrix) &&\r\n !Array.isArray(yMatrix)\r\n ) {\r\n options = yMatrix;\r\n yMatrix = xMatrix;\r\n yIsSame = true;\r\n } else {\r\n yMatrix = new Matrix(yMatrix);\r\n }\r\n if (xMatrix.rows !== yMatrix.rows) {\r\n throw new TypeError('Both matrices must have the same number of rows');\r\n }\r\n\r\n const { center = true, scale = true } = options;\r\n if (center) {\r\n xMatrix.center('column');\r\n if (!yIsSame) {\r\n yMatrix.center('column');\r\n }\r\n }\r\n if (scale) {\r\n xMatrix.scale('column');\r\n if (!yIsSame) {\r\n yMatrix.scale('column');\r\n }\r\n }\r\n\r\n const sdx = xMatrix.standardDeviation('column', { unbiased: true });\r\n const sdy = yIsSame\r\n ? sdx\r\n : yMatrix.standardDeviation('column', { unbiased: true });\r\n\r\n const corr = xMatrix.transpose().mmul(yMatrix);\r\n for (let i = 0; i < corr.rows; i++) {\r\n for (let j = 0; j < corr.columns; j++) {\r\n corr.set(\r\n i,\r\n j,\r\n corr.get(i, j) * (1 / (sdx[i] * sdy[j])) * (1 / (xMatrix.rows - 1)),\r\n );\r\n }\r\n }\r\n return corr;\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nimport { hypotenuse } from './util';\r\n\r\nexport default class EigenvalueDecomposition {\r\n constructor(matrix, options = {}) {\r\n const { assumeSymmetric = false } = options;\r\n\r\n matrix = WrapperMatrix2D.checkMatrix(matrix);\r\n if (!matrix.isSquare()) {\r\n throw new Error('Matrix is not a square matrix');\r\n }\r\n\r\n let n = matrix.columns;\r\n let V = new Matrix(n, n);\r\n let d = new Float64Array(n);\r\n let e = new Float64Array(n);\r\n let value = matrix;\r\n let i, j;\r\n\r\n let isSymmetric = false;\r\n if (assumeSymmetric) {\r\n isSymmetric = true;\r\n } else {\r\n isSymmetric = matrix.isSymmetric();\r\n }\r\n\r\n if (isSymmetric) {\r\n for (i = 0; i < n; i++) {\r\n for (j = 0; j < n; j++) {\r\n V.set(i, j, value.get(i, j));\r\n }\r\n }\r\n tred2(n, e, d, V);\r\n tql2(n, e, d, V);\r\n } else {\r\n let H = new Matrix(n, n);\r\n let ort = new Float64Array(n);\r\n for (j = 0; j < n; j++) {\r\n for (i = 0; i < n; i++) {\r\n H.set(i, j, value.get(i, j));\r\n }\r\n }\r\n orthes(n, H, ort, V);\r\n hqr2(n, e, d, V, H);\r\n }\r\n\r\n this.n = n;\r\n this.e = e;\r\n this.d = d;\r\n this.V = V;\r\n }\r\n\r\n get realEigenvalues() {\r\n return Array.from(this.d);\r\n }\r\n\r\n get imaginaryEigenvalues() {\r\n return Array.from(this.e);\r\n }\r\n\r\n get eigenvectorMatrix() {\r\n return this.V;\r\n }\r\n\r\n get diagonalMatrix() {\r\n let n = this.n;\r\n let e = this.e;\r\n let d = this.d;\r\n let X = new Matrix(n, n);\r\n let i, j;\r\n for (i = 0; i < n; i++) {\r\n for (j = 0; j < n; j++) {\r\n X.set(i, j, 0);\r\n }\r\n X.set(i, i, d[i]);\r\n if (e[i] > 0) {\r\n X.set(i, i + 1, e[i]);\r\n } else if (e[i] < 0) {\r\n X.set(i, i - 1, e[i]);\r\n }\r\n }\r\n return X;\r\n }\r\n}\r\n\r\nfunction tred2(n, e, d, V) {\r\n let f, g, h, i, j, k, hh, scale;\r\n\r\n for (j = 0; j < n; j++) {\r\n d[j] = V.get(n - 1, j);\r\n }\r\n\r\n for (i = n - 1; i > 0; i--) {\r\n scale = 0;\r\n h = 0;\r\n for (k = 0; k < i; k++) {\r\n scale = scale + Math.abs(d[k]);\r\n }\r\n\r\n if (scale === 0) {\r\n e[i] = d[i - 1];\r\n for (j = 0; j < i; j++) {\r\n d[j] = V.get(i - 1, j);\r\n V.set(i, j, 0);\r\n V.set(j, i, 0);\r\n }\r\n } else {\r\n for (k = 0; k < i; k++) {\r\n d[k] /= scale;\r\n h += d[k] * d[k];\r\n }\r\n\r\n f = d[i - 1];\r\n g = Math.sqrt(h);\r\n if (f > 0) {\r\n g = -g;\r\n }\r\n\r\n e[i] = scale * g;\r\n h = h - f * g;\r\n d[i - 1] = f - g;\r\n for (j = 0; j < i; j++) {\r\n e[j] = 0;\r\n }\r\n\r\n for (j = 0; j < i; j++) {\r\n f = d[j];\r\n V.set(j, i, f);\r\n g = e[j] + V.get(j, j) * f;\r\n for (k = j + 1; k <= i - 1; k++) {\r\n g += V.get(k, j) * d[k];\r\n e[k] += V.get(k, j) * f;\r\n }\r\n e[j] = g;\r\n }\r\n\r\n f = 0;\r\n for (j = 0; j < i; j++) {\r\n e[j] /= h;\r\n f += e[j] * d[j];\r\n }\r\n\r\n hh = f / (h + h);\r\n for (j = 0; j < i; j++) {\r\n e[j] -= hh * d[j];\r\n }\r\n\r\n for (j = 0; j < i; j++) {\r\n f = d[j];\r\n g = e[j];\r\n for (k = j; k <= i - 1; k++) {\r\n V.set(k, j, V.get(k, j) - (f * e[k] + g * d[k]));\r\n }\r\n d[j] = V.get(i - 1, j);\r\n V.set(i, j, 0);\r\n }\r\n }\r\n d[i] = h;\r\n }\r\n\r\n for (i = 0; i < n - 1; i++) {\r\n V.set(n - 1, i, V.get(i, i));\r\n V.set(i, i, 1);\r\n h = d[i + 1];\r\n if (h !== 0) {\r\n for (k = 0; k <= i; k++) {\r\n d[k] = V.get(k, i + 1) / h;\r\n }\r\n\r\n for (j = 0; j <= i; j++) {\r\n g = 0;\r\n for (k = 0; k <= i; k++) {\r\n g += V.get(k, i + 1) * V.get(k, j);\r\n }\r\n for (k = 0; k <= i; k++) {\r\n V.set(k, j, V.get(k, j) - g * d[k]);\r\n }\r\n }\r\n }\r\n\r\n for (k = 0; k <= i; k++) {\r\n V.set(k, i + 1, 0);\r\n }\r\n }\r\n\r\n for (j = 0; j < n; j++) {\r\n d[j] = V.get(n - 1, j);\r\n V.set(n - 1, j, 0);\r\n }\r\n\r\n V.set(n - 1, n - 1, 1);\r\n e[0] = 0;\r\n}\r\n\r\nfunction tql2(n, e, d, V) {\r\n let g, h, i, j, k, l, m, p, r, dl1, c, c2, c3, el1, s, s2, iter;\r\n\r\n for (i = 1; i < n; i++) {\r\n e[i - 1] = e[i];\r\n }\r\n\r\n e[n - 1] = 0;\r\n\r\n let f = 0;\r\n let tst1 = 0;\r\n let eps = Number.EPSILON;\r\n\r\n for (l = 0; l < n; l++) {\r\n tst1 = Math.max(tst1, Math.abs(d[l]) + Math.abs(e[l]));\r\n m = l;\r\n while (m < n) {\r\n if (Math.abs(e[m]) <= eps * tst1) {\r\n break;\r\n }\r\n m++;\r\n }\r\n\r\n if (m > l) {\r\n iter = 0;\r\n do {\r\n iter = iter + 1;\r\n\r\n g = d[l];\r\n p = (d[l + 1] - g) / (2 * e[l]);\r\n r = hypotenuse(p, 1);\r\n if (p < 0) {\r\n r = -r;\r\n }\r\n\r\n d[l] = e[l] / (p + r);\r\n d[l + 1] = e[l] * (p + r);\r\n dl1 = d[l + 1];\r\n h = g - d[l];\r\n for (i = l + 2; i < n; i++) {\r\n d[i] -= h;\r\n }\r\n\r\n f = f + h;\r\n\r\n p = d[m];\r\n c = 1;\r\n c2 = c;\r\n c3 = c;\r\n el1 = e[l + 1];\r\n s = 0;\r\n s2 = 0;\r\n for (i = m - 1; i >= l; i--) {\r\n c3 = c2;\r\n c2 = c;\r\n s2 = s;\r\n g = c * e[i];\r\n h = c * p;\r\n r = hypotenuse(p, e[i]);\r\n e[i + 1] = s * r;\r\n s = e[i] / r;\r\n c = p / r;\r\n p = c * d[i] - s * g;\r\n d[i + 1] = h + s * (c * g + s * d[i]);\r\n\r\n for (k = 0; k < n; k++) {\r\n h = V.get(k, i + 1);\r\n V.set(k, i + 1, s * V.get(k, i) + c * h);\r\n V.set(k, i, c * V.get(k, i) - s * h);\r\n }\r\n }\r\n\r\n p = (-s * s2 * c3 * el1 * e[l]) / dl1;\r\n e[l] = s * p;\r\n d[l] = c * p;\r\n } while (Math.abs(e[l]) > eps * tst1);\r\n }\r\n d[l] = d[l] + f;\r\n e[l] = 0;\r\n }\r\n\r\n for (i = 0; i < n - 1; i++) {\r\n k = i;\r\n p = d[i];\r\n for (j = i + 1; j < n; j++) {\r\n if (d[j] < p) {\r\n k = j;\r\n p = d[j];\r\n }\r\n }\r\n\r\n if (k !== i) {\r\n d[k] = d[i];\r\n d[i] = p;\r\n for (j = 0; j < n; j++) {\r\n p = V.get(j, i);\r\n V.set(j, i, V.get(j, k));\r\n V.set(j, k, p);\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction orthes(n, H, ort, V) {\r\n let low = 0;\r\n let high = n - 1;\r\n let f, g, h, i, j, m;\r\n let scale;\r\n\r\n for (m = low + 1; m <= high - 1; m++) {\r\n scale = 0;\r\n for (i = m; i <= high; i++) {\r\n scale = scale + Math.abs(H.get(i, m - 1));\r\n }\r\n\r\n if (scale !== 0) {\r\n h = 0;\r\n for (i = high; i >= m; i--) {\r\n ort[i] = H.get(i, m - 1) / scale;\r\n h += ort[i] * ort[i];\r\n }\r\n\r\n g = Math.sqrt(h);\r\n if (ort[m] > 0) {\r\n g = -g;\r\n }\r\n\r\n h = h - ort[m] * g;\r\n ort[m] = ort[m] - g;\r\n\r\n for (j = m; j < n; j++) {\r\n f = 0;\r\n for (i = high; i >= m; i--) {\r\n f += ort[i] * H.get(i, j);\r\n }\r\n\r\n f = f / h;\r\n for (i = m; i <= high; i++) {\r\n H.set(i, j, H.get(i, j) - f * ort[i]);\r\n }\r\n }\r\n\r\n for (i = 0; i <= high; i++) {\r\n f = 0;\r\n for (j = high; j >= m; j--) {\r\n f += ort[j] * H.get(i, j);\r\n }\r\n\r\n f = f / h;\r\n for (j = m; j <= high; j++) {\r\n H.set(i, j, H.get(i, j) - f * ort[j]);\r\n }\r\n }\r\n\r\n ort[m] = scale * ort[m];\r\n H.set(m, m - 1, scale * g);\r\n }\r\n }\r\n\r\n for (i = 0; i < n; i++) {\r\n for (j = 0; j < n; j++) {\r\n V.set(i, j, i === j ? 1 : 0);\r\n }\r\n }\r\n\r\n for (m = high - 1; m >= low + 1; m--) {\r\n if (H.get(m, m - 1) !== 0) {\r\n for (i = m + 1; i <= high; i++) {\r\n ort[i] = H.get(i, m - 1);\r\n }\r\n\r\n for (j = m; j <= high; j++) {\r\n g = 0;\r\n for (i = m; i <= high; i++) {\r\n g += ort[i] * V.get(i, j);\r\n }\r\n\r\n g = g / ort[m] / H.get(m, m - 1);\r\n for (i = m; i <= high; i++) {\r\n V.set(i, j, V.get(i, j) + g * ort[i]);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction hqr2(nn, e, d, V, H) {\r\n let n = nn - 1;\r\n let low = 0;\r\n let high = nn - 1;\r\n let eps = Number.EPSILON;\r\n let exshift = 0;\r\n let norm = 0;\r\n let p = 0;\r\n let q = 0;\r\n let r = 0;\r\n let s = 0;\r\n let z = 0;\r\n let iter = 0;\r\n let i, j, k, l, m, t, w, x, y;\r\n let ra, sa, vr, vi;\r\n let notlast, cdivres;\r\n\r\n for (i = 0; i < nn; i++) {\r\n if (i < low || i > high) {\r\n d[i] = H.get(i, i);\r\n e[i] = 0;\r\n }\r\n\r\n for (j = Math.max(i - 1, 0); j < nn; j++) {\r\n norm = norm + Math.abs(H.get(i, j));\r\n }\r\n }\r\n\r\n while (n >= low) {\r\n l = n;\r\n while (l > low) {\r\n s = Math.abs(H.get(l - 1, l - 1)) + Math.abs(H.get(l, l));\r\n if (s === 0) {\r\n s = norm;\r\n }\r\n if (Math.abs(H.get(l, l - 1)) < eps * s) {\r\n break;\r\n }\r\n l--;\r\n }\r\n\r\n if (l === n) {\r\n H.set(n, n, H.get(n, n) + exshift);\r\n d[n] = H.get(n, n);\r\n e[n] = 0;\r\n n--;\r\n iter = 0;\r\n } else if (l === n - 1) {\r\n w = H.get(n, n - 1) * H.get(n - 1, n);\r\n p = (H.get(n - 1, n - 1) - H.get(n, n)) / 2;\r\n q = p * p + w;\r\n z = Math.sqrt(Math.abs(q));\r\n H.set(n, n, H.get(n, n) + exshift);\r\n H.set(n - 1, n - 1, H.get(n - 1, n - 1) + exshift);\r\n x = H.get(n, n);\r\n\r\n if (q >= 0) {\r\n z = p >= 0 ? p + z : p - z;\r\n d[n - 1] = x + z;\r\n d[n] = d[n - 1];\r\n if (z !== 0) {\r\n d[n] = x - w / z;\r\n }\r\n e[n - 1] = 0;\r\n e[n] = 0;\r\n x = H.get(n, n - 1);\r\n s = Math.abs(x) + Math.abs(z);\r\n p = x / s;\r\n q = z / s;\r\n r = Math.sqrt(p * p + q * q);\r\n p = p / r;\r\n q = q / r;\r\n\r\n for (j = n - 1; j < nn; j++) {\r\n z = H.get(n - 1, j);\r\n H.set(n - 1, j, q * z + p * H.get(n, j));\r\n H.set(n, j, q * H.get(n, j) - p * z);\r\n }\r\n\r\n for (i = 0; i <= n; i++) {\r\n z = H.get(i, n - 1);\r\n H.set(i, n - 1, q * z + p * H.get(i, n));\r\n H.set(i, n, q * H.get(i, n) - p * z);\r\n }\r\n\r\n for (i = low; i <= high; i++) {\r\n z = V.get(i, n - 1);\r\n V.set(i, n - 1, q * z + p * V.get(i, n));\r\n V.set(i, n, q * V.get(i, n) - p * z);\r\n }\r\n } else {\r\n d[n - 1] = x + p;\r\n d[n] = x + p;\r\n e[n - 1] = z;\r\n e[n] = -z;\r\n }\r\n\r\n n = n - 2;\r\n iter = 0;\r\n } else {\r\n x = H.get(n, n);\r\n y = 0;\r\n w = 0;\r\n if (l < n) {\r\n y = H.get(n - 1, n - 1);\r\n w = H.get(n, n - 1) * H.get(n - 1, n);\r\n }\r\n\r\n if (iter === 10) {\r\n exshift += x;\r\n for (i = low; i <= n; i++) {\r\n H.set(i, i, H.get(i, i) - x);\r\n }\r\n s = Math.abs(H.get(n, n - 1)) + Math.abs(H.get(n - 1, n - 2));\r\n x = y = 0.75 * s;\r\n w = -0.4375 * s * s;\r\n }\r\n\r\n if (iter === 30) {\r\n s = (y - x) / 2;\r\n s = s * s + w;\r\n if (s > 0) {\r\n s = Math.sqrt(s);\r\n if (y < x) {\r\n s = -s;\r\n }\r\n s = x - w / ((y - x) / 2 + s);\r\n for (i = low; i <= n; i++) {\r\n H.set(i, i, H.get(i, i) - s);\r\n }\r\n exshift += s;\r\n x = y = w = 0.964;\r\n }\r\n }\r\n\r\n iter = iter + 1;\r\n\r\n m = n - 2;\r\n while (m >= l) {\r\n z = H.get(m, m);\r\n r = x - z;\r\n s = y - z;\r\n p = (r * s - w) / H.get(m + 1, m) + H.get(m, m + 1);\r\n q = H.get(m + 1, m + 1) - z - r - s;\r\n r = H.get(m + 2, m + 1);\r\n s = Math.abs(p) + Math.abs(q) + Math.abs(r);\r\n p = p / s;\r\n q = q / s;\r\n r = r / s;\r\n if (m === l) {\r\n break;\r\n }\r\n if (\r\n Math.abs(H.get(m, m - 1)) * (Math.abs(q) + Math.abs(r)) <\r\n eps *\r\n (Math.abs(p) *\r\n (Math.abs(H.get(m - 1, m - 1)) +\r\n Math.abs(z) +\r\n Math.abs(H.get(m + 1, m + 1))))\r\n ) {\r\n break;\r\n }\r\n m--;\r\n }\r\n\r\n for (i = m + 2; i <= n; i++) {\r\n H.set(i, i - 2, 0);\r\n if (i > m + 2) {\r\n H.set(i, i - 3, 0);\r\n }\r\n }\r\n\r\n for (k = m; k <= n - 1; k++) {\r\n notlast = k !== n - 1;\r\n if (k !== m) {\r\n p = H.get(k, k - 1);\r\n q = H.get(k + 1, k - 1);\r\n r = notlast ? H.get(k + 2, k - 1) : 0;\r\n x = Math.abs(p) + Math.abs(q) + Math.abs(r);\r\n if (x !== 0) {\r\n p = p / x;\r\n q = q / x;\r\n r = r / x;\r\n }\r\n }\r\n\r\n if (x === 0) {\r\n break;\r\n }\r\n\r\n s = Math.sqrt(p * p + q * q + r * r);\r\n if (p < 0) {\r\n s = -s;\r\n }\r\n\r\n if (s !== 0) {\r\n if (k !== m) {\r\n H.set(k, k - 1, -s * x);\r\n } else if (l !== m) {\r\n H.set(k, k - 1, -H.get(k, k - 1));\r\n }\r\n\r\n p = p + s;\r\n x = p / s;\r\n y = q / s;\r\n z = r / s;\r\n q = q / p;\r\n r = r / p;\r\n\r\n for (j = k; j < nn; j++) {\r\n p = H.get(k, j) + q * H.get(k + 1, j);\r\n if (notlast) {\r\n p = p + r * H.get(k + 2, j);\r\n H.set(k + 2, j, H.get(k + 2, j) - p * z);\r\n }\r\n\r\n H.set(k, j, H.get(k, j) - p * x);\r\n H.set(k + 1, j, H.get(k + 1, j) - p * y);\r\n }\r\n\r\n for (i = 0; i <= Math.min(n, k + 3); i++) {\r\n p = x * H.get(i, k) + y * H.get(i, k + 1);\r\n if (notlast) {\r\n p = p + z * H.get(i, k + 2);\r\n H.set(i, k + 2, H.get(i, k + 2) - p * r);\r\n }\r\n\r\n H.set(i, k, H.get(i, k) - p);\r\n H.set(i, k + 1, H.get(i, k + 1) - p * q);\r\n }\r\n\r\n for (i = low; i <= high; i++) {\r\n p = x * V.get(i, k) + y * V.get(i, k + 1);\r\n if (notlast) {\r\n p = p + z * V.get(i, k + 2);\r\n V.set(i, k + 2, V.get(i, k + 2) - p * r);\r\n }\r\n\r\n V.set(i, k, V.get(i, k) - p);\r\n V.set(i, k + 1, V.get(i, k + 1) - p * q);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (norm === 0) {\r\n return;\r\n }\r\n\r\n for (n = nn - 1; n >= 0; n--) {\r\n p = d[n];\r\n q = e[n];\r\n\r\n if (q === 0) {\r\n l = n;\r\n H.set(n, n, 1);\r\n for (i = n - 1; i >= 0; i--) {\r\n w = H.get(i, i) - p;\r\n r = 0;\r\n for (j = l; j <= n; j++) {\r\n r = r + H.get(i, j) * H.get(j, n);\r\n }\r\n\r\n if (e[i] < 0) {\r\n z = w;\r\n s = r;\r\n } else {\r\n l = i;\r\n if (e[i] === 0) {\r\n H.set(i, n, w !== 0 ? -r / w : -r / (eps * norm));\r\n } else {\r\n x = H.get(i, i + 1);\r\n y = H.get(i + 1, i);\r\n q = (d[i] - p) * (d[i] - p) + e[i] * e[i];\r\n t = (x * s - z * r) / q;\r\n H.set(i, n, t);\r\n H.set(\r\n i + 1,\r\n n,\r\n Math.abs(x) > Math.abs(z) ? (-r - w * t) / x : (-s - y * t) / z,\r\n );\r\n }\r\n\r\n t = Math.abs(H.get(i, n));\r\n if (eps * t * t > 1) {\r\n for (j = i; j <= n; j++) {\r\n H.set(j, n, H.get(j, n) / t);\r\n }\r\n }\r\n }\r\n }\r\n } else if (q < 0) {\r\n l = n - 1;\r\n\r\n if (Math.abs(H.get(n, n - 1)) > Math.abs(H.get(n - 1, n))) {\r\n H.set(n - 1, n - 1, q / H.get(n, n - 1));\r\n H.set(n - 1, n, -(H.get(n, n) - p) / H.get(n, n - 1));\r\n } else {\r\n cdivres = cdiv(0, -H.get(n - 1, n), H.get(n - 1, n - 1) - p, q);\r\n H.set(n - 1, n - 1, cdivres[0]);\r\n H.set(n - 1, n, cdivres[1]);\r\n }\r\n\r\n H.set(n, n - 1, 0);\r\n H.set(n, n, 1);\r\n for (i = n - 2; i >= 0; i--) {\r\n ra = 0;\r\n sa = 0;\r\n for (j = l; j <= n; j++) {\r\n ra = ra + H.get(i, j) * H.get(j, n - 1);\r\n sa = sa + H.get(i, j) * H.get(j, n);\r\n }\r\n\r\n w = H.get(i, i) - p;\r\n\r\n if (e[i] < 0) {\r\n z = w;\r\n r = ra;\r\n s = sa;\r\n } else {\r\n l = i;\r\n if (e[i] === 0) {\r\n cdivres = cdiv(-ra, -sa, w, q);\r\n H.set(i, n - 1, cdivres[0]);\r\n H.set(i, n, cdivres[1]);\r\n } else {\r\n x = H.get(i, i + 1);\r\n y = H.get(i + 1, i);\r\n vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q;\r\n vi = (d[i] - p) * 2 * q;\r\n if (vr === 0 && vi === 0) {\r\n vr =\r\n eps *\r\n norm *\r\n (Math.abs(w) +\r\n Math.abs(q) +\r\n Math.abs(x) +\r\n Math.abs(y) +\r\n Math.abs(z));\r\n }\r\n cdivres = cdiv(\r\n x * r - z * ra + q * sa,\r\n x * s - z * sa - q * ra,\r\n vr,\r\n vi,\r\n );\r\n H.set(i, n - 1, cdivres[0]);\r\n H.set(i, n, cdivres[1]);\r\n if (Math.abs(x) > Math.abs(z) + Math.abs(q)) {\r\n H.set(\r\n i + 1,\r\n n - 1,\r\n (-ra - w * H.get(i, n - 1) + q * H.get(i, n)) / x,\r\n );\r\n H.set(\r\n i + 1,\r\n n,\r\n (-sa - w * H.get(i, n) - q * H.get(i, n - 1)) / x,\r\n );\r\n } else {\r\n cdivres = cdiv(\r\n -r - y * H.get(i, n - 1),\r\n -s - y * H.get(i, n),\r\n z,\r\n q,\r\n );\r\n H.set(i + 1, n - 1, cdivres[0]);\r\n H.set(i + 1, n, cdivres[1]);\r\n }\r\n }\r\n\r\n t = Math.max(Math.abs(H.get(i, n - 1)), Math.abs(H.get(i, n)));\r\n if (eps * t * t > 1) {\r\n for (j = i; j <= n; j++) {\r\n H.set(j, n - 1, H.get(j, n - 1) / t);\r\n H.set(j, n, H.get(j, n) / t);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n for (i = 0; i < nn; i++) {\r\n if (i < low || i > high) {\r\n for (j = i; j < nn; j++) {\r\n V.set(i, j, H.get(i, j));\r\n }\r\n }\r\n }\r\n\r\n for (j = nn - 1; j >= low; j--) {\r\n for (i = low; i <= high; i++) {\r\n z = 0;\r\n for (k = low; k <= Math.min(j, high); k++) {\r\n z = z + V.get(i, k) * H.get(k, j);\r\n }\r\n V.set(i, j, z);\r\n }\r\n }\r\n}\r\n\r\nfunction cdiv(xr, xi, yr, yi) {\r\n let r, d;\r\n if (Math.abs(yr) > Math.abs(yi)) {\r\n r = yi / yr;\r\n d = yr + r * yi;\r\n return [(xr + r * xi) / d, (xi - r * xr) / d];\r\n } else {\r\n r = yr / yi;\r\n d = yi + r * yr;\r\n return [(r * xr + xi) / d, (r * xi - xr) / d];\r\n }\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nexport default class CholeskyDecomposition {\r\n constructor(value) {\r\n value = WrapperMatrix2D.checkMatrix(value);\r\n if (!value.isSymmetric()) {\r\n throw new Error('Matrix is not symmetric');\r\n }\r\n\r\n let a = value;\r\n let dimension = a.rows;\r\n let l = new Matrix(dimension, dimension);\r\n let positiveDefinite = true;\r\n let i, j, k;\r\n\r\n for (j = 0; j < dimension; j++) {\r\n let d = 0;\r\n for (k = 0; k < j; k++) {\r\n let s = 0;\r\n for (i = 0; i < k; i++) {\r\n s += l.get(k, i) * l.get(j, i);\r\n }\r\n s = (a.get(j, k) - s) / l.get(k, k);\r\n l.set(j, k, s);\r\n d = d + s * s;\r\n }\r\n\r\n d = a.get(j, j) - d;\r\n\r\n positiveDefinite &= d > 0;\r\n l.set(j, j, Math.sqrt(Math.max(d, 0)));\r\n for (k = j + 1; k < dimension; k++) {\r\n l.set(j, k, 0);\r\n }\r\n }\r\n\r\n this.L = l;\r\n this.positiveDefinite = Boolean(positiveDefinite);\r\n }\r\n\r\n isPositiveDefinite() {\r\n return this.positiveDefinite;\r\n }\r\n\r\n solve(value) {\r\n value = WrapperMatrix2D.checkMatrix(value);\r\n\r\n let l = this.L;\r\n let dimension = l.rows;\r\n\r\n if (value.rows !== dimension) {\r\n throw new Error('Matrix dimensions do not match');\r\n }\r\n if (this.isPositiveDefinite() === false) {\r\n throw new Error('Matrix is not positive definite');\r\n }\r\n\r\n let count = value.columns;\r\n let B = value.clone();\r\n let i, j, k;\r\n\r\n for (k = 0; k < dimension; k++) {\r\n for (j = 0; j < count; j++) {\r\n for (i = 0; i < k; i++) {\r\n B.set(k, j, B.get(k, j) - B.get(i, j) * l.get(k, i));\r\n }\r\n B.set(k, j, B.get(k, j) / l.get(k, k));\r\n }\r\n }\r\n\r\n for (k = dimension - 1; k >= 0; k--) {\r\n for (j = 0; j < count; j++) {\r\n for (i = k + 1; i < dimension; i++) {\r\n B.set(k, j, B.get(k, j) - B.get(i, j) * l.get(i, k));\r\n }\r\n B.set(k, j, B.get(k, j) / l.get(k, k));\r\n }\r\n }\r\n\r\n return B;\r\n }\r\n\r\n get lowerTriangularMatrix() {\r\n return this.L;\r\n }\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nexport default class nipals {\r\n constructor(X, options = {}) {\r\n X = WrapperMatrix2D.checkMatrix(X);\r\n let { Y } = options;\r\n const {\r\n scaleScores = false,\r\n maxIterations = 1000,\r\n terminationCriteria = 1e-10,\r\n } = options;\r\n\r\n let u;\r\n if (Y) {\r\n if (Array.isArray(Y) && typeof Y[0] === 'number') {\r\n Y = Matrix.columnVector(Y);\r\n } else {\r\n Y = WrapperMatrix2D.checkMatrix(Y);\r\n }\r\n if (!Y.isColumnVector() || Y.rows !== X.rows) {\r\n throw new Error('Y must be a column vector of length X.rows');\r\n }\r\n u = Y;\r\n } else {\r\n u = X.getColumnVector(0);\r\n }\r\n\r\n let diff = 1;\r\n let t, q, w, tOld;\r\n\r\n for (\r\n let counter = 0;\r\n counter < maxIterations && diff > terminationCriteria;\r\n counter++\r\n ) {\r\n w = X.transpose().mmul(u).div(u.transpose().mmul(u).get(0, 0));\r\n w = w.div(w.norm());\r\n\r\n t = X.mmul(w).div(w.transpose().mmul(w).get(0, 0));\r\n\r\n if (counter > 0) {\r\n diff = t.clone().sub(tOld).pow(2).sum();\r\n }\r\n tOld = t.clone();\r\n\r\n if (Y) {\r\n q = Y.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\r\n q = q.div(q.norm());\r\n\r\n u = Y.mmul(q).div(q.transpose().mmul(q).get(0, 0));\r\n } else {\r\n u = t;\r\n }\r\n }\r\n\r\n if (Y) {\r\n let p = X.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\r\n p = p.div(p.norm());\r\n let xResidual = X.clone().sub(t.clone().mmul(p.transpose()));\r\n let residual = u.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\r\n let yResidual = Y.clone().sub(\r\n t.clone().mulS(residual.get(0, 0)).mmul(q.transpose()),\r\n );\r\n\r\n this.t = t;\r\n this.p = p.transpose();\r\n this.w = w.transpose();\r\n this.q = q;\r\n this.u = u;\r\n this.s = t.transpose().mmul(t);\r\n this.xResidual = xResidual;\r\n this.yResidual = yResidual;\r\n this.betas = residual;\r\n } else {\r\n this.w = w.transpose();\r\n this.s = t.transpose().mmul(t).sqrt();\r\n if (scaleScores) {\r\n this.t = t.clone().div(this.s.get(0, 0));\r\n } else {\r\n this.t = t;\r\n }\r\n this.xResidual = X.sub(t.mmul(w.transpose()));\r\n }\r\n }\r\n}\r\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction sum(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var sumValue = 0;\n\n for (var i = 0; i < input.length; i++) {\n sumValue += input[i];\n }\n\n return sumValue;\n}\n\nexport default sum;\n","import sum from 'ml-array-sum';\n\nfunction mean(input) {\n return sum(input) / input.length;\n}\n\nexport default mean;\n","import Matrix from 'ml-matrix';\nimport meanArray from 'ml-array-mean';\n\n/**\n * @private\n * return an array of probabilities of each class\n * @param {Array} array - contains the classes\n * @param {number} numberOfClasses\n * @return {Matrix} - rowVector of probabilities.\n */\nexport function toDiscreteDistribution(array, numberOfClasses) {\n let counts = new Array(numberOfClasses).fill(0);\n for (let i = 0; i < array.length; ++i) {\n counts[array[i]] += 1 / array.length;\n }\n\n return Matrix.rowVector(counts);\n}\n\n/**\n * @private\n * Retrieves the impurity of array of predictions\n * @param {Array} array - predictions.\n * @return {number} Gini impurity\n */\nexport function giniImpurity(array) {\n if (array.length === 0) {\n return 0;\n }\n\n let probabilities = toDiscreteDistribution(\n array,\n getNumberOfClasses(array),\n ).getRow(0);\n\n let sum = 0.0;\n for (let i = 0; i < probabilities.length; ++i) {\n sum += probabilities[i] * probabilities[i];\n }\n\n return 1 - sum;\n}\n\n/**\n * @private\n * Return the number of classes given the array of predictions.\n * @param {Array} array - predictions.\n * @return {number} Number of classes.\n */\nexport function getNumberOfClasses(array) {\n return array\n .filter(function(val, i, arr) {\n return arr.indexOf(val) === i;\n })\n .map((val) => val + 1)\n .reduce((a, b) => Math.max(a, b));\n}\n\n/**\n * @private\n * Calculates the Gini Gain of an array of predictions and those predictions splitted by a feature.\n * @param {Array} array - Predictions\n * @param {object} splitted - Object with elements \"greater\" and \"lesser\" that contains an array of predictions splitted.\n * @return {number} - Gini Gain.\n */\n\nexport function giniGain(array, splitted) {\n let splitsImpurity = 0.0;\n let splits = ['greater', 'lesser'];\n\n for (let i = 0; i < splits.length; ++i) {\n let currentSplit = splitted[splits[i]];\n splitsImpurity +=\n (giniImpurity(currentSplit) * currentSplit.length) / array.length;\n }\n\n return giniImpurity(array) - splitsImpurity;\n}\n\n/**\n * @private\n * Calculates the squared error of a predictions values.\n * @param {Array} array - predictions values\n * @return {number} squared error.\n */\nexport function squaredError(array) {\n let l = array.length;\n\n let m = meanArray(array);\n let error = 0.0;\n\n for (let i = 0; i < l; ++i) {\n let currentElement = array[i];\n error += (currentElement - m) * (currentElement - m);\n }\n\n return error;\n}\n\n/**\n * @private\n * Calculates the sum of squared error of the two arrays that contains the splitted values.\n * @param {Array} array - this argument is no necessary but is used to fit with the main interface.\n * @param {object} splitted - Object with elements \"greater\" and \"lesser\" that contains an array of predictions splitted.\n * @return {number} - sum of squared errors.\n */\nexport function regressionError(array, splitted) {\n let error = 0.0;\n let splits = ['greater', 'lesser'];\n\n for (let i = 0; i < splits.length; ++i) {\n let currentSplit = splitted[splits[i]];\n error += squaredError(currentSplit);\n }\n return error;\n}\n\n/**\n * @private\n * Split the training set and values from a given column of the training set if is less than a value\n * @param {Matrix} X - Training set.\n * @param {Array} y - Training values.\n * @param {number} column - Column to split.\n * @param {number} value - value to split the Training set and values.\n * @return {object} - Object that contains the splitted values.\n */\nexport function matrixSplitter(X, y, column, value) {\n let lesserX = [];\n let greaterX = [];\n let lesserY = [];\n let greaterY = [];\n\n for (let i = 0; i < X.rows; ++i) {\n if (X.get(i, column) < value) {\n lesserX.push(X.getRow(i));\n lesserY.push(y[i]);\n } else {\n greaterX.push(X.getRow(i));\n greaterY.push(y[i]);\n }\n }\n\n return {\n greaterX: greaterX,\n greaterY: greaterY,\n lesserX: lesserX,\n lesserY: lesserY,\n };\n}\n\n/**\n * @private\n * Calculates the mean between two values\n * @param {number} a\n * @param {number} b\n * @return {number}\n */\nexport function mean(a, b) {\n return (a + b) / 2;\n}\n\n/**\n * @private\n * Returns a list of tuples that contains the i-th element of each array.\n * @param {Array} a\n * @param {Array} b\n * @return {Array} list of tuples.\n */\nexport function zip(a, b) {\n if (a.length !== b.length) {\n throw new TypeError(\n `Error on zip: the size of a: ${a.length} is different from b: ${b.length}`,\n );\n }\n\n let ret = new Array(a.length);\n for (let i = 0; i < a.length; ++i) {\n ret[i] = [a[i], b[i]];\n }\n\n return ret;\n}\n","import Matrix from 'ml-matrix';\nimport mean from 'ml-array-mean';\n\nimport * as Utils from './utils';\n\nconst gainFunctions = {\n gini: Utils.giniGain,\n regression: Utils.regressionError,\n};\n\nconst splitFunctions = {\n mean: Utils.mean,\n};\n\nexport default class TreeNode {\n /**\n * @private\n * Constructor for a tree node given the options received on the main classes (DecisionTreeClassifier, DecisionTreeRegression)\n * @param {object|TreeNode} options for loading\n * @constructor\n */\n constructor(options) {\n // options parameters\n this.kind = options.kind;\n this.gainFunction = options.gainFunction;\n this.splitFunction = options.splitFunction;\n this.minNumSamples = options.minNumSamples;\n this.maxDepth = options.maxDepth;\n }\n\n /**\n * @private\n * Function that retrieve the best feature to make the split.\n * @param {Matrix} XTranspose - Training set transposed\n * @param {Array} y - labels or values (depending of the decision tree)\n * @return {object} - return tree values, the best gain, column and the split value.\n */\n bestSplit(XTranspose, y) {\n // Depending in the node tree class, we set the variables to check information gain (to classify)\n // or error (for regression)\n\n let bestGain = this.kind === 'classifier' ? -Infinity : Infinity;\n let check = this.kind === 'classifier' ? (a, b) => a > b : (a, b) => a < b;\n\n let maxColumn;\n let maxValue;\n\n for (let i = 0; i < XTranspose.rows; ++i) {\n let currentFeature = XTranspose.getRow(i);\n let splitValues = this.featureSplit(currentFeature, y);\n for (let j = 0; j < splitValues.length; ++j) {\n let currentSplitVal = splitValues[j];\n let splitted = this.split(currentFeature, y, currentSplitVal);\n\n let gain = gainFunctions[this.gainFunction](y, splitted);\n if (check(gain, bestGain)) {\n maxColumn = i;\n maxValue = currentSplitVal;\n bestGain = gain;\n }\n }\n }\n\n return {\n maxGain: bestGain,\n maxColumn: maxColumn,\n maxValue: maxValue,\n };\n }\n\n /**\n * @private\n * Makes the split of the training labels or values from the training set feature given a split value.\n * @param {Array} x - Training set feature\n * @param {Array} y - Training set value or label\n * @param {number} splitValue\n * @return {object}\n */\n split(x, y, splitValue) {\n let lesser = [];\n let greater = [];\n\n for (let i = 0; i < x.length; ++i) {\n if (x[i] < splitValue) {\n lesser.push(y[i]);\n } else {\n greater.push(y[i]);\n }\n }\n\n return {\n greater: greater,\n lesser: lesser,\n };\n }\n\n /**\n * @private\n * Calculates the possible points to split over the tree given a training set feature and corresponding labels or values.\n * @param {Array} x - Training set feature\n * @param {Array} y - Training set value or label\n * @return {Array} possible split values.\n */\n featureSplit(x, y) {\n let splitValues = [];\n let arr = Utils.zip(x, y);\n arr.sort(function(a, b) {\n return a[0] - b[0];\n });\n\n for (let i = 1; i < arr.length; ++i) {\n if (arr[i - 1][1] !== arr[i][1]) {\n splitValues.push(\n splitFunctions[this.splitFunction](arr[i - 1][0], arr[i][0]),\n );\n }\n }\n\n return splitValues;\n }\n\n /**\n * @private\n * Calculate the predictions of a leaf tree node given the training labels or values\n * @param {Array} y\n */\n calculatePrediction(y) {\n if (this.kind === 'classifier') {\n this.distribution = Utils.toDiscreteDistribution(\n y,\n Utils.getNumberOfClasses(y),\n );\n if (this.distribution.columns === 0) {\n throw new TypeError('Error on calculate the prediction');\n }\n } else {\n this.distribution = mean(y);\n }\n }\n\n /**\n * @private\n * Train a node given the training set and labels, because it trains recursively, it also receive\n * the current depth of the node, parent gain to avoid infinite recursion and boolean value to check if\n * the training set is transposed.\n * @param {Matrix} X - Training set (could be transposed or not given transposed).\n * @param {Array} y - Training labels or values.\n * @param {number} currentDepth - Current depth of the node.\n * @param {number} parentGain - parent node gain or error.\n */\n train(X, y, currentDepth, parentGain) {\n if (X.rows <= this.minNumSamples) {\n this.calculatePrediction(y);\n return;\n }\n if (parentGain === undefined) parentGain = 0.0;\n\n let XTranspose = X.transpose();\n let split = this.bestSplit(XTranspose, y);\n\n this.splitValue = split.maxValue;\n this.splitColumn = split.maxColumn;\n this.gain = split.maxGain;\n\n let splittedMatrix = Utils.matrixSplitter(\n X,\n y,\n this.splitColumn,\n this.splitValue,\n );\n\n if (\n currentDepth < this.maxDepth &&\n (this.gain > 0.01 && this.gain !== parentGain) &&\n (splittedMatrix.lesserX.length > 0 && splittedMatrix.greaterX.length > 0)\n ) {\n this.left = new TreeNode(this);\n this.right = new TreeNode(this);\n\n let lesserX = new Matrix(splittedMatrix.lesserX);\n let greaterX = new Matrix(splittedMatrix.greaterX);\n\n this.left.train(\n lesserX,\n splittedMatrix.lesserY,\n currentDepth + 1,\n this.gain,\n );\n this.right.train(\n greaterX,\n splittedMatrix.greaterY,\n currentDepth + 1,\n this.gain,\n );\n } else {\n this.calculatePrediction(y);\n }\n }\n\n /**\n * @private\n * Calculates the prediction of a given element.\n * @param {Array} row\n * @return {number|Array} prediction\n * * if a node is a classifier returns an array of probabilities of each class.\n * * if a node is for regression returns a number with the prediction.\n */\n classify(row) {\n if (this.right && this.left) {\n if (row[this.splitColumn] < this.splitValue) {\n return this.left.classify(row);\n } else {\n return this.right.classify(row);\n }\n }\n\n return this.distribution;\n }\n\n /**\n * @private\n * Set the parameter of the current node and their children.\n * @param {object} node - parameters of the current node and the children.\n */\n setNodeParameters(node) {\n if (node.distribution !== undefined) {\n this.distribution =\n node.distribution.constructor === Array\n ? new Matrix(node.distribution)\n : node.distribution;\n } else {\n this.distribution = undefined;\n this.splitValue = node.splitValue;\n this.splitColumn = node.splitColumn;\n this.gain = node.gain;\n\n this.left = new TreeNode(this);\n this.right = new TreeNode(this);\n\n if (node.left !== {}) {\n this.left.setNodeParameters(node.left);\n }\n if (node.right !== {}) {\n this.right.setNodeParameters(node.right);\n }\n }\n }\n}\n","import Matrix from 'ml-matrix';\n\nimport Tree from './TreeNode';\n\nconst defaultOptions = {\n gainFunction: 'gini',\n splitFunction: 'mean',\n minNumSamples: 3,\n maxDepth: Infinity,\n};\n\nexport class DecisionTreeClassifier {\n /**\n * Create new Decision Tree Classifier with CART implementation with the given options\n * @param {object} options\n * @param {string} [options.gainFunction=\"gini\"] - gain function to get the best split, \"gini\" the only one supported.\n * @param {string} [options.splitFunction=\"mean\"] - given two integers from a split feature, get the value to split, \"mean\" the only one supported.\n * @param {number} [options.minNumSamples=3] - minimum number of samples to create a leaf node to decide a class.\n * @param {number} [options.maxDepth=Infinity] - Max depth of the tree.\n * @param {object} model - for load purposes.\n * @constructor\n */\n constructor(options, model) {\n if (options === true) {\n this.options = model.options;\n this.root = new Tree(model.options);\n this.root.setNodeParameters(model.root);\n } else {\n this.options = Object.assign({}, defaultOptions, options);\n this.options.kind = 'classifier';\n }\n }\n\n /**\n * Train the decision tree with the given training set and labels.\n * @param {Matrix|MatrixTransposeView|Array} trainingSet\n * @param {Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n this.root = new Tree(this.options);\n trainingSet = Matrix.checkMatrix(trainingSet);\n this.root.train(trainingSet, trainingLabels, 0, null);\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|MatrixTransposeView|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n toPredict = Matrix.checkMatrix(toPredict);\n let predictions = new Array(toPredict.rows);\n\n for (let i = 0; i < toPredict.rows; ++i) {\n predictions[i] = this.root\n .classify(toPredict.getRow(i))\n .maxRowIndex(0)[1];\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n options: this.options,\n root: this.root,\n name: 'DTClassifier',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {DecisionTreeClassifier}\n */\n static load(model) {\n if (model.name !== 'DTClassifier') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new DecisionTreeClassifier(true, model);\n }\n}\n","import Matrix from 'ml-matrix';\n\nimport Tree from './TreeNode';\n\nconst defaultOptions = {\n gainFunction: 'regression',\n splitFunction: 'mean',\n minNumSamples: 3,\n maxDepth: Infinity,\n};\n\nexport class DecisionTreeRegression {\n /**\n * Create new Decision Tree Regression with CART implementation with the given options.\n * @param {object} options\n * @param {string} [options.gainFunction=\"regression\"] - gain function to get the best split, \"regression\" the only one supported.\n * @param {string} [options.splitFunction=\"mean\"] - given two integers from a split feature, get the value to split, \"mean\" the only one supported.\n * @param {number} [options.minNumSamples=3] - minimum number of samples to create a leaf node to decide a class.\n * @param {number} [options.maxDepth=Infinity] - Max depth of the tree.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.options = model.options;\n this.root = new Tree(model.options);\n this.root.setNodeParameters(model.root);\n } else {\n this.options = Object.assign({}, defaultOptions, options);\n this.options.kind = 'regression';\n }\n }\n\n /**\n * Train the decision tree with the given training set and values.\n * @param {Matrix|MatrixTransposeView|Array} trainingSet\n * @param {Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n this.root = new Tree(this.options);\n\n if (\n typeof trainingSet[0] !== 'undefined' &&\n trainingSet[0].length === undefined\n ) {\n trainingSet = Matrix.columnVector(trainingSet);\n } else {\n trainingSet = Matrix.checkMatrix(trainingSet);\n }\n this.root.train(trainingSet, trainingValues, 0);\n }\n\n /**\n * Predicts the values given the matrix to predict.\n * @param {Matrix|MatrixTransposeView|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n if (\n typeof toPredict[0] !== 'undefined' &&\n toPredict[0].length === undefined\n ) {\n toPredict = Matrix.columnVector(toPredict);\n }\n toPredict = Matrix.checkMatrix(toPredict);\n\n let predictions = new Array(toPredict.rows);\n for (let i = 0; i < toPredict.rows; ++i) {\n predictions[i] = this.root.classify(toPredict.getRow(i));\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n options: this.options,\n root: this.root,\n name: 'DTRegression',\n };\n }\n\n /**\n * Load a Decision tree regression with the given model.\n * @param {object} model\n * @return {DecisionTreeRegression}\n */\n static load(model) {\n if (model.name !== 'DTRegression') {\n throw new RangeError(`Invalid model:${model.name}`);\n }\n\n return new DecisionTreeRegression(true, model);\n }\n}\n","const SMALLEST_UNSAFE_INTEGER = 0x20000000000000;\r\nconst LARGEST_SAFE_INTEGER = SMALLEST_UNSAFE_INTEGER - 1;\r\nconst UINT32_MAX = -1 >>> 0;\r\nconst UINT32_SIZE = UINT32_MAX + 1;\r\nconst INT32_SIZE = UINT32_SIZE / 2;\r\nconst INT32_MAX = INT32_SIZE - 1;\r\nconst UINT21_SIZE = 1 << 21;\r\nconst UINT21_MAX = UINT21_SIZE - 1;\n\n/**\r\n * Returns a value within [-0x80000000, 0x7fffffff]\r\n */\r\nfunction int32(engine) {\r\n return engine.next() | 0;\r\n}\n\nfunction add(distribution, addend) {\r\n if (addend === 0) {\r\n return distribution;\r\n }\r\n else {\r\n return engine => distribution(engine) + addend;\r\n }\r\n}\n\n/**\r\n * Returns a value within [-0x20000000000000, 0x1fffffffffffff]\r\n */\r\nfunction int53(engine) {\r\n const high = engine.next() | 0;\r\n const low = engine.next() >>> 0;\r\n return ((high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0));\r\n}\n\n/**\r\n * Returns a value within [-0x20000000000000, 0x20000000000000]\r\n */\r\nfunction int53Full(engine) {\r\n while (true) {\r\n const high = engine.next() | 0;\r\n if (high & 0x400000) {\r\n if ((high & 0x7fffff) === 0x400000 && (engine.next() | 0) === 0) {\r\n return SMALLEST_UNSAFE_INTEGER;\r\n }\r\n }\r\n else {\r\n const low = engine.next() >>> 0;\r\n return ((high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0));\r\n }\r\n }\r\n}\n\n/**\r\n * Returns a value within [0, 0xffffffff]\r\n */\r\nfunction uint32(engine) {\r\n return engine.next() >>> 0;\r\n}\n\n/**\r\n * Returns a value within [0, 0x1fffffffffffff]\r\n */\r\nfunction uint53(engine) {\r\n const high = engine.next() & UINT21_MAX;\r\n const low = engine.next() >>> 0;\r\n return high * UINT32_SIZE + low;\r\n}\n\n/**\r\n * Returns a value within [0, 0x20000000000000]\r\n */\r\nfunction uint53Full(engine) {\r\n while (true) {\r\n const high = engine.next() | 0;\r\n if (high & UINT21_SIZE) {\r\n if ((high & UINT21_MAX) === 0 && (engine.next() | 0) === 0) {\r\n return SMALLEST_UNSAFE_INTEGER;\r\n }\r\n }\r\n else {\r\n const low = engine.next() >>> 0;\r\n return (high & UINT21_MAX) * UINT32_SIZE + low;\r\n }\r\n }\r\n}\n\nfunction isPowerOfTwoMinusOne(value) {\r\n return ((value + 1) & value) === 0;\r\n}\r\nfunction bitmask(masking) {\r\n return (engine) => engine.next() & masking;\r\n}\r\nfunction downscaleToLoopCheckedRange(range) {\r\n const extendedRange = range + 1;\r\n const maximum = extendedRange * Math.floor(UINT32_SIZE / extendedRange);\r\n return engine => {\r\n let value = 0;\r\n do {\r\n value = engine.next() >>> 0;\r\n } while (value >= maximum);\r\n return value % extendedRange;\r\n };\r\n}\r\nfunction downscaleToRange(range) {\r\n if (isPowerOfTwoMinusOne(range)) {\r\n return bitmask(range);\r\n }\r\n else {\r\n return downscaleToLoopCheckedRange(range);\r\n }\r\n}\r\nfunction isEvenlyDivisibleByMaxInt32(value) {\r\n return (value | 0) === 0;\r\n}\r\nfunction upscaleWithHighMasking(masking) {\r\n return engine => {\r\n const high = engine.next() & masking;\r\n const low = engine.next() >>> 0;\r\n return high * UINT32_SIZE + low;\r\n };\r\n}\r\nfunction upscaleToLoopCheckedRange(extendedRange) {\r\n const maximum = extendedRange * Math.floor(SMALLEST_UNSAFE_INTEGER / extendedRange);\r\n return engine => {\r\n let ret = 0;\r\n do {\r\n const high = engine.next() & UINT21_MAX;\r\n const low = engine.next() >>> 0;\r\n ret = high * UINT32_SIZE + low;\r\n } while (ret >= maximum);\r\n return ret % extendedRange;\r\n };\r\n}\r\nfunction upscaleWithinU53(range) {\r\n const extendedRange = range + 1;\r\n if (isEvenlyDivisibleByMaxInt32(extendedRange)) {\r\n const highRange = ((extendedRange / UINT32_SIZE) | 0) - 1;\r\n if (isPowerOfTwoMinusOne(highRange)) {\r\n return upscaleWithHighMasking(highRange);\r\n }\r\n }\r\n return upscaleToLoopCheckedRange(extendedRange);\r\n}\r\nfunction upscaleWithinI53AndLoopCheck(min, max) {\r\n return engine => {\r\n let ret = 0;\r\n do {\r\n const high = engine.next() | 0;\r\n const low = engine.next() >>> 0;\r\n ret =\r\n (high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0);\r\n } while (ret < min || ret > max);\r\n return ret;\r\n };\r\n}\r\n/**\r\n * Returns a Distribution to return a value within [min, max]\r\n * @param min The minimum integer value, inclusive. No less than -0x20000000000000.\r\n * @param max The maximum integer value, inclusive. No greater than 0x20000000000000.\r\n */\r\nfunction integer(min, max) {\r\n min = Math.floor(min);\r\n max = Math.floor(max);\r\n if (min < -SMALLEST_UNSAFE_INTEGER || !isFinite(min)) {\r\n throw new RangeError(`Expected min to be at least ${-SMALLEST_UNSAFE_INTEGER}`);\r\n }\r\n else if (max > SMALLEST_UNSAFE_INTEGER || !isFinite(max)) {\r\n throw new RangeError(`Expected max to be at most ${SMALLEST_UNSAFE_INTEGER}`);\r\n }\r\n const range = max - min;\r\n if (range <= 0 || !isFinite(range)) {\r\n return () => min;\r\n }\r\n else if (range === UINT32_MAX) {\r\n if (min === 0) {\r\n return uint32;\r\n }\r\n else {\r\n return add(int32, min + INT32_SIZE);\r\n }\r\n }\r\n else if (range < UINT32_MAX) {\r\n return add(downscaleToRange(range), min);\r\n }\r\n else if (range === LARGEST_SAFE_INTEGER) {\r\n return add(uint53, min);\r\n }\r\n else if (range < LARGEST_SAFE_INTEGER) {\r\n return add(upscaleWithinU53(range), min);\r\n }\r\n else if (max - 1 - min === LARGEST_SAFE_INTEGER) {\r\n return add(uint53Full, min);\r\n }\r\n else if (min === -SMALLEST_UNSAFE_INTEGER &&\r\n max === SMALLEST_UNSAFE_INTEGER) {\r\n return int53Full;\r\n }\r\n else if (min === -SMALLEST_UNSAFE_INTEGER && max === LARGEST_SAFE_INTEGER) {\r\n return int53;\r\n }\r\n else if (min === -LARGEST_SAFE_INTEGER && max === SMALLEST_UNSAFE_INTEGER) {\r\n return add(int53, 1);\r\n }\r\n else if (max === SMALLEST_UNSAFE_INTEGER) {\r\n return add(upscaleWithinI53AndLoopCheck(min - 1, max - 1), 1);\r\n }\r\n else {\r\n return upscaleWithinI53AndLoopCheck(min, max);\r\n }\r\n}\n\nfunction isLeastBitTrue(engine) {\r\n return (engine.next() & 1) === 1;\r\n}\r\nfunction lessThan(distribution, value) {\r\n return engine => distribution(engine) < value;\r\n}\r\nfunction probability(percentage) {\r\n if (percentage <= 0) {\r\n return () => false;\r\n }\r\n else if (percentage >= 1) {\r\n return () => true;\r\n }\r\n else {\r\n const scaled = percentage * UINT32_SIZE;\r\n if (scaled % 1 === 0) {\r\n return lessThan(int32, (scaled - INT32_SIZE) | 0);\r\n }\r\n else {\r\n return lessThan(uint53, Math.round(percentage * SMALLEST_UNSAFE_INTEGER));\r\n }\r\n }\r\n}\r\nfunction bool(numerator, denominator) {\r\n if (denominator == null) {\r\n if (numerator == null) {\r\n return isLeastBitTrue;\r\n }\r\n return probability(numerator);\r\n }\r\n else {\r\n if (numerator <= 0) {\r\n return () => false;\r\n }\r\n else if (numerator >= denominator) {\r\n return () => true;\r\n }\r\n return lessThan(integer(0, denominator - 1), numerator);\r\n }\r\n}\n\n/**\r\n * Returns a Distribution that returns a random `Date` within the inclusive\r\n * range of [`start`, `end`].\r\n * @param start The minimum `Date`\r\n * @param end The maximum `Date`\r\n */\r\nfunction date(start, end) {\r\n const distribution = integer(+start, +end);\r\n return engine => new Date(distribution(engine));\r\n}\n\n/**\r\n * Returns a Distribution to return a value within [1, sideCount]\r\n * @param sideCount The number of sides of the die\r\n */\r\nfunction die(sideCount) {\r\n return integer(1, sideCount);\r\n}\n\n/**\r\n * Returns a distribution that returns an array of length `dieCount` of values\r\n * within [1, `sideCount`]\r\n * @param sideCount The number of sides of each die\r\n * @param dieCount The number of dice\r\n */\r\nfunction dice(sideCount, dieCount) {\r\n const distribution = die(sideCount);\r\n return engine => {\r\n const result = [];\r\n for (let i = 0; i < dieCount; ++i) {\r\n result.push(distribution(engine));\r\n }\r\n return result;\r\n };\r\n}\n\n// tslint:disable:unified-signatures\r\n// has 2**x chars, for faster uniform distribution\r\nconst DEFAULT_STRING_POOL = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\";\r\nfunction string(pool = DEFAULT_STRING_POOL) {\r\n const poolLength = pool.length;\r\n if (!poolLength) {\r\n throw new Error(\"Expected pool not to be an empty string\");\r\n }\r\n const distribution = integer(0, poolLength - 1);\r\n return (engine, length) => {\r\n let result = \"\";\r\n for (let i = 0; i < length; ++i) {\r\n const j = distribution(engine);\r\n result += pool.charAt(j);\r\n }\r\n return result;\r\n };\r\n}\n\nconst LOWER_HEX_POOL = \"0123456789abcdef\";\r\nconst lowerHex = string(LOWER_HEX_POOL);\r\nconst upperHex = string(LOWER_HEX_POOL.toUpperCase());\r\n/**\r\n * Returns a Distribution that returns a random string comprised of numbers\r\n * or the characters `abcdef` (or `ABCDEF`) of length `length`.\r\n * @param length Length of the result string\r\n * @param uppercase Whether the string should use `ABCDEF` instead of `abcdef`\r\n */\r\nfunction hex(uppercase) {\r\n if (uppercase) {\r\n return upperHex;\r\n }\r\n else {\r\n return lowerHex;\r\n }\r\n}\n\nfunction convertSliceArgument(value, length) {\r\n if (value < 0) {\r\n return Math.max(value + length, 0);\r\n }\r\n else {\r\n return Math.min(value, length);\r\n }\r\n}\n\nfunction toInteger(value) {\r\n const num = +value;\r\n if (num < 0) {\r\n return Math.ceil(num);\r\n }\r\n else {\r\n return Math.floor(num);\r\n }\r\n}\n\n/**\r\n * Returns a random value within the provided `source` within the sliced\r\n * bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\nfunction pick(engine, source, begin, end) {\r\n const length = source.length;\r\n if (length === 0) {\r\n throw new RangeError(\"Cannot pick from an empty array\");\r\n }\r\n const start = begin == null ? 0 : convertSliceArgument(toInteger(begin), length);\r\n const finish = end === void 0 ? length : convertSliceArgument(toInteger(end), length);\r\n if (start >= finish) {\r\n throw new RangeError(`Cannot pick between bounds ${start} and ${finish}`);\r\n }\r\n const distribution = integer(start, finish - 1);\r\n return source[distribution(engine)];\r\n}\n\nfunction multiply(distribution, multiplier) {\r\n if (multiplier === 1) {\r\n return distribution;\r\n }\r\n else if (multiplier === 0) {\r\n return () => 0;\r\n }\r\n else {\r\n return engine => distribution(engine) * multiplier;\r\n }\r\n}\n\n/**\r\n * Returns a floating-point value within [0.0, 1.0)\r\n */\r\nfunction realZeroToOneExclusive(engine) {\r\n return uint53(engine) / SMALLEST_UNSAFE_INTEGER;\r\n}\n\n/**\r\n * Returns a floating-point value within [0.0, 1.0]\r\n */\r\nfunction realZeroToOneInclusive(engine) {\r\n return uint53Full(engine) / SMALLEST_UNSAFE_INTEGER;\r\n}\n\n/**\r\n * Returns a floating-point value within [min, max) or [min, max]\r\n * @param min The minimum floating-point value, inclusive.\r\n * @param max The maximum floating-point value.\r\n * @param inclusive If true, `max` will be inclusive.\r\n */\r\nfunction real(min, max, inclusive = false) {\r\n if (!isFinite(min)) {\r\n throw new RangeError(\"Expected min to be a finite number\");\r\n }\r\n else if (!isFinite(max)) {\r\n throw new RangeError(\"Expected max to be a finite number\");\r\n }\r\n return add(multiply(inclusive ? realZeroToOneInclusive : realZeroToOneExclusive, max - min), min);\r\n}\n\nconst sliceArray = Array.prototype.slice;\n\n/**\r\n * Shuffles an array in-place\r\n * @param engine The Engine to use when choosing random values\r\n * @param array The array to shuffle\r\n * @param downTo minimum index to shuffle. Only used internally.\r\n */\r\nfunction shuffle(engine, array, downTo = 0) {\r\n const length = array.length;\r\n if (length) {\r\n for (let i = (length - 1) >>> 0; i > downTo; --i) {\r\n const distribution = integer(0, i);\r\n const j = distribution(engine);\r\n if (i !== j) {\r\n const tmp = array[i];\r\n array[i] = array[j];\r\n array[j] = tmp;\r\n }\r\n }\r\n }\r\n return array;\r\n}\n\n/**\r\n * From the population array, produce an array with sampleSize elements that\r\n * are randomly chosen without repeats.\r\n * @param engine The Engine to use when choosing random values\r\n * @param population An array that has items to choose a sample from\r\n * @param sampleSize The size of the result array\r\n */\r\nfunction sample(engine, population, sampleSize) {\r\n if (sampleSize < 0 ||\r\n sampleSize > population.length ||\r\n !isFinite(sampleSize)) {\r\n throw new RangeError(\"Expected sampleSize to be within 0 and the length of the population\");\r\n }\r\n if (sampleSize === 0) {\r\n return [];\r\n }\r\n const clone = sliceArray.call(population);\r\n const length = clone.length;\r\n if (length === sampleSize) {\r\n return shuffle(engine, clone, 0);\r\n }\r\n const tailLength = length - sampleSize;\r\n return shuffle(engine, clone, tailLength - 1).slice(tailLength);\r\n}\n\nconst stringRepeat = (() => {\r\n try {\r\n if (\"x\".repeat(3) === \"xxx\") {\r\n return (pattern, count) => pattern.repeat(count);\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n return (pattern, count) => {\r\n let result = \"\";\r\n while (count > 0) {\r\n if (count & 1) {\r\n result += pattern;\r\n }\r\n count >>= 1;\r\n pattern += pattern;\r\n }\r\n return result;\r\n };\r\n})();\n\nfunction zeroPad(text, zeroCount) {\r\n return stringRepeat(\"0\", zeroCount - text.length) + text;\r\n}\r\n/**\r\n * Returns a Universally Unique Identifier Version 4.\r\n *\r\n * See http://en.wikipedia.org/wiki/Universally_unique_identifier\r\n */\r\nfunction uuid4(engine) {\r\n const a = engine.next() >>> 0;\r\n const b = engine.next() | 0;\r\n const c = engine.next() | 0;\r\n const d = engine.next() >>> 0;\r\n return (zeroPad(a.toString(16), 8) +\r\n \"-\" +\r\n zeroPad((b & 0xffff).toString(16), 4) +\r\n \"-\" +\r\n zeroPad((((b >> 4) & 0x0fff) | 0x4000).toString(16), 4) +\r\n \"-\" +\r\n zeroPad(((c & 0x3fff) | 0x8000).toString(16), 4) +\r\n \"-\" +\r\n zeroPad(((c >> 4) & 0xffff).toString(16), 4) +\r\n zeroPad(d.toString(16), 8));\r\n}\n\n/**\r\n * An int32-producing Engine that uses `Math.random()`\r\n */\r\nconst nativeMath = {\r\n next() {\r\n return (Math.random() * UINT32_SIZE) | 0;\r\n }\r\n};\n\n// tslint:disable:unified-signatures\r\n/**\r\n * A wrapper around an Engine that provides easy-to-use methods for\r\n * producing values based on known distributions\r\n */\r\nclass Random {\r\n /**\r\n * Creates a new Random wrapper\r\n * @param engine The engine to use (defaults to a `Math.random`-based implementation)\r\n */\r\n constructor(engine = nativeMath) {\r\n this.engine = engine;\r\n }\r\n /**\r\n * Returns a value within [-0x80000000, 0x7fffffff]\r\n */\r\n int32() {\r\n return int32(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0xffffffff]\r\n */\r\n uint32() {\r\n return uint32(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0x1fffffffffffff]\r\n */\r\n uint53() {\r\n return uint53(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0x20000000000000]\r\n */\r\n uint53Full() {\r\n return uint53Full(this.engine);\r\n }\r\n /**\r\n * Returns a value within [-0x20000000000000, 0x1fffffffffffff]\r\n */\r\n int53() {\r\n return int53(this.engine);\r\n }\r\n /**\r\n * Returns a value within [-0x20000000000000, 0x20000000000000]\r\n */\r\n int53Full() {\r\n return int53Full(this.engine);\r\n }\r\n /**\r\n * Returns a value within [min, max]\r\n * @param min The minimum integer value, inclusive. No less than -0x20000000000000.\r\n * @param max The maximum integer value, inclusive. No greater than 0x20000000000000.\r\n */\r\n integer(min, max) {\r\n return integer(min, max)(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [0.0, 1.0]\r\n */\r\n realZeroToOneInclusive() {\r\n return realZeroToOneInclusive(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [0.0, 1.0)\r\n */\r\n realZeroToOneExclusive() {\r\n return realZeroToOneExclusive(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [min, max) or [min, max]\r\n * @param min The minimum floating-point value, inclusive.\r\n * @param max The maximum floating-point value.\r\n * @param inclusive If true, `max` will be inclusive.\r\n */\r\n real(min, max, inclusive = false) {\r\n return real(min, max, inclusive)(this.engine);\r\n }\r\n bool(numerator, denominator) {\r\n return bool(numerator, denominator)(this.engine);\r\n }\r\n /**\r\n * Return a random value within the provided `source` within the sliced\r\n * bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\n pick(source, begin, end) {\r\n return pick(this.engine, source, begin, end);\r\n }\r\n /**\r\n * Shuffles an array in-place\r\n * @param array The array to shuffle\r\n */\r\n shuffle(array) {\r\n return shuffle(this.engine, array);\r\n }\r\n /**\r\n * From the population array, returns an array with sampleSize elements that\r\n * are randomly chosen without repeats.\r\n * @param population An array that has items to choose a sample from\r\n * @param sampleSize The size of the result array\r\n */\r\n sample(population, sampleSize) {\r\n return sample(this.engine, population, sampleSize);\r\n }\r\n /**\r\n * Returns a value within [1, sideCount]\r\n * @param sideCount The number of sides of the die\r\n */\r\n die(sideCount) {\r\n return die(sideCount)(this.engine);\r\n }\r\n /**\r\n * Returns an array of length `dieCount` of values within [1, sideCount]\r\n * @param sideCount The number of sides of each die\r\n * @param dieCount The number of dice\r\n */\r\n dice(sideCount, dieCount) {\r\n return dice(sideCount, dieCount)(this.engine);\r\n }\r\n /**\r\n * Returns a Universally Unique Identifier Version 4.\r\n *\r\n * See http://en.wikipedia.org/wiki/Universally_unique_identifier\r\n */\r\n uuid4() {\r\n return uuid4(this.engine);\r\n }\r\n string(length, pool) {\r\n return string(pool)(this.engine, length);\r\n }\r\n /**\r\n * Returns a random string comprised of numbers or the characters `abcdef`\r\n * (or `ABCDEF`) of length `length`.\r\n * @param length Length of the result string\r\n * @param uppercase Whether the string should use `ABCDEF` instead of `abcdef`\r\n */\r\n hex(length, uppercase) {\r\n return hex(uppercase)(this.engine, length);\r\n }\r\n /**\r\n * Returns a random `Date` within the inclusive range of [`start`, `end`].\r\n * @param start The minimum `Date`\r\n * @param end The maximum `Date`\r\n */\r\n date(start, end) {\r\n return date(start, end)(this.engine);\r\n }\r\n}\n\n/**\r\n * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array\r\n */\r\nconst I32Array = (() => {\r\n try {\r\n const buffer = new ArrayBuffer(4);\r\n const view = new Int32Array(buffer);\r\n view[0] = INT32_SIZE;\r\n if (view[0] === -INT32_SIZE) {\r\n return Int32Array;\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n return Array;\r\n})();\n\nlet data = null;\r\nconst COUNT = 128;\r\nlet index = COUNT;\r\n/**\r\n * An Engine that relies on the globally-available `crypto.getRandomValues`,\r\n * which is typically available in modern browsers.\r\n *\r\n * See https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues\r\n *\r\n * If unavailable or otherwise non-functioning, then `browserCrypto` will\r\n * likely `throw` on the first call to `next()`.\r\n */\r\nconst browserCrypto = {\r\n next() {\r\n if (index >= COUNT) {\r\n if (data === null) {\r\n data = new I32Array(COUNT);\r\n }\r\n crypto.getRandomValues(data);\r\n index = 0;\r\n }\r\n return data[index++] | 0;\r\n }\r\n};\n\n/**\r\n * Returns an array of random int32 values, based on current time\r\n * and a random number engine\r\n *\r\n * @param engine an Engine to pull random values from, default `nativeMath`\r\n * @param length the length of the Array, minimum 1, default 16\r\n */\r\nfunction createEntropy(engine = nativeMath, length = 16) {\r\n const array = [];\r\n array.push(new Date().getTime() | 0);\r\n for (let i = 1; i < length; ++i) {\r\n array[i] = engine.next() | 0;\r\n }\r\n return array;\r\n}\n\n/**\r\n * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul\r\n */\r\nconst imul = (() => {\r\n try {\r\n if (Math.imul(UINT32_MAX, 5) === -5) {\r\n return Math.imul;\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n const UINT16_MAX = 0xffff;\r\n return (a, b) => {\r\n const ah = (a >>> 16) & UINT16_MAX;\r\n const al = a & UINT16_MAX;\r\n const bh = (b >>> 16) & UINT16_MAX;\r\n const bl = b & UINT16_MAX;\r\n // the shift by 0 fixes the sign on the high part\r\n // the final |0 converts the unsigned value into a signed value\r\n return (al * bl + (((ah * bl + al * bh) << 16) >>> 0)) | 0;\r\n };\r\n})();\n\nconst ARRAY_SIZE = 624;\r\nconst ARRAY_MAX = ARRAY_SIZE - 1;\r\nconst M = 397;\r\nconst ARRAY_SIZE_MINUS_M = ARRAY_SIZE - M;\r\nconst A = 0x9908b0df;\r\n/**\r\n * An Engine that is a pseudorandom number generator using the Mersenne\r\n * Twister algorithm based on the prime 2**19937 − 1\r\n *\r\n * See http://en.wikipedia.org/wiki/Mersenne_twister\r\n */\r\nclass MersenneTwister19937 {\r\n /**\r\n * MersenneTwister19937 should not be instantiated directly.\r\n * Instead, use the static methods `seed`, `seedWithArray`, or `autoSeed`.\r\n */\r\n constructor() {\r\n this.data = new I32Array(ARRAY_SIZE);\r\n this.index = 0; // integer within [0, 624]\r\n this.uses = 0;\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with an initial int32 value\r\n * @param initial the initial seed value\r\n */\r\n static seed(initial) {\r\n return new MersenneTwister19937().seed(initial);\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with zero or more int32 values\r\n * @param source A series of int32 values\r\n */\r\n static seedWithArray(source) {\r\n return new MersenneTwister19937().seedWithArray(source);\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with the current time and\r\n * a series of natively-generated random values\r\n */\r\n static autoSeed() {\r\n return MersenneTwister19937.seedWithArray(createEntropy());\r\n }\r\n /**\r\n * Returns the next int32 value of the sequence\r\n */\r\n next() {\r\n if ((this.index | 0) >= ARRAY_SIZE) {\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n const value = this.data[this.index];\r\n this.index = (this.index + 1) | 0;\r\n this.uses += 1;\r\n return temper(value) | 0;\r\n }\r\n /**\r\n * Returns the number of times that the Engine has been used.\r\n *\r\n * This can be provided to an unused MersenneTwister19937 with the same\r\n * seed, bringing it to the exact point that was left off.\r\n */\r\n getUseCount() {\r\n return this.uses;\r\n }\r\n /**\r\n * Discards one or more items from the engine\r\n * @param count The count of items to discard\r\n */\r\n discard(count) {\r\n if (count <= 0) {\r\n return this;\r\n }\r\n this.uses += count;\r\n if ((this.index | 0) >= ARRAY_SIZE) {\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n while (count + this.index > ARRAY_SIZE) {\r\n count -= ARRAY_SIZE - this.index;\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n this.index = (this.index + count) | 0;\r\n return this;\r\n }\r\n seed(initial) {\r\n let previous = 0;\r\n this.data[0] = previous = initial | 0;\r\n for (let i = 1; i < ARRAY_SIZE; i = (i + 1) | 0) {\r\n this.data[i] = previous =\r\n (imul(previous ^ (previous >>> 30), 0x6c078965) + i) | 0;\r\n }\r\n this.index = ARRAY_SIZE;\r\n this.uses = 0;\r\n return this;\r\n }\r\n seedWithArray(source) {\r\n this.seed(0x012bd6aa);\r\n seedWithArray(this.data, source);\r\n return this;\r\n }\r\n}\r\nfunction refreshData(data) {\r\n let k = 0;\r\n let tmp = 0;\r\n for (; (k | 0) < ARRAY_SIZE_MINUS_M; k = (k + 1) | 0) {\r\n tmp = (data[k] & INT32_SIZE) | (data[(k + 1) | 0] & INT32_MAX);\r\n data[k] = data[(k + M) | 0] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n }\r\n for (; (k | 0) < ARRAY_MAX; k = (k + 1) | 0) {\r\n tmp = (data[k] & INT32_SIZE) | (data[(k + 1) | 0] & INT32_MAX);\r\n data[k] =\r\n data[(k - ARRAY_SIZE_MINUS_M) | 0] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n }\r\n tmp = (data[ARRAY_MAX] & INT32_SIZE) | (data[0] & INT32_MAX);\r\n data[ARRAY_MAX] = data[M - 1] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n}\r\nfunction temper(value) {\r\n value ^= value >>> 11;\r\n value ^= (value << 7) & 0x9d2c5680;\r\n value ^= (value << 15) & 0xefc60000;\r\n return value ^ (value >>> 18);\r\n}\r\nfunction seedWithArray(data, source) {\r\n let i = 1;\r\n let j = 0;\r\n const sourceLength = source.length;\r\n let k = Math.max(sourceLength, ARRAY_SIZE) | 0;\r\n let previous = data[0] | 0;\r\n for (; (k | 0) > 0; --k) {\r\n data[i] = previous =\r\n ((data[i] ^ imul(previous ^ (previous >>> 30), 0x0019660d)) +\r\n (source[j] | 0) +\r\n (j | 0)) |\r\n 0;\r\n i = (i + 1) | 0;\r\n ++j;\r\n if ((i | 0) > ARRAY_MAX) {\r\n data[0] = data[ARRAY_MAX];\r\n i = 1;\r\n }\r\n if (j >= sourceLength) {\r\n j = 0;\r\n }\r\n }\r\n for (k = ARRAY_MAX; (k | 0) > 0; --k) {\r\n data[i] = previous =\r\n ((data[i] ^ imul(previous ^ (previous >>> 30), 0x5d588b65)) - i) | 0;\r\n i = (i + 1) | 0;\r\n if ((i | 0) > ARRAY_MAX) {\r\n data[0] = data[ARRAY_MAX];\r\n i = 1;\r\n }\r\n }\r\n data[0] = INT32_SIZE;\r\n}\n\nlet data$1 = null;\r\nconst COUNT$1 = 128;\r\nlet index$1 = COUNT$1;\r\n/**\r\n * An Engine that relies on the node-available\r\n * `require('crypto').randomBytes`, which has been available since 0.58.\r\n *\r\n * See https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback\r\n *\r\n * If unavailable or otherwise non-functioning, then `nodeCrypto` will\r\n * likely `throw` on the first call to `next()`.\r\n */\r\nconst nodeCrypto = {\r\n next() {\r\n if (index$1 >= COUNT$1) {\r\n data$1 = new Int32Array(new Int8Array(require(\"crypto\").randomBytes(4 * COUNT$1)).buffer);\r\n index$1 = 0;\r\n }\r\n return data$1[index$1++] | 0;\r\n }\r\n};\n\n/**\r\n * Returns a Distribution to random value within the provided `source`\r\n * within the sliced bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\nfunction picker(source, begin, end) {\r\n const clone = sliceArray.call(source, begin, end);\r\n if (clone.length === 0) {\r\n throw new RangeError(`Cannot pick from a source with no items`);\r\n }\r\n const distribution = integer(0, clone.length - 1);\r\n return engine => clone[distribution(engine)];\r\n}\n\nexport { Random, browserCrypto, nativeMath, MersenneTwister19937, nodeCrypto, bool, date, dice, die, hex, int32, int53, int53Full, integer, pick, picker, real, realZeroToOneExclusive, realZeroToOneInclusive, sample, shuffle, string, uint32, uint53, uint53Full, uuid4, createEntropy };\n//# sourceMappingURL=random-js.esm.js.map\n","import * as Random from 'random-js';\nimport Matrix from 'ml-matrix';\n\nexport function checkFloat(n) {\n return n > 0.0 && n <= 1.0;\n}\n\n/**\n * Select n with replacement elements on the training set and values, where n is the size of the training set.\n * @ignore\n * @param {Matrix} trainingSet\n * @param {Array} trainingValue\n * @param {number} seed - seed for the random selection, must be a 32-bit integer.\n * @return {object} with new X and y.\n */\nexport function examplesBaggingWithReplacement(\n trainingSet,\n trainingValue,\n seed,\n) {\n let engine;\n let distribution = Random.integer(0, trainingSet.rows - 1);\n if (seed === undefined) {\n engine = Random.MersenneTwister19937.autoSeed();\n } else if (Number.isInteger(seed)) {\n engine = Random.MersenneTwister19937.seed(seed);\n } else {\n throw new RangeError(\n `Expected seed must be undefined or integer not ${seed}`,\n );\n }\n\n let Xr = new Array(trainingSet.rows);\n let yr = new Array(trainingSet.rows);\n\n for (let i = 0; i < trainingSet.rows; ++i) {\n let index = distribution(engine);\n Xr[i] = trainingSet.getRow(index);\n yr[i] = trainingValue[index];\n }\n\n return {\n X: new Matrix(Xr),\n y: yr,\n };\n}\n\n/**\n * selects n features from the training set with or without replacement, returns the new training set and the indexes used.\n * @ignore\n * @param {Matrix} trainingSet\n * @param {number} n - features.\n * @param {boolean} replacement\n * @param {number} seed - seed for the random selection, must be a 32-bit integer.\n * @return {object}\n */\nexport function featureBagging(trainingSet, n, replacement, seed) {\n if (trainingSet.columns < n) {\n throw new RangeError(\n 'N should be less or equal to the number of columns of X',\n );\n }\n\n let distribution = Random.integer(0, trainingSet.columns - 1);\n let engine;\n if (seed === undefined) {\n engine = Random.MersenneTwister19937.autoSeed();\n } else if (Number.isInteger(seed)) {\n engine = Random.MersenneTwister19937.seed(seed);\n } else {\n throw new RangeError(\n `Expected seed must be undefined or integer not ${seed}`,\n );\n }\n\n let toRet = new Matrix(trainingSet.rows, n);\n\n let usedIndex;\n let index;\n if (replacement) {\n usedIndex = new Array(n);\n for (let i = 0; i < n; ++i) {\n index = distribution(engine);\n usedIndex[i] = index;\n toRet.setColumn(i, trainingSet.getColumn(index));\n }\n } else {\n usedIndex = new Set();\n index = distribution(engine);\n for (let i = 0; i < n; ++i) {\n while (usedIndex.has(index)) {\n index = distribution(engine);\n }\n toRet.setColumn(i, trainingSet.getColumn(index));\n usedIndex.add(index);\n }\n usedIndex = Array.from(usedIndex);\n }\n\n return {\n X: toRet,\n usedIndex: usedIndex,\n };\n}\n","import {\n DecisionTreeClassifier as DTClassifier,\n DecisionTreeRegression as DTRegression,\n} from 'ml-cart';\nimport {\n Matrix,\n WrapperMatrix2D,\n MatrixTransposeView,\n MatrixColumnSelectionView,\n} from 'ml-matrix';\n\nimport * as Utils from './utils';\n\n/**\n * @class RandomForestBase\n */\nexport class RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number|String} [options.maxFeatures] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement] - use replacement over the sample features.\n * @param {number} [options.seed] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators] - number of estimator to use.\n * @param {object} [options.treeOptions] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {boolean} [options.isClassifier] - boolean to check if is a classifier or regression model (used by subclasses).\n * @param {boolean} [options.useSampleBagging] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.replacement = model.replacement;\n this.maxFeatures = model.maxFeatures;\n this.nEstimators = model.nEstimators;\n this.treeOptions = model.treeOptions;\n this.isClassifier = model.isClassifier;\n this.seed = model.seed;\n this.n = model.n;\n this.indexes = model.indexes;\n this.useSampleBagging = model.useSampleBagging;\n\n let Estimator = this.isClassifier ? DTClassifier : DTRegression;\n this.estimators = model.estimators.map((est) => Estimator.load(est));\n } else {\n this.replacement = options.replacement;\n this.maxFeatures = options.maxFeatures;\n this.nEstimators = options.nEstimators;\n this.treeOptions = options.treeOptions;\n this.isClassifier = options.isClassifier;\n this.seed = options.seed;\n this.useSampleBagging = options.useSampleBagging;\n }\n }\n\n /**\n * Train the decision tree with the given training set and labels.\n * @param {Matrix|Array} trainingSet\n * @param {Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n this.maxFeatures = this.maxFeatures || trainingSet.columns;\n\n if (Utils.checkFloat(this.maxFeatures)) {\n this.n = Math.floor(trainingSet.columns * this.maxFeatures);\n } else if (Number.isInteger(this.maxFeatures)) {\n if (this.maxFeatures > trainingSet.columns) {\n throw new RangeError(\n `The maxFeatures parameter should be less than ${trainingSet.columns}`,\n );\n } else {\n this.n = this.maxFeatures;\n }\n } else {\n throw new RangeError(\n `Cannot process the maxFeatures parameter ${this.maxFeatures}`,\n );\n }\n\n let Estimator;\n if (this.isClassifier) {\n Estimator = DTClassifier;\n } else {\n Estimator = DTRegression;\n }\n\n this.estimators = new Array(this.nEstimators);\n this.indexes = new Array(this.nEstimators);\n\n for (let i = 0; i < this.nEstimators; ++i) {\n let res = this.useSampleBagging\n ? Utils.examplesBaggingWithReplacement(\n trainingSet,\n trainingValues,\n this.seed,\n )\n : { X: trainingSet, y: trainingValues };\n let X = res.X;\n let y = res.y;\n\n res = Utils.featureBagging(X, this.n, this.replacement, this.seed);\n X = res.X;\n\n this.indexes[i] = res.usedIndex;\n this.estimators[i] = new Estimator(this.treeOptions);\n this.estimators[i].train(X, y);\n }\n }\n\n /**\n * Method that returns the way the algorithm generates the predictions, for example, in classification\n * you can return the mode of all predictions retrieved by the trees, or in case of regression you can\n * use the mean or the median.\n * @abstract\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction.\n */\n // eslint-disable-next-line no-unused-vars\n selection(values) {\n throw new Error(\"Abstract method 'selection' not implemented!\");\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n let predictionValues = new Array(this.nEstimators);\n toPredict = Matrix.checkMatrix(toPredict);\n for (let i = 0; i < this.nEstimators; ++i) {\n let X = new MatrixColumnSelectionView(toPredict, this.indexes[i]); // get features for estimator\n predictionValues[i] = this.estimators[i].predict(X);\n }\n\n predictionValues = new MatrixTransposeView(\n new WrapperMatrix2D(predictionValues),\n );\n let predictions = new Array(predictionValues.rows);\n for (let i = 0; i < predictionValues.rows; ++i) {\n predictions[i] = this.selection(predictionValues.getRow(i));\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n indexes: this.indexes,\n n: this.n,\n replacement: this.replacement,\n maxFeatures: this.maxFeatures,\n nEstimators: this.nEstimators,\n treeOptions: this.treeOptions,\n isClassifier: this.isClassifier,\n seed: this.seed,\n estimators: this.estimators.map((est) => est.toJSON()),\n useSampleBagging: this.useSampleBagging,\n };\n }\n}\n","import { RandomForestBase } from './RandomForestBase';\n\nconst defaultOptions = {\n maxFeatures: 1.0,\n replacement: true,\n nEstimators: 10,\n seed: 42,\n useSampleBagging: false,\n};\n\n/**\n * @class RandomForestClassifier\n * @augments RandomForestBase\n */\nexport class RandomForestClassifier extends RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number} [options.maxFeatures=1.0] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement=true] - use replacement over the sample features.\n * @param {number} [options.seed=42] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators=10] - number of estimator to use.\n * @param {object} [options.treeOptions={}] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {boolean} [options.useSampleBagging=false] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n super(true, model.baseModel);\n } else {\n options = Object.assign({}, defaultOptions, options);\n options.isClassifier = true;\n super(options);\n }\n }\n\n /**\n * retrieve the prediction given the selection method.\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction\n */\n selection(values) {\n return mode(values);\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n let baseModel = super.toJSON();\n return {\n baseModel: baseModel,\n name: 'RFClassifier',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {RandomForestClassifier}\n */\n static load(model) {\n if (model.name !== 'RFClassifier') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new RandomForestClassifier(true, model);\n }\n}\n\n/**\n * Return the most repeated element on the array.\n * @param {Array} arr\n * @return {number} mode\n */\nfunction mode(arr) {\n return arr\n .sort(\n (a, b) =>\n arr.filter((v) => v === a).length - arr.filter((v) => v === b).length,\n )\n .pop();\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","(function(){function a(d){for(var e=0,f=d.length-1,g=void 0,h=void 0,i=void 0,j=c(e,f);!0;){if(f<=e)return d[j];if(f==e+1)return d[e]>d[f]&&b(d,e,f),d[j];for(g=c(e,f),d[g]>d[f]&&b(d,g,f),d[e]>d[f]&&b(d,e,f),d[g]>d[e]&&b(d,g,e),b(d,g,e+1),h=e+1,i=f;!0;){do h++;while(d[e]>d[h]);do i--;while(d[i]>d[e]);if(i=j&&(f=i-1)}}var b=function b(d,e,f){var _ref;return _ref=[d[f],d[e]],d[e]=_ref[0],d[f]=_ref[1],_ref},c=function c(d,e){return~~((d+e)/2)};'undefined'!=typeof module&&module.exports?module.exports=a:window.median=a})();\n","import isArray from 'is-any-array';\nimport quickSelectMedian from 'median-quickselect';\n\nfunction median(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n return quickSelectMedian(input.slice());\n}\n\nexport default median;\n","import arrayMean from 'ml-array-mean';\nimport arrayMedian from 'ml-array-median';\n\nimport { RandomForestBase } from './RandomForestBase';\n\nconst selectionMethods = {\n mean: arrayMean,\n median: arrayMedian,\n};\n\nconst defaultOptions = {\n maxFeatures: 1.0,\n replacement: false,\n nEstimators: 10,\n treeOptions: {},\n selectionMethod: 'mean',\n seed: 42,\n useSampleBagging: false,\n};\n\n/**\n * @class RandomForestRegression\n * @augments RandomForestBase\n */\nexport class RandomForestRegression extends RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number} [options.maxFeatures=1.0] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement=true] - use replacement over the sample features.\n * @param {number} [options.seed=42] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators=10] - number of estimator to use.\n * @param {object} [options.treeOptions={}] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {string} [options.selectionMethod=\"mean\"] - the way to calculate the prediction from estimators, \"mean\" and \"median\" are supported.\n * @param {boolean} [options.useSampleBagging=false] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n super(true, model.baseModel);\n this.selectionMethod = model.selectionMethod;\n } else {\n options = Object.assign({}, defaultOptions, options);\n\n if (\n !(\n options.selectionMethod === 'mean' ||\n options.selectionMethod === 'median'\n )\n ) {\n throw new RangeError(\n `Unsupported selection method ${options.selectionMethod}`,\n );\n }\n\n options.isClassifier = false;\n\n super(options);\n this.selectionMethod = options.selectionMethod;\n }\n }\n\n /**\n * retrieve the prediction given the selection method.\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction\n */\n selection(values) {\n return selectionMethods[this.selectionMethod](values);\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n let baseModel = super.toJSON();\n return {\n baseModel: baseModel,\n selectionMethod: this.selectionMethod,\n name: 'RFRegression',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {RandomForestRegression}\n */\n static load(model) {\n if (model.name !== 'RFRegression') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new RandomForestRegression(true, model);\n }\n}\n","import { Matrix, MatrixTransposeView, EVD, SVD, NIPALS } from 'ml-matrix';\n\n/**\n * Creates new PCA (Principal Component Analysis) from the dataset\n * @param {Matrix} dataset - dataset or covariance matrix.\n * @param {Object} [options]\n * @param {boolean} [options.isCovarianceMatrix=false] - true if the dataset is a covariance matrix.\n * @param {string} [options.method='SVD'] - select which method to use: SVD (default), covarianceMatrirx or NIPALS.\n * @param {number} [options.nCompNIPALS=2] - number of components to be computed with NIPALS.\n * @param {boolean} [options.center=true] - should the data be centered (subtract the mean).\n * @param {boolean} [options.scale=false] - should the data be scaled (divide by the standard deviation).\n * @param {boolean} [options.ignoreZeroVariance=false] - ignore columns with zero variance if `scale` is `true`.\n * */\nexport class PCA {\n constructor(dataset, options = {}) {\n if (dataset === true) {\n const model = options;\n this.center = model.center;\n this.scale = model.scale;\n this.means = model.means;\n this.stdevs = model.stdevs;\n this.U = Matrix.checkMatrix(model.U);\n this.S = model.S;\n this.R = model.R;\n this.excludedFeatures = model.excludedFeatures || [];\n return;\n }\n\n dataset = new Matrix(dataset);\n\n const {\n isCovarianceMatrix = false,\n method = 'SVD',\n nCompNIPALS = 2,\n center = true,\n scale = false,\n ignoreZeroVariance = false,\n } = options;\n\n this.center = center;\n this.scale = scale;\n this.means = null;\n this.stdevs = null;\n this.excludedFeatures = [];\n\n if (isCovarianceMatrix) {\n // User provided a covariance matrix instead of dataset.\n this._computeFromCovarianceMatrix(dataset);\n return;\n }\n\n this._adjust(dataset, ignoreZeroVariance);\n switch (method) {\n case 'covarianceMatrix': {\n // User provided a dataset but wants us to compute and use the covariance matrix.\n const covarianceMatrix = new MatrixTransposeView(dataset)\n .mmul(dataset)\n .div(dataset.rows - 1);\n this._computeFromCovarianceMatrix(covarianceMatrix);\n break;\n }\n case 'NIPALS': {\n this._computeWithNIPALS(dataset, nCompNIPALS);\n break;\n }\n case 'SVD': {\n const svd = new SVD(dataset, {\n computeLeftSingularVectors: false,\n computeRightSingularVectors: true,\n autoTranspose: true,\n });\n\n this.U = svd.rightSingularVectors;\n\n const singularValues = svd.diagonal;\n const eigenvalues = [];\n for (const singularValue of singularValues) {\n eigenvalues.push((singularValue * singularValue) / (dataset.rows - 1));\n }\n this.S = eigenvalues;\n break;\n }\n default: {\n throw new Error(`unknown method: ${method}`);\n }\n }\n }\n\n /**\n * Load a PCA model from JSON\n * @param {Object} model\n * @return {PCA}\n */\n static load(model) {\n if (typeof model.name !== 'string') {\n throw new TypeError('model must have a name property');\n }\n if (model.name !== 'PCA') {\n throw new RangeError(`invalid model: ${model.name}`);\n }\n return new PCA(true, model);\n }\n\n /**\n * Project the dataset into the PCA space\n * @param {Matrix} dataset\n * @param {Object} options\n * @return {Matrix} dataset projected in the PCA space\n */\n predict(dataset, options = {}) {\n const { nComponents = this.U.columns } = options;\n dataset = new Matrix(dataset);\n if (this.center) {\n dataset.subRowVector(this.means);\n if (this.scale) {\n for (let i of this.excludedFeatures) {\n dataset.removeColumn(i);\n }\n dataset.divRowVector(this.stdevs);\n }\n }\n var predictions = dataset.mmul(this.U);\n return predictions.subMatrix(0, predictions.rows - 1, 0, nComponents - 1);\n }\n\n /**\n * Calculates the inverse PCA transform\n * @param {Matrix} dataset\n * @return {Matrix} dataset projected in the PCA space\n */\n invert(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n\n var inverse = dataset.mmul(this.U.transpose());\n\n if (this.center) {\n if (this.scale) {\n inverse.mulRowVector(this.stdevs);\n }\n inverse.addRowVector(this.means);\n }\n\n return inverse;\n }\n\n\n /**\n * Returns the proportion of variance for each component\n * @return {[number]}\n */\n getExplainedVariance() {\n var sum = 0;\n for (const s of this.S) {\n sum += s;\n }\n return this.S.map((value) => value / sum);\n }\n\n /**\n * Returns the cumulative proportion of variance\n * @return {[number]}\n */\n getCumulativeVariance() {\n var explained = this.getExplainedVariance();\n for (var i = 1; i < explained.length; i++) {\n explained[i] += explained[i - 1];\n }\n return explained;\n }\n\n /**\n * Returns the Eigenvectors of the covariance matrix\n * @returns {Matrix}\n */\n getEigenvectors() {\n return this.U;\n }\n\n /**\n * Returns the Eigenvalues (on the diagonal)\n * @returns {[number]}\n */\n getEigenvalues() {\n return this.S;\n }\n\n /**\n * Returns the standard deviations of the principal components\n * @returns {[number]}\n */\n getStandardDeviations() {\n return this.S.map((x) => Math.sqrt(x));\n }\n\n /**\n * Returns the loadings matrix\n * @return {Matrix}\n */\n getLoadings() {\n return this.U.transpose();\n }\n\n /**\n * Export the current model to a JSON object\n * @return {Object} model\n */\n toJSON() {\n return {\n name: 'PCA',\n center: this.center,\n scale: this.scale,\n means: this.means,\n stdevs: this.stdevs,\n U: this.U,\n S: this.S,\n excludedFeatures: this.excludedFeatures,\n };\n }\n\n _adjust(dataset, ignoreZeroVariance) {\n if (this.center) {\n const mean = dataset.mean('column');\n const stdevs = this.scale\n ? dataset.standardDeviation('column', { mean })\n : null;\n this.means = mean;\n dataset.subRowVector(mean);\n if (this.scale) {\n for (let i = 0; i < stdevs.length; i++) {\n if (stdevs[i] === 0) {\n if (ignoreZeroVariance) {\n dataset.removeColumn(i);\n stdevs.splice(i, 1);\n this.excludedFeatures.push(i);\n i--;\n } else {\n throw new RangeError(\n `Cannot scale the dataset (standard deviation is zero at index ${i}`,\n );\n }\n }\n }\n this.stdevs = stdevs;\n dataset.divRowVector(stdevs);\n }\n }\n }\n\n _computeFromCovarianceMatrix(dataset) {\n const evd = new EVD(dataset, { assumeSymmetric: true });\n this.U = evd.eigenvectorMatrix;\n this.U.flipRows();\n this.S = evd.realEigenvalues;\n this.S.reverse();\n }\n\n _computeWithNIPALS(dataset, nCompNIPALS) {\n this.U = new Matrix(nCompNIPALS, dataset.columns);\n this.S = [];\n\n let x = dataset;\n for (let i = 0; i < nCompNIPALS; i++) {\n let dc = new NIPALS(x);\n\n this.U.setRow(i, dc.w.transpose());\n this.S.push(Math.pow(dc.s.get(0, 0), 2));\n\n x = dc.xResidual;\n }\n this.U = this.U.transpose(); // to be compatible with API\n }\n}\n","export function squaredEuclidean(p, q) {\r\n let d = 0;\r\n for (let i = 0; i < p.length; i++) {\r\n d += (p[i] - q[i]) * (p[i] - q[i]);\r\n }\r\n return d;\r\n}\r\nexport function euclidean(p, q) {\r\n return Math.sqrt(squaredEuclidean(p, q));\r\n}\r\n","/**\n * Computes a distance/similarity matrix given an array of data and a distance/similarity function.\n * @param {Array} data An array of data\n * @param {function} distanceFn A function that accepts two arguments and computes a distance/similarity between them\n * @return {Array} The distance/similarity matrix. The matrix is square and has a size equal to the length of\n * the data array\n */\nexport default function distanceMatrix(data, distanceFn) {\n const result = getMatrix(data.length);\n\n // Compute upper distance matrix\n for (let i = 0; i < data.length; i++) {\n for (let j = 0; j <= i; j++) {\n result[i][j] = distanceFn(data[i], data[j]);\n result[j][i] = result[i][j];\n }\n }\n\n return result;\n}\n\nfunction getMatrix(size) {\n const matrix = [];\n for (let i = 0; i < size; i++) {\n const row = [];\n matrix.push(row);\n for (let j = 0; j < size; j++) {\n row.push(0);\n }\n }\n return matrix;\n}\n","// Generated by CoffeeScript 1.8.0\n(function() {\n var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup;\n\n floor = Math.floor, min = Math.min;\n\n\n /*\n Default comparison function to be used\n */\n\n defaultCmp = function(x, y) {\n if (x < y) {\n return -1;\n }\n if (x > y) {\n return 1;\n }\n return 0;\n };\n\n\n /*\n Insert item x in list a, and keep it sorted assuming a is sorted.\n \n If x is already in a, insert it to the right of the rightmost x.\n \n Optional args lo (default 0) and hi (default a.length) bound the slice\n of a to be searched.\n */\n\n insort = function(a, x, lo, hi, cmp) {\n var mid;\n if (lo == null) {\n lo = 0;\n }\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (lo < 0) {\n throw new Error('lo must be non-negative');\n }\n if (hi == null) {\n hi = a.length;\n }\n while (lo < hi) {\n mid = floor((lo + hi) / 2);\n if (cmp(x, a[mid]) < 0) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n return ([].splice.apply(a, [lo, lo - lo].concat(x)), x);\n };\n\n\n /*\n Push item onto heap, maintaining the heap invariant.\n */\n\n heappush = function(array, item, cmp) {\n if (cmp == null) {\n cmp = defaultCmp;\n }\n array.push(item);\n return _siftdown(array, 0, array.length - 1, cmp);\n };\n\n\n /*\n Pop the smallest item off the heap, maintaining the heap invariant.\n */\n\n heappop = function(array, cmp) {\n var lastelt, returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n lastelt = array.pop();\n if (array.length) {\n returnitem = array[0];\n array[0] = lastelt;\n _siftup(array, 0, cmp);\n } else {\n returnitem = lastelt;\n }\n return returnitem;\n };\n\n\n /*\n Pop and return the current smallest value, and add the new item.\n \n This is more efficient than heappop() followed by heappush(), and can be\n more appropriate when using a fixed size heap. Note that the value\n returned may be larger than item! That constrains reasonable use of\n this routine unless written as part of a conditional replacement:\n if item > array[0]\n item = heapreplace(array, item)\n */\n\n heapreplace = function(array, item, cmp) {\n var returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n returnitem = array[0];\n array[0] = item;\n _siftup(array, 0, cmp);\n return returnitem;\n };\n\n\n /*\n Fast version of a heappush followed by a heappop.\n */\n\n heappushpop = function(array, item, cmp) {\n var _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (array.length && cmp(array[0], item) < 0) {\n _ref = [array[0], item], item = _ref[0], array[0] = _ref[1];\n _siftup(array, 0, cmp);\n }\n return item;\n };\n\n\n /*\n Transform list into a heap, in-place, in O(array.length) time.\n */\n\n heapify = function(array, cmp) {\n var i, _i, _j, _len, _ref, _ref1, _results, _results1;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n _ref1 = (function() {\n _results1 = [];\n for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); }\n return _results1;\n }).apply(this).reverse();\n _results = [];\n for (_i = 0, _len = _ref1.length; _i < _len; _i++) {\n i = _ref1[_i];\n _results.push(_siftup(array, i, cmp));\n }\n return _results;\n };\n\n\n /*\n Update the position of the given item in the heap.\n This function should be called every time the item is being modified.\n */\n\n updateItem = function(array, item, cmp) {\n var pos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n pos = array.indexOf(item);\n if (pos === -1) {\n return;\n }\n _siftdown(array, 0, pos, cmp);\n return _siftup(array, pos, cmp);\n };\n\n\n /*\n Find the n largest elements in a dataset.\n */\n\n nlargest = function(array, n, cmp) {\n var elem, result, _i, _len, _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n result = array.slice(0, n);\n if (!result.length) {\n return result;\n }\n heapify(result, cmp);\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n heappushpop(result, elem, cmp);\n }\n return result.sort(cmp).reverse();\n };\n\n\n /*\n Find the n smallest elements in a dataset.\n */\n\n nsmallest = function(array, n, cmp) {\n var elem, i, los, result, _i, _j, _len, _ref, _ref1, _results;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (n * 10 <= array.length) {\n result = array.slice(0, n).sort(cmp);\n if (!result.length) {\n return result;\n }\n los = result[result.length - 1];\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n if (cmp(elem, los) < 0) {\n insort(result, elem, 0, null, cmp);\n result.pop();\n los = result[result.length - 1];\n }\n }\n return result;\n }\n heapify(array, cmp);\n _results = [];\n for (i = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {\n _results.push(heappop(array, cmp));\n }\n return _results;\n };\n\n _siftdown = function(array, startpos, pos, cmp) {\n var newitem, parent, parentpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n newitem = array[pos];\n while (pos > startpos) {\n parentpos = (pos - 1) >> 1;\n parent = array[parentpos];\n if (cmp(newitem, parent) < 0) {\n array[pos] = parent;\n pos = parentpos;\n continue;\n }\n break;\n }\n return array[pos] = newitem;\n };\n\n _siftup = function(array, pos, cmp) {\n var childpos, endpos, newitem, rightpos, startpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n endpos = array.length;\n startpos = pos;\n newitem = array[pos];\n childpos = 2 * pos + 1;\n while (childpos < endpos) {\n rightpos = childpos + 1;\n if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {\n childpos = rightpos;\n }\n array[pos] = array[childpos];\n pos = childpos;\n childpos = 2 * pos + 1;\n }\n array[pos] = newitem;\n return _siftdown(array, startpos, pos, cmp);\n };\n\n Heap = (function() {\n Heap.push = heappush;\n\n Heap.pop = heappop;\n\n Heap.replace = heapreplace;\n\n Heap.pushpop = heappushpop;\n\n Heap.heapify = heapify;\n\n Heap.updateItem = updateItem;\n\n Heap.nlargest = nlargest;\n\n Heap.nsmallest = nsmallest;\n\n function Heap(cmp) {\n this.cmp = cmp != null ? cmp : defaultCmp;\n this.nodes = [];\n }\n\n Heap.prototype.push = function(x) {\n return heappush(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pop = function() {\n return heappop(this.nodes, this.cmp);\n };\n\n Heap.prototype.peek = function() {\n return this.nodes[0];\n };\n\n Heap.prototype.contains = function(x) {\n return this.nodes.indexOf(x) !== -1;\n };\n\n Heap.prototype.replace = function(x) {\n return heapreplace(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pushpop = function(x) {\n return heappushpop(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.heapify = function() {\n return heapify(this.nodes, this.cmp);\n };\n\n Heap.prototype.updateItem = function(x) {\n return updateItem(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.clear = function() {\n return this.nodes = [];\n };\n\n Heap.prototype.empty = function() {\n return this.nodes.length === 0;\n };\n\n Heap.prototype.size = function() {\n return this.nodes.length;\n };\n\n Heap.prototype.clone = function() {\n var heap;\n heap = new Heap();\n heap.nodes = this.nodes.slice(0);\n return heap;\n };\n\n Heap.prototype.toArray = function() {\n return this.nodes.slice(0);\n };\n\n Heap.prototype.insert = Heap.prototype.push;\n\n Heap.prototype.top = Heap.prototype.peek;\n\n Heap.prototype.front = Heap.prototype.peek;\n\n Heap.prototype.has = Heap.prototype.contains;\n\n Heap.prototype.copy = Heap.prototype.clone;\n\n return Heap;\n\n })();\n\n (function(root, factory) {\n if (typeof define === 'function' && define.amd) {\n return define([], factory);\n } else if (typeof exports === 'object') {\n return module.exports = factory();\n } else {\n return root.Heap = factory();\n }\n })(this, function() {\n return Heap;\n });\n\n}).call(this);\n","module.exports = require('./lib/heap');\n","import Heap from 'heap';\n\nexport default class Cluster {\n constructor() {\n this.children = [];\n this.height = 0;\n this.size = 1;\n this.index = -1;\n this.isLeaf = false;\n }\n\n /**\n * Creates an array of clusters where the maximum height is smaller than the threshold\n * @param {number} threshold\n * @return {Array}\n */\n cut(threshold) {\n if (typeof threshold !== 'number') {\n throw new TypeError('threshold must be a number');\n }\n if (threshold < 0) {\n throw new RangeError('threshold must be a positive number');\n }\n let list = [this];\n const ans = [];\n while (list.length > 0) {\n const aux = list.shift();\n if (threshold >= aux.height) {\n ans.push(aux);\n } else {\n list = list.concat(aux.children);\n }\n }\n return ans;\n }\n\n /**\n * Merge the leaves in the minimum way to have `groups` number of clusters.\n * @param {number} groups - Them number of children the first level of the tree should have.\n * @return {Cluster}\n */\n group(groups) {\n if (!Number.isInteger(groups) || groups < 1) {\n throw new RangeError('groups must be a positive integer');\n }\n\n const heap = new Heap((a, b) => {\n return b.height - a.height;\n });\n\n heap.push(this);\n\n while (heap.size() < groups) {\n var first = heap.pop();\n if (first.children.length === 0) {\n break;\n }\n first.children.forEach((child) => heap.push(child));\n }\n\n var root = new Cluster();\n root.children = heap.toArray();\n root.height = this.height;\n\n return root;\n }\n\n /**\n * Traverses the tree depth-first and calls the provided callback with each individual node\n * @param {function} cb - The callback to be called on each node encounter\n */\n traverse(cb) {\n function visit(root, callback) {\n callback(root);\n if (root.children) {\n for (const child of root.children) {\n visit(child, callback);\n }\n }\n }\n visit(this, cb);\n }\n\n /**\n * Returns a list of indices for all the leaves of this cluster.\n * The list is ordered in such a way that a dendrogram could be drawn without crossing branches.\n * @returns {Array}\n */\n indices() {\n const result = [];\n this.traverse((cluster) => {\n if (cluster.isLeaf) {\n result.push(cluster.index);\n }\n });\n return result;\n }\n}\n","import { euclidean } from 'ml-distance-euclidean';\nimport getDistanceMatrix from 'ml-distance-matrix';\nimport { Matrix } from 'ml-matrix';\n\nimport Cluster from './Cluster';\n\nfunction singleLink(dKI, dKJ) {\n return Math.min(dKI, dKJ);\n}\n\nfunction completeLink(dKI, dKJ) {\n return Math.max(dKI, dKJ);\n}\n\nfunction averageLink(dKI, dKJ, dIJ, ni, nj) {\n const ai = ni / (ni + nj);\n const aj = nj / (ni + nj);\n return ai * dKI + aj * dKJ;\n}\n\nfunction weightedAverageLink(dKI, dKJ) {\n return (dKI + dKJ) / 2;\n}\n\nfunction centroidLink(dKI, dKJ, dIJ, ni, nj) {\n const ai = ni / (ni + nj);\n const aj = nj / (ni + nj);\n const b = -(ni * nj) / (ni + nj) ** 2;\n return ai * dKI + aj * dKJ + b * dIJ;\n}\n\nfunction medianLink(dKI, dKJ, dIJ) {\n return dKI / 2 + dKJ / 2 - dIJ / 4;\n}\n\nfunction wardLink(dKI, dKJ, dIJ, ni, nj, nk) {\n const ai = (ni + nk) / (ni + nj + nk);\n const aj = (nj + nk) / (ni + nj + nk);\n const b = -nk / (ni + nj + nk);\n return ai * dKI + aj * dKJ + b * dIJ;\n}\n\nfunction wardLink2(dKI, dKJ, dIJ, ni, nj, nk) {\n const ai = (ni + nk) / (ni + nj + nk);\n const aj = (nj + nk) / (ni + nj + nk);\n const b = -nk / (ni + nj + nk);\n return Math.sqrt(ai * dKI * dKI + aj * dKJ * dKJ + b * dIJ * dIJ);\n}\n\n/**\n * Continuously merge nodes that have the least dissimilarity\n * @param {Array>} data - Array of points to be clustered\n * @param {object} [options]\n * @param {Function} [options.distanceFunction]\n * @param {string} [options.method] - Default: `'complete'`\n * @param {boolean} [options.isDistanceMatrix] - Is the input already a distance matrix?\n * @constructor\n */\nexport function agnes(data, options = {}) {\n const {\n distanceFunction = euclidean,\n method = 'complete',\n isDistanceMatrix = false,\n } = options;\n\n let updateFunc;\n if (!isDistanceMatrix) {\n data = getDistanceMatrix(data, distanceFunction);\n }\n let distanceMatrix = new Matrix(data);\n const numLeaves = distanceMatrix.rows;\n\n // allows to use a string or a given function\n if (typeof method === 'string') {\n switch (method.toLowerCase()) {\n case 'single':\n updateFunc = singleLink;\n break;\n case 'complete':\n updateFunc = completeLink;\n break;\n case 'average':\n case 'upgma':\n updateFunc = averageLink;\n break;\n case 'wpgma':\n updateFunc = weightedAverageLink;\n break;\n case 'centroid':\n case 'upgmc':\n updateFunc = centroidLink;\n break;\n case 'median':\n case 'wpgmc':\n updateFunc = medianLink;\n break;\n case 'ward':\n updateFunc = wardLink;\n break;\n case 'ward2':\n updateFunc = wardLink2;\n break;\n default:\n throw new RangeError(`unknown clustering method: ${method}`);\n }\n } else if (typeof method !== 'function') {\n throw new TypeError('method must be a string or function');\n }\n\n let clusters = [];\n for (let i = 0; i < numLeaves; i++) {\n const cluster = new Cluster();\n cluster.isLeaf = true;\n cluster.index = i;\n clusters.push(cluster);\n }\n\n for (let n = 0; n < numLeaves - 1; n++) {\n const [row, column, distance] = getSmallestDistance(distanceMatrix);\n const cluster1 = clusters[row];\n const cluster2 = clusters[column];\n const newCluster = new Cluster();\n newCluster.size = cluster1.size + cluster2.size;\n newCluster.children.push(cluster1, cluster2);\n newCluster.height = distance;\n\n const newClusters = [newCluster];\n const newDistanceMatrix = new Matrix(\n distanceMatrix.rows - 1,\n distanceMatrix.rows - 1,\n );\n const previous = (newIndex) =>\n getPreviousIndex(newIndex, Math.min(row, column), Math.max(row, column));\n\n for (let i = 1; i < newDistanceMatrix.rows; i++) {\n const prevI = previous(i);\n const prevICluster = clusters[prevI];\n newClusters.push(prevICluster);\n for (let j = 0; j < i; j++) {\n if (j === 0) {\n const dKI = distanceMatrix.get(row, prevI);\n const dKJ = distanceMatrix.get(prevI, column);\n const val = updateFunc(\n dKI,\n dKJ,\n distance,\n cluster1.size,\n cluster2.size,\n prevICluster.size,\n );\n newDistanceMatrix.set(i, j, val);\n newDistanceMatrix.set(j, i, val);\n } else {\n // Just copy distance from previous matrix\n const val = distanceMatrix.get(prevI, previous(j));\n newDistanceMatrix.set(i, j, val);\n newDistanceMatrix.set(j, i, val);\n }\n }\n }\n\n clusters = newClusters;\n distanceMatrix = newDistanceMatrix;\n }\n\n return clusters[0];\n}\n\nfunction getSmallestDistance(distance) {\n let smallest = Infinity;\n let smallestI = 0;\n let smallestJ = 0;\n for (let i = 1; i < distance.rows; i++) {\n for (let j = 0; j < i; j++) {\n if (distance.get(i, j) < smallest) {\n smallest = distance.get(i, j);\n smallestI = i;\n smallestJ = j;\n }\n }\n }\n return [smallestI, smallestJ, smallest];\n}\n\nfunction getPreviousIndex(newIndex, prev1, prev2) {\n newIndex -= 1;\n if (newIndex >= prev1) newIndex++;\n if (newIndex >= prev2) newIndex++;\n return newIndex;\n}\n","export * from './agnes';\n// export * from './diana';\n// export * from './birch';\n// export * './cure';\n// export * from './chameleon';\n","'use strict';\nimport { squaredEuclidean } from 'ml-distance-euclidean';\nconst defaultOptions = {\n distanceFunction: squaredEuclidean\n};\nexport default function nearestVector(listVectors, vector, options = defaultOptions) {\n const distanceFunction = options.distanceFunction || defaultOptions.distanceFunction;\n const similarityFunction = options.similarityFunction || defaultOptions.similarityFunction;\n let vectorIndex = -1;\n if (typeof similarityFunction === 'function') {\n // maximum similarity\n let maxSim = Number.MIN_VALUE;\n for (let j = 0; j < listVectors.length; j++) {\n const sim = similarityFunction(vector, listVectors[j]);\n if (sim > maxSim) {\n maxSim = sim;\n vectorIndex = j;\n }\n }\n }\n else if (typeof distanceFunction === 'function') {\n // minimum distance\n let minDist = Number.MAX_VALUE;\n for (let i = 0; i < listVectors.length; i++) {\n const dist = distanceFunction(vector, listVectors[i]);\n if (dist < minDist) {\n minDist = dist;\n vectorIndex = i;\n }\n }\n }\n else {\n throw new Error(\"A similarity or distance function it's required\");\n }\n return vectorIndex;\n}\nexport function findNearestVector(vectorList, vector, options = defaultOptions) {\n const index = nearestVector(vectorList, vector, options);\n return vectorList[index];\n}\n","import nearestVector from 'ml-nearest-vector';\n\n/**\n * Calculates the distance matrix for a given array of points\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @param {function} distance - Distance function to use between the points\n * @return {Array>} - matrix with the distance values\n */\nexport function calculateDistanceMatrix(data, distance) {\n var distanceMatrix = new Array(data.length);\n for (var i = 0; i < data.length; ++i) {\n for (var j = i; j < data.length; ++j) {\n if (!distanceMatrix[i]) {\n distanceMatrix[i] = new Array(data.length);\n }\n if (!distanceMatrix[j]) {\n distanceMatrix[j] = new Array(data.length);\n }\n const dist = distance(data[i], data[j]);\n distanceMatrix[i][j] = dist;\n distanceMatrix[j][i] = dist;\n }\n }\n return distanceMatrix;\n}\n\n/**\n * Updates the cluster identifier based in the new data\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @param {Array>} centers - the K centers in format [x,y,z,...]\n * @param {Array } clusterID - the cluster identifier for each data dot\n * @param {function} distance - Distance function to use between the points\n * @return {Array} the cluster identifier for each data dot\n */\nexport function updateClusterID(data, centers, clusterID, distance) {\n for (var i = 0; i < data.length; i++) {\n clusterID[i] = nearestVector(centers, data[i], {\n distanceFunction: distance\n });\n }\n return clusterID;\n}\n\n/**\n * Update the center values based in the new configurations of the clusters\n * @ignore\n * @param {Array>} prevCenters - Centroids from the previous iteration\n * @param {Array >} data - the [x,y,z,...] points to cluster\n * @param {Array } clusterID - the cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @return {Array} he K centers in format [x,y,z,...]\n */\nexport function updateCenters(prevCenters, data, clusterID, K) {\n const nDim = data[0].length;\n\n // copy previous centers\n var centers = new Array(K);\n var centersLen = new Array(K);\n for (var i = 0; i < K; i++) {\n centers[i] = new Array(nDim);\n centersLen[i] = 0;\n for (var j = 0; j < nDim; j++) {\n centers[i][j] = 0;\n }\n }\n\n // add the value for all dimensions of the point\n for (var l = 0; l < data.length; l++) {\n centersLen[clusterID[l]]++;\n for (var dim = 0; dim < nDim; dim++) {\n centers[clusterID[l]][dim] += data[l][dim];\n }\n }\n\n // divides by length\n for (var id = 0; id < K; id++) {\n for (var d = 0; d < nDim; d++) {\n if (centersLen[id]) {\n centers[id][d] /= centersLen[id];\n } else {\n centers[id][d] = prevCenters[id][d];\n }\n }\n }\n return centers;\n}\n\n/**\n * The centers have moved more than the tolerance value?\n * @ignore\n * @param {Array>} centers - the K centers in format [x,y,z,...]\n * @param {Array>} oldCenters - the K old centers in format [x,y,z,...]\n * @param {function} distanceFunction - Distance function to use between the points\n * @param {number} tolerance - Allowed distance for the centroids to move\n * @return {boolean}\n */\nexport function hasConverged(centers, oldCenters, distanceFunction, tolerance) {\n for (var i = 0; i < centers.length; i++) {\n if (distanceFunction(centers[i], oldCenters[i]) > tolerance) {\n return false;\n }\n }\n return true;\n}\n","const LOOP = 8;\nconst FLOAT_MUL = 1 / 16777216;\nconst sh1 = 15;\nconst sh2 = 18;\nconst sh3 = 11;\nfunction multiply_uint32(n, m) {\n n >>>= 0;\n m >>>= 0;\n const nlo = n & 0xffff;\n const nhi = n - nlo;\n return (((nhi * m) >>> 0) + nlo * m) >>> 0;\n}\nexport default class XSadd {\n constructor(seed = Date.now()) {\n this.state = new Uint32Array(4);\n this.init(seed);\n this.random = this.getFloat.bind(this);\n }\n /**\n * Returns a 32-bit integer r (0 <= r < 2^32)\n */\n getUint32() {\n this.nextState();\n return (this.state[3] + this.state[2]) >>> 0;\n }\n /**\n * Returns a floating point number r (0.0 <= r < 1.0)\n */\n getFloat() {\n return (this.getUint32() >>> 8) * FLOAT_MUL;\n }\n init(seed) {\n if (!Number.isInteger(seed)) {\n throw new TypeError('seed must be an integer');\n }\n this.state[0] = seed;\n this.state[1] = 0;\n this.state[2] = 0;\n this.state[3] = 0;\n for (let i = 1; i < LOOP; i++) {\n this.state[i & 3] ^=\n (i +\n multiply_uint32(1812433253, this.state[(i - 1) & 3] ^ ((this.state[(i - 1) & 3] >>> 30) >>> 0))) >>>\n 0;\n }\n this.periodCertification();\n for (let i = 0; i < LOOP; i++) {\n this.nextState();\n }\n }\n periodCertification() {\n if (this.state[0] === 0 &&\n this.state[1] === 0 &&\n this.state[2] === 0 &&\n this.state[3] === 0) {\n this.state[0] = 88; // X\n this.state[1] = 83; // S\n this.state[2] = 65; // A\n this.state[3] = 68; // D\n }\n }\n nextState() {\n let t = this.state[0];\n t ^= t << sh1;\n t ^= t >>> sh2;\n t ^= this.state[3] << sh3;\n this.state[0] = this.state[1];\n this.state[1] = this.state[2];\n this.state[2] = this.state[3];\n this.state[3] = t;\n }\n}\n","const PROB_TOLERANCE = 0.00000001;\nfunction randomChoice(values, options = {}, random = Math.random) {\n const { size = 1, replace = false, probabilities } = options;\n let valuesArr;\n let cumSum;\n if (typeof values === 'number') {\n valuesArr = getArray(values);\n }\n else {\n valuesArr = values.slice();\n }\n if (probabilities) {\n if (!replace) {\n throw new Error('choice with probabilities and no replacement is not implemented');\n }\n // check input is sane\n if (probabilities.length !== valuesArr.length) {\n throw new Error('the length of probabilities option should be equal to the number of choices');\n }\n cumSum = [probabilities[0]];\n for (let i = 1; i < probabilities.length; i++) {\n cumSum[i] = cumSum[i - 1] + probabilities[i];\n }\n if (Math.abs(1 - cumSum[cumSum.length - 1]) > PROB_TOLERANCE) {\n throw new Error(`probabilities should sum to 1, but instead sums to ${cumSum[cumSum.length - 1]}`);\n }\n }\n if (replace === false && size > valuesArr.length) {\n throw new Error('size option is too large');\n }\n const result = [];\n for (let i = 0; i < size; i++) {\n const index = randomIndex(valuesArr.length, random, cumSum);\n result.push(valuesArr[index]);\n if (!replace) {\n valuesArr.splice(index, 1);\n }\n }\n return result;\n}\nfunction getArray(n) {\n const arr = [];\n for (let i = 0; i < n; i++) {\n arr.push(i);\n }\n return arr;\n}\nfunction randomIndex(n, random, cumSum) {\n const rand = random();\n if (!cumSum) {\n return Math.floor(rand * n);\n }\n else {\n let idx = 0;\n while (rand > cumSum[idx]) {\n idx++;\n }\n return idx;\n }\n}\nexport default randomChoice;\n","// tslint:disable-next-line\nimport XSAdd from 'ml-xsadd';\nimport choice from './choice';\n/**\n * @classdesc Random class\n */\nexport default class Random {\n /**\n * @param [seedOrRandom=Math.random] - Control the random number generator used by the Random class instance. Pass a random number generator function with a uniform distribution over the half-open interval [0, 1[. If seed will pass it to ml-xsadd to create a seeded random number generator. If undefined will use Math.random.\n */\n constructor(seedOrRandom = Math.random) {\n if (typeof seedOrRandom === 'number') {\n const xsadd = new XSAdd(seedOrRandom);\n this.randomGenerator = xsadd.random;\n }\n else {\n this.randomGenerator = seedOrRandom;\n }\n }\n choice(values, options) {\n if (typeof values === 'number') {\n return choice(values, options, this.randomGenerator);\n }\n return choice(values, options, this.randomGenerator);\n }\n /**\n * Draw a random number from a uniform distribution on [0,1)\n * @return The random number\n */\n random() {\n return this.randomGenerator();\n }\n /**\n * Draw a random integer from a uniform distribution on [low, high). If only low is specified, the number is drawn on [0, low)\n * @param low - The lower bound of the uniform distribution interval.\n * @param high - The higher bound of the uniform distribution interval.\n */\n randInt(low, high) {\n if (high === undefined) {\n high = low;\n low = 0;\n }\n return low + Math.floor(this.randomGenerator() * (high - low));\n }\n /**\n * Draw several random number from a uniform distribution on [0, 1)\n * @param size - The number of number to draw\n * @return - The list of drawn numbers.\n */\n randomSample(size) {\n const result = [];\n for (let i = 0; i < size; i++) {\n result.push(this.random());\n }\n return result;\n }\n}\n","import Random from 'ml-random';\nimport { squaredEuclidean } from 'ml-distance-euclidean';\nimport { Matrix } from 'ml-matrix';\n\n/**\n * Choose K different random points from the original data\n * @ignore\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - number of clusters\n * @param {number} seed - seed for random number generation\n * @return {Array>} - Initial random points\n */\nexport function random(data, K, seed) {\n const random = new Random(seed);\n return random.choice(data, { size: K });\n}\n\n/**\n * Chooses the most distant points to a first random pick\n * @ignore\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - number of clusters\n * @param {Array>} distanceMatrix - matrix with the distance values\n * @param {number} seed - seed for random number generation\n * @return {Array>} - Initial random points\n */\nexport function mostDistant(data, K, distanceMatrix, seed) {\n const random = new Random(seed);\n var ans = new Array(K);\n // chooses a random point as initial cluster\n ans[0] = Math.floor(random.random() * data.length);\n\n if (K > 1) {\n // chooses the more distant point\n var maxDist = { dist: -1, index: -1 };\n for (var l = 0; l < data.length; ++l) {\n if (distanceMatrix[ans[0]][l] > maxDist.dist) {\n maxDist.dist = distanceMatrix[ans[0]][l];\n maxDist.index = l;\n }\n }\n ans[1] = maxDist.index;\n\n if (K > 2) {\n // chooses the set of points that maximises the min distance\n for (var k = 2; k < K; ++k) {\n var center = { dist: -1, index: -1 };\n for (var m = 0; m < data.length; ++m) {\n // minimum distance to centers\n var minDistCent = { dist: Number.MAX_VALUE, index: -1 };\n for (var n = 0; n < k; ++n) {\n if (\n distanceMatrix[n][m] < minDistCent.dist &&\n ans.indexOf(m) === -1\n ) {\n minDistCent = {\n dist: distanceMatrix[n][m],\n index: m\n };\n }\n }\n\n if (\n minDistCent.dist !== Number.MAX_VALUE &&\n minDistCent.dist > center.dist\n ) {\n center = Object.assign({}, minDistCent);\n }\n }\n\n ans[k] = center.index;\n }\n }\n }\n\n return ans.map((index) => data[index]);\n}\n\n// Implementation inspired from scikit\nexport function kmeanspp(X, K, options = {}) {\n X = new Matrix(X);\n const nSamples = X.rows;\n const random = new Random(options.seed);\n // Set the number of trials\n const centers = [];\n const localTrials = options.localTrials || 2 + Math.floor(Math.log(K));\n\n // Pick the first center at random from the dataset\n const firstCenterIdx = random.randInt(nSamples);\n centers.push(X.getRow(firstCenterIdx));\n\n // Init closest distances\n let closestDistSquared = new Matrix(1, X.rows);\n for (let i = 0; i < X.rows; i++) {\n closestDistSquared.set(0, i, squaredEuclidean(X.getRow(i), centers[0]));\n }\n let cumSumClosestDistSquared = [cumSum(closestDistSquared.getRow(0))];\n const factor = 1 / cumSumClosestDistSquared[0][nSamples - 1];\n let probabilities = Matrix.mul(closestDistSquared, factor);\n\n // Iterate over the remaining centers\n for (let i = 1; i < K; i++) {\n const candidateIdx = random.choice(nSamples, {\n replace: true,\n size: localTrials,\n probabilities: probabilities[0]\n });\n\n const candidates = X.selection(candidateIdx, range(X.columns));\n const distanceToCandidates = euclideanDistances(candidates, X);\n\n let bestCandidate;\n let bestPot;\n let bestDistSquared;\n\n for (let j = 0; j < localTrials; j++) {\n const newDistSquared = Matrix.min(closestDistSquared, [distanceToCandidates.getRow(j)]);\n const newPot = newDistSquared.sum();\n if (bestCandidate === undefined || newPot < bestPot) {\n bestCandidate = candidateIdx[j];\n bestPot = newPot;\n bestDistSquared = newDistSquared;\n }\n }\n centers[i] = X.getRow(bestCandidate);\n closestDistSquared = bestDistSquared;\n cumSumClosestDistSquared = [cumSum(closestDistSquared.getRow(0))];\n probabilities = Matrix.mul(\n closestDistSquared,\n 1 / cumSumClosestDistSquared[0][nSamples - 1]\n );\n }\n return centers;\n}\n\nfunction euclideanDistances(A, B) {\n const result = new Matrix(A.rows, B.rows);\n for (let i = 0; i < A.rows; i++) {\n for (let j = 0; j < B.rows; j++) {\n result.set(i, j, squaredEuclidean(A.getRow(i), B.getRow(j)));\n }\n }\n return result;\n}\n\nfunction range(l) {\n let r = [];\n for (let i = 0; i < l; i++) {\n r.push(i);\n }\n return r;\n}\n\nfunction cumSum(arr) {\n let cumSum = [arr[0]];\n for (let i = 1; i < arr.length; i++) {\n cumSum[i] = cumSum[i - 1] + arr[i];\n }\n return cumSum;\n}\n","import { updateClusterID } from './utils';\n\nconst distanceSymbol = Symbol('distance');\n\nexport default class KMeansResult {\n /**\n * Result of the kmeans algorithm\n * @param {Array} clusters - the cluster identifier for each data dot\n * @param {Array>} centroids - the K centers in format [x,y,z,...], the error and size of the cluster\n * @param {boolean} converged - Converge criteria satisfied\n * @param {number} iterations - Current number of iterations\n * @param {function} distance - (*Private*) Distance function to use between the points\n * @constructor\n */\n constructor(clusters, centroids, converged, iterations, distance) {\n this.clusters = clusters;\n this.centroids = centroids;\n this.converged = converged;\n this.iterations = iterations;\n this[distanceSymbol] = distance;\n }\n\n /**\n * Allows to compute for a new array of points their cluster id\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @return {Array} - cluster id for each point\n */\n nearest(data) {\n const clusterID = new Array(data.length);\n const centroids = this.centroids.map(function (centroid) {\n return centroid.centroid;\n });\n return updateClusterID(data, centroids, clusterID, this[distanceSymbol]);\n }\n\n /**\n * Returns a KMeansResult with the error and size of the cluster\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @return {KMeansResult}\n */\n computeInformation(data) {\n var enrichedCentroids = this.centroids.map(function (centroid) {\n return {\n centroid: centroid,\n error: 0,\n size: 0\n };\n });\n\n for (var i = 0; i < data.length; i++) {\n enrichedCentroids[this.clusters[i]].error += this[distanceSymbol](\n data[i],\n this.centroids[this.clusters[i]]\n );\n enrichedCentroids[this.clusters[i]].size++;\n }\n\n for (var j = 0; j < this.centroids.length; j++) {\n if (enrichedCentroids[j].size) {\n enrichedCentroids[j].error /= enrichedCentroids[j].size;\n } else {\n enrichedCentroids[j].error = null;\n }\n }\n\n return new KMeansResult(\n this.clusters,\n enrichedCentroids,\n this.converged,\n this.iterations,\n this[distanceSymbol]\n );\n }\n}\n","import { squaredEuclidean } from 'ml-distance-euclidean';\n\nimport {\n updateClusterID,\n updateCenters,\n hasConverged,\n calculateDistanceMatrix\n} from './utils';\nimport { mostDistant, random, kmeanspp } from './initialization';\nimport KMeansResult from './KMeansResult';\n\nconst defaultOptions = {\n maxIterations: 100,\n tolerance: 1e-6,\n withIterations: false,\n initialization: 'kmeans++',\n distanceFunction: squaredEuclidean\n};\n\n/**\n * Each step operation for kmeans\n * @ignore\n * @param {Array>} centers - K centers in format [x,y,z,...]\n * @param {Array>} data - Points [x,y,z,...] to cluster\n * @param {Array} clusterID - Cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n * @param {number} iterations - Current number of iterations\n * @return {KMeansResult}\n */\nfunction step(centers, data, clusterID, K, options, iterations) {\n clusterID = updateClusterID(\n data,\n centers,\n clusterID,\n options.distanceFunction\n );\n var newCenters = updateCenters(centers, data, clusterID, K);\n var converged = hasConverged(\n newCenters,\n centers,\n options.distanceFunction,\n options.tolerance\n );\n return new KMeansResult(\n clusterID,\n newCenters,\n converged,\n iterations,\n options.distanceFunction\n );\n}\n\n/**\n * Generator version for the algorithm\n * @ignore\n * @param {Array>} centers - K centers in format [x,y,z,...]\n * @param {Array>} data - Points [x,y,z,...] to cluster\n * @param {Array} clusterID - Cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n */\nfunction* kmeansGenerator(centers, data, clusterID, K, options) {\n var converged = false;\n var stepNumber = 0;\n var stepResult;\n while (!converged && stepNumber < options.maxIterations) {\n stepResult = step(centers, data, clusterID, K, options, ++stepNumber);\n yield stepResult.computeInformation(data);\n converged = stepResult.converged;\n centers = stepResult.centroids;\n }\n}\n\n/**\n * K-means algorithm\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n * @param {number} [options.maxIterations = 100] - Maximum of iterations allowed\n * @param {number} [options.tolerance = 1e-6] - Error tolerance\n * @param {boolean} [options.withIterations = false] - Store clusters and centroids for each iteration\n * @param {function} [options.distanceFunction = squaredDistance] - Distance function to use between the points\n * @param {number} [options.seed] - Seed for random initialization.\n * @param {string|Array>} [options.initialization = 'kmeans++'] - K centers in format [x,y,z,...] or a method for initialize the data:\n * * You can either specify your custom start centroids, or select one of the following initialization method:\n * * `'kmeans++'` will use the kmeans++ method as described by http://ilpubs.stanford.edu:8090/778/1/2006-13.pdf\n * * `'random'` will choose K random different values.\n * * `'mostDistant'` will choose the more distant points to a first random pick\n * @return {KMeansResult} - Cluster identifier for each data dot and centroids with the following fields:\n * * `'clusters'`: Array of indexes for the clusters.\n * * `'centroids'`: Array with the resulting centroids.\n * * `'iterations'`: Number of iterations that took to converge\n */\nexport default function kmeans(data, K, options) {\n options = Object.assign({}, defaultOptions, options);\n\n if (K <= 0 || K > data.length || !Number.isInteger(K)) {\n throw new Error(\n 'K should be a positive integer smaller than the number of points'\n );\n }\n\n var centers;\n if (Array.isArray(options.initialization)) {\n if (options.initialization.length !== K) {\n throw new Error('The initial centers should have the same length as K');\n } else {\n centers = options.initialization;\n }\n } else {\n switch (options.initialization) {\n case 'kmeans++':\n centers = kmeanspp(data, K, options);\n break;\n case 'random':\n centers = random(data, K, options.seed);\n break;\n case 'mostDistant':\n centers = mostDistant(\n data,\n K,\n calculateDistanceMatrix(data, options.distanceFunction),\n options.seed\n );\n break;\n default:\n throw new Error(\n `Unknown initialization method: \"${options.initialization}\"`\n );\n }\n }\n\n // infinite loop until convergence\n if (options.maxIterations === 0) {\n options.maxIterations = Number.MAX_VALUE;\n }\n\n var clusterID = new Array(data.length);\n if (options.withIterations) {\n return kmeansGenerator(centers, data, clusterID, K, options);\n } else {\n var converged = false;\n var stepNumber = 0;\n var stepResult;\n while (!converged && stepNumber < options.maxIterations) {\n stepResult = step(centers, data, clusterID, K, options, ++stepNumber);\n converged = stepResult.converged;\n centers = stepResult.centroids;\n }\n return stepResult.computeInformation(data);\n }\n}\n","import Matrix from 'ml-matrix';\n\n/**\n * @private\n * Function that retuns an array of matrices of the cases that belong to each class.\n * @param {Matrix} X - dataset\n * @param {Array} y - predictions\n * @return {Array}\n */\nexport function separateClasses(X, y) {\n var features = X.columns;\n\n var classes = 0;\n var totalPerClasses = new Array(10000); // max upperbound of classes\n for (var i = 0; i < y.length; i++) {\n if (totalPerClasses[y[i]] === undefined) {\n totalPerClasses[y[i]] = 0;\n classes++;\n }\n totalPerClasses[y[i]]++;\n }\n var separatedClasses = new Array(classes);\n var currentIndex = new Array(classes);\n for (i = 0; i < classes; ++i) {\n separatedClasses[i] = new Matrix(totalPerClasses[i], features);\n currentIndex[i] = 0;\n }\n for (i = 0; i < X.rows; ++i) {\n separatedClasses[y[i]].setRow(currentIndex[y[i]], X.getRow(i));\n currentIndex[y[i]]++;\n }\n return separatedClasses;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { separateClasses } from './utils';\n\nexport class GaussianNB {\n /**\n * Constructor for the Gaussian Naive Bayes classifier, the parameters here is just for loading purposes.\n * @constructor\n * @param {boolean} reload\n * @param {object} model\n */\n constructor(reload, model) {\n if (reload) {\n this.means = model.means;\n this.calculateProbabilities = model.calculateProbabilities;\n }\n }\n\n /**\n * Function that trains the classifier with a matrix that represents the training set and an array that\n * represents the label of each row in the training set. the labels must be numbers between 0 to n-1 where\n * n represents the number of classes.\n *\n * WARNING: in the case that one class, all the cases in one or more features have the same value, the\n * Naive Bayes classifier will not work well.\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n var C1 = Math.sqrt(2 * Math.PI); // constant to precalculate the squared root\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n if (trainingSet.rows !== trainingLabels.length) {\n throw new RangeError(\n 'the size of the training set and the training labels must be the same.'\n );\n }\n\n var separatedClasses = separateClasses(trainingSet, trainingLabels);\n var calculateProbabilities = new Array(separatedClasses.length);\n this.means = new Array(separatedClasses.length);\n for (var i = 0; i < separatedClasses.length; ++i) {\n var means = separatedClasses[i].mean('column');\n var std = separatedClasses[i].standardDeviation('column', {\n mean: means\n });\n\n var logPriorProbability = Math.log(\n separatedClasses[i].rows / trainingSet.rows\n );\n calculateProbabilities[i] = new Array(means.length + 1);\n\n calculateProbabilities[i][0] = logPriorProbability;\n for (var j = 1; j < means.length + 1; ++j) {\n var currentStd = std[j - 1];\n calculateProbabilities[i][j] = [\n 1 / (C1 * currentStd),\n -2 * currentStd * currentStd\n ];\n }\n\n this.means[i] = means;\n }\n\n this.calculateProbabilities = calculateProbabilities;\n }\n\n /**\n * function that predicts each row of the dataset (must be a matrix).\n *\n * @param {Matrix|Array} dataset\n * @return {Array}\n */\n predict(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n if (dataset.rows === this.calculateProbabilities[0].length) {\n throw new RangeError(\n 'the dataset must have the same features as the training set'\n );\n }\n\n var predictions = new Array(dataset.rows);\n\n for (var i = 0; i < predictions.length; ++i) {\n predictions[i] = getCurrentClass(\n dataset.getRow(i),\n this.means,\n this.calculateProbabilities\n );\n }\n\n return predictions;\n }\n\n /**\n * Function that export the NaiveBayes model.\n * @return {object}\n */\n toJSON() {\n return {\n modelName: 'NaiveBayes',\n means: this.means,\n calculateProbabilities: this.calculateProbabilities\n };\n }\n\n /**\n * Function that create a GaussianNB classifier with the given model.\n * @param {object} model\n * @return {GaussianNB}\n */\n static load(model) {\n if (model.modelName !== 'NaiveBayes') {\n throw new RangeError(\n 'The current model is not a Multinomial Naive Bayes, current model:',\n model.name\n );\n }\n\n return new GaussianNB(true, model);\n }\n}\n\n/**\n * @private\n * Function the retrieves a prediction with one case.\n *\n * @param {Array} currentCase\n * @param {Array} mean - Precalculated means of each class trained\n * @param {Array} classes - Precalculated value of each class (Prior probability and probability function of each feature)\n * @return {number}\n */\nfunction getCurrentClass(currentCase, mean, classes) {\n var maxProbability = 0;\n var predictedClass = -1;\n\n // going through all precalculated values for the classes\n for (var i = 0; i < classes.length; ++i) {\n var currentProbability = classes[i][0]; // initialize with the prior probability\n for (var j = 1; j < classes[0][1].length + 1; ++j) {\n currentProbability += calculateLogProbability(\n currentCase[j - 1],\n mean[i][j - 1],\n classes[i][j][0],\n classes[i][j][1]\n );\n }\n\n currentProbability = Math.exp(currentProbability);\n if (currentProbability > maxProbability) {\n maxProbability = currentProbability;\n predictedClass = i;\n }\n }\n\n return predictedClass;\n}\n\n/**\n * @private\n * function that retrieves the probability of the feature given the class.\n * @param {number} value - value of the feature.\n * @param {number} mean - mean of the feature for the given class.\n * @param {number} C1 - precalculated value of (1 / (sqrt(2*pi) * std)).\n * @param {number} C2 - precalculated value of (2 * std^2) for the denominator of the exponential.\n * @return {number}\n */\nfunction calculateLogProbability(value, mean, C1, C2) {\n value = value - mean;\n return Math.log(C1 * Math.exp((value * value) / C2));\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { separateClasses } from './utils';\n\nexport class MultinomialNB {\n /**\n * Constructor for Multinomial Naive Bayes, the model parameter is for load purposes.\n * @constructor\n * @param {object} model - for load purposes.\n */\n constructor(model) {\n if (model) {\n this.conditionalProbability = Matrix.checkMatrix(\n model.conditionalProbability\n );\n this.priorProbability = Matrix.checkMatrix(model.priorProbability);\n }\n }\n\n /**\n * Train the classifier with the current training set and labels, the labels must be numbers between 0 and n.\n * @param {Matrix|Array} trainingSet\n * @param {Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n if (trainingSet.rows !== trainingLabels.length) {\n throw new RangeError(\n 'the size of the training set and the training labels must be the same.'\n );\n }\n\n var separateClass = separateClasses(trainingSet, trainingLabels);\n\n this.priorProbability = new Matrix(separateClass.length, 1);\n\n for (var i = 0; i < separateClass.length; ++i) {\n this.priorProbability.set(i, 0, Math.log(\n separateClass[i].rows / trainingSet.rows\n ));\n }\n\n var features = trainingSet.columns;\n this.conditionalProbability = new Matrix(separateClass.length, features);\n for (i = 0; i < separateClass.length; ++i) {\n var classValues = Matrix.checkMatrix(separateClass[i]);\n var total = classValues.sum();\n var divisor = total + features;\n this.conditionalProbability.setRow(\n i,\n Matrix.rowVector(classValues\n .sum('column'))\n .add(1)\n .div(divisor)\n .apply(matrixLog)\n );\n }\n }\n\n /**\n * Retrieves the predictions for the dataset with the current model.\n * @param {Matrix|Array} dataset\n * @return {Array} - predictions from the dataset.\n */\n predict(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n var predictions = new Array(dataset.rows);\n for (var i = 0; i < dataset.rows; ++i) {\n var currentElement = dataset.getRowVector(i);\n const v = Matrix.columnVector(this.conditionalProbability\n .clone()\n .mulRowVector(currentElement)\n .sum('row'));\n predictions[i] = v\n .add(this.priorProbability)\n .maxIndex()[0];\n }\n\n return predictions;\n }\n\n /**\n * Function that saves the current model.\n * @return {object} - model in JSON format.\n */\n toJSON() {\n return {\n name: 'MultinomialNB',\n priorProbability: this.priorProbability,\n conditionalProbability: this.conditionalProbability\n };\n }\n\n /**\n * Creates a new MultinomialNB from the given model\n * @param {object} model\n * @return {MultinomialNB}\n */\n static load(model) {\n if (model.name !== 'MultinomialNB') {\n throw new RangeError(`${model.name} is not a Multinomial Naive Bayes`);\n }\n\n return new MultinomialNB(model);\n }\n}\n\nfunction matrixLog(i, j) {\n this.set(i, j, Math.log(this.get(i, j)));\n}\n","/*\n * Original code from:\n *\n * k-d Tree JavaScript - V 1.01\n *\n * https://github.com/ubilabs/kd-tree-javascript\n *\n * @author Mircea Pricop , 2012\n * @author Martin Kleppe , 2012\n * @author Ubilabs http://ubilabs.net, 2012\n * @license MIT License \n */\n\nfunction Node(obj, dimension, parent) {\n this.obj = obj;\n this.left = null;\n this.right = null;\n this.parent = parent;\n this.dimension = dimension;\n}\n\nexport default class KDTree {\n constructor(points, metric) {\n // If points is not an array, assume we're loading a pre-built tree\n if (!Array.isArray(points)) {\n this.dimensions = points.dimensions;\n this.root = points;\n restoreParent(this.root);\n } else {\n this.dimensions = new Array(points[0].length);\n for (var i = 0; i < this.dimensions.length; i++) {\n this.dimensions[i] = i;\n }\n this.root = buildTree(points, 0, null, this.dimensions);\n }\n this.metric = metric;\n }\n\n // Convert to a JSON serializable structure; this just requires removing\n // the `parent` property\n toJSON() {\n const result = toJSONImpl(this.root, true);\n result.dimensions = this.dimensions;\n return result;\n }\n\n nearest(point, maxNodes, maxDistance) {\n const metric = this.metric;\n const dimensions = this.dimensions;\n var i;\n\n const bestNodes = new BinaryHeap(function (e) {\n return -e[1];\n });\n\n function nearestSearch(node) {\n const dimension = dimensions[node.dimension];\n const ownDistance = metric(point, node.obj);\n const linearPoint = {};\n var bestChild, linearDistance, otherChild, i;\n\n function saveNode(node, distance) {\n bestNodes.push([node, distance]);\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop();\n }\n }\n\n for (i = 0; i < dimensions.length; i += 1) {\n if (i === node.dimension) {\n linearPoint[dimensions[i]] = point[dimensions[i]];\n } else {\n linearPoint[dimensions[i]] = node.obj[dimensions[i]];\n }\n }\n\n linearDistance = metric(linearPoint, node.obj);\n\n if (node.right === null && node.left === null) {\n if (bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1]) {\n saveNode(node, ownDistance);\n }\n return;\n }\n\n if (node.right === null) {\n bestChild = node.left;\n } else if (node.left === null) {\n bestChild = node.right;\n } else {\n if (point[dimension] < node.obj[dimension]) {\n bestChild = node.left;\n } else {\n bestChild = node.right;\n }\n }\n\n nearestSearch(bestChild);\n\n if (bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1]) {\n saveNode(node, ownDistance);\n }\n\n if (\n bestNodes.size() < maxNodes ||\n Math.abs(linearDistance) < bestNodes.peek()[1]\n ) {\n if (bestChild === node.left) {\n otherChild = node.right;\n } else {\n otherChild = node.left;\n }\n if (otherChild !== null) {\n nearestSearch(otherChild);\n }\n }\n }\n\n if (maxDistance) {\n for (i = 0; i < maxNodes; i += 1) {\n bestNodes.push([null, maxDistance]);\n }\n }\n\n if (this.root) {\n nearestSearch(this.root);\n }\n\n const result = [];\n for (i = 0; i < Math.min(maxNodes, bestNodes.content.length); i += 1) {\n if (bestNodes.content[i][0]) {\n result.push([bestNodes.content[i][0].obj, bestNodes.content[i][1]]);\n }\n }\n return result;\n }\n}\n\nfunction toJSONImpl(src) {\n const dest = new Node(src.obj, src.dimension, null);\n if (src.left) dest.left = toJSONImpl(src.left);\n if (src.right) dest.right = toJSONImpl(src.right);\n return dest;\n}\n\nfunction buildTree(points, depth, parent, dimensions) {\n const dim = depth % dimensions.length;\n\n if (points.length === 0) {\n return null;\n }\n if (points.length === 1) {\n return new Node(points[0], dim, parent);\n }\n\n points.sort((a, b) => a[dimensions[dim]] - b[dimensions[dim]]);\n\n const median = Math.floor(points.length / 2);\n const node = new Node(points[median], dim, parent);\n node.left = buildTree(points.slice(0, median), depth + 1, node, dimensions);\n node.right = buildTree(points.slice(median + 1), depth + 1, node, dimensions);\n\n return node;\n}\n\nfunction restoreParent(root) {\n if (root.left) {\n root.left.parent = root;\n restoreParent(root.left);\n }\n\n if (root.right) {\n root.right.parent = root;\n restoreParent(root.right);\n }\n}\n\n// Binary heap implementation from:\n// http://eloquentjavascript.net/appendix2.html\nclass BinaryHeap {\n constructor(scoreFunction) {\n this.content = [];\n this.scoreFunction = scoreFunction;\n }\n\n push(element) {\n // Add the new element to the end of the array.\n this.content.push(element);\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1);\n }\n\n pop() {\n // Store the first element so we can return it later.\n var result = this.content[0];\n // Get the element at the end of the array.\n var end = this.content.pop();\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (this.content.length > 0) {\n this.content[0] = end;\n this.sinkDown(0);\n }\n return result;\n }\n\n peek() {\n return this.content[0];\n }\n\n size() {\n return this.content.length;\n }\n\n bubbleUp(n) {\n // Fetch the element that has to be moved.\n var element = this.content[n];\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1;\n const parent = this.content[parentN];\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[parentN] = element;\n this.content[n] = parent;\n // Update 'n' to continue at the new position.\n n = parentN;\n } else {\n // Found a parent that is less, no need to move it further.\n break;\n }\n }\n }\n\n sinkDown(n) {\n // Look up the target element and its score.\n var length = this.content.length;\n var element = this.content[n];\n var elemScore = this.scoreFunction(element);\n\n while (true) {\n // Compute the indices of the child elements.\n var child2N = (n + 1) * 2;\n var child1N = child2N - 1;\n // This is used to store the new position of the element,\n // if any.\n var swap = null;\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n var child1 = this.content[child1N];\n var child1Score = this.scoreFunction(child1);\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) {\n swap = child1N;\n }\n }\n // Do the same checks for the other child.\n if (child2N < length) {\n var child2 = this.content[child2N];\n var child2Score = this.scoreFunction(child2);\n if (child2Score < (swap === null ? elemScore : child1Score)) {\n swap = child2N;\n }\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[n] = this.content[swap];\n this.content[swap] = element;\n n = swap;\n } else {\n // Otherwise, we are done.\n break;\n }\n }\n }\n}\n","import { euclidean as euclideanDistance } from 'ml-distance-euclidean';\n\nimport KDTree from './KDTree';\n\nexport default class KNN {\n /**\n * @param {Array} dataset\n * @param {Array} labels\n * @param {object} options\n * @param {number} [options.k=numberOfClasses + 1] - Number of neighbors to classify.\n * @param {function} [options.distance=euclideanDistance] - Distance function that takes two parameters.\n */\n constructor(dataset, labels, options = {}) {\n if (dataset === true) {\n const model = labels;\n this.kdTree = new KDTree(model.kdTree, options);\n this.k = model.k;\n this.classes = new Set(model.classes);\n this.isEuclidean = model.isEuclidean;\n return;\n }\n\n const classes = new Set(labels);\n\n const { distance = euclideanDistance, k = classes.size + 1 } = options;\n\n const points = new Array(dataset.length);\n for (var i = 0; i < points.length; ++i) {\n points[i] = dataset[i].slice();\n }\n\n for (i = 0; i < labels.length; ++i) {\n points[i].push(labels[i]);\n }\n\n this.kdTree = new KDTree(points, distance);\n this.k = k;\n this.classes = classes;\n this.isEuclidean = distance === euclideanDistance;\n }\n\n /**\n * Create a new KNN instance with the given model.\n * @param {object} model\n * @param {function} distance=euclideanDistance - distance function must be provided if the model wasn't trained with euclidean distance.\n * @return {KNN}\n */\n static load(model, distance = euclideanDistance) {\n if (model.name !== 'KNN') {\n throw new Error(`invalid model: ${model.name}`);\n }\n if (!model.isEuclidean && distance === euclideanDistance) {\n throw new Error(\n 'a custom distance function was used to create the model. Please provide it again'\n );\n }\n if (model.isEuclidean && distance !== euclideanDistance) {\n throw new Error(\n 'the model was created with the default distance function. Do not load it with another one'\n );\n }\n return new KNN(true, model, distance);\n }\n\n /**\n * Return a JSON containing the kd-tree model.\n * @return {object} JSON KNN model.\n */\n toJSON() {\n return {\n name: 'KNN',\n kdTree: this.kdTree,\n k: this.k,\n classes: Array.from(this.classes),\n isEuclidean: this.isEuclidean\n };\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Array} dataset\n * @return {Array} predictions\n */\n predict(dataset) {\n if (Array.isArray(dataset)) {\n if (typeof dataset[0] === 'number') {\n return getSinglePrediction(this, dataset);\n } else if (\n Array.isArray(dataset[0]) &&\n typeof dataset[0][0] === 'number'\n ) {\n const predictions = new Array(dataset.length);\n for (var i = 0; i < dataset.length; i++) {\n predictions[i] = getSinglePrediction(this, dataset[i]);\n }\n return predictions;\n }\n }\n throw new TypeError('dataset to predict must be an array or a matrix');\n }\n}\n\nfunction getSinglePrediction(knn, currentCase) {\n var nearestPoints = knn.kdTree.nearest(currentCase, knn.k);\n var pointsPerClass = {};\n var predictedClass = -1;\n var maxPoints = -1;\n var lastElement = nearestPoints[0][0].length - 1;\n\n for (var element of knn.classes) {\n pointsPerClass[element] = 0;\n }\n\n for (var i = 0; i < nearestPoints.length; ++i) {\n var currentClass = nearestPoints[i][0][lastElement];\n var currentPoints = ++pointsPerClass[currentClass];\n if (currentPoints > maxPoints) {\n predictedClass = currentClass;\n maxPoints = currentPoints;\n }\n }\n\n return predictedClass;\n}\n","import Matrix from 'ml-matrix';\n\n/**\n * @private\n * Function that given vector, returns its norm\n * @param {Vector} X\n * @return {number} Norm of the vector\n */\nexport function norm(X) {\n return Math.sqrt(\n X.clone()\n .apply(pow2array)\n .sum(),\n );\n}\n\n/**\n * @private\n * Function that pow 2 each element of a Matrix or a Vector,\n * used in the apply method of the Matrix object\n * @param {number} i - index i.\n * @param {number} j - index j.\n * @return {Matrix} The Matrix object modified at the index i, j.\n * */\nexport function pow2array(i, j) {\n this.set(i, j, this.get(i, j) ** 2);\n}\n\n/**\n * @private\n * Function that normalize the dataset and return the means and\n * standard deviation of each feature.\n * @param {Matrix} dataset\n * @return {object} dataset normalized, means and standard deviations\n */\nexport function featureNormalize(dataset) {\n let means = dataset.mean('column');\n let std = dataset.standardDeviation('column', {\n mean: means,\n unbiased: true,\n });\n let result = Matrix.checkMatrix(dataset).subRowVector(means);\n return { result: result.divRowVector(std), means: means, std: std };\n}\n\n/**\n * @private\n * Function that initialize an array of matrices.\n * @param {Array} array\n * @param {boolean} isMatrix\n * @return {Array} array with the matrices initialized.\n */\nexport function initializeMatrices(array, isMatrix) {\n if (isMatrix) {\n for (let i = 0; i < array.length; ++i) {\n for (let j = 0; j < array[i].length; ++j) {\n let elem = array[i][j];\n array[i][j] = elem !== null ? new Matrix(array[i][j]) : undefined;\n }\n }\n } else {\n for (let i = 0; i < array.length; ++i) {\n array[i] = new Matrix(array[i]);\n }\n }\n\n return array;\n}\n","import Matrix from 'ml-matrix';\n\nimport * as Utils from './util/utils';\n\n/**\n * @class PLS\n */\nexport class PLS {\n /**\n * Constructor for Partial Least Squares (PLS)\n * @param {object} options\n * @param {number} [options.latentVectors] - Number of latent vector to get (if the algorithm doesn't find a good model below the tolerance)\n * @param {number} [options.tolerance=1e-5]\n * @param {boolean} [options.scale=true] - rescale dataset using mean.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.meanX = model.meanX;\n this.stdDevX = model.stdDevX;\n this.meanY = model.meanY;\n this.stdDevY = model.stdDevY;\n this.PBQ = Matrix.checkMatrix(model.PBQ);\n this.R2X = model.R2X;\n this.scale = model.scale;\n this.scaleMethod = model.scaleMethod;\n this.tolerance = model.tolerance;\n } else {\n let { tolerance = 1e-5, scale = true } = options;\n this.tolerance = tolerance;\n this.scale = scale;\n this.latentVectors = options.latentVectors;\n }\n }\n\n /**\n * Fits the model with the given data and predictions, in this function is calculated the\n * following outputs:\n *\n * T - Score matrix of X\n * P - Loading matrix of X\n * U - Score matrix of Y\n * Q - Loading matrix of Y\n * B - Matrix of regression coefficient\n * W - Weight matrix of X\n *\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n trainingValues = Matrix.checkMatrix(trainingValues);\n\n if (trainingSet.length !== trainingValues.length) {\n throw new RangeError(\n 'The number of X rows must be equal to the number of Y rows',\n );\n }\n\n this.meanX = trainingSet.mean('column');\n this.stdDevX = trainingSet.standardDeviation('column', {\n mean: this.meanX,\n unbiased: true,\n });\n this.meanY = trainingValues.mean('column');\n this.stdDevY = trainingValues.standardDeviation('column', {\n mean: this.meanY,\n unbiased: true,\n });\n\n if (this.scale) {\n trainingSet = trainingSet\n .clone()\n .subRowVector(this.meanX)\n .divRowVector(this.stdDevX);\n trainingValues = trainingValues\n .clone()\n .subRowVector(this.meanY)\n .divRowVector(this.stdDevY);\n }\n\n if (this.latentVectors === undefined) {\n this.latentVectors = Math.min(trainingSet.rows - 1, trainingSet.columns);\n }\n\n let rx = trainingSet.rows;\n let cx = trainingSet.columns;\n let ry = trainingValues.rows;\n let cy = trainingValues.columns;\n\n let ssqXcal = trainingSet\n .clone()\n .mul(trainingSet)\n .sum(); // for the r²\n let sumOfSquaresY = trainingValues\n .clone()\n .mul(trainingValues)\n .sum();\n\n let tolerance = this.tolerance;\n let n = this.latentVectors;\n let T = Matrix.zeros(rx, n);\n let P = Matrix.zeros(cx, n);\n let U = Matrix.zeros(ry, n);\n let Q = Matrix.zeros(cy, n);\n let B = Matrix.zeros(n, n);\n let W = P.clone();\n let k = 0;\n let t;\n let w;\n let q;\n let p;\n\n while (Utils.norm(trainingValues) > tolerance && k < n) {\n let transposeX = trainingSet.transpose();\n let transposeY = trainingValues.transpose();\n\n let tIndex = maxSumColIndex(trainingSet.clone().mul(trainingSet));\n let uIndex = maxSumColIndex(trainingValues.clone().mul(trainingValues));\n\n let t1 = trainingSet.getColumnVector(tIndex);\n let u = trainingValues.getColumnVector(uIndex);\n t = Matrix.zeros(rx, 1);\n\n while (Utils.norm(t1.clone().sub(t)) > tolerance) {\n w = transposeX.mmul(u);\n w.div(Utils.norm(w));\n t = t1;\n t1 = trainingSet.mmul(w);\n q = transposeY.mmul(t1);\n q.div(Utils.norm(q));\n u = trainingValues.mmul(q);\n }\n\n t = t1;\n let num = transposeX.mmul(t);\n let den = t\n .transpose()\n .mmul(t)\n .get(0, 0);\n p = num.div(den);\n let pnorm = Utils.norm(p);\n p.div(pnorm);\n t.mul(pnorm);\n w.mul(pnorm);\n\n num = u.transpose().mmul(t);\n den = t\n .transpose()\n .mmul(t)\n .get(0, 0);\n let b = num.div(den).get(0, 0);\n trainingSet.sub(t.mmul(p.transpose()));\n trainingValues.sub(\n t\n .clone()\n .mul(b)\n .mmul(q.transpose()),\n );\n\n T.setColumn(k, t);\n P.setColumn(k, p);\n U.setColumn(k, u);\n Q.setColumn(k, q);\n W.setColumn(k, w);\n\n B.set(k, k, b);\n k++;\n }\n\n k--;\n T = T.subMatrix(0, T.rows - 1, 0, k);\n P = P.subMatrix(0, P.rows - 1, 0, k);\n U = U.subMatrix(0, U.rows - 1, 0, k);\n Q = Q.subMatrix(0, Q.rows - 1, 0, k);\n W = W.subMatrix(0, W.rows - 1, 0, k);\n B = B.subMatrix(0, k, 0, k);\n\n this.ssqYcal = sumOfSquaresY;\n this.E = trainingSet;\n this.F = trainingValues;\n this.T = T;\n this.P = P;\n this.U = U;\n this.Q = Q;\n this.W = W;\n this.B = B;\n this.PBQ = P.mmul(B).mmul(Q.transpose());\n this.R2X = t\n .transpose()\n .mmul(t)\n .mmul(p.transpose().mmul(p))\n .div(ssqXcal)\n .get(0, 0);\n }\n\n /**\n * Predicts the behavior of the given dataset.\n * @param {Matrix|Array} dataset - data to be predicted.\n * @return {Matrix} - predictions of each element of the dataset.\n */\n predict(dataset) {\n let X = Matrix.checkMatrix(dataset);\n if (this.scale) {\n X = X.subRowVector(this.meanX).divRowVector(this.stdDevX);\n }\n let Y = X.mmul(this.PBQ);\n Y = Y.mulRowVector(this.stdDevY).addRowVector(this.meanY);\n return Y;\n }\n\n /**\n * Returns the explained variance on training of the PLS model\n * @return {number}\n */\n getExplainedVariance() {\n return this.R2X;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n name: 'PLS',\n R2X: this.R2X,\n meanX: this.meanX,\n stdDevX: this.stdDevX,\n meanY: this.meanY,\n stdDevY: this.stdDevY,\n PBQ: this.PBQ,\n tolerance: this.tolerance,\n scale: this.scale,\n };\n }\n\n /**\n * Load a PLS model from a JSON Object\n * @param {object} model\n * @return {PLS} - PLS object from the given model\n */\n static load(model) {\n if (model.name !== 'PLS') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n return new PLS(true, model);\n }\n}\n\n/**\n * @private\n * Function that returns the index where the sum of each\n * column vector is maximum.\n * @param {Matrix} data\n * @return {number} index of the maximum\n */\nfunction maxSumColIndex(data) {\n return Matrix.rowVector(data.sum('column')).maxIndex()[0];\n}\n","import { Matrix, SingularValueDecomposition, inverse } from 'ml-matrix';\n\nimport { initializeMatrices } from './util/utils';\n\n/**\n * @class KOPLS\n */\nexport class KOPLS {\n /**\n * Constructor for Kernel-based Orthogonal Projections to Latent Structures (K-OPLS)\n * @param {object} options\n * @param {number} [options.predictiveComponents] - Number of predictive components to use.\n * @param {number} [options.orthogonalComponents] - Number of Y-Orthogonal components.\n * @param {Kernel} [options.kernel] - Kernel object to apply, see [ml-kernel](https://github.com/mljs/kernel).\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.trainingSet = new Matrix(model.trainingSet);\n this.YLoadingMat = new Matrix(model.YLoadingMat);\n this.SigmaPow = new Matrix(model.SigmaPow);\n this.YScoreMat = new Matrix(model.YScoreMat);\n this.predScoreMat = initializeMatrices(model.predScoreMat, false);\n this.YOrthLoadingVec = initializeMatrices(model.YOrthLoadingVec, false);\n this.YOrthEigen = model.YOrthEigen;\n this.YOrthScoreMat = initializeMatrices(model.YOrthScoreMat, false);\n this.toNorm = initializeMatrices(model.toNorm, false);\n this.TURegressionCoeff = initializeMatrices(\n model.TURegressionCoeff,\n false,\n );\n this.kernelX = initializeMatrices(model.kernelX, true);\n this.kernel = model.kernel;\n this.orthogonalComp = model.orthogonalComp;\n this.predictiveComp = model.predictiveComp;\n } else {\n if (options.predictiveComponents === undefined) {\n throw new RangeError('no predictive components found!');\n }\n if (options.orthogonalComponents === undefined) {\n throw new RangeError('no orthogonal components found!');\n }\n if (options.kernel === undefined) {\n throw new RangeError('no kernel found!');\n }\n\n this.orthogonalComp = options.orthogonalComponents;\n this.predictiveComp = options.predictiveComponents;\n this.kernel = options.kernel;\n }\n }\n\n /**\n * Train the K-OPLS model with the given training set and labels.\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n trainingValues = Matrix.checkMatrix(trainingValues);\n\n // to save and compute kernel with the prediction dataset.\n this.trainingSet = trainingSet.clone();\n\n let kernelX = this.kernel.compute(trainingSet);\n\n let Identity = Matrix.eye(kernelX.rows, kernelX.rows, 1);\n let temp = kernelX;\n kernelX = new Array(this.orthogonalComp + 1);\n for (let i = 0; i < this.orthogonalComp + 1; i++) {\n kernelX[i] = new Array(this.orthogonalComp + 1);\n }\n kernelX[0][0] = temp;\n\n let result = new SingularValueDecomposition(\n trainingValues\n .transpose()\n .mmul(kernelX[0][0])\n .mmul(trainingValues),\n {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false,\n },\n );\n let YLoadingMat = result.leftSingularVectors;\n let Sigma = result.diagonalMatrix;\n\n YLoadingMat = YLoadingMat.subMatrix(\n 0,\n YLoadingMat.rows - 1,\n 0,\n this.predictiveComp - 1,\n );\n Sigma = Sigma.subMatrix(\n 0,\n this.predictiveComp - 1,\n 0,\n this.predictiveComp - 1,\n );\n\n let YScoreMat = trainingValues.mmul(YLoadingMat);\n\n let predScoreMat = new Array(this.orthogonalComp + 1);\n let TURegressionCoeff = new Array(this.orthogonalComp + 1);\n let YOrthScoreMat = new Array(this.orthogonalComp);\n let YOrthLoadingVec = new Array(this.orthogonalComp);\n let YOrthEigen = new Array(this.orthogonalComp);\n let YOrthScoreNorm = new Array(this.orthogonalComp);\n\n let SigmaPow = Matrix.pow(Sigma, -0.5);\n // to avoid errors, check infinity\n SigmaPow.apply(function(i, j) {\n if (this.get(i, j) === Infinity) {\n this.set(i, j, 0);\n }\n });\n\n for (let i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = kernelX[0][i]\n .transpose()\n .mmul(YScoreMat)\n .mmul(SigmaPow);\n\n let TpiPrime = predScoreMat[i].transpose();\n TURegressionCoeff[i] = inverse(TpiPrime.mmul(predScoreMat[i]))\n .mmul(TpiPrime)\n .mmul(YScoreMat);\n\n result = new SingularValueDecomposition(\n TpiPrime.mmul(\n Matrix.sub(kernelX[i][i], predScoreMat[i].mmul(TpiPrime)),\n ).mmul(predScoreMat[i]),\n {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false,\n },\n );\n let CoTemp = result.leftSingularVectors;\n let SoTemp = result.diagonalMatrix;\n\n YOrthLoadingVec[i] = CoTemp.subMatrix(0, CoTemp.rows - 1, 0, 0);\n YOrthEigen[i] = SoTemp.get(0, 0);\n\n YOrthScoreMat[i] = Matrix.sub(\n kernelX[i][i],\n predScoreMat[i].mmul(TpiPrime),\n )\n .mmul(predScoreMat[i])\n .mmul(YOrthLoadingVec[i])\n .mul(Math.pow(YOrthEigen[i], -0.5));\n\n let toiPrime = YOrthScoreMat[i].transpose();\n YOrthScoreNorm[i] = Matrix.sqrt(toiPrime.mmul(YOrthScoreMat[i]));\n\n YOrthScoreMat[i] = YOrthScoreMat[i].divRowVector(YOrthScoreNorm[i]);\n\n let ITo = Matrix.sub(\n Identity,\n YOrthScoreMat[i].mmul(YOrthScoreMat[i].transpose()),\n );\n\n kernelX[0][i + 1] = kernelX[0][i].mmul(ITo);\n kernelX[i + 1][i + 1] = ITo.mmul(kernelX[i][i]).mmul(ITo);\n }\n\n let lastScoreMat = (predScoreMat[this.orthogonalComp] = kernelX[0][\n this.orthogonalComp\n ]\n .transpose()\n .mmul(YScoreMat)\n .mmul(SigmaPow));\n\n let lastTpPrime = lastScoreMat.transpose();\n TURegressionCoeff[this.orthogonalComp] = inverse(\n lastTpPrime.mmul(lastScoreMat),\n )\n .mmul(lastTpPrime)\n .mmul(YScoreMat);\n\n this.YLoadingMat = YLoadingMat;\n this.SigmaPow = SigmaPow;\n this.YScoreMat = YScoreMat;\n this.predScoreMat = predScoreMat;\n this.YOrthLoadingVec = YOrthLoadingVec;\n this.YOrthEigen = YOrthEigen;\n this.YOrthScoreMat = YOrthScoreMat;\n this.toNorm = YOrthScoreNorm;\n this.TURegressionCoeff = TURegressionCoeff;\n this.kernelX = kernelX;\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|Array} toPredict\n * @return {{y: Matrix, predScoreMat: Array, predYOrthVectors: Array}} predictions\n */\n predict(toPredict) {\n let KTestTrain = this.kernel.compute(toPredict, this.trainingSet);\n\n let temp = KTestTrain;\n KTestTrain = new Array(this.orthogonalComp + 1);\n for (let i = 0; i < this.orthogonalComp + 1; i++) {\n KTestTrain[i] = new Array(this.orthogonalComp + 1);\n }\n KTestTrain[0][0] = temp;\n\n let YOrthScoreVector = new Array(this.orthogonalComp);\n let predScoreMat = new Array(this.orthogonalComp);\n\n let i;\n for (i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = KTestTrain[i][0]\n .mmul(this.YScoreMat)\n .mmul(this.SigmaPow);\n\n YOrthScoreVector[i] = Matrix.sub(\n KTestTrain[i][i],\n predScoreMat[i].mmul(this.predScoreMat[i].transpose()),\n )\n .mmul(this.predScoreMat[i])\n .mmul(this.YOrthLoadingVec[i])\n .mul(Math.pow(this.YOrthEigen[i], -0.5));\n\n YOrthScoreVector[i] = YOrthScoreVector[i].divRowVector(this.toNorm[i]);\n\n let scoreMatPrime = this.YOrthScoreMat[i].transpose();\n KTestTrain[i + 1][0] = Matrix.sub(\n KTestTrain[i][0],\n YOrthScoreVector[i]\n .mmul(scoreMatPrime)\n .mmul(this.kernelX[0][i].transpose()),\n );\n\n let p1 = Matrix.sub(\n KTestTrain[i][0],\n KTestTrain[i][i].mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime),\n );\n let p2 = YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[i][i]);\n let p3 = p2.mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime);\n\n KTestTrain[i + 1][i + 1] = p1.sub(p2).add(p3);\n }\n\n predScoreMat[i] = KTestTrain[i][0].mmul(this.YScoreMat).mmul(this.SigmaPow);\n let prediction = predScoreMat[i]\n .mmul(this.TURegressionCoeff[i])\n .mmul(this.YLoadingMat.transpose());\n\n return {\n prediction: prediction,\n predScoreMat: predScoreMat,\n predYOrthVectors: YOrthScoreVector,\n };\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n name: 'K-OPLS',\n YLoadingMat: this.YLoadingMat,\n SigmaPow: this.SigmaPow,\n YScoreMat: this.YScoreMat,\n predScoreMat: this.predScoreMat,\n YOrthLoadingVec: this.YOrthLoadingVec,\n YOrthEigen: this.YOrthEigen,\n YOrthScoreMat: this.YOrthScoreMat,\n toNorm: this.toNorm,\n TURegressionCoeff: this.TURegressionCoeff,\n kernelX: this.kernelX,\n trainingSet: this.trainingSet,\n orthogonalComp: this.orthogonalComp,\n predictiveComp: this.predictiveComp,\n };\n }\n\n /**\n * Load a K-OPLS with the given model.\n * @param {object} model\n * @param {Kernel} kernel - kernel used on the model, see [ml-kernel](https://github.com/mljs/kernel).\n * @return {KOPLS}\n */\n static load(model, kernel) {\n if (model.name !== 'K-OPLS') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n if (!kernel) {\n throw new RangeError('You must provide a kernel for the model!');\n }\n\n model.kernel = kernel;\n return new KOPLS(true, model);\n }\n}\n","/**\n * Constructs a confusion matrix\n * @class ConfusionMatrix\n * @example\n * const CM = new ConfusionMatrix([[13, 2], [10, 5]], ['cat', 'dog'])\n * @param {Array>} matrix - The confusion matrix, a 2D Array. Rows represent the actual label and columns\n * the predicted label.\n * @param {Array} labels - Labels of the confusion matrix, a 1D Array\n */\nexport default class ConfusionMatrix {\n constructor(matrix, labels) {\n if (matrix.length !== matrix[0].length) {\n throw new Error('Confusion matrix must be square');\n }\n if (labels.length !== matrix.length) {\n throw new Error(\n 'Confusion matrix and labels should have the same length',\n );\n }\n this.labels = labels;\n this.matrix = matrix;\n }\n\n /**\n * Construct confusion matrix from the predicted and actual labels (classes). Be sure to provide the arguments in\n * the correct order!\n * @param {Array} actual - The predicted labels of the classification\n * @param {Array} predicted - The actual labels of the classification. Has to be of same length as\n * predicted.\n * @param {object} [options] - Additional options\n * @param {Array} [options.labels] - The list of labels that should be used. If not provided the distinct set\n * of labels present in predicted and actual is used. Labels are compared using the strict equality operator\n * '==='\n * @return {ConfusionMatrix} - Confusion matrix\n */\n static fromLabels(actual, predicted, options = {}) {\n if (predicted.length !== actual.length) {\n throw new Error('predicted and actual must have the same length');\n }\n let distinctLabels;\n if (options.labels) {\n distinctLabels = new Set(options.labels);\n } else {\n distinctLabels = new Set([...actual, ...predicted]);\n }\n distinctLabels = Array.from(distinctLabels);\n if (options.sort) {\n distinctLabels.sort(options.sort);\n }\n\n // Create confusion matrix and fill with 0's\n const matrix = Array.from({ length: distinctLabels.length });\n for (let i = 0; i < matrix.length; i++) {\n matrix[i] = new Array(matrix.length);\n matrix[i].fill(0);\n }\n\n for (let i = 0; i < predicted.length; i++) {\n const actualIdx = distinctLabels.indexOf(actual[i]);\n const predictedIdx = distinctLabels.indexOf(predicted[i]);\n if (actualIdx >= 0 && predictedIdx >= 0) {\n matrix[actualIdx][predictedIdx]++;\n }\n }\n\n return new ConfusionMatrix(matrix, distinctLabels);\n }\n\n /**\n * Get the confusion matrix\n * @return {Array >}\n */\n getMatrix() {\n return this.matrix;\n }\n\n getLabels() {\n return this.labels;\n }\n\n /**\n * Get the total number of samples\n * @return {number}\n */\n getTotalCount() {\n let predicted = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n predicted += this.matrix[i][j];\n }\n }\n return predicted;\n }\n\n /**\n * Get the total number of true predictions\n * @return {number}\n */\n getTrueCount() {\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n count += this.matrix[i][i];\n }\n return count;\n }\n\n /**\n * Get the total number of false predictions.\n * @return {number}\n */\n getFalseCount() {\n return this.getTotalCount() - this.getTrueCount();\n }\n\n /**\n * Get the number of true positive predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTruePositiveCount(label) {\n const index = this.getIndex(label);\n return this.matrix[index][index];\n }\n\n /**\n * Get the number of true negative predictions\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTrueNegativeCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n if (i !== index && j !== index) {\n count += this.matrix[i][j];\n }\n }\n }\n return count;\n }\n\n /**\n * Get the number of false positive predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalsePositiveCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n if (i !== index) {\n count += this.matrix[i][index];\n }\n }\n return count;\n }\n\n /**\n * Get the number of false negative predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseNegativeCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n if (i !== index) {\n count += this.matrix[index][i];\n }\n }\n return count;\n }\n\n /**\n * Get the number of real positive samples.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getPositiveCount(label) {\n return this.getTruePositiveCount(label) + this.getFalseNegativeCount(label);\n }\n\n /**\n * Get the number of real negative samples.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getNegativeCount(label) {\n return this.getTrueNegativeCount(label) + this.getFalsePositiveCount(label);\n }\n\n /**\n * Get the index in the confusion matrix that corresponds to the given label\n * @param {any} label - The label to search for\n * @throws if the label is not found\n * @return {number}\n */\n getIndex(label) {\n const index = this.labels.indexOf(label);\n if (index === -1) throw new Error('The label does not exist');\n return index;\n }\n\n /**\n * Get the true positive rate a.k.a. sensitivity. Computes the ratio between the number of true positive predictions and the total number of positive samples.\n * {@link https://en.wikipedia.org/wiki/Sensitivity_and_specificity}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number} - The true positive rate [0-1]\n */\n getTruePositiveRate(label) {\n return this.getTruePositiveCount(label) / this.getPositiveCount(label);\n }\n\n /**\n * Get the true negative rate a.k.a. specificity. Computes the ration between the number of true negative predictions and the total number of negative samples.\n * {@link https://en.wikipedia.org/wiki/Sensitivity_and_specificity}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTrueNegativeRate(label) {\n return this.getTrueNegativeCount(label) / this.getNegativeCount(label);\n }\n\n /**\n * Get the positive predictive value a.k.a. precision. Computes TP / (TP + FP)\n * {@link https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getPositivePredictiveValue(label) {\n const TP = this.getTruePositiveCount(label);\n return TP / (TP + this.getFalsePositiveCount(label));\n }\n\n /**\n * Negative predictive value\n * {@link https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getNegativePredictiveValue(label) {\n const TN = this.getTrueNegativeCount(label);\n return TN / (TN + this.getFalseNegativeCount(label));\n }\n\n /**\n * False negative rate a.k.a. miss rate.\n * {@link https://en.wikipedia.org/wiki/Type_I_and_type_II_errors#False_positive_and_false_negative_rates}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseNegativeRate(label) {\n return 1 - this.getTruePositiveRate(label);\n }\n\n /**\n * False positive rate a.k.a. fall-out rate.\n * {@link https://en.wikipedia.org/wiki/Type_I_and_type_II_errors#False_positive_and_false_negative_rates}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalsePositiveRate(label) {\n return 1 - this.getTrueNegativeRate(label);\n }\n\n /**\n * False discovery rate (FDR)\n * {@link https://en.wikipedia.org/wiki/False_discovery_rate}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseDiscoveryRate(label) {\n const FP = this.getFalsePositiveCount(label);\n return FP / (FP + this.getTruePositiveCount(label));\n }\n\n /**\n * False omission rate (FOR)\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseOmissionRate(label) {\n const FN = this.getFalseNegativeCount(label);\n return FN / (FN + this.getTruePositiveCount(label));\n }\n\n /**\n * F1 score\n * {@link https://en.wikipedia.org/wiki/F1_score}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getF1Score(label) {\n const TP = this.getTruePositiveCount(label);\n return (\n (2 * TP) /\n (2 * TP +\n this.getFalsePositiveCount(label) +\n this.getFalseNegativeCount(label))\n );\n }\n\n /**\n * Matthews correlation coefficient (MCC)\n * {@link https://en.wikipedia.org/wiki/Matthews_correlation_coefficient}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getMatthewsCorrelationCoefficient(label) {\n const TP = this.getTruePositiveCount(label);\n const TN = this.getTrueNegativeCount(label);\n const FP = this.getFalsePositiveCount(label);\n const FN = this.getFalseNegativeCount(label);\n return (\n (TP * TN - FP * FN) /\n Math.sqrt((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN))\n );\n }\n\n /**\n * Informedness\n * {@link https://en.wikipedia.org/wiki/Youden%27s_J_statistic}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getInformedness(label) {\n return (\n this.getTruePositiveRate(label) + this.getTrueNegativeRate(label) - 1\n );\n }\n\n /**\n * Markedness\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getMarkedness(label) {\n return (\n this.getPositivePredictiveValue(label) +\n this.getNegativePredictiveValue(label) -\n 1\n );\n }\n\n /**\n * Get the confusion table.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {Array >} - The 2x2 confusion table. [[TP, FN], [FP, TN]]\n */\n getConfusionTable(label) {\n return [\n [this.getTruePositiveCount(label), this.getFalseNegativeCount(label)],\n [this.getFalsePositiveCount(label), this.getTrueNegativeCount(label)],\n ];\n }\n\n /**\n * Get total accuracy.\n * @return {number} - The ratio between the number of true predictions and total number of classifications ([0-1])\n */\n getAccuracy() {\n let correct = 0;\n let incorrect = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n if (i === j) correct += this.matrix[i][j];\n else incorrect += this.matrix[i][j];\n }\n }\n return correct / (correct + incorrect);\n }\n\n /**\n * Returns the element in the confusion matrix that corresponds to the given actual and predicted labels.\n * @param {any} actual - The true label\n * @param {any} predicted - The predicted label\n * @return {number} - The element in the confusion matrix\n */\n getCount(actual, predicted) {\n const actualIndex = this.getIndex(actual);\n const predictedIndex = this.getIndex(predicted);\n return this.matrix[actualIndex][predictedIndex];\n }\n\n /**\n * Compute the general prediction accuracy\n * @deprecated Use getAccuracy\n * @return {number} - The prediction accuracy ([0-1]\n */\n get accuracy() {\n return this.getAccuracy();\n }\n\n /**\n * Compute the number of predicted observations\n * @deprecated Use getTotalCount\n * @return {number}\n */\n get total() {\n return this.getTotalCount();\n }\n}\n","(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(factory());\n}(this, (function () { 'use strict';\n\n\tfunction createCommonjsModule(fn, module) {\n\t\treturn module = { exports: {} }, fn(module, module.exports), module.exports;\n\t}\n\n\tvar runtime = createCommonjsModule(function (module) {\n\t/**\n\t * Copyright (c) 2014-present, Facebook, Inc.\n\t *\n\t * This source code is licensed under the MIT license found in the\n\t * LICENSE file in the root directory of this source tree.\n\t */\n\n\t!(function(global) {\n\n\t var Op = Object.prototype;\n\t var hasOwn = Op.hasOwnProperty;\n\t var undefined; // More compressible than void 0.\n\t var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n\t var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n\t var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n\t var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\t var runtime = global.regeneratorRuntime;\n\t if (runtime) {\n\t {\n\t // If regeneratorRuntime is defined globally and we're in a module,\n\t // make the exports object identical to regeneratorRuntime.\n\t module.exports = runtime;\n\t }\n\t // Don't bother evaluating the rest of this file if the runtime was\n\t // already defined globally.\n\t return;\n\t }\n\n\t // Define the runtime globally (as expected by generated code) as either\n\t // module.exports (if we're in a module) or a new, empty object.\n\t runtime = global.regeneratorRuntime = module.exports;\n\n\t function wrap(innerFn, outerFn, self, tryLocsList) {\n\t // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n\t var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n\t var generator = Object.create(protoGenerator.prototype);\n\t var context = new Context(tryLocsList || []);\n\n\t // The ._invoke method unifies the implementations of the .next,\n\t // .throw, and .return methods.\n\t generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n\t return generator;\n\t }\n\t runtime.wrap = wrap;\n\n\t // Try/catch helper to minimize deoptimizations. Returns a completion\n\t // record like context.tryEntries[i].completion. This interface could\n\t // have been (and was previously) designed to take a closure to be\n\t // invoked without arguments, but in all the cases we care about we\n\t // already have an existing method we want to call, so there's no need\n\t // to create a new function object. We can even get away with assuming\n\t // the method takes exactly one argument, since that happens to be true\n\t // in every case, so we don't have to touch the arguments object. The\n\t // only additional allocation required is the completion record, which\n\t // has a stable shape and so hopefully should be cheap to allocate.\n\t function tryCatch(fn, obj, arg) {\n\t try {\n\t return { type: \"normal\", arg: fn.call(obj, arg) };\n\t } catch (err) {\n\t return { type: \"throw\", arg: err };\n\t }\n\t }\n\n\t var GenStateSuspendedStart = \"suspendedStart\";\n\t var GenStateSuspendedYield = \"suspendedYield\";\n\t var GenStateExecuting = \"executing\";\n\t var GenStateCompleted = \"completed\";\n\n\t // Returning this object from the innerFn has the same effect as\n\t // breaking out of the dispatch switch statement.\n\t var ContinueSentinel = {};\n\n\t // Dummy constructor functions that we use as the .constructor and\n\t // .constructor.prototype properties for functions that return Generator\n\t // objects. For full spec compliance, you may wish to configure your\n\t // minifier not to mangle the names of these two functions.\n\t function Generator() {}\n\t function GeneratorFunction() {}\n\t function GeneratorFunctionPrototype() {}\n\n\t // This is a polyfill for %IteratorPrototype% for environments that\n\t // don't natively support it.\n\t var IteratorPrototype = {};\n\t IteratorPrototype[iteratorSymbol] = function () {\n\t return this;\n\t };\n\n\t var getProto = Object.getPrototypeOf;\n\t var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n\t if (NativeIteratorPrototype &&\n\t NativeIteratorPrototype !== Op &&\n\t hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n\t // This environment has a native %IteratorPrototype%; use it instead\n\t // of the polyfill.\n\t IteratorPrototype = NativeIteratorPrototype;\n\t }\n\n\t var Gp = GeneratorFunctionPrototype.prototype =\n\t Generator.prototype = Object.create(IteratorPrototype);\n\t GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n\t GeneratorFunctionPrototype.constructor = GeneratorFunction;\n\t GeneratorFunctionPrototype[toStringTagSymbol] =\n\t GeneratorFunction.displayName = \"GeneratorFunction\";\n\n\t // Helper for defining the .next, .throw, and .return methods of the\n\t // Iterator interface in terms of a single ._invoke method.\n\t function defineIteratorMethods(prototype) {\n\t [\"next\", \"throw\", \"return\"].forEach(function(method) {\n\t prototype[method] = function(arg) {\n\t return this._invoke(method, arg);\n\t };\n\t });\n\t }\n\n\t runtime.isGeneratorFunction = function(genFun) {\n\t var ctor = typeof genFun === \"function\" && genFun.constructor;\n\t return ctor\n\t ? ctor === GeneratorFunction ||\n\t // For the native GeneratorFunction constructor, the best we can\n\t // do is to check its .name property.\n\t (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n\t : false;\n\t };\n\n\t runtime.mark = function(genFun) {\n\t if (Object.setPrototypeOf) {\n\t Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n\t } else {\n\t genFun.__proto__ = GeneratorFunctionPrototype;\n\t if (!(toStringTagSymbol in genFun)) {\n\t genFun[toStringTagSymbol] = \"GeneratorFunction\";\n\t }\n\t }\n\t genFun.prototype = Object.create(Gp);\n\t return genFun;\n\t };\n\n\t // Within the body of any async function, `await x` is transformed to\n\t // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n\t // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n\t // meant to be awaited.\n\t runtime.awrap = function(arg) {\n\t return { __await: arg };\n\t };\n\n\t function AsyncIterator(generator) {\n\t function invoke(method, arg, resolve, reject) {\n\t var record = tryCatch(generator[method], generator, arg);\n\t if (record.type === \"throw\") {\n\t reject(record.arg);\n\t } else {\n\t var result = record.arg;\n\t var value = result.value;\n\t if (value &&\n\t typeof value === \"object\" &&\n\t hasOwn.call(value, \"__await\")) {\n\t return Promise.resolve(value.__await).then(function(value) {\n\t invoke(\"next\", value, resolve, reject);\n\t }, function(err) {\n\t invoke(\"throw\", err, resolve, reject);\n\t });\n\t }\n\n\t return Promise.resolve(value).then(function(unwrapped) {\n\t // When a yielded Promise is resolved, its final value becomes\n\t // the .value of the Promise<{value,done}> result for the\n\t // current iteration. If the Promise is rejected, however, the\n\t // result for this iteration will be rejected with the same\n\t // reason. Note that rejections of yielded Promises are not\n\t // thrown back into the generator function, as is the case\n\t // when an awaited Promise is rejected. This difference in\n\t // behavior between yield and await is important, because it\n\t // allows the consumer to decide what to do with the yielded\n\t // rejection (swallow it and continue, manually .throw it back\n\t // into the generator, abandon iteration, whatever). With\n\t // await, by contrast, there is no opportunity to examine the\n\t // rejection reason outside the generator function, so the\n\t // only option is to throw it from the await expression, and\n\t // let the generator function handle the exception.\n\t result.value = unwrapped;\n\t resolve(result);\n\t }, reject);\n\t }\n\t }\n\n\t var previousPromise;\n\n\t function enqueue(method, arg) {\n\t function callInvokeWithMethodAndArg() {\n\t return new Promise(function(resolve, reject) {\n\t invoke(method, arg, resolve, reject);\n\t });\n\t }\n\n\t return previousPromise =\n\t // If enqueue has been called before, then we want to wait until\n\t // all previous Promises have been resolved before calling invoke,\n\t // so that results are always delivered in the correct order. If\n\t // enqueue has not been called before, then it is important to\n\t // call invoke immediately, without waiting on a callback to fire,\n\t // so that the async generator function has the opportunity to do\n\t // any necessary setup in a predictable way. This predictability\n\t // is why the Promise constructor synchronously invokes its\n\t // executor callback, and why async functions synchronously\n\t // execute code before the first await. Since we implement simple\n\t // async functions in terms of async generators, it is especially\n\t // important to get this right, even though it requires care.\n\t previousPromise ? previousPromise.then(\n\t callInvokeWithMethodAndArg,\n\t // Avoid propagating failures to Promises returned by later\n\t // invocations of the iterator.\n\t callInvokeWithMethodAndArg\n\t ) : callInvokeWithMethodAndArg();\n\t }\n\n\t // Define the unified helper method that is used to implement .next,\n\t // .throw, and .return (see defineIteratorMethods).\n\t this._invoke = enqueue;\n\t }\n\n\t defineIteratorMethods(AsyncIterator.prototype);\n\t AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n\t return this;\n\t };\n\t runtime.AsyncIterator = AsyncIterator;\n\n\t // Note that simple async functions are implemented on top of\n\t // AsyncIterator objects; they just return a Promise for the value of\n\t // the final result produced by the iterator.\n\t runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n\t var iter = new AsyncIterator(\n\t wrap(innerFn, outerFn, self, tryLocsList)\n\t );\n\n\t return runtime.isGeneratorFunction(outerFn)\n\t ? iter // If outerFn is a generator, return the full iterator.\n\t : iter.next().then(function(result) {\n\t return result.done ? result.value : iter.next();\n\t });\n\t };\n\n\t function makeInvokeMethod(innerFn, self, context) {\n\t var state = GenStateSuspendedStart;\n\n\t return function invoke(method, arg) {\n\t if (state === GenStateExecuting) {\n\t throw new Error(\"Generator is already running\");\n\t }\n\n\t if (state === GenStateCompleted) {\n\t if (method === \"throw\") {\n\t throw arg;\n\t }\n\n\t // Be forgiving, per 25.3.3.3.3 of the spec:\n\t // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n\t return doneResult();\n\t }\n\n\t context.method = method;\n\t context.arg = arg;\n\n\t while (true) {\n\t var delegate = context.delegate;\n\t if (delegate) {\n\t var delegateResult = maybeInvokeDelegate(delegate, context);\n\t if (delegateResult) {\n\t if (delegateResult === ContinueSentinel) continue;\n\t return delegateResult;\n\t }\n\t }\n\n\t if (context.method === \"next\") {\n\t // Setting context._sent for legacy support of Babel's\n\t // function.sent implementation.\n\t context.sent = context._sent = context.arg;\n\n\t } else if (context.method === \"throw\") {\n\t if (state === GenStateSuspendedStart) {\n\t state = GenStateCompleted;\n\t throw context.arg;\n\t }\n\n\t context.dispatchException(context.arg);\n\n\t } else if (context.method === \"return\") {\n\t context.abrupt(\"return\", context.arg);\n\t }\n\n\t state = GenStateExecuting;\n\n\t var record = tryCatch(innerFn, self, context);\n\t if (record.type === \"normal\") {\n\t // If an exception is thrown from innerFn, we leave state ===\n\t // GenStateExecuting and loop back for another invocation.\n\t state = context.done\n\t ? GenStateCompleted\n\t : GenStateSuspendedYield;\n\n\t if (record.arg === ContinueSentinel) {\n\t continue;\n\t }\n\n\t return {\n\t value: record.arg,\n\t done: context.done\n\t };\n\n\t } else if (record.type === \"throw\") {\n\t state = GenStateCompleted;\n\t // Dispatch the exception by looping back around to the\n\t // context.dispatchException(context.arg) call above.\n\t context.method = \"throw\";\n\t context.arg = record.arg;\n\t }\n\t }\n\t };\n\t }\n\n\t // Call delegate.iterator[context.method](context.arg) and handle the\n\t // result, either by returning a { value, done } result from the\n\t // delegate iterator, or by modifying context.method and context.arg,\n\t // setting context.delegate to null, and returning the ContinueSentinel.\n\t function maybeInvokeDelegate(delegate, context) {\n\t var method = delegate.iterator[context.method];\n\t if (method === undefined) {\n\t // A .throw or .return when the delegate iterator has no .throw\n\t // method always terminates the yield* loop.\n\t context.delegate = null;\n\n\t if (context.method === \"throw\") {\n\t if (delegate.iterator.return) {\n\t // If the delegate iterator has a return method, give it a\n\t // chance to clean up.\n\t context.method = \"return\";\n\t context.arg = undefined;\n\t maybeInvokeDelegate(delegate, context);\n\n\t if (context.method === \"throw\") {\n\t // If maybeInvokeDelegate(context) changed context.method from\n\t // \"return\" to \"throw\", let that override the TypeError below.\n\t return ContinueSentinel;\n\t }\n\t }\n\n\t context.method = \"throw\";\n\t context.arg = new TypeError(\n\t \"The iterator does not provide a 'throw' method\");\n\t }\n\n\t return ContinueSentinel;\n\t }\n\n\t var record = tryCatch(method, delegate.iterator, context.arg);\n\n\t if (record.type === \"throw\") {\n\t context.method = \"throw\";\n\t context.arg = record.arg;\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t var info = record.arg;\n\n\t if (! info) {\n\t context.method = \"throw\";\n\t context.arg = new TypeError(\"iterator result is not an object\");\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t if (info.done) {\n\t // Assign the result of the finished delegate to the temporary\n\t // variable specified by delegate.resultName (see delegateYield).\n\t context[delegate.resultName] = info.value;\n\n\t // Resume execution at the desired location (see delegateYield).\n\t context.next = delegate.nextLoc;\n\n\t // If context.method was \"throw\" but the delegate handled the\n\t // exception, let the outer generator proceed normally. If\n\t // context.method was \"next\", forget context.arg since it has been\n\t // \"consumed\" by the delegate iterator. If context.method was\n\t // \"return\", allow the original .return call to continue in the\n\t // outer generator.\n\t if (context.method !== \"return\") {\n\t context.method = \"next\";\n\t context.arg = undefined;\n\t }\n\n\t } else {\n\t // Re-yield the result returned by the delegate method.\n\t return info;\n\t }\n\n\t // The delegate iterator is finished, so forget it and continue with\n\t // the outer generator.\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t // Define Generator.prototype.{next,throw,return} in terms of the\n\t // unified ._invoke helper method.\n\t defineIteratorMethods(Gp);\n\n\t Gp[toStringTagSymbol] = \"Generator\";\n\n\t // A Generator should always return itself as the iterator object when the\n\t // @@iterator function is called on it. Some browsers' implementations of the\n\t // iterator prototype chain incorrectly implement this, causing the Generator\n\t // object to not be returned from this call. This ensures that doesn't happen.\n\t // See https://github.com/facebook/regenerator/issues/274 for more details.\n\t Gp[iteratorSymbol] = function() {\n\t return this;\n\t };\n\n\t Gp.toString = function() {\n\t return \"[object Generator]\";\n\t };\n\n\t function pushTryEntry(locs) {\n\t var entry = { tryLoc: locs[0] };\n\n\t if (1 in locs) {\n\t entry.catchLoc = locs[1];\n\t }\n\n\t if (2 in locs) {\n\t entry.finallyLoc = locs[2];\n\t entry.afterLoc = locs[3];\n\t }\n\n\t this.tryEntries.push(entry);\n\t }\n\n\t function resetTryEntry(entry) {\n\t var record = entry.completion || {};\n\t record.type = \"normal\";\n\t delete record.arg;\n\t entry.completion = record;\n\t }\n\n\t function Context(tryLocsList) {\n\t // The root entry object (effectively a try statement without a catch\n\t // or a finally block) gives us a place to store values thrown from\n\t // locations where there is no enclosing try statement.\n\t this.tryEntries = [{ tryLoc: \"root\" }];\n\t tryLocsList.forEach(pushTryEntry, this);\n\t this.reset(true);\n\t }\n\n\t runtime.keys = function(object) {\n\t var keys = [];\n\t for (var key in object) {\n\t keys.push(key);\n\t }\n\t keys.reverse();\n\n\t // Rather than returning an object with a next method, we keep\n\t // things simple and return the next function itself.\n\t return function next() {\n\t while (keys.length) {\n\t var key = keys.pop();\n\t if (key in object) {\n\t next.value = key;\n\t next.done = false;\n\t return next;\n\t }\n\t }\n\n\t // To avoid creating an additional object, we just hang the .value\n\t // and .done properties off the next function object itself. This\n\t // also ensures that the minifier will not anonymize the function.\n\t next.done = true;\n\t return next;\n\t };\n\t };\n\n\t function values(iterable) {\n\t if (iterable) {\n\t var iteratorMethod = iterable[iteratorSymbol];\n\t if (iteratorMethod) {\n\t return iteratorMethod.call(iterable);\n\t }\n\n\t if (typeof iterable.next === \"function\") {\n\t return iterable;\n\t }\n\n\t if (!isNaN(iterable.length)) {\n\t var i = -1, next = function next() {\n\t while (++i < iterable.length) {\n\t if (hasOwn.call(iterable, i)) {\n\t next.value = iterable[i];\n\t next.done = false;\n\t return next;\n\t }\n\t }\n\n\t next.value = undefined;\n\t next.done = true;\n\n\t return next;\n\t };\n\n\t return next.next = next;\n\t }\n\t }\n\n\t // Return an iterator with no values.\n\t return { next: doneResult };\n\t }\n\t runtime.values = values;\n\n\t function doneResult() {\n\t return { value: undefined, done: true };\n\t }\n\n\t Context.prototype = {\n\t constructor: Context,\n\n\t reset: function(skipTempReset) {\n\t this.prev = 0;\n\t this.next = 0;\n\t // Resetting context._sent for legacy support of Babel's\n\t // function.sent implementation.\n\t this.sent = this._sent = undefined;\n\t this.done = false;\n\t this.delegate = null;\n\n\t this.method = \"next\";\n\t this.arg = undefined;\n\n\t this.tryEntries.forEach(resetTryEntry);\n\n\t if (!skipTempReset) {\n\t for (var name in this) {\n\t // Not sure about the optimal order of these conditions:\n\t if (name.charAt(0) === \"t\" &&\n\t hasOwn.call(this, name) &&\n\t !isNaN(+name.slice(1))) {\n\t this[name] = undefined;\n\t }\n\t }\n\t }\n\t },\n\n\t stop: function() {\n\t this.done = true;\n\n\t var rootEntry = this.tryEntries[0];\n\t var rootRecord = rootEntry.completion;\n\t if (rootRecord.type === \"throw\") {\n\t throw rootRecord.arg;\n\t }\n\n\t return this.rval;\n\t },\n\n\t dispatchException: function(exception) {\n\t if (this.done) {\n\t throw exception;\n\t }\n\n\t var context = this;\n\t function handle(loc, caught) {\n\t record.type = \"throw\";\n\t record.arg = exception;\n\t context.next = loc;\n\n\t if (caught) {\n\t // If the dispatched exception was caught by a catch block,\n\t // then let that catch block handle the exception normally.\n\t context.method = \"next\";\n\t context.arg = undefined;\n\t }\n\n\t return !! caught;\n\t }\n\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t var record = entry.completion;\n\n\t if (entry.tryLoc === \"root\") {\n\t // Exception thrown outside of any try block that could handle\n\t // it, so set the completion value of the entire function to\n\t // throw the exception.\n\t return handle(\"end\");\n\t }\n\n\t if (entry.tryLoc <= this.prev) {\n\t var hasCatch = hasOwn.call(entry, \"catchLoc\");\n\t var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n\t if (hasCatch && hasFinally) {\n\t if (this.prev < entry.catchLoc) {\n\t return handle(entry.catchLoc, true);\n\t } else if (this.prev < entry.finallyLoc) {\n\t return handle(entry.finallyLoc);\n\t }\n\n\t } else if (hasCatch) {\n\t if (this.prev < entry.catchLoc) {\n\t return handle(entry.catchLoc, true);\n\t }\n\n\t } else if (hasFinally) {\n\t if (this.prev < entry.finallyLoc) {\n\t return handle(entry.finallyLoc);\n\t }\n\n\t } else {\n\t throw new Error(\"try statement without catch or finally\");\n\t }\n\t }\n\t }\n\t },\n\n\t abrupt: function(type, arg) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.tryLoc <= this.prev &&\n\t hasOwn.call(entry, \"finallyLoc\") &&\n\t this.prev < entry.finallyLoc) {\n\t var finallyEntry = entry;\n\t break;\n\t }\n\t }\n\n\t if (finallyEntry &&\n\t (type === \"break\" ||\n\t type === \"continue\") &&\n\t finallyEntry.tryLoc <= arg &&\n\t arg <= finallyEntry.finallyLoc) {\n\t // Ignore the finally entry if control is not jumping to a\n\t // location outside the try/catch block.\n\t finallyEntry = null;\n\t }\n\n\t var record = finallyEntry ? finallyEntry.completion : {};\n\t record.type = type;\n\t record.arg = arg;\n\n\t if (finallyEntry) {\n\t this.method = \"next\";\n\t this.next = finallyEntry.finallyLoc;\n\t return ContinueSentinel;\n\t }\n\n\t return this.complete(record);\n\t },\n\n\t complete: function(record, afterLoc) {\n\t if (record.type === \"throw\") {\n\t throw record.arg;\n\t }\n\n\t if (record.type === \"break\" ||\n\t record.type === \"continue\") {\n\t this.next = record.arg;\n\t } else if (record.type === \"return\") {\n\t this.rval = this.arg = record.arg;\n\t this.method = \"return\";\n\t this.next = \"end\";\n\t } else if (record.type === \"normal\" && afterLoc) {\n\t this.next = afterLoc;\n\t }\n\n\t return ContinueSentinel;\n\t },\n\n\t finish: function(finallyLoc) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.finallyLoc === finallyLoc) {\n\t this.complete(entry.completion, entry.afterLoc);\n\t resetTryEntry(entry);\n\t return ContinueSentinel;\n\t }\n\t }\n\t },\n\n\t \"catch\": function(tryLoc) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.tryLoc === tryLoc) {\n\t var record = entry.completion;\n\t if (record.type === \"throw\") {\n\t var thrown = record.arg;\n\t resetTryEntry(entry);\n\t }\n\t return thrown;\n\t }\n\t }\n\n\t // The context.catch method must only be called with a location\n\t // argument that corresponds to a known catch block.\n\t throw new Error(\"illegal catch attempt\");\n\t },\n\n\t delegateYield: function(iterable, resultName, nextLoc) {\n\t this.delegate = {\n\t iterator: values(iterable),\n\t resultName: resultName,\n\t nextLoc: nextLoc\n\t };\n\n\t if (this.method === \"next\") {\n\t // Deliberately forget the last sent value so that we don't\n\t // accidentally pass it on to the delegate.\n\t this.arg = undefined;\n\t }\n\n\t return ContinueSentinel;\n\t }\n\t };\n\t})(\n\t // In sloppy mode, unbound `this` refers to the global object, fallback to\n\t // Function constructor if we're in global strict mode. That is sadly a form\n\t // of indirect eval which violates Content Security Policy.\n\t (function() { return this })() || Function(\"return this\")()\n\t);\n\t});\n\n\t/**\n\t * Copyright (c) 2014-present, Facebook, Inc.\n\t *\n\t * This source code is licensed under the MIT license found in the\n\t * LICENSE file in the root directory of this source tree.\n\t */\n\n\t// This method of obtaining a reference to the global object needs to be\n\t// kept identical to the way it is obtained in runtime.js\n\tvar g = (function() { return this })() || Function(\"return this\")();\n\n\t// Use `getOwnPropertyNames` because not all browsers support calling\n\t// `hasOwnProperty` on the global `self` object in a worker. See #183.\n\tvar hadRuntime = g.regeneratorRuntime &&\n\t Object.getOwnPropertyNames(g).indexOf(\"regeneratorRuntime\") >= 0;\n\n\t// Save the old regeneratorRuntime in case it needs to be restored later.\n\tvar oldRuntime = hadRuntime && g.regeneratorRuntime;\n\n\t// Force reevalutation of runtime.js.\n\tg.regeneratorRuntime = undefined;\n\n\tvar runtimeModule = runtime;\n\n\tif (hadRuntime) {\n\t // Restore the original runtime.\n\t g.regeneratorRuntime = oldRuntime;\n\t} else {\n\t // Remove the global property added by runtime.js.\n\t try {\n\t delete g.regeneratorRuntime;\n\t } catch(e) {\n\t g.regeneratorRuntime = undefined;\n\t }\n\t}\n\n\tvar regenerator = runtimeModule;\n\n\tvar defaultOptions = {\n\t mode: 'index'\n\t};\n\n\tmodule.exports = /*#__PURE__*/regenerator.mark(function _callee(M, N, options) {\n\t var a, c, b, p, x, y, z, i, twiddle;\n\t return regenerator.wrap(function _callee$(_context) {\n\t while (1) {\n\t switch (_context.prev = _context.next) {\n\t case 0:\n\t twiddle = function twiddle() {\n\t var i, j, k;\n\t j = 1;\n\t while (p[j] <= 0) {\n\t j++;\n\t }\n\t if (p[j - 1] === 0) {\n\t for (i = j - 1; i !== 1; i--) {\n\t p[i] = -1;\n\t }\n\t p[j] = 0;\n\t x = z = 0;\n\t p[1] = 1;\n\t y = j - 1;\n\t } else {\n\t if (j > 1) {\n\t p[j - 1] = 0;\n\t }\n\t do {\n\t j++;\n\t } while (p[j] > 0);\n\t k = j - 1;\n\t i = j;\n\t while (p[i] === 0) {\n\t p[i++] = -1;\n\t }\n\t if (p[i] === -1) {\n\t p[i] = p[k];\n\t z = p[k] - 1;\n\t x = i - 1;\n\t y = k - 1;\n\t p[k] = -1;\n\t } else {\n\t if (i === p[0]) {\n\t return 0;\n\t } else {\n\t p[j] = p[i];\n\t z = p[i] - 1;\n\t p[i] = 0;\n\t x = j - 1;\n\t y = i - 1;\n\t }\n\t }\n\t }\n\t return 1;\n\t };\n\n\t options = Object.assign({}, defaultOptions, options);\n\t a = new Array(N);\n\t c = new Array(M);\n\t b = new Array(N);\n\t p = new Array(N + 2);\n\n\n\t // init a and b\n\t for (i = 0; i < N; i++) {\n\t a[i] = i;\n\t if (i < N - M) b[i] = 0;else b[i] = 1;\n\t }\n\n\t // init c\n\t for (i = 0; i < M; i++) {\n\t c[i] = N - M + i;\n\t }\n\n\t // init p\n\t for (i = 0; i < p.length; i++) {\n\t if (i === 0) p[i] = N + 1;else if (i <= N - M) p[i] = 0;else if (i <= N) p[i] = i - N + M;else p[i] = -2;\n\t }\n\n\t if (!(options.mode === 'index')) {\n\t _context.next = 20;\n\t break;\n\t }\n\n\t _context.next = 12;\n\t return c.slice();\n\n\t case 12:\n\t if (!twiddle()) {\n\t _context.next = 18;\n\t break;\n\t }\n\n\t c[z] = a[x];\n\t _context.next = 16;\n\t return c.slice();\n\n\t case 16:\n\t _context.next = 12;\n\t break;\n\n\t case 18:\n\t _context.next = 33;\n\t break;\n\n\t case 20:\n\t if (!(options.mode === 'mask')) {\n\t _context.next = 32;\n\t break;\n\t }\n\n\t _context.next = 23;\n\t return b.slice();\n\n\t case 23:\n\t if (!twiddle()) {\n\t _context.next = 30;\n\t break;\n\t }\n\n\t b[x] = 1;\n\t b[y] = 0;\n\t _context.next = 28;\n\t return b.slice();\n\n\t case 28:\n\t _context.next = 23;\n\t break;\n\n\t case 30:\n\t _context.next = 33;\n\t break;\n\n\t case 32:\n\t throw new Error('Invalid mode');\n\n\t case 33:\n\t case 'end':\n\t return _context.stop();\n\t }\n\t }\n\t }, _callee, this);\n\t});\n\n})));\n","/**\n * get folds indexes\n * @param {Array} features\n * @param {Number} k - number of folds, a\n */\nexport function getFolds(features, k = 5) {\n let N = features.length;\n let allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n\n let l = Math.floor(N / k);\n // create random k-folds\n let current = [];\n let folds = [];\n while (allIdx.length) {\n let randi = Math.floor(Math.random() * allIdx.length);\n current.push(allIdx[randi]);\n allIdx.splice(randi, 1);\n if (current.length === l) {\n folds.push(current);\n current = [];\n }\n }\n // we push the remaining to the last fold so that the total length is\n // preserved. Otherwise the Q2 will fail.\n if (current.length) current.forEach((e) => folds[k - 1].push(e));\n folds = folds.slice(0, k);\n\n let foldsIndex = folds.map((x, idx) => ({\n testIndex: x,\n trainIndex: [].concat(...folds.filter((el, idx2) => idx2 !== idx)),\n }));\n return foldsIndex;\n}\n","/**\n * A function to sample a dataset maintaining classes equilibrated\n * @param {Array} classVector - an array containing class or group information\n * @param {Number} fraction - a fraction of the class to sample\n * @return {Object} - an object with indexes\n */\n\nexport function sampleAClass(classVector, fraction) {\n // sort the vector\n let classVectorSorted = JSON.parse(JSON.stringify(classVector));\n let result = Array.from(Array(classVectorSorted.length).keys()).sort((a, b) =>\n classVectorSorted[a] < classVectorSorted[b]\n ? -1\n : (classVectorSorted[b] < classVectorSorted[a]) | 0,\n );\n classVectorSorted.sort((a, b) => (a < b ? -1 : (b < a) | 0));\n\n // counts the class elements\n let counts = {};\n classVectorSorted.forEach((x) => (counts[x] = (counts[x] || 0) + 1));\n\n // pick a few per class\n let indexOfSelected = [];\n\n Object.keys(counts).forEach((e, i) => {\n let shift = [];\n Object.values(counts).reduce((a, c, item) => (shift[item] = a + c), 0);\n\n let arr = [...Array(counts[e]).keys()];\n\n let r = [];\n for (let j = 0; j < Math.floor(counts[e] * fraction); j++) {\n let n = arr[Math.floor(Math.random() * arr.length)];\n r.push(n);\n let ind = arr.indexOf(n);\n arr.splice(ind, 1);\n }\n\n if (i === 0) {\n indexOfSelected = indexOfSelected.concat(r);\n } else {\n indexOfSelected = indexOfSelected.concat(r.map((x) => x + shift[i - 1]));\n }\n });\n\n // sort back the index\n let trainIndex = [];\n indexOfSelected.forEach((e) => trainIndex.push(result[e]));\n\n let testIndex = [];\n let mask = [];\n classVector.forEach((el, idx) => {\n if (trainIndex.includes(idx)) {\n mask.push(true);\n } else {\n mask.push(false);\n testIndex.push(idx);\n }\n });\n return { trainIndex, testIndex, mask };\n}\n","import ConfusionMatrix from 'ml-confusion-matrix';\nimport combinations from 'ml-combinations';\n\nimport { getFolds } from './getFolds.js';\n\nexport { sampleAClass } from './sampleAClass.js';\nexport { getFolds } from './getFolds.js';\n\n/**\n * Performs a leave-one-out cross-validation (LOO-CV) of the given samples. In LOO-CV, 1 observation is used as the\n * validation set while the rest is used as the training set. This is repeated once for each observation. LOO-CV is a\n * special case of LPO-CV. @see leavePout\n * @param {function} Classifier - The classifier's constructor to use for the cross validation. Expect ml-classifier\n * api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\n\nexport function leaveOneOut(Classifier, features, labels, classifierOptions) {\n if (typeof labels === 'function') {\n let callback = labels;\n labels = features;\n features = Classifier;\n return leavePOut(features, labels, 1, callback);\n }\n return leavePOut(Classifier, features, labels, classifierOptions, 1);\n}\n\n/**\n * Performs a leave-p-out cross-validation (LPO-CV) of the given samples. In LPO-CV, p observations are used as the\n * validation set while the rest is used as the training set. This is repeated as many times as there are possible\n * ways to combine p observations from the set (unordered without replacement). Be aware that for relatively small\n * data-set size this can require a very large number of training and testing to do!\n * @param {function} Classifier - The classifier's constructor to use for the cross validation. Expect ml-classifier\n * api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @param {number} p - The size of the validation sub-samples' set\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\nexport function leavePOut(Classifier, features, labels, classifierOptions, p) {\n let callback;\n if (typeof classifierOptions === 'function') {\n callback = classifierOptions;\n p = labels;\n labels = features;\n features = Classifier;\n }\n check(features, labels);\n const distinct = getDistinct(labels);\n const confusionMatrix = initMatrix(distinct.length, distinct.length);\n\n let N = features.length;\n let gen = combinations(p, N);\n let allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n for (const testIdx of gen) {\n let trainIdx = allIdx.slice();\n\n for (let i = testIdx.length - 1; i >= 0; i--) {\n trainIdx.splice(testIdx[i], 1);\n }\n\n if (callback) {\n validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n );\n } else {\n validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n );\n }\n }\n\n return new ConfusionMatrix(confusionMatrix, distinct);\n}\n\n/**\n * Performs k-fold cross-validation (KF-CV). KF-CV separates the data-set into k random equally sized partitions, and\n * uses each as a validation set, with all other partitions used in the training set. Observations left over from if k\n * does not divide the number of observations are left out of the cross-validation process.\n * @param {function} Classifier - The classifier's to use for the cross validation. Expect ml-classifier api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @param {number} k - The number of partitions to create\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\nexport function kFold(Classifier, features, labels, classifierOptions, k) {\n let callback;\n if (typeof classifierOptions === 'function') {\n callback = classifierOptions;\n k = labels;\n labels = features;\n features = Classifier;\n }\n check(features, labels);\n const distinct = getDistinct(labels);\n const confusionMatrix = initMatrix(distinct.length, distinct.length);\n\n let folds = getFolds(features, k);\n\n for (let i = 0; i < folds.length; i++) {\n let testIdx = folds[i].testIndex;\n let trainIdx = folds[i].trainIndex;\n\n if (callback) {\n validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n );\n } else {\n validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n );\n }\n }\n\n return new ConfusionMatrix(confusionMatrix, distinct);\n}\n\nfunction check(features, labels) {\n if (features.length !== labels.length) {\n throw new Error('features and labels should have the same length');\n }\n}\n\nfunction initMatrix(rows, columns) {\n return new Array(rows).fill(0).map(() => new Array(columns).fill(0));\n}\n\nfunction getDistinct(arr) {\n let s = new Set();\n for (let i = 0; i < arr.length; i++) {\n s.add(arr[i]);\n }\n return Array.from(s);\n}\n\nfunction validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n) {\n const { testFeatures, trainFeatures, testLabels, trainLabels } = getTrainTest(\n features,\n labels,\n testIdx,\n trainIdx,\n );\n\n let classifier;\n if (Classifier.prototype.train) {\n classifier = new Classifier(classifierOptions);\n classifier.train(trainFeatures, trainLabels);\n } else {\n classifier = new Classifier(trainFeatures, trainLabels, classifierOptions);\n }\n\n let predictedLabels = classifier.predict(testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n) {\n const { testFeatures, trainFeatures, testLabels, trainLabels } = getTrainTest(\n features,\n labels,\n testIdx,\n trainIdx,\n );\n const predictedLabels = callback(trainFeatures, trainLabels, testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction updateConfusionMatrix(\n confusionMatrix,\n testLabels,\n predictedLabels,\n distinct,\n) {\n for (let i = 0; i < predictedLabels.length; i++) {\n const actualIdx = distinct.indexOf(testLabels[i]);\n const predictedIdx = distinct.indexOf(predictedLabels[i]);\n if (actualIdx < 0 || predictedIdx < 0) {\n // eslint-disable-next-line no-console\n console.warn(`ignore unknown predicted label ${predictedLabels[i]}`);\n }\n confusionMatrix[actualIdx][predictedIdx]++;\n }\n}\n\nexport function getTrainTest(features, labels, testIdx, trainIdx) {\n return {\n testFeatures: testIdx.map(function(index) {\n return features[index];\n }),\n trainFeatures: trainIdx.map(function(index) {\n return features[index];\n }),\n testLabels: testIdx.map(function(index) {\n return labels[index];\n }),\n trainLabels: trainIdx.map(function(index) {\n return labels[index];\n }),\n };\n}\n","import Matrix from 'ml-matrix';\n\nimport { norm } from './util/utils.js';\n\n/**\n * OPLS loop\n * @param {Array} x a matrix with features\n * @param {Array} y an array of labels (dependent variable)\n * @param {Object} options an object with options\n * @return {Object} an object with model (filteredX: err,\n loadingsXOrtho: pOrtho,\n scoresXOrtho: tOrtho,\n weightsXOrtho: wOrtho,\n weightsPred: w,\n loadingsXpred: p,\n scoresXpred: t,\n loadingsY:)\n */\nexport function OPLSNipals(x, y, options = {}) {\n const { numberOSC = 100 } = options;\n\n let X = Matrix.checkMatrix(x);\n let Y = Matrix.checkMatrix(y);\n\n let u = Y.getColumnVector(0);\n\n let diff = 1;\n let t, c, w, uNew;\n for (let i = 0; i < numberOSC && diff > 1e-10; i++) {\n w = u\n .transpose()\n .mmul(X)\n .div(\n u\n .transpose()\n .mmul(u)\n .get(0, 0),\n );\n w = w.transpose().div(norm(w));\n\n t = X.mmul(w).div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n ); // t_h paso 3\n\n // calc loading\n c = t\n .transpose()\n .mmul(Y)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n\n // calc new u and compare with one in previus iteration (stop criterion)\n uNew = Y.mmul(c.transpose());\n uNew = uNew.div(\n c\n .transpose()\n .mmul(c)\n .get(0, 0),\n );\n\n if (i > 0) {\n diff =\n uNew\n .clone()\n .sub(u)\n .pow(2)\n .sum() /\n uNew\n .clone()\n .pow(2)\n .sum();\n }\n\n u = uNew.clone();\n }\n\n // calc loadings\n let p = t\n .transpose()\n .mmul(X)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n\n let wOrtho = p.clone().sub(\n w\n .transpose()\n .mmul(p.transpose())\n .div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n )\n .mmul(w.transpose()),\n );\n wOrtho.div(norm(wOrtho));\n\n // orthogonal scores\n let tOrtho = X.mmul(wOrtho.transpose()).div(\n wOrtho.mmul(wOrtho.transpose()).get(0, 0),\n );\n\n // orthogonal loadings\n let pOrtho = tOrtho\n .transpose()\n .mmul(X)\n .div(\n tOrtho\n .transpose()\n .mmul(tOrtho)\n .get(0, 0),\n );\n\n // filtered data\n let err = X.clone().sub(tOrtho.mmul(pOrtho));\n return {\n filteredX: err,\n weightsXOrtho: wOrtho,\n loadingsXOrtho: pOrtho,\n scoresXOrtho: tOrtho,\n weightsXPred: w,\n loadingsXpred: p,\n scoresXpred: t,\n loadingsY: c,\n };\n}\n","import { Matrix } from 'ml-matrix';\n\n/**\n * Get total sum of square\n * @param {Array} x an array\n * @return {Number} - the sum of the squares\n */\nexport function tss(x) {\n return Matrix.mul(x, x).sum();\n}\n","import { Matrix, NIPALS } from 'ml-matrix';\nimport ConfusionMatrix from 'ml-confusion-matrix';\nimport { getFolds } from 'ml-cross-validation';\n\nimport { OPLSNipals } from './OPLSNipals.js';\nimport { tss } from './util/tss.js';\n\n/**\n * Creates new OPLS (orthogonal partial latent structures) from features and labels.\n * @param {Matrix} data - matrix containing data (X).\n * @param {Array} labels - 1D Array containing metadata (Y).\n * @param {Object} [options]\n * @param {number} [options.nComp = 3] - number of latent structures computed.\n * @param {boolean} [options.center = true] - should the data be centered (subtract the mean).\n * @param {boolean} [options.scale = false] - should the data be scaled (divide by the standard deviation).\n * @param {Array} [options.cvFolds = []] - allows to provide folds as 2D array for testing purpose.\n * */\n\nexport class OPLS {\n constructor(data, labels, options = {}) {\n if (data === true) {\n const opls = options;\n this.center = opls.center;\n this.scale = opls.scale;\n this.means = opls.means;\n this.meansY = opls.meansY;\n this.stdevs = opls.stdevs;\n this.stdevs = opls.stdevsY;\n this.model = opls.model;\n this.tCV = opls.tCV;\n this.tOrthCV = opls.tOrthCV;\n this.yHatCV = opls.yHatCV;\n this.mode = opls.mode;\n return;\n }\n\n let features = data.clone();\n // set default values\n // cvFolds allows to define folds for testing purpose\n const { nComp = 3, center = true, scale = true, cvFolds = [] } = options;\n\n let group;\n if (typeof labels[0] === 'number') {\n // numeric labels: OPLS regression is used\n this.mode = 'regression';\n group = Matrix.from1DArray(labels.length, 1, labels);\n } else if (typeof labels[0] === 'string') {\n // non-numeric labels: OPLS-DA is used\n this.mode = 'discriminantAnalysis';\n group = labels;\n throw new Error('discriminant analysis is not yet supported');\n }\n\n // check types of features and labels\n if (features.constructor.name !== 'Matrix') {\n throw new TypeError('features must be of class Matrix');\n }\n // getting center and scale the features (all)\n this.center = center;\n if (this.center) {\n this.means = features.mean('column');\n this.meansY = group.mean('column');\n } else {\n this.stdevs = null;\n }\n this.scale = scale;\n if (this.scale) {\n this.stdevs = features.standardDeviation('column');\n this.stdevsY = group.standardDeviation('column');\n } else {\n this.means = null;\n }\n\n // check and remove for features with sd = 0 TODO here\n // check opls.R line 70\n\n let folds;\n if (cvFolds.length > 0) {\n folds = cvFolds;\n } else {\n folds = getFolds(labels, 5);\n }\n\n let Q2 = [];\n this.model = [];\n\n this.tCV = [];\n this.tOrthCV = [];\n this.yHatCV = [];\n let oplsCV = [];\n\n let modelNC = [];\n\n // this code could be made more efficient by reverting the order of the loops\n // this is a legacy loop to be consistent with R code from MetaboMate package\n // this allows for having statistic (R2) from CV to decide wether to continue\n // with more latent structures\n let nc;\n for (nc = 0; nc < nComp; nc++) {\n let yHatk = new Matrix(group.rows, 1);\n let tPredk = new Matrix(group.rows, 1);\n let tOrthk = new Matrix(group.rows, 1);\n let oplsk = [];\n\n let f = 0;\n for (let fold of folds) {\n let trainTest = this._getTrainTest(features, group, fold);\n let testXk = trainTest.testFeatures;\n let Xk = trainTest.trainFeatures;\n let Yk = trainTest.trainLabels;\n\n // determine center and scale of training set\n let dataCenter = Xk.mean('column');\n let dataSD = Xk.standardDeviation('column');\n\n // center and scale training set\n if (center) {\n Xk.center('column');\n Yk.center('column');\n }\n\n if (scale) {\n Xk.scale('column');\n Yk.scale('column');\n }\n\n // perform opls\n if (nc === 0) {\n oplsk[f] = OPLSNipals(Xk, Yk);\n } else {\n oplsk[f] = OPLSNipals(oplsCV[nc - 1][f].filteredX, Yk);\n }\n // store model for next component\n oplsCV[nc] = oplsk;\n\n let plsCV = new NIPALS(oplsk[f].filteredX, { Y: Yk });\n\n // scaling the test dataset with respect to the train\n testXk.center('column', { center: dataCenter });\n testXk.scale('column', { scale: dataSD });\n\n let Eh = testXk;\n // removing the orthogonal components from PLS\n let scores;\n for (let idx = 0; idx < nc + 1; idx++) {\n scores = Eh.mmul(oplsCV[idx][f].weightsXOrtho.transpose()); // ok\n Eh.sub(scores.mmul(oplsCV[idx][f].loadingsXOrtho));\n }\n\n // prediction\n let tPred = Eh.mmul(plsCV.w.transpose());\n // this should be summed over ncomp (pls_prediction.R line 23)\n let yHat = tPred.mmul(plsCV.betas); // ok\n\n // adding all prediction from all folds\n for (let i = 0; i < fold.testIndex.length; i++) {\n yHatk.setRow(fold.testIndex[i], [yHat.get(i, 0)]);\n tPredk.setRow(fold.testIndex[i], [tPred.get(i, 0)]);\n tOrthk.setRow(fold.testIndex[i], [scores.get(i, 0)]);\n }\n f++;\n } // end of loop over folds\n\n this.tCV.push(tPredk);\n this.tOrthCV.push(tOrthk);\n this.yHatCV.push(yHatk);\n\n // calculate Q2y for all the prediction (all folds)\n // ROC for DA is not implemented (check opls.R line 183) TODO\n if (this.mode === 'regression') {\n let tssy = tss(group.center('column').scale('column'));\n let press = tss(group.clone().sub(yHatk));\n let Q2y = 1 - press / tssy;\n Q2.push(Q2y);\n } else if (this.mode === 'discriminantAnalysis') {\n throw new Error('discriminant analysis is not yet supported');\n }\n\n // calculate the R2y for the complete data\n if (nc === 0) {\n modelNC = this._predictAll(features, group);\n } else {\n modelNC = this._predictAll(\n modelNC.xRes,\n group,\n (options = { scale: false, center: false }),\n );\n }\n\n // adding the predictive statistics from CV\n modelNC.Q2y = Q2;\n // store the model for each component\n this.model.push(modelNC);\n // console.warn(`OPLS iteration over # of Components: ${nc + 1}`);\n } // end of loop over nc\n\n // store scores from CV\n let tCV = this.tCV;\n let tOrthCV = this.tOrthCV;\n\n let m = this.model[nc - 1];\n let XOrth = m.XOrth;\n let FeaturesCS = features.center('column').scale('column');\n let labelsCS = group.center('column').scale('column');\n let Xres = FeaturesCS.clone().sub(XOrth);\n let plsCall = new NIPALS(Xres, { Y: labelsCS });\n let E = Xres.clone().sub(plsCall.t.mmul(plsCall.p));\n\n let R2x = this.model.map((x) => x.R2x);\n let R2y = this.model.map((x) => x.R2y);\n\n this.output = {\n Q2y: Q2,\n R2x,\n R2y,\n tPred: m.plsC.t,\n pPred: m.plsC.p,\n wPred: m.plsC.w,\n betasPred: m.plsC.betas,\n Qpc: m.plsC.q,\n tCV,\n tOrthCV,\n tOrth: m.tOrth,\n pOrth: m.pOrth,\n wOrth: m.wOrth,\n XOrth,\n yHat: m.totalPred,\n Yres: m.plsC.yResidual,\n E,\n };\n }\n\n /**\n * get access to all the computed elements\n * Mainly for debug and testing\n * @return {Object} output object\n */\n getLogs() {\n return this.output;\n }\n\n getScores() {\n let scoresX = this.tCV.map((x) => x.to1DArray());\n let scoresY = this.tOrthCV.map((x) => x.to1DArray());\n return { scoresX, scoresY };\n }\n\n /**\n * Load an OPLS model from JSON\n * @param {Object} model\n * @return {OPLS}\n */\n static load(model) {\n if (typeof model.name !== 'string') {\n throw new TypeError('model must have a name property');\n }\n if (model.name !== 'OPLS') {\n throw new RangeError(`invalid model: ${model.name}`);\n }\n return new OPLS(true, [], model);\n }\n\n /**\n * Export the current model to a JSON object\n * @return {Object} model\n */\n toJSON() {\n return {\n name: 'OPLS',\n center: this.center,\n scale: this.scale,\n means: this.means,\n stdevs: this.stdevs,\n model: this.model,\n tCV: this.tCV,\n tOrthCV: this.tOrthCV,\n yHatCV: this.yHatCV,\n };\n }\n\n /**\n * Predict scores for new data\n * @param {Matrix} features - a matrix containing new data\n * @param {Object} [options]\n * @param {Array} [options.trueLabel] - an array with true values to compute confusion matrix\n * @param {Number} [options.nc] - the number of components to be used\n * @return {Object} - predictions\n */\n predict(newData, options = {}) {\n let { trueLabels = [], nc = 1 } = options;\n let labels = [];\n if (trueLabels.length > 0) {\n trueLabels = Matrix.from1DArray(trueLabels.length, 1, trueLabels);\n labels = trueLabels.clone();\n }\n\n let features = newData.clone();\n\n // scaling the test dataset with respect to the train\n if (this.center) {\n features.center('column', { center: this.means });\n if (labels.rows > 0 && this.mode === 'regression') {\n labels.center('column', { center: this.meansY });\n }\n }\n if (this.scale) {\n features.scale('column', { scale: this.stdevs });\n if (labels.rows > 0 && this.mode === 'regression') {\n labels.scale('column', { scale: this.stdevsY });\n }\n }\n\n let Eh = features.clone();\n // removing the orthogonal components from PLS\n let tOrth;\n let wOrth;\n let pOrth;\n let yHat;\n let tPred;\n\n for (let idx = 0; idx < nc; idx++) {\n wOrth = this.model[idx].wOrth.transpose();\n pOrth = this.model[idx].pOrth;\n tOrth = Eh.mmul(wOrth);\n Eh.sub(tOrth.mmul(pOrth));\n // prediction\n tPred = Eh.mmul(this.model[idx].plsC.w.transpose());\n // this should be summed over ncomp (pls_prediction.R line 23)\n yHat = tPred.mmul(this.model[idx].plsC.betas);\n }\n\n if (labels.rows > 0) {\n if (this.mode === 'regression') {\n let tssy = tss(labels);\n let press = tss(labels.clone().sub(yHat));\n let Q2y = 1 - press / tssy;\n\n return { tPred, tOrth, yHat, Q2y };\n } else if (this.mode === 'discriminantAnalysis') {\n let confusionMatrix = [];\n confusionMatrix = ConfusionMatrix.fromLabels(\n trueLabels.to1DArray(),\n yHat.to1DArray(),\n );\n\n return { tPred, tOrth, yHat, confusionMatrix };\n }\n } else {\n return { tPred, tOrth, yHat };\n }\n }\n\n _predictAll(features, labels, options = {}) {\n // cannot use the global this.center here\n // since it is used in the NC loop and\n // centering and scaling should only be\n // performed once\n const { center = true, scale = true } = options;\n\n if (center) {\n features.center('column');\n labels.center('column');\n }\n\n if (scale) {\n features.scale('column');\n labels.scale('column');\n // reevaluate tssy and tssx after scaling\n // must be global because re-used for next nc iteration\n // tssx is only evaluate the first time\n this.tssy = tss(labels);\n this.tssx = tss(features);\n }\n\n let oplsC = OPLSNipals(features, labels);\n let plsC = new NIPALS(oplsC.filteredX, { Y: labels });\n\n let tPred = oplsC.filteredX.mmul(plsC.w.transpose());\n let yHat = tPred.mmul(plsC.betas);\n\n let rss = tss(labels.clone().sub(yHat));\n let R2y = 1 - rss / this.tssy;\n\n let xEx = plsC.t.mmul(plsC.p);\n let rssx = tss(xEx);\n let R2x = rssx / this.tssx;\n\n return {\n R2y,\n R2x,\n xRes: oplsC.filteredX,\n tOrth: oplsC.scoresXOrtho,\n pOrth: oplsC.loadingsXOrtho,\n wOrth: oplsC.weightsXOrtho,\n tPred: tPred,\n totalPred: yHat,\n XOrth: oplsC.scoresXOrtho.mmul(oplsC.loadingsXOrtho),\n oplsC,\n plsC,\n };\n }\n /**\n *\n * @param {*} X - dataset matrix object\n * @param {*} group - labels matrix object\n * @param {*} index - train and test index (output from getFold())\n */\n _getTrainTest(X, group, index) {\n let testFeatures = new Matrix(index.testIndex.length, X.columns);\n let testLabels = new Matrix(index.testIndex.length, 1);\n index.testIndex.forEach((el, idx) => {\n testFeatures.setRow(idx, X.getRow(el));\n testLabels.setRow(idx, group.getRow(el));\n });\n\n let trainFeatures = new Matrix(index.trainIndex.length, X.columns);\n let trainLabels = new Matrix(index.trainIndex.length, 1);\n index.trainIndex.forEach((el, idx) => {\n trainFeatures.setRow(idx, X.getRow(el));\n trainLabels.setRow(idx, group.getRow(el));\n });\n\n return {\n trainFeatures,\n testFeatures,\n trainLabels,\n testLabels,\n };\n }\n}\n","'use strict';\n\nvar mlMatrix = require('ml-matrix');\n\nfunction logistic(val) {\n return 1 / (1 + Math.exp(-val));\n}\n\nfunction expELU(val, param) {\n return val < 0 ? param * (Math.exp(val) - 1) : val;\n}\n\nfunction softExponential(val, param) {\n if (param < 0) {\n return -Math.log(1 - param * (val + param)) / param;\n }\n if (param > 0) {\n return ((Math.exp(param * val) - 1) / param) + param;\n }\n return val;\n}\n\nfunction softExponentialPrime(val, param) {\n if (param < 0) {\n return 1 / (1 - param * (param + val));\n } else {\n return Math.exp(param * val);\n }\n}\n\nconst ACTIVATION_FUNCTIONS = {\n tanh: {\n activation: Math.tanh,\n derivate: (val) => 1 - (val * val)\n },\n identity: {\n activation: (val) => val,\n derivate: () => 1\n },\n logistic: {\n activation: logistic,\n derivate: (val) => logistic(val) * (1 - logistic(val))\n },\n arctan: {\n activation: Math.atan,\n derivate: (val) => 1 / (val * val + 1)\n },\n softsign: {\n activation: (val) => val / (1 + Math.abs(val)),\n derivate: (val) => 1 / ((1 + Math.abs(val)) * (1 + Math.abs(val)))\n },\n relu: {\n activation: (val) => (val < 0 ? 0 : val),\n derivate: (val) => (val < 0 ? 0 : 1)\n },\n softplus: {\n activation: (val) => Math.log(1 + Math.exp(val)),\n derivate: (val) => 1 / (1 + Math.exp(-val))\n },\n bent: {\n activation: (val) => ((Math.sqrt(val * val + 1) - 1) / 2) + val,\n derivate: (val) => (val / (2 * Math.sqrt(val * val + 1))) + 1\n },\n sinusoid: {\n activation: Math.sin,\n derivate: Math.cos\n },\n sinc: {\n activation: (val) => (val === 0 ? 1 : Math.sin(val) / val),\n derivate: (val) => (val === 0 ? 0 : (Math.cos(val) / val) - (Math.sin(val) / (val * val)))\n },\n gaussian: {\n activation: (val) => Math.exp(-(val * val)),\n derivate: (val) => -2 * val * Math.exp(-(val * val))\n },\n 'parametric-relu': {\n activation: (val, param) => (val < 0 ? param * val : val),\n derivate: (val, param) => (val < 0 ? param : 1)\n },\n 'exponential-elu': {\n activation: expELU,\n derivate: (val, param) => (val < 0 ? expELU(val, param) + param : 1)\n },\n 'soft-exponential': {\n activation: softExponential,\n derivate: softExponentialPrime\n }\n};\n\nclass Layer {\n /**\n * @private\n * Create a new layer with the given options\n * @param {object} options\n * @param {number} [options.inputSize] - Number of conections that enter the neurons.\n * @param {number} [options.outputSize] - Number of conections that leave the neurons.\n * @param {number} [options.regularization] - Regularization parameter.\n * @param {number} [options.epsilon] - Learning rate parameter.\n * @param {string} [options.activation] - Activation function parameter from the FeedForwardNeuralNetwork class.\n * @param {number} [options.activationParam] - Activation parameter if needed.\n */\n constructor(options) {\n this.inputSize = options.inputSize;\n this.outputSize = options.outputSize;\n this.regularization = options.regularization;\n this.epsilon = options.epsilon;\n this.activation = options.activation;\n this.activationParam = options.activationParam;\n\n var selectedFunction = ACTIVATION_FUNCTIONS[options.activation];\n var params = selectedFunction.activation.length;\n\n var actFunction = params > 1 ? (val) => selectedFunction.activation(val, options.activationParam) : selectedFunction.activation;\n var derFunction = params > 1 ? (val) => selectedFunction.derivate(val, options.activationParam) : selectedFunction.derivate;\n\n this.activationFunction = function (i, j) {\n this.set(i, j, actFunction(this.get(i, j)));\n };\n this.derivate = function (i, j) {\n this.set(i, j, derFunction(this.get(i, j)));\n };\n\n if (options.model) {\n // load model\n this.W = mlMatrix.Matrix.checkMatrix(options.W);\n this.b = mlMatrix.Matrix.checkMatrix(options.b);\n } else {\n // default constructor\n this.W = mlMatrix.Matrix.rand(this.inputSize, this.outputSize);\n this.b = mlMatrix.Matrix.zeros(1, this.outputSize);\n\n this.W.apply(function (i, j) {\n this.set(i, j, this.get(i, j) / Math.sqrt(options.inputSize));\n });\n }\n }\n\n /**\n * @private\n * propagate the given input through the current layer.\n * @param {Matrix} X - input.\n * @return {Matrix} output at the current layer.\n */\n forward(X) {\n var z = X.mmul(this.W).addRowVector(this.b);\n z.apply(this.activationFunction);\n this.a = z.clone();\n return z;\n }\n\n /**\n * @private\n * apply backpropagation algorithm at the current layer\n * @param {Matrix} delta - delta values estimated at the following layer.\n * @param {Matrix} a - 'a' values from the following layer.\n * @return {Matrix} the new delta values for the next layer.\n */\n backpropagation(delta, a) {\n this.dW = a.transpose().mmul(delta);\n this.db = mlMatrix.Matrix.rowVector(delta.sum('column'));\n\n var aCopy = a.clone();\n return delta.mmul(this.W.transpose()).mul(aCopy.apply(this.derivate));\n }\n\n /**\n * @private\n * Function that updates the weights at the current layer with the derivatives.\n */\n update() {\n this.dW.add(this.W.clone().mul(this.regularization));\n this.W.add(this.dW.mul(-this.epsilon));\n this.b.add(this.db.mul(-this.epsilon));\n }\n\n /**\n * @private\n * Export the current layer to JSON.\n * @return {object} model\n */\n toJSON() {\n return {\n model: 'Layer',\n inputSize: this.inputSize,\n outputSize: this.outputSize,\n regularization: this.regularization,\n epsilon: this.epsilon,\n activation: this.activation,\n W: this.W,\n b: this.b\n };\n }\n\n /**\n * @private\n * Creates a new Layer with the given model.\n * @param {object} model\n * @return {Layer}\n */\n static load(model) {\n if (model.model !== 'Layer') {\n throw new RangeError('the current model is not a Layer model');\n }\n return new Layer(model);\n }\n}\n\nclass OutputLayer extends Layer {\n constructor(options) {\n super(options);\n\n this.activationFunction = function (i, j) {\n this.set(i, j, Math.exp(this.get(i, j)));\n };\n }\n\n static load(model) {\n if (model.model !== 'Layer') {\n throw new RangeError('the current model is not a Layer model');\n }\n\n return new OutputLayer(model);\n }\n}\n\nclass FeedForwardNeuralNetworks {\n /**\n * Create a new Feedforward neural network model.\n * @class FeedForwardNeuralNetworks\n * @param {object} [options]\n * @param {Array} [options.hiddenLayers=[10]] - Array that contains the sizes of the hidden layers.\n * @param {number} [options.iterations=50] - Number of iterations at the training step.\n * @param {number} [options.learningRate=0.01] - Learning rate of the neural net (also known as epsilon).\n * @param {number} [options.regularization=0.01] - Regularization parameter af the neural net.\n * @param {string} [options.activation='tanh'] - activation function to be used. (options: 'tanh'(default),\n * 'identity', 'logistic', 'arctan', 'softsign', 'relu', 'softplus', 'bent', 'sinusoid', 'sinc', 'gaussian').\n * (single-parametric options: 'parametric-relu', 'exponential-relu', 'soft-exponential').\n * @param {number} [options.activationParam=1] - if the selected activation function needs a parameter.\n */\n constructor(options) {\n options = options || {};\n if (options.model) {\n // load network\n this.hiddenLayers = options.hiddenLayers;\n this.iterations = options.iterations;\n this.learningRate = options.learningRate;\n this.regularization = options.regularization;\n this.dicts = options.dicts;\n this.activation = options.activation;\n this.activationParam = options.activationParam;\n this.model = new Array(options.layers.length);\n\n for (var i = 0; i < this.model.length - 1; ++i) {\n this.model[i] = Layer.load(options.layers[i]);\n }\n this.model[this.model.length - 1] = OutputLayer.load(options.layers[this.model.length - 1]);\n } else {\n // default constructor\n this.hiddenLayers = options.hiddenLayers || [10];\n this.iterations = options.iterations || 50;\n\n this.learningRate = options.learningRate || 0.01;\n this.regularization = options.regularization || 0.01;\n\n this.activation = options.activation || 'tanh';\n this.activationParam = options.activationParam || 1;\n if (!(this.activation in Object.keys(ACTIVATION_FUNCTIONS))) {\n this.activation = 'tanh';\n }\n }\n }\n\n /**\n * @private\n * Function that build and initialize the neural net.\n * @param {number} inputSize - total of features to fit.\n * @param {number} outputSize - total of labels of the prediction set.\n */\n buildNetwork(inputSize, outputSize) {\n var size = 2 + (this.hiddenLayers.length - 1);\n this.model = new Array(size);\n\n // input layer\n this.model[0] = new Layer({\n inputSize: inputSize,\n outputSize: this.hiddenLayers[0],\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n\n // hidden layers\n for (var i = 1; i < this.hiddenLayers.length; ++i) {\n this.model[i] = new Layer({\n inputSize: this.hiddenLayers[i - 1],\n outputSize: this.hiddenLayers[i],\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n }\n\n // output layer\n this.model[size - 1] = new OutputLayer({\n inputSize: this.hiddenLayers[this.hiddenLayers.length - 1],\n outputSize: outputSize,\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n }\n\n /**\n * Train the neural net with the given features and labels.\n * @param {Matrix|Array} features\n * @param {Matrix|Array} labels\n */\n train(features, labels) {\n features = mlMatrix.Matrix.checkMatrix(features);\n this.dicts = dictOutputs(labels);\n\n var inputSize = features.columns;\n var outputSize = Object.keys(this.dicts.inputs).length;\n\n if (!this.model) {\n this.buildNetwork(inputSize, outputSize);\n }\n\n for (var i = 0; i < this.iterations; ++i) {\n var probabilities = this.propagate(features);\n this.backpropagation(features, labels, probabilities);\n }\n }\n\n /**\n * @private\n * Propagate the input(training set) and retrives the probabilities of each class.\n * @param {Matrix} X\n * @return {Matrix} probabilities of each class.\n */\n propagate(X) {\n var input = X;\n for (var i = 0; i < this.model.length; ++i) {\n input = this.model[i].forward(input);\n }\n\n // get probabilities\n return input.divColumnVector(input.sum('row'));\n }\n\n /**\n * @private\n * Function that applies the backpropagation algorithm on each layer of the network\n * in order to fit the features and labels.\n * @param {Matrix} features\n * @param {Array} labels\n * @param {Matrix} probabilities - probabilities of each class of the feature set.\n */\n backpropagation(features, labels, probabilities) {\n for (var i = 0; i < probabilities.rows; ++i) {\n probabilities.set(i, this.dicts.inputs[labels[i]], probabilities.get(i, this.dicts.inputs[labels[i]]) - 1);\n }\n\n // remember, the last delta doesn't matter\n var delta = probabilities;\n for (i = this.model.length - 1; i >= 0; --i) {\n var a = i > 0 ? this.model[i - 1].a : features;\n delta = this.model[i].backpropagation(delta, a);\n }\n\n for (i = 0; i < this.model.length; ++i) {\n this.model[i].update();\n }\n }\n\n /**\n * Predict the output given the feature set.\n * @param {Array|Matrix} features\n * @return {Array}\n */\n predict(features) {\n features = mlMatrix.Matrix.checkMatrix(features);\n var outputs = new Array(features.rows);\n var probabilities = this.propagate(features);\n for (var i = 0; i < features.rows; ++i) {\n outputs[i] = this.dicts.outputs[probabilities.maxRowIndex(i)[1]];\n }\n\n return outputs;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} model\n */\n toJSON() {\n var model = {\n model: 'FNN',\n hiddenLayers: this.hiddenLayers,\n iterations: this.iterations,\n learningRate: this.learningRate,\n regularization: this.regularization,\n activation: this.activation,\n activationParam: this.activationParam,\n dicts: this.dicts,\n layers: new Array(this.model.length)\n };\n\n for (var i = 0; i < this.model.length; ++i) {\n model.layers[i] = this.model[i].toJSON();\n }\n\n return model;\n }\n\n /**\n * Load a Feedforward Neural Network with the current model.\n * @param {object} model\n * @return {FeedForwardNeuralNetworks}\n */\n static load(model) {\n if (model.model !== 'FNN') {\n throw new RangeError('the current model is not a feed forward network');\n }\n\n return new FeedForwardNeuralNetworks(model);\n }\n}\n\n/**\n * @private\n * Method that given an array of labels(predictions), returns two dictionaries, one to transform from labels to\n * numbers and other in the reverse way\n * @param {Array} array\n * @return {object}\n */\nfunction dictOutputs(array) {\n var inputs = {};\n var outputs = {};\n var index = 0;\n for (var i = 0; i < array.length; i += 1) {\n if (inputs[array[i]] === undefined) {\n inputs[array[i]] = index;\n outputs[index] = array[i];\n index++;\n }\n }\n\n return {\n inputs: inputs,\n outputs: outputs\n };\n}\n\nmodule.exports = FeedForwardNeuralNetworks;\n","function NodeSquare(x, y, weights, som) {\n this.x = x;\n this.y = y;\n this.weights = weights;\n this.som = som;\n this.neighbors = {};\n}\n\nNodeSquare.prototype.adjustWeights = function adjustWeights(target, learningRate, influence) {\n for (var i = 0, ii = this.weights.length; i < ii; i++) {\n this.weights[i] += learningRate * influence * (target[i] - this.weights[i]);\n }\n};\n\nNodeSquare.prototype.getDistance = function getDistance(otherNode) {\n return Math.max(Math.abs(this.x - otherNode.x), Math.abs(this.y - otherNode.y));\n};\n\nNodeSquare.prototype.getDistanceTorus = function getDistanceTorus(otherNode) {\n var distX = Math.abs(this.x - otherNode.x),\n distY = Math.abs(this.y - otherNode.y);\n return Math.max(Math.min(distX, this.som.gridDim.x - distX), Math.min(distY, this.som.gridDim.y - distY));\n};\n\nNodeSquare.prototype.getNeighbors = function getNeighbors(xy) {\n if (!this.neighbors[xy]) {\n this.neighbors[xy] = new Array(2);\n\n // left or bottom neighbor\n var v;\n if (this[xy] > 0) {\n v = this[xy] - 1;\n } else if (this.som.torus) {\n v = this.som.gridDim[xy] - 1\n }\n if (typeof v !== 'undefined') {\n var x, y;\n if (xy === 'x') {\n x = v;\n y = this.y;\n } else {\n x = this.x;\n y = v;\n }\n this.neighbors[xy][0] = this.som.nodes[x][y];\n }\n\n // top or right neighbor\n var w;\n if (this[xy] < (this.som.gridDim[xy] - 1)) {\n w = this[xy] + 1;\n } else if (this.som.torus) {\n w = 0;\n }\n if (typeof w !== 'undefined') {\n if (xy === 'x') {\n x = w;\n y = this.y;\n } else {\n x = this.x;\n y = w;\n }\n this.neighbors[xy][1] = this.som.nodes[x][y];\n }\n }\n return this.neighbors[xy];\n};\n\nNodeSquare.prototype.getPos = function getPos(xy, element) {\n var neighbors = this.getNeighbors(xy),\n distance = this.som.distance,\n bestNeighbor,\n direction;\n if(neighbors[0]) {\n if (neighbors[1]) {\n var dist1 = distance(element, neighbors[0].weights),\n dist2 = distance(element, neighbors[1].weights);\n if(dist1 < dist2) {\n bestNeighbor = neighbors[0];\n direction = -1;\n } else {\n bestNeighbor = neighbors[1];\n direction = 1;\n }\n } else {\n bestNeighbor = neighbors[0];\n direction = -1;\n }\n } else {\n bestNeighbor = neighbors[1];\n direction = 1;\n }\n var simA = 1 - distance(element, this.weights),\n simB = 1 - distance(element, bestNeighbor.weights);\n var factor = ((simA - simB) / (2 - simA - simB));\n return 0.5 + 0.5 * factor * direction;\n};\n\nNodeSquare.prototype.getPosition = function getPosition(element) {\n return [\n this.getPos('x', element),\n this.getPos('y', element)\n ];\n};\n\nmodule.exports = NodeSquare;","var NodeSquare = require('./node-square');\n\nfunction NodeHexagonal(x, y, weights, som) {\n\n NodeSquare.call(this, x, y, weights, som);\n\n this.hX = x - Math.floor(y / 2);\n this.z = 0 - this.hX - y;\n\n}\n\nNodeHexagonal.prototype = new NodeSquare;\nNodeHexagonal.prototype.constructor = NodeHexagonal;\n\nNodeHexagonal.prototype.getDistance = function getDistanceHexagonal(otherNode) {\n return Math.max(Math.abs(this.hX - otherNode.hX), Math.abs(this.y - otherNode.y), Math.abs(this.z - otherNode.z));\n};\n\nNodeHexagonal.prototype.getDistanceTorus = function getDistanceTorus(otherNode) {\n var distX = Math.abs(this.hX - otherNode.hX),\n distY = Math.abs(this.y - otherNode.y),\n distZ = Math.abs(this.z - otherNode.z);\n return Math.max(Math.min(distX, this.som.gridDim.x - distX), Math.min(distY, this.som.gridDim.y - distY), Math.min(distZ, this.som.gridDim.z - distZ));\n};\n\nNodeHexagonal.prototype.getPosition = function getPosition() {\n throw new Error('Unimplemented : cannot get position of the points for hexagonal grid');\n};\n\nmodule.exports = NodeHexagonal;","'use strict';\n\nvar NodeSquare = require('./node-square'),\n NodeHexagonal = require('./node-hexagonal');\n\nvar defaultOptions = {\n fields: 3,\n randomizer: Math.random,\n distance: squareEuclidean,\n iterations: 10,\n learningRate: 0.1,\n gridType: 'rect',\n torus: true,\n method: 'random'\n};\n\nfunction SOM(x, y, options, reload) {\n\n this.x = x;\n this.y = y;\n\n options = options || {};\n this.options = {};\n for (var i in defaultOptions) {\n if (options.hasOwnProperty(i)) {\n this.options[i] = options[i];\n } else {\n this.options[i] = defaultOptions[i];\n }\n }\n\n if (typeof this.options.fields === 'number') {\n this.numWeights = this.options.fields;\n } else if (Array.isArray(this.options.fields)) {\n this.numWeights = this.options.fields.length;\n var converters = getConverters(this.options.fields);\n this.extractor = converters.extractor;\n this.creator = converters.creator;\n } else {\n throw new Error('Invalid fields definition');\n }\n\n if (this.options.gridType === 'rect') {\n this.nodeType = NodeSquare;\n this.gridDim = {\n x: x,\n y: y\n };\n } else {\n this.nodeType = NodeHexagonal;\n var hx = this.x - Math.floor(this.y / 2);\n this.gridDim = {\n x: hx,\n y: this.y,\n z: -(0 - hx - this.y)\n };\n }\n\n this.torus = this.options.torus;\n this.distanceMethod = this.torus ? 'getDistanceTorus' : 'getDistance';\n\n this.distance = this.options.distance;\n\n this.maxDistance = getMaxDistance(this.distance, this.numWeights);\n\n if (reload === true) { // For model loading\n this.done = true;\n return;\n }\n if (!(x > 0 && y > 0)) {\n throw new Error('x and y must be positive');\n }\n\n this.times = {\n findBMU: 0,\n adjust: 0\n };\n\n this.randomizer = this.options.randomizer;\n\n this.iterationCount = 0;\n this.iterations = this.options.iterations;\n\n this.startLearningRate = this.learningRate = this.options.learningRate;\n\n this.mapRadius = Math.floor(Math.max(x, y) / 2);\n\n this.algorithmMethod = this.options.method;\n\n this._initNodes();\n\n this.done = false;\n}\n\nSOM.load = function loadModel(model, distance) {\n if (model.name === 'SOM') {\n var x = model.data.length,\n y = model.data[0].length;\n if (distance) {\n model.options.distance = distance;\n } else if (model.options.distance) {\n model.options.distance = eval('(' + model.options.distance + ')');\n }\n var som = new SOM(x, y, model.options, true);\n som.nodes = new Array(x);\n for (var i = 0; i < x; i++) {\n som.nodes[i] = new Array(y);\n for (var j = 0; j < y; j++) {\n som.nodes[i][j] = new som.nodeType(i, j, model.data[i][j], som);\n }\n }\n return som;\n } else {\n throw new Error('expecting a SOM model');\n }\n};\n\nSOM.prototype.export = function exportModel(includeDistance) {\n if (!this.done) {\n throw new Error('model is not ready yet');\n }\n var model = {\n name: 'SOM'\n };\n model.options = {\n fields: this.options.fields,\n gridType: this.options.gridType,\n torus: this.options.torus\n };\n model.data = new Array(this.x);\n for (var i = 0; i < this.x; i++) {\n model.data[i] = new Array(this.y);\n for (var j = 0; j < this.y; j++) {\n model.data[i][j] = this.nodes[i][j].weights;\n }\n }\n if (includeDistance) {\n model.options.distance = this.distance.toString();\n }\n return model;\n};\n\nSOM.prototype._initNodes = function initNodes() {\n var now = Date.now(),\n i, j, k;\n this.nodes = new Array(this.x);\n for (i = 0; i < this.x; i++) {\n this.nodes[i] = new Array(this.y);\n for (j = 0; j < this.y; j++) {\n var weights = new Array(this.numWeights);\n for (k = 0; k < this.numWeights; k++) {\n weights[k] = this.randomizer();\n }\n this.nodes[i][j] = new this.nodeType(i, j, weights, this);\n }\n }\n this.times.initNodes = Date.now() - now;\n};\n\nSOM.prototype.setTraining = function setTraining(trainingSet) {\n if (this.trainingSet) {\n throw new Error('training set has already been set');\n }\n var now = Date.now();\n var convertedSet = trainingSet;\n var i, l = trainingSet.length;\n if (this.extractor) {\n convertedSet = new Array(l);\n for (i = 0; i < l; i++) {\n convertedSet[i] = this.extractor(trainingSet[i]);\n }\n }\n this.numIterations = this.iterations * l;\n\n if (this.algorithmMethod === 'random') {\n this.timeConstant = this.numIterations / Math.log(this.mapRadius);\n } else {\n this.timeConstant = l / Math.log(this.mapRadius);\n }\n this.trainingSet = convertedSet;\n this.times.setTraining = Date.now() - now;\n};\n\nSOM.prototype.trainOne = function trainOne() {\n if (this.done) {\n\n return false;\n\n } else if (this.numIterations-- > 0) {\n\n var neighbourhoodRadius,\n trainingValue,\n trainingSetFactor;\n\n if (this.algorithmMethod === 'random') { // Pick a random value of the training set at each step\n neighbourhoodRadius = this.mapRadius * Math.exp(-this.iterationCount / this.timeConstant);\n trainingValue = getRandomValue(this.trainingSet, this.randomizer);\n this._adjust(trainingValue, neighbourhoodRadius);\n this.learningRate = this.startLearningRate * Math.exp(-this.iterationCount / this.numIterations);\n } else { // Get next input vector\n trainingSetFactor = -Math.floor(this.iterationCount / this.trainingSet.length);\n neighbourhoodRadius = this.mapRadius * Math.exp(trainingSetFactor / this.timeConstant);\n trainingValue = this.trainingSet[this.iterationCount % this.trainingSet.length];\n this._adjust(trainingValue, neighbourhoodRadius);\n if (((this.iterationCount + 1) % this.trainingSet.length) === 0) {\n this.learningRate = this.startLearningRate * Math.exp(trainingSetFactor / Math.floor(this.numIterations / this.trainingSet.length));\n }\n }\n\n this.iterationCount++;\n\n return true;\n\n } else {\n\n this.done = true;\n return false;\n\n }\n};\n\nSOM.prototype._adjust = function adjust(trainingValue, neighbourhoodRadius) {\n var now = Date.now(),\n x, y, dist, influence;\n\n var bmu = this._findBestMatchingUnit(trainingValue);\n\n var now2 = Date.now();\n this.times.findBMU += now2 - now;\n\n var radiusLimit = Math.floor(neighbourhoodRadius);\n var xMin = bmu.x - radiusLimit,\n xMax = bmu.x + radiusLimit,\n yMin = bmu.y - radiusLimit,\n yMax = bmu.y + radiusLimit;\n\n for (x = xMin; x <= xMax; x++) {\n var theX = x;\n if (x < 0) {\n theX += this.x;\n } else if (x >= this.x) {\n theX -= this.x;\n }\n for (y = yMin; y <= yMax; y++) {\n var theY = y;\n if (y < 0) {\n theY += this.y;\n } else if (y >= this.y) {\n theY -= this.y;\n }\n\n dist = bmu[this.distanceMethod](this.nodes[theX][theY]);\n\n if (dist < neighbourhoodRadius) {\n influence = Math.exp(-dist / (2 * neighbourhoodRadius));\n this.nodes[theX][theY].adjustWeights(trainingValue, this.learningRate, influence);\n }\n\n }\n }\n\n this.times.adjust += (Date.now() - now2);\n\n};\n\nSOM.prototype.train = function train(trainingSet) {\n if (!this.done) {\n this.setTraining(trainingSet);\n while (this.trainOne()) {\n }\n }\n};\n\nSOM.prototype.getConvertedNodes = function getConvertedNodes() {\n var result = new Array(this.x);\n for (var i = 0; i < this.x; i++) {\n result[i] = new Array(this.y);\n for (var j = 0; j < this.y; j++) {\n var node = this.nodes[i][j];\n result[i][j] = this.creator ? this.creator(node.weights) : node.weights;\n }\n }\n return result;\n};\n\nSOM.prototype._findBestMatchingUnit = function findBestMatchingUnit(candidate) {\n\n var bmu,\n lowest = Infinity,\n dist;\n\n for (var i = 0; i < this.x; i++) {\n for (var j = 0; j < this.y; j++) {\n dist = this.distance(this.nodes[i][j].weights, candidate);\n if (dist < lowest) {\n lowest = dist;\n bmu = this.nodes[i][j];\n }\n }\n }\n\n return bmu;\n\n};\n\nSOM.prototype.predict = function predict(data, computePosition) {\n if (typeof data === 'boolean') {\n computePosition = data;\n data = null;\n }\n if (!data) {\n data = this.trainingSet;\n }\n if (Array.isArray(data) && (Array.isArray(data[0]) || (typeof data[0] === 'object'))) { // predict a dataset\n var self = this;\n return data.map(function (element) {\n return self._predict(element, computePosition);\n });\n } else { // predict a single element\n return this._predict(data, computePosition);\n }\n};\n\nSOM.prototype._predict = function _predict(element, computePosition) {\n if (!Array.isArray(element)) {\n element = this.extractor(element);\n }\n var bmu = this._findBestMatchingUnit(element);\n var result = [bmu.x, bmu.y];\n if (computePosition) {\n result[2] = bmu.getPosition(element);\n }\n return result;\n};\n\n// As seen in http://www.scholarpedia.org/article/Kohonen_network\nSOM.prototype.getQuantizationError = function getQuantizationError() {\n var fit = this.getFit(),\n l = fit.length,\n sum = 0;\n for (var i = 0; i < l; i++) {\n sum += fit[i];\n }\n return sum / l;\n};\n\nSOM.prototype.getFit = function getFit(dataset) {\n if (!dataset) {\n dataset = this.trainingSet;\n }\n var l = dataset.length,\n bmu,\n result = new Array(l);\n for (var i = 0; i < l; i++) {\n bmu = this._findBestMatchingUnit(dataset[i]);\n result[i] = Math.sqrt(this.distance(dataset[i], bmu.weights));\n }\n return result;\n};\n\nfunction getConverters(fields) {\n var l = fields.length,\n normalizers = new Array(l),\n denormalizers = new Array(l);\n for (var i = 0; i < l; i++) {\n normalizers[i] = getNormalizer(fields[i].range);\n denormalizers[i] = getDenormalizer(fields[i].range);\n }\n return {\n extractor: function extractor(value) {\n var result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = normalizers[i](value[fields[i].name]);\n }\n return result;\n },\n creator: function creator(value) {\n var result = {};\n for (var i = 0; i < l; i++) {\n result[fields[i].name] = denormalizers[i](value[i]);\n }\n return result;\n }\n };\n}\n\nfunction getNormalizer(minMax) {\n return function normalizer(value) {\n return (value - minMax[0]) / (minMax[1] - minMax[0]);\n };\n}\n\nfunction getDenormalizer(minMax) {\n return function denormalizer(value) {\n return (minMax[0] + value * (minMax[1] - minMax[0]));\n };\n}\n\nfunction squareEuclidean(a, b) {\n var d = 0;\n for (var i = 0, ii = a.length; i < ii; i++) {\n d += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return d;\n}\n\nfunction getRandomValue(arr, randomizer) {\n return arr[Math.floor(randomizer() * arr.length)];\n}\n\nfunction getMaxDistance(distance, numWeights) {\n var zero = new Array(numWeights),\n one = new Array(numWeights);\n for (var i = 0; i < numWeights; i++) {\n zero[i] = 0;\n one[i] = 1;\n }\n return distance(zero, one);\n}\n\nmodule.exports = SOM;","export default function maybeToPrecision(value, digits) {\n if (value < 0) {\n value = 0 - value;\n if (typeof digits === 'number') {\n return `- ${value.toPrecision(digits)}`;\n } else {\n return `- ${value.toString()}`;\n }\n } else {\n if (typeof digits === 'number') {\n return value.toPrecision(digits);\n } else {\n return value.toString();\n }\n }\n}\n","export default function checkArraySize(x, y) {\n if (!Array.isArray(x) || !Array.isArray(y)) {\n throw new TypeError('x and y must be arrays');\n }\n if (x.length !== y.length) {\n throw new RangeError('x and y arrays must have the same length');\n }\n}\n","export { default as maybeToPrecision } from './maybeToPrecision';\nexport { default as checkArrayLength } from './checkArrayLength';\n\nexport default class BaseRegression {\n constructor() {\n if (new.target === BaseRegression) {\n throw new Error('BaseRegression must be subclassed');\n }\n }\n\n predict(x) {\n if (typeof x === 'number') {\n return this._predict(x);\n } else if (Array.isArray(x)) {\n const y = [];\n for (let i = 0; i < x.length; i++) {\n y.push(this._predict(x[i]));\n }\n return y;\n } else {\n throw new TypeError('x must be a number or array');\n }\n }\n\n _predict() {\n throw new Error('_predict must be implemented');\n }\n\n train() {\n // Do nothing for this package\n }\n\n toString() {\n return '';\n }\n\n toLaTeX() {\n return '';\n }\n\n /**\n * Return the correlation coefficient of determination (r) and chi-square.\n * @param {Array} x\n * @param {Array} y\n * @return {object}\n */\n score(x, y) {\n if (!Array.isArray(x) || !Array.isArray(y) || x.length !== y.length) {\n throw new Error('x and y must be arrays of the same length');\n }\n\n const n = x.length;\n const y2 = new Array(n);\n for (let i = 0; i < n; i++) {\n y2[i] = this._predict(x[i]);\n }\n\n let xSum = 0;\n let ySum = 0;\n let chi2 = 0;\n let rmsd = 0;\n let xSquared = 0;\n let ySquared = 0;\n let xY = 0;\n for (let i = 0; i < n; i++) {\n xSum += y2[i];\n ySum += y[i];\n xSquared += y2[i] * y2[i];\n ySquared += y[i] * y[i];\n xY += y2[i] * y[i];\n if (y[i] !== 0) {\n chi2 += ((y[i] - y2[i]) * (y[i] - y2[i])) / y[i];\n }\n rmsd += (y[i] - y2[i]) * (y[i] - y2[i]);\n }\n\n const r =\n (n * xY - xSum * ySum) /\n Math.sqrt((n * xSquared - xSum * xSum) * (n * ySquared - ySum * ySum));\n\n return {\n r: r,\n r2: r * r,\n chi2: chi2,\n rmsd: Math.sqrt(rmsd / n)\n };\n }\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport { Matrix, MatrixTransposeView, solve } from 'ml-matrix';\n\nexport default class PolynomialRegression extends BaseRegression {\n constructor(x, y, degree) {\n super();\n if (x === true) {\n this.degree = y.degree;\n this.powers = y.powers;\n this.coefficients = y.coefficients;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y, degree);\n }\n }\n\n _predict(x) {\n let y = 0;\n for (let k = 0; k < this.powers.length; k++) {\n y += this.coefficients[k] * Math.pow(x, this.powers[k]);\n }\n return y;\n }\n\n toJSON() {\n return {\n name: 'polynomialRegression',\n degree: this.degree,\n powers: this.powers,\n coefficients: this.coefficients\n };\n }\n\n toString(precision) {\n return this._toFormula(precision, false);\n }\n\n toLaTeX(precision) {\n return this._toFormula(precision, true);\n }\n\n _toFormula(precision, isLaTeX) {\n let sup = '^';\n let closeSup = '';\n let times = ' * ';\n if (isLaTeX) {\n sup = '^{';\n closeSup = '}';\n times = '';\n }\n\n let fn = '';\n let str = '';\n for (let k = 0; k < this.coefficients.length; k++) {\n str = '';\n if (this.coefficients[k] !== 0) {\n if (this.powers[k] === 0) {\n str = maybeToPrecision(this.coefficients[k], precision);\n } else {\n if (this.powers[k] === 1) {\n str =\n `${maybeToPrecision(this.coefficients[k], precision) + times}x`;\n } else {\n str =\n `${maybeToPrecision(this.coefficients[k], precision) +\n times\n }x${\n sup\n }${this.powers[k]\n }${closeSup}`;\n }\n }\n\n if (this.coefficients[k] > 0 && k !== this.coefficients.length - 1) {\n str = ` + ${str}`;\n } else if (k !== this.coefficients.length - 1) {\n str = ` ${str}`;\n }\n }\n fn = str + fn;\n }\n if (fn.charAt(0) === '+') {\n fn = fn.slice(1);\n }\n\n return `f(x) = ${fn}`;\n }\n\n static load(json) {\n if (json.name !== 'polynomialRegression') {\n throw new TypeError('not a polynomial regression model');\n }\n return new PolynomialRegression(true, json);\n }\n}\n\nfunction regress(pr, x, y, degree) {\n const n = x.length;\n let powers;\n if (Array.isArray(degree)) {\n powers = degree;\n degree = powers.length;\n } else {\n degree++;\n powers = new Array(degree);\n for (let k = 0; k < degree; k++) {\n powers[k] = k;\n }\n }\n const F = new Matrix(n, degree);\n const Y = new Matrix([y]);\n for (let k = 0; k < degree; k++) {\n for (let i = 0; i < n; i++) {\n if (powers[k] === 0) {\n F.set(i, k, 1);\n } else {\n F.set(i, k, Math.pow(x[i], powers[k]));\n }\n }\n }\n\n const FT = new MatrixTransposeView(F);\n const A = FT.mmul(F);\n const B = FT.mmul(new MatrixTransposeView(Y));\n\n pr.degree = degree - 1;\n pr.powers = powers;\n pr.coefficients = solve(A, B).to1DArray();\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\n\nexport default class SimpleLinearRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n this.slope = y.slope;\n this.intercept = y.intercept;\n this.coefficients = [y.intercept, y.slope];\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n toJSON() {\n return {\n name: 'simpleLinearRegression',\n slope: this.slope,\n intercept: this.intercept\n };\n }\n\n _predict(x) {\n return this.slope * x + this.intercept;\n }\n\n computeX(y) {\n return (y - this.intercept) / this.slope;\n }\n\n toString(precision) {\n let result = 'f(x) = ';\n if (this.slope !== 0) {\n const xFactor = maybeToPrecision(this.slope, precision);\n result += `${xFactor === '1' ? '' : `${xFactor} * `}x`;\n if (this.intercept !== 0) {\n const absIntercept = Math.abs(this.intercept);\n const operator = absIntercept === this.intercept ? '+' : '-';\n result += ` ${operator} ${maybeToPrecision(absIntercept, precision)}`;\n }\n } else {\n result += maybeToPrecision(this.intercept, precision);\n }\n return result;\n }\n\n toLaTeX(precision) {\n return this.toString(precision);\n }\n\n static load(json) {\n if (json.name !== 'simpleLinearRegression') {\n throw new TypeError('not a SLR model');\n }\n return new SimpleLinearRegression(true, json);\n }\n}\n\nfunction regress(slr, x, y) {\n const n = x.length;\n let xSum = 0;\n let ySum = 0;\n\n let xSquared = 0;\n let xY = 0;\n\n for (let i = 0; i < n; i++) {\n xSum += x[i];\n ySum += y[i];\n xSquared += x[i] * x[i];\n xY += x[i] * y[i];\n }\n\n const numerator = n * xY - xSum * ySum;\n slr.slope = numerator / (n * xSquared - xSum * xSum);\n slr.intercept = (1 / n) * ySum - slr.slope * (1 / n) * xSum;\n slr.coefficients = [slr.intercept, slr.slope];\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport SimpleLinearRegression from 'ml-regression-simple-linear';\n\nexport default class ExponentialRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n this.A = y.A;\n this.B = y.B;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n _predict(input) {\n return this.B * Math.exp(input * this.A);\n }\n\n toJSON() {\n return {\n name: 'exponentialRegression',\n A: this.A,\n B: this.B\n };\n }\n\n toString(precision) {\n return (\n `f(x) = ${\n maybeToPrecision(this.B, precision)\n } * e^(${\n maybeToPrecision(this.A, precision)\n } * x)`\n );\n }\n\n toLaTeX(precision) {\n if (this.A >= 0) {\n return (\n `f(x) = ${\n maybeToPrecision(this.B, precision)\n }e^{${\n maybeToPrecision(this.A, precision)\n }x}`\n );\n } else {\n return (\n `f(x) = \\\\frac{${\n maybeToPrecision(this.B, precision)\n }}{e^{${\n maybeToPrecision(-this.A, precision)\n }x}}`\n );\n }\n }\n\n static load(json) {\n if (json.name !== 'exponentialRegression') {\n throw new TypeError('not a exponential regression model');\n }\n return new ExponentialRegression(true, json);\n }\n}\n\nfunction regress(er, x, y) {\n const n = x.length;\n const yl = new Array(n);\n for (let i = 0; i < n; i++) {\n yl[i] = Math.log(y[i]);\n }\n\n const linear = new SimpleLinearRegression(x, yl);\n er.A = linear.slope;\n er.B = Math.exp(linear.intercept);\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport SimpleLinearRegression from 'ml-regression-simple-linear';\n\nexport default class PowerRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n // reloading model\n this.A = y.A;\n this.B = y.B;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n _predict(newInputs) {\n return this.A * Math.pow(newInputs, this.B);\n }\n\n toJSON() {\n return {\n name: 'powerRegression',\n A: this.A,\n B: this.B\n };\n }\n\n toString(precision) {\n return `f(x) = ${maybeToPrecision(\n this.A,\n precision\n )} * x^${maybeToPrecision(this.B, precision)}`;\n }\n\n toLaTeX(precision) {\n let latex = '';\n if (this.B >= 0) {\n latex = `f(x) = ${maybeToPrecision(\n this.A,\n precision\n )}x^{${maybeToPrecision(this.B, precision)}}`;\n } else {\n latex = `f(x) = \\\\frac{${maybeToPrecision(\n this.A,\n precision\n )}}{x^{${maybeToPrecision(-this.B, precision)}}}`;\n }\n latex = latex.replace(/e([+-]?[0-9]+)/g, 'e^{$1}');\n return latex;\n }\n\n static load(json) {\n if (json.name !== 'powerRegression') {\n throw new TypeError('not a power regression model');\n }\n return new PowerRegression(true, json);\n }\n}\n\nfunction regress(pr, x, y) {\n const n = x.length;\n const xl = new Array(n);\n const yl = new Array(n);\n for (let i = 0; i < n; i++) {\n xl[i] = Math.log(x[i]);\n yl[i] = Math.log(y[i]);\n }\n\n const linear = new SimpleLinearRegression(xl, yl);\n pr.A = Math.exp(linear.intercept);\n pr.B = linear.slope;\n}\n","import Matrix, { SVD, pseudoInverse } from 'ml-matrix';\n\nexport default class MultivariateLinearRegression {\n constructor(x, y, options = {}) {\n const { intercept = true, statistics = true } = options;\n this.statistics = statistics;\n if (x === true) {\n this.weights = y.weights;\n this.inputs = y.inputs;\n this.outputs = y.outputs;\n this.intercept = y.intercept;\n } else {\n x = new Matrix(x);\n y = new Matrix(y);\n if (intercept) {\n x.addColumn(new Array(x.rows).fill(1));\n }\n let xt = x.transpose();\n const xx = xt\n .mmul(x);\n const xy = xt\n .mmul(y);\n const invxx = new SVD(xx)\n .inverse();\n const beta = xy\n .transpose()\n .mmul(invxx)\n .transpose();\n this.weights = beta.to2DArray();\n this.inputs = x.columns;\n this.outputs = y.columns;\n if (intercept) this.inputs--;\n this.intercept = intercept;\n if (statistics) {\n /*\n * Let's add some basic statistics about the beta's to be able to interpret them.\n * source: http://dept.stat.lsa.umich.edu/~kshedden/Courses/Stat401/Notes/401-multreg.pdf\n * validated against Excel Regression AddIn\n * test: \"datamining statistics test\"\n */\n const fittedValues = x.mmul(beta);\n const residuals = y.clone().addM(fittedValues.neg());\n const variance =\n residuals\n .to2DArray()\n .map((ri) => Math.pow(ri[0], 2))\n .reduce((a, b) => a + b) /\n (y.rows - x.columns);\n this.stdError = Math.sqrt(variance);\n this.stdErrorMatrix = pseudoInverse(xx).mul(variance);\n this.stdErrors = this.stdErrorMatrix\n .diagonal()\n .map((d) => Math.sqrt(d));\n this.tStats = this.weights.map((d, i) =>\n (this.stdErrors[i] === 0 ? 0 : d[0] / this.stdErrors[i])\n );\n }\n }\n }\n\n predict(x) {\n if (Array.isArray(x)) {\n if (typeof x[0] === 'number') {\n return this._predict(x);\n } else if (Array.isArray(x[0])) {\n const y = new Array(x.length);\n for (let i = 0; i < x.length; i++) {\n y[i] = this._predict(x[i]);\n }\n return y;\n }\n } else if (Matrix.isMatrix(x)) {\n const y = new Matrix(x.rows, this.outputs);\n for (let i = 0; i < x.rows; i++) {\n y.setRow(i, this._predict(x.getRow(i)));\n }\n return y;\n }\n throw new TypeError('x must be a matrix or array of numbers');\n }\n\n _predict(x) {\n const result = new Array(this.outputs);\n if (this.intercept) {\n for (let i = 0; i < this.outputs; i++) {\n result[i] = this.weights[this.inputs][i];\n }\n } else {\n result.fill(0);\n }\n for (let i = 0; i < this.inputs; i++) {\n for (let j = 0; j < this.outputs; j++) {\n result[j] += this.weights[i][j] * x[i];\n }\n }\n return result;\n }\n\n score() {\n throw new Error('score method is not implemented yet');\n }\n\n toJSON() {\n return {\n name: 'multivariateLinearRegression',\n weights: this.weights,\n inputs: this.inputs,\n outputs: this.outputs,\n intercept: this.intercept,\n summary: this.statistics\n ? {\n regressionStatistics: {\n standardError: this.stdError,\n observations: this.outputs\n },\n variables: this.weights.map((d, i) => {\n return {\n label:\n i === this.weights.length - 1\n ? 'Intercept'\n : `X Variable ${i + 1}`,\n coefficients: d,\n standardError: this.stdErrors[i],\n tStat: this.tStats[i]\n };\n })\n }\n : undefined\n };\n }\n\n static load(model) {\n if (model.name !== 'multivariateLinearRegression') {\n throw new Error('not a MLR model');\n }\n return new MultivariateLinearRegression(true, model);\n }\n}\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass GaussianKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.divisor = 2 * options.sigma * options.sigma;\n }\n compute(x, y) {\n const distance = squaredEuclidean(x, y);\n return Math.exp(-distance / this.divisor);\n }\n}\n\nmodule.exports = GaussianKernel;\n","'use strict';\n\nconst defaultOptions = {\n degree: 1,\n constant: 1,\n scale: 1\n};\n\nclass PolynomialKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n\n this.degree = options.degree;\n this.constant = options.constant;\n this.scale = options.scale;\n }\n\n compute(x, y) {\n var sum = 0;\n for (var i = 0; i < x.length; i++) {\n sum += x[i] * y[i];\n }\n return Math.pow(this.scale * sum + this.constant, this.degree);\n }\n}\n\nmodule.exports = PolynomialKernel;\n","'use strict';\n\nconst defaultOptions = {\n alpha: 0.01,\n constant: -Math.E\n};\n\nclass SigmoidKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.alpha = options.alpha;\n this.constant = options.constant;\n }\n\n compute(x, y) {\n var sum = 0;\n for (var i = 0; i < x.length; i++) {\n sum += x[i] * y[i];\n }\n return Math.tanh(this.alpha * sum + this.constant);\n }\n}\n\nmodule.exports = SigmoidKernel;\n","'use strict';\n\nconst defaultOptions = {\n sigma: 1,\n degree: 1\n};\n\nclass ANOVAKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.degree = options.degree;\n }\n\n compute(x, y) {\n var sum = 0;\n var len = Math.min(x.length, y.length);\n for (var i = 1; i <= len; ++i) {\n sum += Math.pow(\n Math.exp(\n -this.sigma *\n Math.pow(Math.pow(x[i - 1], i) - Math.pow(y[i - 1], i), 2)\n ),\n this.degree\n );\n }\n return sum;\n }\n}\n\nmodule.exports = ANOVAKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass CauchyKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n }\n\n compute(x, y) {\n return 1 / (1 + squaredEuclidean(x, y) / (this.sigma * this.sigma));\n }\n}\n\nmodule.exports = CauchyKernel;\n","'use strict';\n\nconst { euclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass ExponentialKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.divisor = 2 * options.sigma * options.sigma;\n }\n\n compute(x, y) {\n const distance = euclidean(x, y);\n return Math.exp(-distance / this.divisor);\n }\n}\n\nmodule.exports = ExponentialKernel;\n","'use strict';\n\nclass HistogramIntersectionKernel {\n compute(x, y) {\n var min = Math.min(x.length, y.length);\n var sum = 0;\n for (var i = 0; i < min; ++i) {\n sum += Math.min(x[i], y[i]);\n }\n\n return sum;\n }\n}\n\nmodule.exports = HistogramIntersectionKernel;\n","'use strict';\n\nconst { euclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass LaplacianKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n }\n\n compute(x, y) {\n const distance = euclidean(x, y);\n return Math.exp(-distance / this.sigma);\n }\n}\n\nmodule.exports = LaplacianKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n constant: 1\n};\n\nclass MultiquadraticKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.constant = options.constant;\n }\n\n compute(x, y) {\n return Math.sqrt(squaredEuclidean(x, y) + this.constant * this.constant);\n }\n}\n\nmodule.exports = MultiquadraticKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n constant: 1\n};\n\nclass RationalQuadraticKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.constant = options.constant;\n }\n\n compute(x, y) {\n const distance = squaredEuclidean(x, y);\n return 1 - distance / (distance + this.constant);\n }\n}\n\nmodule.exports = RationalQuadraticKernel;\n","'use strict';\n\nconst { Matrix, MatrixTransposeView } = require('ml-matrix');\nconst GaussianKernel = require('ml-kernel-gaussian');\nconst PolynomialKernel = require('ml-kernel-polynomial');\nconst SigmoidKernel = require('ml-kernel-sigmoid');\n\nconst ANOVAKernel = require('./kernels/anova-kernel');\nconst CauchyKernel = require('./kernels/cauchy-kernel');\nconst ExponentialKernel = require('./kernels/exponential-kernel');\nconst HistogramKernel = require('./kernels/histogram-intersection-kernel');\nconst LaplacianKernel = require('./kernels/laplacian-kernel');\nconst MultiquadraticKernel = require('./kernels/multiquadratic-kernel');\nconst RationalKernel = require('./kernels/rational-quadratic-kernel');\n\nconst kernelType = {\n gaussian: GaussianKernel,\n rbf: GaussianKernel,\n polynomial: PolynomialKernel,\n poly: PolynomialKernel,\n anova: ANOVAKernel,\n cauchy: CauchyKernel,\n exponential: ExponentialKernel,\n histogram: HistogramKernel,\n min: HistogramKernel,\n laplacian: LaplacianKernel,\n multiquadratic: MultiquadraticKernel,\n rational: RationalKernel,\n sigmoid: SigmoidKernel,\n mlp: SigmoidKernel\n};\n\nclass Kernel {\n constructor(type, options) {\n this.kernelType = type;\n if (type === 'linear') return;\n\n if (typeof type === 'string') {\n type = type.toLowerCase();\n\n var KernelConstructor = kernelType[type];\n if (KernelConstructor) {\n this.kernelFunction = new KernelConstructor(options);\n } else {\n throw new Error(`unsupported kernel type: ${type}`);\n }\n } else if (typeof type === 'object' && typeof type.compute === 'function') {\n this.kernelFunction = type;\n } else {\n throw new TypeError(\n 'first argument must be a valid kernel type or instance'\n );\n }\n }\n\n compute(inputs, landmarks) {\n inputs = Matrix.checkMatrix(inputs);\n if (landmarks === undefined) {\n landmarks = inputs;\n } else {\n landmarks = Matrix.checkMatrix(landmarks);\n }\n if (this.kernelType === 'linear') {\n return inputs.mmul(new MatrixTransposeView(landmarks));\n }\n\n const kernelMatrix = new Matrix(inputs.rows, landmarks.rows);\n if (inputs === landmarks) {\n // fast path, matrix is symmetric\n for (let i = 0; i < inputs.rows; i++) {\n for (let j = i; j < inputs.rows; j++) {\n const value = this.kernelFunction.compute(\n inputs.getRow(i),\n inputs.getRow(j)\n );\n kernelMatrix.set(i, j, value);\n kernelMatrix.set(j, i, value);\n }\n }\n } else {\n for (let i = 0; i < inputs.rows; i++) {\n for (let j = 0; j < landmarks.rows; j++) {\n kernelMatrix.set(\n i,\n j,\n this.kernelFunction.compute(inputs.getRow(i), landmarks.getRow(j))\n );\n }\n }\n }\n return kernelMatrix;\n }\n}\n\nmodule.exports = Kernel;\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport median from 'ml-array-median';\n\nexport default class TheilSenRegression extends BaseRegression {\n /**\n * Theil–Sen estimator\n * https://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator\n * @param {Array|boolean} x\n * @param {Array|object} y\n * @constructor\n */\n constructor(x, y) {\n super();\n if (x === true) {\n // loads the model\n this.slope = y.slope;\n this.intercept = y.intercept;\n this.coefficients = y.coefficients;\n } else {\n // creates the model\n checkArrayLength(x, y);\n theilSen(this, x, y);\n }\n }\n\n toJSON() {\n return {\n name: 'TheilSenRegression',\n slope: this.slope,\n intercept: this.intercept\n };\n }\n\n _predict(input) {\n return this.slope * input + this.intercept;\n }\n\n computeX(input) {\n return (input - this.intercept) / this.slope;\n }\n\n toString(precision) {\n var result = 'f(x) = ';\n if (this.slope) {\n var xFactor = maybeToPrecision(this.slope, precision);\n result += `${Math.abs(xFactor - 1) < 1e-5 ? '' : `${xFactor} * `}x`;\n if (this.intercept) {\n var absIntercept = Math.abs(this.intercept);\n var operator = absIntercept === this.intercept ? '+' : '-';\n result +=\n ` ${operator} ${maybeToPrecision(absIntercept, precision)}`;\n }\n } else {\n result += maybeToPrecision(this.intercept, precision);\n }\n return result;\n }\n\n toLaTeX(precision) {\n return this.toString(precision);\n }\n\n static load(json) {\n if (json.name !== 'TheilSenRegression') {\n throw new TypeError('not a Theil-Sen model');\n }\n return new TheilSenRegression(true, json);\n }\n}\n\nfunction theilSen(regression, x, y) {\n let len = x.length;\n let slopes = new Array(len * len);\n let count = 0;\n for (let i = 0; i < len; ++i) {\n for (let j = i + 1; j < len; ++j) {\n if (x[i] !== x[j]) {\n slopes[count++] = (y[j] - y[i]) / (x[j] - x[i]);\n }\n }\n }\n slopes.length = count;\n let medianSlope = median(slopes);\n\n let cuts = new Array(len);\n for (let i = 0; i < len; ++i) {\n cuts[i] = y[i] - medianSlope * x[i];\n }\n\n regression.slope = medianSlope;\n regression.intercept = median(cuts);\n regression.coefficients = [regression.intercept, regression.slope];\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport { solve } from 'ml-matrix';\n\n/**\n * @class RobustPolynomialRegression\n * @param {Array} x\n * @param {Array} y\n * @param {number} degree - polynomial degree\n */\nexport default class RobustPolynomialRegression extends BaseRegression {\n constructor(x, y, degree) {\n super();\n if (x === true) {\n this.degree = y.degree;\n this.powers = y.powers;\n this.coefficients = y.coefficients;\n } else {\n checkArrayLength(x, y);\n robustPolynomial(this, x, y, degree);\n }\n }\n\n toJSON() {\n return {\n name: 'robustPolynomialRegression',\n degree: this.degree,\n powers: this.powers,\n coefficients: this.coefficients\n };\n }\n\n _predict(x) {\n return predict(x, this.powers, this.coefficients);\n }\n\n /**\n * Display the formula\n * @param {number} precision - precision for the numbers\n * @return {string}\n */\n toString(precision) {\n return this._toFormula(precision, false);\n }\n\n /**\n * Display the formula in LaTeX format\n * @param {number} precision - precision for the numbers\n * @return {string}\n */\n toLaTeX(precision) {\n return this._toFormula(precision, true);\n }\n\n _toFormula(precision, isLaTeX) {\n let sup = '^';\n let closeSup = '';\n let times = ' * ';\n if (isLaTeX) {\n sup = '^{';\n closeSup = '}';\n times = '';\n }\n\n let fn = '';\n let str = '';\n for (let k = 0; k < this.coefficients.length; k++) {\n str = '';\n if (this.coefficients[k] !== 0) {\n if (this.powers[k] === 0) {\n str = maybeToPrecision(this.coefficients[k], precision);\n } else {\n if (this.powers[k] === 1) {\n str = `${maybeToPrecision(this.coefficients[k], precision) +\n times}x`;\n } else {\n str = `${maybeToPrecision(this.coefficients[k], precision) +\n times}x${sup}${this.powers[k]}${closeSup}`;\n }\n }\n\n if (this.coefficients[k] > 0 && k !== this.coefficients.length - 1) {\n str = ` + ${str}`;\n } else if (k !== this.coefficients.length - 1) {\n str = ` ${str}`;\n }\n }\n fn = str + fn;\n }\n if (fn.charAt(0) === '+') {\n fn = fn.slice(1);\n }\n\n return `f(x) = ${fn}`;\n }\n\n static load(json) {\n if (json.name !== 'robustPolynomialRegression') {\n throw new TypeError('not a RobustPolynomialRegression model');\n }\n return new RobustPolynomialRegression(true, json);\n }\n}\n\nfunction robustPolynomial(regression, x, y, degree) {\n let powers = Array(degree)\n .fill(0)\n .map((_, index) => index);\n\n const tuples = getRandomTuples(x, y, degree);\n\n var min;\n for (var i = 0; i < tuples.length; i++) {\n var tuple = tuples[i];\n var coefficients = calcCoefficients(tuple, powers);\n\n var residuals = x.slice();\n for (var j = 0; j < x.length; j++) {\n residuals[j] = y[j] - predict(x[j], powers, coefficients);\n residuals[j] = {\n residual: residuals[j] * residuals[j],\n coefficients\n };\n }\n\n var median = residualsMedian(residuals);\n if (!min || median.residual < min.residual) {\n min = median;\n }\n }\n\n regression.degree = degree;\n regression.powers = powers;\n regression.coefficients = min.coefficients;\n}\n\n/**\n * @ignore\n * @param {Array} x\n * @param {Array} y\n * @param {number} degree\n * @return {Array<{x:number,y:number}>}\n */\nfunction getRandomTuples(x, y, degree) {\n var len = Math.floor(x.length / degree);\n var tuples = new Array(len);\n\n for (var i = 0; i < x.length; i++) {\n var pos = Math.floor(Math.random() * len);\n\n var counter = 0;\n while (counter < x.length) {\n if (!tuples[pos]) {\n tuples[pos] = [\n {\n x: x[i],\n y: y[i]\n }\n ];\n break;\n } else if (tuples[pos].length < degree) {\n tuples[pos].push({\n x: x[i],\n y: y[i]\n });\n break;\n } else {\n counter++;\n pos = (pos + 1) % len;\n }\n }\n\n if (counter === x.length) {\n return tuples;\n }\n }\n return tuples;\n}\n\n/**\n * @ignore\n * @param {{x:number,y:number}} tuple\n * @param {Array} powers\n * @return {Array}\n */\nfunction calcCoefficients(tuple, powers) {\n var X = tuple.slice();\n var Y = tuple.slice();\n for (var i = 0; i < X.length; i++) {\n Y[i] = [tuple[i].y];\n X[i] = new Array(powers.length);\n for (var j = 0; j < powers.length; j++) {\n X[i][j] = Math.pow(tuple[i].x, powers[j]);\n }\n }\n\n return solve(X, Y).to1DArray();\n}\n\nfunction predict(x, powers, coefficients) {\n let y = 0;\n for (let k = 0; k < powers.length; k++) {\n y += coefficients[k] * Math.pow(x, powers[k]);\n }\n return y;\n}\n\nfunction residualsMedian(residuals) {\n residuals.sort((a, b) => a.residual - b.residual);\n\n var l = residuals.length;\n var half = Math.floor(l / 2);\n return l % 2 === 0 ? residuals[half - 1] : residuals[half];\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","/**\n * Calculate current error\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} parameters - Array of current parameter values\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {number}\n */\nexport default function errorCalculation(\n data,\n parameters,\n parameterizedFunction,\n) {\n let error = 0;\n const func = parameterizedFunction(parameters);\n\n for (let i = 0; i < data.x.length; i++) {\n error += Math.abs(data.y[i] - func(data.x[i]));\n }\n\n return error;\n}\n","import { inverse, Matrix } from 'ml-matrix';\n\n/**\n * Difference of the matrix function over the parameters\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} evaluatedData - Array of previous evaluated function values\n * @param {Array} params - Array of previous parameter values\n * @param {number} gradientDifference - Adjustment for decrease the damping parameter\n * @param {function} paramFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {Matrix}\n */\nfunction gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n paramFunction,\n) {\n const n = params.length;\n const m = data.x.length;\n\n let ans = new Array(n);\n\n for (let param = 0; param < n; param++) {\n ans[param] = new Array(m);\n let auxParams = params.slice();\n auxParams[param] += gradientDifference;\n let funcParam = paramFunction(auxParams);\n\n for (let point = 0; point < m; point++) {\n ans[param][point] = evaluatedData[point] - funcParam(data.x[point]);\n }\n }\n return new Matrix(ans);\n}\n\n/**\n * Matrix function over the samples\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} evaluatedData - Array of previous evaluated function values\n * @return {Matrix}\n */\nfunction matrixFunction(data, evaluatedData) {\n const m = data.x.length;\n\n let ans = new Array(m);\n\n for (let point = 0; point < m; point++) {\n ans[point] = [data.y[point] - evaluatedData[point]];\n }\n\n return new Matrix(ans);\n}\n\n/**\n * Iteration for Levenberg-Marquardt\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} params - Array of previous parameter values\n * @param {number} damping - Levenberg-Marquardt parameter\n * @param {number} gradientDifference - Adjustment for decrease the damping parameter\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {Array}\n */\nexport default function step(\n data,\n params,\n damping,\n gradientDifference,\n parameterizedFunction,\n) {\n let value = damping * gradientDifference * gradientDifference;\n let identity = Matrix.eye(params.length, params.length, value);\n\n const func = parameterizedFunction(params);\n\n let evaluatedData = new Float64Array(data.x.length);\n for (let i = 0; i < data.x.length; i++) {\n evaluatedData[i] = func(data.x[i]);\n }\n\n let gradientFunc = gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n parameterizedFunction,\n );\n let matrixFunc = matrixFunction(data, evaluatedData);\n let inverseMatrix = inverse(\n identity.add(gradientFunc.mmul(gradientFunc.transpose())),\n );\n\n params = new Matrix([params]);\n params = params.sub(\n inverseMatrix\n .mmul(gradientFunc)\n .mmul(matrixFunc)\n .mul(gradientDifference)\n .transpose(),\n );\n\n return params.to1DArray();\n}\n","import isArray from 'is-any-array';\n\nimport errorCalculation from './errorCalculation';\nimport step from './step';\n\n/**\n * Curve fitting algorithm\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @param {object} [options] - Options object\n * @param {number} [options.damping] - Levenberg-Marquardt parameter\n * @param {number} [options.gradientDifference = 10e-2] - Adjustment for decrease the damping parameter\n * @param {Array} [options.minValues] - Minimum allowed values for parameters\n * @param {Array} [options.maxValues] - Maximum allowed values for parameters\n * @param {Array} [options.initialValues] - Array of initial parameter values\n * @param {number} [options.maxIterations = 100] - Maximum of allowed iterations\n * @param {number} [options.errorTolerance = 10e-3] - Minimum uncertainty allowed for each point\n * @return {{parameterValues: Array, parameterError: number, iterations: number}}\n */\nexport default function levenbergMarquardt(\n data,\n parameterizedFunction,\n options = {},\n) {\n let {\n maxIterations = 100,\n gradientDifference = 10e-2,\n damping = 0,\n errorTolerance = 10e-3,\n minValues,\n maxValues,\n initialValues,\n } = options;\n\n if (damping <= 0) {\n throw new Error('The damping option must be a positive number');\n } else if (!data.x || !data.y) {\n throw new Error('The data parameter must have x and y elements');\n } else if (\n !isArray(data.x) ||\n data.x.length < 2 ||\n !isArray(data.y) ||\n data.y.length < 2\n ) {\n throw new Error(\n 'The data parameter elements must be an array with more than 2 points',\n );\n } else if (data.x.length !== data.y.length) {\n throw new Error('The data parameter elements must have the same size');\n }\n\n let parameters =\n initialValues || new Array(parameterizedFunction.length).fill(1);\n let parLen = parameters.length;\n maxValues = maxValues || new Array(parLen).fill(Number.MAX_SAFE_INTEGER);\n minValues = minValues || new Array(parLen).fill(Number.MIN_SAFE_INTEGER);\n\n if (maxValues.length !== minValues.length) {\n throw new Error('minValues and maxValues must be the same size');\n }\n\n if (!isArray(parameters)) {\n throw new Error('initialValues must be an array');\n }\n\n let error = errorCalculation(data, parameters, parameterizedFunction);\n\n let converged = error <= errorTolerance;\n\n let iteration;\n for (iteration = 0; iteration < maxIterations && !converged; iteration++) {\n parameters = step(\n data,\n parameters,\n damping,\n gradientDifference,\n parameterizedFunction,\n );\n\n for (let k = 0; k < parLen; k++) {\n parameters[k] = Math.min(\n Math.max(minValues[k], parameters[k]),\n maxValues[k],\n );\n }\n\n error = errorCalculation(data, parameters, parameterizedFunction);\n if (isNaN(error)) break;\n converged = error <= errorTolerance;\n }\n\n return {\n parameterValues: parameters,\n parameterError: error,\n iterations: iteration,\n };\n}\n","/**\n * Returns a new array based on extraction of specific indices of an array\n * @private\n * @param {Array} vector\n * @param {Array} indices\n */\nexport default function selection(vector, indices) {\n let u = []; //new Float64Array(indices.length);\n for (let i = 0; i < indices.length; i++) {\n u[i] = vector[indices[i]];\n }\n return u;\n}\n","/**\n *\n * @private\n * @param {Array of arrays} collection\n */\nexport default function sortCollectionSet(collection) {\n let objectCollection = collection\n .map((value, index) => {\n let key = BigInt(0);\n value.forEach((item) => (key |= BigInt(1) << BigInt(item)));\n return { value, index, key };\n })\n .sort((a, b) => {\n if (a.key - b.key < 0) return -1;\n return 1;\n });\n\n let sorted = [];\n let indices = [];\n\n let key;\n for (let set of objectCollection) {\n if (set.key !== key) {\n key = set.key;\n indices.push([]);\n sorted.push(set.value);\n }\n indices[indices.length - 1].push(set.index);\n }\n\n let result = {\n values: sorted,\n indices: indices,\n };\n return result;\n}\n","import {\n Matrix,\n LuDecomposition,\n solve,\n CholeskyDecomposition,\n} from 'ml-matrix';\n\nimport sortCollectionSet from './util/sortCollectionSet';\n\n/**\n * (Combinatorial Subspace Least Squares) - subfunction for the FC-NNLS\n * @private\n * @param {Matrix} XtX\n * @param {Matrix} XtY\n * @param {Array} Pset\n * @param {Numbers} l\n * @param {Numbers} p\n */\nexport default function cssls(XtX, XtY, Pset, l, p) {\n // Solves the set of equation XtX*K = XtY for the variables in Pset\n // if XtX (or XtX(vars,vars)) is singular, performs the svd and find pseudoinverse, otherwise (even if ill-conditioned) finds inverse with LU decomposition and solves the set of equation\n // it is consistent with matlab results for ill-conditioned matrices (at least consistent with test 'ill-conditionned square X rank 2, Y 3x1' in cssls.test)\n\n let K = Matrix.zeros(l, p);\n if (Pset === null) {\n let choXtX = new CholeskyDecomposition(XtX);\n if (choXtX.isPositiveDefinite() === true) {\n K = choXtX.solve(XtY);\n } else {\n let luXtX = new LuDecomposition(XtX);\n if (luXtX.isSingular() === false) {\n K = luXtX.solve(Matrix.eye(l)).mmul(XtY);\n } else {\n K = solve(XtX, XtY, { useSVD: true });\n }\n }\n } else {\n let sortedPset = sortCollectionSet(Pset).values;\n let sortedEset = sortCollectionSet(Pset).indices;\n if (\n sortedPset.length === 1 &&\n sortedPset[0].length === 0 &&\n sortedEset[0].length === p\n ) {\n return K;\n } else if (\n sortedPset.length === 1 &&\n sortedPset[0].length === l &&\n sortedEset[0].length === p\n ) {\n let choXtX = new CholeskyDecomposition(XtX);\n if (choXtX.isPositiveDefinite() === true) {\n K = choXtX.solve(XtY);\n } else {\n let luXtX = new LuDecomposition(XtX);\n if (luXtX.isSingular() === false) {\n K = luXtX.solve(Matrix.eye(l)).mmul(XtY);\n } else {\n K = solve(XtX, XtY, { useSVD: true });\n }\n }\n } else {\n for (let k = 0; k < sortedPset.length; k++) {\n let cols2Solve = sortedEset[k];\n let vars = sortedPset[k];\n let L;\n let choXtX = new CholeskyDecomposition(XtX.selection(vars, vars));\n if (choXtX.isPositiveDefinite() === true) {\n L = choXtX.solve(XtY.selection(vars, cols2Solve));\n } else {\n let luXtX = new LuDecomposition(XtX.selection(vars, vars));\n if (luXtX.isSingular() === false) {\n L = luXtX\n .solve(Matrix.eye(vars.length))\n .mmul(XtY.selection(vars, cols2Solve));\n } else {\n L = solve(\n XtX.selection(vars, vars),\n XtY.selection(vars, cols2Solve),\n { useSVD: true },\n );\n }\n }\n for (let i = 0; i < L.rows; i++) {\n for (let j = 0; j < L.columns; j++) {\n K.set(vars[i], cols2Solve[j], L.get(i, j));\n }\n }\n }\n }\n }\n return K;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport cssls from './cssls';\n\nexport default function initialisation(X, Y) {\n let n = X.rows;\n let l = X.columns;\n let p = Y.columns;\n let iter = 0;\n\n if (Y.rows !== n) throw new Error('ERROR: matrix size not compatible');\n\n let W = Matrix.zeros(l, p);\n\n // precomputes part of pseudoinverse\n let XtX = X.transpose().mmul(X);\n let XtY = X.transpose().mmul(Y);\n\n let K = cssls(XtX, XtY, null, l, p); // K is lxp\n let Pset = [];\n for (let j = 0; j < p; j++) {\n Pset[j] = [];\n for (let i = 0; i < l; i++) {\n if (K.get(i, j) > 0) {\n Pset[j].push(i);\n } else {\n K.set(i, j, 0);\n } //This is our initial solution, it's the solution found by overwriting the unconstrained least square solution\n }\n }\n let Fset = [];\n for (let j = 0; j < p; j++) {\n if (Pset[j].length !== l) {\n Fset.push(j);\n }\n }\n\n let D = K.clone();\n\n return { n, l, p, iter, W, XtX, XtY, K, Pset, Fset, D };\n}\n","/**\n * Computes the set difference A\\B\n * @private\n * @param {A} set A as an array\n * @param {B} set B as an array\n */\nexport default function setDifference(A, B) {\n let C = [];\n for (let i of A) {\n if (!B.includes(i)) C.push(i);\n }\n return C;\n}\n","import setDifference from './util/setDifference';\n\n// Makes sure the solution has converged\nexport default function optimality(\n iter,\n maxIter,\n XtX,\n XtY,\n Fset,\n Pset,\n W,\n K,\n l,\n p,\n D,\n) {\n if (iter === maxIter) {\n throw new Error('Maximum number of iterations exceeded');\n }\n\n // Check solution for optimality\n let V = XtY.subMatrixColumn(Fset).subtract(XtX.mmul(K.subMatrixColumn(Fset)));\n for (let j = 0; j < Fset.length; j++) {\n W.setColumn(Fset[j], V.subMatrixColumn([j]));\n }\n let Jset = [];\n let fullSet = [];\n for (let i = 0; i < l; i++) {\n fullSet.push(i);\n }\n for (let j = 0; j < Fset.length; j++) {\n let notPset = setDifference(fullSet, Pset[Fset[j]]);\n if (notPset.length === 0) {\n Jset.push(Fset[j]);\n } else if (W.selection(notPset, [Fset[j]]).max() <= 0) {\n Jset.push(Fset[j]);\n }\n }\n Fset = setDifference(Fset, Jset);\n\n // For non-optimal solutions, add the appropriate variables to Pset\n if (Fset.length !== 0) {\n for (let j = 0; j < Fset.length; j++) {\n for (let i = 0; i < l; i++) {\n if (Pset[Fset[j]].includes(i)) W.set(i, Fset[j], -Infinity);\n }\n Pset[Fset[j]].push(W.subMatrixColumn(Fset).maxColumnIndex(j)[0]);\n }\n for (let j = 0; j < Fset.length; j++) {\n D.setColumn(Fset[j], K.getColumn(Fset[j]));\n }\n }\n for (let j = 0; j < p; j++) {\n Pset[j].sort((a, b) => a - b);\n }\n return { Pset, Fset, W };\n}\n","import { Matrix } from 'ml-matrix';\n\nimport selection from './util/selection';\nimport cssls from './cssls';\nimport initialisation from './initialisation';\nimport optimality from './optimality';\n\n/**\n * Fast Combinatorial Non-negative Least Squares with multiple Right Hand Side\n * @param {Matrix|number[][]} X\n * @param {Matrix|number[][]} Y\n * @param {object} [options={}]\n * @param {number} [options.maxIterations] if empty maxIterations is set at 3 times the number of columns of X\n * @returns {Matrix} K\n */\nexport default function fcnnls(X, Y, options = {}) {\n X = Matrix.checkMatrix(X);\n Y = Matrix.checkMatrix(Y);\n let { l, p, iter, W, XtX, XtY, K, Pset, Fset, D } = initialisation(X, Y);\n const { maxIterations = X.columns * 3 } = options;\n\n // Active set algorithm for NNLS main loop\n while (Fset.length > 0) {\n // Solves for the passive variables (uses subroutine below)\n let L = cssls(\n XtX,\n XtY.subMatrixColumn(Fset),\n selection(Pset, Fset),\n l,\n Fset.length,\n );\n for (let i = 0; i < l; i++) {\n for (let j = 0; j < Fset.length; j++) {\n K.set(i, Fset[j], L.get(i, j));\n }\n }\n\n // Finds any infeasible solutions\n let infeasIndex = [];\n for (let j = 0; j < Fset.length; j++) {\n for (let i = 0; i < l; i++) {\n if (L.get(i, j) < 0) {\n infeasIndex.push(j);\n break;\n }\n }\n }\n let Hset = selection(Fset, infeasIndex);\n\n // Makes infeasible solutions feasible (standard NNLS inner loop)\n if (Hset.length > 0) {\n let m = Hset.length;\n let alpha = Matrix.ones(l, m);\n\n while (m > 0 && iter < maxIterations) {\n iter++;\n\n alpha.mul(Infinity);\n\n // Finds indices of negative variables in passive set\n let hRowColIdx = [[], []]; // Indexes work in pairs, each pair reprensents a single element, first array is row index, second array is column index\n let negRowColIdx = [[], []]; // Same as before\n for (let j = 0; j < m; j++) {\n for (let i = 0; i < Pset[Hset[j]].length; i++) {\n if (K.get(Pset[Hset[j]][i], Hset[j]) < 0) {\n hRowColIdx[0].push(Pset[Hset[j]][i]); // i\n hRowColIdx[1].push(j);\n negRowColIdx[0].push(Pset[Hset[j]][i]); // i\n negRowColIdx[1].push(Hset[j]);\n } // Compared to matlab, here we keep the row/column indexing (we are not taking the linear indexing)\n }\n }\n\n for (let k = 0; k < hRowColIdx[0].length; k++) {\n // could be hRowColIdx[1].length as well\n alpha.set(\n hRowColIdx[0][k],\n hRowColIdx[1][k],\n D.get(negRowColIdx[0][k], negRowColIdx[1][k]) /\n (D.get(negRowColIdx[0][k], negRowColIdx[1][k]) -\n K.get(negRowColIdx[0][k], negRowColIdx[1][k])),\n );\n }\n\n let alphaMin = [];\n let minIdx = [];\n for (let j = 0; j < m; j++) {\n alphaMin[j] = alpha.minColumn(j);\n minIdx[j] = alpha.minColumnIndex(j)[0];\n }\n\n alphaMin = Matrix.rowVector(alphaMin);\n for (let i = 0; i < l; i++) {\n alpha.setSubMatrix(alphaMin, i, 0);\n }\n\n let E = new Matrix(l, m);\n E = D.subMatrixColumn(Hset).subtract(\n alpha\n .subMatrix(0, l - 1, 0, m - 1)\n .mul(D.subMatrixColumn(Hset).subtract(K.subMatrixColumn(Hset))),\n );\n for (let j = 0; j < m; j++) {\n D.setColumn(Hset[j], E.subMatrixColumn([j]));\n }\n\n let idx2zero = [minIdx, Hset];\n for (let k = 0; k < m; k++) {\n D.set(idx2zero[0][k], idx2zero[1][k], 0);\n }\n\n for (let j = 0; j < m; j++) {\n Pset[Hset[j]].splice(\n Pset[Hset[j]].findIndex((item) => item === minIdx[j]),\n 1,\n );\n }\n\n L = cssls(XtX, XtY.subMatrixColumn(Hset), selection(Pset, Hset), l, m);\n for (let j = 0; j < m; j++) {\n K.setColumn(Hset[j], L.subMatrixColumn([j]));\n }\n\n Hset = [];\n for (let j = 0; j < K.columns; j++) {\n for (let i = 0; i < l; i++) {\n if (K.get(i, j) < 0) {\n Hset.push(j);\n\n break;\n }\n }\n }\n m = Hset.length;\n }\n }\n\n let newParam = optimality(\n iter,\n maxIterations,\n XtX,\n XtY,\n Fset,\n Pset,\n W,\n K,\n l,\n p,\n D,\n );\n Pset = newParam.Pset;\n Fset = newParam.Fset;\n W = newParam.W;\n }\n\n return K;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport fcnnls from './fcnnls';\n\n/**\n * Fast Combinatorial Non-negative Least Squares with single Right Hand Side\n * @param {Matrix|number[][]} X\n * @param {number[]} y\n * @param {object} [options={}]\n * @param {boolean} [maxIterations] if true or empty maxIterations is set at 3 times the number of columns of X\n * @returns {Array} k\n */\nexport default function fcnnlsVector(X, y, options = {}) {\n if (Array.isArray(y) === false) {\n throw new TypeError('y must be a 1D Array');\n }\n let Y = Matrix.columnVector(y);\n let K = fcnnls(X, Y, options);\n let k = K.to1DArray();\n return k;\n}\n","module.exports = function(haystack, needle, comparator, low, high) {\n var mid, cmp;\n\n if(low === undefined)\n low = 0;\n\n else {\n low = low|0;\n if(low < 0 || low >= haystack.length)\n throw new RangeError(\"invalid lower bound\");\n }\n\n if(high === undefined)\n high = haystack.length - 1;\n\n else {\n high = high|0;\n if(high < low || high >= haystack.length)\n throw new RangeError(\"invalid upper bound\");\n }\n\n while(low <= high) {\n // The naive `low + high >>> 1` could fail for array lengths > 2**31\n // because `>>>` converts its operands to int32. `low + (high - low >>> 1)`\n // works for array lengths <= 2**32-1 which is also Javascript's max array\n // length.\n mid = low + ((high - low) >>> 1);\n cmp = +comparator(haystack[mid], needle, mid, haystack);\n\n // Too low.\n if(cmp < 0.0)\n low = mid + 1;\n\n // Too high.\n else if(cmp > 0.0)\n high = mid - 1;\n\n // Key found.\n else\n return mid;\n }\n\n // Key not found.\n return ~low;\n}\n","'use strict';\n\nfunction assertNumber(number) {\n\tif (typeof number !== 'number') {\n\t\tthrow new TypeError('Expected a number');\n\t}\n}\n\nexports.ascending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\n\tif (Number.isNaN(left)) {\n\t\treturn -1;\n\t}\n\n\tif (Number.isNaN(right)) {\n\t\treturn 1;\n\t}\n\n\treturn left - right;\n};\n\nexports.descending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\n\tif (Number.isNaN(left)) {\n\t\treturn 1;\n\t}\n\n\tif (Number.isNaN(right)) {\n\t\treturn -1;\n\t}\n\n\treturn right - left;\n};\n","import binarySearch from 'binary-search';\nimport { ascending } from 'num-sort';\n\nexport const largestPrime = 0x7fffffff;\n\nconst primeNumbers = [\n // chunk #0\n largestPrime, // 2^31-1\n\n // chunk #1\n 5,\n 11,\n 23,\n 47,\n 97,\n 197,\n 397,\n 797,\n 1597,\n 3203,\n 6421,\n 12853,\n 25717,\n 51437,\n 102877,\n 205759,\n 411527,\n 823117,\n 1646237,\n 3292489,\n 6584983,\n 13169977,\n 26339969,\n 52679969,\n 105359939,\n 210719881,\n 421439783,\n 842879579,\n 1685759167,\n\n // chunk #2\n 433,\n 877,\n 1759,\n 3527,\n 7057,\n 14143,\n 28289,\n 56591,\n 113189,\n 226379,\n 452759,\n 905551,\n 1811107,\n 3622219,\n 7244441,\n 14488931,\n 28977863,\n 57955739,\n 115911563,\n 231823147,\n 463646329,\n 927292699,\n 1854585413,\n\n // chunk #3\n 953,\n 1907,\n 3821,\n 7643,\n 15287,\n 30577,\n 61169,\n 122347,\n 244703,\n 489407,\n 978821,\n 1957651,\n 3915341,\n 7830701,\n 15661423,\n 31322867,\n 62645741,\n 125291483,\n 250582987,\n 501165979,\n 1002331963,\n 2004663929,\n\n // chunk #4\n 1039,\n 2081,\n 4177,\n 8363,\n 16729,\n 33461,\n 66923,\n 133853,\n 267713,\n 535481,\n 1070981,\n 2141977,\n 4283963,\n 8567929,\n 17135863,\n 34271747,\n 68543509,\n 137087021,\n 274174111,\n 548348231,\n 1096696463,\n\n // chunk #5\n 31,\n 67,\n 137,\n 277,\n 557,\n 1117,\n 2237,\n 4481,\n 8963,\n 17929,\n 35863,\n 71741,\n 143483,\n 286973,\n 573953,\n 1147921,\n 2295859,\n 4591721,\n 9183457,\n 18366923,\n 36733847,\n 73467739,\n 146935499,\n 293871013,\n 587742049,\n 1175484103,\n\n // chunk #6\n 599,\n 1201,\n 2411,\n 4831,\n 9677,\n 19373,\n 38747,\n 77509,\n 155027,\n 310081,\n 620171,\n 1240361,\n 2480729,\n 4961459,\n 9922933,\n 19845871,\n 39691759,\n 79383533,\n 158767069,\n 317534141,\n 635068283,\n 1270136683,\n\n // chunk #7\n 311,\n 631,\n 1277,\n 2557,\n 5119,\n 10243,\n 20507,\n 41017,\n 82037,\n 164089,\n 328213,\n 656429,\n 1312867,\n 2625761,\n 5251529,\n 10503061,\n 21006137,\n 42012281,\n 84024581,\n 168049163,\n 336098327,\n 672196673,\n 1344393353,\n\n // chunk #8\n 3,\n 7,\n 17,\n 37,\n 79,\n 163,\n 331,\n 673,\n 1361,\n 2729,\n 5471,\n 10949,\n 21911,\n 43853,\n 87719,\n 175447,\n 350899,\n 701819,\n 1403641,\n 2807303,\n 5614657,\n 11229331,\n 22458671,\n 44917381,\n 89834777,\n 179669557,\n 359339171,\n 718678369,\n 1437356741,\n\n // chunk #9\n 43,\n 89,\n 179,\n 359,\n 719,\n 1439,\n 2879,\n 5779,\n 11579,\n 23159,\n 46327,\n 92657,\n 185323,\n 370661,\n 741337,\n 1482707,\n 2965421,\n 5930887,\n 11861791,\n 23723597,\n 47447201,\n 94894427,\n 189788857,\n 379577741,\n 759155483,\n 1518310967,\n\n // chunk #10\n 379,\n 761,\n 1523,\n 3049,\n 6101,\n 12203,\n 24407,\n 48817,\n 97649,\n 195311,\n 390647,\n 781301,\n 1562611,\n 3125257,\n 6250537,\n 12501169,\n 25002389,\n 50004791,\n 100009607,\n 200019221,\n 400038451,\n 800076929,\n 1600153859,\n\n // chunk #11\n 13,\n 29,\n 59,\n 127,\n 257,\n 521,\n 1049,\n 2099,\n 4201,\n 8419,\n 16843,\n 33703,\n 67409,\n 134837,\n 269683,\n 539389,\n 1078787,\n 2157587,\n 4315183,\n 8630387,\n 17260781,\n 34521589,\n 69043189,\n 138086407,\n 276172823,\n 552345671,\n 1104691373,\n\n // chunk #12\n 19,\n 41,\n 83,\n 167,\n 337,\n 677,\n 1361,\n 2729,\n 5471,\n 10949,\n 21911,\n 43853,\n 87719,\n 175447,\n 350899,\n 701819,\n 1403641,\n 2807303,\n 5614657,\n 11229331,\n 22458671,\n 44917381,\n 89834777,\n 179669557,\n 359339171,\n 718678369,\n 1437356741,\n\n // chunk #13\n 53,\n 107,\n 223,\n 449,\n 907,\n 1823,\n 3659,\n 7321,\n 14653,\n 29311,\n 58631,\n 117269,\n 234539,\n 469099,\n 938207,\n 1876417,\n 3752839,\n 7505681,\n 15011389,\n 30022781,\n 60045577,\n 120091177,\n 240182359,\n 480364727,\n 960729461,\n 1921458943\n];\n\nprimeNumbers.sort(ascending);\n\nexport function nextPrime(value) {\n let index = binarySearch(primeNumbers, value, ascending);\n if (index < 0) {\n index = ~index;\n }\n return primeNumbers[index];\n}\n","import { largestPrime, nextPrime } from './primeFinder';\n\nconst FREE = 0;\nconst FULL = 1;\nconst REMOVED = 2;\n\nconst defaultInitialCapacity = 150;\nconst defaultMinLoadFactor = 1 / 6;\nconst defaultMaxLoadFactor = 2 / 3;\n\nexport default class HashTable {\n constructor(options = {}) {\n if (options instanceof HashTable) {\n this.table = options.table.slice();\n this.values = options.values.slice();\n this.state = options.state.slice();\n this.minLoadFactor = options.minLoadFactor;\n this.maxLoadFactor = options.maxLoadFactor;\n this.distinct = options.distinct;\n this.freeEntries = options.freeEntries;\n this.lowWaterMark = options.lowWaterMark;\n this.highWaterMark = options.maxLoadFactor;\n return;\n }\n\n const initialCapacity =\n options.initialCapacity === undefined\n ? defaultInitialCapacity\n : options.initialCapacity;\n if (initialCapacity < 0) {\n throw new RangeError(\n `initial capacity must not be less than zero: ${initialCapacity}`\n );\n }\n\n const minLoadFactor =\n options.minLoadFactor === undefined\n ? defaultMinLoadFactor\n : options.minLoadFactor;\n const maxLoadFactor =\n options.maxLoadFactor === undefined\n ? defaultMaxLoadFactor\n : options.maxLoadFactor;\n if (minLoadFactor < 0 || minLoadFactor >= 1) {\n throw new RangeError(`invalid minLoadFactor: ${minLoadFactor}`);\n }\n if (maxLoadFactor <= 0 || maxLoadFactor >= 1) {\n throw new RangeError(`invalid maxLoadFactor: ${maxLoadFactor}`);\n }\n if (minLoadFactor >= maxLoadFactor) {\n throw new RangeError(\n `minLoadFactor (${minLoadFactor}) must be smaller than maxLoadFactor (${maxLoadFactor})`\n );\n }\n\n let capacity = initialCapacity;\n // User wants to put at least capacity elements. We need to choose the size based on the maxLoadFactor to\n // avoid the need to rehash before this capacity is reached.\n // actualCapacity * maxLoadFactor >= capacity\n capacity = (capacity / maxLoadFactor) | 0;\n capacity = nextPrime(capacity);\n if (capacity === 0) capacity = 1;\n\n this.table = newArray(capacity);\n this.values = newArray(capacity);\n this.state = newArray(capacity);\n\n this.minLoadFactor = minLoadFactor;\n if (capacity === largestPrime) {\n this.maxLoadFactor = 1;\n } else {\n this.maxLoadFactor = maxLoadFactor;\n }\n\n this.distinct = 0;\n this.freeEntries = capacity;\n\n this.lowWaterMark = 0;\n this.highWaterMark = chooseHighWaterMark(capacity, this.maxLoadFactor);\n }\n\n clone() {\n return new HashTable(this);\n }\n\n get size() {\n return this.distinct;\n }\n\n get(key) {\n const i = this.indexOfKey(key);\n if (i < 0) return 0;\n return this.values[i];\n }\n\n set(key, value) {\n let i = this.indexOfInsertion(key);\n if (i < 0) {\n i = -i - 1;\n this.values[i] = value;\n return false;\n }\n\n if (this.distinct > this.highWaterMark) {\n const newCapacity = chooseGrowCapacity(\n this.distinct + 1,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n return this.set(key, value);\n }\n\n this.table[i] = key;\n this.values[i] = value;\n if (this.state[i] === FREE) this.freeEntries--;\n this.state[i] = FULL;\n this.distinct++;\n\n if (this.freeEntries < 1) {\n const newCapacity = chooseGrowCapacity(\n this.distinct + 1,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n }\n\n return true;\n }\n\n remove(key, noRehash) {\n const i = this.indexOfKey(key);\n if (i < 0) return false;\n\n this.state[i] = REMOVED;\n this.distinct--;\n\n if (!noRehash) this.maybeShrinkCapacity();\n\n return true;\n }\n\n delete(key, noRehash) {\n const i = this.indexOfKey(key);\n if (i < 0) return false;\n\n this.state[i] = FREE;\n this.distinct--;\n\n if (!noRehash) this.maybeShrinkCapacity();\n\n return true;\n }\n\n maybeShrinkCapacity() {\n if (this.distinct < this.lowWaterMark) {\n const newCapacity = chooseShrinkCapacity(\n this.distinct,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n }\n }\n\n containsKey(key) {\n return this.indexOfKey(key) >= 0;\n }\n\n indexOfKey(key) {\n const table = this.table;\n const state = this.state;\n const length = this.table.length;\n\n const hash = key & 0x7fffffff;\n let i = hash % length;\n let decrement = hash % (length - 2);\n if (decrement === 0) decrement = 1;\n\n while (state[i] !== FREE && (state[i] === REMOVED || table[i] !== key)) {\n i -= decrement;\n if (i < 0) i += length;\n }\n\n if (state[i] === FREE) return -1;\n return i;\n }\n\n containsValue(value) {\n return this.indexOfValue(value) >= 0;\n }\n\n indexOfValue(value) {\n const values = this.values;\n const state = this.state;\n\n for (var i = 0; i < state.length; i++) {\n if (state[i] === FULL && values[i] === value) {\n return i;\n }\n }\n\n return -1;\n }\n\n indexOfInsertion(key) {\n const table = this.table;\n const state = this.state;\n const length = table.length;\n\n const hash = key & 0x7fffffff;\n let i = hash % length;\n let decrement = hash % (length - 2);\n if (decrement === 0) decrement = 1;\n\n while (state[i] === FULL && table[i] !== key) {\n i -= decrement;\n if (i < 0) i += length;\n }\n\n if (state[i] === REMOVED) {\n const j = i;\n while (state[i] !== FREE && (state[i] === REMOVED || table[i] !== key)) {\n i -= decrement;\n if (i < 0) i += length;\n }\n if (state[i] === FREE) i = j;\n }\n\n if (state[i] === FULL) {\n return -i - 1;\n }\n\n return i;\n }\n\n ensureCapacity(minCapacity) {\n if (this.table.length < minCapacity) {\n const newCapacity = nextPrime(minCapacity);\n this.rehash(newCapacity);\n }\n }\n\n rehash(newCapacity) {\n const oldCapacity = this.table.length;\n\n if (newCapacity <= this.distinct) throw new Error('Unexpected');\n\n const oldTable = this.table;\n const oldValues = this.values;\n const oldState = this.state;\n\n const newTable = newArray(newCapacity);\n const newValues = newArray(newCapacity);\n const newState = newArray(newCapacity);\n\n this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor);\n this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor);\n\n this.table = newTable;\n this.values = newValues;\n this.state = newState;\n this.freeEntries = newCapacity - this.distinct;\n\n for (var i = 0; i < oldCapacity; i++) {\n if (oldState[i] === FULL) {\n var element = oldTable[i];\n var index = this.indexOfInsertion(element);\n newTable[index] = element;\n newValues[index] = oldValues[i];\n newState[index] = FULL;\n }\n }\n }\n\n forEachKey(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.table[i])) return false;\n }\n }\n return true;\n }\n\n forEachValue(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.values[i])) return false;\n }\n }\n return true;\n }\n\n forEachPair(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.table[i], this.values[i])) return false;\n }\n }\n return true;\n }\n}\n\nfunction chooseLowWaterMark(capacity, minLoad) {\n return (capacity * minLoad) | 0;\n}\n\nfunction chooseHighWaterMark(capacity, maxLoad) {\n return Math.min(capacity - 2, (capacity * maxLoad) | 0);\n}\n\nfunction chooseGrowCapacity(size, minLoad, maxLoad) {\n return nextPrime(\n Math.max(size + 1, ((4 * size) / (3 * minLoad + maxLoad)) | 0)\n );\n}\n\nfunction chooseShrinkCapacity(size, minLoad, maxLoad) {\n return nextPrime(\n Math.max(size + 1, ((4 * size) / (minLoad + 3 * maxLoad)) | 0)\n );\n}\n\nfunction newArray(size) {\n return Array(size).fill(0);\n}\n","import HashTable from 'ml-hash-table';\n\nexport class SparseMatrix {\n constructor(rows, columns, options = {}) {\n if (rows instanceof SparseMatrix) {\n // clone\n const other = rows;\n this._init(\n other.rows,\n other.columns,\n other.elements.clone(),\n other.threshold\n );\n return;\n }\n\n if (Array.isArray(rows)) {\n const matrix = rows;\n rows = matrix.length;\n options = columns || {};\n columns = matrix[0].length;\n this._init(rows, columns, new HashTable(options), options.threshold);\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n var value = matrix[i][j];\n if (this.threshold && Math.abs(value) < this.threshold) value = 0;\n if (value !== 0) {\n this.elements.set(i * columns + j, matrix[i][j]);\n }\n }\n }\n } else {\n this._init(rows, columns, new HashTable(options), options.threshold);\n }\n }\n\n _init(rows, columns, elements, threshold) {\n this.rows = rows;\n this.columns = columns;\n this.elements = elements;\n this.threshold = threshold || 0;\n }\n\n static eye(rows = 1, columns = rows) {\n const min = Math.min(rows, columns);\n const matrix = new SparseMatrix(rows, columns, { initialCapacity: min });\n for (var i = 0; i < min; i++) {\n matrix.set(i, i, 1);\n }\n return matrix;\n }\n\n clone() {\n return new SparseMatrix(this);\n }\n\n to2DArray() {\n const copy = new Array(this.rows);\n for (var i = 0; i < this.rows; i++) {\n copy[i] = new Array(this.columns);\n for (var j = 0; j < this.columns; j++) {\n copy[i][j] = this.get(i, j);\n }\n }\n return copy;\n }\n\n isSquare() {\n return this.rows === this.columns;\n }\n\n isSymmetric() {\n if (!this.isSquare()) return false;\n\n var symmetric = true;\n this.forEachNonZero((i, j, v) => {\n if (this.get(j, i) !== v) {\n symmetric = false;\n return false;\n }\n return v;\n });\n return symmetric;\n }\n\n /**\n * Search for the wither band in the main diagonals\n * @return {number}\n */\n bandWidth() {\n let min = this.columns;\n let max = -1;\n this.forEachNonZero((i, j, v) => {\n let diff = i - j;\n min = Math.min(min, diff);\n max = Math.max(max, diff);\n return v;\n });\n return max - min;\n }\n\n /**\n * Test if a matrix is consider banded using a threshold\n * @param {number} width\n * @return {boolean}\n */\n isBanded(width) {\n let bandWidth = this.bandWidth();\n return bandWidth <= width;\n }\n\n get cardinality() {\n return this.elements.size;\n }\n\n get size() {\n return this.rows * this.columns;\n }\n\n get(row, column) {\n return this.elements.get(row * this.columns + column);\n }\n\n set(row, column, value) {\n if (this.threshold && Math.abs(value) < this.threshold) value = 0;\n if (value === 0) {\n this.elements.remove(row * this.columns + column);\n } else {\n this.elements.set(row * this.columns + column, value);\n }\n return this;\n }\n\n mmul(other) {\n if (this.columns !== other.rows) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Number of columns of left matrix are not equal to number of rows of right matrix.'\n );\n }\n\n const m = this.rows;\n const p = other.columns;\n\n const result = new SparseMatrix(m, p);\n this.forEachNonZero((i, j, v1) => {\n other.forEachNonZero((k, l, v2) => {\n if (j === k) {\n result.set(i, l, result.get(i, l) + v1 * v2);\n }\n return v2;\n });\n return v1;\n });\n return result;\n }\n\n kroneckerProduct(other) {\n const m = this.rows;\n const n = this.columns;\n const p = other.rows;\n const q = other.columns;\n\n const result = new SparseMatrix(m * p, n * q, {\n initialCapacity: this.cardinality * other.cardinality\n });\n this.forEachNonZero((i, j, v1) => {\n other.forEachNonZero((k, l, v2) => {\n result.set(p * i + k, q * j + l, v1 * v2);\n return v2;\n });\n return v1;\n });\n return result;\n }\n\n forEachNonZero(callback) {\n this.elements.forEachPair((key, value) => {\n const i = (key / this.columns) | 0;\n const j = key % this.columns;\n let r = callback(i, j, value);\n if (r === false) return false; // stop iteration\n if (this.threshold && Math.abs(r) < this.threshold) r = 0;\n if (r !== value) {\n if (r === 0) {\n this.elements.remove(key, true);\n } else {\n this.elements.set(key, r);\n }\n }\n return true;\n });\n this.elements.maybeShrinkCapacity();\n return this;\n }\n\n getNonZeros() {\n const cardinality = this.cardinality;\n const rows = new Array(cardinality);\n const columns = new Array(cardinality);\n const values = new Array(cardinality);\n var idx = 0;\n this.forEachNonZero((i, j, value) => {\n rows[idx] = i;\n columns[idx] = j;\n values[idx] = value;\n idx++;\n return value;\n });\n return { rows, columns, values };\n }\n\n setThreshold(newThreshold) {\n if (newThreshold !== 0 && newThreshold !== this.threshold) {\n this.threshold = newThreshold;\n this.forEachNonZero((i, j, v) => v);\n }\n return this;\n }\n\n /**\n * @return {SparseMatrix} - New transposed sparse matrix\n */\n transpose() {\n let trans = new SparseMatrix(this.columns, this.rows, {\n initialCapacity: this.cardinality\n });\n this.forEachNonZero((i, j, value) => {\n trans.set(j, i, value);\n return value;\n });\n return trans;\n }\n}\n\nSparseMatrix.prototype.klass = 'Matrix';\n\nSparseMatrix.identity = SparseMatrix.eye;\nSparseMatrix.prototype.tensorProduct = SparseMatrix.prototype.kroneckerProduct;\n\n/*\n Add dynamically instance and static methods for mathematical operations\n */\n\nvar inplaceOperator = `\n(function %name%(value) {\n if (typeof value === 'number') return this.%name%S(value);\n return this.%name%M(value);\n})\n`;\n\nvar inplaceOperatorScalar = `\n(function %name%S(value) {\n this.forEachNonZero((i, j, v) => v %op% value);\n return this;\n})\n`;\n\nvar inplaceOperatorMatrix = `\n(function %name%M(matrix) {\n matrix.forEachNonZero((i, j, v) => {\n this.set(i, j, this.get(i, j) %op% v);\n return v;\n });\n return this;\n})\n`;\n\nvar staticOperator = `\n(function %name%(matrix, value) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%(value);\n})\n`;\n\nvar inplaceMethod = `\n(function %name%() {\n this.forEachNonZero((i, j, v) => %method%(v));\n return this;\n})\n`;\n\nvar staticMethod = `\n(function %name%(matrix) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%();\n})\n`;\n\nconst operators = [\n // Arithmetic operators\n ['+', 'add'],\n ['-', 'sub', 'subtract'],\n ['*', 'mul', 'multiply'],\n ['/', 'div', 'divide'],\n ['%', 'mod', 'modulus'],\n // Bitwise operators\n ['&', 'and'],\n ['|', 'or'],\n ['^', 'xor'],\n ['<<', 'leftShift'],\n ['>>', 'signPropagatingRightShift'],\n ['>>>', 'rightShift', 'zeroFillRightShift']\n];\n\nfor (const operator of operators) {\n for (let i = 1; i < operator.length; i++) {\n SparseMatrix.prototype[operator[i]] = eval(\n fillTemplateFunction(inplaceOperator, {\n name: operator[i],\n op: operator[0]\n })\n );\n SparseMatrix.prototype[`${operator[i]}S`] = eval(\n fillTemplateFunction(inplaceOperatorScalar, {\n name: `${operator[i]}S`,\n op: operator[0]\n })\n );\n SparseMatrix.prototype[`${operator[i]}M`] = eval(\n fillTemplateFunction(inplaceOperatorMatrix, {\n name: `${operator[i]}M`,\n op: operator[0]\n })\n );\n\n SparseMatrix[operator[i]] = eval(\n fillTemplateFunction(staticOperator, { name: operator[i] })\n );\n }\n}\n\nvar methods = [['~', 'not']];\n\n[\n 'abs',\n 'acos',\n 'acosh',\n 'asin',\n 'asinh',\n 'atan',\n 'atanh',\n 'cbrt',\n 'ceil',\n 'clz32',\n 'cos',\n 'cosh',\n 'exp',\n 'expm1',\n 'floor',\n 'fround',\n 'log',\n 'log1p',\n 'log10',\n 'log2',\n 'round',\n 'sign',\n 'sin',\n 'sinh',\n 'sqrt',\n 'tan',\n 'tanh',\n 'trunc'\n].forEach(function (mathMethod) {\n methods.push([`Math.${mathMethod}`, mathMethod]);\n});\n\nfor (const method of methods) {\n for (let i = 1; i < method.length; i++) {\n SparseMatrix.prototype[method[i]] = eval(\n fillTemplateFunction(inplaceMethod, {\n name: method[i],\n method: method[0]\n })\n );\n SparseMatrix[method[i]] = eval(\n fillTemplateFunction(staticMethod, { name: method[i] })\n );\n }\n}\n\nfunction fillTemplateFunction(template, values) {\n for (const i in values) {\n template = template.replace(new RegExp(`%${i}%`, 'g'), values[i]);\n }\n return template;\n}\n","export default function additiveSymmetric(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i]) * (a[i] + b[i])) / (a[i] * b[i]);\n }\n return 2 * d;\n}\n","export default function avg(a, b) {\n var ii = a.length;\n var max = 0;\n var ans = 0;\n var aux = 0;\n for (var i = 0; i < ii; i++) {\n aux = Math.abs(a[i] - b[i]);\n ans += aux;\n if (max < aux) {\n max = aux;\n }\n }\n return (max + ans) / 2;\n}\n","export default function bhattacharyya(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return -Math.log(ans);\n}\n","export default function canberra(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.abs(a[i] - b[i]) / (a[i] + b[i]);\n }\n return ans;\n}\n","export default function chebyshev(a, b) {\n var ii = a.length;\n var max = 0;\n var aux = 0;\n for (var i = 0; i < ii; i++) {\n aux = Math.abs(a[i] - b[i]);\n if (max < aux) {\n max = aux;\n }\n }\n return max;\n}\n","export default function clark(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.sqrt(\n ((a[i] - b[i]) * (a[i] - b[i])) / ((a[i] + b[i]) * (a[i] + b[i]))\n );\n }\n return 2 * d;\n}\n","export default function czekanowskiSimilarity(a, b) {\n var up = 0;\n var down = 0;\n for (var i = 0; i < a.length; i++) {\n up += Math.min(a[i], b[i]);\n down += a[i] + b[i];\n }\n return (2 * up) / down;\n}\n","import czekanowskiSimilarity from '../similarities/czekanowski';\n\nexport default function czekanowskiDistance(a, b) {\n return 1 - czekanowskiSimilarity(a, b);\n}\n","export default function dice(a, b) {\n var ii = a.length;\n var p = 0;\n var q1 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * a[i];\n q1 += b[i] * b[i];\n q2 += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return q2 / (p + q1);\n}\n","export default function divergence(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / ((a[i] + b[i]) * (a[i] + b[i]));\n }\n return 2 * d;\n}\n","export default function fidelity(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return ans;\n}\n","export default function gower(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.abs(a[i] - b[i]);\n }\n return ans / ii;\n}\n","export default function harmonicMean(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += (a[i] * b[i]) / (a[i] + b[i]);\n }\n return 2 * ans;\n}\n","export default function hellinger(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return 2 * Math.sqrt(1 - ans);\n}\n","export default function innerProduct(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * b[i];\n }\n return ans;\n}\n","export default function intersection(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.min(a[i], b[i]);\n }\n return 1 - ans;\n}\n","export default function jaccard(a, b) {\n var ii = a.length;\n var p1 = 0;\n var p2 = 0;\n var q1 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p1 += a[i] * b[i];\n p2 += a[i] * a[i];\n q1 += b[i] * b[i];\n q2 += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return q2 / (p2 + q1 - p1);\n}\n","export default function jeffreys(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += (a[i] - b[i]) * Math.log(a[i] / b[i]);\n }\n return ans;\n}\n","export default function jensenDifference(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n (a[i] * Math.log(a[i]) + b[i] * Math.log(b[i])) / 2 -\n ((a[i] + b[i]) / 2) * Math.log((a[i] + b[i]) / 2);\n }\n return ans;\n}\n","export default function jensenShannon(a, b) {\n var ii = a.length;\n var p = 0;\n var q = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * Math.log((2 * a[i]) / (a[i] + b[i]));\n q += b[i] * Math.log((2 * b[i]) / (a[i] + b[i]));\n }\n return (p + q) / 2;\n}\n","export default function kdivergence(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * Math.log((2 * a[i]) / (a[i] + b[i]));\n }\n return ans;\n}\n","export default function kulczynski(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += Math.min(a[i], b[i]);\n }\n return up / down;\n}\n","export default function kullbackLeibler(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * Math.log(a[i] / b[i]);\n }\n return ans;\n}\n","export default function kumarHassebrook(a, b) {\n var ii = a.length;\n var p = 0;\n var p2 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * b[i];\n p2 += a[i] * a[i];\n q2 += b[i] * b[i];\n }\n return p / (p2 + q2 - p);\n}\n","export default function kumarJohnson(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n Math.pow(a[i] * a[i] - b[i] * b[i], 2) / (2 * Math.pow(a[i] * b[i], 1.5));\n }\n return ans;\n}\n","export default function lorentzian(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.log(Math.abs(a[i] - b[i]) + 1);\n }\n return ans;\n}\n","export default function manhattan(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.abs(a[i] - b[i]);\n }\n return d;\n}\n","export default function matusita(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return Math.sqrt(2 - 2 * ans);\n}\n","export default function minkowski(a, b, p) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.pow(Math.abs(a[i] - b[i]), p);\n }\n return Math.pow(d, 1 / p);\n}\n","export default function motyka(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.min(a[i], b[i]);\n down += a[i] + b[i];\n }\n return 1 - up / down;\n}\n","export default function neyman(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / a[i];\n }\n return d;\n}\n","export default function pearson(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / b[i];\n }\n return d;\n}\n","export default function probabilisticSymmetric(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / (a[i] + b[i]);\n }\n return 2 * d;\n}\n","export default function ruzicka(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.min(a[i], b[i]);\n down += Math.max(a[i], b[i]);\n }\n return up / down;\n}\n","export default function soergel(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += Math.max(a[i], b[i]);\n }\n return up / down;\n}\n","export default function sorensen(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += a[i] + b[i];\n }\n return up / down;\n}\n","export default function squared(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / (a[i] + b[i]);\n }\n return d;\n}\n","export default function squaredChord(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n (Math.sqrt(a[i]) - Math.sqrt(b[i])) * (Math.sqrt(a[i]) - Math.sqrt(b[i]));\n }\n return ans;\n}\n","export default function taneja(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n ((a[i] + b[i]) / 2) *\n Math.log((a[i] + b[i]) / (2 * Math.sqrt(a[i] * b[i])));\n }\n return ans;\n}\n","export default function tanimoto(a, b, bitvector) {\n if (bitvector) {\n var inter = 0;\n var union = 0;\n for (var j = 0; j < a.length; j++) {\n inter += a[j] && b[j];\n union += a[j] || b[j];\n }\n if (union === 0) {\n return 1;\n }\n return inter / union;\n } else {\n var ii = a.length;\n var p = 0;\n var q = 0;\n var m = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i];\n q += b[i];\n m += Math.min(a[i], b[i]);\n }\n return 1 - (p + q - 2 * m) / (p + q - m);\n }\n}\n","import tanimotoS from '../similarities/tanimoto';\n\nexport default function tanimoto(a, b, bitvector) {\n if (bitvector) {\n return 1 - tanimotoS(a, b, bitvector);\n } else {\n var ii = a.length;\n var p = 0;\n var q = 0;\n var m = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i];\n q += b[i];\n m += Math.min(a[i], b[i]);\n }\n return (p + q - 2 * m) / (p + q - m);\n }\n}\n","export default function topsoe(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n a[i] * Math.log((2 * a[i]) / (a[i] + b[i])) +\n b[i] * Math.log((2 * b[i]) / (a[i] + b[i]));\n }\n return ans;\n}\n","export default function waveHedges(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += 1 - Math.min(a[i], b[i]) / Math.max(a[i], b[i]);\n }\n return ans;\n}\n","import binarySearch from 'binary-search';\nimport { ascending } from 'num-sort';\n\n/**\n * Function that creates the tree\n * @param {Array>} spectrum\n * @param {object} [options]\n * @return {Tree|null}\n * left and right have the same structure than the parent,\n * or are null if they are leaves\n */\nexport function createTree(spectrum, options = {}) {\n var X = spectrum[0];\n const {\n minWindow = 0.16,\n threshold = 0.01,\n from = X[0],\n to = X[X.length - 1]\n } = options;\n\n return mainCreateTree(\n spectrum[0],\n spectrum[1],\n from,\n to,\n minWindow,\n threshold\n );\n}\n\nfunction mainCreateTree(X, Y, from, to, minWindow, threshold) {\n if (to - from < minWindow) {\n return null;\n }\n\n // search first point\n var start = binarySearch(X, from, ascending);\n if (start < 0) {\n start = ~start;\n }\n\n // stop at last point\n var sum = 0;\n var center = 0;\n for (var i = start; i < X.length; i++) {\n if (X[i] >= to) {\n break;\n }\n sum += Y[i];\n center += X[i] * Y[i];\n }\n\n if (sum < threshold) {\n return null;\n }\n\n center /= sum;\n if (center - from < 1e-6 || to - center < 1e-6) {\n return null;\n }\n if (center - from < minWindow / 4) {\n return mainCreateTree(X, Y, center, to, minWindow, threshold);\n } else {\n if (to - center < minWindow / 4) {\n return mainCreateTree(X, Y, from, center, minWindow, threshold);\n } else {\n return new Tree(\n sum,\n center,\n mainCreateTree(X, Y, from, center, minWindow, threshold),\n mainCreateTree(X, Y, center, to, minWindow, threshold)\n );\n }\n }\n}\n\nclass Tree {\n constructor(sum, center, left, right) {\n this.sum = sum;\n this.center = center;\n this.left = left;\n this.right = right;\n }\n}\n","import { createTree } from './createTree';\n\n/**\n * Similarity between two nodes\n * @param {Tree|Array>} a - tree A node\n * @param {Tree|Array>} b - tree B node\n * @param {object} [options]\n * @return {number} similarity measure between tree nodes\n */\nexport function getSimilarity(a, b, options = {}) {\n const { alpha = 0.1, beta = 0.33, gamma = 0.001 } = options;\n\n if (a === null || b === null) {\n return 0;\n }\n if (Array.isArray(a)) {\n a = createTree(a);\n }\n if (Array.isArray(b)) {\n b = createTree(b);\n }\n\n var C =\n (alpha * Math.min(a.sum, b.sum)) / Math.max(a.sum, b.sum) +\n (1 - alpha) * Math.exp(-gamma * Math.abs(a.center - b.center));\n\n return (\n beta * C +\n ((1 - beta) *\n (getSimilarity(a.left, b.left, options) +\n getSimilarity(a.right, b.right, options))) /\n 2\n );\n}\n","import { getSimilarity } from './getSimilarity';\n\nexport { createTree } from './createTree';\n\nexport function treeSimilarity(A, B, options = {}) {\n return getSimilarity(A, B, options);\n}\n\nexport function getFunction(options = {}) {\n return (A, B) => getSimilarity(A, B, options);\n}\n","export default function cosine(a, b) {\n var ii = a.length;\n var p = 0;\n var p2 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * b[i];\n p2 += a[i] * a[i];\n q2 += b[i] * b[i];\n }\n return p / (Math.sqrt(p2) * Math.sqrt(q2));\n}\n","import diceD from '../distances/dice';\n\nexport default function dice(a, b) {\n return 1 - diceD(a, b);\n}\n","import intersectionD from '../distances/intersection';\n\nexport default function intersection(a, b) {\n return 1 - intersectionD(a, b);\n}\n","import jaccardD from '../distances/jaccard';\n\nexport default function jaccard(a, b) {\n return 1 - jaccardD(a, b);\n}\n","import kulczynskiD from '../distances/kulczynski';\n\nexport default function kulczynski(a, b) {\n return 1 / kulczynskiD(a, b);\n}\n","import motykaD from '../distances/motyka';\n\nexport default function motyka(a, b) {\n return 1 - motykaD(a, b);\n}\n","import mean from 'ml-array-mean';\n\nimport cosine from './cosine';\n\nexport default function pearson(a, b) {\n var avgA = mean(a);\n var avgB = mean(b);\n\n var newA = new Array(a.length);\n var newB = new Array(b.length);\n for (var i = 0; i < newA.length; i++) {\n newA[i] = a[i] - avgA;\n newB[i] = b[i] - avgB;\n }\n\n return cosine(newA, newB);\n}\n","import squaredChordD from '../distances/squaredChord';\n\nexport default function squaredChord(a, b) {\n return 1 - squaredChordD(a, b);\n}\n","import { Matrix } from 'ml-matrix';\n\nexport function zeroInsteadOfNegative(X) {\n let rows = X.rows;\n let columns = X.columns;\n let newMatrix = new Matrix(X);\n for (let r = 0; r < rows; r++) {\n for (let c = 0; c < columns; c++) {\n if (newMatrix.get(r, c) < 0) {\n newMatrix.set(r, c, 0);\n }\n }\n }\n return newMatrix;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nexport function checkMatrixS(data, originalMatrix) {\n let { A, S } = data;\n //check if is there at least one element cero\n let indices = [];\n let sum = S.sum('row');\n\n for (let i = 0; i < sum.length; i++) {\n if (sum[i] === 0) {\n indices.push(i);\n continue;\n } else {\n for (let j = 0; j < S.columns; j++) {\n if (isNaN(S.get(i, j))) {\n indices.push(i);\n break;\n }\n }\n }\n }\n // if there than just one zero or NaN element\n // run a NMF with the residual matrix Y - A*B\n if (indices.length > 0) {\n let temp = fastExtractNMF(\n originalMatrix.clone().subM(A.mmul(S)),\n indices.length,\n );\n for (let i = 0; i < indices.length; i++) {\n for (let j = 0; j < S.columns; j++) {\n S.set(indices[i], j, temp.S.get(i, j));\n }\n for (let j = 0; j < A.rows; j++) {\n A.set(j, indices[i], temp.A.get(j, i));\n }\n }\n }\n\n return Object.assign({}, data, { A, S });\n}\n\nfunction fastExtractNMF(residual, r) {\n if (r <= 0) return { A: [], S: [] };\n\n const { columns, rows } = residual;\n\n let A = Matrix.zeros(rows, r);\n let S = Matrix.zeros(r, columns);\n for (let i = 0; i < r; i++) {\n residual = zeroInsteadOfNegative(residual);\n if (residual.sum() === 0) continue;\n let res2 = Matrix.pow(residual, 2).sum('column');\n //find the max of the first column\n\n let maxIndex = 0;\n for (let j = 1; j < res2.length; j++) {\n if (res2[maxIndex] < res2[j]) maxIndex = j;\n }\n\n if (res2[maxIndex] > 0) {\n let sqrtMaxValue = Math.sqrt(res2[maxIndex]);\n for (let j = 0; j < rows; j++) {\n let value = residual.get(j, maxIndex) / sqrtMaxValue;\n A.set(j, i, value);\n }\n let temp = A.getColumnVector(i).transpose().mmul(residual);\n for (let j = 0; j < columns; j++) {\n S.set(i, j, Math.max(temp.get(0, j), 0));\n }\n let subtracting = A.getColumnVector(i).mmul(S.getRowVector(i));\n residual = residual.sub(subtracting);\n }\n }\n return { A, S };\n}\n","import { Matrix } from 'ml-matrix';\n\nexport function normBy(x, by = 'column') {\n let norms = Matrix.mul(x, x).sum(by);\n let length = norms.length;\n for (let i = 0; i < length; i++) {\n norms[i] = Math.sqrt(norms[i]);\n }\n return by === 'row'\n ? Matrix.from1DArray(length, 1, norms)\n : Matrix.from1DArray(1, length, norms);\n}\n","import { normBy } from './normBy';\n\nexport function normProj(X, normLimits) {\n let norms;\n let r = X.rows;\n let c = X.columns;\n if (normLimits.rows === r) {\n norms = normBy(X, 'row');\n //select rows with norm > 0 then multiply twise by the min\n for (let i = 0; i < r; i++) {\n if (norms.get(i, 0) <= 0) continue;\n for (let j = 0; j < c; j++) {\n let value =\n X.get(i, j) *\n Math.min(norms.get(i, 0), normLimits.get(i, 0) / norms.get(i, 0));\n X.set(i, j, value);\n }\n }\n } else {\n norms = normBy(X, 'column');\n for (let i = 0; i < c; i++) {\n if (norms.get(0, i) <= 0) continue;\n for (let j = 0; j < r; j++) {\n let value =\n X.get(j, i) *\n Math.min(norms.get(0, i), normLimits.get(0, i) / norms.get(0, i));\n X.set(j, i, value);\n }\n }\n }\n return X;\n}\n","import { Matrix, EVD } from 'ml-matrix';\n\nimport { normBy } from '../util/normBy';\nimport { normProj } from '../util/normProj';\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nexport function updateMatrixA(Ainit, S, originalMatrix, options) {\n let {\n maxFBIteration,\n toleranceFB,\n normConstrained = false,\n lambda,\n } = options;\n let St = S.transpose();\n let H = S.mmul(St);\n let YSt = originalMatrix.mmul(St);\n let evd = new EVD(H, { assumeSymmetric: true });\n let L = Math.max(...evd.realEigenvalues);\n let A = Ainit;\n let prevA = A.clone();\n let t = 1;\n\n let gradient = (a) => a.mmul(H).sub(YSt);\n let proximal;\n if (normConstrained) {\n let normLimits = normBy(Ainit, 'column');\n proximal = (x, threshold) =>\n normProj(zeroInsteadOfNegative(x.subS(threshold)), normLimits);\n } else {\n proximal = (x, threshold) => zeroInsteadOfNegative(x.subS(threshold));\n }\n\n for (let i = 0; i < maxFBIteration; i++) {\n let tNext = (1 + Math.sqrt(1 + 4 * t * t)) / 2;\n let w = (t - 1) / tNext;\n t = tNext;\n let B = Matrix.mul(A, w + 1).sub(Matrix.mul(prevA, w));\n prevA = A.clone();\n A = proximal(B.sub(gradient(B).divS(L)), lambda / L);\n if (Matrix.sub(prevA, A).norm() / A.norm() < toleranceFB) {\n break;\n }\n }\n return A;\n}\n","export function getMax(array = []) {\n let max = Number.MIN_SAFE_INTEGER;\n for (let i = 0; i < array.length; i++) {\n if (max < array[i]) max = array[i];\n }\n return max;\n}\n","import { Matrix, EVD } from 'ml-matrix';\n\nimport { getMax } from '../util/getMax';\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nexport function updateMatrixS(A, Sinit, originalMatrix, lambda, options) {\n let { maxFBIteration, toleranceFB } = options;\n let At = A.transpose();\n let H = At.mmul(A);\n let AtY = At.mmul(originalMatrix);\n let evd = new EVD(H, { assumeSymmetric: true });\n let L = getMax(evd.realEigenvalues);\n let t = 1;\n let S = Sinit.clone();\n let prevS = S.clone();\n let gradient = (s) => H.mmul(s).sub(AtY);\n let proximal = (x, threshold) => zeroInsteadOfNegative(x.subS(threshold));\n\n for (let i = 0; i < maxFBIteration; i++) {\n let tNext = (1 + Math.sqrt(1 + 4 * t * t)) / 2;\n let w = (t - 1) / tNext;\n t = tNext;\n // R = S_k + w [S_k - S_(k-1)] = (1 + w) .* S_k - w .* S_(k-1)\n let R = Matrix.mul(S, 1 + w).sub(Matrix.mul(prevS, w));\n prevS = S.clone();\n S = proximal(R.sub(gradient(R).divS(L)), lambda / L);\n if (Matrix.sub(prevS, S).norm() / S.norm() < toleranceFB) {\n break;\n }\n }\n return S;\n}\n","import { Matrix, solve } from 'ml-matrix';\n\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nimport { checkMatrixS } from './checkMatrixS';\nimport { updateMatrixA } from './updateMatrixA';\nimport { updateMatrixS } from './updateMatrixS';\n\nexport function initialize(originalMatrix, options = {}) {\n const {\n rank,\n randGenerator,\n maxInitFBIteration,\n toleranceFBInit,\n maxFBIteration,\n toleranceFB,\n normConstrained,\n } = options;\n\n let result = {};\n let rows = originalMatrix.rows;\n\n result.A = Matrix.rand(rows, rank, { random: randGenerator });\n\n for (let iter = 0; iter < maxInitFBIteration; iter++) {\n //select columns with sum positive from A\n let sumC = result.A.sum('column');\n for (let i = 0; i < sumC.length; i++) {\n while (sumC[i] === 0) {\n sumC[i] = 0;\n for (let j = 0; j < rows; j++) {\n result.A.set(j, i, randGenerator());\n sumC[i] += result.A.get(j, i);\n }\n }\n }\n\n //resolve the system of equation Lx = D for x, then select just non negative values;\n result.S = zeroInsteadOfNegative(solve(result.A, originalMatrix));\n\n //select rows with positive sum by row\n let sumR = result.S.sum('row');\n let positiveSumRowIndexS = [];\n let positiveSumRowS = [];\n for (let i = 0; i < sumR.length; i++) {\n if (sumR[i] > 0) {\n positiveSumRowIndexS.push(i);\n positiveSumRowS.push(result.S.getRow(i));\n }\n }\n\n positiveSumRowS = Matrix.checkMatrix(positiveSumRowS);\n\n // solve the system of linear equation xL = D for x. knowing that D/L = (L'\\D')'.\n let candidateA = zeroInsteadOfNegative(\n solve(positiveSumRowS.transpose(), originalMatrix.transpose()),\n );\n\n //then, set the columns of A with an index equal to the row index with sum > 0 into S\n //this step complete the last transpose of D/L = (L'\\D')'.\n for (let i = 0; i < positiveSumRowIndexS.length; i++) {\n let colCandidate = candidateA.getRow(i);\n for (let j = 0; j < rows; j++) {\n result.A.set(j, positiveSumRowIndexS[i], colCandidate[j]);\n }\n }\n\n let prevS = result.S.clone();\n result.S = updateMatrixS(result.A, result.S, originalMatrix, 0, {\n maxFBIteration,\n toleranceFB,\n });\n\n result = checkMatrixS(result, originalMatrix);\n\n result.A = updateMatrixA(result.A, result.S, originalMatrix, 0, {\n maxFBIteration,\n toleranceFB,\n normConstrained,\n });\n\n if (\n Matrix.sub(prevS, result.S).norm() / result.S.norm() <\n toleranceFBInit\n ) {\n break;\n }\n }\n return result;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { normBy } from '../util/normBy';\n\nexport function normalize(data, options) {\n const { normOnA } = options;\n let DS = normBy(data.S.transpose(), 'column');\n let DA = normBy(data.A, 'column');\n let D = Matrix.mul(DS, DA);\n let onS, onA;\n if (normOnA) {\n onS = (index, c) =>\n (data.S.get(index, c) * D.get(0, index)) / DS.get(0, index);\n onA = (index, r) => data.A.get(r, index) / DA.get(0, index);\n } else {\n onS = (index, c) => data.S.get(index, c) / DS.get(0, index);\n onA = (index, r) =>\n (data.A.get(r, index) * D.get(0, index)) / DA.get(0, index);\n }\n const sColumns = data.S.columns;\n const aRows = data.A.rows;\n for (let index = 0; index < D.columns; index++) {\n let valueForS, valueForA;\n if (D.get(0, index) > 0) {\n valueForS = onS;\n valueForA = onA;\n } else {\n valueForA = () => 0;\n valueForS = () => 0;\n }\n for (let c = 0; c < sColumns; c++) {\n data.S.set(index, c, valueForS(index, c));\n }\n for (let r = 0; r < aRows; r++) {\n data.A.set(r, index, valueForA(index, r));\n }\n }\n return data;\n}\n","import median from 'median-quickselect';\nimport { Matrix } from 'ml-matrix';\n\nexport function getMedians(X, by) {\n let medians = [];\n let rows = X.rows;\n let columns = X.columns;\n switch (by) {\n case 'column':\n for (let i = 0; i < columns; i++) {\n medians.push(median(X.getColumn(i)));\n }\n medians = Matrix.from1DArray(1, columns, medians);\n break;\n default:\n for (let i = 0; i < rows; i++) {\n medians.push(median(X.getRow(i)));\n }\n medians = Matrix.from1DArray(rows, 1, medians);\n }\n return medians;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { getMedians } from './getMedians';\n\nexport function dimMADstd(X, by) {\n let medians = getMedians(X, by);\n let matrix = X.clone();\n matrix =\n by === 'column'\n ? matrix.subRowVector(medians.to1DArray())\n : matrix.subColumnVector(medians.to1DArray());\n return Matrix.mul(getMedians(matrix.abs(), by), 1.4826);\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { dimMADstd } from '../util/dimMADstd';\n\nexport function updateLambda(data, originalMatrix, options = {}) {\n let { refinementBeginning, tauMAD } = options;\n let { iteration, lambda, A, S } = data;\n\n if (refinementBeginning <= iteration) return lambda;\n\n let sigmaResidue;\n if (options.lambdaInf !== undefined) {\n sigmaResidue = options.lambdaInf / options.tauMAD;\n } else if (options.addStd !== undefined) {\n sigmaResidue = options.addStd;\n } else {\n let alY = Matrix.sub(originalMatrix, A.mmul(S)).to1DArray();\n let result = dimMADstd(Matrix.from1DArray(1, alY.length, alY), 'row');\n sigmaResidue = result.get(0, 0);\n }\n let nextLambda = Math.max(\n tauMAD * sigmaResidue,\n lambda - 1 / (refinementBeginning - iteration),\n );\n return nextLambda;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { checkMatrixS } from './stages/checkMatrixS';\nimport { initialize } from './stages/initialize';\nimport { normalize } from './stages/normalize';\nimport { updateLambda } from './stages/updateLambda';\nimport { updateMatrixA } from './stages/updateMatrixA';\nimport { updateMatrixS } from './stages/updateMatrixS';\n\n/**\n * Performing non-negative matrix factorization solving argmin_(A >= 0, S >= 0) 1 / 2 * ||Y - AS||_2^2 + lambda * ||S||_1\n * @param {Matrix||Array} originalMatrix - Matrix to be separated.\n * @param {Number} rank - The maximum number of linearly independent column/row vectors in the matrix.\n * @param {Object} [options = {}] - Options of ngmca factorization method.\n * @param {Number} [options.maximumIteration = 500] - Maximum number of iterations.\n * @param {Number} [options.maxFBIteration = 80] - Maximum number of iterations of the Forward-Backward subroutine.\n * @param {Object} [options.randGenerator = Math.random] - Random number generator for the subroutine of initialization.\n * @param {Number} [options.maxInitFBIteration = 50] - Maximum number of iterations of the Forward-Backward subroutine at the initialization.\n * @param {Number} [options.toleranceFB = 1e-5] - relative difference tolerance for convergence of the Forward-Backward sub-iterations.\n * @param {Number} [options.toleranceFBInit = 0] - relative difference tolerance for convergence of the Forward-Backward sub-iterations at the initialization.\n * @param {Number} [options.phaseRatio = 0.8] - transition between decreasing thresholding phase and refinement phase in percent of the iterations.\n * @param {Number} [options.tauMAD = 1] - constant coefficient for the final threshold computation.\n * @param {Boolean} [options.useTranspose = false] - if true the originalMatrix is transposed.\n */\n\nexport function nGMCA(originalMatrix, rank, options = {}) {\n const {\n maximumIteration = 500,\n maxFBIteration = 80,\n maxInitFBIteration = 50,\n toleranceFBInit = 0,\n toleranceFB = 0.00001,\n phaseRatio = 0.8,\n randGenerator = Math.random,\n tauMAD = 1,\n useTranspose = false,\n } = options;\n\n let { normConstrained = false } = options;\n originalMatrix = Matrix.checkMatrix(originalMatrix);\n if (useTranspose) originalMatrix = originalMatrix.transpose();\n let refinementBeginning = Math.floor(phaseRatio * maximumIteration);\n\n let data = initialize(originalMatrix, {\n rank,\n randGenerator,\n maxInitFBIteration,\n toleranceFBInit,\n maxFBIteration,\n toleranceFB,\n });\n\n data = normalize(data, { normOnA: true });\n data.lambda = data.A.transpose()\n .mmul(data.A.mmul(data.S).sub(originalMatrix))\n .abs()\n .max();\n\n for (let iter = 0; iter < maximumIteration; iter++) {\n data.iteration = iter;\n data.S = updateMatrixS(\n data.A,\n data.S,\n originalMatrix,\n data.lambda,\n options,\n );\n data = checkMatrixS(data, originalMatrix);\n data = normalize(data, { normOnA: false });\n\n if (iter > refinementBeginning) normConstrained = true;\n\n data.A = updateMatrixA(data.A, data.S, originalMatrix, {\n maxFBIteration,\n toleranceFB,\n normConstrained,\n lambda: 0,\n });\n\n data = normalize(data, { normOnA: true });\n\n data.lambda = updateLambda(data, originalMatrix, {\n refinementBeginning,\n tauMAD,\n });\n }\n\n if (useTranspose) {\n let temp = data.A.transpose();\n data.A = data.S.transpose();\n data.S = temp;\n }\n return data;\n}\n","'use strict';\n\n// Accuracy\nexports.acc = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.tn[i] + pred.tp[i]) / (l - 1);\n }\n return result;\n};\n\n// Error rate\nexports.err = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.fp[i] / (l - 1));\n }\n return result;\n};\n\n// False positive rate\nexports.fpr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.fp[i] / pred.nNeg;\n }\n return result;\n};\n\n// True positive rate\nexports.tpr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.tp[i] / pred.nPos;\n }\n return result;\n};\n\n// False negative rate\nexports.fnr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.fn[i] / pred.nPos;\n }\n return result;\n};\n\n// True negative rate\nexports.tnr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.tn[i] / pred.nNeg;\n }\n return result;\n};\n\n// Positive predictive value\nexports.ppv = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fp[i] + pred.tp[i] !== 0) ? (pred.tp[i] / (pred.fp[i] + pred.tp[i])) : 0;\n }\n return result;\n};\n\n// Negative predictive value\nexports.npv = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.tn[i] !== 0) ? (pred.tn[i] / (pred.fn[i] + pred.tn[i])) : 0;\n }\n return result;\n};\n\n// Prediction conditioned fallout\nexports.pcfall = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fp[i] + pred.tp[i] !== 0) ? 1 - (pred.tp[i] / (pred.fp[i] + pred.tp[i])) : 1;\n }\n return result;\n};\n\n// Prediction conditioned miss\nexports.pcmiss = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.tn[i] !== 0) ? 1 - (pred.tn[i] / (pred.fn[i] + pred.tn[i])) : 1;\n }\n return result;\n};\n\n// Lift value\nexports.lift = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.nPosPred[i] !== 0) ? ((pred.tp[i] / pred.nPos) / (pred.nPosPred[i] / pred.nSamples)) : 0;\n }\n return result;\n};\n\n// Rate of positive predictions\nexports.rpp = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.nPosPred[i] / pred.nSamples;\n }\n return result;\n};\n\n// Rate of negative predictions\nexports.rnp = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.nNegPred[i] / pred.nSamples;\n }\n return result;\n};\n\n// Threshold\nexports.threshold = pred => {\n const clone = pred.cutoffs.slice();\n clone[0] = clone[1]; // Remove the infinite value\n return clone;\n};\n","'use strict';\n\nconst measures = require('./measures');\n\nclass Performance {\n /**\n *\n * @param prediction - The prediction matrix\n * @param target - The target matrix (values: truthy for same class, falsy for different class)\n * @param options\n *\n * @option all True if the entire matrix must be used. False to ignore the diagonal and lower part (default is false, for similarity/distance matrices)\n * @option max True if the max value corresponds to a perfect match (like in similarity matrices), false if it is the min value (default is false, like in distance matrices. All values will be multiplied by -1)\n */\n constructor(prediction, target, options) {\n options = options || {};\n if (prediction.length !== target.length || prediction[0].length !== target[0].length) {\n throw new Error('dimensions of prediction and target do not match');\n }\n const rows = prediction.length;\n const columns = prediction[0].length;\n const isDistance = !options.max;\n\n const predP = [];\n\n if (options.all) {\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n predP.push({\n pred: prediction[i][j],\n targ: target[i][j]\n });\n }\n }\n } else {\n if (rows < 3 || rows !== columns) {\n throw new Error('When \"all\" option is false, the prediction matrix must be square and have at least 3 columns');\n }\n for (var i = 0; i < rows - 1; i++) {\n for (var j = i + 1; j < columns; j++) {\n predP.push({\n pred: prediction[i][j],\n targ: target[i][j]\n });\n }\n }\n }\n\n if (isDistance) {\n predP.sort((a, b) => a.pred - b.pred);\n } else {\n predP.sort((a, b) => b.pred - a.pred);\n }\n \n const cutoffs = this.cutoffs = [isDistance ? Number.MIN_VALUE : Number.MAX_VALUE];\n const fp = this.fp = [0];\n const tp = this.tp = [0];\n\n var nPos = 0;\n var nNeg = 0;\n\n var currentPred = predP[0].pred;\n var nTp = 0;\n var nFp = 0;\n for (var i = 0; i < predP.length; i++) {\n if (predP[i].pred !== currentPred) {\n cutoffs.push(currentPred);\n fp.push(nFp);\n tp.push(nTp);\n currentPred = predP[i].pred;\n }\n if (predP[i].targ) {\n nPos++;\n nTp++;\n } else {\n nNeg++;\n nFp++;\n }\n }\n cutoffs.push(currentPred);\n fp.push(nFp);\n tp.push(nTp);\n\n const l = cutoffs.length;\n const fn = this.fn = new Array(l);\n const tn = this.tn = new Array(l);\n const nPosPred = this.nPosPred = new Array(l);\n const nNegPred = this.nNegPred = new Array(l);\n\n for (var i = 0; i < l; i++) {\n fn[i] = nPos - tp[i];\n tn[i] = nNeg - fp[i];\n\n nPosPred[i] = tp[i] + fp[i];\n nNegPred[i] = tn[i] + fn[i];\n }\n\n this.nPos = nPos;\n this.nNeg = nNeg;\n this.nSamples = nPos + nNeg;\n }\n\n /**\n * Computes a measure from the prediction object.\n *\n * Many measures are available and can be combined :\n * To create a ROC curve, you need fpr and tpr\n * To create a DET curve, you need fnr and fpr\n * To create a Lift chart, you need rpp and lift\n *\n * Possible measures are : threshold (Threshold), acc (Accuracy), err (Error rate),\n * fpr (False positive rate), tpr (True positive rate), fnr (False negative rate), tnr (True negative rate), ppv (Positive predictive value),\n * npv (Negative predictive value), pcfall (Prediction-conditioned fallout), pcmiss (Prediction-conditioned miss), lift (Lift value), rpp (Rate of positive predictions), rnp (Rate of negative predictions)\n *\n * @param measure - The short name of the measure\n *\n * @return [number]\n */\n getMeasure(measure) {\n if (typeof measure !== 'string') {\n throw new Error('No measure specified');\n }\n if (!measures[measure]) {\n throw new Error(`The specified measure (${measure}) does not exist`);\n }\n return measures[measure](this);\n }\n\n /**\n * Returns the area under the ROC curve\n */\n getAURC() {\n const l = this.cutoffs.length;\n const x = new Array(l);\n const y = new Array(l);\n for (var i = 0; i < l; i++) {\n x[i] = this.fp[i] / this.nNeg;\n y[i] = this.tp[i] / this.nPos;\n }\n var auc = 0;\n for (i = 1; i < l; i++) {\n auc += 0.5 * (x[i] - x[i - 1]) * (y[i] + y[i - 1]);\n }\n return auc;\n }\n\n /**\n * Returns the area under the DET curve\n */\n getAUDC() {\n const l = this.cutoffs.length;\n const x = new Array(l);\n const y = new Array(l);\n for (var i = 0; i < l; i++) {\n x[i] = this.fn[i] / this.nPos;\n y[i] = this.fp[i] / this.nNeg;\n }\n var auc = 0;\n for (i = 1; i < l; i++) {\n auc += 0.5 * (x[i] + x[i - 1]) * (y[i] - y[i - 1]);\n }\n return auc;\n }\n\n getDistribution(options) {\n options = options || {};\n var cutLength = this.cutoffs.length;\n var cutLow = options.xMin || Math.floor(this.cutoffs[cutLength - 1] * 100) / 100;\n var cutHigh = options.xMax || Math.ceil(this.cutoffs[1] * 100) / 100;\n var interval = options.interval || Math.floor(((cutHigh - cutLow) / 20 * 10000000) - 1) / 10000000; // Trick to avoid the precision problem of float numbers\n\n var xLabels = [];\n var interValues = [];\n var intraValues = [];\n var interCumPercent = [];\n var intraCumPercent = [];\n\n var nTP = this.tp[cutLength - 1], currentTP = 0;\n var nFP = this.fp[cutLength - 1], currentFP = 0;\n\n for (var i = cutLow, j = (cutLength - 1); i <= cutHigh; i += interval) {\n while (this.cutoffs[j] < i)\n j--;\n\n xLabels.push(i);\n\n var thisTP = nTP - currentTP - this.tp[j];\n var thisFP = nFP - currentFP - this.fp[j];\n\n currentTP += thisTP;\n currentFP += thisFP;\n\n interValues.push(thisFP);\n intraValues.push(thisTP);\n\n interCumPercent.push(100 - (nFP - this.fp[j]) / nFP * 100);\n intraCumPercent.push(100 - (nTP - this.tp[j]) / nTP * 100);\n }\n\n return {\n xLabels: xLabels,\n interValues: interValues,\n intraValues: intraValues,\n interCumPercent: interCumPercent,\n intraCumPercent: intraCumPercent\n };\n }\n}\n\nPerformance.names = {\n acc: 'Accuracy',\n err: 'Error rate',\n fpr: 'False positive rate',\n tpr: 'True positive rate',\n fnr: 'False negative rate',\n tnr: 'True negative rate',\n ppv: 'Positive predictive value',\n npv: 'Negative predictive value',\n pcfall: 'Prediction-conditioned fallout',\n pcmiss: 'Prediction-conditioned miss',\n lift: 'Lift value',\n rpp: 'Rate of positive predictions',\n rnp: 'Rate of negative predictions',\n threshold: 'Threshold'\n};\n\nmodule.exports = Performance;\n","'use strict';\n\nvar defaultOptions = {\n size: 1,\n value: 0\n};\n\n/**\n * Case when the entry is an array\n * @param data\n * @param options\n * @returns {Array}\n */\nfunction arrayCase(data, options) {\n var len = data.length;\n if (typeof options.size === 'number') {\n options.size = [options.size, options.size];\n }\n\n var cond = len + options.size[0] + options.size[1];\n\n var output;\n if (options.output) {\n if (options.output.length !== cond) {\n throw new RangeError('Wrong output size');\n }\n output = options.output;\n } else {\n output = new Array(cond);\n }\n\n var i;\n if (options.value === 'circular') {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) {\n output[i] = data[(len - (options.size[0] % len) + i) % len];\n } else if (i < options.size[0] + len) {\n output[i] = data[i - options.size[0]];\n } else {\n output[i] = data[(i - options.size[0]) % len];\n }\n }\n } else if (options.value === 'replicate') {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = data[0];\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = data[len - 1];\n }\n } else if (options.value === 'symmetric') {\n if (options.size[0] > len || options.size[1] > len) {\n throw new RangeError(\n 'expanded value should not be bigger than the data length'\n );\n }\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = data[options.size[0] - 1 - i];\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = data[2 * len + options.size[0] - i - 1];\n }\n } else {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = options.value;\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = options.value;\n }\n }\n\n return output;\n}\n\n/**\n * Case when the entry is a matrix\n * @param data\n * @param options\n * @returns {Array}\n */\nfunction matrixCase(data, options) {\n // var row = data.length;\n // var col = data[0].length;\n if (options.size[0] === undefined) {\n options.size = [options.size, options.size, options.size, options.size];\n }\n throw new Error('matrix not supported yet, sorry');\n}\n\n/**\n * Pads and array\n * @param {Array } data\n * @param {object} options\n */\nfunction padArray(data, options) {\n options = Object.assign({}, defaultOptions, options);\n if (Array.isArray(data)) {\n if (Array.isArray(data[0])) return matrixCase(data, options);\n else return arrayCase(data, options);\n } else {\n throw new TypeError('data should be an array');\n }\n}\n\nmodule.exports = padArray;\n","import { Matrix, MatrixTransposeView, inverse } from 'ml-matrix';\nimport padArray from 'ml-pad-array';\n\n/**\n * Factorial of a number\n * @ignore\n * @param n\n * @return {number}\n */\nfunction factorial(n) {\n let r = 1;\n while (n > 0) r *= n--;\n return r;\n}\n\nconst defaultOptions = {\n windowSize: 5,\n derivative: 1,\n polynomial: 2,\n pad: 'none',\n padValue: 'replicate',\n};\n\n/**\n * Savitzky-Golay filter\n * @param {Array } data\n * @param {number} h\n * @param {Object} options\n * @returns {Array}\n */\nexport default function savitzkyGolay(data, h, options) {\n options = Object.assign({}, defaultOptions, options);\n if (\n options.windowSize % 2 === 0 ||\n options.windowSize < 5 ||\n !Number.isInteger(options.windowSize)\n ) {\n throw new RangeError(\n 'Invalid window size (should be odd and at least 5 integer number)',\n );\n }\n if (options.derivative < 0 || !Number.isInteger(options.derivative)) {\n throw new RangeError('Derivative should be a positive integer');\n }\n if (options.polynomial < 1 || !Number.isInteger(options.polynomial)) {\n throw new RangeError('Polynomial should be a positive integer');\n }\n\n let C, norm;\n let step = Math.floor(options.windowSize / 2);\n\n if (options.pad === 'pre') {\n data = padArray(data, { size: step, value: options.padValue });\n }\n\n let ans = new Array(data.length - 2 * step);\n\n if (\n options.windowSize === 5 &&\n options.polynomial === 2 &&\n (options.derivative === 1 || options.derivative === 2)\n ) {\n if (options.derivative === 1) {\n C = [-2, -1, 0, 1, 2];\n norm = 10;\n } else {\n C = [2, -1, -2, -1, 2];\n norm = 7;\n }\n } else {\n let J = Matrix.ones(options.windowSize, options.polynomial + 1);\n let inic = -(options.windowSize - 1) / 2;\n for (let i = 0; i < J.rows; i++) {\n for (let j = 0; j < J.columns; j++) {\n if (inic + 1 !== 0 || j !== 0) J.set(i, j, Math.pow(inic + i, j));\n }\n }\n let Jtranspose = new MatrixTransposeView(J);\n let Jinv = inverse(Jtranspose.mmul(J));\n C = Jinv.mmul(Jtranspose);\n C = C.getRow(options.derivative);\n norm = 1 / factorial(options.derivative);\n }\n let det = norm * Math.pow(h, options.derivative);\n for (let k = step; k < data.length - step; k++) {\n let d = 0;\n for (let l = 0; l < C.length; l++) d += (C[l] * data[l + k - step]) / det;\n ans[k - step] = d;\n }\n\n if (options.pad === 'post') {\n ans = padArray(ans, { size: step, value: options.padValue });\n }\n\n return ans;\n}\n","// auxiliary file to create the 256 look at table elements\n\nvar ans = new Array(256);\nfor (var i = 0; i < 256; i++) {\n var num = i;\n var c = 0;\n while (num) {\n num = num & (num - 1);\n c++;\n }\n ans[i] = c;\n}\n\nmodule.exports = ans;","'use strict';\n\nvar eightBits = require('./creator');\n\n/**\n * Count the number of true values in an array\n * @param {Array} arr\n * @return {number}\n */\nfunction count(arr) {\n var c = 0;\n for (var i = 0; i < arr.length; i++) {\n c += eightBits[arr[i] & 0xff] + eightBits[(arr[i] >> 8) & 0xff] + eightBits[(arr[i] >> 16) & 0xff] + eightBits[(arr[i] >> 24) & 0xff];\n }\n return c;\n}\n\n/**\n * Logical AND operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction and(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] & arr2[i];\n return ans;\n}\n\n/**\n * Logical OR operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction or(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] | arr2[i];\n return ans;\n}\n\n/**\n * Logical XOR operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction xor(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] ^ arr2[i];\n return ans;\n}\n\n/**\n * Logical NOT operation\n * @param {Array} arr\n * @return {Array}\n */\nfunction not(arr) {\n var ans = new Array(arr.length);\n for (var i = 0; i < ans.length; i++)\n ans[i] = ~arr[i];\n return ans;\n}\n\n/**\n * Gets the n value of array arr\n * @param {Array} arr\n * @param {number} n\n * @return {boolean}\n */\nfunction getBit(arr, n) {\n var index = n >> 5; // Same as Math.floor(n/32)\n var mask = 1 << (31 - n % 32);\n return Boolean(arr[index] & mask);\n}\n\n/**\n * Sets the n value of array arr to the value val\n * @param {Array} arr\n * @param {number} n\n * @param {boolean} val\n * @return {Array}\n */\nfunction setBit(arr, n, val) {\n var index = n >> 5; // Same as Math.floor(n/32)\n var mask = 1 << (31 - n % 32);\n if (val)\n arr[index] = mask | arr[index];\n else\n arr[index] = ~mask & arr[index];\n return arr;\n}\n\n/**\n * Translates an array of numbers to a string of bits\n * @param {Array} arr\n * @returns {string}\n */\nfunction toBinaryString(arr) {\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n var obj = (arr[i] >>> 0).toString(2);\n str += '00000000000000000000000000000000'.substr(obj.length) + obj;\n }\n return str;\n}\n\n/**\n * Creates an array of numbers based on a string of bits\n * @param {string} str\n * @returns {Array}\n */\nfunction parseBinaryString(str) {\n var len = str.length / 32;\n var ans = new Array(len);\n for (var i = 0; i < len; i++) {\n ans[i] = parseInt(str.substr(i*32, 32), 2) | 0;\n }\n return ans;\n}\n\n/**\n * Translates an array of numbers to a hex string\n * @param {Array} arr\n * @returns {string}\n */\nfunction toHexString(arr) {\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n var obj = (arr[i] >>> 0).toString(16);\n str += '00000000'.substr(obj.length) + obj;\n }\n return str;\n}\n\n/**\n * Creates an array of numbers based on a hex string\n * @param {string} str\n * @returns {Array}\n */\nfunction parseHexString(str) {\n var len = str.length / 8;\n var ans = new Array(len);\n for (var i = 0; i < len; i++) {\n ans[i] = parseInt(str.substr(i*8, 8), 16) | 0;\n }\n return ans;\n}\n\n/**\n * Creates a human readable string of the array\n * @param {Array} arr\n * @returns {string}\n */\nfunction toDebug(arr) {\n var binary = toBinaryString(arr);\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n str += '0000'.substr((i * 32).toString(16).length) + (i * 32).toString(16) + ':';\n for (var j = 0; j < 32; j += 4) {\n str += ' ' + binary.substr(i * 32 + j, 4);\n }\n if (i < arr.length - 1) str += '\\n';\n }\n return str\n}\n\nmodule.exports = {\n count: count,\n and: and,\n or: or,\n xor: xor,\n not: not,\n getBit: getBit,\n setBit: setBit,\n toBinaryString: toBinaryString,\n parseBinaryString: parseBinaryString,\n toHexString: toHexString,\n parseHexString: parseHexString,\n toDebug: toDebug\n};\n","export default function SavitzkyGolay(data, h, options = {}) {\n let { windowSize = 9, derivative = 0, polynomial = 3 } = options;\n\n if (windowSize % 2 === 0 || windowSize < 5 || !Number.isInteger(windowSize)) {\n throw new RangeError(\n 'Invalid window size (should be odd and at least 5 integer number)',\n );\n }\n if (windowSize > data.length) {\n throw new RangeError(\n `Window size is higher than the data length ${windowSize}>${data.length}`,\n );\n }\n if (derivative < 0 || !Number.isInteger(derivative)) {\n throw new RangeError('Derivative should be a positive integer');\n }\n if (polynomial < 1 || !Number.isInteger(polynomial)) {\n throw new RangeError('Polynomial should be a positive integer');\n }\n if (polynomial >= 6) {\n // eslint-disable-next-line no-console\n console.warn(\n 'You should not use polynomial grade higher than 5 if you are' +\n ' not sure that your data arises from such a model. Possible polynomial oscillation problems',\n );\n }\n\n let half = Math.floor(windowSize / 2);\n let np = data.length;\n let ans = new Array(np);\n let weights = fullWeights(windowSize, polynomial, derivative);\n let hs = 0;\n let constantH = true;\n if (Array.isArray(h)) {\n constantH = false;\n } else {\n hs = Math.pow(h, derivative);\n }\n\n //For the borders\n for (let i = 0; i < half; i++) {\n let wg1 = weights[half - i - 1];\n let wg2 = weights[half + i + 1];\n let d1 = 0;\n let d2 = 0;\n for (let l = 0; l < windowSize; l++) {\n d1 += wg1[l] * data[l];\n d2 += wg2[l] * data[np - windowSize + l];\n }\n if (constantH) {\n ans[half - i - 1] = d1 / hs;\n ans[np - half + i] = d2 / hs;\n } else {\n hs = getHs(h, half - i - 1, half, derivative);\n ans[half - i - 1] = d1 / hs;\n hs = getHs(h, np - half + i, half, derivative);\n ans[np - half + i] = d2 / hs;\n }\n }\n\n //For the internal points\n let wg = weights[half];\n for (let i = windowSize; i <= np; i++) {\n let d = 0;\n for (let l = 0; l < windowSize; l++) d += wg[l] * data[l + i - windowSize];\n if (!constantH) hs = getHs(h, i - half - 1, half, derivative);\n ans[i - half - 1] = d / hs;\n }\n return ans;\n}\n\nfunction getHs(h, center, half, derivative) {\n let hs = 0;\n let count = 0;\n for (let i = center - half; i < center + half; i++) {\n if (i >= 0 && i < h.length - 1) {\n hs += h[i + 1] - h[i];\n count++;\n }\n }\n return Math.pow(hs / count, derivative);\n}\n\nfunction GramPoly(i, m, k, s) {\n let Grampoly = 0;\n if (k > 0) {\n Grampoly =\n ((4 * k - 2) / (k * (2 * m - k + 1))) *\n (i * GramPoly(i, m, k - 1, s) + s * GramPoly(i, m, k - 1, s - 1)) -\n (((k - 1) * (2 * m + k)) / (k * (2 * m - k + 1))) *\n GramPoly(i, m, k - 2, s);\n } else {\n if (k === 0 && s === 0) {\n Grampoly = 1;\n } else {\n Grampoly = 0;\n }\n }\n return Grampoly;\n}\n\nfunction GenFact(a, b) {\n let gf = 1;\n if (a >= b) {\n for (let j = a - b + 1; j <= a; j++) {\n gf *= j;\n }\n }\n return gf;\n}\n\nfunction Weight(i, t, m, n, s) {\n let sum = 0;\n for (let k = 0; k <= n; k++) {\n //console.log(k);\n sum +=\n (2 * k + 1) *\n (GenFact(2 * m, k) / GenFact(2 * m + k + 1, k + 1)) *\n GramPoly(i, m, k, 0) *\n GramPoly(t, m, k, s);\n }\n return sum;\n}\n\n/**\n *\n * @param m Number of points\n * @param n Polynomial grade\n * @param s Derivative\n */\nfunction fullWeights(m, n, s) {\n let weights = new Array(m);\n let np = Math.floor(m / 2);\n for (let t = -np; t <= np; t++) {\n weights[t + np] = new Array(m);\n for (let j = -np; j <= np; j++) {\n weights[t + np][j + np] = Weight(j, t, np, n, s);\n }\n }\n return weights;\n}\n\n/*function entropy(data,h,options){\n var trend = SavitzkyGolay(data,h,trendOptions);\n var copy = new Array(data.length);\n var sum = 0;\n var max = 0;\n for(var i=0;i} x - Independent variable\n * @param {Array} yIn - Dependent variable\n * @param {object} [options] - Options object\n * @param {object} [options.sgOptions] - Options object for Savitzky-Golay filter. See https://github.com/mljs/savitzky-golay-generalized#options\n * @param {number} [options.sgOptions.windowSize = 9] - points to use in the approximations\n * @param {number} [options.sgOptions.polynomial = 3] - degree of the polynomial to use in the approximations\n * @param {number} [options.minMaxRatio = 0.00025] - Threshold to determine if a given peak should be considered as a noise\n * @param {number} [options.broadRatio = 0.00] - If `broadRatio` is higher than 0, then all the peaks which second derivative\n * smaller than `broadRatio * maxAbsSecondDerivative` will be marked with the soft mask equal to true.\n * @param {number} [options.noiseLevel = 0] - Noise threshold in spectrum units\n * @param {boolean} [options.maxCriteria = true] - Peaks are local maximum(true) or minimum(false)\n * @param {boolean} [options.smoothY = true] - Select the peak intensities from a smoothed version of the independent variables\n * @param {boolean} [options.realTopDetection = false] - Use a quadratic optimizations with the peak and its 3 closest neighbors\n * to determine the true x,y values of the peak?\n * @param {number} [options.heightFactor = 0] - Factor to multiply the calculated height (usually 2)\n * @param {number} [options.derivativeThreshold = -1] - Filters based on the amplitude of the first derivative\n * @return {Array}\n */\nexport function gsd(x, yIn, options = {}) {\n let {\n noiseLevel,\n sgOptions = {\n windowSize: 9,\n polynomial: 3,\n },\n smoothY = true,\n heightFactor = 0,\n broadRatio = 0.0,\n maxCriteria = true,\n minMaxRatio = 0.00025,\n derivativeThreshold = -1,\n realTopDetection = false,\n } = options;\n\n const y = yIn.slice();\n let equalSpaced = isEqualSpaced(x);\n\n if (noiseLevel === undefined) {\n noiseLevel = equalSpaced ? getNoiseLevel(y) : 0;\n }\n\n const yCorrection = { m: 1, b: noiseLevel };\n\n if (!maxCriteria) {\n yCorrection.m = -1;\n yCorrection.b *= -1;\n }\n\n for (let i = 0; i < y.length; i++) {\n y[i] = yCorrection.m * y[i] - yCorrection.b;\n }\n\n for (let i = 0; i < y.length; i++) {\n if (y[i] < 0) {\n y[i] = 0;\n }\n }\n // If the max difference between delta x is less than 5%, then,\n // we can assume it to be equally spaced variable\n let yData = y;\n let dY, ddY;\n const { windowSize, polynomial } = sgOptions;\n\n if (equalSpaced) {\n if (smoothY) {\n yData = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 0,\n });\n }\n dY = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 1,\n });\n ddY = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 2,\n });\n } else {\n if (smoothY) {\n yData = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 0,\n });\n }\n dY = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 1,\n });\n ddY = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 2,\n });\n }\n\n const xData = x;\n const dX = x[1] - x[0];\n let maxDdy = 0;\n let maxY = 0;\n for (let i = 0; i < yData.length; i++) {\n if (Math.abs(ddY[i]) > maxDdy) {\n maxDdy = Math.abs(ddY[i]);\n }\n if (Math.abs(yData[i]) > maxY) {\n maxY = Math.abs(yData[i]);\n }\n }\n\n let lastMax = null;\n let lastMin = null;\n let minddY = new Array(yData.length - 2);\n let intervalL = new Array(yData.length);\n let intervalR = new Array(yData.length);\n let broadMask = new Array(yData.length - 2);\n let minddYLen = 0;\n let intervalLLen = 0;\n let intervalRLen = 0;\n let broadMaskLen = 0;\n // By the intermediate value theorem We cannot find 2 consecutive maximum or minimum\n for (let i = 1; i < yData.length - 1; ++i) {\n // filter based on derivativeThreshold\n // console.log('pasa', y[i], dY[i], ddY[i]);\n if (Math.abs(dY[i]) > derivativeThreshold) {\n // Minimum in first derivative\n if (\n (dY[i] < dY[i - 1] && dY[i] <= dY[i + 1]) ||\n (dY[i] <= dY[i - 1] && dY[i] < dY[i + 1])\n ) {\n lastMin = {\n x: xData[i],\n index: i,\n };\n if (dX > 0 && lastMax !== null) {\n intervalL[intervalLLen++] = lastMax;\n intervalR[intervalRLen++] = lastMin;\n }\n }\n\n // Maximum in first derivative\n if (\n (dY[i] >= dY[i - 1] && dY[i] > dY[i + 1]) ||\n (dY[i] > dY[i - 1] && dY[i] >= dY[i + 1])\n ) {\n lastMax = {\n x: xData[i],\n index: i,\n };\n if (dX < 0 && lastMin !== null) {\n intervalL[intervalLLen++] = lastMax;\n intervalR[intervalRLen++] = lastMin;\n }\n }\n }\n\n // Minimum in second derivative\n if (ddY[i] < ddY[i - 1] && ddY[i] < ddY[i + 1]) {\n // TODO should we change this to have 3 arrays ? Huge overhead creating arrays\n minddY[minddYLen++] = i; // ( [xData[i], yData[i], i] );\n broadMask[broadMaskLen++] = Math.abs(ddY[i]) <= broadRatio * maxDdy;\n }\n }\n minddY.length = minddYLen;\n intervalL.length = intervalLLen;\n intervalR.length = intervalRLen;\n broadMask.length = broadMaskLen;\n\n let signals = new Array(minddY.length);\n let signalsLen = 0;\n let lastK = -1;\n let possible, frequency, distanceJ, minDistance, gettingCloser;\n for (let j = 0; j < minddY.length; ++j) {\n frequency = xData[minddY[j]];\n possible = -1;\n let k = lastK + 1;\n minDistance = Number.MAX_VALUE;\n distanceJ = 0;\n gettingCloser = true;\n while (possible === -1 && k < intervalL.length && gettingCloser) {\n distanceJ = Math.abs(frequency - (intervalL[k].x + intervalR[k].x) / 2);\n\n // Still getting closer?\n if (distanceJ < minDistance) {\n minDistance = distanceJ;\n } else {\n gettingCloser = false;\n }\n if (distanceJ < Math.abs(intervalL[k].x - intervalR[k].x) / 2) {\n possible = k;\n lastK = k;\n }\n ++k;\n }\n\n if (possible !== -1) {\n if (Math.abs(yData[minddY[j]]) > minMaxRatio * maxY) {\n signals[signalsLen++] = {\n index: minddY[j],\n x: frequency,\n y: (yData[minddY[j]] + yCorrection.b) / yCorrection.m,\n width: Math.abs(intervalR[possible].x - intervalL[possible].x), // widthCorrection\n soft: broadMask[j],\n };\n\n signals[signalsLen - 1].left = intervalL[possible];\n signals[signalsLen - 1].right = intervalR[possible];\n\n if (heightFactor) {\n let yLeft = yData[intervalL[possible].index];\n let yRight = yData[intervalR[possible].index];\n signals[signalsLen - 1].height =\n heightFactor * (signals[signalsLen - 1].y - (yLeft + yRight) / 2);\n }\n }\n }\n }\n signals.length = signalsLen;\n\n if (realTopDetection) {\n determineRealTop(signals, xData, yData);\n }\n\n // Correct the values to fit the original spectra data\n for (let j = 0; j < signals.length; j++) {\n signals[j].base = noiseLevel;\n }\n\n signals.sort(function (a, b) {\n return a.x - b.x;\n });\n\n return signals;\n}\n\nconst isEqualSpaced = (x) => {\n let tmp;\n let maxDx = 0;\n let minDx = Number.MAX_SAFE_INTEGER;\n for (let i = 0; i < x.length - 1; ++i) {\n tmp = Math.abs(x[i + 1] - x[i]);\n if (tmp < minDx) {\n minDx = tmp;\n }\n if (tmp > maxDx) {\n maxDx = tmp;\n }\n }\n return (maxDx - minDx) / maxDx < 0.05;\n};\n\nconst getNoiseLevel = (y) => {\n let mean = 0;\n\n let stddev = 0;\n let length = y.length;\n for (let i = 0; i < length; ++i) {\n mean += y[i];\n }\n mean /= length;\n let averageDeviations = new Array(length);\n for (let i = 0; i < length; ++i) {\n averageDeviations[i] = Math.abs(y[i] - mean);\n }\n averageDeviations.sort((a, b) => a - b);\n if (length % 2 === 1) {\n stddev = averageDeviations[(length - 1) / 2] / 0.6745;\n } else {\n stddev =\n (0.5 *\n (averageDeviations[length / 2] + averageDeviations[length / 2 - 1])) /\n 0.6745;\n }\n\n return stddev;\n};\n\nconst determineRealTop = (peakList, x, y) => {\n let alpha, beta, gamma, p, currentPoint;\n for (let j = 0; j < peakList.length; j++) {\n currentPoint = peakList[j].index; // peakList[j][2];\n // The detected peak could be moved 1 or 2 units to left or right.\n if (\n y[currentPoint - 1] >= y[currentPoint - 2] &&\n y[currentPoint - 1] >= y[currentPoint]\n ) {\n currentPoint--;\n } else {\n if (\n y[currentPoint + 1] >= y[currentPoint] &&\n y[currentPoint + 1] >= y[currentPoint + 2]\n ) {\n currentPoint++;\n } else {\n if (\n y[currentPoint - 2] >= y[currentPoint - 3] &&\n y[currentPoint - 2] >= y[currentPoint - 1]\n ) {\n currentPoint -= 2;\n } else {\n if (\n y[currentPoint + 2] >= y[currentPoint + 1] &&\n y[currentPoint + 2] >= y[currentPoint + 3]\n ) {\n currentPoint += 2;\n }\n }\n }\n }\n // interpolation to a sin() function\n if (\n y[currentPoint - 1] > 0 &&\n y[currentPoint + 1] > 0 &&\n y[currentPoint] >= y[currentPoint - 1] &&\n y[currentPoint] >= y[currentPoint + 1] &&\n (y[currentPoint] !== y[currentPoint - 1] ||\n y[currentPoint] !== y[currentPoint + 1])\n ) {\n alpha = 20 * Math.log10(y[currentPoint - 1]);\n beta = 20 * Math.log10(y[currentPoint]);\n gamma = 20 * Math.log10(y[currentPoint + 1]);\n p = (0.5 * (alpha - gamma)) / (alpha - 2 * beta + gamma);\n // console.log(alpha, beta, gamma, `p: ${p}`);\n // console.log(x[currentPoint]+\" \"+tmp+\" \"+currentPoint);\n peakList[j].x =\n x[currentPoint] + (x[currentPoint] - x[currentPoint - 1]) * p;\n peakList[j].y =\n y[currentPoint] -\n 0.25 * (y[currentPoint - 1] - y[currentPoint + 1]) * p;\n }\n }\n};\n","/**\n * This function calculates the spectrum as a sum of gaussian functions. The Gaussian\n * parameters are divided in 3 batches. 1st: centers; 2nd: height; 3th: std's;\n * @param t Ordinate values\n * @param p Gaussian parameters\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\nexport function sumOfGaussians(p) {\n return function (t) {\n let nL = p.length / 3;\n let factor;\n let rows = t.length;\n let result = rows === undefined ? 0 : new Float64Array(rows).fill(0);\n for (let i = 0; i < nL; i++) {\n factor = Math.pow(p[i + nL * 2], 2) * 2;\n if (rows === undefined) {\n result += p[i + nL] * Math.exp(-Math.pow(t - p[i], 2) / factor);\n } else {\n for (let j = 0; j < rows; j++) {\n result[j] += p[i + nL] * Math.exp(-Math.pow(t[j] - p[i], 2) / factor);\n }\n }\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { sumOfGaussians } from './sumOfGaussians';\n\n/**\n *\n * @param xy A two column matrix containing the x and y data to be fitted\n * @param group A set of initial lorentzian parameters to be optimized [center, heigth, half_width_at_half_height]\n * @returns {Array} A set of final lorentzian parameters [center, heigth, hwhh*2]\n */\nexport function optimizeGaussianSum(xy, group, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let nL = group.length;\n let pInit = new Float64Array(nL * 3);\n let pMin = new Float64Array(nL * 3);\n let pMax = new Float64Array(nL * 3);\n let dt = Math.abs(t[0] - t[1]);\n\n for (let i = 0; i < nL; i++) {\n pInit[i] = group[i].x;\n pInit[i + nL] = group[i].y / maxY;\n pInit[i + 2 * nL] = group[i].width;\n\n pMin[i] = group[i].x - dt;\n pMin[i + nL] = 0;\n pMin[i + 2 * nL] = group[i].width / 4;\n\n pMax[i] = group[i].x + dt;\n pMax[i + nL] = (group[i].y * 1.2) / maxY;\n pMax[i + 2 * nL] = group[i].width * 4;\n }\n\n let data = {\n x: t,\n y: yData,\n };\n let result = new Array(nL);\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n\n let pFit = LM(data, sumOfGaussians, opts);\n for (let i = 0; i < nL; i++) {\n result[i] = {\n parameters: [\n pFit.parameterValues[i],\n pFit.parameterValues[i + nL] * maxY,\n pFit.parameterValues[i + nL * 2],\n ],\n error: pFit.parameterError,\n };\n }\n return result;\n}\n","/**\n * Single 3 parameter gaussian function\n * @param t Ordinate values\n * @param p Gaussian parameters [mean, height, std]\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\n\nexport function singleGaussian(p) {\n return function (t) {\n let factor2 = (p[2] * p[2]) / 2;\n let rows = t.length;\n if (!rows) return p[1] * Math.exp((-(t - p[0]) * (t - p[0])) / factor2);\n let result = new Float64Array(t.length);\n for (let i = 0; i < t.length; i++) {\n result[i] = p[1] * Math.exp((-(t[i] - p[0]) * (t[i] - p[0])) / factor2);\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { singleGaussian } from './singleGaussian';\n\n/**\n * Fits a set of points to a gaussian bell. Returns the mean of the peak, the std and the height of the signal.\n * @param data,[y]\n * @returns {*[]}\n */\nexport function optimizeSingleGaussian(xy, peak, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let dt = Math.abs(t[0] - t[1]);\n let pInit = new Float64Array([peak.x, 1, peak.width]);\n let pMin = new Float64Array([peak.x - dt, 0, peak.width / 4]);\n let pMax = new Float64Array([peak.x + dt, 1.25, peak.width * 4]);\n\n let data = {\n x: t,\n y: yData,\n };\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n let pFit = LM(data, singleGaussian, opts);\n return {\n parameters: [\n pFit.parameterValues[0],\n pFit.parameterValues[1] * maxY,\n pFit.parameterValues[2],\n ],\n error: pFit.parameterError,\n };\n}\n","/**\n * This function calculates the spectrum as a sum of lorentzian functions. The Lorentzian\n * parameters are divided in 3 batches. 1st: centers; 2nd: heights; 3th: widths;\n * @param t Ordinate values\n * @param p Lorentzian parameters\n * @returns {*}\n */\n\nexport function sumOfLorentzians(p) {\n return function (t) {\n let nL = p.length / 3;\n let factor;\n let p2;\n let rows = t.length;\n let result = rows === undefined ? 0 : new Float64Array(rows).fill(0);\n for (let i = 0; i < nL; i++) {\n p2 = Math.pow(p[i + nL * 2] / 2, 2);\n factor = p[i + nL] * p2;\n if (rows === undefined) {\n result += factor / (Math.pow(t - p[i], 2) + p2);\n } else {\n for (let j = 0; j < rows; j++) {\n result[j] += factor / (Math.pow(t[j] - p[i], 2) + p2);\n }\n }\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { sumOfLorentzians } from './sumOfLorentzians';\n\n/**\n *\n * @param xy A two column matrix containing the x and y data to be fitted\n * @param group A set of initial lorentzian parameters to be optimized [center, heigth, half_width_at_half_height]\n * @returns {Array} A set of final lorentzian parameters [center, heigth, hwhh*2]\n */\nexport function optimizeLorentzianSum(xy, group, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n\n let nL = group.length;\n let pInit = new Float64Array(nL * 3);\n let pMin = new Float64Array(nL * 3);\n let pMax = new Float64Array(nL * 3);\n let dt = Math.abs(t[0] - t[1]);\n\n for (let i = 0; i < nL; i++) {\n pInit[i] = group[i].x;\n pInit[i + nL] = 1;\n pInit[i + 2 * nL] = group[i].width;\n\n pMin[i] = group[i].x - dt;\n pMin[i + nL] = 0;\n pMin[i + 2 * nL] = group[i].width / 4;\n\n pMax[i] = group[i].x + dt;\n pMax[i + nL] = 1.5;\n pMax[i + 2 * nL] = group[i].width * 4;\n }\n\n let data = {\n x: t,\n y: yData,\n };\n\n let result = new Array(nL);\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n\n let pFit = LM(data, sumOfLorentzians, opts);\n for (let i = 0; i < nL; i++) {\n result[i] = {\n parameters: [\n pFit.parameterValues[i],\n pFit.parameterValues[i + nL] * maxY,\n pFit.parameterValues[i + nL * 2],\n ],\n error: pFit.parameterError,\n };\n }\n return result;\n}\n","/**\n * Single 4 parameter lorentzian function\n * @param t Ordinate values\n * @param p Lorentzian parameters\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\n\nexport function singleLorentzian(p) {\n return function (t) {\n let factor = p[1] * Math.pow(p[2] / 2, 2);\n let rows = t.length;\n if (!rows) return factor / (Math.pow(t - p[0], 2) + Math.pow(p[2] / 2, 2));\n let result = new Float64Array(rows);\n for (let i = 0; i < rows; i++) {\n result[i] = factor / (Math.pow(t[i] - p[0], 2) + Math.pow(p[2] / 2, 2));\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { singleLorentzian } from './singleLorentzian';\n\n/**\n * * Fits a set of points to a Lorentzian function. Returns the center of the peak, the width at half height, and the height of the signal.\n * @param data,[y]\n * @returns {*[]}\n */\nexport function optimizeSingleLorentzian(xy, peak, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let dt = Math.abs(t[0] - t[1]);\n let pInit = new Float64Array([peak.x, 1, peak.width]);\n let pMin = new Float64Array([peak.x - dt, 0.75, peak.width / 4]);\n let pMax = new Float64Array([peak.x + dt, 1.25, peak.width * 4]);\n\n let data = {\n x: t,\n y: yData,\n };\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n opts = Object.assign({}, lmOptions, opts);\n let pFit = LM(data, singleLorentzian, opts);\n return {\n parameters: [\n pFit.parameterValues[0],\n pFit.parameterValues[1] * maxY,\n pFit.parameterValues[2],\n ],\n error: pFit.parameterError,\n };\n}\n","import {\n optimizeGaussianSum,\n optimizeLorentzianSum,\n optimizeSingleGaussian,\n optimizeSingleLorentzian,\n} from 'ml-optimize-lorentzian';\n\nexport function optimizePeaks(peakList, x, y, options = {}) {\n const {\n functionName = 'gaussian',\n factorWidth = 4,\n optimizationOptions = {\n damping: 1.5,\n maxIterations: 100,\n errorTolerance: 10e-5,\n },\n } = options;\n\n let lastIndex = [0];\n let groups = groupPeaks(peakList, factorWidth);\n let result = [];\n let factor = 1;\n if (functionName === 'gaussian') {\n factor = 1.17741;\n } // From https://en.wikipedia.org/wiki/Gaussian_function#Properties\n let sampling;\n for (let i = 0; i < groups.length; i++) {\n let peaks = groups[i].group;\n if (peaks.length > 1) {\n // Multiple peaks\n sampling = sampleFunction(\n groups[i].limits[0] - groups[i].limits[1],\n groups[i].limits[0] + groups[i].limits[1],\n x,\n y,\n lastIndex,\n );\n if (sampling[0].length > 5) {\n let optPeaks = [];\n if (functionName === 'gaussian') {\n optPeaks = optimizeGaussianSum(sampling, peaks, optimizationOptions);\n } else {\n if (functionName === 'lorentzian') {\n optPeaks = optimizeLorentzianSum(\n sampling,\n peaks,\n optimizationOptions,\n );\n }\n }\n\n for (let j = 0; j < optPeaks.length; j++) {\n let { parameters } = optPeaks[j];\n result.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2] * factor,\n index: peaks[j].index,\n });\n }\n }\n } else {\n // Single peak\n peaks = peaks[0];\n sampling = sampleFunction(\n peaks.x - factorWidth * peaks.width,\n peaks.x + factorWidth * peaks.width,\n x,\n y,\n lastIndex,\n );\n\n if (sampling[0].length > 5) {\n let fitResult = [];\n if (functionName === 'gaussian') {\n fitResult = optimizeSingleGaussian(\n [sampling[0], sampling[1]],\n peaks,\n optimizationOptions,\n );\n } else {\n if (functionName === 'lorentzian') {\n fitResult = optimizeSingleLorentzian(\n [sampling[0], sampling[1]],\n peaks,\n optimizationOptions,\n );\n }\n }\n\n let { parameters } = fitResult;\n result.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2] * factor,\n index: peaks.index,\n }); // From https://en.wikipedia.org/wiki/Gaussian_function#Properties}\n }\n }\n }\n return result;\n}\n\nfunction sampleFunction(from, to, x, y, lastIndex) {\n let nbPoints = x.length;\n let sampleX = [];\n let sampleY = [];\n let direction = Math.sign(x[1] - x[0]); // Direction of the derivative\n if (direction === -1) {\n lastIndex[0] = x.length - 1;\n }\n\n let delta = Math.abs(to - from) / 2;\n let mid = (from + to) / 2;\n let stop = false;\n let index = lastIndex[0];\n while (!stop && index < nbPoints && index >= 0) {\n if (Math.abs(x[index] - mid) <= delta) {\n sampleX.push(x[index]);\n sampleY.push(y[index]);\n index += direction;\n } else {\n // It is outside the range.\n if (Math.sign(mid - x[index]) === 1) {\n // We'll reach the mid going in the current direction\n index += direction;\n } else {\n // There is not more peaks in the current range\n stop = true;\n }\n }\n }\n lastIndex[0] = index;\n return [sampleX, sampleY];\n}\n\nfunction groupPeaks(peakList, nL) {\n let group = [];\n let groups = [];\n let limits = [peakList[0].x, nL * peakList[0].width];\n let upperLimit, lowerLimit;\n // Merge forward\n for (let i = 0; i < peakList.length; i++) {\n // If the 2 things overlaps\n if (\n Math.abs(peakList[i].x - limits[0]) <\n nL * peakList[i].width + limits[1]\n ) {\n // Add the peak to the group\n group.push(peakList[i]);\n // Update the group limits\n upperLimit = limits[0] + limits[1];\n if (peakList[i].x + nL * peakList[i].width > upperLimit) {\n upperLimit = peakList[i].x + nL * peakList[i].width;\n }\n lowerLimit = limits[0] - limits[1];\n if (peakList[i].x - nL * peakList[i].width < lowerLimit) {\n lowerLimit = peakList[i].x - nL * peakList[i].width;\n }\n limits = [\n (upperLimit + lowerLimit) / 2,\n Math.abs(upperLimit - lowerLimit) / 2,\n ];\n } else {\n groups.push({ limits: limits, group: group });\n // var optmimalPeak = fitSpectrum(group,limits,spectrum);\n group = [peakList[i]];\n limits = [peakList[i].x, nL * peakList[i].width];\n }\n }\n groups.push({ limits: limits, group: group });\n // Merge backward\n for (let i = groups.length - 2; i >= 0; i--) {\n // The groups overlaps\n if (\n Math.abs(groups[i].limits[0] - groups[i + 1].limits[0]) <\n (groups[i].limits[1] + groups[i + 1].limits[1]) / 2\n ) {\n for (let j = 0; j < groups[i + 1].group.length; j++) {\n groups[i].group.push(groups[i + 1].group[j]);\n }\n upperLimit = groups[i].limits[0] + groups[i].limits[1];\n if (groups[i + 1].limits[0] + groups[i + 1].limits[1] > upperLimit) {\n upperLimit = groups[i + 1].limits[0] + groups[i + 1].limits[1];\n }\n lowerLimit = groups[i].limits[0] - groups[i].limits[1];\n if (groups[i + 1].limits[0] - groups[i + 1].limits[1] < lowerLimit) {\n lowerLimit = groups[i + 1].limits[0] - groups[i + 1].limits[1];\n }\n\n groups[i].limits = [\n (upperLimit + lowerLimit) / 2,\n Math.abs(upperLimit - lowerLimit) / 2,\n ];\n\n groups.splice(i + 1, 1);\n }\n }\n return groups;\n}\n","import { optimizeSingleLorentzian } from 'ml-optimize-lorentzian';\n\n/**\n * This function try to join the peaks that seems to belong to a broad signal in a single broad peak.\n * @param peakList\n * @param options\n */\nexport function joinBroadPeaks(peakList, options = {}) {\n let width = options.width;\n let broadLines = [];\n // Optimize the possible broad lines\n let max = 0;\n\n let maxI = 0;\n\n let count = 1;\n for (let i = peakList.length - 1; i >= 0; i--) {\n if (peakList[i].soft) {\n broadLines.push(peakList.splice(i, 1)[0]);\n }\n }\n // Push a feke peak\n broadLines.push({ x: Number.MAX_VALUE });\n\n let candidates = [[broadLines[0].x, broadLines[0].y]];\n let indexes = [broadLines[0].index];\n\n for (let i = 1; i < broadLines.length; i++) {\n // console.log(broadLines[i-1].x+\" \"+broadLines[i].x);\n if (Math.abs(broadLines[i - 1].x - broadLines[i].x) < width) {\n candidates.push([broadLines[i].x, broadLines[i].y]);\n if (broadLines[i].y > max) {\n max = broadLines[i].y;\n maxI = i;\n }\n indexes.push(broadLines[i].index);\n count++;\n } else {\n if (count > 2) {\n let fitted = optimizeSingleLorentzian(candidates, {\n x: broadLines[maxI].x,\n y: max,\n width: Math.abs(\n candidates[0][0] - candidates[candidates.length - 1][0],\n ),\n });\n let { parameters } = fitted;\n peakList.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2],\n index: Math.floor(\n indexes.reduce((a, b) => a + b, 0) / indexes.length,\n ),\n soft: false,\n });\n } else {\n // Put back the candidates to the signals list\n indexes.forEach((index) => {\n peakList.push(broadLines[index]);\n });\n }\n candidates = [[broadLines[i].x, broadLines[i].y]];\n indexes = [i];\n max = broadLines[i].y;\n maxI = i;\n count = 1;\n }\n }\n\n peakList.sort(function (a, b) {\n return a.x - b.x;\n });\n\n return peakList;\n}\n","/**\n * This method will allow to enlarge peaks and prevent overlap between peaks\n * Because peaks may not be symmetric after we add 2 properties, from and to.\n * @param {Array} peakList\n * @param {object} [options={}]\n * @param {number} [factor=2]\n * @param {boolean} [overlap=false] by default we don't allow overlap\n * @return {Array} peakList\n */\nexport function broadenPeaks(peakList, options = {}) {\n const { factor = 2, overlap = false } = options;\n\n for (let peak of peakList) {\n if (!peak.right || !peak.left) {\n peak.from = peak.x - (peak.width / 2) * factor;\n peak.to = peak.x + (peak.width / 2) * factor;\n } else {\n peak.from = peak.x - (peak.x - peak.left.x) * factor;\n peak.to = peak.x + (peak.right.x - peak.x) * factor;\n }\n }\n\n if (!overlap) {\n for (let i = 0; i < peakList.length - 1; i++) {\n let peak = peakList[i];\n let nextPeak = peakList[i + 1];\n if (peak.to > nextPeak.from) {\n peak.to = nextPeak.from = (peak.to + nextPeak.from) / 2;\n }\n }\n }\n\n for (let peak of peakList) {\n peak.width = peak.to - peak.from;\n }\n\n return peakList;\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction min(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var minValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\n\nfunction mode(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var maxValue = 0;\n var maxCount = 0;\n var count = 0;\n var counts = {};\n\n for (var i = 0; i < input.length; ++i) {\n var element = input[i];\n count = counts[element];\n\n if (count) {\n counts[element]++;\n count++;\n } else {\n counts[element] = count = 1;\n }\n\n if (count > maxCount) {\n maxCount = count;\n maxValue = input[i];\n }\n }\n\n return maxValue;\n}\n\nexport default mode;\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\nimport max from 'ml-array-max';\nimport sum from 'ml-array-sum';\n\nfunction norm(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var _options$algorithm = options.algorithm,\n algorithm = _options$algorithm === void 0 ? 'absolute' : _options$algorithm,\n _options$sumValue = options.sumValue,\n sumValue = _options$sumValue === void 0 ? 1 : _options$sumValue,\n _options$maxValue = options.maxValue,\n maxValue = _options$maxValue === void 0 ? 1 : _options$maxValue;\n\n if (!isArray(input)) {\n throw new Error('input must be an array');\n }\n\n var output;\n\n if (options.output !== undefined) {\n if (!isArray(options.output)) {\n throw new TypeError('output option must be an array if specified');\n }\n\n output = options.output;\n } else {\n output = new Array(input.length);\n }\n\n if (input.length === 0) {\n throw new Error('input must not be empty');\n }\n\n switch (algorithm.toLowerCase()) {\n case 'absolute':\n {\n var absoluteSumValue = absoluteSum(input) / sumValue;\n if (absoluteSumValue === 0) return input.slice(0);\n\n for (var i = 0; i < input.length; i++) {\n output[i] = input[i] / absoluteSumValue;\n }\n\n return output;\n }\n\n case 'max':\n {\n var currentMaxValue = max(input);\n if (currentMaxValue === 0) return input.slice(0);\n var factor = maxValue / currentMaxValue;\n\n for (var _i = 0; _i < input.length; _i++) {\n output[_i] = input[_i] * factor;\n }\n\n return output;\n }\n\n case 'sum':\n {\n var sumFactor = sum(input) / sumValue;\n if (sumFactor === 0) return input.slice(0);\n\n for (var _i2 = 0; _i2 < input.length; _i2++) {\n output[_i2] = input[_i2] / sumFactor;\n }\n\n return output;\n }\n\n default:\n throw new Error(\"norm: unknown algorithm: \".concat(algorithm));\n }\n}\n\nfunction absoluteSum(input) {\n var sumValue = 0;\n\n for (var i = 0; i < input.length; i++) {\n sumValue += Math.abs(input[i]);\n }\n\n return sumValue;\n}\n\nexport default norm;\n","import isArray from 'is-any-array';\n\nfunction _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n _typeof = function (obj) {\n return typeof obj;\n };\n } else {\n _typeof = function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n }\n\n return _typeof(obj);\n}\n\n/**\r\n * Fill an array with sequential numbers\r\n * @param {Array} [input] - optional destination array (if not provided a new array will be created)\r\n * @param {object} [options={}]\r\n * @param {number} [options.from=0] - first value in the array\r\n * @param {number} [options.to=10] - last value in the array\r\n * @param {number} [options.size=input.length] - size of the array (if not provided calculated from step)\r\n * @param {number} [options.step] - if not provided calculated from size\r\n * @return {Array}\r\n */\n\nfunction sequentialFill() {\n var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (_typeof(input) === 'object' && !isArray(input)) {\n options = input;\n input = [];\n }\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n var _options = options,\n _options$from = _options.from,\n from = _options$from === void 0 ? 0 : _options$from,\n _options$to = _options.to,\n to = _options$to === void 0 ? 10 : _options$to,\n _options$size = _options.size,\n size = _options$size === void 0 ? input.length : _options$size,\n step = _options.step;\n\n if (size !== 0 && step) {\n throw new Error('step is defined by the array size');\n }\n\n if (!size) {\n if (step) {\n size = Math.floor((to - from) / step) + 1;\n } else {\n size = to - from + 1;\n }\n }\n\n if (!step && size) {\n step = (to - from) / (size - 1);\n }\n\n if (Array.isArray(input)) {\n // only works with normal array\n input.length = 0;\n\n for (var i = 0; i < size; i++) {\n input.push(from);\n from += step;\n }\n } else {\n if (input.length !== size) {\n throw new Error('sequentialFill typed array must have the correct length');\n }\n\n for (var _i = 0; _i < size; _i++) {\n input[_i] = from;\n from += step;\n }\n }\n\n return input;\n}\n\nexport default sequentialFill;\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\nimport arrayMean from 'ml-array-mean';\n\nfunction variance(values) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(values)) {\n throw new TypeError('input must be an array');\n }\n\n var _options$unbiased = options.unbiased,\n unbiased = _options$unbiased === void 0 ? true : _options$unbiased,\n _options$mean = options.mean,\n mean = _options$mean === void 0 ? arrayMean(values) : _options$mean;\n var sqrError = 0;\n\n for (var i = 0; i < values.length; i++) {\n var x = values[i] - mean;\n sqrError += x * x;\n }\n\n if (unbiased) {\n return sqrError / (values.length - 1);\n } else {\n return sqrError / values.length;\n }\n}\n\nexport default variance;\n","import variance from 'ml-array-variance';\n\nfunction standardDeviation(values) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return Math.sqrt(variance(values, options));\n}\n\nexport default standardDeviation;\n","/**\n * Merge abscissa values if the ordinate value is in a list of centroids\n * @param {object} originalPoints\n * @param {Array} originalPoints.x\n * @param {Array} originalPoints.y\n * @param {Array} centroids\n * @param {object} [options]\n * @param {number} [options.window = 0.01] - has to be a positive number\n * @return {{x: Array, y: Array}}\n */\nexport default function mergeByCentroids(\n originalPoints,\n centroids,\n options = {}\n) {\n const { window = 0.01 } = options;\n\n var mergedPoints = {\n x: centroids.slice(),\n y: new Array(centroids.length).fill(0)\n };\n\n var originalIndex = 0;\n var mergedIndex = 0;\n while (\n originalIndex < originalPoints.x.length &&\n mergedIndex < centroids.length\n ) {\n var diff = originalPoints.x[originalIndex] - centroids[mergedIndex];\n if (Math.abs(diff) < window) {\n mergedPoints.y[mergedIndex] += originalPoints.y[originalIndex++];\n } else if (diff < 0) {\n originalIndex++;\n } else {\n mergedIndex++;\n }\n }\n\n return mergedPoints;\n}\n","import binarySearch from 'binary-search';\nimport { ascending, descending } from 'num-sort';\n\n/**\n *\n * @param {object} points\n * @param {Array} originalPoints.x\n * @param {Array} originalPoints.y\n * @param {*} options\n * @return {{x: Array, y: Array}}\n */\nexport default function closestX(points, options) {\n const { x, y } = points;\n const { target = x[0], reverse = false } = options;\n\n let index;\n if (reverse) {\n index = binarySearch(x, target, descending);\n } else {\n index = binarySearch(x, target, ascending);\n }\n\n if (index >= 0) {\n return {\n x: x[index],\n y: y[index]\n };\n } else {\n index = ~index;\n if (\n (index !== 0 && Math.abs(x[index] - target) > 0.5) ||\n index === x.length\n ) {\n return {\n x: x[index - 1],\n y: y[index - 1]\n };\n } else {\n return {\n x: x[index],\n y: y[index]\n };\n }\n }\n}\n","import mean from 'ml-array-mean';\n\n/**\n *\n * @param {object} points\n * @param {Array} points.x\n * @param {Array} points.y\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @return {number}\n */\nexport default function covariance(points, options = {}) {\n const { x, y } = points;\n const { unbiased = true } = options;\n\n const meanX = mean(x);\n const meanY = mean(y);\n\n var error = 0;\n\n for (let i = 0; i < x.length; i++) {\n error += (x[i] - meanX) * (y[i] - meanY);\n }\n\n if (unbiased) {\n return error / (x.length - 1);\n } else {\n return error / x.length;\n }\n}\n","/**\n * Merge abscissas values on similar ordinates and weight the group of abscissas\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {number} [options.groupWidth = 0.001] - window for abscissas to merge\n * @return {{x: Array, y: Array}}\n */\nexport default function maxMerge(points, options = {}) {\n const { x, y } = points;\n const { groupWidth = 0.001 } = options;\n\n var merged = { x: [], y: [] };\n var maxAbscissa = { x: [], y: [] };\n var size = 0;\n var index = 0;\n\n while (index < x.length) {\n if (size === 0 || x[index] - merged.x[size - 1] > groupWidth) {\n maxAbscissa.x.push(x[index]);\n maxAbscissa.y.push(y[index]);\n merged.x.push(x[index]);\n merged.y.push(y[index]);\n index++;\n size++;\n } else {\n if (y[index] > maxAbscissa.y[size - 1]) {\n maxAbscissa.x[size - 1] = x[index];\n maxAbscissa.y[size - 1] = y[index];\n }\n merged.x[size - 1] = x[index];\n merged.y[size - 1] += y[index];\n index++;\n }\n }\n\n merged.x = maxAbscissa.x.slice();\n\n return merged;\n}\n","import binarySearch from 'binary-search';\nimport { ascending, descending } from 'num-sort';\n\n/**\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {object} [options.from = {index: 0}]\n * @param {object} [options.to = {index: x.length-1}]\n * @param {boolean} [options.reverse = false]\n * @return {{index: number, value: number}}\n */\nexport default function maxY(points, options = {}) {\n const { x, y } = points;\n let {\n from = { index: 0 },\n to = { index: x.length },\n reverse = false\n } = options;\n\n if (from.value !== undefined && from.index === undefined) {\n from.index = calculateIndex(from.value, x, reverse);\n }\n\n if (to.value !== undefined && to.index === undefined) {\n to.index = calculateIndex(to.value, x, reverse);\n }\n\n var currentMax = Number.MIN_VALUE;\n var currentIndex;\n for (var i = from.index; i < to.index; i++) {\n if (currentMax < y[i]) {\n currentMax = y[i];\n currentIndex = i;\n }\n }\n\n return {\n index: currentIndex,\n value: currentMax\n };\n}\n\n/**\n * @param {number} value\n * @param {Array} x\n * @param {boolean} reverse\n * @return {number} index of the value in the array\n */\nfunction calculateIndex(value, x, reverse) {\n let index;\n if (reverse) {\n index = binarySearch(x, value, descending);\n } else {\n index = binarySearch(x, value, ascending);\n }\n\n if (index < 0) {\n throw new Error(`the value ${value} doesn't belongs to the abscissa value`);\n }\n\n return index;\n}\n","export default function sortX(points, options = {}) {\n const { x, y } = points;\n const { reverse = false } = options;\n\n var sortFunc;\n if (!reverse) {\n sortFunc = (a, b) => a.x - b.x;\n } else {\n sortFunc = (a, b) => b.x - a.x;\n }\n\n var grouped = x\n .map((val, index) => ({\n x: val,\n y: y[index]\n }))\n .sort(sortFunc);\n\n var response = { x: x.slice(), y: y.slice() };\n for (var i = 0; i < x.length; i++) {\n response.x[i] = grouped[i].x;\n response.y[i] = grouped[i].y;\n }\n\n return response;\n}\n","\n/**\n * In place modification of the 2 arrays to make X unique and sum the Y if X has the same value\n * @param {object} [points={}] : Object of points contains property x (an array) and y (an array)\n * @return points\n */\n\nexport default function uniqueX(points = {}) {\n const { x, y } = points;\n if (x.length < 2) return;\n if (x.length !== y.length) {\n throw new Error('The X and Y arrays mush have the same length');\n }\n\n let current = x[0];\n let counter = 0;\n\n for (let i = 1; i < x.length; i++) {\n if (current !== x[i]) {\n counter++;\n current = x[i];\n x[counter] = x[i];\n if (i !== counter) {\n y[counter] = 0;\n }\n }\n if (i !== counter) {\n y[counter] += y[i];\n }\n }\n\n x.length = counter + 1;\n y.length = counter + 1;\n}\n","/**\n * Merge abscissas values on similar ordinates and weight the group of abscissas\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {number} [options.groupWidth = 0.001] - window for abscissas to merge\n * @return {{x: Array, y: Array}}\n */\nexport default function weightedMerge(points, options = {}) {\n const { x, y } = points;\n const { groupWidth = 0.001 } = options;\n\n var merged = { x: [], y: [] };\n var weightedAbscissa = { x: [], y: [] };\n var size = 0;\n var index = 0;\n\n while (index < x.length) {\n if (size === 0 || x[index] - merged.x[size - 1] > groupWidth) {\n weightedAbscissa.x.push(x[index] * y[index]);\n weightedAbscissa.y.push(y[index]);\n merged.x.push(x[index]);\n merged.y.push(y[index]);\n index++;\n size++;\n } else {\n weightedAbscissa.x[size - 1] += x[index] * y[index];\n weightedAbscissa.y[size - 1] += y[index];\n merged.x[size - 1] = x[index];\n merged.y[size - 1] += y[index];\n index++;\n }\n }\n\n for (var i = 0; i < merged.x.length; i++) {\n merged.x[i] = weightedAbscissa.x[i] / weightedAbscissa.y[i];\n }\n\n return merged;\n}\n","/**\n * Normalize an array of zones:\n * - ensure than from < to\n * - merge overlapping zones\n *\n * The method will always check if from if lower than to and will swap if required.\n * @param {Array} [zones=[]]\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of a zone\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of a zone\n */\n\nexport function normalize(zones = [], options = {}) {\n if (zones.length === 0) return [];\n let {\n from = Number.NEGATIVE_INFINITY,\n to = Number.POSITIVE_INFINITY,\n } = options;\n if (from > to) [from, to] = [to, from];\n\n zones = JSON.parse(JSON.stringify(zones)).map((zone) =>\n zone.from > zone.to ? { from: zone.to, to: zone.from } : zone,\n );\n zones = zones.sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return a.to - b.to;\n });\n\n zones.forEach((zone) => {\n if (from > zone.from) zone.from = from;\n if (to < zone.to) zone.to = to;\n });\n\n zones = zones.filter((zone) => zone.from <= zone.to);\n if (zones.length === 0) return [];\n\n let currentZone = zones[0];\n let result = [currentZone];\n for (let i = 1; i < zones.length; i++) {\n let zone = zones[i];\n if (zone.from <= currentZone.to) {\n currentZone.to = zone.to;\n } else {\n currentZone = zone;\n result.push(currentZone);\n }\n }\n return result;\n}\n","import { normalize } from './normalize';\n\n/**\n * Convert an array of exclusions and keep only from / to\n *\n * The method will always check if from if lower than to and will swap if required.\n * @param {Array} [exclusions=[]]\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of zones (after inversion)\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of zones (after inversion)\n */\n\nexport function invert(exclusions = [], options = {}) {\n let {\n from = Number.NEGATIVE_INFINITY,\n to = Number.POSITIVE_INFINITY,\n } = options;\n if (from > to) [from, to] = [to, from];\n\n exclusions = normalize(exclusions, { from, to });\n if (exclusions.length === 0) return [{ from, to }];\n\n let zones = [];\n for (let i = 0; i < exclusions.length; i++) {\n let exclusion = exclusions[i];\n let nextExclusion = exclusions[i + 1];\n if (i === 0) {\n if (exclusion.from > from) {\n zones.push({ from, to: exclusion.from });\n }\n }\n if (i === exclusions.length - 1) {\n if (exclusion.to < to) {\n zones.push({ from: exclusion.to, to });\n }\n } else {\n zones.push({ from: exclusion.to, to: nextExclusion.from });\n }\n }\n\n return zones;\n}\n","import { normalize } from './normalize';\n\n/**\n * Add the number of points per zone to reach a specified total\n * @param {Array} [zones=[]]\n * @param {number} [numberOfPoints] Total number of points to distribute between zones\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of a zone\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of a zone\n */\n\nexport function zonesWithPoints(zones, numberOfPoints, options = {}) {\n if (zones.length === 0) return zones;\n zones = normalize(zones, options);\n\n const totalSize = zones.reduce((previous, current) => {\n return previous + (current.to - current.from);\n }, 0);\n\n let unitsPerPoint = totalSize / numberOfPoints;\n let currentTotal = 0;\n for (let i = 0; i < zones.length - 1; i++) {\n let zone = zones[i];\n zone.numberOfPoints = Math.min(\n Math.round((zone.to - zone.from) / unitsPerPoint),\n numberOfPoints - currentTotal,\n );\n currentTotal += zone.numberOfPoints;\n }\n\n zones[zones.length - 1].numberOfPoints = numberOfPoints - currentTotal;\n\n return zones;\n}\n","/**\n * Function that calculates the integral of the line between two\n * x-coordinates, given the slope and intercept of the line.\n * @param {number} x0\n * @param {number} x1\n * @param {number} slope\n * @param {number} intercept\n * @return {number} integral value.\n */\nexport default function integral(x0, x1, slope, intercept) {\n return (\n 0.5 * slope * x1 * x1 +\n intercept * x1 -\n (0.5 * slope * x0 * x0 + intercept * x0)\n );\n}\n","import integral from './integral';\n\n/**\n * function that retrieves the getEquallySpacedData with the variant \"smooth\"\n *\n * @param {Array} x\n * @param {Array} y\n * @param {number} from - Initial point\n * @param {number} to - Final point\n * @param {number} numberOfPoints\n * @return {Array} - Array of y's equally spaced with the variant \"smooth\"\n */\nexport default function equallySpacedSmooth(x, y, from, to, numberOfPoints) {\n let xLength = x.length;\n\n let step = (to - from) / (numberOfPoints - 1);\n let halfStep = step / 2;\n\n let output = new Array(numberOfPoints);\n\n let initialOriginalStep = x[1] - x[0];\n let lastOriginalStep = x[xLength - 1] - x[xLength - 2];\n\n // Init main variables\n let min = from - halfStep;\n let max = from + halfStep;\n\n let previousX = Number.MIN_VALUE;\n let previousY = 0;\n let nextX = x[0] - initialOriginalStep;\n let nextY = 0;\n\n let currentValue = 0;\n let slope = 0;\n let intercept = 0;\n let sumAtMin = 0;\n let sumAtMax = 0;\n\n let i = 0; // index of input\n let j = 0; // index of output\n\n function getSlope(x0, y0, x1, y1) {\n return (y1 - y0) / (x1 - x0);\n }\n\n let add = 0;\n main: while (true) {\n if (previousX <= min && min <= nextX) {\n add = integral(0, min - previousX, slope, previousY);\n sumAtMin = currentValue + add;\n }\n\n while (nextX - max >= 0) {\n // no overlap with original point, just consume current value\n add = integral(0, max - previousX, slope, previousY);\n sumAtMax = currentValue + add;\n\n output[j++] = (sumAtMax - sumAtMin) / step;\n\n if (j === numberOfPoints) {\n break main;\n }\n\n min = max;\n max += step;\n sumAtMin = sumAtMax;\n }\n\n currentValue += integral(previousX, nextX, slope, intercept);\n\n previousX = nextX;\n previousY = nextY;\n\n if (i < xLength) {\n nextX = x[i];\n nextY = y[i];\n i++;\n } else if (i === xLength) {\n nextX += lastOriginalStep;\n nextY = 0;\n }\n\n slope = getSlope(previousX, previousY, nextX, nextY);\n intercept = -slope * previousX + previousY;\n }\n\n return output;\n}\n","/**\n * function that retrieves the getEquallySpacedData with the variant \"slot\"\n *\n * @param {Array} x\n * @param {Array} y\n * @param {number} from - Initial point\n * @param {number} to - Final point\n * @param {number} numberOfPoints\n * @return {Array} - Array of y's equally spaced with the variant \"slot\"\n */\nexport default function equallySpacedSlot(x, y, from, to, numberOfPoints) {\n let xLength = x.length;\n\n let step = (to - from) / (numberOfPoints - 1);\n let halfStep = step / 2;\n let lastStep = x[x.length - 1] - x[x.length - 2];\n\n let start = from - halfStep;\n let output = new Array(numberOfPoints);\n\n // Init main variables\n let min = start;\n let max = start + step;\n\n let previousX = -Number.MAX_VALUE;\n let previousY = 0;\n let nextX = x[0];\n let nextY = y[0];\n let frontOutsideSpectra = 0;\n let backOutsideSpectra = true;\n\n let currentValue = 0;\n\n // for slot algorithm\n let currentPoints = 0;\n\n let i = 1; // index of input\n let j = 0; // index of output\n\n main: while (true) {\n if (previousX >= nextX) throw new Error('x must be an increasing serie');\n while (previousX - max > 0) {\n // no overlap with original point, just consume current value\n if (backOutsideSpectra) {\n currentPoints++;\n backOutsideSpectra = false;\n }\n\n output[j] = currentPoints <= 0 ? 0 : currentValue / currentPoints;\n j++;\n\n if (j === numberOfPoints) {\n break main;\n }\n\n min = max;\n max += step;\n currentValue = 0;\n currentPoints = 0;\n }\n\n if (previousX > min) {\n currentValue += previousY;\n currentPoints++;\n }\n\n if (previousX === -Number.MAX_VALUE || frontOutsideSpectra > 1) {\n currentPoints--;\n }\n\n previousX = nextX;\n previousY = nextY;\n\n if (i < xLength) {\n nextX = x[i];\n nextY = y[i];\n i++;\n } else {\n nextX += lastStep;\n nextY = 0;\n frontOutsideSpectra++;\n }\n }\n\n return output;\n}\n","import sequentialFill from 'ml-array-sequential-fill';\nimport { zonesWithPoints, invert } from 'ml-zones';\n\nimport equallySpacedSmooth from './equallySpacedSmooth';\nimport equallySpacedSlot from './equallySpacedSlot';\n\n/**\n * Function that returns a Number array of equally spaced numberOfPoints\n * containing a representation of intensities of the spectra arguments x\n * and y.\n *\n * The options parameter contains an object in the following form:\n * from: starting point\n * to: last point\n * numberOfPoints: number of points between from and to\n * variant: \"slot\" or \"smooth\" - smooth is the default option\n *\n * The slot variant consist that each point in the new array is calculated\n * averaging the existing points between the slot that belongs to the current\n * value. The smooth variant is the same but takes the integral of the range\n * of the slot and divide by the step size between two points in the new array.\n *\n * If exclusions zone are present, zones are ignored !\n * @param {object} [arrayXY={}] - object containing 2 properties x and y (both an array)\n * @param {object} [options={}]\n * @param {number} [options.from=x[0]]\n * @param {number} [options.to=x[x.length-1]]\n * @param {string} [options.variant='smooth']\n * @param {number} [options.numberOfPoints=100]\n * @param {Array} [options.exclusions=[]] array of from / to that should be skipped for the generation of the points\n * @param {Array} [options.zones=[]] array of from / to that should be kept\n * @return {object} new object with x / y array with the equally spaced data.\n */\n\nexport default function equallySpaced(arrayXY = {}, options = {}) {\n let { x, y } = arrayXY;\n let xLength = x.length;\n let reverse = false;\n if (x.length > 1 && x[0] > x[1]) {\n x = x.slice().reverse();\n y = y.slice().reverse();\n reverse = true;\n }\n\n let {\n from = x[0],\n to = x[xLength - 1],\n variant = 'smooth',\n numberOfPoints = 100,\n exclusions = [],\n zones = [],\n } = options;\n\n if (xLength !== y.length) {\n throw new RangeError(\"the x and y vector doesn't have the same size.\");\n }\n\n if (typeof from !== 'number' || isNaN(from)) {\n throw new RangeError(\"'from' option must be a number\");\n }\n\n if (typeof to !== 'number' || isNaN(to)) {\n throw new RangeError(\"'to' option must be a number\");\n }\n\n if (typeof numberOfPoints !== 'number' || isNaN(numberOfPoints)) {\n throw new RangeError(\"'numberOfPoints' option must be a number\");\n }\n\n if (numberOfPoints < 2) {\n throw new RangeError(\"'numberOfPoints' option must be greater than 1\");\n }\n\n if (zones.length === 0) {\n zones = invert(exclusions, { from, to });\n }\n\n zones = zonesWithPoints(zones, numberOfPoints, { from, to });\n\n let xResult = [];\n let yResult = [];\n for (let zone of zones) {\n let zoneResult = processZone(\n x,\n y,\n zone.from,\n zone.to,\n zone.numberOfPoints,\n variant,\n reverse,\n );\n\n xResult = xResult.concat(zoneResult.x);\n yResult = yResult.concat(zoneResult.y);\n }\n if (reverse) {\n if (from < to) {\n return { x: xResult.reverse(), y: yResult.reverse() };\n } else {\n return { x: xResult, y: yResult };\n }\n } else {\n if (from < to) {\n return { x: xResult, y: yResult };\n } else {\n return { x: xResult.reverse(), y: yResult.reverse() };\n }\n }\n}\n\nfunction processZone(x, y, from, to, numberOfPoints, variant) {\n if (numberOfPoints < 1) {\n throw new RangeError('the number of points must be at least 1');\n }\n\n let output =\n variant === 'slot'\n ? equallySpacedSlot(x, y, from, to, numberOfPoints)\n : equallySpacedSmooth(x, y, from, to, numberOfPoints);\n\n return {\n x: sequentialFill({\n from,\n to,\n size: numberOfPoints,\n }),\n y: output,\n };\n}\n","export default function getZones(from, to, exclusions = []) {\n if (from > to) {\n [from, to] = [to, from];\n }\n\n // in exclusions from and to have to be defined\n exclusions = exclusions.filter(\n (exclusion) => exclusion.from !== undefined && exclusion.to !== undefined\n );\n\n exclusions = JSON.parse(JSON.stringify(exclusions));\n // we ensure that from before to\n exclusions.forEach((exclusion) => {\n if (exclusion.from > exclusion.to) {\n [exclusion.to, exclusion.from] = [exclusion.from, exclusion.to];\n }\n });\n\n exclusions.sort((a, b) => a.from - b.from);\n\n // we will rework the exclusions in order to remove overlap and outside range (from / to)\n exclusions.forEach((exclusion) => {\n if (exclusion.from < from) exclusion.from = from;\n if (exclusion.to > to) exclusion.to = to;\n });\n for (let i = 0; i < exclusions.length - 1; i++) {\n if (exclusions[i].to > exclusions[i + 1].from) {\n exclusions[i].to = exclusions[i + 1].from;\n }\n }\n exclusions = exclusions.filter((exclusion) => exclusion.from < exclusion.to);\n\n if (!exclusions || exclusions.length === 0) {\n return [{ from, to }];\n }\n\n let zones = [];\n let currentFrom = from;\n for (let exclusion of exclusions) {\n if (currentFrom < exclusion.from) {\n zones.push({\n from: currentFrom,\n to: exclusion.from\n });\n }\n\n currentFrom = exclusion.to;\n }\n if (currentFrom < to) {\n zones.push({\n from: currentFrom,\n to: to\n });\n }\n\n return zones;\n}\n","import getZones from './getZones';\n\n/**\n * Filter an array x/y based on various criteria\n * x points are expected to be sorted\n *\n * @param {object} points\n * @param {object} [options={}]\n * @param {array} [options.from]\n * @param {array} [options.to]\n * @param {array} [options.exclusions=[]]\n * @return {{x: Array, y: Array}}\n */\n\nexport default function filterX(points, options = {}) {\n const { x, y } = points;\n const { from = x[0], to = x[x.length - 1], exclusions = [] } = options;\n\n let zones = getZones(from, to, exclusions);\n\n\n let currentZoneIndex = 0;\n let newX = [];\n let newY = [];\n let position = 0;\n while (position < x.length) {\n if (\n x[position] <= zones[currentZoneIndex].to &&\n x[position] >= zones[currentZoneIndex].from\n ) {\n newX.push(x[position]);\n newY.push(y[position]);\n } else {\n if (x[position] > zones[currentZoneIndex].to) {\n currentZoneIndex++;\n if (!zones[currentZoneIndex]) break;\n }\n }\n position++;\n }\n\n return {\n x: newX,\n y: newY\n };\n}\n","import { DecisionTreeClassifier, DecisionTreeRegression } from \"ml-cart\";\nimport {\n RandomForestClassifier,\n RandomForestRegression,\n} from \"ml-random-forest\";\n\n// Try to keep this list in the same structure as the README.\n\n// Unsupervised learning\nexport { PCA } from \"ml-pca\";\nimport * as HClust from \"ml-hclust\";\nexport { HClust };\nexport { default as KMeans } from \"ml-kmeans\";\n\n// Supervised learning\nimport * as NaiveBayes from \"ml-naivebayes\";\nexport { NaiveBayes };\nexport { default as KNN } from \"ml-knn\";\nexport { PLS, KOPLS, OPLS, OPLSNipals } from \"ml-pls\";\nimport * as CrossValidation from \"ml-cross-validation\";\nexport { CrossValidation };\nexport { default as ConfusionMatrix } from \"ml-confusion-matrix\";\nexport { DecisionTreeClassifier };\nexport { RandomForestClassifier };\n\n// Artificial neural networks\nexport { default as FNN } from \"ml-fnn\";\nexport { default as SOM } from \"ml-som\";\n\n// Regression\nexport {\n SimpleLinearRegression,\n PolynomialRegression,\n MultivariateLinearRegression,\n PowerRegression,\n ExponentialRegression,\n TheilSenRegression,\n RobustPolynomialRegression,\n} from \"ml-regression\";\nexport { DecisionTreeRegression };\nexport { RandomForestRegression };\n\n// Optimization\nexport { default as levenbergMarquardt } from \"ml-levenberg-marquardt\";\nimport * as FCNNLS from \"ml-fcnnls\";\nexport { FCNNLS };\n\n// Math\nimport * as MatrixLib from \"ml-matrix\";\nconst {\n Matrix,\n SVD,\n EVD,\n CholeskyDecomposition,\n LuDecomposition,\n QrDecomposition,\n} = MatrixLib;\nexport {\n MatrixLib,\n Matrix,\n SVD,\n EVD,\n CholeskyDecomposition,\n LuDecomposition,\n QrDecomposition,\n};\n\nexport { SparseMatrix } from \"ml-sparse-matrix\";\nexport { default as Kernel } from \"ml-kernel\";\nimport { distance, similarity } from \"ml-distance\";\nexport { distance as Distance, similarity as Similarity };\nexport { default as distanceMatrix } from \"ml-distance-matrix\";\nexport { default as XSadd } from \"ml-xsadd\";\nexport { nGMCA } from \"ml-ngmca\";\n\n// Statistics\nexport { default as Performance } from \"ml-performance\";\n\n// Data preprocessing\nexport { default as savitzkyGolay } from \"ml-savitzky-golay\";\n\n// Utility\nexport { default as BitArray } from \"ml-bit-array\";\nexport { default as HashTable } from \"ml-hash-table\";\nexport { default as padArray } from \"ml-pad-array\";\nexport { default as binarySearch } from \"binary-search\";\nimport * as numSort from \"num-sort\";\nexport { numSort };\nexport { default as Random } from \"ml-random\";\nimport * as GSD from 'ml-gsd';\nexport { GSD };\n\nimport min from \"ml-array-min\";\nimport max from \"ml-array-max\";\nimport median from \"ml-array-median\";\nimport mean from \"ml-array-mean\";\nimport mode from \"ml-array-mode\";\nimport normed from \"ml-array-normed\";\nimport rescale from \"ml-array-rescale\";\nimport sequentialFill from \"ml-array-sequential-fill\";\nimport sum from \"ml-array-sum\";\nimport standardDeviation from \"ml-array-standard-deviation\";\nimport variance from \"ml-array-variance\";\nexport const Array = {\n min,\n max,\n median,\n mean,\n mode,\n normed,\n rescale,\n sequentialFill,\n standardDeviation,\n sum,\n variance,\n};\n\nimport centroidsMerge from \"ml-array-xy-centroids-merge\";\nimport closestX from \"ml-arrayxy-closestx\";\nimport covariance from \"ml-array-xy-covariance\";\nimport maxMerge from \"ml-array-xy-max-merge\";\nimport maxY from \"ml-array-xy-max-y\";\nimport sortX from \"ml-array-xy-sort-x\";\nimport uniqueX from \"ml-arrayxy-uniquex\";\nimport weightedMerge from \"ml-array-xy-weighted-merge\";\nimport equallySpaced from \"ml-array-xy-equally-spaced\";\nimport filterX from \"ml-array-xy-filter-x\";\nexport const ArrayXY = {\n centroidsMerge,\n closestX,\n covariance,\n maxMerge,\n maxY,\n sortX,\n uniqueX,\n weightedMerge,\n equallySpaced,\n filterX,\n};\n"],"names":["toString","Object","prototype","isAnyArray","object","call","endsWith","max","input","options","arguments","length","undefined","isArray","TypeError","_options$fromIndex","fromIndex","_options$toIndex","toIndex","Number","isInteger","Error","maxValue","i","min","minValue","rescale","output","Array","currentMin","currentMax","RangeError","_options$min","autoMinMax","_options$max","factor","indent","repeat","indentData","inspectMatrix","inspectMatrixWithOptions","matrix","maxRows","maxColumns","maxNumSize","constructor","name","inspectData","rows","columns","maxI","Math","maxJ","result","line","j","push","formatNumber","get","join","num","numStr","String","padEnd","precise","toPrecision","exponential","toExponential","eIndex","indexOf","e","slice","installMathOperations","AbstractMatrix","Matrix","add","value","addS","addM","set","checkMatrix","newMatrix","sub","subS","subM","subtract","subtractS","subtractM","mul","mulS","mulM","multiply","multiplyS","multiplyM","div","divS","divM","divide","divideS","divideM","mod","modS","modM","modulus","modulusS","modulusM","and","andS","andM","or","orS","orM","xor","xorS","xorM","leftShift","leftShiftS","leftShiftM","signPropagatingRightShift","signPropagatingRightShiftS","signPropagatingRightShiftM","rightShift","rightShiftS","rightShiftM","zeroFillRightShift","zeroFillRightShiftS","zeroFillRightShiftM","not","abs","acos","acosh","asin","asinh","atan","atanh","cbrt","ceil","clz32","cos","cosh","exp","expm1","floor","fround","log","log1p","log10","log2","round","sign","sin","sinh","sqrt","tan","tanh","trunc","pow","arg0","powS","powM","checkRowIndex","index","outer","checkColumnIndex","checkRowVector","vector","to1DArray","checkColumnVector","checkIndices","rowIndices","columnIndices","row","checkRowIndices","column","checkColumnIndices","rowOut","some","r","from","columnOut","c","checkRange","startRow","endRow","startColumn","endColumn","checkNumber","newArray","array","sumByRow","sum","sumByColumn","sumAll","v","productByRow","productByColumn","productAll","varianceByRow","unbiased","mean","cols","variance","sum1","sum2","x","varianceByColumn","varianceAll","size","centerByRow","centerByColumn","centerAll","getScaleByRow","scale","scaleByRow","getScaleByColumn","scaleByColumn","getScaleAll","divider","scaleAll","from1DArray","newRows","newColumns","newData","rowVector","columnVector","zeros","ones","fill","rand","random","randInt","interval","eye","diag","data","l","matrix1","matrix2","isMatrix","klass","apply","callback","to2DArray","copy","toJSON","isRowVector","isColumnVector","isVector","isSquare","isSymmetric","isEchelonForm","previousColumn","checked","isReducedEchelonForm","k","echelonForm","clone","h","iMax","swapRows","tmp","reducedEchelonForm","m","n","maxRow","p","pivot","setSubMatrix","neg","getRow","getRowVector","setRow","row1","row2","temp","getColumn","getColumnVector","setColumn","swapColumns","column1","column2","addRowVector","subRowVector","mulRowVector","divRowVector","addColumnVector","subColumnVector","mulColumnVector","divColumnVector","mulRow","mulColumn","maxIndex","idx","minIndex","maxRowIndex","minRow","minRowIndex","maxColumn","maxColumnIndex","minColumn","minColumnIndex","norm","type","cumulativeSum","dot","vector2","vector1","mmul","other","Bcolj","Float64Array","s","strassen2x2","a11","b11","a12","b12","a21","b21","a22","b22","m1","m2","m3","m4","m5","m6","m7","c00","c01","c10","c11","strassen3x3","a00","a01","a02","a10","a20","b00","b01","b02","b10","b20","m8","m9","m10","m11","m12","m13","m14","m15","m16","m17","m18","m19","m20","m21","m22","m23","c02","c12","c20","c21","c22","mmulStrassen","y","r1","c1","r2","c2","console","warn","embed","mat","resultat","blockMult","a","b","halfRows","parseInt","halfCols","subMatrix","scaleRows","isFinite","scaleColumns","flipRows","middle","first","last","flipColumns","kroneckerProduct","q","transpose","sortRows","compareFunction","compareNumbers","sort","sortColumns","subMatrixRow","indices","subMatrixColumn","selection","rowIndex","columnIndex","trace","by","product","standardDeviation","center","Symbol","for","randomInt","diagonal","identity","negate","tensorProduct","nRows","nColumns","arrayData","removeRow","splice","addRow","removeColumn","newRow","addColumn","BaseView","MatrixColumnView","MatrixColumnSelectionView","MatrixFlipColumnView","MatrixFlipRowView","MatrixRowView","MatrixRowSelectionView","MatrixSelectionView","MatrixSubView","MatrixTransposeView","WrapperMatrix1D","_calculateIndex","WrapperMatrix2D","wrap","LuDecomposition","lu","pivotVector","pivotSign","t","LUcolj","kmax","LU","isSingular","col","solve","count","X","determinant","lowerTriangularMatrix","upperTriangularMatrix","pivotPermutationVector","hypotenuse","QrDecomposition","qr","rdiag","nrm","QR","Rdiag","isFullRank","orthogonalMatrix","SingularValueDecomposition","computeLeftSingularVectors","computeRightSingularVectors","autoTranspose","wantu","Boolean","wantv","swapped","aux","nu","ni","U","V","work","si","nct","nrt","mrc","pp","eps","EPSILON","kase","alpha","MIN_VALUE","isNaN","ks","f","cs","sn","sp","spm1","epm1","sk","ek","shift","g","Y","threshold","scols","Ls","rightSingularVectors","VL","vrows","urows","VLU","solveForDiagonal","inverse","vcols","ucols","condition","norm2","rank","tol","ii","leftSingularVectors","diagonalMatrix","useSVD","leftHandSide","rightHandSide","d","subMatrix0","subMatrix1","subMatrix2","xrange","exception","range","dependenciesOneRow","error","thresholdValue","thresholdError","returnArray","linearDependencies","results","Abis","svd","pseudoInverse","svdSolution","SVD","covariance","xMatrix","yMatrix","yIsSame","cov","correlation","sdx","sdy","corr","EigenvalueDecomposition","assumeSymmetric","tred2","tql2","H","ort","orthes","hqr2","realEigenvalues","imaginaryEigenvalues","eigenvectorMatrix","hh","dl1","c3","el1","s2","tst1","low","high","nn","exshift","z","iter","w","ra","sa","vr","vi","notlast","cdivres","cdiv","xr","xi","yr","yi","CholeskyDecomposition","dimension","positiveDefinite","L","isPositiveDefinite","B","nipals","scaleScores","maxIterations","terminationCriteria","u","diff","tOld","counter","xResidual","residual","yResidual","betas","sumValue","toDiscreteDistribution","numberOfClasses","counts","giniImpurity","probabilities","getNumberOfClasses","filter","val","arr","map","reduce","giniGain","splitted","splitsImpurity","splits","currentSplit","squaredError","meanArray","currentElement","regressionError","matrixSplitter","lesserX","greaterX","lesserY","greaterY","zip","ret","gainFunctions","gini","Utils","regression","splitFunctions","TreeNode","kind","gainFunction","splitFunction","minNumSamples","maxDepth","bestSplit","XTranspose","bestGain","Infinity","check","currentFeature","splitValues","featureSplit","currentSplitVal","split","gain","maxGain","splitValue","lesser","greater","calculatePrediction","distribution","train","currentDepth","parentGain","splitColumn","splittedMatrix","left","right","classify","setNodeParameters","node","defaultOptions","DecisionTreeClassifier","model","root","Tree","assign","trainingSet","trainingLabels","predict","toPredict","predictions","load","DecisionTreeRegression","trainingValues","checkFloat","examplesBaggingWithReplacement","trainingValue","seed","engine","Random","autoSeed","Xr","featureBagging","replacement","toRet","usedIndex","Set","has","RandomForestBase","maxFeatures","nEstimators","treeOptions","isClassifier","indexes","useSampleBagging","Estimator","DTClassifier","DTRegression","estimators","est","res","values","predictionValues","RandomForestClassifier","baseModel","mode","pop","_ref","module","exports","window","median","quickSelectMedian","selectionMethods","arrayMean","arrayMedian","selectionMethod","RandomForestRegression","PCA","dataset","means","stdevs","S","R","excludedFeatures","isCovarianceMatrix","method","nCompNIPALS","ignoreZeroVariance","_computeFromCovarianceMatrix","_adjust","covarianceMatrix","_computeWithNIPALS","singularValues","eigenvalues","singularValue","nComponents","invert","getExplainedVariance","getCumulativeVariance","explained","getEigenvectors","getEigenvalues","getStandardDeviations","getLoadings","evd","EVD","reverse","dc","NIPALS","squaredEuclidean","euclidean","distanceMatrix","distanceFn","getMatrix","Heap","defaultCmp","heapify","heappop","heappush","heappushpop","heapreplace","insort","nlargest","nsmallest","updateItem","_siftdown","_siftup","lo","hi","cmp","mid","concat","item","lastelt","returnitem","_i","_len","_ref1","_results","_results1","_j","pos","elem","los","startpos","newitem","parent","parentpos","childpos","endpos","rightpos","replace","pushpop","nodes","peek","contains","clear","empty","heap","toArray","insert","top","front","factory","this","require$$0","Cluster","children","height","isLeaf","cut","list","ans","group","groups","forEach","child","traverse","cb","visit","cluster","singleLink","dKI","dKJ","completeLink","averageLink","dIJ","nj","ai","aj","weightedAverageLink","centroidLink","medianLink","wardLink","nk","wardLink2","agnes","distanceFunction","isDistanceMatrix","updateFunc","getDistanceMatrix","numLeaves","toLowerCase","clusters","distance","getSmallestDistance","cluster1","cluster2","newCluster","newClusters","newDistanceMatrix","previous","newIndex","getPreviousIndex","prevI","prevICluster","smallest","smallestI","smallestJ","prev1","prev2","nearestVector","listVectors","similarityFunction","vectorIndex","maxSim","sim","minDist","MAX_VALUE","dist","calculateDistanceMatrix","updateClusterID","centers","clusterID","updateCenters","prevCenters","K","nDim","centersLen","dim","id","hasConverged","oldCenters","tolerance","LOOP","FLOAT_MUL","sh1","sh2","sh3","multiply_uint32","nlo","nhi","XSadd","Date","now","state","Uint32Array","init","getFloat","bind","getUint32","nextState","periodCertification","PROB_TOLERANCE","randomChoice","valuesArr","cumSum","getArray","randomIndex","seedOrRandom","xsadd","XSAdd","randomGenerator","choice","randomSample","mostDistant","maxDist","minDistCent","kmeanspp","nSamples","localTrials","firstCenterIdx","closestDistSquared","cumSumClosestDistSquared","candidateIdx","candidates","distanceToCandidates","euclideanDistances","bestCandidate","bestPot","bestDistSquared","newDistSquared","newPot","A","distanceSymbol","KMeansResult","centroids","converged","iterations","nearest","centroid","computeInformation","enrichedCentroids","withIterations","initialization","step","newCenters","kmeansGenerator","stepNumber","stepResult","kmeans","separateClasses","features","classes","totalPerClasses","separatedClasses","currentIndex","GaussianNB","reload","calculateProbabilities","C1","PI","std","logPriorProbability","currentStd","getCurrentClass","modelName","currentCase","maxProbability","predictedClass","currentProbability","calculateLogProbability","C2","MultinomialNB","conditionalProbability","priorProbability","separateClass","classValues","total","divisor","matrixLog","Node","obj","KDTree","points","metric","dimensions","restoreParent","buildTree","toJSONImpl","point","maxNodes","maxDistance","bestNodes","BinaryHeap","nearestSearch","ownDistance","linearPoint","bestChild","linearDistance","otherChild","saveNode","content","src","dest","depth","scoreFunction","element","bubbleUp","end","sinkDown","parentN","elemScore","child2N","child1N","swap","child1","child1Score","child2","child2Score","KNN","labels","kdTree","isEuclidean","euclideanDistance","getSinglePrediction","knn","nearestPoints","pointsPerClass","maxPoints","lastElement","currentClass","currentPoints","pow2array","initializeMatrices","PLS","meanX","stdDevX","meanY","stdDevY","PBQ","R2X","scaleMethod","latentVectors","rx","cx","ry","cy","ssqXcal","sumOfSquaresY","T","P","Q","W","transposeX","transposeY","tIndex","maxSumColIndex","uIndex","t1","den","pnorm","ssqYcal","E","F","KOPLS","YLoadingMat","SigmaPow","YScoreMat","predScoreMat","YOrthLoadingVec","YOrthEigen","YOrthScoreMat","toNorm","TURegressionCoeff","kernelX","kernel","orthogonalComp","predictiveComp","predictiveComponents","orthogonalComponents","compute","Identity","Sigma","YOrthScoreNorm","TpiPrime","CoTemp","SoTemp","toiPrime","ITo","lastScoreMat","lastTpPrime","KTestTrain","YOrthScoreVector","scoreMatPrime","p1","p2","p3","prediction","predYOrthVectors","ConfusionMatrix","fromLabels","actual","predicted","distinctLabels","actualIdx","predictedIdx","getLabels","getTotalCount","getTrueCount","getFalseCount","getTruePositiveCount","label","getIndex","getTrueNegativeCount","getFalsePositiveCount","getFalseNegativeCount","getPositiveCount","getNegativeCount","getTruePositiveRate","getTrueNegativeRate","getPositivePredictiveValue","TP","getNegativePredictiveValue","TN","getFalseNegativeRate","getFalsePositiveRate","getFalseDiscoveryRate","FP","getFalseOmissionRate","FN","getF1Score","getMatthewsCorrelationCoefficient","getInformedness","getMarkedness","getConfusionTable","getAccuracy","correct","incorrect","getCount","actualIndex","predictedIndex","accuracy","global","createCommonjsModule","fn","runtime","Op","hasOwn","hasOwnProperty","$Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","regeneratorRuntime","innerFn","outerFn","self","tryLocsList","protoGenerator","Generator","generator","create","context","Context","_invoke","makeInvokeMethod","tryCatch","arg","err","GenStateSuspendedStart","GenStateSuspendedYield","GenStateExecuting","GenStateCompleted","ContinueSentinel","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","getProto","getPrototypeOf","NativeIteratorPrototype","Gp","displayName","defineIteratorMethods","isGeneratorFunction","genFun","ctor","mark","setPrototypeOf","__proto__","awrap","__await","AsyncIterator","invoke","resolve","reject","record","Promise","then","unwrapped","previousPromise","enqueue","callInvokeWithMethodAndArg","async","next","done","doneResult","delegate","delegateResult","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","return","info","resultName","nextLoc","pushTryEntry","locs","entry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","resetTryEntry","completion","reset","keys","key","iterable","iteratorMethod","skipTempReset","prev","charAt","stop","rootEntry","rootRecord","rval","handle","loc","caught","hasCatch","hasFinally","finallyEntry","complete","finish","thrown","delegateYield","Function","hadRuntime","getOwnPropertyNames","oldRuntime","runtimeModule","regenerator","_callee","M","N","twiddle","_callee$","_context","getFolds","allIdx","current","folds","randi","foldsIndex","testIndex","trainIndex","el","idx2","sampleAClass","classVector","fraction","classVectorSorted","JSON","parse","stringify","indexOfSelected","ind","mask","includes","leaveOneOut","Classifier","classifierOptions","leavePOut","distinct","getDistinct","confusionMatrix","initMatrix","gen","combinations","testIdx","trainIdx","validateWithCallback","validate","kFold","testFeatures","trainFeatures","testLabels","trainLabels","getTrainTest","classifier","predictedLabels","updateConfusionMatrix","OPLSNipals","numberOSC","uNew","wOrtho","tOrtho","pOrtho","filteredX","weightsXOrtho","loadingsXOrtho","scoresXOrtho","weightsXPred","loadingsXpred","scoresXpred","loadingsY","tss","OPLS","opls","meansY","stdevsY","tCV","tOrthCV","yHatCV","nComp","cvFolds","Q2","oplsCV","modelNC","nc","yHatk","tPredk","tOrthk","oplsk","fold","trainTest","_getTrainTest","testXk","Xk","Yk","dataCenter","dataSD","plsCV","Eh","scores","tPred","yHat","tssy","press","Q2y","_predictAll","xRes","XOrth","FeaturesCS","labelsCS","Xres","plsCall","R2x","R2y","plsC","pPred","wPred","betasPred","Qpc","tOrth","pOrth","wOrth","totalPred","Yres","getLogs","getScores","scoresX","scoresY","trueLabels","tssx","oplsC","rss","xEx","rssx","logistic","expELU","param","softExponential","softExponentialPrime","ACTIVATION_FUNCTIONS","activation","derivate","arctan","softsign","relu","softplus","bent","sinusoid","sinc","gaussian","Layer","inputSize","outputSize","regularization","epsilon","activationParam","selectedFunction","params","actFunction","derFunction","activationFunction","mlMatrix","forward","backpropagation","delta","dW","db","aCopy","update","OutputLayer","FeedForwardNeuralNetworks","hiddenLayers","learningRate","dicts","layers","buildNetwork","dictOutputs","inputs","propagate","outputs","NodeSquare","weights","som","neighbors","adjustWeights","target","influence","getDistance","otherNode","getDistanceTorus","distX","distY","gridDim","getNeighbors","xy","torus","getPos","bestNeighbor","direction","dist1","dist2","simA","simB","getPosition","NodeHexagonal","hX","getDistanceHexagonal","distZ","fields","randomizer","squareEuclidean","gridType","SOM","numWeights","converters","getConverters","extractor","creator","nodeType","hx","distanceMethod","getMaxDistance","times","findBMU","adjust","iterationCount","startLearningRate","mapRadius","algorithmMethod","_initNodes","loadModel","eval","export","exportModel","includeDistance","initNodes","setTraining","convertedSet","numIterations","timeConstant","trainOne","neighbourhoodRadius","trainingSetFactor","getRandomValue","bmu","_findBestMatchingUnit","now2","radiusLimit","xMin","xMax","yMin","yMax","theX","theY","getConvertedNodes","findBestMatchingUnit","candidate","lowest","computePosition","_predict","getQuantizationError","fit","getFit","normalizers","denormalizers","getNormalizer","getDenormalizer","minMax","normalizer","denormalizer","zero","one","maybeToPrecision","digits","checkArraySize","BaseRegression","new","toLaTeX","score","y2","xSum","ySum","chi2","rmsd","xSquared","ySquared","xY","PolynomialRegression","degree","powers","coefficients","checkArrayLength","regress","precision","_toFormula","isLaTeX","sup","closeSup","str","json","pr","FT","SimpleLinearRegression","slope","intercept","computeX","xFactor","absIntercept","operator","slr","numerator","ExponentialRegression","er","yl","linear","PowerRegression","newInputs","latex","xl","MultivariateLinearRegression","statistics","xt","xx","invxx","beta","fittedValues","residuals","ri","stdError","stdErrorMatrix","stdErrors","tStats","summary","regressionStatistics","standardError","observations","variables","tStat","sigma","GaussianKernel","constant","PolynomialKernel","SigmoidKernel","ANOVAKernel","len","CauchyKernel","ExponentialKernel","HistogramIntersectionKernel","LaplacianKernel","MultiquadraticKernel","RationalQuadraticKernel","kernelType","rbf","polynomial","poly","anova","cauchy","histogram","HistogramKernel","laplacian","multiquadratic","rational","RationalKernel","sigmoid","mlp","Kernel","KernelConstructor","kernelFunction","landmarks","kernelMatrix","TheilSenRegression","theilSen","slopes","medianSlope","cuts","RobustPolynomialRegression","robustPolynomial","_","tuples","getRandomTuples","tuple","calcCoefficients","residualsMedian","half","errorCalculation","parameters","parameterizedFunction","func","gradientFunction","evaluatedData","gradientDifference","paramFunction","auxParams","funcParam","matrixFunction","damping","gradientFunc","matrixFunc","inverseMatrix","levenbergMarquardt","errorTolerance","minValues","maxValues","initialValues","parLen","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","iteration","parameterValues","parameterError","sortCollectionSet","collection","objectCollection","BigInt","sorted","cssls","XtX","XtY","Pset","choXtX","luXtX","sortedPset","sortedEset","cols2Solve","vars","initialisation","Fset","D","setDifference","C","optimality","maxIter","Jset","fullSet","notPset","fcnnls","infeasIndex","Hset","hRowColIdx","negRowColIdx","alphaMin","minIdx","idx2zero","findIndex","newParam","fcnnlsVector","haystack","needle","comparator","assertNumber","number","largestPrime","primeNumbers","ascending","nextPrime","binarySearch","FREE","FULL","REMOVED","defaultInitialCapacity","defaultMinLoadFactor","defaultMaxLoadFactor","HashTable","table","minLoadFactor","maxLoadFactor","freeEntries","lowWaterMark","highWaterMark","initialCapacity","capacity","chooseHighWaterMark","indexOfKey","indexOfInsertion","newCapacity","chooseGrowCapacity","rehash","remove","noRehash","maybeShrinkCapacity","delete","chooseShrinkCapacity","containsKey","hash","decrement","containsValue","indexOfValue","ensureCapacity","minCapacity","oldCapacity","oldTable","oldValues","oldState","newTable","newValues","newState","chooseLowWaterMark","forEachKey","forEachValue","forEachPair","minLoad","maxLoad","SparseMatrix","_init","elements","symmetric","forEachNonZero","bandWidth","isBanded","width","cardinality","v1","v2","getNonZeros","setThreshold","newThreshold","trans","inplaceOperator","inplaceOperatorScalar","inplaceOperatorMatrix","staticOperator","inplaceMethod","staticMethod","operators","fillTemplateFunction","op","methods","mathMethod","template","RegExp","additiveSymmetric","avg","bhattacharyya","canberra","chebyshev","clark","czekanowskiSimilarity","up","down","czekanowskiDistance","dice","q1","q2","divergence","fidelity","gower","harmonicMean","hellinger","innerProduct","intersection","jaccard","jeffreys","jensenDifference","jensenShannon","kdivergence","kulczynski","kullbackLeibler","kumarHassebrook","kumarJohnson","lorentzian","manhattan","matusita","minkowski","motyka","neyman","pearson","probabilisticSymmetric","ruzicka","soergel","sorensen","squared","squaredChord","taneja","tanimoto","bitvector","inter","union","tanimotoS","topsoe","waveHedges","createTree","spectrum","minWindow","to","mainCreateTree","start","getSimilarity","gamma","treeSimilarity","getFunction","cosine","diceD","intersectionD","jaccardD","kulczynskiD","motykaD","avgA","avgB","newA","newB","squaredChordD","zeroInsteadOfNegative","checkMatrixS","originalMatrix","fastExtractNMF","res2","sqrtMaxValue","subtracting","normBy","norms","normProj","normLimits","updateMatrixA","Ainit","maxFBIteration","toleranceFB","normConstrained","lambda","St","YSt","prevA","gradient","proximal","tNext","getMax","updateMatrixS","Sinit","At","AtY","prevS","initialize","randGenerator","maxInitFBIteration","toleranceFBInit","sumC","sumR","positiveSumRowIndexS","positiveSumRowS","candidateA","colCandidate","normalize","normOnA","DS","DA","onS","onA","sColumns","aRows","valueForS","valueForA","getMedians","medians","dimMADstd","updateLambda","refinementBeginning","tauMAD","sigmaResidue","lambdaInf","addStd","alY","nextLambda","nGMCA","maximumIteration","phaseRatio","useTranspose","pred","cutoffs","tn","tp","fp","nNeg","nPos","nPosPred","nNegPred","Performance","isDistance","predP","all","targ","currentPred","nTp","nFp","getMeasure","measure","measures","getAURC","auc","getAUDC","getDistribution","cutLength","cutLow","cutHigh","xLabels","interValues","intraValues","interCumPercent","intraCumPercent","nTP","currentTP","nFP","currentFP","thisTP","thisFP","names","acc","fpr","tpr","fnr","tnr","ppv","npv","pcfall","pcmiss","lift","rpp","rnp","arrayCase","cond","matrixCase","padArray","factorial","windowSize","derivative","pad","padValue","savitzkyGolay","J","inic","Jtranspose","Jinv","det","eightBits","arr1","arr2","getBit","setBit","toBinaryString","substr","parseBinaryString","toHexString","parseHexString","toDebug","binary","SavitzkyGolay","np","fullWeights","hs","constantH","wg1","wg2","d1","d2","getHs","wg","GramPoly","Grampoly","GenFact","gf","Weight","gsd","yIn","noiseLevel","sgOptions","smoothY","heightFactor","broadRatio","maxCriteria","minMaxRatio","derivativeThreshold","realTopDetection","equalSpaced","isEqualSpaced","getNoiseLevel","yCorrection","yData","dY","ddY","SG","xData","dX","maxDdy","maxY","lastMax","lastMin","minddY","intervalL","intervalR","broadMask","minddYLen","intervalLLen","intervalRLen","broadMaskLen","signals","signalsLen","lastK","possible","frequency","distanceJ","minDistance","gettingCloser","soft","yLeft","yRight","determineRealTop","base","maxDx","minDx","stddev","averageDeviations","peakList","currentPoint","sumOfGaussians","nL","optimizeGaussianSum","opts","pInit","pMin","pMax","dt","lmOptions","pFit","LM","singleGaussian","factor2","optimizeSingleGaussian","peak","sumOfLorentzians","optimizeLorentzianSum","singleLorentzian","optimizeSingleLorentzian","optimizePeaks","functionName","factorWidth","optimizationOptions","lastIndex","groupPeaks","sampling","peaks","sampleFunction","limits","optPeaks","fitResult","nbPoints","sampleX","sampleY","upperLimit","lowerLimit","joinBroadPeaks","broadLines","fitted","broadenPeaks","overlap","nextPeak","maxCount","_options$algorithm","algorithm","_options$sumValue","_options$maxValue","absoluteSumValue","absoluteSum","currentMaxValue","sumFactor","_i2","_typeof","sequentialFill","_options","_options$from","_options$to","_options$size","_options$unbiased","_options$mean","sqrError","mergeByCentroids","originalPoints","mergedPoints","originalIndex","mergedIndex","closestX","descending","maxMerge","groupWidth","merged","maxAbscissa","calculateIndex","sortX","sortFunc","grouped","response","uniqueX","weightedMerge","weightedAbscissa","zones","NEGATIVE_INFINITY","POSITIVE_INFINITY","zone","currentZone","exclusions","exclusion","nextExclusion","zonesWithPoints","numberOfPoints","totalSize","unitsPerPoint","currentTotal","integral","x0","x1","equallySpacedSmooth","xLength","halfStep","initialOriginalStep","lastOriginalStep","previousX","previousY","nextX","nextY","currentValue","sumAtMin","sumAtMax","getSlope","y0","y1","main","equallySpacedSlot","lastStep","frontOutsideSpectra","backOutsideSpectra","equallySpaced","arrayXY","variant","xResult","yResult","zoneResult","processZone","getZones","currentFrom","filterX","currentZoneIndex","newX","newY","position","MatrixLib","normed","ArrayXY","centroidsMerge"],"mappings":";;;;;;;;;;;;EAAA,MAAMA,QAAQ,GAAGC,MAAM,CAACC,SAAP,CAAiBF,QAAlC;EAEe,SAASG,UAAT,CAAoBC,MAApB,EAA4B;EACzC,SAAOJ,QAAQ,CAACK,IAAT,CAAcD,MAAd,EAAsBE,QAA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K,yBAAAA,uBAJI;EAKJpJ,mBAAAA,iBALI;EAMJkB,mBAAAA;EANI,IAOFotD;QA+CSjoE,OAAK,GAAG;EACnBJ,OAAAA,KADmB;EAEnBjB,OAAAA,KAFmB;EAGnB2sB,EAAAA,MAHmB;EAInB3gB,EAAAA,IAJmB;EAKnBqgB,QAAAA,MALmB;EAMnBk9C,UAAAA,MANmB;EAOnBpoE,EAAAA,OAPmB;EAQnBsjE,EAAAA,cARmB;EASnBzrD,EAAAA,iBATmB;EAUnBzN,EAAAA,GAVmB;EAWnBW,EAAAA;EAXmB;QAwBRs9D,OAAO,GAAG;EACrBC,kBAAAA,gBADqB;EAErBnE,EAAAA,QAFqB;EAGrB9jD,cAAAA,YAHqB;EAIrBgkD,EAAAA,QAJqB;EAKrBlG,EAAAA,IALqB;EAMrBuG,EAAAA,KANqB;EAOrBI,EAAAA,OAPqB;EAQrBC,EAAAA,aARqB;EASrBsC,EAAAA,aATqB;EAUrBS,EAAAA;EAVqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/ml.min.js b/dist/ml.min.js index 58ae0db..0a9732a 100644 --- a/dist/ml.min.js +++ b/dist/ml.min.js @@ -1,4 +1,4 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ML={})}(this,(function(exports){"use strict";const toString=Object.prototype.toString;function isAnyArray(t){return toString.call(t).endsWith("Array]")}function max(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,i=e.toIndex,o=void 0===i?t.length:i;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=n||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;as&&(s=t[a]);return s}function min(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,i=e.toIndex,o=void 0===i?t.length:i;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=n||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!isAnyArray(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=min(t),i=max(t);if(n===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=r.min,s=void 0===o?r.autoMinMax?n:0:o,a=r.max,l=void 0===a?r.autoMinMax?i:1:a;if(s>=l)throw new RangeError("min option must be smaller than max option");for(var h=(l-s)/(i-n),u=0;u>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;tn)throw new RangeError("Row index out of range")}function checkColumnIndex(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function checkRowVector(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function checkColumnVector(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function checkIndices(t,e,r){return{row:checkRowIndices(t,e),column:checkColumnIndices(t,r)}}function checkRowIndices(t,e){if("object"!=typeof e)throw new TypeError("unexpected type for row indices");if(e.some((e=>e<0||e>=t.rows)))throw new RangeError("row indices are out of range");return Array.isArray(e)||(e=Array.from(e)),e}function checkColumnIndices(t,e){if("object"!=typeof e)throw new TypeError("unexpected type for column indices");if(e.some((e=>e<0||e>=t.columns)))throw new RangeError("column indices are out of range");return Array.isArray(e)||(e=Array.from(e)),e}function checkRange(t,e,r,n,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(checkNumber("startRow",e),checkNumber("endRow",r),checkNumber("startColumn",n),checkNumber("endColumn",i),e>r||n>i||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function newArray(t,e=0){let r=[];for(let n=0;n=i)throw new RangeError("min must be smaller than max");let s=i-n,a=new Matrix(t,e);for(let r=0;rr?(i=!0,r=e):(n=!1,i=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,i=!1;for(;tr?(i=!0,r=e):(n=!1,i=!0);for(let r=e+1;rt.get(n,r)&&(n=i);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let i=t.get(e,r);for(let n=r;n=0;)if(0===t.maxRow(n))n--;else{let i=0,o=!1;for(;it&&(t=this.get(e,r));return t}maxIndex(){let t=this.get(0,0),e=[0,0];for(let r=0;rt&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(){let t=this.get(0,0);for(let e=0;ee&&(e=this.get(t,r));return e}maxRowIndex(t){checkRowIndex(this,t);let e=this.get(t,0),r=[t,0];for(let n=1;ne&&(e=this.get(t,n),r[1]=n);return r}minRow(t){checkRowIndex(this,t);let e=this.get(t,0);for(let r=1;re&&(e=this.get(r,t));return e}maxColumnIndex(t){checkColumnIndex(this,t);let e=this.get(0,t),r=[0,t];for(let n=1;ne&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){checkColumnIndex(this,t);let e=this.get(0,t);for(let r=1;r=r)throw new RangeError("min must be smaller than max");let n=new Matrix(this.rows,this.columns);for(let t=0;t=r)throw new RangeError("min must be smaller than max");let n=new Matrix(this.rows,this.columns);for(let t=0;tr||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new Matrix(t.length,r-e+1);for(let i=0;i=this.rows)throw new RangeError("Row index out of range: "+t[i]);n.set(i,o-e,this.get(t[i],o))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new Matrix(r-e+1,t.length);for(let i=0;i=this.columns)throw new RangeError("Column index out of range: "+t[i]);n.set(o-e,i,this.get(o,t[i]))}return n}setSubMatrix(t,e,r){checkRange(this,e,e+(t=Matrix.checkMatrix(t)).rows-1,r,r+t.columns-1);for(let n=0;n0){if(this.data=[],!(Number.isInteger(e)&&e>0))throw new TypeError("nColumns must be a positive integer");for(let r=0;rMath.abs(l[i])&&(i=e);if(i!==r){for(n=0;n=0;i--){for(n=0;ne?n.set(i,e,t.get(i,e)):i===e?n.set(i,e,1):n.set(i,e,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new Matrix(e,r);for(let i=0;iMath.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class QrDecomposition{constructor(t){let e,r,n,i,o=(t=WrapperMatrix2D.checkMatrix(t)).clone(),s=t.rows,a=t.columns,l=new Float64Array(a);for(n=0;n=0;o--){for(i=0;i=0;r--){for(t=0;t=0;t--)if(0!==m[t]){for(let e=t+1;e=0;t--){if(t0;){let t,e;for(t=b-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+A*Math.abs(m[t]+Math.abs(m[t+1]));if(Math.abs(d[t])<=e||Number.isNaN(d[t])){d[t]=0;break}}if(t===b-2)e=4;else{let r;for(r=b-1;r>=t&&r!==t;r--){let e=(r!==b?Math.abs(d[r]):0)+(r!==t+1?Math.abs(d[r-1]):0);if(Math.abs(m[r])<=A*e){m[r]=0;break}}r===t?e=3:r===b-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=d[b-2];d[b-2]=0;for(let r=b-2;r>=t;r--){let i=hypotenuse(m[r],e),o=m[r]/i,s=e/i;if(m[r]=i,r!==t&&(e=-s*d[r-1],d[r-1]=o*d[r-1]),h)for(let t=0;t=m[t+1]);){let e=m[t];if(m[t]=m[t+1],m[t+1]=e,h&&te&&i.set(o,r,t.get(o,r)/this.s[r]);let o=this.U,s=o.rows,a=o.columns,l=new Matrix(r,s);for(let t=0;tt&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return Matrix.diag(this.s)}}function inverse(t,e=!1){return t=WrapperMatrix2D.checkMatrix(t),e?new SingularValueDecomposition(t).inverse():solve(t,Matrix.eye(t.rows))}function solve(t,e,r=!1){return t=WrapperMatrix2D.checkMatrix(t),e=WrapperMatrix2D.checkMatrix(e),r?new SingularValueDecomposition(t).solve(e):t.isSquare()?new LuDecomposition(t).solve(e):new QrDecomposition(t).solve(e)}function determinant(t){if((t=Matrix.checkMatrix(t)).isSquare()){let e,r,n,i;if(2===t.columns)return e=t.get(0,0),r=t.get(0,1),n=t.get(1,0),i=t.get(1,1),e*i-r*n;if(3===t.columns){let i,o,s;return i=new MatrixSelectionView(t,[1,2],[1,2]),o=new MatrixSelectionView(t,[1,2],[0,2]),s=new MatrixSelectionView(t,[1,2],[0,1]),e=t.get(0,0),r=t.get(0,1),n=t.get(0,2),e*determinant(i)-r*determinant(o)+n*determinant(s)}return new LuDecomposition(t).determinant}throw Error("determinant can only be calculated for a square matrix")}function xrange(t,e){let r=[];for(let n=0;ni)return new Array(e.rows+1).fill(0);{let t=e.addRow(r,[0]);for(let e=0;ee?o[t]=1/o[t]:o[t]=0;return i.mmul(Matrix.diag(o).mmul(n.transpose()))}function covariance(t,e=t,r={}){t=new Matrix(t);let n=!1;if("object"!=typeof e||Matrix.isMatrix(e)||Array.isArray(e)?e=new Matrix(e):(r=e,e=t,n=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=r;i&&(t=t.center("column"),n||(e=e.center("column")));const o=t.transpose().mmul(e);for(let e=0;e0?o.set(t,t+1,n[t]):n[t]<0&&o.set(t,t-1,n[t])}return o}}function tred2(t,e,r,n){let i,o,s,a,l,h,u,c;for(l=0;l0;a--){for(c=0,s=0,h=0;h0&&(o=-o),e[a]=c*o,s-=i*o,r[a-1]=i-o,l=0;lh)do{for(i=r[h],c=(r[h+1]-i)/(2*e[h]),f=hypotenuse(c,1),c<0&&(f=-f),r[h]=e[h]/(c+f),r[h+1]=e[h]*(c+f),m=r[h+1],o=i-r[h],s=h+2;s=h;s--)for(d=p,p=g,x=y,i=g*e[s],o=g*c,f=hypotenuse(c,e[s]),e[s+1]=y*f,y=e[s]/f,g=c/f,c=g*r[s]-y*i,r[s+1]=o+y*(g*i+y*r[s]),l=0;lb*v);r[h]=r[h]+M,e[h]=0}for(s=0;s=h;a--)r[a]=e.get(a,h-1)/u,s+=r[a]*r[a];for(o=Math.sqrt(s),r[h]>0&&(o=-o),s-=r[h]*o,r[h]=r[h]-o,l=h;l=h;a--)i+=r[a]*e.get(a,l);for(i/=s,a=h;a<=c;a++)e.set(a,l,e.get(a,l)-i*r[a])}for(a=0;a<=c;a++){for(i=0,l=c;l>=h;l--)i+=r[l]*e.get(a,l);for(i/=s,l=h;l<=c;l++)e.set(a,l,e.get(a,l)-i*r[l])}r[h]=u*r[h],e.set(h,h-1,u*o)}}for(a=0;a=1;h--)if(0!==e.get(h,h-1)){for(a=h+1;a<=c;a++)r[a]=e.get(a,h-1);for(l=h;l<=c;l++){for(o=0,a=h;a<=c;a++)o+=r[a]*n.get(a,l);for(o=o/r[h]/e.get(h,h-1),a=h;a<=c;a++)n.set(a,l,n.get(a,l)+o*r[a])}}}function hqr2(t,e,r,n,i){let o,s,a,l,h,u,c,f,m,g,p,d,w,y,x,M=t-1,v=t-1,b=Number.EPSILON,S=0,A=0,E=0,R=0,k=0,N=0,T=0,C=0;for(o=0;ov)&&(r[o]=i.get(o,o),e[o]=0),s=Math.max(o-1,0);s=0;){for(l=M;l>0&&(N=Math.abs(i.get(l-1,l-1))+Math.abs(i.get(l,l)),0===N&&(N=A),!(Math.abs(i.get(l,l-1))=0){for(T=E>=0?E+T:E-T,r[M-1]=f+T,r[M]=r[M-1],0!==T&&(r[M]=f-c/T),e[M-1]=0,e[M]=0,f=i.get(M,M-1),N=Math.abs(f)+Math.abs(T),E=f/N,R=T/N,k=Math.sqrt(E*E+R*R),E/=k,R/=k,s=M-1;s0)){for(N=Math.sqrt(N),m=l&&(T=i.get(h,h),k=f-T,N=m-T,E=(k*N-c)/i.get(h+1,h)+i.get(h,h+1),R=i.get(h+1,h+1)-T-k-N,k=i.get(h+2,h+1),N=Math.abs(E)+Math.abs(R)+Math.abs(k),E/=N,R/=N,k/=N,h!==l)&&!(Math.abs(i.get(h,h-1))*(Math.abs(R)+Math.abs(k))h+2&&i.set(o,o-3,0);for(a=h;a<=M-1&&(y=a!==M-1,a!==h&&(E=i.get(a,a-1),R=i.get(a+1,a-1),k=y?i.get(a+2,a-1):0,f=Math.abs(E)+Math.abs(R)+Math.abs(k),0!==f&&(E/=f,R/=f,k/=f)),0!==f);a++)if(N=Math.sqrt(E*E+R*R+k*k),E<0&&(N=-N),0!==N){for(a!==h?i.set(a,a-1,-N*f):l!==h&&i.set(a,a-1,-i.get(a,a-1)),E+=N,f=E/N,m=R/N,T=k/N,R/=E,k/=E,s=a;s=0;M--)if(E=r[M],R=e[M],0===R)for(l=M,i.set(M,M,1),o=M-1;o>=0;o--){for(c=i.get(o,o)-E,k=0,s=l;s<=M;s++)k+=i.get(o,s)*i.get(s,M);if(e[o]<0)T=c,N=k;else if(l=o,0===e[o]?i.set(o,M,0!==c?-k/c:-k/(b*A)):(f=i.get(o,o+1),m=i.get(o+1,o),R=(r[o]-E)*(r[o]-E)+e[o]*e[o],u=(f*N-T*k)/R,i.set(o,M,u),i.set(o+1,M,Math.abs(f)>Math.abs(T)?(-k-c*u)/f:(-N-m*u)/T)),u=Math.abs(i.get(o,M)),b*u*u>1)for(s=o;s<=M;s++)i.set(s,M,i.get(s,M)/u)}else if(R<0)for(l=M-1,Math.abs(i.get(M,M-1))>Math.abs(i.get(M-1,M))?(i.set(M-1,M-1,R/i.get(M,M-1)),i.set(M-1,M,-(i.get(M,M)-E)/i.get(M,M-1))):(x=cdiv(0,-i.get(M-1,M),i.get(M-1,M-1)-E,R),i.set(M-1,M-1,x[0]),i.set(M-1,M,x[1])),i.set(M,M-1,0),i.set(M,M,1),o=M-2;o>=0;o--){for(g=0,p=0,s=l;s<=M;s++)g+=i.get(o,s)*i.get(s,M-1),p+=i.get(o,s)*i.get(s,M);if(c=i.get(o,o)-E,e[o]<0)T=c,k=g,N=p;else if(l=o,0===e[o]?(x=cdiv(-g,-p,c,R),i.set(o,M-1,x[0]),i.set(o,M,x[1])):(f=i.get(o,o+1),m=i.get(o+1,o),d=(r[o]-E)*(r[o]-E)+e[o]*e[o]-R*R,w=2*(r[o]-E)*R,0===d&&0===w&&(d=b*A*(Math.abs(c)+Math.abs(R)+Math.abs(f)+Math.abs(m)+Math.abs(T))),x=cdiv(f*k-T*g+R*p,f*N-T*p-R*g,d,w),i.set(o,M-1,x[0]),i.set(o,M,x[1]),Math.abs(f)>Math.abs(T)+Math.abs(R)?(i.set(o+1,M-1,(-g-c*i.get(o,M-1)+R*i.get(o,M))/f),i.set(o+1,M,(-p-c*i.get(o,M)-R*i.get(o,M-1))/f)):(x=cdiv(-k-m*i.get(o,M-1),-N-m*i.get(o,M),T,R),i.set(o+1,M-1,x[0]),i.set(o+1,M,x[1]))),u=Math.max(Math.abs(i.get(o,M-1)),Math.abs(i.get(o,M))),b*u*u>1)for(s=o;s<=M;s++)i.set(s,M-1,i.get(s,M-1)/u),i.set(s,M,i.get(s,M)/u)}for(o=0;ov)for(s=o;s=0;s--)for(o=0;o<=v;o++){for(T=0,a=0;a<=Math.min(s,v);a++)T+=n.get(o,a)*i.get(a,s);n.set(o,s,T)}}}function cdiv(t,e,r,n){let i,o;return Math.abs(r)>Math.abs(n)?(i=n/r,o=r+i*n,[(t+i*e)/o,(e-i*t)/o]):(i=r/n,o=n+i*r,[(i*t+e)/o,(i*e-t)/o])}class CholeskyDecomposition{constructor(t){if(!(t=WrapperMatrix2D.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,r,n,i=t,o=i.rows,s=new Matrix(o,o),a=!0;for(r=0;r0,s.set(r,r,Math.sqrt(Math.max(t,0))),n=r+1;n=0;o--)for(i=0;io;e++)h=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),h=h.div(h.norm()),a=t.mmul(h).div(h.transpose().mmul(h).get(0,0)),e>0&&(c=a.clone().sub(u).pow(2).sum()),u=a.clone(),r?(l=r.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),l=l.div(l.norm()),s=r.mmul(l).div(l.transpose().mmul(l).get(0,0))):s=a;if(r){let e=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0));e=e.div(e.norm());let n=t.clone().sub(a.clone().mmul(e.transpose())),i=s.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),o=r.clone().sub(a.clone().mulS(i.get(0,0)).mmul(l.transpose()));this.t=a,this.p=e.transpose(),this.w=h.transpose(),this.q=l,this.u=s,this.s=a.transpose().mmul(a),this.xResidual=n,this.yResidual=o,this.betas=i}else this.w=h.transpose(),this.s=a.transpose().mmul(a).sqrt(),this.t=n?a.clone().div(this.s.get(0,0)):a,this.xResidual=t.sub(a.mmul(h.transpose()))}}var MatrixLib=Object.freeze({__proto__:null,AbstractMatrix:AbstractMatrix,default:Matrix,Matrix:Matrix,wrap:wrap,WrapperMatrix1D:WrapperMatrix1D,WrapperMatrix2D:WrapperMatrix2D,solve:solve,inverse:inverse,determinant:determinant,linearDependencies:linearDependencies,pseudoInverse:pseudoInverse,covariance:covariance,correlation:correlation,SingularValueDecomposition:SingularValueDecomposition,SVD:SingularValueDecomposition,EigenvalueDecomposition:EigenvalueDecomposition,EVD:EigenvalueDecomposition,CholeskyDecomposition:CholeskyDecomposition,CHO:CholeskyDecomposition,LuDecomposition:LuDecomposition,LU:LuDecomposition,QrDecomposition:QrDecomposition,QR:QrDecomposition,Nipals:nipals,NIPALS:nipals,MatrixColumnView:MatrixColumnView,MatrixColumnSelectionView:MatrixColumnSelectionView,MatrixFlipColumnView:MatrixFlipColumnView,MatrixFlipRowView:MatrixFlipRowView,MatrixRowView:MatrixRowView,MatrixRowSelectionView:MatrixRowSelectionView,MatrixSelectionView:MatrixSelectionView,MatrixSubView:MatrixSubView,MatrixTransposeView:MatrixTransposeView});const toString$1=Object.prototype.toString;function isAnyArray$1(t){return toString$1.call(t).endsWith("Array]")}function sum(t){if(!isAnyArray$1(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");for(var e=0,r=0;rt+1)).reduce(((t,e)=>Math.max(t,e)))}function giniGain(t,e){let r=0,n=["greater","lesser"];for(let i=0;it>e:(t,e)=>t.01&&this.gain!==n&&s.lesserX.length>0&&s.greaterX.length>0){this.left=new TreeNode(this),this.right=new TreeNode(this);let t=new Matrix(s.lesserX),e=new Matrix(s.greaterX);this.left.train(t,s.lesserY,r+1,this.gain),this.right.train(e,s.greaterY,r+1,this.gain)}else this.calculatePrediction(e)}classify(t){return this.right&&this.left?t[this.splitColumn]>>0,UINT32_SIZE=UINT32_MAX+1,INT32_SIZE=UINT32_SIZE/2,INT32_MAX=INT32_SIZE-1,UINT21_SIZE=1<<21,UINT21_MAX=UINT21_SIZE-1;function int32(t){return 0|t.next()}function add(t,e){return 0===e?t:r=>t(r)+e}function int53(t){const e=0|t.next(),r=t.next()>>>0;return(e&UINT21_MAX)*UINT32_SIZE+r+(e&UINT21_SIZE?-SMALLEST_UNSAFE_INTEGER:0)}function int53Full(t){for(;;){const e=0|t.next();if(!(4194304&e)){const r=t.next()>>>0;return(e&UINT21_MAX)*UINT32_SIZE+r+(e&UINT21_SIZE?-SMALLEST_UNSAFE_INTEGER:0)}if(4194304==(8388607&e)&&0==(0|t.next()))return SMALLEST_UNSAFE_INTEGER}}function uint32(t){return t.next()>>>0}function uint53(t){const e=t.next()&UINT21_MAX,r=t.next()>>>0;return e*UINT32_SIZE+r}function uint53Full(t){for(;;){const e=0|t.next();if(!(e&UINT21_SIZE)){const r=t.next()>>>0;return(e&UINT21_MAX)*UINT32_SIZE+r}if(0==(e&UINT21_MAX)&&0==(0|t.next()))return SMALLEST_UNSAFE_INTEGER}}function isPowerOfTwoMinusOne(t){return 0==(t+1&t)}function bitmask(t){return e=>e.next()&t}function downscaleToLoopCheckedRange(t){const e=t+1,r=e*Math.floor(UINT32_SIZE/e);return t=>{let n=0;do{n=t.next()>>>0}while(n>=r);return n%e}}function downscaleToRange(t){return isPowerOfTwoMinusOne(t)?bitmask(t):downscaleToLoopCheckedRange(t)}function isEvenlyDivisibleByMaxInt32(t){return 0==(0|t)}function upscaleWithHighMasking(t){return e=>{const r=e.next()&t,n=e.next()>>>0;return r*UINT32_SIZE+n}}function upscaleToLoopCheckedRange(t){const e=t*Math.floor(SMALLEST_UNSAFE_INTEGER/t);return r=>{let n=0;do{const t=r.next()&UINT21_MAX,e=r.next()>>>0;n=t*UINT32_SIZE+e}while(n>=e);return n%t}}function upscaleWithinU53(t){const e=t+1;if(isEvenlyDivisibleByMaxInt32(e)){const t=(e/UINT32_SIZE|0)-1;if(isPowerOfTwoMinusOne(t))return upscaleWithHighMasking(t)}return upscaleToLoopCheckedRange(e)}function upscaleWithinI53AndLoopCheck(t,e){return r=>{let n=0;do{const t=0|r.next(),e=r.next()>>>0;n=(t&UINT21_MAX)*UINT32_SIZE+e+(t&UINT21_SIZE?-SMALLEST_UNSAFE_INTEGER:0)}while(ne);return n}}function integer(t,e){if(t=Math.floor(t),e=Math.floor(e),t<-SMALLEST_UNSAFE_INTEGER||!isFinite(t))throw new RangeError("Expected min to be at least "+-SMALLEST_UNSAFE_INTEGER);if(e>SMALLEST_UNSAFE_INTEGER||!isFinite(e))throw new RangeError("Expected max to be at most "+SMALLEST_UNSAFE_INTEGER);const r=e-t;return r<=0||!isFinite(r)?()=>t:r===UINT32_MAX?0===t?uint32:add(int32,t+INT32_SIZE):r{let i="";for(let o=0;o{try{if("xxx"==="x".repeat(3))return(t,e)=>t.repeat(e)}catch(t){}return(t,e)=>{let r="";for(;e>0;)1&e&&(r+=t),e>>=1,t+=t;return r}})(),nativeMath={next:()=>Math.random()*UINT32_SIZE|0},I32Array=(()=>{try{const t=new ArrayBuffer(4),e=new Int32Array(t);if(e[0]=INT32_SIZE,e[0]===-INT32_SIZE)return Int32Array}catch(t){}return Array})();function createEntropy(t=nativeMath,e=16){const r=[];r.push(0|(new Date).getTime());for(let n=1;n{try{if(-5===Math.imul(UINT32_MAX,5))return Math.imul}catch(t){}const t=65535;return(e,r)=>{const n=e&t,i=r&t;return n*i+((e>>>16&t)*i+n*(r>>>16&t)<<16>>>0)|0}})(),ARRAY_SIZE=624,ARRAY_MAX=ARRAY_SIZE-1,M=397,ARRAY_SIZE_MINUS_M=ARRAY_SIZE-M,A=2567483615;class MersenneTwister19937{constructor(){this.data=new I32Array(ARRAY_SIZE),this.index=0,this.uses=0}static seed(t){return(new MersenneTwister19937).seed(t)}static seedWithArray(t){return(new MersenneTwister19937).seedWithArray(t)}static autoSeed(){return MersenneTwister19937.seedWithArray(createEntropy())}next(){(0|this.index)>=ARRAY_SIZE&&(refreshData(this.data),this.index=0);const t=this.data[this.index];return this.index=this.index+1|0,this.uses+=1,0|temper(t)}getUseCount(){return this.uses}discard(t){if(t<=0)return this;for(this.uses+=t,(0|this.index)>=ARRAY_SIZE&&(refreshData(this.data),this.index=0);t+this.index>ARRAY_SIZE;)t-=ARRAY_SIZE-this.index,refreshData(this.data),this.index=0;return this.index=this.index+t|0,this}seed(t){let e=0;this.data[0]=e=0|t;for(let t=1;t>>30,1812433253)+t|0;return this.index=ARRAY_SIZE,this.uses=0,this}seedWithArray(t){return this.seed(19650218),seedWithArray(this.data,t),this}}function refreshData(t){let e=0,r=0;for(;(0|e)>>1^(1&r?A:0);for(;(0|e)>>1^(1&r?A:0);r=t[ARRAY_MAX]&INT32_SIZE|t[0]&INT32_MAX,t[ARRAY_MAX]=t[M-1]^r>>>1^(1&r?A:0)}function temper(t){return t^=t>>>11,t^=t<<7&2636928640,(t^=t<<15&4022730752)^t>>>18}function seedWithArray(t,e){let r=1,n=0;const i=e.length;let o=0|Math.max(i,ARRAY_SIZE),s=0|t[0];for(;(0|o)>0;--o)t[r]=s=(t[r]^imul(s^s>>>30,1664525))+(0|e[n])+(0|n)|0,r=r+1|0,++n,(0|r)>ARRAY_MAX&&(t[0]=t[ARRAY_MAX],r=1),n>=i&&(n=0);for(o=ARRAY_MAX;(0|o)>0;--o)t[r]=s=(t[r]^imul(s^s>>>30,1566083941))-r|0,r=r+1|0,(0|r)>ARRAY_MAX&&(t[0]=t[ARRAY_MAX],r=1);t[0]=INT32_SIZE}function checkFloat(t){return t>0&&t<=1}function examplesBaggingWithReplacement(t,e,r){let n,i=integer(0,t.rows-1);if(void 0===r)n=MersenneTwister19937.autoSeed();else{if(!Number.isInteger(r))throw new RangeError("Expected seed must be undefined or integer not "+r);n=MersenneTwister19937.seed(r)}let o=new Array(t.rows),s=new Array(t.rows);for(let r=0;rt.load(e)))}else this.replacement=t.replacement,this.maxFeatures=t.maxFeatures,this.nEstimators=t.nEstimators,this.treeOptions=t.treeOptions,this.isClassifier=t.isClassifier,this.seed=t.seed,this.useSampleBagging=t.useSampleBagging}train(t,e){if(t=Matrix.checkMatrix(t),this.maxFeatures=this.maxFeatures||t.columns,checkFloat(this.maxFeatures))this.n=Math.floor(t.columns*this.maxFeatures);else{if(!Number.isInteger(this.maxFeatures))throw new RangeError("Cannot process the maxFeatures parameter "+this.maxFeatures);if(this.maxFeatures>t.columns)throw new RangeError("The maxFeatures parameter should be less than "+t.columns);this.n=this.maxFeatures}let r;r=this.isClassifier?DecisionTreeClassifier:DecisionTreeRegression,this.estimators=new Array(this.nEstimators),this.indexes=new Array(this.nEstimators);for(let n=0;nt.toJSON())),useSampleBagging:this.useSampleBagging}}}const defaultOptions$2={maxFeatures:1,replacement:!0,nEstimators:10,seed:42,useSampleBagging:!1};class RandomForestClassifier extends RandomForestBase{constructor(t,e){!0===t?super(!0,e.baseModel):((t=Object.assign({},defaultOptions$2,t)).isClassifier=!0,super(t))}selection(t){return mode(t)}toJSON(){return{baseModel:super.toJSON(),name:"RFClassifier"}}static load(t){if("RFClassifier"!==t.name)throw new RangeError("Invalid model: "+t.name);return new RandomForestClassifier(!0,t)}}function mode(t){return t.sort(((e,r)=>t.filter((t=>t===e)).length-t.filter((t=>t===r)).length)).pop()}const toString$2=Object.prototype.toString;function isAnyArray$2(t){return toString$2.call(t).endsWith("Array]")}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return commonjsRequire(t,null==e?r.path:e)}},r.exports),r.exports}function getAugmentedNamespace(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})})),e}function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var medianQuickselect_min=createCommonjsModule((function(t){!function(){function e(t){for(var e=0,i=t.length-1,o=void 0,s=void 0,a=void 0,l=n(e,i);;){if(i<=e)return t[l];if(i==e+1)return t[e]>t[i]&&r(t,e,i),t[l];for(t[o=n(e,i)]>t[i]&&r(t,o,i),t[e]>t[i]&&r(t,e,i),t[o]>t[e]&&r(t,o,e),r(t,o,e+1),s=e+1,a=i;;){do{s++}while(t[e]>t[s]);do{a--}while(t[a]>t[e]);if(a=l&&(i=a-1)}}var r=function(t,e,r){var n;return n=[t[r],t[e]],t[e]=n[0],t[r]=n[1],n},n=function(t,e){return~~((t+e)/2)};t.exports?t.exports=e:window.median=e}()}));function median(t){if(!isAnyArray$2(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");return medianQuickselect_min(t.slice())}const selectionMethods={mean:mean,median:median},defaultOptions$3={maxFeatures:1,replacement:!1,nEstimators:10,treeOptions:{},selectionMethod:"mean",seed:42,useSampleBagging:!1};class RandomForestRegression extends RandomForestBase{constructor(t,e){if(!0===t)super(!0,e.baseModel),this.selectionMethod=e.selectionMethod;else{if("mean"!==(t=Object.assign({},defaultOptions$3,t)).selectionMethod&&"median"!==t.selectionMethod)throw new RangeError("Unsupported selection method "+t.selectionMethod);t.isClassifier=!1,super(t),this.selectionMethod=t.selectionMethod}}selection(t){return selectionMethods[this.selectionMethod](t)}toJSON(){return{baseModel:super.toJSON(),selectionMethod:this.selectionMethod,name:"RFRegression"}}static load(t){if("RFRegression"!==t.name)throw new RangeError("Invalid model: "+t.name);return new RandomForestRegression(!0,t)}}class PCA{constructor(t,e={}){if(!0===t){const t=e;return this.center=t.center,this.scale=t.scale,this.means=t.means,this.stdevs=t.stdevs,this.U=Matrix.checkMatrix(t.U),this.S=t.S,this.R=t.R,void(this.excludedFeatures=t.excludedFeatures||[])}t=new Matrix(t);const{isCovarianceMatrix:r=!1,method:n="SVD",nCompNIPALS:i=2,center:o=!0,scale:s=!1,ignoreZeroVariance:a=!1}=e;if(this.center=o,this.scale=s,this.means=null,this.stdevs=null,this.excludedFeatures=[],r)this._computeFromCovarianceMatrix(t);else switch(this._adjust(t,a),n){case"covarianceMatrix":{const e=new MatrixTransposeView(t).mmul(t).div(t.rows-1);this._computeFromCovarianceMatrix(e);break}case"NIPALS":this._computeWithNIPALS(t,i);break;case"SVD":{const e=new SingularValueDecomposition(t,{computeLeftSingularVectors:!1,computeRightSingularVectors:!0,autoTranspose:!0});this.U=e.rightSingularVectors;const r=e.diagonal,n=[];for(const e of r)n.push(e*e/(t.rows-1));this.S=n;break}default:throw new Error("unknown method: "+n)}}static load(t){if("string"!=typeof t.name)throw new TypeError("model must have a name property");if("PCA"!==t.name)throw new RangeError("invalid model: "+t.name);return new PCA(!0,t)}predict(t,e={}){const{nComponents:r=this.U.columns}=e;if(t=new Matrix(t),this.center&&(t.subRowVector(this.means),this.scale)){for(let e of this.excludedFeatures)t.removeColumn(e);t.divRowVector(this.stdevs)}var n=t.mmul(this.U);return n.subMatrix(0,n.rows-1,0,r-1)}invert(t){var e=(t=Matrix.checkMatrix(t)).mmul(this.U.transpose());return this.center&&(this.scale&&e.mulRowVector(this.stdevs),e.addRowVector(this.means)),e}getExplainedVariance(){var t=0;for(const e of this.S)t+=e;return this.S.map((e=>e/t))}getCumulativeVariance(){for(var t=this.getExplainedVariance(),e=1;eMath.sqrt(t)))}getLoadings(){return this.U.transpose()}toJSON(){return{name:"PCA",center:this.center,scale:this.scale,means:this.means,stdevs:this.stdevs,U:this.U,S:this.S,excludedFeatures:this.excludedFeatures}}_adjust(t,e){if(this.center){const r=t.mean("column"),n=this.scale?t.standardDeviation("column",{mean:r}):null;if(this.means=r,t.subRowVector(r),this.scale){for(let r=0;re?1:0},h=function(t,e,i,o,s){var a;if(null==i&&(i=0),null==s&&(s=r),i<0)throw new Error("lo must be non-negative");for(null==o&&(o=t.length);ir;0<=r?e++:e--)h.push(e);return h}.apply(this).reverse()).length;op;0<=p?++f:--f)d.push(o(t,n));return d},g=function(t,e,n,i){var o,s,a;for(null==i&&(i=r),o=t[n];n>e&&i(o,s=t[a=n-1>>1])<0;)t[n]=s,n=a;return t[n]=o},p=function(t,e,n){var i,o,s,a,l;for(null==n&&(n=r),o=t.length,l=e,s=t[e],i=2*e+1;i0;){const n=e.shift();t>=n.height?r.push(n):e=e.concat(n.children)}return r}group(t){if(!Number.isInteger(t)||t<1)throw new RangeError("groups must be a positive integer");const e=new heap$1(((t,e)=>e.height-t.height));for(e.push(this);e.size()e.push(t)))}var n=new Cluster;return n.children=e.toArray(),n.height=this.height,n}traverse(t){!function t(e,r){if(r(e),e.children)for(const n of e.children)t(n,r)}(this,t)}indices(){const t=[];return this.traverse((e=>{e.isLeaf&&t.push(e.index)})),t}}function singleLink(t,e){return Math.min(t,e)}function completeLink(t,e){return Math.max(t,e)}function averageLink(t,e,r,n,i){return n/(n+i)*t+i/(n+i)*e}function weightedAverageLink(t,e){return(t+e)/2}function centroidLink(t,e,r,n,i){return n/(n+i)*t+i/(n+i)*e+-n*i/(n+i)**2*r}function medianLink(t,e,r){return t/2+e/2-r/4}function wardLink(t,e,r,n,i,o){return(n+o)/(n+i+o)*t+(i+o)/(n+i+o)*e+-o/(n+i+o)*r}function wardLink2(t,e,r,n,i,o){const s=(n+o)/(n+i+o),a=(i+o)/(n+i+o),l=-o/(n+i+o);return Math.sqrt(s*t*t+a*e*e+l*r*r)}function agnes(t,e={}){const{distanceFunction:r=euclidean,method:n="complete",isDistanceMatrix:i=!1}=e;let o;i||(t=distanceMatrix(t,r));let s=new Matrix(t);const a=s.rows;if("string"==typeof n)switch(n.toLowerCase()){case"single":o=singleLink;break;case"complete":o=completeLink;break;case"average":case"upgma":o=averageLink;break;case"wpgma":o=weightedAverageLink;break;case"centroid":case"upgmc":o=centroidLink;break;case"median":case"wpgmc":o=medianLink;break;case"ward":o=wardLink;break;case"ward2":o=wardLink2;break;default:throw new RangeError("unknown clustering method: "+n)}else if("function"!=typeof n)throw new TypeError("method must be a string or function");let l=[];for(let t=0;tgetPreviousIndex(r,Math.min(t,e),Math.max(t,e));for(let a=1;a=e&&t++,t>=r&&t++,t}var index=Object.freeze({__proto__:null,agnes:agnes});const defaultOptions$4={distanceFunction:squaredEuclidean};function nearestVector(t,e,r=defaultOptions$4){const n=r.distanceFunction||defaultOptions$4.distanceFunction,i=r.similarityFunction||defaultOptions$4.similarityFunction;let o=-1;if("function"==typeof i){let r=Number.MIN_VALUE;for(let n=0;nr&&(r=s,o=n)}}else{if("function"!=typeof n)throw new Error("A similarity or distance function it's required");{let r=Number.MAX_VALUE;for(let i=0;in)return!1;return!0}const LOOP=8,FLOAT_MUL=1/16777216,sh1=15,sh2=18,sh3=11;function multiply_uint32(t,e){const r=65535&(t>>>=0);return((t-r)*(e>>>=0)>>>0)+r*e>>>0}class XSadd{constructor(t=Date.now()){this.state=new Uint32Array(4),this.init(t),this.random=this.getFloat.bind(this)}getUint32(){return this.nextState(),this.state[3]+this.state[2]>>>0}getFloat(){return(this.getUint32()>>>8)*FLOAT_MUL}init(t){if(!Number.isInteger(t))throw new TypeError("seed must be an integer");this.state[0]=t,this.state[1]=0,this.state[2]=0,this.state[3]=0;for(let t=1;t>>30>>>0)>>>0;this.periodCertification();for(let t=0;t>>sh2,t^=this.state[3]<PROB_TOLERANCE)throw new Error("probabilities should sum to 1, but instead sums to "+a[a.length-1])}if(!1===i&&n>s.length)throw new Error("size option is too large");const l=[];for(let t=0;tr[t];)t++;return t}return Math.floor(n*t)}class Random{constructor(t=Math.random){if("number"==typeof t){const e=new XSadd(t);this.randomGenerator=e.random}else this.randomGenerator=t}choice(t,e){return randomChoice(t,e,this.randomGenerator)}random(){return this.randomGenerator()}randInt(t,e){return void 0===e&&(e=t,t=0),t+Math.floor(this.randomGenerator()*(e-t))}randomSample(t){const e=[];for(let r=0;r1){for(var s={dist:-1,index:-1},a=0;as.dist&&(s.dist=r[o[0]][a],s.index=a);if(o[1]=s.index,e>2)for(var l=2;lh.dist&&(h=Object.assign({},c))}o[l]=h.index}}return o.map((e=>t[e]))}function kmeanspp(t,e,r={}){const n=(t=new Matrix(t)).rows,i=new Random(r.seed),o=[],s=r.localTrials||2+Math.floor(Math.log(e)),a=i.randInt(n);o.push(t.getRow(a));let l=new Matrix(1,t.rows);for(let e=0;et.length||!Number.isInteger(e))throw new Error("K should be a positive integer smaller than the number of points");var n;if(Array.isArray(r.initialization)){if(r.initialization.length!==e)throw new Error("The initial centers should have the same length as K");n=r.initialization}else switch(r.initialization){case"kmeans++":n=kmeanspp(t,e,r);break;case"random":n=random(t,e,r.seed);break;case"mostDistant":n=mostDistant(t,e,calculateDistanceMatrix(t,r.distanceFunction),r.seed);break;default:throw new Error(`Unknown initialization method: "${r.initialization}"`)}0===r.maxIterations&&(r.maxIterations=Number.MAX_VALUE);var i=new Array(t.length);if(r.withIterations)return kmeansGenerator(n,t,i,e,r);for(var o,s=!1,a=0;!s&&an&&(n=s,i=o)}return i}function calculateLogProbability(t,e,r,n){return t-=e,Math.log(r*Math.exp(t*t/n))}class MultinomialNB{constructor(t){t&&(this.conditionalProbability=Matrix.checkMatrix(t.conditionalProbability),this.priorProbability=Matrix.checkMatrix(t.priorProbability))}train(t,e){if((t=Matrix.checkMatrix(t)).rows!==e.length)throw new RangeError("the size of the training set and the training labels must be the same.");var r=separateClasses(t,e);this.priorProbability=new Matrix(r.length,1);for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,i=e.toIndex,o=void 0===i?t.length:i;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=n||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;as&&(s=t[a]);return s}function min(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,i=e.toIndex,o=void 0===i?t.length:i;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=n||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!isAnyArray(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=min(t),i=max(t);if(n===i)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var o=r.min,s=void 0===o?r.autoMinMax?n:0:o,a=r.max,l=void 0===a?r.autoMinMax?i:1:a;if(s>=l)throw new RangeError("min option must be smaller than max option");for(var h=(l-s)/(i-n),u=0;u>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;tn)throw new RangeError("Row index out of range")}function checkColumnIndex(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function checkRowVector(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function checkColumnVector(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function checkIndices(t,e,r){return{row:checkRowIndices(t,e),column:checkColumnIndices(t,r)}}function checkRowIndices(t,e){if("object"!=typeof e)throw new TypeError("unexpected type for row indices");if(e.some((e=>e<0||e>=t.rows)))throw new RangeError("row indices are out of range");return Array.isArray(e)||(e=Array.from(e)),e}function checkColumnIndices(t,e){if("object"!=typeof e)throw new TypeError("unexpected type for column indices");if(e.some((e=>e<0||e>=t.columns)))throw new RangeError("column indices are out of range");return Array.isArray(e)||(e=Array.from(e)),e}function checkRange(t,e,r,n,i){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(checkNumber("startRow",e),checkNumber("endRow",r),checkNumber("startColumn",n),checkNumber("endColumn",i),e>r||n>i||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||i<0||i>=t.columns)throw new RangeError("Submatrix indices are out of range")}function newArray(t,e=0){let r=[];for(let n=0;n=i)throw new RangeError("min must be smaller than max");let s=i-n,a=new Matrix(t,e);for(let r=0;rr?(i=!0,r=e):(n=!1,i=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,i=!1;for(;tr?(i=!0,r=e):(n=!1,i=!0);for(let r=e+1;rt.get(n,r)&&(n=i);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let i=t.get(e,r);for(let n=r;n=0;)if(0===t.maxRow(n))n--;else{let i=0,o=!1;for(;it&&(t=this.get(e,r));return t}maxIndex(){let t=this.get(0,0),e=[0,0];for(let r=0;rt&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(){let t=this.get(0,0);for(let e=0;ee&&(e=this.get(t,r));return e}maxRowIndex(t){checkRowIndex(this,t);let e=this.get(t,0),r=[t,0];for(let n=1;ne&&(e=this.get(t,n),r[1]=n);return r}minRow(t){checkRowIndex(this,t);let e=this.get(t,0);for(let r=1;re&&(e=this.get(r,t));return e}maxColumnIndex(t){checkColumnIndex(this,t);let e=this.get(0,t),r=[0,t];for(let n=1;ne&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){checkColumnIndex(this,t);let e=this.get(0,t);for(let r=1;r=r)throw new RangeError("min must be smaller than max");let n=new Matrix(this.rows,this.columns);for(let t=0;t=r)throw new RangeError("min must be smaller than max");let n=new Matrix(this.rows,this.columns);for(let t=0;tr||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new Matrix(t.length,r-e+1);for(let i=0;i=this.rows)throw new RangeError("Row index out of range: "+t[i]);n.set(i,o-e,this.get(t[i],o))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new Matrix(r-e+1,t.length);for(let i=0;i=this.columns)throw new RangeError("Column index out of range: "+t[i]);n.set(o-e,i,this.get(o,t[i]))}return n}setSubMatrix(t,e,r){checkRange(this,e,e+(t=Matrix.checkMatrix(t)).rows-1,r,r+t.columns-1);for(let n=0;n0){if(this.data=[],!(Number.isInteger(e)&&e>0))throw new TypeError("nColumns must be a positive integer");for(let r=0;rMath.abs(l[i])&&(i=e);if(i!==r){for(n=0;n=0;i--){for(n=0;ne?n.set(i,e,t.get(i,e)):i===e?n.set(i,e,1):n.set(i,e,0);return n}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,n=new Matrix(e,r);for(let i=0;iMath.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class QrDecomposition{constructor(t){let e,r,n,i,o=(t=WrapperMatrix2D.checkMatrix(t)).clone(),s=t.rows,a=t.columns,l=new Float64Array(a);for(n=0;n=0;o--){for(i=0;i=0;r--){for(t=0;t=0;t--)if(0!==f[t]){for(let e=t+1;e=0;t--){if(t0;){let t,e;for(t=b-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+A*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(d[t])<=e||Number.isNaN(d[t])){d[t]=0;break}}if(t===b-2)e=4;else{let r;for(r=b-1;r>=t&&r!==t;r--){let e=(r!==b?Math.abs(d[r]):0)+(r!==t+1?Math.abs(d[r-1]):0);if(Math.abs(f[r])<=A*e){f[r]=0;break}}r===t?e=3:r===b-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=d[b-2];d[b-2]=0;for(let r=b-2;r>=t;r--){let i=hypotenuse(f[r],e),o=f[r]/i,s=e/i;if(f[r]=i,r!==t&&(e=-s*d[r-1],d[r-1]=o*d[r-1]),h)for(let t=0;t=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,h&&te&&i.set(o,r,t.get(o,r)/this.s[r]);let o=this.U,s=o.rows,a=o.columns,l=new Matrix(r,s);for(let t=0;tt&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return Matrix.diag(this.s)}}function inverse(t,e=!1){return t=WrapperMatrix2D.checkMatrix(t),e?new SingularValueDecomposition(t).inverse():solve(t,Matrix.eye(t.rows))}function solve(t,e,r=!1){return t=WrapperMatrix2D.checkMatrix(t),e=WrapperMatrix2D.checkMatrix(e),r?new SingularValueDecomposition(t).solve(e):t.isSquare()?new LuDecomposition(t).solve(e):new QrDecomposition(t).solve(e)}function determinant(t){if((t=Matrix.checkMatrix(t)).isSquare()){let e,r,n,i;if(2===t.columns)return e=t.get(0,0),r=t.get(0,1),n=t.get(1,0),i=t.get(1,1),e*i-r*n;if(3===t.columns){let i,o,s;return i=new MatrixSelectionView(t,[1,2],[1,2]),o=new MatrixSelectionView(t,[1,2],[0,2]),s=new MatrixSelectionView(t,[1,2],[0,1]),e=t.get(0,0),r=t.get(0,1),n=t.get(0,2),e*determinant(i)-r*determinant(o)+n*determinant(s)}return new LuDecomposition(t).determinant}throw Error("determinant can only be calculated for a square matrix")}function xrange(t,e){let r=[];for(let n=0;ni)return new Array(e.rows+1).fill(0);{let t=e.addRow(r,[0]);for(let e=0;ee?o[t]=1/o[t]:o[t]=0;return i.mmul(Matrix.diag(o).mmul(n.transpose()))}function covariance(t,e=t,r={}){t=new Matrix(t);let n=!1;if("object"!=typeof e||Matrix.isMatrix(e)||Array.isArray(e)?e=new Matrix(e):(r=e,e=t,n=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:i=!0}=r;i&&(t=t.center("column"),n||(e=e.center("column")));const o=t.transpose().mmul(e);for(let e=0;e0?o.set(t,t+1,n[t]):n[t]<0&&o.set(t,t-1,n[t])}return o}}function tred2(t,e,r,n){let i,o,s,a,l,h,u,c;for(l=0;l0;a--){for(c=0,s=0,h=0;h0&&(o=-o),e[a]=c*o,s-=i*o,r[a-1]=i-o,l=0;lh)do{for(i=r[h],c=(r[h+1]-i)/(2*e[h]),m=hypotenuse(c,1),c<0&&(m=-m),r[h]=e[h]/(c+m),r[h+1]=e[h]*(c+m),f=r[h+1],o=i-r[h],s=h+2;s=h;s--)for(d=p,p=g,y=x,i=g*e[s],o=g*c,m=hypotenuse(c,e[s]),e[s+1]=x*m,x=e[s]/m,g=c/m,c=g*r[s]-x*i,r[s+1]=o+x*(g*i+x*r[s]),l=0;lb*v);r[h]=r[h]+M,e[h]=0}for(s=0;s=h;a--)r[a]=e.get(a,h-1)/u,s+=r[a]*r[a];for(o=Math.sqrt(s),r[h]>0&&(o=-o),s-=r[h]*o,r[h]=r[h]-o,l=h;l=h;a--)i+=r[a]*e.get(a,l);for(i/=s,a=h;a<=c;a++)e.set(a,l,e.get(a,l)-i*r[a])}for(a=0;a<=c;a++){for(i=0,l=c;l>=h;l--)i+=r[l]*e.get(a,l);for(i/=s,l=h;l<=c;l++)e.set(a,l,e.get(a,l)-i*r[l])}r[h]=u*r[h],e.set(h,h-1,u*o)}}for(a=0;a=1;h--)if(0!==e.get(h,h-1)){for(a=h+1;a<=c;a++)r[a]=e.get(a,h-1);for(l=h;l<=c;l++){for(o=0,a=h;a<=c;a++)o+=r[a]*n.get(a,l);for(o=o/r[h]/e.get(h,h-1),a=h;a<=c;a++)n.set(a,l,n.get(a,l)+o*r[a])}}}function hqr2(t,e,r,n,i){let o,s,a,l,h,u,c,m,f,g,p,d,w,x,y,M=t-1,v=t-1,b=Number.EPSILON,S=0,A=0,E=0,R=0,k=0,N=0,C=0,T=0;for(o=0;ov)&&(r[o]=i.get(o,o),e[o]=0),s=Math.max(o-1,0);s=0;){for(l=M;l>0&&(N=Math.abs(i.get(l-1,l-1))+Math.abs(i.get(l,l)),0===N&&(N=A),!(Math.abs(i.get(l,l-1))=0){for(C=E>=0?E+C:E-C,r[M-1]=m+C,r[M]=r[M-1],0!==C&&(r[M]=m-c/C),e[M-1]=0,e[M]=0,m=i.get(M,M-1),N=Math.abs(m)+Math.abs(C),E=m/N,R=C/N,k=Math.sqrt(E*E+R*R),E/=k,R/=k,s=M-1;s0)){for(N=Math.sqrt(N),f=l&&(C=i.get(h,h),k=m-C,N=f-C,E=(k*N-c)/i.get(h+1,h)+i.get(h,h+1),R=i.get(h+1,h+1)-C-k-N,k=i.get(h+2,h+1),N=Math.abs(E)+Math.abs(R)+Math.abs(k),E/=N,R/=N,k/=N,h!==l)&&!(Math.abs(i.get(h,h-1))*(Math.abs(R)+Math.abs(k))h+2&&i.set(o,o-3,0);for(a=h;a<=M-1&&(x=a!==M-1,a!==h&&(E=i.get(a,a-1),R=i.get(a+1,a-1),k=x?i.get(a+2,a-1):0,m=Math.abs(E)+Math.abs(R)+Math.abs(k),0!==m&&(E/=m,R/=m,k/=m)),0!==m);a++)if(N=Math.sqrt(E*E+R*R+k*k),E<0&&(N=-N),0!==N){for(a!==h?i.set(a,a-1,-N*m):l!==h&&i.set(a,a-1,-i.get(a,a-1)),E+=N,m=E/N,f=R/N,C=k/N,R/=E,k/=E,s=a;s=0;M--)if(E=r[M],R=e[M],0===R)for(l=M,i.set(M,M,1),o=M-1;o>=0;o--){for(c=i.get(o,o)-E,k=0,s=l;s<=M;s++)k+=i.get(o,s)*i.get(s,M);if(e[o]<0)C=c,N=k;else if(l=o,0===e[o]?i.set(o,M,0!==c?-k/c:-k/(b*A)):(m=i.get(o,o+1),f=i.get(o+1,o),R=(r[o]-E)*(r[o]-E)+e[o]*e[o],u=(m*N-C*k)/R,i.set(o,M,u),i.set(o+1,M,Math.abs(m)>Math.abs(C)?(-k-c*u)/m:(-N-f*u)/C)),u=Math.abs(i.get(o,M)),b*u*u>1)for(s=o;s<=M;s++)i.set(s,M,i.get(s,M)/u)}else if(R<0)for(l=M-1,Math.abs(i.get(M,M-1))>Math.abs(i.get(M-1,M))?(i.set(M-1,M-1,R/i.get(M,M-1)),i.set(M-1,M,-(i.get(M,M)-E)/i.get(M,M-1))):(y=cdiv(0,-i.get(M-1,M),i.get(M-1,M-1)-E,R),i.set(M-1,M-1,y[0]),i.set(M-1,M,y[1])),i.set(M,M-1,0),i.set(M,M,1),o=M-2;o>=0;o--){for(g=0,p=0,s=l;s<=M;s++)g+=i.get(o,s)*i.get(s,M-1),p+=i.get(o,s)*i.get(s,M);if(c=i.get(o,o)-E,e[o]<0)C=c,k=g,N=p;else if(l=o,0===e[o]?(y=cdiv(-g,-p,c,R),i.set(o,M-1,y[0]),i.set(o,M,y[1])):(m=i.get(o,o+1),f=i.get(o+1,o),d=(r[o]-E)*(r[o]-E)+e[o]*e[o]-R*R,w=2*(r[o]-E)*R,0===d&&0===w&&(d=b*A*(Math.abs(c)+Math.abs(R)+Math.abs(m)+Math.abs(f)+Math.abs(C))),y=cdiv(m*k-C*g+R*p,m*N-C*p-R*g,d,w),i.set(o,M-1,y[0]),i.set(o,M,y[1]),Math.abs(m)>Math.abs(C)+Math.abs(R)?(i.set(o+1,M-1,(-g-c*i.get(o,M-1)+R*i.get(o,M))/m),i.set(o+1,M,(-p-c*i.get(o,M)-R*i.get(o,M-1))/m)):(y=cdiv(-k-f*i.get(o,M-1),-N-f*i.get(o,M),C,R),i.set(o+1,M-1,y[0]),i.set(o+1,M,y[1]))),u=Math.max(Math.abs(i.get(o,M-1)),Math.abs(i.get(o,M))),b*u*u>1)for(s=o;s<=M;s++)i.set(s,M-1,i.get(s,M-1)/u),i.set(s,M,i.get(s,M)/u)}for(o=0;ov)for(s=o;s=0;s--)for(o=0;o<=v;o++){for(C=0,a=0;a<=Math.min(s,v);a++)C+=n.get(o,a)*i.get(a,s);n.set(o,s,C)}}}function cdiv(t,e,r,n){let i,o;return Math.abs(r)>Math.abs(n)?(i=n/r,o=r+i*n,[(t+i*e)/o,(e-i*t)/o]):(i=r/n,o=n+i*r,[(i*t+e)/o,(i*e-t)/o])}class CholeskyDecomposition{constructor(t){if(!(t=WrapperMatrix2D.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,r,n,i=t,o=i.rows,s=new Matrix(o,o),a=!0;for(r=0;r0,s.set(r,r,Math.sqrt(Math.max(t,0))),n=r+1;n=0;o--)for(i=0;io;e++)h=t.transpose().mmul(s).div(s.transpose().mmul(s).get(0,0)),h=h.div(h.norm()),a=t.mmul(h).div(h.transpose().mmul(h).get(0,0)),e>0&&(c=a.clone().sub(u).pow(2).sum()),u=a.clone(),r?(l=r.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),l=l.div(l.norm()),s=r.mmul(l).div(l.transpose().mmul(l).get(0,0))):s=a;if(r){let e=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0));e=e.div(e.norm());let n=t.clone().sub(a.clone().mmul(e.transpose())),i=s.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),o=r.clone().sub(a.clone().mulS(i.get(0,0)).mmul(l.transpose()));this.t=a,this.p=e.transpose(),this.w=h.transpose(),this.q=l,this.u=s,this.s=a.transpose().mmul(a),this.xResidual=n,this.yResidual=o,this.betas=i}else this.w=h.transpose(),this.s=a.transpose().mmul(a).sqrt(),this.t=n?a.clone().div(this.s.get(0,0)):a,this.xResidual=t.sub(a.mmul(h.transpose()))}}var MatrixLib=Object.freeze({__proto__:null,AbstractMatrix:AbstractMatrix,default:Matrix,Matrix:Matrix,wrap:wrap,WrapperMatrix1D:WrapperMatrix1D,WrapperMatrix2D:WrapperMatrix2D,solve:solve,inverse:inverse,determinant:determinant,linearDependencies:linearDependencies,pseudoInverse:pseudoInverse,covariance:covariance,correlation:correlation,SingularValueDecomposition:SingularValueDecomposition,SVD:SingularValueDecomposition,EigenvalueDecomposition:EigenvalueDecomposition,EVD:EigenvalueDecomposition,CholeskyDecomposition:CholeskyDecomposition,CHO:CholeskyDecomposition,LuDecomposition:LuDecomposition,LU:LuDecomposition,QrDecomposition:QrDecomposition,QR:QrDecomposition,Nipals:nipals,NIPALS:nipals,MatrixColumnView:MatrixColumnView,MatrixColumnSelectionView:MatrixColumnSelectionView,MatrixFlipColumnView:MatrixFlipColumnView,MatrixFlipRowView:MatrixFlipRowView,MatrixRowView:MatrixRowView,MatrixRowSelectionView:MatrixRowSelectionView,MatrixSelectionView:MatrixSelectionView,MatrixSubView:MatrixSubView,MatrixTransposeView:MatrixTransposeView});const toString$1=Object.prototype.toString;function isAnyArray$1(t){return toString$1.call(t).endsWith("Array]")}function sum(t){if(!isAnyArray$1(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");for(var e=0,r=0;rt+1)).reduce(((t,e)=>Math.max(t,e)))}function giniGain(t,e){let r=0,n=["greater","lesser"];for(let i=0;it>e:(t,e)=>t.01&&this.gain!==n&&s.lesserX.length>0&&s.greaterX.length>0){this.left=new TreeNode(this),this.right=new TreeNode(this);let t=new Matrix(s.lesserX),e=new Matrix(s.greaterX);this.left.train(t,s.lesserY,r+1,this.gain),this.right.train(e,s.greaterY,r+1,this.gain)}else this.calculatePrediction(e)}classify(t){return this.right&&this.left?t[this.splitColumn]>>0,UINT32_SIZE=UINT32_MAX+1,INT32_SIZE=UINT32_SIZE/2,INT32_MAX=INT32_SIZE-1,UINT21_SIZE=1<<21,UINT21_MAX=UINT21_SIZE-1;function int32(t){return 0|t.next()}function add(t,e){return 0===e?t:r=>t(r)+e}function int53(t){const e=0|t.next(),r=t.next()>>>0;return(e&UINT21_MAX)*UINT32_SIZE+r+(e&UINT21_SIZE?-SMALLEST_UNSAFE_INTEGER:0)}function int53Full(t){for(;;){const e=0|t.next();if(!(4194304&e)){const r=t.next()>>>0;return(e&UINT21_MAX)*UINT32_SIZE+r+(e&UINT21_SIZE?-SMALLEST_UNSAFE_INTEGER:0)}if(4194304==(8388607&e)&&0==(0|t.next()))return SMALLEST_UNSAFE_INTEGER}}function uint32(t){return t.next()>>>0}function uint53(t){const e=t.next()&UINT21_MAX,r=t.next()>>>0;return e*UINT32_SIZE+r}function uint53Full(t){for(;;){const e=0|t.next();if(!(e&UINT21_SIZE)){const r=t.next()>>>0;return(e&UINT21_MAX)*UINT32_SIZE+r}if(0==(e&UINT21_MAX)&&0==(0|t.next()))return SMALLEST_UNSAFE_INTEGER}}function isPowerOfTwoMinusOne(t){return 0==(t+1&t)}function bitmask(t){return e=>e.next()&t}function downscaleToLoopCheckedRange(t){const e=t+1,r=e*Math.floor(UINT32_SIZE/e);return t=>{let n=0;do{n=t.next()>>>0}while(n>=r);return n%e}}function downscaleToRange(t){return isPowerOfTwoMinusOne(t)?bitmask(t):downscaleToLoopCheckedRange(t)}function isEvenlyDivisibleByMaxInt32(t){return 0==(0|t)}function upscaleWithHighMasking(t){return e=>{const r=e.next()&t,n=e.next()>>>0;return r*UINT32_SIZE+n}}function upscaleToLoopCheckedRange(t){const e=t*Math.floor(SMALLEST_UNSAFE_INTEGER/t);return r=>{let n=0;do{const t=r.next()&UINT21_MAX,e=r.next()>>>0;n=t*UINT32_SIZE+e}while(n>=e);return n%t}}function upscaleWithinU53(t){const e=t+1;if(isEvenlyDivisibleByMaxInt32(e)){const t=(e/UINT32_SIZE|0)-1;if(isPowerOfTwoMinusOne(t))return upscaleWithHighMasking(t)}return upscaleToLoopCheckedRange(e)}function upscaleWithinI53AndLoopCheck(t,e){return r=>{let n=0;do{const t=0|r.next(),e=r.next()>>>0;n=(t&UINT21_MAX)*UINT32_SIZE+e+(t&UINT21_SIZE?-SMALLEST_UNSAFE_INTEGER:0)}while(ne);return n}}function integer(t,e){if(t=Math.floor(t),e=Math.floor(e),t<-SMALLEST_UNSAFE_INTEGER||!isFinite(t))throw new RangeError("Expected min to be at least "+-SMALLEST_UNSAFE_INTEGER);if(e>SMALLEST_UNSAFE_INTEGER||!isFinite(e))throw new RangeError("Expected max to be at most "+SMALLEST_UNSAFE_INTEGER);const r=e-t;return r<=0||!isFinite(r)?()=>t:r===UINT32_MAX?0===t?uint32:add(int32,t+INT32_SIZE):r{let i="";for(let o=0;o{try{if("xxx"==="x".repeat(3))return(t,e)=>t.repeat(e)}catch(t){}return(t,e)=>{let r="";for(;e>0;)1&e&&(r+=t),e>>=1,t+=t;return r}})(),nativeMath={next:()=>Math.random()*UINT32_SIZE|0},I32Array=(()=>{try{const t=new ArrayBuffer(4),e=new Int32Array(t);if(e[0]=INT32_SIZE,e[0]===-INT32_SIZE)return Int32Array}catch(t){}return Array})();function createEntropy(t=nativeMath,e=16){const r=[];r.push(0|(new Date).getTime());for(let n=1;n{try{if(-5===Math.imul(UINT32_MAX,5))return Math.imul}catch(t){}const t=65535;return(e,r)=>{const n=e&t,i=r&t;return n*i+((e>>>16&t)*i+n*(r>>>16&t)<<16>>>0)|0}})(),ARRAY_SIZE=624,ARRAY_MAX=ARRAY_SIZE-1,M=397,ARRAY_SIZE_MINUS_M=ARRAY_SIZE-M,A=2567483615;class MersenneTwister19937{constructor(){this.data=new I32Array(ARRAY_SIZE),this.index=0,this.uses=0}static seed(t){return(new MersenneTwister19937).seed(t)}static seedWithArray(t){return(new MersenneTwister19937).seedWithArray(t)}static autoSeed(){return MersenneTwister19937.seedWithArray(createEntropy())}next(){(0|this.index)>=ARRAY_SIZE&&(refreshData(this.data),this.index=0);const t=this.data[this.index];return this.index=this.index+1|0,this.uses+=1,0|temper(t)}getUseCount(){return this.uses}discard(t){if(t<=0)return this;for(this.uses+=t,(0|this.index)>=ARRAY_SIZE&&(refreshData(this.data),this.index=0);t+this.index>ARRAY_SIZE;)t-=ARRAY_SIZE-this.index,refreshData(this.data),this.index=0;return this.index=this.index+t|0,this}seed(t){let e=0;this.data[0]=e=0|t;for(let t=1;t>>30,1812433253)+t|0;return this.index=ARRAY_SIZE,this.uses=0,this}seedWithArray(t){return this.seed(19650218),seedWithArray(this.data,t),this}}function refreshData(t){let e=0,r=0;for(;(0|e)>>1^(1&r?A:0);for(;(0|e)>>1^(1&r?A:0);r=t[ARRAY_MAX]&INT32_SIZE|t[0]&INT32_MAX,t[ARRAY_MAX]=t[M-1]^r>>>1^(1&r?A:0)}function temper(t){return t^=t>>>11,t^=t<<7&2636928640,(t^=t<<15&4022730752)^t>>>18}function seedWithArray(t,e){let r=1,n=0;const i=e.length;let o=0|Math.max(i,ARRAY_SIZE),s=0|t[0];for(;(0|o)>0;--o)t[r]=s=(t[r]^imul(s^s>>>30,1664525))+(0|e[n])+(0|n)|0,r=r+1|0,++n,(0|r)>ARRAY_MAX&&(t[0]=t[ARRAY_MAX],r=1),n>=i&&(n=0);for(o=ARRAY_MAX;(0|o)>0;--o)t[r]=s=(t[r]^imul(s^s>>>30,1566083941))-r|0,r=r+1|0,(0|r)>ARRAY_MAX&&(t[0]=t[ARRAY_MAX],r=1);t[0]=INT32_SIZE}function checkFloat(t){return t>0&&t<=1}function examplesBaggingWithReplacement(t,e,r){let n,i=integer(0,t.rows-1);if(void 0===r)n=MersenneTwister19937.autoSeed();else{if(!Number.isInteger(r))throw new RangeError("Expected seed must be undefined or integer not "+r);n=MersenneTwister19937.seed(r)}let o=new Array(t.rows),s=new Array(t.rows);for(let r=0;rt.load(e)))}else this.replacement=t.replacement,this.maxFeatures=t.maxFeatures,this.nEstimators=t.nEstimators,this.treeOptions=t.treeOptions,this.isClassifier=t.isClassifier,this.seed=t.seed,this.useSampleBagging=t.useSampleBagging}train(t,e){if(t=Matrix.checkMatrix(t),this.maxFeatures=this.maxFeatures||t.columns,checkFloat(this.maxFeatures))this.n=Math.floor(t.columns*this.maxFeatures);else{if(!Number.isInteger(this.maxFeatures))throw new RangeError("Cannot process the maxFeatures parameter "+this.maxFeatures);if(this.maxFeatures>t.columns)throw new RangeError("The maxFeatures parameter should be less than "+t.columns);this.n=this.maxFeatures}let r;r=this.isClassifier?DecisionTreeClassifier:DecisionTreeRegression,this.estimators=new Array(this.nEstimators),this.indexes=new Array(this.nEstimators);for(let n=0;nt.toJSON())),useSampleBagging:this.useSampleBagging}}}const defaultOptions$2={maxFeatures:1,replacement:!0,nEstimators:10,seed:42,useSampleBagging:!1};class RandomForestClassifier extends RandomForestBase{constructor(t,e){!0===t?super(!0,e.baseModel):((t=Object.assign({},defaultOptions$2,t)).isClassifier=!0,super(t))}selection(t){return mode(t)}toJSON(){return{baseModel:super.toJSON(),name:"RFClassifier"}}static load(t){if("RFClassifier"!==t.name)throw new RangeError("Invalid model: "+t.name);return new RandomForestClassifier(!0,t)}}function mode(t){return t.sort(((e,r)=>t.filter((t=>t===e)).length-t.filter((t=>t===r)).length)).pop()}const toString$2=Object.prototype.toString;function isAnyArray$2(t){return toString$2.call(t).endsWith("Array]")}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return commonjsRequire(t,null==e?r.path:e)}},r.exports),r.exports}function getAugmentedNamespace(t){if(t.__esModule)return t;var e=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(t).forEach((function(r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})})),e}function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var medianQuickselect_min=createCommonjsModule((function(t){!function(){function e(t){for(var e=0,i=t.length-1,o=void 0,s=void 0,a=void 0,l=n(e,i);;){if(i<=e)return t[l];if(i==e+1)return t[e]>t[i]&&r(t,e,i),t[l];for(t[o=n(e,i)]>t[i]&&r(t,o,i),t[e]>t[i]&&r(t,e,i),t[o]>t[e]&&r(t,o,e),r(t,o,e+1),s=e+1,a=i;;){do{s++}while(t[e]>t[s]);do{a--}while(t[a]>t[e]);if(a=l&&(i=a-1)}}var r=function(t,e,r){var n;return n=[t[r],t[e]],t[e]=n[0],t[r]=n[1],n},n=function(t,e){return~~((t+e)/2)};t.exports?t.exports=e:window.median=e}()}));function median(t){if(!isAnyArray$2(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");return medianQuickselect_min(t.slice())}const selectionMethods={mean:mean,median:median},defaultOptions$3={maxFeatures:1,replacement:!1,nEstimators:10,treeOptions:{},selectionMethod:"mean",seed:42,useSampleBagging:!1};class RandomForestRegression extends RandomForestBase{constructor(t,e){if(!0===t)super(!0,e.baseModel),this.selectionMethod=e.selectionMethod;else{if("mean"!==(t=Object.assign({},defaultOptions$3,t)).selectionMethod&&"median"!==t.selectionMethod)throw new RangeError("Unsupported selection method "+t.selectionMethod);t.isClassifier=!1,super(t),this.selectionMethod=t.selectionMethod}}selection(t){return selectionMethods[this.selectionMethod](t)}toJSON(){return{baseModel:super.toJSON(),selectionMethod:this.selectionMethod,name:"RFRegression"}}static load(t){if("RFRegression"!==t.name)throw new RangeError("Invalid model: "+t.name);return new RandomForestRegression(!0,t)}}class PCA{constructor(t,e={}){if(!0===t){const t=e;return this.center=t.center,this.scale=t.scale,this.means=t.means,this.stdevs=t.stdevs,this.U=Matrix.checkMatrix(t.U),this.S=t.S,this.R=t.R,void(this.excludedFeatures=t.excludedFeatures||[])}t=new Matrix(t);const{isCovarianceMatrix:r=!1,method:n="SVD",nCompNIPALS:i=2,center:o=!0,scale:s=!1,ignoreZeroVariance:a=!1}=e;if(this.center=o,this.scale=s,this.means=null,this.stdevs=null,this.excludedFeatures=[],r)this._computeFromCovarianceMatrix(t);else switch(this._adjust(t,a),n){case"covarianceMatrix":{const e=new MatrixTransposeView(t).mmul(t).div(t.rows-1);this._computeFromCovarianceMatrix(e);break}case"NIPALS":this._computeWithNIPALS(t,i);break;case"SVD":{const e=new SingularValueDecomposition(t,{computeLeftSingularVectors:!1,computeRightSingularVectors:!0,autoTranspose:!0});this.U=e.rightSingularVectors;const r=e.diagonal,n=[];for(const e of r)n.push(e*e/(t.rows-1));this.S=n;break}default:throw new Error("unknown method: "+n)}}static load(t){if("string"!=typeof t.name)throw new TypeError("model must have a name property");if("PCA"!==t.name)throw new RangeError("invalid model: "+t.name);return new PCA(!0,t)}predict(t,e={}){const{nComponents:r=this.U.columns}=e;if(t=new Matrix(t),this.center&&(t.subRowVector(this.means),this.scale)){for(let e of this.excludedFeatures)t.removeColumn(e);t.divRowVector(this.stdevs)}var n=t.mmul(this.U);return n.subMatrix(0,n.rows-1,0,r-1)}invert(t){var e=(t=Matrix.checkMatrix(t)).mmul(this.U.transpose());return this.center&&(this.scale&&e.mulRowVector(this.stdevs),e.addRowVector(this.means)),e}getExplainedVariance(){var t=0;for(const e of this.S)t+=e;return this.S.map((e=>e/t))}getCumulativeVariance(){for(var t=this.getExplainedVariance(),e=1;eMath.sqrt(t)))}getLoadings(){return this.U.transpose()}toJSON(){return{name:"PCA",center:this.center,scale:this.scale,means:this.means,stdevs:this.stdevs,U:this.U,S:this.S,excludedFeatures:this.excludedFeatures}}_adjust(t,e){if(this.center){const r=t.mean("column"),n=this.scale?t.standardDeviation("column",{mean:r}):null;if(this.means=r,t.subRowVector(r),this.scale){for(let r=0;re?1:0},h=function(t,e,i,o,s){var a;if(null==i&&(i=0),null==s&&(s=r),i<0)throw new Error("lo must be non-negative");for(null==o&&(o=t.length);ir;0<=r?e++:e--)h.push(e);return h}.apply(this).reverse()).length;op;0<=p?++m:--m)d.push(o(t,n));return d},g=function(t,e,n,i){var o,s,a;for(null==i&&(i=r),o=t[n];n>e&&i(o,s=t[a=n-1>>1])<0;)t[n]=s,n=a;return t[n]=o},p=function(t,e,n){var i,o,s,a,l;for(null==n&&(n=r),o=t.length,l=e,s=t[e],i=2*e+1;i0;){const n=e.shift();t>=n.height?r.push(n):e=e.concat(n.children)}return r}group(t){if(!Number.isInteger(t)||t<1)throw new RangeError("groups must be a positive integer");const e=new heap$1(((t,e)=>e.height-t.height));for(e.push(this);e.size()e.push(t)))}var n=new Cluster;return n.children=e.toArray(),n.height=this.height,n}traverse(t){!function t(e,r){if(r(e),e.children)for(const n of e.children)t(n,r)}(this,t)}indices(){const t=[];return this.traverse((e=>{e.isLeaf&&t.push(e.index)})),t}}function singleLink(t,e){return Math.min(t,e)}function completeLink(t,e){return Math.max(t,e)}function averageLink(t,e,r,n,i){return n/(n+i)*t+i/(n+i)*e}function weightedAverageLink(t,e){return(t+e)/2}function centroidLink(t,e,r,n,i){return n/(n+i)*t+i/(n+i)*e+-n*i/(n+i)**2*r}function medianLink(t,e,r){return t/2+e/2-r/4}function wardLink(t,e,r,n,i,o){return(n+o)/(n+i+o)*t+(i+o)/(n+i+o)*e+-o/(n+i+o)*r}function wardLink2(t,e,r,n,i,o){const s=(n+o)/(n+i+o),a=(i+o)/(n+i+o),l=-o/(n+i+o);return Math.sqrt(s*t*t+a*e*e+l*r*r)}function agnes(t,e={}){const{distanceFunction:r=euclidean,method:n="complete",isDistanceMatrix:i=!1}=e;let o;i||(t=distanceMatrix(t,r));let s=new Matrix(t);const a=s.rows;if("string"==typeof n)switch(n.toLowerCase()){case"single":o=singleLink;break;case"complete":o=completeLink;break;case"average":case"upgma":o=averageLink;break;case"wpgma":o=weightedAverageLink;break;case"centroid":case"upgmc":o=centroidLink;break;case"median":case"wpgmc":o=medianLink;break;case"ward":o=wardLink;break;case"ward2":o=wardLink2;break;default:throw new RangeError("unknown clustering method: "+n)}else if("function"!=typeof n)throw new TypeError("method must be a string or function");let l=[];for(let t=0;tgetPreviousIndex(r,Math.min(t,e),Math.max(t,e));for(let a=1;a=e&&t++,t>=r&&t++,t}var index=Object.freeze({__proto__:null,agnes:agnes});const defaultOptions$4={distanceFunction:squaredEuclidean};function nearestVector(t,e,r=defaultOptions$4){const n=r.distanceFunction||defaultOptions$4.distanceFunction,i=r.similarityFunction||defaultOptions$4.similarityFunction;let o=-1;if("function"==typeof i){let r=Number.MIN_VALUE;for(let n=0;nr&&(r=s,o=n)}}else{if("function"!=typeof n)throw new Error("A similarity or distance function it's required");{let r=Number.MAX_VALUE;for(let i=0;in)return!1;return!0}const LOOP=8,FLOAT_MUL=1/16777216,sh1=15,sh2=18,sh3=11;function multiply_uint32(t,e){const r=65535&(t>>>=0);return((t-r)*(e>>>=0)>>>0)+r*e>>>0}class XSadd{constructor(t=Date.now()){this.state=new Uint32Array(4),this.init(t),this.random=this.getFloat.bind(this)}getUint32(){return this.nextState(),this.state[3]+this.state[2]>>>0}getFloat(){return(this.getUint32()>>>8)*FLOAT_MUL}init(t){if(!Number.isInteger(t))throw new TypeError("seed must be an integer");this.state[0]=t,this.state[1]=0,this.state[2]=0,this.state[3]=0;for(let t=1;t>>30>>>0)>>>0;this.periodCertification();for(let t=0;t>>sh2,t^=this.state[3]<PROB_TOLERANCE)throw new Error("probabilities should sum to 1, but instead sums to "+a[a.length-1])}if(!1===i&&n>s.length)throw new Error("size option is too large");const l=[];for(let t=0;tr[t];)t++;return t}return Math.floor(n*t)}class Random{constructor(t=Math.random){if("number"==typeof t){const e=new XSadd(t);this.randomGenerator=e.random}else this.randomGenerator=t}choice(t,e){return randomChoice(t,e,this.randomGenerator)}random(){return this.randomGenerator()}randInt(t,e){return void 0===e&&(e=t,t=0),t+Math.floor(this.randomGenerator()*(e-t))}randomSample(t){const e=[];for(let r=0;r1){for(var s={dist:-1,index:-1},a=0;as.dist&&(s.dist=r[o[0]][a],s.index=a);if(o[1]=s.index,e>2)for(var l=2;lh.dist&&(h=Object.assign({},c))}o[l]=h.index}}return o.map((e=>t[e]))}function kmeanspp(t,e,r={}){const n=(t=new Matrix(t)).rows,i=new Random(r.seed),o=[],s=r.localTrials||2+Math.floor(Math.log(e)),a=i.randInt(n);o.push(t.getRow(a));let l=new Matrix(1,t.rows);for(let e=0;et.length||!Number.isInteger(e))throw new Error("K should be a positive integer smaller than the number of points");var n;if(Array.isArray(r.initialization)){if(r.initialization.length!==e)throw new Error("The initial centers should have the same length as K");n=r.initialization}else switch(r.initialization){case"kmeans++":n=kmeanspp(t,e,r);break;case"random":n=random(t,e,r.seed);break;case"mostDistant":n=mostDistant(t,e,calculateDistanceMatrix(t,r.distanceFunction),r.seed);break;default:throw new Error(`Unknown initialization method: "${r.initialization}"`)}0===r.maxIterations&&(r.maxIterations=Number.MAX_VALUE);var i=new Array(t.length);if(r.withIterations)return kmeansGenerator(n,t,i,e,r);for(var o,s=!1,a=0;!s&&an&&(n=s,i=o)}return i}function calculateLogProbability(t,e,r,n){return t-=e,Math.log(r*Math.exp(t*t/n))}class MultinomialNB{constructor(t){t&&(this.conditionalProbability=Matrix.checkMatrix(t.conditionalProbability),this.priorProbability=Matrix.checkMatrix(t.priorProbability))}train(t,e){if((t=Matrix.checkMatrix(t)).rows!==e.length)throw new RangeError("the size of the training set and the training labels must be the same.");var r=separateClasses(t,e);this.priorProbability=new Matrix(r.length,1);for(var n=0;n, 2012 * @author Ubilabs http://ubilabs.net, 2012 * @license MIT License - */function Node(t,e,r){this.obj=t,this.left=null,this.right=null,this.parent=r,this.dimension=e}class KDTree{constructor(t,e){if(Array.isArray(t)){this.dimensions=new Array(t[0].length);for(var r=0;re&&s.pop()}for(m=0;mt[n[i]]-e[n[i]]));const o=Math.floor(t.length/2),s=new Node(t[o],i,r);return s.left=buildTree(t.slice(0,o),e+1,s,n),s.right=buildTree(t.slice(o+1),e+1,s,n),s}function restoreParent(t){t.left&&(t.left.parent=t,restoreParent(t.left)),t.right&&(t.right.parent=t,restoreParent(t.right))}class BinaryHeap{constructor(t){this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}pop(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t}peek(){return this.content[0]}size(){return this.content.length}bubbleUp(t){for(var e=this.content[t];t>0;){const r=Math.floor((t+1)/2)-1,n=this.content[r];if(!(this.scoreFunction(e)o&&(i=h,o=u)}return i}function norm(t){return Math.sqrt(t.clone().apply(pow2array).sum())}function pow2array(t,e){this.set(t,e,this.get(t,e)**2)}function initializeMatrices(t,e){if(e)for(let e=0;ef&&Mf;)n=a.mmul(m),n.div(norm(n)),r=c,c=t.mmul(n),i=l.mmul(c),i.div(norm(i)),m=e.mmul(i);r=c;let v=a.mmul(r),b=r.transpose().mmul(r).get(0,0);o=v.div(b);let S=norm(o);o.div(S),r.mul(S),n.mul(S),v=m.transpose().mmul(r),b=r.transpose().mmul(r).get(0,0);let A=v.div(b).get(0,0);t.sub(r.mmul(o.transpose())),e.sub(r.clone().mul(A).mmul(i.transpose())),g.setColumn(M,r),p.setColumn(M,o),d.setColumn(M,m),w.setColumn(M,i),x.setColumn(M,n),y.set(M,M,A),M++}M--,g=g.subMatrix(0,g.rows-1,0,M),p=p.subMatrix(0,p.rows-1,0,M),d=d.subMatrix(0,d.rows-1,0,M),w=w.subMatrix(0,w.rows-1,0,M),x=x.subMatrix(0,x.rows-1,0,M),y=y.subMatrix(0,M,0,M),this.ssqYcal=c,this.E=t,this.F=e,this.T=g,this.P=p,this.U=d,this.Q=w,this.W=x,this.B=y,this.PBQ=p.mmul(y).mmul(w.transpose()),this.R2X=r.transpose().mmul(r).mmul(o.transpose().mmul(o)).div(u).get(0,0)}predict(t){let e=Matrix.checkMatrix(t);this.scale&&(e=e.subRowVector(this.meanX).divRowVector(this.stdDevX));let r=e.mmul(this.PBQ);return r=r.mulRowVector(this.stdDevY).addRowVector(this.meanY),r}getExplainedVariance(){return this.R2X}toJSON(){return{name:"PLS",R2X:this.R2X,meanX:this.meanX,stdDevX:this.stdDevX,meanY:this.meanY,stdDevY:this.stdDevY,PBQ:this.PBQ,tolerance:this.tolerance,scale:this.scale}}static load(t){if("PLS"!==t.name)throw new RangeError("Invalid model: "+t.name);return new PLS(!0,t)}}function maxSumColIndex(t){return Matrix.rowVector(t.sum("column")).maxIndex()[0]}class KOPLS{constructor(t,e){if(!0===t)this.trainingSet=new Matrix(e.trainingSet),this.YLoadingMat=new Matrix(e.YLoadingMat),this.SigmaPow=new Matrix(e.SigmaPow),this.YScoreMat=new Matrix(e.YScoreMat),this.predScoreMat=initializeMatrices(e.predScoreMat,!1),this.YOrthLoadingVec=initializeMatrices(e.YOrthLoadingVec,!1),this.YOrthEigen=e.YOrthEigen,this.YOrthScoreMat=initializeMatrices(e.YOrthScoreMat,!1),this.toNorm=initializeMatrices(e.toNorm,!1),this.TURegressionCoeff=initializeMatrices(e.TURegressionCoeff,!1),this.kernelX=initializeMatrices(e.kernelX,!0),this.kernel=e.kernel,this.orthogonalComp=e.orthogonalComp,this.predictiveComp=e.predictiveComp;else{if(void 0===t.predictiveComponents)throw new RangeError("no predictive components found!");if(void 0===t.orthogonalComponents)throw new RangeError("no orthogonal components found!");if(void 0===t.kernel)throw new RangeError("no kernel found!");this.orthogonalComp=t.orthogonalComponents,this.predictiveComp=t.predictiveComponents,this.kernel=t.kernel}}train(t,e){t=Matrix.checkMatrix(t),e=Matrix.checkMatrix(e),this.trainingSet=t.clone();let r=this.kernel.compute(t),n=Matrix.eye(r.rows,r.rows,1),i=r;r=new Array(this.orthogonalComp+1);for(let t=0;t=0&&s>=0&&i[o][s]++}return new ConfusionMatrix(i,n)}getMatrix(){return this.matrix}getLabels(){return this.labels}getTotalCount(){let t=0;for(let e=0;e=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var l=i.call(s,"catchLoc"),h=i.call(s,"finallyLoc");if(l&&h){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:I(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),g}}}function x(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),s=new C(n||[]);return o._invoke=R(t,r,s),o}function M(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function v(){}function b(){}function S(){}function A(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function E(t){function e(r,n,o,s){var a=M(t[r],t,n);if("throw"!==a.type){var l=a.arg,h=l.value;return h&&"object"==typeof h&&i.call(h,"__await")?Promise.resolve(h.__await).then((function(t){e("next",t,o,s)}),(function(t){e("throw",t,o,s)})):Promise.resolve(h).then((function(t){l.value=t,o(l)}),s)}s(a.arg)}var r;function n(t,n){function i(){return new Promise((function(r,i){e(t,n,r,i)}))}return r=r?r.then(i,i):i()}this._invoke=n}function R(t,e,r){var n=u;return function(i,o){if(n===f)throw new Error("Generator is already running");if(n===m){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var s=r.delegate;if(s){var a=k(s,r);if(a){if(a===g)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===u)throw n=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=f;var l=M(t,e,r);if("normal"===l.type){if(n=r.done?m:c,l.arg===g)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n=m,r.method="throw",r.arg=l.arg)}}}function k(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,k(t,e),"throw"===e.method))return g;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return g}var i=M(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,g):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function T(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function I(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n=0,o=i&&n.regeneratorRuntime;n.regeneratorRuntime=void 0;var s=r;if(i)n.regeneratorRuntime=o;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}var a=s,l={mode:"index"};t.exports=a.mark((function t(e,r,n){var i,o,s,h,u,c,f,m,g;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(g=function(){var t,e,r;for(e=1;h[e]<=0;)e++;if(0===h[e-1]){for(t=e-1;1!==t;t--)h[t]=-1;h[e]=0,u=f=0,h[1]=1,c=e-1}else{e>1&&(h[e-1]=0);do{e++}while(h[e]>0);for(r=e-1,t=e;0===h[t];)h[t++]=-1;if(-1===h[t])h[t]=h[r],f=h[r]-1,u=t-1,c=r-1,h[r]=-1;else{if(t===h[0])return 0;h[e]=h[t],f=h[t]-1,h[t]=0,u=e-1,c=t-1}}return 1},n=Object.assign({},l,n),i=new Array(r),o=new Array(e),s=new Array(r),h=new Array(r+2),m=0;ms[e-1].push(t))),s=s.slice(0,e),s.map(((t,e)=>({testIndex:t,trainIndex:[].concat(...s.filter(((t,r)=>r!==e)))})))}function sampleAClass(t,e){let r=JSON.parse(JSON.stringify(t)),n=Array.from(Array(r.length).keys()).sort(((t,e)=>r[t]ti[t]=(i[t]||0)+1));let o=[];Object.keys(i).forEach(((t,r)=>{let n=[];Object.values(i).reduce(((t,e,r)=>n[r]=t+e),0);let s=[...Array(i[t]).keys()],a=[];for(let r=0;rt+n[r-1])))}));let s=[];o.forEach((t=>s.push(n[t])));let a=[],l=[];return t.forEach(((t,e)=>{s.includes(e)?l.push(!0):(l.push(!1),a.push(e))})),{trainIndex:s,testIndex:a,mask:l}}function leaveOneOut(t,e,r,n){if("function"==typeof r){let n=r;return r=e,leavePOut(e=t,r,1,n)}return leavePOut(t,e,r,n,1)}function leavePOut(t,e,r,n,i){let o;"function"==typeof n&&(o=n,i=r,r=e,e=t),check(e,r);const s=getDistinct(r),a=initMatrix(s.length,s.length);let l=e.length,h=lib(i,l),u=new Array(l);for(let t=0;t=0;t--)l.splice(i[t],1);o?validateWithCallback(e,r,i,l,a,s,o):validate(t,e,r,n,i,l,a,s)}return new ConfusionMatrix(a,s)}function kFold(t,e,r,n,i){let o;"function"==typeof n&&(o=n,i=r,r=e,e=t),check(e,r);const s=getDistinct(r),a=initMatrix(s.length,s.length);let l=getFolds(e,i);for(let i=0;inew Array(e).fill(0)))}function getDistinct(t){let e=new Set;for(let r=0;r1e-10;t++)s=u.transpose().mmul(l).div(u.transpose().mmul(u).get(0,0)),s=s.transpose().div(norm(s)),i=l.mmul(s).div(s.transpose().mmul(s).get(0,0)),o=i.transpose().mmul(h).div(i.transpose().mmul(i).get(0,0)),a=h.mmul(o.transpose()),a=a.div(o.transpose().mmul(o).get(0,0)),t>0&&(c=a.clone().sub(u).pow(2).sum()/a.clone().pow(2).sum()),u=a.clone();let f=i.transpose().mmul(l).div(i.transpose().mmul(i).get(0,0)),m=f.clone().sub(s.transpose().mmul(f.transpose()).div(s.transpose().mmul(s).get(0,0)).mmul(s.transpose()));m.div(norm(m));let g=l.mmul(m.transpose()).div(m.mmul(m.transpose()).get(0,0)),p=g.transpose().mmul(l).div(g.transpose().mmul(g).get(0,0));return{filteredX:l.clone().sub(g.mmul(p)),weightsXOrtho:m,loadingsXOrtho:p,scoresXOrtho:g,weightsXPred:s,loadingsXpred:f,scoresXpred:i,loadingsY:o}}function tss(t){return Matrix.mul(t,t).sum()}class OPLS{constructor(t,e,r={}){if(!0===t){const t=r;return this.center=t.center,this.scale=t.scale,this.means=t.means,this.meansY=t.meansY,this.stdevs=t.stdevs,this.stdevs=t.stdevsY,this.model=t.model,this.tCV=t.tCV,this.tOrthCV=t.tOrthCV,this.yHatCV=t.yHatCV,void(this.mode=t.mode)}let n=t.clone();const{nComp:i=3,center:o=!0,scale:s=!0,cvFolds:a=[]}=r;let l,h;if("number"==typeof e[0])this.mode="regression",l=Matrix.from1DArray(e.length,1,e);else if("string"==typeof e[0])throw this.mode="discriminantAnalysis",l=e,new Error("discriminant analysis is not yet supported");if("Matrix"!==n.constructor.name)throw new TypeError("features must be of class Matrix");this.center=o,this.center?(this.means=n.mean("column"),this.meansY=l.mean("column")):this.stdevs=null,this.scale=s,this.scale?(this.stdevs=n.standardDeviation("column"),this.stdevsY=l.standardDeviation("column")):this.means=null,h=a.length>0?a:getFolds(e,5);let u=[];this.model=[],this.tCV=[],this.tOrthCV=[],this.yHatCV=[];let c,f=[],m=[];for(c=0;ct.R2x)),A=this.model.map((t=>t.R2y));this.output={Q2y:u,R2x:S,R2y:A,tPred:d.plsC.t,pPred:d.plsC.p,wPred:d.plsC.w,betasPred:d.plsC.betas,Qpc:d.plsC.q,tCV:g,tOrthCV:p,tOrth:d.tOrth,pOrth:d.pOrth,wOrth:d.wOrth,XOrth:w,yHat:d.totalPred,Yres:d.plsC.yResidual,E:b}}getLogs(){return this.output}getScores(){return{scoresX:this.tCV.map((t=>t.to1DArray())),scoresY:this.tOrthCV.map((t=>t.to1DArray()))}}static load(t){if("string"!=typeof t.name)throw new TypeError("model must have a name property");if("OPLS"!==t.name)throw new RangeError("invalid model: "+t.name);return new OPLS(!0,[],t)}toJSON(){return{name:"OPLS",center:this.center,scale:this.scale,means:this.means,stdevs:this.stdevs,model:this.model,tCV:this.tCV,tOrthCV:this.tOrthCV,yHatCV:this.yHatCV}}predict(t,e={}){let{trueLabels:r=[],nc:n=1}=e,i=[];r.length>0&&(r=Matrix.from1DArray(r.length,1,r),i=r.clone());let o=t.clone();this.center&&(o.center("column",{center:this.means}),i.rows>0&&"regression"===this.mode&&i.center("column",{center:this.meansY})),this.scale&&(o.scale("column",{scale:this.stdevs}),i.rows>0&&"regression"===this.mode&&i.scale("column",{scale:this.stdevsY}));let s,a,l,h,u,c=o.clone();for(let t=0;t0))return{tPred:u,tOrth:s,yHat:h};if("regression"===this.mode){let t=tss(i);return{tPred:u,tOrth:s,yHat:h,Q2y:1-tss(i.clone().sub(h))/t}}if("discriminantAnalysis"===this.mode){let t=[];return t=ConfusionMatrix.fromLabels(r.to1DArray(),h.to1DArray()),{tPred:u,tOrth:s,yHat:h,confusionMatrix:t}}}_predictAll(t,e,r={}){const{center:n=!0,scale:i=!0}=r;n&&(t.center("column"),e.center("column")),i&&(t.scale("column"),e.scale("column"),this.tssy=tss(e),this.tssx=tss(t));let o=OPLSNipals(t,e),s=new nipals(o.filteredX,{Y:e}),a=o.filteredX.mmul(s.w.transpose()),l=a.mmul(s.betas);return{R2y:1-tss(e.clone().sub(l))/this.tssy,R2x:tss(s.t.mmul(s.p))/this.tssx,xRes:o.filteredX,tOrth:o.scoresXOrtho,pOrth:o.loadingsXOrtho,wOrth:o.weightsXOrtho,tPred:a,totalPred:l,XOrth:o.scoresXOrtho.mmul(o.loadingsXOrtho),oplsC:o,plsC:s}}_getTrainTest(t,e,r){let n=new Matrix(r.testIndex.length,t.columns),i=new Matrix(r.testIndex.length,1);r.testIndex.forEach(((r,o)=>{n.setRow(o,t.getRow(r)),i.setRow(o,e.getRow(r))}));let o=new Matrix(r.trainIndex.length,t.columns),s=new Matrix(r.trainIndex.length,1);return r.trainIndex.forEach(((r,n)=>{o.setRow(n,t.getRow(r)),s.setRow(n,e.getRow(r))})),{trainFeatures:o,testFeatures:n,trainLabels:s,testLabels:i}}}var require$$0=getAugmentedNamespace(MatrixLib);function logistic(t){return 1/(1+Math.exp(-t))}function expELU(t,e){return t<0?e*(Math.exp(t)-1):t}function softExponential(t,e){return e<0?-Math.log(1-e*(t+e))/e:e>0?(Math.exp(e*t)-1)/e+e:t}function softExponentialPrime(t,e){return e<0?1/(1-e*(e+t)):Math.exp(e*t)}const ACTIVATION_FUNCTIONS={tanh:{activation:Math.tanh,derivate:t=>1-t*t},identity:{activation:t=>t,derivate:()=>1},logistic:{activation:logistic,derivate:t=>logistic(t)*(1-logistic(t))},arctan:{activation:Math.atan,derivate:t=>1/(t*t+1)},softsign:{activation:t=>t/(1+Math.abs(t)),derivate:t=>1/((1+Math.abs(t))*(1+Math.abs(t)))},relu:{activation:t=>t<0?0:t,derivate:t=>t<0?0:1},softplus:{activation:t=>Math.log(1+Math.exp(t)),derivate:t=>1/(1+Math.exp(-t))},bent:{activation:t=>(Math.sqrt(t*t+1)-1)/2+t,derivate:t=>t/(2*Math.sqrt(t*t+1))+1},sinusoid:{activation:Math.sin,derivate:Math.cos},sinc:{activation:t=>0===t?1:Math.sin(t)/t,derivate:t=>0===t?0:Math.cos(t)/t-Math.sin(t)/(t*t)},gaussian:{activation:t=>Math.exp(-t*t),derivate:t=>-2*t*Math.exp(-t*t)},"parametric-relu":{activation:(t,e)=>t<0?e*t:t,derivate:(t,e)=>t<0?e:1},"exponential-elu":{activation:expELU,derivate:(t,e)=>t<0?expELU(t,e)+e:1},"soft-exponential":{activation:softExponential,derivate:softExponentialPrime}};class Layer{constructor(t){this.inputSize=t.inputSize,this.outputSize=t.outputSize,this.regularization=t.regularization,this.epsilon=t.epsilon,this.activation=t.activation,this.activationParam=t.activationParam;var e=ACTIVATION_FUNCTIONS[t.activation],r=e.activation.length,n=r>1?r=>e.activation(r,t.activationParam):e.activation,i=r>1?r=>e.derivate(r,t.activationParam):e.derivate;this.activationFunction=function(t,e){this.set(t,e,n(this.get(t,e)))},this.derivate=function(t,e){this.set(t,e,i(this.get(t,e)))},t.model?(this.W=require$$0.Matrix.checkMatrix(t.W),this.b=require$$0.Matrix.checkMatrix(t.b)):(this.W=require$$0.Matrix.rand(this.inputSize,this.outputSize),this.b=require$$0.Matrix.zeros(1,this.outputSize),this.W.apply((function(e,r){this.set(e,r,this.get(e,r)/Math.sqrt(t.inputSize))})))}forward(t){var e=t.mmul(this.W).addRowVector(this.b);return e.apply(this.activationFunction),this.a=e.clone(),e}backpropagation(t,e){this.dW=e.transpose().mmul(t),this.db=require$$0.Matrix.rowVector(t.sum("column"));var r=e.clone();return t.mmul(this.W.transpose()).mul(r.apply(this.derivate))}update(){this.dW.add(this.W.clone().mul(this.regularization)),this.W.add(this.dW.mul(-this.epsilon)),this.b.add(this.db.mul(-this.epsilon))}toJSON(){return{model:"Layer",inputSize:this.inputSize,outputSize:this.outputSize,regularization:this.regularization,epsilon:this.epsilon,activation:this.activation,W:this.W,b:this.b}}static load(t){if("Layer"!==t.model)throw new RangeError("the current model is not a Layer model");return new Layer(t)}}class OutputLayer extends Layer{constructor(t){super(t),this.activationFunction=function(t,e){this.set(t,e,Math.exp(this.get(t,e)))}}static load(t){if("Layer"!==t.model)throw new RangeError("the current model is not a Layer model");return new OutputLayer(t)}}class FeedForwardNeuralNetworks{constructor(t){if((t=t||{}).model){this.hiddenLayers=t.hiddenLayers,this.iterations=t.iterations,this.learningRate=t.learningRate,this.regularization=t.regularization,this.dicts=t.dicts,this.activation=t.activation,this.activationParam=t.activationParam,this.model=new Array(t.layers.length);for(var e=0;e=0;--n){var o=n>0?this.model[n-1].a:t;i=this.model[n].backpropagation(i,o)}for(n=0;n0?e=this[t]-1:this.som.torus&&(e=this.som.gridDim[t]-1),void 0!==e)"x"===t?(r=e,n=this.y):(r=this.x,n=e),this.neighbors[t][0]=this.som.nodes[r][n];this[t]0&&e>0))throw new Error("x and y must be positive");this.times={findBMU:0,adjust:0},this.randomizer=this.options.randomizer,this.iterationCount=0,this.iterations=this.options.iterations,this.startLearningRate=this.learningRate=this.options.learningRate,this.mapRadius=Math.floor(Math.max(t,e)/2),this.algorithmMethod=this.options.method,this._initNodes(),this.done=!1}else this.done=!0}function getConverters(t){for(var e=t.length,r=new Array(e),n=new Array(e),i=0;i0?("random"===this.algorithmMethod?(t=this.mapRadius*Math.exp(-this.iterationCount/this.timeConstant),e=getRandomValue(this.trainingSet,this.randomizer),this._adjust(e,t),this.learningRate=this.startLearningRate*Math.exp(-this.iterationCount/this.numIterations)):(r=-Math.floor(this.iterationCount/this.trainingSet.length),t=this.mapRadius*Math.exp(r/this.timeConstant),e=this.trainingSet[this.iterationCount%this.trainingSet.length],this._adjust(e,t),(this.iterationCount+1)%this.trainingSet.length==0&&(this.learningRate=this.startLearningRate*Math.exp(r/Math.floor(this.numIterations/this.trainingSet.length)))),this.iterationCount++,!0):(this.done=!0,!1));var t,e,r},SOM.prototype._adjust=function(t,e){var r,n,i,o,s=Date.now(),a=this._findBestMatchingUnit(t),l=Date.now();this.times.findBMU+=l-s;var h=Math.floor(e),u=a.x-h,c=a.x+h,f=a.y-h,m=a.y+h;for(r=u;r<=c;r++){var g=r;for(r<0?g+=this.x:r>=this.x&&(g-=this.x),n=f;n<=m;n++){var p=n;n<0?p+=this.y:n>=this.y&&(p-=this.y),(i=a[this.distanceMethod](this.nodes[g][p]))0&&e!==this.coefficients.length-1?s=" + "+s:e!==this.coefficients.length-1&&(s=" "+s)),o=s+o;return"+"===o.charAt(0)&&(o=o.slice(1)),"f(x) = "+o}static load(t){if("polynomialRegression"!==t.name)throw new TypeError("not a polynomial regression model");return new PolynomialRegression(!0,t)}}function regress(t,e,r,n){const i=e.length;let o;if(Array.isArray(n))o=n,n=o.length;else{n++,o=new Array(n);for(let t=0;t=0?`f(x) = ${maybeToPrecision(this.B,t)}e^{${maybeToPrecision(this.A,t)}x}`:`f(x) = \\frac{${maybeToPrecision(this.B,t)}}{e^{${maybeToPrecision(-this.A,t)}x}}`}static load(t){if("exponentialRegression"!==t.name)throw new TypeError("not a exponential regression model");return new ExponentialRegression(!0,t)}}function regress$2(t,e,r){const n=e.length,i=new Array(n);for(let t=0;t=0?`f(x) = ${maybeToPrecision(this.A,t)}x^{${maybeToPrecision(this.B,t)}}`:`f(x) = \\frac{${maybeToPrecision(this.A,t)}}{x^{${maybeToPrecision(-this.B,t)}}}`,e=e.replace(/e([+-]?[0-9]+)/g,"e^{$1}"),e}static load(t){if("powerRegression"!==t.name)throw new TypeError("not a power regression model");return new PowerRegression(!0,t)}}function regress$3(t,e,r){const n=e.length,i=new Array(n),o=new Array(n);for(let t=0;tMath.pow(t[0],2))).reduce(((t,e)=>t+e))/(e.rows-t.columns);this.stdError=Math.sqrt(n),this.stdErrorMatrix=pseudoInverse(o).mul(n),this.stdErrors=this.stdErrorMatrix.diagonal().map((t=>Math.sqrt(t))),this.tStats=this.weights.map(((t,e)=>0===this.stdErrors[e]?0:t[0]/this.stdErrors[e]))}}}predict(t){if(Array.isArray(t)){if("number"==typeof t[0])return this._predict(t);if(Array.isArray(t[0])){const e=new Array(t.length);for(let r=0;r({label:e===this.weights.length-1?"Intercept":"X Variable "+(e+1),coefficients:t,standardError:this.stdErrors[e],tStat:this.tStats[e]})))}:void 0}}static load(t){if("multivariateLinearRegression"!==t.name)throw new Error("not a MLR model");return new MultivariateLinearRegression(!0,t)}}var require$$0$1=getAugmentedNamespace(euclidean$1);const{squaredEuclidean:squaredEuclidean$1}=require$$0$1,defaultOptions$7={sigma:1};class GaussianKernel{constructor(t){t=Object.assign({},defaultOptions$7,t),this.sigma=t.sigma,this.divisor=2*t.sigma*t.sigma}compute(t,e){const r=squaredEuclidean$1(t,e);return Math.exp(-r/this.divisor)}}var gaussianKernel=GaussianKernel;const defaultOptions$8={degree:1,constant:1,scale:1};class PolynomialKernel{constructor(t){t=Object.assign({},defaultOptions$8,t),this.degree=t.degree,this.constant=t.constant,this.scale=t.scale}compute(t,e){for(var r=0,n=0;n0&&e!==this.coefficients.length-1?s=" + "+s:e!==this.coefficients.length-1&&(s=" "+s)),o=s+o;return"+"===o.charAt(0)&&(o=o.slice(1)),"f(x) = "+o}static load(t){if("robustPolynomialRegression"!==t.name)throw new TypeError("not a RobustPolynomialRegression model");return new RobustPolynomialRegression(!0,t)}}function robustPolynomial(t,e,r,n){let i=Array(n).fill(0).map(((t,e)=>e));const o=getRandomTuples(e,r,n);for(var s,a=0;at.residual-e.residual));var e=t.length,r=Math.floor(e/2);return e%2==0?t[r-1]:t[r]}const toString$3=Object.prototype.toString;function isAnyArray$3(t){return toString$3.call(t).endsWith("Array]")}function errorCalculation(t,e,r){let n=0;const i=r(e);for(let e=0;e{let r=BigInt(0);return t.forEach((t=>r|=BigInt(1)<t.key-e.key<0?-1:1)),n=[],i=[];for(let t of r)t.key!==e&&(e=t.key,i.push([]),n.push(t.value)),i[i.length-1].push(t.index);return{values:n,indices:i}}function cssls(t,e,r,n,i){let o=Matrix.zeros(n,i);if(null===r){let r=new CholeskyDecomposition(t);if(!0===r.isPositiveDefinite())o=r.solve(e);else{let r=new LuDecomposition(t);o=!1===r.isSingular()?r.solve(Matrix.eye(n)).mmul(e):solve(t,e,{useSVD:!0})}}else{let s=sortCollectionSet(r).values,a=sortCollectionSet(r).indices;if(1===s.length&&0===s[0].length&&a[0].length===i)return o;if(1===s.length&&s[0].length===n&&a[0].length===i){let r=new CholeskyDecomposition(t);if(!0===r.isPositiveDefinite())o=r.solve(e);else{let r=new LuDecomposition(t);o=!1===r.isSingular()?r.solve(Matrix.eye(n)).mmul(e):solve(t,e,{useSVD:!0})}}else for(let r=0;r0?h[t].push(e):l.set(e,t,0)}let u=[];for(let t=0;tt-e));return{Pset:o,Fset:i,W:s}}function fcnnls(t,e,r={}){t=Matrix.checkMatrix(t),e=Matrix.checkMatrix(e);let{l:n,p:i,iter:o,W:s,XtX:a,XtY:l,K:h,Pset:u,Fset:c,D:f}=initialisation(t,e);const{maxIterations:m=3*t.columns}=r;for(;c.length>0;){let t=cssls(a,l.subMatrixColumn(c),selection(u,c),n,c.length);for(let e=0;e0){let e=r.length,i=Matrix.ones(n,e);for(;e>0&&oe===g[t])),1);t=cssls(a,l.subMatrixColumn(r),selection(u,r),n,e);for(let n=0;n=t.length)throw new RangeError("invalid lower bound");if(void 0===i)i=t.length-1;else if((i|=0)=t.length)throw new RangeError("invalid upper bound");for(;n<=i;)if((s=+r(t[o=n+(i-n>>>1)],e,o,t))<0)n=o+1;else{if(!(s>0))return o;i=o-1}return~n};function assertNumber(t){if("number"!=typeof t)throw new TypeError("Expected a number")}var ascending=(t,e)=>(assertNumber(t),assertNumber(e),Number.isNaN(t)?-1:Number.isNaN(e)?1:t-e),descending=(t,e)=>(assertNumber(t),assertNumber(e),Number.isNaN(t)?1:Number.isNaN(e)?-1:e-t),numSort={ascending:ascending,descending:descending},index$4=Object.freeze(Object.assign(Object.create(null),numSort,{default:numSort,ascending:ascending,descending:descending}));const largestPrime=2147483647,primeNumbers=[largestPrime,5,11,23,47,97,197,397,797,1597,3203,6421,12853,25717,51437,102877,205759,411527,823117,1646237,3292489,6584983,13169977,26339969,52679969,105359939,210719881,421439783,842879579,1685759167,433,877,1759,3527,7057,14143,28289,56591,113189,226379,452759,905551,1811107,3622219,7244441,14488931,28977863,57955739,115911563,231823147,463646329,927292699,1854585413,953,1907,3821,7643,15287,30577,61169,122347,244703,489407,978821,1957651,3915341,7830701,15661423,31322867,62645741,125291483,250582987,501165979,1002331963,2004663929,1039,2081,4177,8363,16729,33461,66923,133853,267713,535481,1070981,2141977,4283963,8567929,17135863,34271747,68543509,137087021,274174111,548348231,1096696463,31,67,137,277,557,1117,2237,4481,8963,17929,35863,71741,143483,286973,573953,1147921,2295859,4591721,9183457,18366923,36733847,73467739,146935499,293871013,587742049,1175484103,599,1201,2411,4831,9677,19373,38747,77509,155027,310081,620171,1240361,2480729,4961459,9922933,19845871,39691759,79383533,158767069,317534141,635068283,1270136683,311,631,1277,2557,5119,10243,20507,41017,82037,164089,328213,656429,1312867,2625761,5251529,10503061,21006137,42012281,84024581,168049163,336098327,672196673,1344393353,3,7,17,37,79,163,331,673,1361,2729,5471,10949,21911,43853,87719,175447,350899,701819,1403641,2807303,5614657,11229331,22458671,44917381,89834777,179669557,359339171,718678369,1437356741,43,89,179,359,719,1439,2879,5779,11579,23159,46327,92657,185323,370661,741337,1482707,2965421,5930887,11861791,23723597,47447201,94894427,189788857,379577741,759155483,1518310967,379,761,1523,3049,6101,12203,24407,48817,97649,195311,390647,781301,1562611,3125257,6250537,12501169,25002389,50004791,100009607,200019221,400038451,800076929,1600153859,13,29,59,127,257,521,1049,2099,4201,8419,16843,33703,67409,134837,269683,539389,1078787,2157587,4315183,8630387,17260781,34521589,69043189,138086407,276172823,552345671,1104691373,19,41,83,167,337,677,1361,2729,5471,10949,21911,43853,87719,175447,350899,701819,1403641,2807303,5614657,11229331,22458671,44917381,89834777,179669557,359339171,718678369,1437356741,53,107,223,449,907,1823,3659,7321,14653,29311,58631,117269,234539,469099,938207,1876417,3752839,7505681,15011389,30022781,60045577,120091177,240182359,480364727,960729461,1921458943];function nextPrime(t){let e=binarySearch(primeNumbers,t,ascending);return e<0&&(e=~e),primeNumbers[e]}primeNumbers.sort(ascending);const FREE=0,FULL=1,REMOVED=2,defaultInitialCapacity=150,defaultMinLoadFactor=1/6,defaultMaxLoadFactor=2/3;class HashTable{constructor(t={}){if(t instanceof HashTable)return this.table=t.table.slice(),this.values=t.values.slice(),this.state=t.state.slice(),this.minLoadFactor=t.minLoadFactor,this.maxLoadFactor=t.maxLoadFactor,this.distinct=t.distinct,this.freeEntries=t.freeEntries,this.lowWaterMark=t.lowWaterMark,void(this.highWaterMark=t.maxLoadFactor);const e=void 0===t.initialCapacity?defaultInitialCapacity:t.initialCapacity;if(e<0)throw new RangeError("initial capacity must not be less than zero: "+e);const r=void 0===t.minLoadFactor?defaultMinLoadFactor:t.minLoadFactor,n=void 0===t.maxLoadFactor?defaultMaxLoadFactor:t.maxLoadFactor;if(r<0||r>=1)throw new RangeError("invalid minLoadFactor: "+r);if(n<=0||n>=1)throw new RangeError("invalid maxLoadFactor: "+n);if(r>=n)throw new RangeError(`minLoadFactor (${r}) must be smaller than maxLoadFactor (${n})`);let i=e;i=i/n|0,i=nextPrime(i),0===i&&(i=1),this.table=newArray$1(i),this.values=newArray$1(i),this.state=newArray$1(i),this.minLoadFactor=r,this.maxLoadFactor=i===largestPrime?1:n,this.distinct=0,this.freeEntries=i,this.lowWaterMark=0,this.highWaterMark=chooseHighWaterMark(i,this.maxLoadFactor)}clone(){return new HashTable(this)}get size(){return this.distinct}get(t){const e=this.indexOfKey(t);return e<0?0:this.values[e]}set(t,e){let r=this.indexOfInsertion(t);if(r<0)return r=-r-1,this.values[r]=e,!1;if(this.distinct>this.highWaterMark){const r=chooseGrowCapacity(this.distinct+1,this.minLoadFactor,this.maxLoadFactor);return this.rehash(r),this.set(t,e)}if(this.table[r]=t,this.values[r]=e,this.state[r]===FREE&&this.freeEntries--,this.state[r]=FULL,this.distinct++,this.freeEntries<1){const t=chooseGrowCapacity(this.distinct+1,this.minLoadFactor,this.maxLoadFactor);this.rehash(t)}return!0}remove(t,e){const r=this.indexOfKey(t);return!(r<0)&&(this.state[r]=REMOVED,this.distinct--,e||this.maybeShrinkCapacity(),!0)}delete(t,e){const r=this.indexOfKey(t);return!(r<0)&&(this.state[r]=FREE,this.distinct--,e||this.maybeShrinkCapacity(),!0)}maybeShrinkCapacity(){if(this.distinct=0}indexOfKey(t){const e=this.table,r=this.state,n=this.table.length,i=2147483647&t;let o=i%n,s=i%(n-2);for(0===s&&(s=1);r[o]!==FREE&&(r[o]===REMOVED||e[o]!==t);)o-=s,o<0&&(o+=n);return r[o]===FREE?-1:o}containsValue(t){return this.indexOfValue(t)>=0}indexOfValue(t){const e=this.values,r=this.state;for(var n=0;nthis.get(r,e)!==n?(t=!1,!1):n)),t}bandWidth(){let t=this.columns,e=-1;return this.forEachNonZero(((r,n,i)=>{let o=r-n;return t=Math.min(t,o),e=Math.max(e,o),i})),e-t}isBanded(t){return this.bandWidth()<=t}get cardinality(){return this.elements.size}get size(){return this.rows*this.columns}get(t,e){return this.elements.get(t*this.columns+e)}set(t,e,r){return this.threshold&&Math.abs(r)(t.forEachNonZero(((t,o,s)=>(r===t&&n.set(e,o,n.get(e,o)+i*s),s))),i))),n}kroneckerProduct(t){const e=this.rows,r=this.columns,n=t.rows,i=t.columns,o=new SparseMatrix(e*n,r*i,{initialCapacity:this.cardinality*t.cardinality});return this.forEachNonZero(((e,r,s)=>(t.forEachNonZero(((t,a,l)=>(o.set(n*e+t,i*r+a,s*l),l))),s))),o}forEachNonZero(t){return this.elements.forEachPair(((e,r)=>{const n=e/this.columns|0,i=e%this.columns;let o=t(n,i,r);return!1!==o&&(this.threshold&&Math.abs(o)(e[i]=t,r[i]=o,n[i]=s,i++,s))),{rows:e,columns:r,values:n}}setThreshold(t){return 0!==t&&t!==this.threshold&&(this.threshold=t,this.forEachNonZero(((t,e,r)=>r))),this}transpose(){let t=new SparseMatrix(this.columns,this.rows,{initialCapacity:this.cardinality});return this.forEachNonZero(((e,r,n)=>(t.set(r,e,n),n))),t}}SparseMatrix.prototype.klass="Matrix",SparseMatrix.identity=SparseMatrix.eye,SparseMatrix.prototype.tensorProduct=SparseMatrix.prototype.kroneckerProduct;var inplaceOperator="\n(function %name%(value) {\n if (typeof value === 'number') return this.%name%S(value);\n return this.%name%M(value);\n})\n",inplaceOperatorScalar="\n(function %name%S(value) {\n this.forEachNonZero((i, j, v) => v %op% value);\n return this;\n})\n",inplaceOperatorMatrix="\n(function %name%M(matrix) {\n matrix.forEachNonZero((i, j, v) => {\n this.set(i, j, this.get(i, j) %op% v);\n return v;\n });\n return this;\n})\n",staticOperator="\n(function %name%(matrix, value) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%(value);\n})\n",inplaceMethod="\n(function %name%() {\n this.forEachNonZero((i, j, v) => %method%(v));\n return this;\n})\n",staticMethod="\n(function %name%(matrix) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%();\n})\n";const operators=[["+","add"],["-","sub","subtract"],["*","mul","multiply"],["/","div","divide"],["%","mod","modulus"],["&","and"],["|","or"],["^","xor"],["<<","leftShift"],[">>","signPropagatingRightShift"],[">>>","rightShift","zeroFillRightShift"]];for(const operator of operators)for(let i=1;i=n);h++)a+=e[h],l+=t[h]*e[h];return agetSimilarity(e,r,t)}var index$5=Object.freeze({__proto__:null,treeSimilarity:treeSimilarity,getFunction:getFunction,createTree:createTree});function cosine(t,e){for(var r=t.length,n=0,i=0,o=0,s=0;s{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.slice();return e[0]=e[1],e},measures={acc:acc,err:err,fpr:fpr,tpr:tpr,fnr:fnr,tnr:tnr,ppv:ppv,npv:npv,pcfall:pcfall,pcmiss:pcmiss,lift:lift,rpp:rpp,rnp:rnp,threshold:threshold};class Performance{constructor(t,e,r){if(r=r||{},t.length!==e.length||t[0].length!==e[0].length)throw new Error("dimensions of prediction and target do not match");const n=t.length,i=t[0].length,o=!r.max,s=[];if(r.all)for(var a=0;at.pred-e.pred)):s.sort(((t,e)=>e.pred-t.pred));const h=this.cutoffs=[o?Number.MIN_VALUE:Number.MAX_VALUE],u=this.fp=[0],c=this.tp=[0];var f=0,m=0,g=s[0].pred,p=0,d=0;for(a=0;ar||e.size[1]>r)throw new RangeError("expanded value should not be bigger than the data length");for(i=0;i0;)e*=t--;return e}const defaultOptions$h={windowSize:5,derivative:1,polynomial:2,pad:"none",padValue:"replicate"};function savitzkyGolay(t,e,r){if((r=Object.assign({},defaultOptions$h,r)).windowSize%2==0||r.windowSize<5||!Number.isInteger(r.windowSize))throw new RangeError("Invalid window size (should be odd and at least 5 integer number)");if(r.derivative<0||!Number.isInteger(r.derivative))throw new RangeError("Derivative should be a positive integer");if(r.polynomial<1||!Number.isInteger(r.polynomial))throw new RangeError("Polynomial should be a positive integer");let n,i,o=Math.floor(r.windowSize/2);"pre"===r.pad&&(t=src$2(t,{size:o,value:r.padValue}));let s=new Array(t.length-2*o);if(5!==r.windowSize||2!==r.polynomial||1!==r.derivative&&2!==r.derivative){let t=Matrix.ones(r.windowSize,r.polynomial+1),e=-(r.windowSize-1)/2;for(let r=0;r>8&255]+creator[t[r]>>16&255]+creator[t[r]>>24&255];return e}function and(t,e){for(var r=new Array(t.length),n=0;n>5]&r)}function setBit(t,e,r){var n=e>>5,i=1<<31-e%32;return t[n]=r?i|t[n]:~i&t[n],t}function toBinaryString(t){for(var e="",r=0;r>>0).toString(2);e+="00000000000000000000000000000000".substr(n.length)+n}return e}function parseBinaryString(t){for(var e=t.length/32,r=new Array(e),n=0;n>>0).toString(16);e+="00000000".substr(n.length)+n}return e}function parseHexString(t){for(var e=t.length/8,r=new Array(e),n=0;nt.length)throw new RangeError(`Window size is higher than the data length ${n}>${t.length}`);if(i<0||!Number.isInteger(i))throw new RangeError("Derivative should be a positive integer");if(o<1||!Number.isInteger(o))throw new RangeError("Polynomial should be a positive integer");o>=6&&console.warn("You should not use polynomial grade higher than 5 if you are not sure that your data arises from such a model. Possible polynomial oscillation problems");let s=Math.floor(n/2),a=t.length,l=new Array(a),h=fullWeights(n,o,i),u=0,c=!0;Array.isArray(e)?c=!1:u=Math.pow(e,i);for(let r=0;r=0&&n0?(4*r-2)/(r*(2*e-r+1))*(t*GramPoly(t,e,r-1,n)+n*GramPoly(t,e,r-1,n-1))-(r-1)*(2*e+r)/(r*(2*e-r+1))*GramPoly(t,e,r-2,n):0===r&&0===n?1:0,i}function GenFact(t,e){let r=1;if(t>=e)for(let n=t-e+1;n<=t;n++)r*=n;return r}function Weight(t,e,r,n,i){let o=0;for(let s=0;s<=n;s++)o+=(2*s+1)*(GenFact(2*r,s)/GenFact(2*r+s+1,s+1))*GramPoly(t,r,s,0)*GramPoly(e,r,s,i);return o}function fullWeights(t,e,r){let n=new Array(t),i=Math.floor(t/2);for(let o=-i;o<=i;o++){n[o+i]=new Array(t);for(let t=-i;t<=i;t++)n[o+i][t+i]=Weight(t,o,i,e,r)}return n}function gsd(t,e,r={}){let{noiseLevel:n,sgOptions:i={windowSize:9,polynomial:3},smoothY:o=!0,heightFactor:s=0,broadRatio:a=0,maxCriteria:l=!0,minMaxRatio:h=25e-5,derivativeThreshold:u=-1,realTopDetection:c=!1}=r;const f=e.slice();let m=isEqualSpaced(t);void 0===n&&(n=m?getNoiseLevel(f):0);const g={m:1,b:n};l||(g.m=-1,g.b*=-1);for(let t=0;tb&&(b=Math.abs(d[t])),Math.abs(w[t])>S&&(S=Math.abs(w[t]));let A=null,E=null,R=new Array(w.length-2),k=new Array(w.length),N=new Array(w.length),T=new Array(w.length-2),C=0,I=0,O=0,L=0;for(let t=1;tu&&((p[t]0&&null!==A&&(k[I++]=A,N[O++]=E)),(p[t]>=p[t-1]&&p[t]>p[t+1]||p[t]>p[t-1]&&p[t]>=p[t+1])&&(A={x:M[t],index:t},v<0&&null!==E&&(k[I++]=A,N[O++]=E))),d[t]h*S&&(z[$++]={index:R[t],x:P,y:(w[R[t]]+g.b)/g.m,width:Math.abs(N[F].x-k[F].x),soft:T[t]},z[$-1].left=k[F],z[$-1].right=N[F],s)){let t=w[k[F].index],e=w[N[F].index];z[$-1].height=s*(z[$-1].y-(t+e)/2)}}z.length=$,c&&determineRealTop(z,M,w);for(let t=0;t{let e,r=0,n=Number.MAX_SAFE_INTEGER;for(let i=0;ir&&(r=e);return(r-n)/r<.05},getNoiseLevel=t=>{let e=0,r=0,n=t.length;for(let r=0;rt-e)),r=n%2==1?i[(n-1)/2]/.6745:.5*(i[n/2]+i[n/2-1])/.6745,r},determineRealTop=(t,e,r)=>{let n,i,o,s,a;for(let l=0;l=r[a-2]&&r[a-1]>=r[a]?a--:r[a+1]>=r[a]&&r[a+1]>=r[a+2]?a++:r[a-2]>=r[a-3]&&r[a-2]>=r[a-1]?a-=2:r[a+2]>=r[a+1]&&r[a+2]>=r[a+3]&&(a+=2),r[a-1]>0&&r[a+1]>0&&r[a]>=r[a-1]&&r[a]>=r[a+1]&&(r[a]!==r[a-1]||r[a]!==r[a+1])&&(n=20*Math.log10(r[a-1]),i=20*Math.log10(r[a]),o=20*Math.log10(r[a+1]),s=.5*(n-o)/(n-2*i+o),t[l].x=e[a]+(e[a]-e[a-1])*s,t[l].y=r[a]-.25*(r[a-1]-r[a+1])*s)};function sumOfGaussians(t){return function(e){let r,n=t.length/3,i=e.length,o=void 0===i?0:new Float64Array(i).fill(0);for(let s=0;sr[e]/=o));let s=e.length,a=new Float64Array(3*s),l=new Float64Array(3*s),h=new Float64Array(3*s),u=Math.abs(n[0]-n[1]);for(let t=0;tr[e]/=o));let s=Math.abs(n[0]-n[1]),a={damping:1.5,initialValues:new Float64Array([e.x,1,e.width]),minValues:new Float64Array([e.x-s,0,e.width/4]),maxValues:new Float64Array([e.x+s,1.25,4*e.width]),gradientDifference:s/1e4,maxIterations:100,errorTolerance:1e-4},l=levenbergMarquardt({x:n,y:i},singleGaussian,r=Object.assign({},a,r));return{parameters:[l.parameterValues[0],l.parameterValues[1]*o,l.parameterValues[2]],error:l.parameterError}}function sumOfLorentzians(t){return function(e){let r,n,i=t.length/3,o=e.length,s=void 0===o?0:new Float64Array(o).fill(0);for(let a=0;ar[e]/=o));let s=e.length,a=new Float64Array(3*s),l=new Float64Array(3*s),h=new Float64Array(3*s),u=Math.abs(n[0]-n[1]);for(let t=0;tr[e]/=o));let s=Math.abs(n[0]-n[1]),a={damping:1.5,initialValues:new Float64Array([e.x,1,e.width]),minValues:new Float64Array([e.x-s,.75,e.width/4]),maxValues:new Float64Array([e.x+s,1.25,4*e.width]),gradientDifference:s/1e4,maxIterations:100,errorTolerance:1e-4},l=levenbergMarquardt({x:n,y:i},singleLorentzian,r=Object.assign({},a,r));return{parameters:[l.parameterValues[0],l.parameterValues[1]*o,l.parameterValues[2]],error:l.parameterError}}function optimizePeaks(t,e,r,n={}){const{functionName:i="gaussian",factorWidth:o=4,optimizationOptions:s={damping:1.5,maxIterations:100,errorTolerance:1e-4}}=n;let a,l=[0],h=groupPeaks(t,o),u=[],c=1;"gaussian"===i&&(c=1.17741);for(let t=0;t1){if(a=sampleFunction(h[t].limits[0]-h[t].limits[1],h[t].limits[0]+h[t].limits[1],e,r,l),a[0].length>5){let t=[];"gaussian"===i?t=optimizeGaussianSum(a,n,s):"lorentzian"===i&&(t=optimizeLorentzianSum(a,n,s));for(let e=0;e5){let t=[];"gaussian"===i?t=optimizeSingleGaussian([a[0],a[1]],n,s):"lorentzian"===i&&(t=optimizeSingleLorentzian([a[0],a[1]],n,s));let{parameters:e}=t;u.push({x:e[0],y:e[1],width:e[2]*c,index:n.index})}}return u}function sampleFunction(t,e,r,n,i){let o=r.length,s=[],a=[],l=Math.sign(r[1]-r[0]);-1===l&&(i[0]=r.length-1);let h=Math.abs(e-t)/2,u=(t+e)/2,c=!1,f=i[0];for(;!c&&f=0;)Math.abs(r[f]-u)<=h?(s.push(r[f]),a.push(n[f]),f+=l):1===Math.sign(u-r[f])?f+=l:c=!0;return i[0]=f,[s,a]}function groupPeaks(t,e){let r,n,i=[],o=[],s=[t[0].x,e*t[0].width];for(let a=0;ar&&(r=t[a].x+e*t[a].width),n=s[0]-s[1],t[a].x-e*t[a].width=0;t--)if(Math.abs(o[t].limits[0]-o[t+1].limits[0])<(o[t].limits[1]+o[t+1].limits[1])/2){for(let e=0;er&&(r=o[t+1].limits[0]+o[t+1].limits[1]),n=o[t].limits[0]-o[t].limits[1],o[t+1].limits[0]-o[t+1].limits[1]=0;e--)t[e].soft&&n.push(t.splice(e,1)[0]);n.push({x:Number.MAX_VALUE});let a=[[n[0].x,n[0].y]],l=[n[0].index];for(let e=1;ei&&(i=n[e].y,o=e),l.push(n[e].index),s++;else{if(s>2){let e=optimizeSingleLorentzian(a,{x:n[o].x,y:i,width:Math.abs(a[0][0]-a[a.length-1][0])}),{parameters:r}=e;t.push({x:r[0],y:r[1],width:r[2],index:Math.floor(l.reduce(((t,e)=>t+e),0)/l.length),soft:!1})}else l.forEach((e=>{t.push(n[e])}));a=[[n[e].x,n[e].y]],l=[e],i=n[e].y,o=e,s=1}return t.sort((function(t,e){return t.x-e.x})),t}function broadenPeaks(t,e={}){const{factor:r=2,overlap:n=!1}=e;for(let e of t)e.right&&e.left?(e.from=e.x-(e.x-e.left.x)*r,e.to=e.x+(e.right.x-e.x)*r):(e.from=e.x-e.width/2*r,e.to=e.x+e.width/2*r);if(!n)for(let e=0;en.from&&(r.to=n.from=(r.to+n.from)/2)}for(let e of t)e.width=e.to-e.from;return t}var index$6=Object.freeze({__proto__:null,gsd:gsd,optimizePeaks:optimizePeaks,joinBroadPeaks:joinBroadPeaks,broadenPeaks:broadenPeaks});const toString$4=Object.prototype.toString;function isAnyArray$4(t){return toString$4.call(t).endsWith("Array]")}function min$1(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray$4(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,i=e.toIndex,o=void 0===i?t.length:i;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=n||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray$4(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,i=e.toIndex,o=void 0===i?t.length:i;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=n||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;as&&(s=t[a]);return s}function mode$1(t){if(!isAnyArray$4(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");for(var e=0,r=0,n=0,i={},o=0;or&&(r=n,e=t[o])}return e}const toString$5=Object.prototype.toString;function isAnyArray$5(t){return toString$5.call(t).endsWith("Array]")}function max$2(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray$5(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,i=e.toIndex,o=void 0===i?t.length:i;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=n||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;as&&(s=t[a]);return s}function norm$1(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.algorithm,i=void 0===n?"absolute":n,o=r.sumValue,s=void 0===o?1:o,a=r.maxValue,l=void 0===a?1:a;if(!isAnyArray$5(t))throw new Error("input must be an array");if(void 0!==r.output){if(!isAnyArray$5(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);if(0===t.length)throw new Error("input must not be empty");switch(i.toLowerCase()){case"absolute":var h=absoluteSum(t)/s;if(0===h)return t.slice(0);for(var u=0;u0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==_typeof(t)||isAnyArray$4(t)||(e=t,t=[]),!isAnyArray$4(t))throw new TypeError("input must be an array");var r=e,n=r.from,i=void 0===n?0:n,o=r.to,s=void 0===o?10:o,a=r.size,l=void 0===a?t.length:a,h=r.step;if(0!==l&&h)throw new Error("step is defined by the array size");if(l||(l=h?Math.floor((s-i)/h)+1:s-i+1),!h&&l&&(h=(s-i)/(l-1)),Array.isArray(t)){t.length=0;for(var u=0;u1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray$6(t))throw new TypeError("input must be an array");for(var r=e.unbiased,n=void 0===r||r,i=e.mean,o=void 0===i?mean(t):i,s=0,a=0;a1&&void 0!==arguments[1]?arguments[1]:{};return Math.sqrt(variance(t,e))}function mergeByCentroids(t,e,r={}){const{window:n=.01}=r;for(var i={x:e.slice(),y:new Array(e.length).fill(0)},o=0,s=0;o=0?{x:r[s],y:n[s]}:(s=~s,0!==s&&Math.abs(r[s]-i)>.5||s===r.length?{x:r[s-1],y:n[s-1]}:{x:r[s],y:n[s]})}function covariance$1(t,e={}){const{x:r,y:n}=t,{unbiased:i=!0}=e,o=mean(r),s=mean(n);var a=0;for(let t=0;ti?(s.x.push(r[l]),s.y.push(n[l]),o.x.push(r[l]),o.y.push(n[l]),l++,a++):(n[l]>s.y[a-1]&&(s.x[a-1]=r[l],s.y[a-1]=n[l]),o.x[a-1]=r[l],o.y[a-1]+=n[l],l++);return o.x=s.x.slice(),o}function maxY(t,e={}){const{x:r,y:n}=t;let{from:i={index:0},to:o={index:r.length},reverse:s=!1}=e;void 0!==i.value&&void 0===i.index&&(i.index=calculateIndex(i.value,r,s)),void 0!==o.value&&void 0===o.index&&(o.index=calculateIndex(o.value,r,s));for(var a,l=Number.MIN_VALUE,h=i.index;he.x-t.x:(t,e)=>t.x-e.x;for(var s=r.map(((t,e)=>({x:t,y:n[e]}))).sort(o),a={x:r.slice(),y:n.slice()},l=0;li?(s.x.push(r[l]*n[l]),s.y.push(n[l]),o.x.push(r[l]),o.y.push(n[l]),l++,a++):(s.x[a-1]+=r[l]*n[l],s.y[a-1]+=n[l],o.x[a-1]=r[l],o.y[a-1]+=n[l],l++);for(var h=0;hn&&([r,n]=[n,r]),(t=(t=JSON.parse(JSON.stringify(t)).map((t=>t.from>t.to?{from:t.to,to:t.from}:t))).sort(((t,e)=>t.from!==e.from?t.from-e.from:t.to-e.to))).forEach((t=>{r>t.from&&(t.from=r),nt.from<=t.to))).length)return[];let i=t[0],o=[i];for(let e=1;en&&([r,n]=[n,r]),0===(t=normalize(t,{from:r,to:n})).length)return[{from:r,to:n}];let i=[];for(let e=0;er&&i.push({from:r,to:o.from}),e===t.length-1?o.tot+(e.to-e.from)),0)/e,i=0;for(let r=0;r=0;){if(A=integral(0,f-m,y,g),v=w+A,l[S++]=(v-M)/s,S===i)break t;c=f,f+=s,M=v}w+=integral(m,p,y,x),m=p,g=d,b=p)throw new Error("x must be an increasing serie");for(;m-f>0;){if(y&&(M++,y=!1),u[b]=M<=0?0:x/M,b++,b===i)break t;c=f,f+=s,x=0,M=0}m>c&&(x+=g,M++),(m===-Number.MAX_VALUE||w>1)&&M--,m=p,g=d,v1&&r[0]>r[1]&&(r=r.slice().reverse(),n=n.slice().reverse(),o=!0);let{from:s=r[0],to:a=r[i-1],variant:l="smooth",numberOfPoints:h=100,exclusions:u=[],zones:c=[]}=e;if(i!==n.length)throw new RangeError("the x and y vector doesn't have the same size.");if("number"!=typeof s||isNaN(s))throw new RangeError("'from' option must be a number");if("number"!=typeof a||isNaN(a))throw new RangeError("'to' option must be a number");if("number"!=typeof h||isNaN(h))throw new RangeError("'numberOfPoints' option must be a number");if(h<2)throw new RangeError("'numberOfPoints' option must be greater than 1");0===c.length&&(c=invert(u,{from:s,to:a})),c=zonesWithPoints(c,h,{from:s,to:a});let f=[],m=[];for(let t of c){let e=processZone(r,n,t.from,t.to,t.numberOfPoints,l);f=f.concat(e.x),m=m.concat(e.y)}return o?se&&([t,e]=[e,t]),r=r.filter((t=>void 0!==t.from&&void 0!==t.to)),(r=JSON.parse(JSON.stringify(r))).forEach((t=>{t.from>t.to&&([t.to,t.from]=[t.from,t.to])})),r.sort(((t,e)=>t.from-e.from)),r.forEach((r=>{r.frome&&(r.to=e)}));for(let t=0;tr[t+1].from&&(r[t].to=r[t+1].from);if(!(r=r.filter((t=>t.from=a[l].from)h.push(r[c]),u.push(n[c]);else if(r[c]>a[l].to&&(l++,!a[l]))break;c++}return{x:h,y:u}}const{Matrix:Matrix$2,SVD:SVD,EVD:EVD,CholeskyDecomposition:CholeskyDecomposition$1,LuDecomposition:LuDecomposition$1,QrDecomposition:QrDecomposition$1}=MatrixLib,Array$1={min:min$1,max:max$1,median:median,mean:mean,mode:mode$1,normed:norm$1,rescale:rescale,sequentialFill:sequentialFill,standardDeviation:standardDeviation,sum:sum,variance:variance},ArrayXY={centroidsMerge:mergeByCentroids,closestX:closestX,covariance:covariance$1,maxMerge:maxMerge,maxY:maxY,sortX:sortX,uniqueX:uniqueX,weightedMerge:weightedMerge,equallySpaced:equallySpaced,filterX:filterX};exports.Array=Array$1,exports.ArrayXY=ArrayXY,exports.BitArray=src$3,exports.CholeskyDecomposition=CholeskyDecomposition$1,exports.ConfusionMatrix=ConfusionMatrix,exports.CrossValidation=index$2,exports.DecisionTreeClassifier=DecisionTreeClassifier,exports.DecisionTreeRegression=DecisionTreeRegression,exports.Distance=distances,exports.EVD=EVD,exports.ExponentialRegression=ExponentialRegression,exports.FCNNLS=index$3,exports.FNN=FeedForwardNeuralNetwork,exports.GSD=index$6,exports.HClust=index,exports.HashTable=HashTable,exports.KMeans=kmeans,exports.KNN=KNN,exports.KOPLS=KOPLS,exports.Kernel=kernel,exports.LuDecomposition=LuDecomposition$1,exports.Matrix=Matrix$2,exports.MatrixLib=MatrixLib,exports.MultivariateLinearRegression=MultivariateLinearRegression,exports.NaiveBayes=index$1,exports.OPLS=OPLS,exports.OPLSNipals=OPLSNipals,exports.PCA=PCA,exports.PLS=PLS,exports.Performance=src$1,exports.PolynomialRegression=PolynomialRegression,exports.PowerRegression=PowerRegression,exports.QrDecomposition=QrDecomposition$1,exports.Random=Random,exports.RandomForestClassifier=RandomForestClassifier,exports.RandomForestRegression=RandomForestRegression,exports.RobustPolynomialRegression=RobustPolynomialRegression,exports.SOM=src,exports.SVD=SVD,exports.Similarity=similarities,exports.SimpleLinearRegression=SimpleLinearRegression,exports.SparseMatrix=SparseMatrix,exports.TheilSenRegression=TheilSenRegression,exports.XSadd=XSadd,exports.binarySearch=binarySearch,exports.distanceMatrix=distanceMatrix,exports.levenbergMarquardt=levenbergMarquardt,exports.numSort=index$4,exports.padArray=src$2,exports.savitzkyGolay=savitzkyGolay,Object.defineProperty(exports,"__esModule",{value:!0})})); + */function Node(t,e,r){this.obj=t,this.left=null,this.right=null,this.parent=r,this.dimension=e}class KDTree{constructor(t,e){if(Array.isArray(t)){this.dimensions=new Array(t[0].length);for(var r=0;re&&s.pop()}for(f=0;ft[n[i]]-e[n[i]]));const o=Math.floor(t.length/2),s=new Node(t[o],i,r);return s.left=buildTree(t.slice(0,o),e+1,s,n),s.right=buildTree(t.slice(o+1),e+1,s,n),s}function restoreParent(t){t.left&&(t.left.parent=t,restoreParent(t.left)),t.right&&(t.right.parent=t,restoreParent(t.right))}class BinaryHeap{constructor(t){this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.bubbleUp(this.content.length-1)}pop(){var t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.sinkDown(0)),t}peek(){return this.content[0]}size(){return this.content.length}bubbleUp(t){for(var e=this.content[t];t>0;){const r=Math.floor((t+1)/2)-1,n=this.content[r];if(!(this.scoreFunction(e)o&&(i=h,o=u)}return i}function norm(t){return Math.sqrt(t.clone().apply(pow2array).sum())}function pow2array(t,e){this.set(t,e,this.get(t,e)**2)}function initializeMatrices(t,e){if(e)for(let e=0;em&&Mm;)n=a.mmul(f),n.div(norm(n)),r=c,c=t.mmul(n),i=l.mmul(c),i.div(norm(i)),f=e.mmul(i);r=c;let v=a.mmul(r),b=r.transpose().mmul(r).get(0,0);o=v.div(b);let S=norm(o);o.div(S),r.mul(S),n.mul(S),v=f.transpose().mmul(r),b=r.transpose().mmul(r).get(0,0);let A=v.div(b).get(0,0);t.sub(r.mmul(o.transpose())),e.sub(r.clone().mul(A).mmul(i.transpose())),g.setColumn(M,r),p.setColumn(M,o),d.setColumn(M,f),w.setColumn(M,i),y.setColumn(M,n),x.set(M,M,A),M++}M--,g=g.subMatrix(0,g.rows-1,0,M),p=p.subMatrix(0,p.rows-1,0,M),d=d.subMatrix(0,d.rows-1,0,M),w=w.subMatrix(0,w.rows-1,0,M),y=y.subMatrix(0,y.rows-1,0,M),x=x.subMatrix(0,M,0,M),this.ssqYcal=c,this.E=t,this.F=e,this.T=g,this.P=p,this.U=d,this.Q=w,this.W=y,this.B=x,this.PBQ=p.mmul(x).mmul(w.transpose()),this.R2X=r.transpose().mmul(r).mmul(o.transpose().mmul(o)).div(u).get(0,0)}predict(t){let e=Matrix.checkMatrix(t);this.scale&&(e=e.subRowVector(this.meanX).divRowVector(this.stdDevX));let r=e.mmul(this.PBQ);return r=r.mulRowVector(this.stdDevY).addRowVector(this.meanY),r}getExplainedVariance(){return this.R2X}toJSON(){return{name:"PLS",R2X:this.R2X,meanX:this.meanX,stdDevX:this.stdDevX,meanY:this.meanY,stdDevY:this.stdDevY,PBQ:this.PBQ,tolerance:this.tolerance,scale:this.scale}}static load(t){if("PLS"!==t.name)throw new RangeError("Invalid model: "+t.name);return new PLS(!0,t)}}function maxSumColIndex(t){return Matrix.rowVector(t.sum("column")).maxIndex()[0]}class KOPLS{constructor(t,e){if(!0===t)this.trainingSet=new Matrix(e.trainingSet),this.YLoadingMat=new Matrix(e.YLoadingMat),this.SigmaPow=new Matrix(e.SigmaPow),this.YScoreMat=new Matrix(e.YScoreMat),this.predScoreMat=initializeMatrices(e.predScoreMat,!1),this.YOrthLoadingVec=initializeMatrices(e.YOrthLoadingVec,!1),this.YOrthEigen=e.YOrthEigen,this.YOrthScoreMat=initializeMatrices(e.YOrthScoreMat,!1),this.toNorm=initializeMatrices(e.toNorm,!1),this.TURegressionCoeff=initializeMatrices(e.TURegressionCoeff,!1),this.kernelX=initializeMatrices(e.kernelX,!0),this.kernel=e.kernel,this.orthogonalComp=e.orthogonalComp,this.predictiveComp=e.predictiveComp;else{if(void 0===t.predictiveComponents)throw new RangeError("no predictive components found!");if(void 0===t.orthogonalComponents)throw new RangeError("no orthogonal components found!");if(void 0===t.kernel)throw new RangeError("no kernel found!");this.orthogonalComp=t.orthogonalComponents,this.predictiveComp=t.predictiveComponents,this.kernel=t.kernel}}train(t,e){t=Matrix.checkMatrix(t),e=Matrix.checkMatrix(e),this.trainingSet=t.clone();let r=this.kernel.compute(t),n=Matrix.eye(r.rows,r.rows,1),i=r;r=new Array(this.orthogonalComp+1);for(let t=0;t=0&&s>=0&&i[o][s]++}return new ConfusionMatrix(i,n)}getMatrix(){return this.matrix}getLabels(){return this.labels}getTotalCount(){let t=0;for(let e=0;e=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return n("end");if(s.tryLoc<=this.prev){var l=i.call(s,"catchLoc"),h=i.call(s,"finallyLoc");if(l&&h){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;C(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:I(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),g}}}function y(t,e,r,n){var i=e&&e.prototype instanceof v?e:v,o=Object.create(i.prototype),s=new T(n||[]);return o._invoke=R(t,r,s),o}function M(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}function v(){}function b(){}function S(){}function A(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function E(t){function e(r,n,o,s){var a=M(t[r],t,n);if("throw"!==a.type){var l=a.arg,h=l.value;return h&&"object"==typeof h&&i.call(h,"__await")?Promise.resolve(h.__await).then((function(t){e("next",t,o,s)}),(function(t){e("throw",t,o,s)})):Promise.resolve(h).then((function(t){l.value=t,o(l)}),s)}s(a.arg)}var r;function n(t,n){function i(){return new Promise((function(r,i){e(t,n,r,i)}))}return r=r?r.then(i,i):i()}this._invoke=n}function R(t,e,r){var n=u;return function(i,o){if(n===m)throw new Error("Generator is already running");if(n===f){if("throw"===i)throw o;return O()}for(r.method=i,r.arg=o;;){var s=r.delegate;if(s){var a=k(s,r);if(a){if(a===g)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===u)throw n=f,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=m;var l=M(t,e,r);if("normal"===l.type){if(n=r.done?f:c,l.arg===g)continue;return{value:l.arg,done:r.done}}"throw"===l.type&&(n=f,r.method="throw",r.arg=l.arg)}}}function k(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,k(t,e),"throw"===e.method))return g;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return g}var i=M(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,g):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function N(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(N,this),this.reset(!0)}function I(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n=0,o=i&&n.regeneratorRuntime;n.regeneratorRuntime=void 0;var s=r;if(i)n.regeneratorRuntime=o;else try{delete n.regeneratorRuntime}catch(t){n.regeneratorRuntime=void 0}var a=s,l={mode:"index"};t.exports=a.mark((function t(e,r,n){var i,o,s,h,u,c,m,f,g;return a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(g=function(){var t,e,r;for(e=1;h[e]<=0;)e++;if(0===h[e-1]){for(t=e-1;1!==t;t--)h[t]=-1;h[e]=0,u=m=0,h[1]=1,c=e-1}else{e>1&&(h[e-1]=0);do{e++}while(h[e]>0);for(r=e-1,t=e;0===h[t];)h[t++]=-1;if(-1===h[t])h[t]=h[r],m=h[r]-1,u=t-1,c=r-1,h[r]=-1;else{if(t===h[0])return 0;h[e]=h[t],m=h[t]-1,h[t]=0,u=e-1,c=t-1}}return 1},n=Object.assign({},l,n),i=new Array(r),o=new Array(e),s=new Array(r),h=new Array(r+2),f=0;fs[e-1].push(t))),s=s.slice(0,e),s.map(((t,e)=>({testIndex:t,trainIndex:[].concat(...s.filter(((t,r)=>r!==e)))})))}function sampleAClass(t,e){let r=JSON.parse(JSON.stringify(t)),n=Array.from(Array(r.length).keys()).sort(((t,e)=>r[t]ti[t]=(i[t]||0)+1));let o=[];Object.keys(i).forEach(((t,r)=>{let n=[];Object.values(i).reduce(((t,e,r)=>n[r]=t+e),0);let s=[...Array(i[t]).keys()],a=[];for(let r=0;rt+n[r-1])))}));let s=[];o.forEach((t=>s.push(n[t])));let a=[],l=[];return t.forEach(((t,e)=>{s.includes(e)?l.push(!0):(l.push(!1),a.push(e))})),{trainIndex:s,testIndex:a,mask:l}}function leaveOneOut(t,e,r,n){if("function"==typeof r){let n=r;return r=e,leavePOut(e=t,r,1,n)}return leavePOut(t,e,r,n,1)}function leavePOut(t,e,r,n,i){let o;"function"==typeof n&&(o=n,i=r,r=e,e=t),check(e,r);const s=getDistinct(r),a=initMatrix(s.length,s.length);let l=e.length,h=lib(i,l),u=new Array(l);for(let t=0;t=0;t--)l.splice(i[t],1);o?validateWithCallback(e,r,i,l,a,s,o):validate(t,e,r,n,i,l,a,s)}return new ConfusionMatrix(a,s)}function kFold(t,e,r,n,i){let o;"function"==typeof n&&(o=n,i=r,r=e,e=t),check(e,r);const s=getDistinct(r),a=initMatrix(s.length,s.length);let l=getFolds(e,i);for(let i=0;inew Array(e).fill(0)))}function getDistinct(t){let e=new Set;for(let r=0;r1e-10;t++)s=u.transpose().mmul(l).div(u.transpose().mmul(u).get(0,0)),s=s.transpose().div(norm(s)),i=l.mmul(s).div(s.transpose().mmul(s).get(0,0)),o=i.transpose().mmul(h).div(i.transpose().mmul(i).get(0,0)),a=h.mmul(o.transpose()),a=a.div(o.transpose().mmul(o).get(0,0)),t>0&&(c=a.clone().sub(u).pow(2).sum()/a.clone().pow(2).sum()),u=a.clone();let m=i.transpose().mmul(l).div(i.transpose().mmul(i).get(0,0)),f=m.clone().sub(s.transpose().mmul(m.transpose()).div(s.transpose().mmul(s).get(0,0)).mmul(s.transpose()));f.div(norm(f));let g=l.mmul(f.transpose()).div(f.mmul(f.transpose()).get(0,0)),p=g.transpose().mmul(l).div(g.transpose().mmul(g).get(0,0));return{filteredX:l.clone().sub(g.mmul(p)),weightsXOrtho:f,loadingsXOrtho:p,scoresXOrtho:g,weightsXPred:s,loadingsXpred:m,scoresXpred:i,loadingsY:o}}function tss(t){return Matrix.mul(t,t).sum()}class OPLS{constructor(t,e,r={}){if(!0===t){const t=r;return this.center=t.center,this.scale=t.scale,this.means=t.means,this.meansY=t.meansY,this.stdevs=t.stdevs,this.stdevs=t.stdevsY,this.model=t.model,this.tCV=t.tCV,this.tOrthCV=t.tOrthCV,this.yHatCV=t.yHatCV,void(this.mode=t.mode)}let n=t.clone();const{nComp:i=3,center:o=!0,scale:s=!0,cvFolds:a=[]}=r;let l,h;if("number"==typeof e[0])this.mode="regression",l=Matrix.from1DArray(e.length,1,e);else if("string"==typeof e[0])throw this.mode="discriminantAnalysis",l=e,new Error("discriminant analysis is not yet supported");if("Matrix"!==n.constructor.name)throw new TypeError("features must be of class Matrix");this.center=o,this.center?(this.means=n.mean("column"),this.meansY=l.mean("column")):this.stdevs=null,this.scale=s,this.scale?(this.stdevs=n.standardDeviation("column"),this.stdevsY=l.standardDeviation("column")):this.means=null,h=a.length>0?a:getFolds(e,5);let u=[];this.model=[],this.tCV=[],this.tOrthCV=[],this.yHatCV=[];let c,m=[],f=[];for(c=0;ct.R2x)),A=this.model.map((t=>t.R2y));this.output={Q2y:u,R2x:S,R2y:A,tPred:d.plsC.t,pPred:d.plsC.p,wPred:d.plsC.w,betasPred:d.plsC.betas,Qpc:d.plsC.q,tCV:g,tOrthCV:p,tOrth:d.tOrth,pOrth:d.pOrth,wOrth:d.wOrth,XOrth:w,yHat:d.totalPred,Yres:d.plsC.yResidual,E:b}}getLogs(){return this.output}getScores(){return{scoresX:this.tCV.map((t=>t.to1DArray())),scoresY:this.tOrthCV.map((t=>t.to1DArray()))}}static load(t){if("string"!=typeof t.name)throw new TypeError("model must have a name property");if("OPLS"!==t.name)throw new RangeError("invalid model: "+t.name);return new OPLS(!0,[],t)}toJSON(){return{name:"OPLS",center:this.center,scale:this.scale,means:this.means,stdevs:this.stdevs,model:this.model,tCV:this.tCV,tOrthCV:this.tOrthCV,yHatCV:this.yHatCV}}predict(t,e={}){let{trueLabels:r=[],nc:n=1}=e,i=[];r.length>0&&(r=Matrix.from1DArray(r.length,1,r),i=r.clone());let o=t.clone();this.center&&(o.center("column",{center:this.means}),i.rows>0&&"regression"===this.mode&&i.center("column",{center:this.meansY})),this.scale&&(o.scale("column",{scale:this.stdevs}),i.rows>0&&"regression"===this.mode&&i.scale("column",{scale:this.stdevsY}));let s,a,l,h,u,c=o.clone();for(let t=0;t0))return{tPred:u,tOrth:s,yHat:h};if("regression"===this.mode){let t=tss(i);return{tPred:u,tOrth:s,yHat:h,Q2y:1-tss(i.clone().sub(h))/t}}if("discriminantAnalysis"===this.mode){let t=[];return t=ConfusionMatrix.fromLabels(r.to1DArray(),h.to1DArray()),{tPred:u,tOrth:s,yHat:h,confusionMatrix:t}}}_predictAll(t,e,r={}){const{center:n=!0,scale:i=!0}=r;n&&(t.center("column"),e.center("column")),i&&(t.scale("column"),e.scale("column"),this.tssy=tss(e),this.tssx=tss(t));let o=OPLSNipals(t,e),s=new nipals(o.filteredX,{Y:e}),a=o.filteredX.mmul(s.w.transpose()),l=a.mmul(s.betas);return{R2y:1-tss(e.clone().sub(l))/this.tssy,R2x:tss(s.t.mmul(s.p))/this.tssx,xRes:o.filteredX,tOrth:o.scoresXOrtho,pOrth:o.loadingsXOrtho,wOrth:o.weightsXOrtho,tPred:a,totalPred:l,XOrth:o.scoresXOrtho.mmul(o.loadingsXOrtho),oplsC:o,plsC:s}}_getTrainTest(t,e,r){let n=new Matrix(r.testIndex.length,t.columns),i=new Matrix(r.testIndex.length,1);r.testIndex.forEach(((r,o)=>{n.setRow(o,t.getRow(r)),i.setRow(o,e.getRow(r))}));let o=new Matrix(r.trainIndex.length,t.columns),s=new Matrix(r.trainIndex.length,1);return r.trainIndex.forEach(((r,n)=>{o.setRow(n,t.getRow(r)),s.setRow(n,e.getRow(r))})),{trainFeatures:o,testFeatures:n,trainLabels:s,testLabels:i}}}var require$$0=getAugmentedNamespace(MatrixLib);function logistic(t){return 1/(1+Math.exp(-t))}function expELU(t,e){return t<0?e*(Math.exp(t)-1):t}function softExponential(t,e){return e<0?-Math.log(1-e*(t+e))/e:e>0?(Math.exp(e*t)-1)/e+e:t}function softExponentialPrime(t,e){return e<0?1/(1-e*(e+t)):Math.exp(e*t)}const ACTIVATION_FUNCTIONS={tanh:{activation:Math.tanh,derivate:t=>1-t*t},identity:{activation:t=>t,derivate:()=>1},logistic:{activation:logistic,derivate:t=>logistic(t)*(1-logistic(t))},arctan:{activation:Math.atan,derivate:t=>1/(t*t+1)},softsign:{activation:t=>t/(1+Math.abs(t)),derivate:t=>1/((1+Math.abs(t))*(1+Math.abs(t)))},relu:{activation:t=>t<0?0:t,derivate:t=>t<0?0:1},softplus:{activation:t=>Math.log(1+Math.exp(t)),derivate:t=>1/(1+Math.exp(-t))},bent:{activation:t=>(Math.sqrt(t*t+1)-1)/2+t,derivate:t=>t/(2*Math.sqrt(t*t+1))+1},sinusoid:{activation:Math.sin,derivate:Math.cos},sinc:{activation:t=>0===t?1:Math.sin(t)/t,derivate:t=>0===t?0:Math.cos(t)/t-Math.sin(t)/(t*t)},gaussian:{activation:t=>Math.exp(-t*t),derivate:t=>-2*t*Math.exp(-t*t)},"parametric-relu":{activation:(t,e)=>t<0?e*t:t,derivate:(t,e)=>t<0?e:1},"exponential-elu":{activation:expELU,derivate:(t,e)=>t<0?expELU(t,e)+e:1},"soft-exponential":{activation:softExponential,derivate:softExponentialPrime}};class Layer{constructor(t){this.inputSize=t.inputSize,this.outputSize=t.outputSize,this.regularization=t.regularization,this.epsilon=t.epsilon,this.activation=t.activation,this.activationParam=t.activationParam;var e=ACTIVATION_FUNCTIONS[t.activation],r=e.activation.length,n=r>1?r=>e.activation(r,t.activationParam):e.activation,i=r>1?r=>e.derivate(r,t.activationParam):e.derivate;this.activationFunction=function(t,e){this.set(t,e,n(this.get(t,e)))},this.derivate=function(t,e){this.set(t,e,i(this.get(t,e)))},t.model?(this.W=require$$0.Matrix.checkMatrix(t.W),this.b=require$$0.Matrix.checkMatrix(t.b)):(this.W=require$$0.Matrix.rand(this.inputSize,this.outputSize),this.b=require$$0.Matrix.zeros(1,this.outputSize),this.W.apply((function(e,r){this.set(e,r,this.get(e,r)/Math.sqrt(t.inputSize))})))}forward(t){var e=t.mmul(this.W).addRowVector(this.b);return e.apply(this.activationFunction),this.a=e.clone(),e}backpropagation(t,e){this.dW=e.transpose().mmul(t),this.db=require$$0.Matrix.rowVector(t.sum("column"));var r=e.clone();return t.mmul(this.W.transpose()).mul(r.apply(this.derivate))}update(){this.dW.add(this.W.clone().mul(this.regularization)),this.W.add(this.dW.mul(-this.epsilon)),this.b.add(this.db.mul(-this.epsilon))}toJSON(){return{model:"Layer",inputSize:this.inputSize,outputSize:this.outputSize,regularization:this.regularization,epsilon:this.epsilon,activation:this.activation,W:this.W,b:this.b}}static load(t){if("Layer"!==t.model)throw new RangeError("the current model is not a Layer model");return new Layer(t)}}class OutputLayer extends Layer{constructor(t){super(t),this.activationFunction=function(t,e){this.set(t,e,Math.exp(this.get(t,e)))}}static load(t){if("Layer"!==t.model)throw new RangeError("the current model is not a Layer model");return new OutputLayer(t)}}class FeedForwardNeuralNetworks{constructor(t){if((t=t||{}).model){this.hiddenLayers=t.hiddenLayers,this.iterations=t.iterations,this.learningRate=t.learningRate,this.regularization=t.regularization,this.dicts=t.dicts,this.activation=t.activation,this.activationParam=t.activationParam,this.model=new Array(t.layers.length);for(var e=0;e=0;--n){var o=n>0?this.model[n-1].a:t;i=this.model[n].backpropagation(i,o)}for(n=0;n0?e=this[t]-1:this.som.torus&&(e=this.som.gridDim[t]-1),void 0!==e)"x"===t?(r=e,n=this.y):(r=this.x,n=e),this.neighbors[t][0]=this.som.nodes[r][n];this[t]0&&e>0))throw new Error("x and y must be positive");this.times={findBMU:0,adjust:0},this.randomizer=this.options.randomizer,this.iterationCount=0,this.iterations=this.options.iterations,this.startLearningRate=this.learningRate=this.options.learningRate,this.mapRadius=Math.floor(Math.max(t,e)/2),this.algorithmMethod=this.options.method,this._initNodes(),this.done=!1}else this.done=!0}function getConverters(t){for(var e=t.length,r=new Array(e),n=new Array(e),i=0;i0?("random"===this.algorithmMethod?(t=this.mapRadius*Math.exp(-this.iterationCount/this.timeConstant),e=getRandomValue(this.trainingSet,this.randomizer),this._adjust(e,t),this.learningRate=this.startLearningRate*Math.exp(-this.iterationCount/this.numIterations)):(r=-Math.floor(this.iterationCount/this.trainingSet.length),t=this.mapRadius*Math.exp(r/this.timeConstant),e=this.trainingSet[this.iterationCount%this.trainingSet.length],this._adjust(e,t),(this.iterationCount+1)%this.trainingSet.length==0&&(this.learningRate=this.startLearningRate*Math.exp(r/Math.floor(this.numIterations/this.trainingSet.length)))),this.iterationCount++,!0):(this.done=!0,!1));var t,e,r},SOM.prototype._adjust=function(t,e){var r,n,i,o,s=Date.now(),a=this._findBestMatchingUnit(t),l=Date.now();this.times.findBMU+=l-s;var h=Math.floor(e),u=a.x-h,c=a.x+h,m=a.y-h,f=a.y+h;for(r=u;r<=c;r++){var g=r;for(r<0?g+=this.x:r>=this.x&&(g-=this.x),n=m;n<=f;n++){var p=n;n<0?p+=this.y:n>=this.y&&(p-=this.y),(i=a[this.distanceMethod](this.nodes[g][p]))0&&e!==this.coefficients.length-1?s=" + "+s:e!==this.coefficients.length-1&&(s=" "+s)),o=s+o;return"+"===o.charAt(0)&&(o=o.slice(1)),"f(x) = "+o}static load(t){if("polynomialRegression"!==t.name)throw new TypeError("not a polynomial regression model");return new PolynomialRegression(!0,t)}}function regress(t,e,r,n){const i=e.length;let o;if(Array.isArray(n))o=n,n=o.length;else{n++,o=new Array(n);for(let t=0;t=0?`f(x) = ${maybeToPrecision(this.B,t)}e^{${maybeToPrecision(this.A,t)}x}`:`f(x) = \\frac{${maybeToPrecision(this.B,t)}}{e^{${maybeToPrecision(-this.A,t)}x}}`}static load(t){if("exponentialRegression"!==t.name)throw new TypeError("not a exponential regression model");return new ExponentialRegression(!0,t)}}function regress$2(t,e,r){const n=e.length,i=new Array(n);for(let t=0;t=0?`f(x) = ${maybeToPrecision(this.A,t)}x^{${maybeToPrecision(this.B,t)}}`:`f(x) = \\frac{${maybeToPrecision(this.A,t)}}{x^{${maybeToPrecision(-this.B,t)}}}`,e=e.replace(/e([+-]?[0-9]+)/g,"e^{$1}"),e}static load(t){if("powerRegression"!==t.name)throw new TypeError("not a power regression model");return new PowerRegression(!0,t)}}function regress$3(t,e,r){const n=e.length,i=new Array(n),o=new Array(n);for(let t=0;tMath.pow(t[0],2))).reduce(((t,e)=>t+e))/(e.rows-t.columns);this.stdError=Math.sqrt(n),this.stdErrorMatrix=pseudoInverse(o).mul(n),this.stdErrors=this.stdErrorMatrix.diagonal().map((t=>Math.sqrt(t))),this.tStats=this.weights.map(((t,e)=>0===this.stdErrors[e]?0:t[0]/this.stdErrors[e]))}}}predict(t){if(Array.isArray(t)){if("number"==typeof t[0])return this._predict(t);if(Array.isArray(t[0])){const e=new Array(t.length);for(let r=0;r({label:e===this.weights.length-1?"Intercept":"X Variable "+(e+1),coefficients:t,standardError:this.stdErrors[e],tStat:this.tStats[e]})))}:void 0}}static load(t){if("multivariateLinearRegression"!==t.name)throw new Error("not a MLR model");return new MultivariateLinearRegression(!0,t)}}var require$$0$1=getAugmentedNamespace(euclidean$1);const{squaredEuclidean:squaredEuclidean$1}=require$$0$1,defaultOptions$7={sigma:1};class GaussianKernel{constructor(t){t=Object.assign({},defaultOptions$7,t),this.sigma=t.sigma,this.divisor=2*t.sigma*t.sigma}compute(t,e){const r=squaredEuclidean$1(t,e);return Math.exp(-r/this.divisor)}}var gaussianKernel=GaussianKernel;const defaultOptions$8={degree:1,constant:1,scale:1};class PolynomialKernel{constructor(t){t=Object.assign({},defaultOptions$8,t),this.degree=t.degree,this.constant=t.constant,this.scale=t.scale}compute(t,e){for(var r=0,n=0;n0&&e!==this.coefficients.length-1?s=" + "+s:e!==this.coefficients.length-1&&(s=" "+s)),o=s+o;return"+"===o.charAt(0)&&(o=o.slice(1)),"f(x) = "+o}static load(t){if("robustPolynomialRegression"!==t.name)throw new TypeError("not a RobustPolynomialRegression model");return new RobustPolynomialRegression(!0,t)}}function robustPolynomial(t,e,r,n){let i=Array(n).fill(0).map(((t,e)=>e));const o=getRandomTuples(e,r,n);for(var s,a=0;at.residual-e.residual));var e=t.length,r=Math.floor(e/2);return e%2==0?t[r-1]:t[r]}const toString$3=Object.prototype.toString;function isAnyArray$3(t){return toString$3.call(t).endsWith("Array]")}function errorCalculation(t,e,r){let n=0;const i=r(e);for(let e=0;e{let r=BigInt(0);return t.forEach((t=>r|=BigInt(1)<t.key-e.key<0?-1:1)),n=[],i=[];for(let t of r)t.key!==e&&(e=t.key,i.push([]),n.push(t.value)),i[i.length-1].push(t.index);return{values:n,indices:i}}function cssls(t,e,r,n,i){let o=Matrix.zeros(n,i);if(null===r){let r=new CholeskyDecomposition(t);if(!0===r.isPositiveDefinite())o=r.solve(e);else{let r=new LuDecomposition(t);o=!1===r.isSingular()?r.solve(Matrix.eye(n)).mmul(e):solve(t,e,{useSVD:!0})}}else{let s=sortCollectionSet(r).values,a=sortCollectionSet(r).indices;if(1===s.length&&0===s[0].length&&a[0].length===i)return o;if(1===s.length&&s[0].length===n&&a[0].length===i){let r=new CholeskyDecomposition(t);if(!0===r.isPositiveDefinite())o=r.solve(e);else{let r=new LuDecomposition(t);o=!1===r.isSingular()?r.solve(Matrix.eye(n)).mmul(e):solve(t,e,{useSVD:!0})}}else for(let r=0;r0?h[t].push(e):l.set(e,t,0)}let u=[];for(let t=0;tt-e));return{Pset:o,Fset:i,W:s}}function fcnnls(t,e,r={}){t=Matrix.checkMatrix(t),e=Matrix.checkMatrix(e);let{l:n,p:i,iter:o,W:s,XtX:a,XtY:l,K:h,Pset:u,Fset:c,D:m}=initialisation(t,e);const{maxIterations:f=3*t.columns}=r;for(;c.length>0;){let t=cssls(a,l.subMatrixColumn(c),selection(u,c),n,c.length);for(let e=0;e0){let e=r.length,i=Matrix.ones(n,e);for(;e>0&&oe===g[t])),1);t=cssls(a,l.subMatrixColumn(r),selection(u,r),n,e);for(let n=0;n=t.length)throw new RangeError("invalid lower bound");if(void 0===i)i=t.length-1;else if((i|=0)=t.length)throw new RangeError("invalid upper bound");for(;n<=i;)if((s=+r(t[o=n+(i-n>>>1)],e,o,t))<0)n=o+1;else{if(!(s>0))return o;i=o-1}return~n};function assertNumber(t){if("number"!=typeof t)throw new TypeError("Expected a number")}var ascending=(t,e)=>(assertNumber(t),assertNumber(e),Number.isNaN(t)?-1:Number.isNaN(e)?1:t-e),descending=(t,e)=>(assertNumber(t),assertNumber(e),Number.isNaN(t)?1:Number.isNaN(e)?-1:e-t),numSort={ascending:ascending,descending:descending},index$4=Object.freeze(Object.assign(Object.create(null),numSort,{default:numSort,ascending:ascending,descending:descending}));const largestPrime=2147483647,primeNumbers=[largestPrime,5,11,23,47,97,197,397,797,1597,3203,6421,12853,25717,51437,102877,205759,411527,823117,1646237,3292489,6584983,13169977,26339969,52679969,105359939,210719881,421439783,842879579,1685759167,433,877,1759,3527,7057,14143,28289,56591,113189,226379,452759,905551,1811107,3622219,7244441,14488931,28977863,57955739,115911563,231823147,463646329,927292699,1854585413,953,1907,3821,7643,15287,30577,61169,122347,244703,489407,978821,1957651,3915341,7830701,15661423,31322867,62645741,125291483,250582987,501165979,1002331963,2004663929,1039,2081,4177,8363,16729,33461,66923,133853,267713,535481,1070981,2141977,4283963,8567929,17135863,34271747,68543509,137087021,274174111,548348231,1096696463,31,67,137,277,557,1117,2237,4481,8963,17929,35863,71741,143483,286973,573953,1147921,2295859,4591721,9183457,18366923,36733847,73467739,146935499,293871013,587742049,1175484103,599,1201,2411,4831,9677,19373,38747,77509,155027,310081,620171,1240361,2480729,4961459,9922933,19845871,39691759,79383533,158767069,317534141,635068283,1270136683,311,631,1277,2557,5119,10243,20507,41017,82037,164089,328213,656429,1312867,2625761,5251529,10503061,21006137,42012281,84024581,168049163,336098327,672196673,1344393353,3,7,17,37,79,163,331,673,1361,2729,5471,10949,21911,43853,87719,175447,350899,701819,1403641,2807303,5614657,11229331,22458671,44917381,89834777,179669557,359339171,718678369,1437356741,43,89,179,359,719,1439,2879,5779,11579,23159,46327,92657,185323,370661,741337,1482707,2965421,5930887,11861791,23723597,47447201,94894427,189788857,379577741,759155483,1518310967,379,761,1523,3049,6101,12203,24407,48817,97649,195311,390647,781301,1562611,3125257,6250537,12501169,25002389,50004791,100009607,200019221,400038451,800076929,1600153859,13,29,59,127,257,521,1049,2099,4201,8419,16843,33703,67409,134837,269683,539389,1078787,2157587,4315183,8630387,17260781,34521589,69043189,138086407,276172823,552345671,1104691373,19,41,83,167,337,677,1361,2729,5471,10949,21911,43853,87719,175447,350899,701819,1403641,2807303,5614657,11229331,22458671,44917381,89834777,179669557,359339171,718678369,1437356741,53,107,223,449,907,1823,3659,7321,14653,29311,58631,117269,234539,469099,938207,1876417,3752839,7505681,15011389,30022781,60045577,120091177,240182359,480364727,960729461,1921458943];function nextPrime(t){let e=binarySearch(primeNumbers,t,ascending);return e<0&&(e=~e),primeNumbers[e]}primeNumbers.sort(ascending);const FREE=0,FULL=1,REMOVED=2,defaultInitialCapacity=150,defaultMinLoadFactor=1/6,defaultMaxLoadFactor=2/3;class HashTable{constructor(t={}){if(t instanceof HashTable)return this.table=t.table.slice(),this.values=t.values.slice(),this.state=t.state.slice(),this.minLoadFactor=t.minLoadFactor,this.maxLoadFactor=t.maxLoadFactor,this.distinct=t.distinct,this.freeEntries=t.freeEntries,this.lowWaterMark=t.lowWaterMark,void(this.highWaterMark=t.maxLoadFactor);const e=void 0===t.initialCapacity?defaultInitialCapacity:t.initialCapacity;if(e<0)throw new RangeError("initial capacity must not be less than zero: "+e);const r=void 0===t.minLoadFactor?defaultMinLoadFactor:t.minLoadFactor,n=void 0===t.maxLoadFactor?defaultMaxLoadFactor:t.maxLoadFactor;if(r<0||r>=1)throw new RangeError("invalid minLoadFactor: "+r);if(n<=0||n>=1)throw new RangeError("invalid maxLoadFactor: "+n);if(r>=n)throw new RangeError(`minLoadFactor (${r}) must be smaller than maxLoadFactor (${n})`);let i=e;i=i/n|0,i=nextPrime(i),0===i&&(i=1),this.table=newArray$1(i),this.values=newArray$1(i),this.state=newArray$1(i),this.minLoadFactor=r,this.maxLoadFactor=i===largestPrime?1:n,this.distinct=0,this.freeEntries=i,this.lowWaterMark=0,this.highWaterMark=chooseHighWaterMark(i,this.maxLoadFactor)}clone(){return new HashTable(this)}get size(){return this.distinct}get(t){const e=this.indexOfKey(t);return e<0?0:this.values[e]}set(t,e){let r=this.indexOfInsertion(t);if(r<0)return r=-r-1,this.values[r]=e,!1;if(this.distinct>this.highWaterMark){const r=chooseGrowCapacity(this.distinct+1,this.minLoadFactor,this.maxLoadFactor);return this.rehash(r),this.set(t,e)}if(this.table[r]=t,this.values[r]=e,this.state[r]===FREE&&this.freeEntries--,this.state[r]=FULL,this.distinct++,this.freeEntries<1){const t=chooseGrowCapacity(this.distinct+1,this.minLoadFactor,this.maxLoadFactor);this.rehash(t)}return!0}remove(t,e){const r=this.indexOfKey(t);return!(r<0)&&(this.state[r]=REMOVED,this.distinct--,e||this.maybeShrinkCapacity(),!0)}delete(t,e){const r=this.indexOfKey(t);return!(r<0)&&(this.state[r]=FREE,this.distinct--,e||this.maybeShrinkCapacity(),!0)}maybeShrinkCapacity(){if(this.distinct=0}indexOfKey(t){const e=this.table,r=this.state,n=this.table.length,i=2147483647&t;let o=i%n,s=i%(n-2);for(0===s&&(s=1);r[o]!==FREE&&(r[o]===REMOVED||e[o]!==t);)o-=s,o<0&&(o+=n);return r[o]===FREE?-1:o}containsValue(t){return this.indexOfValue(t)>=0}indexOfValue(t){const e=this.values,r=this.state;for(var n=0;nthis.get(r,e)!==n?(t=!1,!1):n)),t}bandWidth(){let t=this.columns,e=-1;return this.forEachNonZero(((r,n,i)=>{let o=r-n;return t=Math.min(t,o),e=Math.max(e,o),i})),e-t}isBanded(t){return this.bandWidth()<=t}get cardinality(){return this.elements.size}get size(){return this.rows*this.columns}get(t,e){return this.elements.get(t*this.columns+e)}set(t,e,r){return this.threshold&&Math.abs(r)(t.forEachNonZero(((t,o,s)=>(r===t&&n.set(e,o,n.get(e,o)+i*s),s))),i))),n}kroneckerProduct(t){const e=this.rows,r=this.columns,n=t.rows,i=t.columns,o=new SparseMatrix(e*n,r*i,{initialCapacity:this.cardinality*t.cardinality});return this.forEachNonZero(((e,r,s)=>(t.forEachNonZero(((t,a,l)=>(o.set(n*e+t,i*r+a,s*l),l))),s))),o}forEachNonZero(t){return this.elements.forEachPair(((e,r)=>{const n=e/this.columns|0,i=e%this.columns;let o=t(n,i,r);return!1!==o&&(this.threshold&&Math.abs(o)(e[i]=t,r[i]=o,n[i]=s,i++,s))),{rows:e,columns:r,values:n}}setThreshold(t){return 0!==t&&t!==this.threshold&&(this.threshold=t,this.forEachNonZero(((t,e,r)=>r))),this}transpose(){let t=new SparseMatrix(this.columns,this.rows,{initialCapacity:this.cardinality});return this.forEachNonZero(((e,r,n)=>(t.set(r,e,n),n))),t}}SparseMatrix.prototype.klass="Matrix",SparseMatrix.identity=SparseMatrix.eye,SparseMatrix.prototype.tensorProduct=SparseMatrix.prototype.kroneckerProduct;var inplaceOperator="\n(function %name%(value) {\n if (typeof value === 'number') return this.%name%S(value);\n return this.%name%M(value);\n})\n",inplaceOperatorScalar="\n(function %name%S(value) {\n this.forEachNonZero((i, j, v) => v %op% value);\n return this;\n})\n",inplaceOperatorMatrix="\n(function %name%M(matrix) {\n matrix.forEachNonZero((i, j, v) => {\n this.set(i, j, this.get(i, j) %op% v);\n return v;\n });\n return this;\n})\n",staticOperator="\n(function %name%(matrix, value) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%(value);\n})\n",inplaceMethod="\n(function %name%() {\n this.forEachNonZero((i, j, v) => %method%(v));\n return this;\n})\n",staticMethod="\n(function %name%(matrix) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%();\n})\n";const operators=[["+","add"],["-","sub","subtract"],["*","mul","multiply"],["/","div","divide"],["%","mod","modulus"],["&","and"],["|","or"],["^","xor"],["<<","leftShift"],[">>","signPropagatingRightShift"],[">>>","rightShift","zeroFillRightShift"]];for(const operator of operators)for(let i=1;i=n);h++)a+=e[h],l+=t[h]*e[h];return agetSimilarity(e,r,t)}var index$5=Object.freeze({__proto__:null,treeSimilarity:treeSimilarity,getFunction:getFunction,createTree:createTree});function cosine(t,e){for(var r=t.length,n=0,i=0,o=0,s=0;s0){let t=fastExtractNMF(e.clone().subM(r.mmul(n)),i.length);for(let e=0;e0){let l=Math.sqrt(e[a]);for(let e=0;enormProj(zeroInsteadOfNegative(t.subS(r)),e)}else i=(t,e)=>zeroInsteadOfNegative(t.subS(e));for(let t=0;tzeroInsteadOfNegative(t.subS(e));for(let t=0;t0&&(i.push(t),l.push(h.S.getRow(t)));l=Matrix.checkMatrix(l);let c=zeroInsteadOfNegative(solve(l.transpose(),t.transpose()));for(let t=0;tt.S.get(e,r)*a.get(0,e)/o.get(0,e),i=(e,r)=>t.A.get(r,e)/s.get(0,e)):(n=(e,r)=>t.S.get(e,r)/o.get(0,e),i=(e,r)=>t.A.get(r,e)*a.get(0,e)/s.get(0,e));const l=t.S.columns,h=t.A.rows;for(let e=0;e0?(r=n,o=i):(o=()=>0,r=()=>0);for(let n=0;nf&&(m=!0),g.A=updateMatrixA(g.A,g.S,t,{maxFBIteration:i,toleranceFB:a,normConstrained:m,lambda:0}),g=normalize(g,{normOnA:!0}),g.lambda=updateLambda(g,t,{refinementBeginning:f,tauMAD:u});if(c){let t=g.A.transpose();g.A=g.S.transpose(),g.S=t}return g}var acc=t=>{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.length,r=new Array(e);for(var n=0;n{const e=t.cutoffs.slice();return e[0]=e[1],e},measures={acc:acc,err:err,fpr:fpr,tpr:tpr,fnr:fnr,tnr:tnr,ppv:ppv,npv:npv,pcfall:pcfall,pcmiss:pcmiss,lift:lift,rpp:rpp,rnp:rnp,threshold:threshold};class Performance{constructor(t,e,r){if(r=r||{},t.length!==e.length||t[0].length!==e[0].length)throw new Error("dimensions of prediction and target do not match");const n=t.length,i=t[0].length,o=!r.max,s=[];if(r.all)for(var a=0;at.pred-e.pred)):s.sort(((t,e)=>e.pred-t.pred));const h=this.cutoffs=[o?Number.MIN_VALUE:Number.MAX_VALUE],u=this.fp=[0],c=this.tp=[0];var m=0,f=0,g=s[0].pred,p=0,d=0;for(a=0;ar||e.size[1]>r)throw new RangeError("expanded value should not be bigger than the data length");for(i=0;i0;)e*=t--;return e}const defaultOptions$h={windowSize:5,derivative:1,polynomial:2,pad:"none",padValue:"replicate"};function savitzkyGolay(t,e,r){if((r=Object.assign({},defaultOptions$h,r)).windowSize%2==0||r.windowSize<5||!Number.isInteger(r.windowSize))throw new RangeError("Invalid window size (should be odd and at least 5 integer number)");if(r.derivative<0||!Number.isInteger(r.derivative))throw new RangeError("Derivative should be a positive integer");if(r.polynomial<1||!Number.isInteger(r.polynomial))throw new RangeError("Polynomial should be a positive integer");let n,i,o=Math.floor(r.windowSize/2);"pre"===r.pad&&(t=src$2(t,{size:o,value:r.padValue}));let s=new Array(t.length-2*o);if(5!==r.windowSize||2!==r.polynomial||1!==r.derivative&&2!==r.derivative){let t=Matrix.ones(r.windowSize,r.polynomial+1),e=-(r.windowSize-1)/2;for(let r=0;r>8&255]+creator[t[r]>>16&255]+creator[t[r]>>24&255];return e}function and(t,e){for(var r=new Array(t.length),n=0;n>5]&r)}function setBit(t,e,r){var n=e>>5,i=1<<31-e%32;return t[n]=r?i|t[n]:~i&t[n],t}function toBinaryString(t){for(var e="",r=0;r>>0).toString(2);e+="00000000000000000000000000000000".substr(n.length)+n}return e}function parseBinaryString(t){for(var e=t.length/32,r=new Array(e),n=0;n>>0).toString(16);e+="00000000".substr(n.length)+n}return e}function parseHexString(t){for(var e=t.length/8,r=new Array(e),n=0;nt.length)throw new RangeError(`Window size is higher than the data length ${n}>${t.length}`);if(i<0||!Number.isInteger(i))throw new RangeError("Derivative should be a positive integer");if(o<1||!Number.isInteger(o))throw new RangeError("Polynomial should be a positive integer");o>=6&&console.warn("You should not use polynomial grade higher than 5 if you are not sure that your data arises from such a model. Possible polynomial oscillation problems");let s=Math.floor(n/2),a=t.length,l=new Array(a),h=fullWeights(n,o,i),u=0,c=!0;Array.isArray(e)?c=!1:u=Math.pow(e,i);for(let r=0;r=0&&n0?(4*r-2)/(r*(2*e-r+1))*(t*GramPoly(t,e,r-1,n)+n*GramPoly(t,e,r-1,n-1))-(r-1)*(2*e+r)/(r*(2*e-r+1))*GramPoly(t,e,r-2,n):0===r&&0===n?1:0,i}function GenFact(t,e){let r=1;if(t>=e)for(let n=t-e+1;n<=t;n++)r*=n;return r}function Weight(t,e,r,n,i){let o=0;for(let s=0;s<=n;s++)o+=(2*s+1)*(GenFact(2*r,s)/GenFact(2*r+s+1,s+1))*GramPoly(t,r,s,0)*GramPoly(e,r,s,i);return o}function fullWeights(t,e,r){let n=new Array(t),i=Math.floor(t/2);for(let o=-i;o<=i;o++){n[o+i]=new Array(t);for(let t=-i;t<=i;t++)n[o+i][t+i]=Weight(t,o,i,e,r)}return n}function gsd(t,e,r={}){let{noiseLevel:n,sgOptions:i={windowSize:9,polynomial:3},smoothY:o=!0,heightFactor:s=0,broadRatio:a=0,maxCriteria:l=!0,minMaxRatio:h=25e-5,derivativeThreshold:u=-1,realTopDetection:c=!1}=r;const m=e.slice();let f=isEqualSpaced(t);void 0===n&&(n=f?getNoiseLevel(m):0);const g={m:1,b:n};l||(g.m=-1,g.b*=-1);for(let t=0;tb&&(b=Math.abs(d[t])),Math.abs(w[t])>S&&(S=Math.abs(w[t]));let A=null,E=null,R=new Array(w.length-2),k=new Array(w.length),N=new Array(w.length),C=new Array(w.length-2),T=0,I=0,O=0,L=0;for(let t=1;tu&&((p[t]0&&null!==A&&(k[I++]=A,N[O++]=E)),(p[t]>=p[t-1]&&p[t]>p[t+1]||p[t]>p[t-1]&&p[t]>=p[t+1])&&(A={x:M[t],index:t},v<0&&null!==E&&(k[I++]=A,N[O++]=E))),d[t]h*S&&(_[$++]={index:R[t],x:P,y:(w[R[t]]+g.b)/g.m,width:Math.abs(N[F].x-k[F].x),soft:C[t]},_[$-1].left=k[F],_[$-1].right=N[F],s)){let t=w[k[F].index],e=w[N[F].index];_[$-1].height=s*(_[$-1].y-(t+e)/2)}}_.length=$,c&&determineRealTop(_,M,w);for(let t=0;t<_.length;t++)_[t].base=n;return _.sort((function(t,e){return t.x-e.x})),_}const isEqualSpaced=t=>{let e,r=0,n=Number.MAX_SAFE_INTEGER;for(let i=0;ir&&(r=e);return(r-n)/r<.05},getNoiseLevel=t=>{let e=0,r=0,n=t.length;for(let r=0;rt-e)),r=n%2==1?i[(n-1)/2]/.6745:.5*(i[n/2]+i[n/2-1])/.6745,r},determineRealTop=(t,e,r)=>{let n,i,o,s,a;for(let l=0;l=r[a-2]&&r[a-1]>=r[a]?a--:r[a+1]>=r[a]&&r[a+1]>=r[a+2]?a++:r[a-2]>=r[a-3]&&r[a-2]>=r[a-1]?a-=2:r[a+2]>=r[a+1]&&r[a+2]>=r[a+3]&&(a+=2),r[a-1]>0&&r[a+1]>0&&r[a]>=r[a-1]&&r[a]>=r[a+1]&&(r[a]!==r[a-1]||r[a]!==r[a+1])&&(n=20*Math.log10(r[a-1]),i=20*Math.log10(r[a]),o=20*Math.log10(r[a+1]),s=.5*(n-o)/(n-2*i+o),t[l].x=e[a]+(e[a]-e[a-1])*s,t[l].y=r[a]-.25*(r[a-1]-r[a+1])*s)};function sumOfGaussians(t){return function(e){let r,n=t.length/3,i=e.length,o=void 0===i?0:new Float64Array(i).fill(0);for(let s=0;sr[e]/=o));let s=e.length,a=new Float64Array(3*s),l=new Float64Array(3*s),h=new Float64Array(3*s),u=Math.abs(n[0]-n[1]);for(let t=0;tr[e]/=o));let s=Math.abs(n[0]-n[1]),a={damping:1.5,initialValues:new Float64Array([e.x,1,e.width]),minValues:new Float64Array([e.x-s,0,e.width/4]),maxValues:new Float64Array([e.x+s,1.25,4*e.width]),gradientDifference:s/1e4,maxIterations:100,errorTolerance:1e-4},l=levenbergMarquardt({x:n,y:i},singleGaussian,r=Object.assign({},a,r));return{parameters:[l.parameterValues[0],l.parameterValues[1]*o,l.parameterValues[2]],error:l.parameterError}}function sumOfLorentzians(t){return function(e){let r,n,i=t.length/3,o=e.length,s=void 0===o?0:new Float64Array(o).fill(0);for(let a=0;ar[e]/=o));let s=e.length,a=new Float64Array(3*s),l=new Float64Array(3*s),h=new Float64Array(3*s),u=Math.abs(n[0]-n[1]);for(let t=0;tr[e]/=o));let s=Math.abs(n[0]-n[1]),a={damping:1.5,initialValues:new Float64Array([e.x,1,e.width]),minValues:new Float64Array([e.x-s,.75,e.width/4]),maxValues:new Float64Array([e.x+s,1.25,4*e.width]),gradientDifference:s/1e4,maxIterations:100,errorTolerance:1e-4},l=levenbergMarquardt({x:n,y:i},singleLorentzian,r=Object.assign({},a,r));return{parameters:[l.parameterValues[0],l.parameterValues[1]*o,l.parameterValues[2]],error:l.parameterError}}function optimizePeaks(t,e,r,n={}){const{functionName:i="gaussian",factorWidth:o=4,optimizationOptions:s={damping:1.5,maxIterations:100,errorTolerance:1e-4}}=n;let a,l=[0],h=groupPeaks(t,o),u=[],c=1;"gaussian"===i&&(c=1.17741);for(let t=0;t1){if(a=sampleFunction(h[t].limits[0]-h[t].limits[1],h[t].limits[0]+h[t].limits[1],e,r,l),a[0].length>5){let t=[];"gaussian"===i?t=optimizeGaussianSum(a,n,s):"lorentzian"===i&&(t=optimizeLorentzianSum(a,n,s));for(let e=0;e5){let t=[];"gaussian"===i?t=optimizeSingleGaussian([a[0],a[1]],n,s):"lorentzian"===i&&(t=optimizeSingleLorentzian([a[0],a[1]],n,s));let{parameters:e}=t;u.push({x:e[0],y:e[1],width:e[2]*c,index:n.index})}}return u}function sampleFunction(t,e,r,n,i){let o=r.length,s=[],a=[],l=Math.sign(r[1]-r[0]);-1===l&&(i[0]=r.length-1);let h=Math.abs(e-t)/2,u=(t+e)/2,c=!1,m=i[0];for(;!c&&m=0;)Math.abs(r[m]-u)<=h?(s.push(r[m]),a.push(n[m]),m+=l):1===Math.sign(u-r[m])?m+=l:c=!0;return i[0]=m,[s,a]}function groupPeaks(t,e){let r,n,i=[],o=[],s=[t[0].x,e*t[0].width];for(let a=0;ar&&(r=t[a].x+e*t[a].width),n=s[0]-s[1],t[a].x-e*t[a].width=0;t--)if(Math.abs(o[t].limits[0]-o[t+1].limits[0])<(o[t].limits[1]+o[t+1].limits[1])/2){for(let e=0;er&&(r=o[t+1].limits[0]+o[t+1].limits[1]),n=o[t].limits[0]-o[t].limits[1],o[t+1].limits[0]-o[t+1].limits[1]=0;e--)t[e].soft&&n.push(t.splice(e,1)[0]);n.push({x:Number.MAX_VALUE});let a=[[n[0].x,n[0].y]],l=[n[0].index];for(let e=1;ei&&(i=n[e].y,o=e),l.push(n[e].index),s++;else{if(s>2){let e=optimizeSingleLorentzian(a,{x:n[o].x,y:i,width:Math.abs(a[0][0]-a[a.length-1][0])}),{parameters:r}=e;t.push({x:r[0],y:r[1],width:r[2],index:Math.floor(l.reduce(((t,e)=>t+e),0)/l.length),soft:!1})}else l.forEach((e=>{t.push(n[e])}));a=[[n[e].x,n[e].y]],l=[e],i=n[e].y,o=e,s=1}return t.sort((function(t,e){return t.x-e.x})),t}function broadenPeaks(t,e={}){const{factor:r=2,overlap:n=!1}=e;for(let e of t)e.right&&e.left?(e.from=e.x-(e.x-e.left.x)*r,e.to=e.x+(e.right.x-e.x)*r):(e.from=e.x-e.width/2*r,e.to=e.x+e.width/2*r);if(!n)for(let e=0;en.from&&(r.to=n.from=(r.to+n.from)/2)}for(let e of t)e.width=e.to-e.from;return t}var index$6=Object.freeze({__proto__:null,gsd:gsd,optimizePeaks:optimizePeaks,joinBroadPeaks:joinBroadPeaks,broadenPeaks:broadenPeaks});const toString$4=Object.prototype.toString;function isAnyArray$4(t){return toString$4.call(t).endsWith("Array]")}function min$1(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray$4(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,i=e.toIndex,o=void 0===i?t.length:i;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=n||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;a1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray$4(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,i=e.toIndex,o=void 0===i?t.length:i;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=n||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;as&&(s=t[a]);return s}function mode$1(t){if(!isAnyArray$4(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");for(var e=0,r=0,n=0,i={},o=0;or&&(r=n,e=t[o])}return e}const toString$5=Object.prototype.toString;function isAnyArray$5(t){return toString$5.call(t).endsWith("Array]")}function max$2(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray$5(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,i=e.toIndex,o=void 0===i?t.length:i;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(o<=n||o>t.length||!Number.isInteger(o))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var s=t[n],a=n+1;as&&(s=t[a]);return s}function norm$1(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.algorithm,i=void 0===n?"absolute":n,o=r.sumValue,s=void 0===o?1:o,a=r.maxValue,l=void 0===a?1:a;if(!isAnyArray$5(t))throw new Error("input must be an array");if(void 0!==r.output){if(!isAnyArray$5(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);if(0===t.length)throw new Error("input must not be empty");switch(i.toLowerCase()){case"absolute":var h=absoluteSum(t)/s;if(0===h)return t.slice(0);for(var u=0;u0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==_typeof(t)||isAnyArray$4(t)||(e=t,t=[]),!isAnyArray$4(t))throw new TypeError("input must be an array");var r=e,n=r.from,i=void 0===n?0:n,o=r.to,s=void 0===o?10:o,a=r.size,l=void 0===a?t.length:a,h=r.step;if(0!==l&&h)throw new Error("step is defined by the array size");if(l||(l=h?Math.floor((s-i)/h)+1:s-i+1),!h&&l&&(h=(s-i)/(l-1)),Array.isArray(t)){t.length=0;for(var u=0;u1&&void 0!==arguments[1]?arguments[1]:{};if(!isAnyArray$6(t))throw new TypeError("input must be an array");for(var r=e.unbiased,n=void 0===r||r,i=e.mean,o=void 0===i?mean(t):i,s=0,a=0;a1&&void 0!==arguments[1]?arguments[1]:{};return Math.sqrt(variance(t,e))}function mergeByCentroids(t,e,r={}){const{window:n=.01}=r;for(var i={x:e.slice(),y:new Array(e.length).fill(0)},o=0,s=0;o=0?{x:r[s],y:n[s]}:(s=~s,0!==s&&Math.abs(r[s]-i)>.5||s===r.length?{x:r[s-1],y:n[s-1]}:{x:r[s],y:n[s]})}function covariance$1(t,e={}){const{x:r,y:n}=t,{unbiased:i=!0}=e,o=mean(r),s=mean(n);var a=0;for(let t=0;ti?(s.x.push(r[l]),s.y.push(n[l]),o.x.push(r[l]),o.y.push(n[l]),l++,a++):(n[l]>s.y[a-1]&&(s.x[a-1]=r[l],s.y[a-1]=n[l]),o.x[a-1]=r[l],o.y[a-1]+=n[l],l++);return o.x=s.x.slice(),o}function maxY(t,e={}){const{x:r,y:n}=t;let{from:i={index:0},to:o={index:r.length},reverse:s=!1}=e;void 0!==i.value&&void 0===i.index&&(i.index=calculateIndex(i.value,r,s)),void 0!==o.value&&void 0===o.index&&(o.index=calculateIndex(o.value,r,s));for(var a,l=Number.MIN_VALUE,h=i.index;he.x-t.x:(t,e)=>t.x-e.x;for(var s=r.map(((t,e)=>({x:t,y:n[e]}))).sort(o),a={x:r.slice(),y:n.slice()},l=0;li?(s.x.push(r[l]*n[l]),s.y.push(n[l]),o.x.push(r[l]),o.y.push(n[l]),l++,a++):(s.x[a-1]+=r[l]*n[l],s.y[a-1]+=n[l],o.x[a-1]=r[l],o.y[a-1]+=n[l],l++);for(var h=0;hn&&([r,n]=[n,r]),(t=(t=JSON.parse(JSON.stringify(t)).map((t=>t.from>t.to?{from:t.to,to:t.from}:t))).sort(((t,e)=>t.from!==e.from?t.from-e.from:t.to-e.to))).forEach((t=>{r>t.from&&(t.from=r),nt.from<=t.to))).length)return[];let i=t[0],o=[i];for(let e=1;en&&([r,n]=[n,r]),0===(t=normalize$1(t,{from:r,to:n})).length)return[{from:r,to:n}];let i=[];for(let e=0;er&&i.push({from:r,to:o.from}),e===t.length-1?o.tot+(e.to-e.from)),0)/e,i=0;for(let r=0;r=0;){if(A=integral(0,m-f,x,g),v=w+A,l[S++]=(v-M)/s,S===i)break t;c=m,m+=s,M=v}w+=integral(f,p,x,y),f=p,g=d,b=p)throw new Error("x must be an increasing serie");for(;f-m>0;){if(x&&(M++,x=!1),u[b]=M<=0?0:y/M,b++,b===i)break t;c=m,m+=s,y=0,M=0}f>c&&(y+=g,M++),(f===-Number.MAX_VALUE||w>1)&&M--,f=p,g=d,v1&&r[0]>r[1]&&(r=r.slice().reverse(),n=n.slice().reverse(),o=!0);let{from:s=r[0],to:a=r[i-1],variant:l="smooth",numberOfPoints:h=100,exclusions:u=[],zones:c=[]}=e;if(i!==n.length)throw new RangeError("the x and y vector doesn't have the same size.");if("number"!=typeof s||isNaN(s))throw new RangeError("'from' option must be a number");if("number"!=typeof a||isNaN(a))throw new RangeError("'to' option must be a number");if("number"!=typeof h||isNaN(h))throw new RangeError("'numberOfPoints' option must be a number");if(h<2)throw new RangeError("'numberOfPoints' option must be greater than 1");0===c.length&&(c=invert(u,{from:s,to:a})),c=zonesWithPoints(c,h,{from:s,to:a});let m=[],f=[];for(let t of c){let e=processZone(r,n,t.from,t.to,t.numberOfPoints,l);m=m.concat(e.x),f=f.concat(e.y)}return o?se&&([t,e]=[e,t]),r=r.filter((t=>void 0!==t.from&&void 0!==t.to)),(r=JSON.parse(JSON.stringify(r))).forEach((t=>{t.from>t.to&&([t.to,t.from]=[t.from,t.to])})),r.sort(((t,e)=>t.from-e.from)),r.forEach((r=>{r.frome&&(r.to=e)}));for(let t=0;tr[t+1].from&&(r[t].to=r[t+1].from);if(!(r=r.filter((t=>t.from=a[l].from)h.push(r[c]),u.push(n[c]);else if(r[c]>a[l].to&&(l++,!a[l]))break;c++}return{x:h,y:u}}const{Matrix:Matrix$2,SVD:SVD,EVD:EVD,CholeskyDecomposition:CholeskyDecomposition$1,LuDecomposition:LuDecomposition$1,QrDecomposition:QrDecomposition$1}=MatrixLib,Array$1={min:min$1,max:max$1,median:median,mean:mean,mode:mode$1,normed:norm$1,rescale:rescale,sequentialFill:sequentialFill,standardDeviation:standardDeviation,sum:sum,variance:variance},ArrayXY={centroidsMerge:mergeByCentroids,closestX:closestX,covariance:covariance$1,maxMerge:maxMerge,maxY:maxY,sortX:sortX,uniqueX:uniqueX,weightedMerge:weightedMerge,equallySpaced:equallySpaced,filterX:filterX};exports.Array=Array$1,exports.ArrayXY=ArrayXY,exports.BitArray=src$3,exports.CholeskyDecomposition=CholeskyDecomposition$1,exports.ConfusionMatrix=ConfusionMatrix,exports.CrossValidation=index$2,exports.DecisionTreeClassifier=DecisionTreeClassifier,exports.DecisionTreeRegression=DecisionTreeRegression,exports.Distance=distances,exports.EVD=EVD,exports.ExponentialRegression=ExponentialRegression,exports.FCNNLS=index$3,exports.FNN=FeedForwardNeuralNetwork,exports.GSD=index$6,exports.HClust=index,exports.HashTable=HashTable,exports.KMeans=kmeans,exports.KNN=KNN,exports.KOPLS=KOPLS,exports.Kernel=kernel,exports.LuDecomposition=LuDecomposition$1,exports.Matrix=Matrix$2,exports.MatrixLib=MatrixLib,exports.MultivariateLinearRegression=MultivariateLinearRegression,exports.NaiveBayes=index$1,exports.OPLS=OPLS,exports.OPLSNipals=OPLSNipals,exports.PCA=PCA,exports.PLS=PLS,exports.Performance=src$1,exports.PolynomialRegression=PolynomialRegression,exports.PowerRegression=PowerRegression,exports.QrDecomposition=QrDecomposition$1,exports.Random=Random,exports.RandomForestClassifier=RandomForestClassifier,exports.RandomForestRegression=RandomForestRegression,exports.RobustPolynomialRegression=RobustPolynomialRegression,exports.SOM=src,exports.SVD=SVD,exports.Similarity=similarities,exports.SimpleLinearRegression=SimpleLinearRegression,exports.SparseMatrix=SparseMatrix,exports.TheilSenRegression=TheilSenRegression,exports.XSadd=XSadd,exports.binarySearch=binarySearch,exports.distanceMatrix=distanceMatrix,exports.levenbergMarquardt=levenbergMarquardt,exports.nGMCA=nGMCA,exports.numSort=index$4,exports.padArray=src$2,exports.savitzkyGolay=savitzkyGolay,Object.defineProperty(exports,"__esModule",{value:!0})})); //# sourceMappingURL=ml.min.js.map diff --git a/dist/ml.min.js.map b/dist/ml.min.js.map index cb45a49..f8d11db 100644 --- a/dist/ml.min.js.map +++ b/dist/ml.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ml.min.js","sources":["../node_modules/ml-array-rescale/node_modules/is-any-array/src/index.js","../node_modules/ml-array-rescale/node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-rescale/node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-rescale/lib-es6/index.js","../node_modules/ml-matrix/src/inspect.js","../node_modules/ml-matrix/src/mathOperations.js","../node_modules/ml-matrix/src/util.js","../node_modules/ml-matrix/src/stat.js","../node_modules/ml-matrix/src/matrix.js","../node_modules/ml-matrix/src/views/base.js","../node_modules/ml-matrix/src/views/column.js","../node_modules/ml-matrix/src/views/columnSelection.js","../node_modules/ml-matrix/src/views/flipColumn.js","../node_modules/ml-matrix/src/views/flipRow.js","../node_modules/ml-matrix/src/views/row.js","../node_modules/ml-matrix/src/views/rowSelection.js","../node_modules/ml-matrix/src/views/selection.js","../node_modules/ml-matrix/src/views/sub.js","../node_modules/ml-matrix/src/views/transpose.js","../node_modules/ml-matrix/src/wrap/WrapperMatrix1D.js","../node_modules/ml-matrix/src/wrap/WrapperMatrix2D.js","../node_modules/ml-matrix/src/wrap/wrap.js","../node_modules/ml-matrix/src/dc/lu.js","../node_modules/ml-matrix/src/dc/util.js","../node_modules/ml-matrix/src/dc/qr.js","../node_modules/ml-matrix/src/dc/svd.js","../node_modules/ml-matrix/src/decompositions.js","../node_modules/ml-matrix/src/determinant.js","../node_modules/ml-matrix/src/linearDependencies.js","../node_modules/ml-matrix/src/pseudoInverse.js","../node_modules/ml-matrix/src/covariance.js","../node_modules/ml-matrix/src/correlation.js","../node_modules/ml-matrix/src/dc/evd.js","../node_modules/ml-matrix/src/dc/cholesky.js","../node_modules/ml-matrix/src/dc/nipals.js","../node_modules/ml-array-sum/node_modules/is-any-array/src/index.js","../node_modules/ml-array-sum/lib-es6/index.js","../node_modules/ml-array-mean/lib-es6/index.js","../node_modules/ml-cart/src/utils.js","../node_modules/ml-cart/src/TreeNode.js","../node_modules/ml-cart/src/DecisionTreeClassifier.js","../node_modules/ml-cart/src/DecisionTreeRegression.js","../node_modules/random-js/dist/random-js.esm.js","../node_modules/ml-random-forest/src/utils.js","../node_modules/ml-random-forest/src/RandomForestBase.js","../node_modules/ml-random-forest/src/RandomForestClassifier.js","../node_modules/ml-array-median/node_modules/is-any-array/src/index.js","../node_modules/median-quickselect/lib/median-quickselect.min.js","../node_modules/ml-array-median/lib-es6/index.js","../node_modules/ml-random-forest/src/RandomForestRegression.js","../node_modules/ml-pca/src/pca.js","../node_modules/ml-distance-euclidean/lib-es6/euclidean.js","../node_modules/ml-distance-matrix/src/index.js","../node_modules/heap/lib/heap.js","../node_modules/heap/index.js","../node_modules/ml-hclust/src/Cluster.js","../node_modules/ml-hclust/src/agnes.js","../node_modules/ml-nearest-vector/lib-es6/index.js","../node_modules/ml-kmeans/src/utils.js","../node_modules/ml-xsadd/lib-es6/xsadd.js","../node_modules/ml-random/lib-es6/choice.js","../node_modules/ml-random/lib-es6/index.js","../node_modules/ml-kmeans/src/initialization.js","../node_modules/ml-kmeans/src/KMeansResult.js","../node_modules/ml-kmeans/src/kmeans.js","../node_modules/ml-naivebayes/src/utils.js","../node_modules/ml-naivebayes/src/GaussianNB.js","../node_modules/ml-naivebayes/src/MultinomialNB.js","../node_modules/ml-knn/src/KDTree.js","../node_modules/ml-knn/src/index.js","../node_modules/ml-pls/src/util/utils.js","../node_modules/ml-pls/src/PLS.js","../node_modules/ml-pls/src/KOPLS.js","../node_modules/ml-confusion-matrix/src/index.js","../node_modules/ml-combinations/lib/index.js","../node_modules/ml-cross-validation/src/getFolds.js","../node_modules/ml-cross-validation/src/sampleAClass.js","../node_modules/ml-cross-validation/src/index.js","../node_modules/ml-pls/src/OPLSNipals.js","../node_modules/ml-pls/src/util/tss.js","../node_modules/ml-pls/src/OPLS.js","../node_modules/ml-fnn/FeedForwardNeuralNetwork.js","../node_modules/ml-som/src/node-square.js","../node_modules/ml-som/src/node-hexagonal.js","../node_modules/ml-som/src/index.js","../node_modules/ml-regression-base/src/maybeToPrecision.js","../node_modules/ml-regression-base/src/checkArrayLength.js","../node_modules/ml-regression-base/src/index.js","../node_modules/ml-regression-polynomial/src/index.js","../node_modules/ml-regression-simple-linear/src/index.js","../node_modules/ml-regression-exponential/src/index.js","../node_modules/ml-regression-power/src/index.js","../node_modules/ml-regression-multivariate-linear/src/index.js","../node_modules/ml-kernel-gaussian/gaussian-kernel.js","../node_modules/ml-kernel-polynomial/polynomial-kernel.js","../node_modules/ml-kernel-sigmoid/sigmoid-kernel.js","../node_modules/ml-kernel/src/kernels/anova-kernel.js","../node_modules/ml-kernel/src/kernels/cauchy-kernel.js","../node_modules/ml-kernel/src/kernels/exponential-kernel.js","../node_modules/ml-kernel/src/kernels/histogram-intersection-kernel.js","../node_modules/ml-kernel/src/kernels/laplacian-kernel.js","../node_modules/ml-kernel/src/kernels/multiquadratic-kernel.js","../node_modules/ml-kernel/src/kernels/rational-quadratic-kernel.js","../node_modules/ml-kernel/src/kernel.js","../node_modules/ml-regression-theil-sen/src/index.js","../node_modules/ml-regression-robust-polynomial/src/index.js","../node_modules/ml-levenberg-marquardt/node_modules/is-any-array/src/index.js","../node_modules/ml-levenberg-marquardt/src/errorCalculation.js","../node_modules/ml-levenberg-marquardt/src/step.js","../node_modules/ml-levenberg-marquardt/src/index.js","../node_modules/ml-fcnnls/src/util/selection.js","../node_modules/ml-fcnnls/src/util/sortCollectionSet.js","../node_modules/ml-fcnnls/src/cssls.js","../node_modules/ml-fcnnls/src/initialisation.js","../node_modules/ml-fcnnls/src/util/setDifference.js","../node_modules/ml-fcnnls/src/optimality.js","../node_modules/ml-fcnnls/src/fcnnls.js","../node_modules/ml-fcnnls/src/fcnnlsVector.js","../node_modules/binary-search/index.js","../node_modules/num-sort/index.js","../node_modules/ml-hash-table/src/primeFinder.js","../node_modules/ml-hash-table/src/HashTable.js","../node_modules/ml-sparse-matrix/src/index.js","../node_modules/ml-distance/src/distances/additiveSymmetric.js","../node_modules/ml-distance/src/distances/avg.js","../node_modules/ml-distance/src/distances/bhattacharyya.js","../node_modules/ml-distance/src/distances/canberra.js","../node_modules/ml-distance/src/distances/chebyshev.js","../node_modules/ml-distance/src/distances/clark.js","../node_modules/ml-distance/src/similarities/czekanowski.js","../node_modules/ml-distance/src/distances/czekanowski.js","../node_modules/ml-distance/src/distances/dice.js","../node_modules/ml-distance/src/distances/divergence.js","../node_modules/ml-distance/src/distances/fidelity.js","../node_modules/ml-distance/src/distances/gower.js","../node_modules/ml-distance/src/distances/harmonicMean.js","../node_modules/ml-distance/src/distances/hellinger.js","../node_modules/ml-distance/src/distances/innerProduct.js","../node_modules/ml-distance/src/distances/intersection.js","../node_modules/ml-distance/src/distances/jaccard.js","../node_modules/ml-distance/src/distances/jeffreys.js","../node_modules/ml-distance/src/distances/jensenDifference.js","../node_modules/ml-distance/src/distances/jensenShannon.js","../node_modules/ml-distance/src/distances/kdivergence.js","../node_modules/ml-distance/src/distances/kulczynski.js","../node_modules/ml-distance/src/distances/kullbackLeibler.js","../node_modules/ml-distance/src/distances/kumarHassebrook.js","../node_modules/ml-distance/src/distances/kumarJohnson.js","../node_modules/ml-distance/src/distances/lorentzian.js","../node_modules/ml-distance/src/distances/manhattan.js","../node_modules/ml-distance/src/distances/matusita.js","../node_modules/ml-distance/src/distances/minkowski.js","../node_modules/ml-distance/src/distances/motyka.js","../node_modules/ml-distance/src/distances/neyman.js","../node_modules/ml-distance/src/distances/pearson.js","../node_modules/ml-distance/src/distances/probabilisticSymmetric.js","../node_modules/ml-distance/src/distances/ruzicka.js","../node_modules/ml-distance/src/distances/soergel.js","../node_modules/ml-distance/src/distances/sorensen.js","../node_modules/ml-distance/src/distances/squared.js","../node_modules/ml-distance/src/distances/squaredChord.js","../node_modules/ml-distance/src/distances/taneja.js","../node_modules/ml-distance/src/similarities/tanimoto.js","../node_modules/ml-distance/src/distances/tanimoto.js","../node_modules/ml-distance/src/distances/topsoe.js","../node_modules/ml-distance/src/distances/waveHedges.js","../node_modules/ml-tree-similarity/src/createTree.js","../node_modules/ml-tree-similarity/src/getSimilarity.js","../node_modules/ml-tree-similarity/src/index.js","../node_modules/ml-distance/src/similarities/cosine.js","../node_modules/ml-distance/src/similarities/dice.js","../node_modules/ml-distance/src/similarities/intersection.js","../node_modules/ml-distance/src/similarities/jaccard.js","../node_modules/ml-distance/src/similarities/kulczynski.js","../node_modules/ml-distance/src/similarities/motyka.js","../node_modules/ml-distance/src/similarities/pearson.js","../node_modules/ml-distance/src/similarities/squaredChord.js","../node_modules/ml-performance/src/measures.js","../node_modules/ml-performance/src/index.js","../node_modules/ml-pad-array/src/index.js","../node_modules/ml-savitzky-golay/src/index.js","../node_modules/ml-bit-array/src/creator.js","../node_modules/ml-bit-array/src/index.js","../node_modules/ml-gsd/node_modules/ml-savitzky-golay-generalized/src/index.js","../node_modules/ml-gsd/src/gsd.js","../node_modules/ml-optimize-lorentzian/src/sumOfGaussians.js","../node_modules/ml-optimize-lorentzian/src/optimizeGaussianSum.js","../node_modules/ml-optimize-lorentzian/src/singleGaussian.js","../node_modules/ml-optimize-lorentzian/src/optimizeSingleGaussian.js","../node_modules/ml-optimize-lorentzian/src/sumOfLorentzians.js","../node_modules/ml-optimize-lorentzian/src/optimizeLorentzianSum.js","../node_modules/ml-optimize-lorentzian/src/singleLorentzian.js","../node_modules/ml-optimize-lorentzian/src/optimizeSingleLorentzian.js","../node_modules/ml-gsd/src/post/optimizePeaks.js","../node_modules/ml-gsd/src/post/joinBroadPeaks.js","../node_modules/ml-gsd/src/post/broadenPeaks.js","../node_modules/is-any-array/src/index.js","../node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-mode/lib-es6/index.js","../node_modules/ml-array-normed/node_modules/is-any-array/src/index.js","../node_modules/ml-array-normed/node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-normed/lib-es6/index.js","../node_modules/ml-array-sequential-fill/lib-es6/index.js","../node_modules/ml-array-variance/node_modules/is-any-array/src/index.js","../node_modules/ml-array-variance/lib-es6/index.js","../node_modules/ml-array-standard-deviation/lib-es6/index.js","../node_modules/ml-array-xy-centroids-merge/src/index.js","../node_modules/ml-arrayxy-closestx/src/index.js","../node_modules/ml-array-xy-covariance/src/index.js","../node_modules/ml-array-xy-max-merge/src/index.js","../node_modules/ml-array-xy-max-y/src/index.js","../node_modules/ml-array-xy-sort-x/src/index.js","../node_modules/ml-arrayxy-uniquex/src/index.js","../node_modules/ml-array-xy-weighted-merge/src/index.js","../node_modules/ml-zones/src/normalize.js","../node_modules/ml-zones/src/invert.js","../node_modules/ml-zones/src/zonesWithPoints.js","../node_modules/ml-array-xy-equally-spaced/src/integral.js","../node_modules/ml-array-xy-equally-spaced/src/equallySpacedSmooth.js","../node_modules/ml-array-xy-equally-spaced/src/equallySpacedSlot.js","../node_modules/ml-array-xy-equally-spaced/src/index.js","../node_modules/ml-array-xy-filter-x/src/getZones.js","../node_modules/ml-array-xy-filter-x/src/index.js","../src/index.js"],"sourcesContent":["const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\n\nfunction min(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var minValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import isArray from 'is-any-array';\nimport max from 'ml-array-max';\nimport min from 'ml-array-min';\n\nfunction rescale(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n } else if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var output;\n\n if (options.output !== undefined) {\n if (!isArray(options.output)) {\n throw new TypeError('output option must be an array if specified');\n }\n\n output = options.output;\n } else {\n output = new Array(input.length);\n }\n\n var currentMin = min(input);\n var currentMax = max(input);\n\n if (currentMin === currentMax) {\n throw new RangeError('minimum and maximum input values are equal. Cannot rescale a constant array');\n }\n\n var _options$min = options.min,\n minValue = _options$min === void 0 ? options.autoMinMax ? currentMin : 0 : _options$min,\n _options$max = options.max,\n maxValue = _options$max === void 0 ? options.autoMinMax ? currentMax : 1 : _options$max;\n\n if (minValue >= maxValue) {\n throw new RangeError('min option must be smaller than max option');\n }\n\n var factor = (maxValue - minValue) / (currentMax - currentMin);\n\n for (var i = 0; i < input.length; i++) {\n output[i] = (input[i] - currentMin) * factor + minValue;\n }\n\n return output;\n}\n\nexport default rescale;\n","const indent = ' '.repeat(2);\nconst indentData = ' '.repeat(4);\n\nexport function inspectMatrix() {\n return inspectMatrixWithOptions(this);\n}\n\nexport function inspectMatrixWithOptions(matrix, options = {}) {\n const { maxRows = 15, maxColumns = 10, maxNumSize = 8 } = options;\n return `${matrix.constructor.name} {\n${indent}[\n${indentData}${inspectData(matrix, maxRows, maxColumns, maxNumSize)}\n${indent}]\n${indent}rows: ${matrix.rows}\n${indent}columns: ${matrix.columns}\n}`;\n}\n\nfunction inspectData(matrix, maxRows, maxColumns, maxNumSize) {\n const { rows, columns } = matrix;\n const maxI = Math.min(rows, maxRows);\n const maxJ = Math.min(columns, maxColumns);\n const result = [];\n for (let i = 0; i < maxI; i++) {\n let line = [];\n for (let j = 0; j < maxJ; j++) {\n line.push(formatNumber(matrix.get(i, j), maxNumSize));\n }\n result.push(`${line.join(' ')}`);\n }\n if (maxJ !== columns) {\n result[result.length - 1] += ` ... ${columns - maxColumns} more columns`;\n }\n if (maxI !== rows) {\n result.push(`... ${rows - maxRows} more rows`);\n }\n return result.join(`\\n${indentData}`);\n}\n\nfunction formatNumber(num, maxNumSize) {\n const numStr = String(num);\n if (numStr.length <= maxNumSize) {\n return numStr.padEnd(maxNumSize, ' ');\n }\n const precise = num.toPrecision(maxNumSize - 2);\n if (precise.length <= maxNumSize) {\n return precise;\n }\n const exponential = num.toExponential(maxNumSize - 2);\n const eIndex = exponential.indexOf('e');\n const e = exponential.slice(eIndex);\n return exponential.slice(0, maxNumSize - e.length) + e;\n}\n","export function installMathOperations(AbstractMatrix, Matrix) {\r\n AbstractMatrix.prototype.add = function add(value) {\r\n if (typeof value === 'number') return this.addS(value);\r\n return this.addM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.addS = function addS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.addM = function addM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.add = function add(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.add(value);\r\n };\r\n\r\n AbstractMatrix.prototype.sub = function sub(value) {\r\n if (typeof value === 'number') return this.subS(value);\r\n return this.subM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.subS = function subS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.subM = function subM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sub = function sub(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sub(value);\r\n };\r\n AbstractMatrix.prototype.subtract = AbstractMatrix.prototype.sub;\r\n AbstractMatrix.prototype.subtractS = AbstractMatrix.prototype.subS;\r\n AbstractMatrix.prototype.subtractM = AbstractMatrix.prototype.subM;\r\n AbstractMatrix.subtract = AbstractMatrix.sub;\r\n\r\n AbstractMatrix.prototype.mul = function mul(value) {\r\n if (typeof value === 'number') return this.mulS(value);\r\n return this.mulM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.mulS = function mulS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.mulM = function mulM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.mul = function mul(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.mul(value);\r\n };\r\n AbstractMatrix.prototype.multiply = AbstractMatrix.prototype.mul;\r\n AbstractMatrix.prototype.multiplyS = AbstractMatrix.prototype.mulS;\r\n AbstractMatrix.prototype.multiplyM = AbstractMatrix.prototype.mulM;\r\n AbstractMatrix.multiply = AbstractMatrix.mul;\r\n\r\n AbstractMatrix.prototype.div = function div(value) {\r\n if (typeof value === 'number') return this.divS(value);\r\n return this.divM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.divS = function divS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.divM = function divM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.div = function div(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.div(value);\r\n };\r\n AbstractMatrix.prototype.divide = AbstractMatrix.prototype.div;\r\n AbstractMatrix.prototype.divideS = AbstractMatrix.prototype.divS;\r\n AbstractMatrix.prototype.divideM = AbstractMatrix.prototype.divM;\r\n AbstractMatrix.divide = AbstractMatrix.div;\r\n\r\n AbstractMatrix.prototype.mod = function mod(value) {\r\n if (typeof value === 'number') return this.modS(value);\r\n return this.modM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.modS = function modS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) % value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.modM = function modM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) % matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.mod = function mod(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.mod(value);\r\n };\r\n AbstractMatrix.prototype.modulus = AbstractMatrix.prototype.mod;\r\n AbstractMatrix.prototype.modulusS = AbstractMatrix.prototype.modS;\r\n AbstractMatrix.prototype.modulusM = AbstractMatrix.prototype.modM;\r\n AbstractMatrix.modulus = AbstractMatrix.mod;\r\n\r\n AbstractMatrix.prototype.and = function and(value) {\r\n if (typeof value === 'number') return this.andS(value);\r\n return this.andM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.andS = function andS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) & value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.andM = function andM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) & matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.and = function and(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.and(value);\r\n };\r\n\r\n AbstractMatrix.prototype.or = function or(value) {\r\n if (typeof value === 'number') return this.orS(value);\r\n return this.orM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.orS = function orS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) | value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.orM = function orM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) | matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.or = function or(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.or(value);\r\n };\r\n\r\n AbstractMatrix.prototype.xor = function xor(value) {\r\n if (typeof value === 'number') return this.xorS(value);\r\n return this.xorM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.xorS = function xorS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) ^ value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.xorM = function xorM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) ^ matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.xor = function xor(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.xor(value);\r\n };\r\n\r\n AbstractMatrix.prototype.leftShift = function leftShift(value) {\r\n if (typeof value === 'number') return this.leftShiftS(value);\r\n return this.leftShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.leftShiftS = function leftShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) << value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.leftShiftM = function leftShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) << matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.leftShift = function leftShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.leftShift(value);\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShift = function signPropagatingRightShift(value) {\r\n if (typeof value === 'number') return this.signPropagatingRightShiftS(value);\r\n return this.signPropagatingRightShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShiftS = function signPropagatingRightShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >> value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShiftM = function signPropagatingRightShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >> matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.signPropagatingRightShift = function signPropagatingRightShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.signPropagatingRightShift(value);\r\n };\r\n\r\n AbstractMatrix.prototype.rightShift = function rightShift(value) {\r\n if (typeof value === 'number') return this.rightShiftS(value);\r\n return this.rightShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.rightShiftS = function rightShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >>> value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.rightShiftM = function rightShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >>> matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.rightShift = function rightShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.rightShift(value);\r\n };\r\n AbstractMatrix.prototype.zeroFillRightShift = AbstractMatrix.prototype.rightShift;\r\n AbstractMatrix.prototype.zeroFillRightShiftS = AbstractMatrix.prototype.rightShiftS;\r\n AbstractMatrix.prototype.zeroFillRightShiftM = AbstractMatrix.prototype.rightShiftM;\r\n AbstractMatrix.zeroFillRightShift = AbstractMatrix.rightShift;\r\n\r\n AbstractMatrix.prototype.not = function not() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, ~(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.not = function not(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.not();\r\n };\r\n\r\n AbstractMatrix.prototype.abs = function abs() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.abs(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.abs = function abs(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.abs();\r\n };\r\n\r\n AbstractMatrix.prototype.acos = function acos() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.acos(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.acos = function acos(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.acos();\r\n };\r\n\r\n AbstractMatrix.prototype.acosh = function acosh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.acosh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.acosh = function acosh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.acosh();\r\n };\r\n\r\n AbstractMatrix.prototype.asin = function asin() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.asin(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.asin = function asin(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.asin();\r\n };\r\n\r\n AbstractMatrix.prototype.asinh = function asinh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.asinh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.asinh = function asinh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.asinh();\r\n };\r\n\r\n AbstractMatrix.prototype.atan = function atan() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.atan(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.atan = function atan(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.atan();\r\n };\r\n\r\n AbstractMatrix.prototype.atanh = function atanh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.atanh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.atanh = function atanh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.atanh();\r\n };\r\n\r\n AbstractMatrix.prototype.cbrt = function cbrt() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cbrt(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cbrt = function cbrt(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cbrt();\r\n };\r\n\r\n AbstractMatrix.prototype.ceil = function ceil() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.ceil(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.ceil = function ceil(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.ceil();\r\n };\r\n\r\n AbstractMatrix.prototype.clz32 = function clz32() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.clz32(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.clz32 = function clz32(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.clz32();\r\n };\r\n\r\n AbstractMatrix.prototype.cos = function cos() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cos(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cos = function cos(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cos();\r\n };\r\n\r\n AbstractMatrix.prototype.cosh = function cosh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cosh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cosh = function cosh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cosh();\r\n };\r\n\r\n AbstractMatrix.prototype.exp = function exp() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.exp(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.exp = function exp(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.exp();\r\n };\r\n\r\n AbstractMatrix.prototype.expm1 = function expm1() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.expm1(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.expm1 = function expm1(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.expm1();\r\n };\r\n\r\n AbstractMatrix.prototype.floor = function floor() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.floor(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.floor = function floor(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.floor();\r\n };\r\n\r\n AbstractMatrix.prototype.fround = function fround() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.fround(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.fround = function fround(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.fround();\r\n };\r\n\r\n AbstractMatrix.prototype.log = function log() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log = function log(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log();\r\n };\r\n\r\n AbstractMatrix.prototype.log1p = function log1p() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log1p(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log1p = function log1p(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log1p();\r\n };\r\n\r\n AbstractMatrix.prototype.log10 = function log10() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log10(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log10 = function log10(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log10();\r\n };\r\n\r\n AbstractMatrix.prototype.log2 = function log2() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log2(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log2 = function log2(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log2();\r\n };\r\n\r\n AbstractMatrix.prototype.round = function round() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.round(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.round = function round(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.round();\r\n };\r\n\r\n AbstractMatrix.prototype.sign = function sign() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sign(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sign = function sign(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sign();\r\n };\r\n\r\n AbstractMatrix.prototype.sin = function sin() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sin(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sin = function sin(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sin();\r\n };\r\n\r\n AbstractMatrix.prototype.sinh = function sinh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sinh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sinh = function sinh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sinh();\r\n };\r\n\r\n AbstractMatrix.prototype.sqrt = function sqrt() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sqrt(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sqrt = function sqrt(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sqrt();\r\n };\r\n\r\n AbstractMatrix.prototype.tan = function tan() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.tan(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.tan = function tan(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.tan();\r\n };\r\n\r\n AbstractMatrix.prototype.tanh = function tanh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.tanh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.tanh = function tanh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.tanh();\r\n };\r\n\r\n AbstractMatrix.prototype.trunc = function trunc() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.trunc(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.trunc = function trunc(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.trunc();\r\n };\r\n\r\n AbstractMatrix.pow = function pow(matrix, arg0) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.pow(arg0);\r\n };\r\n\r\n AbstractMatrix.prototype.pow = function pow(value) {\r\n if (typeof value === 'number') return this.powS(value);\r\n return this.powM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.powS = function powS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.pow(this.get(i, j), value));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.powM = function powM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n}\r\n","/**\n * @private\n * Check that a row index is not out of bounds\n * @param {Matrix} matrix\n * @param {number} index\n * @param {boolean} [outer]\n */\nexport function checkRowIndex(matrix, index, outer) {\n let max = outer ? matrix.rows : matrix.rows - 1;\n if (index < 0 || index > max) {\n throw new RangeError('Row index out of range');\n }\n}\n\n/**\n * @private\n * Check that a column index is not out of bounds\n * @param {Matrix} matrix\n * @param {number} index\n * @param {boolean} [outer]\n */\nexport function checkColumnIndex(matrix, index, outer) {\n let max = outer ? matrix.columns : matrix.columns - 1;\n if (index < 0 || index > max) {\n throw new RangeError('Column index out of range');\n }\n}\n\n/**\n * @private\n * Check that the provided vector is an array with the right length\n * @param {Matrix} matrix\n * @param {Array|Matrix} vector\n * @return {Array}\n * @throws {RangeError}\n */\nexport function checkRowVector(matrix, vector) {\n if (vector.to1DArray) {\n vector = vector.to1DArray();\n }\n if (vector.length !== matrix.columns) {\n throw new RangeError(\n 'vector size must be the same as the number of columns',\n );\n }\n return vector;\n}\n\n/**\n * @private\n * Check that the provided vector is an array with the right length\n * @param {Matrix} matrix\n * @param {Array|Matrix} vector\n * @return {Array}\n * @throws {RangeError}\n */\nexport function checkColumnVector(matrix, vector) {\n if (vector.to1DArray) {\n vector = vector.to1DArray();\n }\n if (vector.length !== matrix.rows) {\n throw new RangeError('vector size must be the same as the number of rows');\n }\n return vector;\n}\n\nexport function checkIndices(matrix, rowIndices, columnIndices) {\n return {\n row: checkRowIndices(matrix, rowIndices),\n column: checkColumnIndices(matrix, columnIndices),\n };\n}\n\nexport function checkRowIndices(matrix, rowIndices) {\n if (typeof rowIndices !== 'object') {\n throw new TypeError('unexpected type for row indices');\n }\n\n let rowOut = rowIndices.some((r) => {\n return r < 0 || r >= matrix.rows;\n });\n\n if (rowOut) {\n throw new RangeError('row indices are out of range');\n }\n\n if (!Array.isArray(rowIndices)) rowIndices = Array.from(rowIndices);\n\n return rowIndices;\n}\n\nexport function checkColumnIndices(matrix, columnIndices) {\n if (typeof columnIndices !== 'object') {\n throw new TypeError('unexpected type for column indices');\n }\n\n let columnOut = columnIndices.some((c) => {\n return c < 0 || c >= matrix.columns;\n });\n\n if (columnOut) {\n throw new RangeError('column indices are out of range');\n }\n if (!Array.isArray(columnIndices)) columnIndices = Array.from(columnIndices);\n\n return columnIndices;\n}\n\nexport function checkRange(matrix, startRow, endRow, startColumn, endColumn) {\n if (arguments.length !== 5) {\n throw new RangeError('expected 4 arguments');\n }\n checkNumber('startRow', startRow);\n checkNumber('endRow', endRow);\n checkNumber('startColumn', startColumn);\n checkNumber('endColumn', endColumn);\n if (\n startRow > endRow ||\n startColumn > endColumn ||\n startRow < 0 ||\n startRow >= matrix.rows ||\n endRow < 0 ||\n endRow >= matrix.rows ||\n startColumn < 0 ||\n startColumn >= matrix.columns ||\n endColumn < 0 ||\n endColumn >= matrix.columns\n ) {\n throw new RangeError('Submatrix indices are out of range');\n }\n}\n\nexport function newArray(length, value = 0) {\n let array = [];\n for (let i = 0; i < length; i++) {\n array.push(value);\n }\n return array;\n}\n\nfunction checkNumber(name, value) {\n if (typeof value !== 'number') {\n throw new TypeError(`${name} must be a number`);\n }\n}\n","import { newArray } from './util';\n\nexport function sumByRow(matrix) {\n let sum = newArray(matrix.rows);\n for (let i = 0; i < matrix.rows; ++i) {\n for (let j = 0; j < matrix.columns; ++j) {\n sum[i] += matrix.get(i, j);\n }\n }\n return sum;\n}\n\nexport function sumByColumn(matrix) {\n let sum = newArray(matrix.columns);\n for (let i = 0; i < matrix.rows; ++i) {\n for (let j = 0; j < matrix.columns; ++j) {\n sum[j] += matrix.get(i, j);\n }\n }\n return sum;\n}\n\nexport function sumAll(matrix) {\n let v = 0;\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n v += matrix.get(i, j);\n }\n }\n return v;\n}\n\nexport function productByRow(matrix) {\n let sum = newArray(matrix.rows, 1);\n for (let i = 0; i < matrix.rows; ++i) {\n for (let j = 0; j < matrix.columns; ++j) {\n sum[i] *= matrix.get(i, j);\n }\n }\n return sum;\n}\n\nexport function productByColumn(matrix) {\n let sum = newArray(matrix.columns, 1);\n for (let i = 0; i < matrix.rows; ++i) {\n for (let j = 0; j < matrix.columns; ++j) {\n sum[j] *= matrix.get(i, j);\n }\n }\n return sum;\n}\n\nexport function productAll(matrix) {\n let v = 1;\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n v *= matrix.get(i, j);\n }\n }\n return v;\n}\n\nexport function varianceByRow(matrix, unbiased, mean) {\n const rows = matrix.rows;\n const cols = matrix.columns;\n const variance = [];\n\n for (let i = 0; i < rows; i++) {\n let sum1 = 0;\n let sum2 = 0;\n let x = 0;\n for (let j = 0; j < cols; j++) {\n x = matrix.get(i, j) - mean[i];\n sum1 += x;\n sum2 += x * x;\n }\n if (unbiased) {\n variance.push((sum2 - (sum1 * sum1) / cols) / (cols - 1));\n } else {\n variance.push((sum2 - (sum1 * sum1) / cols) / cols);\n }\n }\n return variance;\n}\n\nexport function varianceByColumn(matrix, unbiased, mean) {\n const rows = matrix.rows;\n const cols = matrix.columns;\n const variance = [];\n\n for (let j = 0; j < cols; j++) {\n let sum1 = 0;\n let sum2 = 0;\n let x = 0;\n for (let i = 0; i < rows; i++) {\n x = matrix.get(i, j) - mean[j];\n sum1 += x;\n sum2 += x * x;\n }\n if (unbiased) {\n variance.push((sum2 - (sum1 * sum1) / rows) / (rows - 1));\n } else {\n variance.push((sum2 - (sum1 * sum1) / rows) / rows);\n }\n }\n return variance;\n}\n\nexport function varianceAll(matrix, unbiased, mean) {\n const rows = matrix.rows;\n const cols = matrix.columns;\n const size = rows * cols;\n\n let sum1 = 0;\n let sum2 = 0;\n let x = 0;\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < cols; j++) {\n x = matrix.get(i, j) - mean;\n sum1 += x;\n sum2 += x * x;\n }\n }\n if (unbiased) {\n return (sum2 - (sum1 * sum1) / size) / (size - 1);\n } else {\n return (sum2 - (sum1 * sum1) / size) / size;\n }\n}\n\nexport function centerByRow(matrix, mean) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) - mean[i]);\n }\n }\n}\n\nexport function centerByColumn(matrix, mean) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) - mean[j]);\n }\n }\n}\n\nexport function centerAll(matrix, mean) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) - mean);\n }\n }\n}\n\nexport function getScaleByRow(matrix) {\n const scale = [];\n for (let i = 0; i < matrix.rows; i++) {\n let sum = 0;\n for (let j = 0; j < matrix.columns; j++) {\n sum += Math.pow(matrix.get(i, j), 2) / (matrix.columns - 1);\n }\n scale.push(Math.sqrt(sum));\n }\n return scale;\n}\n\nexport function scaleByRow(matrix, scale) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) / scale[i]);\n }\n }\n}\n\nexport function getScaleByColumn(matrix) {\n const scale = [];\n for (let j = 0; j < matrix.columns; j++) {\n let sum = 0;\n for (let i = 0; i < matrix.rows; i++) {\n sum += Math.pow(matrix.get(i, j), 2) / (matrix.rows - 1);\n }\n scale.push(Math.sqrt(sum));\n }\n return scale;\n}\n\nexport function scaleByColumn(matrix, scale) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) / scale[j]);\n }\n }\n}\n\nexport function getScaleAll(matrix) {\n const divider = matrix.size - 1;\n let sum = 0;\n for (let j = 0; j < matrix.columns; j++) {\n for (let i = 0; i < matrix.rows; i++) {\n sum += Math.pow(matrix.get(i, j), 2) / divider;\n }\n }\n return Math.sqrt(sum);\n}\n\nexport function scaleAll(matrix, scale) {\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n matrix.set(i, j, matrix.get(i, j) / scale);\n }\n }\n}\n","import rescale from 'ml-array-rescale';\n\nimport { inspectMatrix, inspectMatrixWithOptions } from './inspect';\nimport { installMathOperations } from './mathOperations';\nimport {\n sumByRow,\n sumByColumn,\n sumAll,\n productByRow,\n productByColumn,\n productAll,\n varianceByRow,\n varianceByColumn,\n varianceAll,\n centerByRow,\n centerByColumn,\n centerAll,\n scaleByRow,\n scaleByColumn,\n scaleAll,\n getScaleByRow,\n getScaleByColumn,\n getScaleAll,\n} from './stat';\nimport {\n checkRowVector,\n checkRowIndex,\n checkColumnIndex,\n checkColumnVector,\n checkRange,\n checkIndices,\n} from './util';\n\nexport class AbstractMatrix {\n static from1DArray(newRows, newColumns, newData) {\n let length = newRows * newColumns;\n if (length !== newData.length) {\n throw new RangeError('data length does not match given dimensions');\n }\n let newMatrix = new Matrix(newRows, newColumns);\n for (let row = 0; row < newRows; row++) {\n for (let column = 0; column < newColumns; column++) {\n newMatrix.set(row, column, newData[row * newColumns + column]);\n }\n }\n return newMatrix;\n }\n\n static rowVector(newData) {\n let vector = new Matrix(1, newData.length);\n for (let i = 0; i < newData.length; i++) {\n vector.set(0, i, newData[i]);\n }\n return vector;\n }\n\n static columnVector(newData) {\n let vector = new Matrix(newData.length, 1);\n for (let i = 0; i < newData.length; i++) {\n vector.set(i, 0, newData[i]);\n }\n return vector;\n }\n\n static zeros(rows, columns) {\n return new Matrix(rows, columns);\n }\n\n static ones(rows, columns) {\n return new Matrix(rows, columns).fill(1);\n }\n\n static rand(rows, columns, options = {}) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { random = Math.random } = options;\n let matrix = new Matrix(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n matrix.set(i, j, random());\n }\n }\n return matrix;\n }\n\n static randInt(rows, columns, options = {}) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { min = 0, max = 1000, random = Math.random } = options;\n if (!Number.isInteger(min)) throw new TypeError('min must be an integer');\n if (!Number.isInteger(max)) throw new TypeError('max must be an integer');\n if (min >= max) throw new RangeError('min must be smaller than max');\n let interval = max - min;\n let matrix = new Matrix(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n let value = min + Math.round(random() * interval);\n matrix.set(i, j, value);\n }\n }\n return matrix;\n }\n\n static eye(rows, columns, value) {\n if (columns === undefined) columns = rows;\n if (value === undefined) value = 1;\n let min = Math.min(rows, columns);\n let matrix = this.zeros(rows, columns);\n for (let i = 0; i < min; i++) {\n matrix.set(i, i, value);\n }\n return matrix;\n }\n\n static diag(data, rows, columns) {\n let l = data.length;\n if (rows === undefined) rows = l;\n if (columns === undefined) columns = rows;\n let min = Math.min(l, rows, columns);\n let matrix = this.zeros(rows, columns);\n for (let i = 0; i < min; i++) {\n matrix.set(i, i, data[i]);\n }\n return matrix;\n }\n\n static min(matrix1, matrix2) {\n matrix1 = this.checkMatrix(matrix1);\n matrix2 = this.checkMatrix(matrix2);\n let rows = matrix1.rows;\n let columns = matrix1.columns;\n let result = new Matrix(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n result.set(i, j, Math.min(matrix1.get(i, j), matrix2.get(i, j)));\n }\n }\n return result;\n }\n\n static max(matrix1, matrix2) {\n matrix1 = this.checkMatrix(matrix1);\n matrix2 = this.checkMatrix(matrix2);\n let rows = matrix1.rows;\n let columns = matrix1.columns;\n let result = new this(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n result.set(i, j, Math.max(matrix1.get(i, j), matrix2.get(i, j)));\n }\n }\n return result;\n }\n\n static checkMatrix(value) {\n return AbstractMatrix.isMatrix(value) ? value : new Matrix(value);\n }\n\n static isMatrix(value) {\n return value != null && value.klass === 'Matrix';\n }\n\n get size() {\n return this.rows * this.columns;\n }\n\n apply(callback) {\n if (typeof callback !== 'function') {\n throw new TypeError('callback must be a function');\n }\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n callback.call(this, i, j);\n }\n }\n return this;\n }\n\n to1DArray() {\n let array = [];\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n array.push(this.get(i, j));\n }\n }\n return array;\n }\n\n to2DArray() {\n let copy = [];\n for (let i = 0; i < this.rows; i++) {\n copy.push([]);\n for (let j = 0; j < this.columns; j++) {\n copy[i].push(this.get(i, j));\n }\n }\n return copy;\n }\n\n toJSON() {\n return this.to2DArray();\n }\n\n isRowVector() {\n return this.rows === 1;\n }\n\n isColumnVector() {\n return this.columns === 1;\n }\n\n isVector() {\n return this.rows === 1 || this.columns === 1;\n }\n\n isSquare() {\n return this.rows === this.columns;\n }\n\n isSymmetric() {\n if (this.isSquare()) {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j <= i; j++) {\n if (this.get(i, j) !== this.get(j, i)) {\n return false;\n }\n }\n }\n return true;\n }\n return false;\n }\n\n isEchelonForm() {\n let i = 0;\n let j = 0;\n let previousColumn = -1;\n let isEchelonForm = true;\n let checked = false;\n while (i < this.rows && isEchelonForm) {\n j = 0;\n checked = false;\n while (j < this.columns && checked === false) {\n if (this.get(i, j) === 0) {\n j++;\n } else if (this.get(i, j) === 1 && j > previousColumn) {\n checked = true;\n previousColumn = j;\n } else {\n isEchelonForm = false;\n checked = true;\n }\n }\n i++;\n }\n return isEchelonForm;\n }\n\n isReducedEchelonForm() {\n let i = 0;\n let j = 0;\n let previousColumn = -1;\n let isReducedEchelonForm = true;\n let checked = false;\n while (i < this.rows && isReducedEchelonForm) {\n j = 0;\n checked = false;\n while (j < this.columns && checked === false) {\n if (this.get(i, j) === 0) {\n j++;\n } else if (this.get(i, j) === 1 && j > previousColumn) {\n checked = true;\n previousColumn = j;\n } else {\n isReducedEchelonForm = false;\n checked = true;\n }\n }\n for (let k = j + 1; k < this.rows; k++) {\n if (this.get(i, k) !== 0) {\n isReducedEchelonForm = false;\n }\n }\n i++;\n }\n return isReducedEchelonForm;\n }\n\n echelonForm() {\n let result = this.clone();\n let h = 0;\n let k = 0;\n while (h < result.rows && k < result.columns) {\n let iMax = h;\n for (let i = h; i < result.rows; i++) {\n if (result.get(i, k) > result.get(iMax, k)) {\n iMax = i;\n }\n }\n if (result.get(iMax, k) === 0) {\n k++;\n } else {\n result.swapRows(h, iMax);\n let tmp = result.get(h, k);\n for (let j = k; j < result.columns; j++) {\n result.set(h, j, result.get(h, j) / tmp);\n }\n for (let i = h + 1; i < result.rows; i++) {\n let factor = result.get(i, k) / result.get(h, k);\n result.set(i, k, 0);\n for (let j = k + 1; j < result.columns; j++) {\n result.set(i, j, result.get(i, j) - result.get(h, j) * factor);\n }\n }\n h++;\n k++;\n }\n }\n return result;\n }\n\n reducedEchelonForm() {\n let result = this.echelonForm();\n let m = result.columns;\n let n = result.rows;\n let h = n - 1;\n while (h >= 0) {\n if (result.maxRow(h) === 0) {\n h--;\n } else {\n let p = 0;\n let pivot = false;\n while (p < n && pivot === false) {\n if (result.get(h, p) === 1) {\n pivot = true;\n } else {\n p++;\n }\n }\n for (let i = 0; i < h; i++) {\n let factor = result.get(i, p);\n for (let j = p; j < m; j++) {\n let tmp = result.get(i, j) - factor * result.get(h, j);\n result.set(i, j, tmp);\n }\n }\n h--;\n }\n }\n return result;\n }\n\n set() {\n throw new Error('set method is unimplemented');\n }\n\n get() {\n throw new Error('get method is unimplemented');\n }\n\n repeat(options = {}) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { rows = 1, columns = 1 } = options;\n if (!Number.isInteger(rows) || rows <= 0) {\n throw new TypeError('rows must be a positive integer');\n }\n if (!Number.isInteger(columns) || columns <= 0) {\n throw new TypeError('columns must be a positive integer');\n }\n let matrix = new Matrix(this.rows * rows, this.columns * columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n matrix.setSubMatrix(this, this.rows * i, this.columns * j);\n }\n }\n return matrix;\n }\n\n fill(value) {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, value);\n }\n }\n return this;\n }\n\n neg() {\n return this.mulS(-1);\n }\n\n getRow(index) {\n checkRowIndex(this, index);\n let row = [];\n for (let i = 0; i < this.columns; i++) {\n row.push(this.get(index, i));\n }\n return row;\n }\n\n getRowVector(index) {\n return Matrix.rowVector(this.getRow(index));\n }\n\n setRow(index, array) {\n checkRowIndex(this, index);\n array = checkRowVector(this, array);\n for (let i = 0; i < this.columns; i++) {\n this.set(index, i, array[i]);\n }\n return this;\n }\n\n swapRows(row1, row2) {\n checkRowIndex(this, row1);\n checkRowIndex(this, row2);\n for (let i = 0; i < this.columns; i++) {\n let temp = this.get(row1, i);\n this.set(row1, i, this.get(row2, i));\n this.set(row2, i, temp);\n }\n return this;\n }\n\n getColumn(index) {\n checkColumnIndex(this, index);\n let column = [];\n for (let i = 0; i < this.rows; i++) {\n column.push(this.get(i, index));\n }\n return column;\n }\n\n getColumnVector(index) {\n return Matrix.columnVector(this.getColumn(index));\n }\n\n setColumn(index, array) {\n checkColumnIndex(this, index);\n array = checkColumnVector(this, array);\n for (let i = 0; i < this.rows; i++) {\n this.set(i, index, array[i]);\n }\n return this;\n }\n\n swapColumns(column1, column2) {\n checkColumnIndex(this, column1);\n checkColumnIndex(this, column2);\n for (let i = 0; i < this.rows; i++) {\n let temp = this.get(i, column1);\n this.set(i, column1, this.get(i, column2));\n this.set(i, column2, temp);\n }\n return this;\n }\n\n addRowVector(vector) {\n vector = checkRowVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) + vector[j]);\n }\n }\n return this;\n }\n\n subRowVector(vector) {\n vector = checkRowVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) - vector[j]);\n }\n }\n return this;\n }\n\n mulRowVector(vector) {\n vector = checkRowVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) * vector[j]);\n }\n }\n return this;\n }\n\n divRowVector(vector) {\n vector = checkRowVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) / vector[j]);\n }\n }\n return this;\n }\n\n addColumnVector(vector) {\n vector = checkColumnVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) + vector[i]);\n }\n }\n return this;\n }\n\n subColumnVector(vector) {\n vector = checkColumnVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) - vector[i]);\n }\n }\n return this;\n }\n\n mulColumnVector(vector) {\n vector = checkColumnVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) * vector[i]);\n }\n }\n return this;\n }\n\n divColumnVector(vector) {\n vector = checkColumnVector(this, vector);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, this.get(i, j) / vector[i]);\n }\n }\n return this;\n }\n\n mulRow(index, value) {\n checkRowIndex(this, index);\n for (let i = 0; i < this.columns; i++) {\n this.set(index, i, this.get(index, i) * value);\n }\n return this;\n }\n\n mulColumn(index, value) {\n checkColumnIndex(this, index);\n for (let i = 0; i < this.rows; i++) {\n this.set(i, index, this.get(i, index) * value);\n }\n return this;\n }\n\n max() {\n let v = this.get(0, 0);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n if (this.get(i, j) > v) {\n v = this.get(i, j);\n }\n }\n }\n return v;\n }\n\n maxIndex() {\n let v = this.get(0, 0);\n let idx = [0, 0];\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n if (this.get(i, j) > v) {\n v = this.get(i, j);\n idx[0] = i;\n idx[1] = j;\n }\n }\n }\n return idx;\n }\n\n min() {\n let v = this.get(0, 0);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n if (this.get(i, j) < v) {\n v = this.get(i, j);\n }\n }\n }\n return v;\n }\n\n minIndex() {\n let v = this.get(0, 0);\n let idx = [0, 0];\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n if (this.get(i, j) < v) {\n v = this.get(i, j);\n idx[0] = i;\n idx[1] = j;\n }\n }\n }\n return idx;\n }\n\n maxRow(row) {\n checkRowIndex(this, row);\n let v = this.get(row, 0);\n for (let i = 1; i < this.columns; i++) {\n if (this.get(row, i) > v) {\n v = this.get(row, i);\n }\n }\n return v;\n }\n\n maxRowIndex(row) {\n checkRowIndex(this, row);\n let v = this.get(row, 0);\n let idx = [row, 0];\n for (let i = 1; i < this.columns; i++) {\n if (this.get(row, i) > v) {\n v = this.get(row, i);\n idx[1] = i;\n }\n }\n return idx;\n }\n\n minRow(row) {\n checkRowIndex(this, row);\n let v = this.get(row, 0);\n for (let i = 1; i < this.columns; i++) {\n if (this.get(row, i) < v) {\n v = this.get(row, i);\n }\n }\n return v;\n }\n\n minRowIndex(row) {\n checkRowIndex(this, row);\n let v = this.get(row, 0);\n let idx = [row, 0];\n for (let i = 1; i < this.columns; i++) {\n if (this.get(row, i) < v) {\n v = this.get(row, i);\n idx[1] = i;\n }\n }\n return idx;\n }\n\n maxColumn(column) {\n checkColumnIndex(this, column);\n let v = this.get(0, column);\n for (let i = 1; i < this.rows; i++) {\n if (this.get(i, column) > v) {\n v = this.get(i, column);\n }\n }\n return v;\n }\n\n maxColumnIndex(column) {\n checkColumnIndex(this, column);\n let v = this.get(0, column);\n let idx = [0, column];\n for (let i = 1; i < this.rows; i++) {\n if (this.get(i, column) > v) {\n v = this.get(i, column);\n idx[0] = i;\n }\n }\n return idx;\n }\n\n minColumn(column) {\n checkColumnIndex(this, column);\n let v = this.get(0, column);\n for (let i = 1; i < this.rows; i++) {\n if (this.get(i, column) < v) {\n v = this.get(i, column);\n }\n }\n return v;\n }\n\n minColumnIndex(column) {\n checkColumnIndex(this, column);\n let v = this.get(0, column);\n let idx = [0, column];\n for (let i = 1; i < this.rows; i++) {\n if (this.get(i, column) < v) {\n v = this.get(i, column);\n idx[0] = i;\n }\n }\n return idx;\n }\n\n diag() {\n let min = Math.min(this.rows, this.columns);\n let diag = [];\n for (let i = 0; i < min; i++) {\n diag.push(this.get(i, i));\n }\n return diag;\n }\n\n norm(type = 'frobenius') {\n let result = 0;\n if (type === 'max') {\n return this.max();\n } else if (type === 'frobenius') {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n result = result + this.get(i, j) * this.get(i, j);\n }\n }\n return Math.sqrt(result);\n } else {\n throw new RangeError(`unknown norm type: ${type}`);\n }\n }\n\n cumulativeSum() {\n let sum = 0;\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n sum += this.get(i, j);\n this.set(i, j, sum);\n }\n }\n return this;\n }\n\n dot(vector2) {\n if (AbstractMatrix.isMatrix(vector2)) vector2 = vector2.to1DArray();\n let vector1 = this.to1DArray();\n if (vector1.length !== vector2.length) {\n throw new RangeError('vectors do not have the same size');\n }\n let dot = 0;\n for (let i = 0; i < vector1.length; i++) {\n dot += vector1[i] * vector2[i];\n }\n return dot;\n }\n\n mmul(other) {\n other = Matrix.checkMatrix(other);\n\n let m = this.rows;\n let n = this.columns;\n let p = other.columns;\n\n let result = new Matrix(m, p);\n\n let Bcolj = new Float64Array(n);\n for (let j = 0; j < p; j++) {\n for (let k = 0; k < n; k++) {\n Bcolj[k] = other.get(k, j);\n }\n\n for (let i = 0; i < m; i++) {\n let s = 0;\n for (let k = 0; k < n; k++) {\n s += this.get(i, k) * Bcolj[k];\n }\n\n result.set(i, j, s);\n }\n }\n return result;\n }\n\n strassen2x2(other) {\n other = Matrix.checkMatrix(other);\n let result = new Matrix(2, 2);\n const a11 = this.get(0, 0);\n const b11 = other.get(0, 0);\n const a12 = this.get(0, 1);\n const b12 = other.get(0, 1);\n const a21 = this.get(1, 0);\n const b21 = other.get(1, 0);\n const a22 = this.get(1, 1);\n const b22 = other.get(1, 1);\n\n // Compute intermediate values.\n const m1 = (a11 + a22) * (b11 + b22);\n const m2 = (a21 + a22) * b11;\n const m3 = a11 * (b12 - b22);\n const m4 = a22 * (b21 - b11);\n const m5 = (a11 + a12) * b22;\n const m6 = (a21 - a11) * (b11 + b12);\n const m7 = (a12 - a22) * (b21 + b22);\n\n // Combine intermediate values into the output.\n const c00 = m1 + m4 - m5 + m7;\n const c01 = m3 + m5;\n const c10 = m2 + m4;\n const c11 = m1 - m2 + m3 + m6;\n\n result.set(0, 0, c00);\n result.set(0, 1, c01);\n result.set(1, 0, c10);\n result.set(1, 1, c11);\n return result;\n }\n\n strassen3x3(other) {\n other = Matrix.checkMatrix(other);\n let result = new Matrix(3, 3);\n\n const a00 = this.get(0, 0);\n const a01 = this.get(0, 1);\n const a02 = this.get(0, 2);\n const a10 = this.get(1, 0);\n const a11 = this.get(1, 1);\n const a12 = this.get(1, 2);\n const a20 = this.get(2, 0);\n const a21 = this.get(2, 1);\n const a22 = this.get(2, 2);\n\n const b00 = other.get(0, 0);\n const b01 = other.get(0, 1);\n const b02 = other.get(0, 2);\n const b10 = other.get(1, 0);\n const b11 = other.get(1, 1);\n const b12 = other.get(1, 2);\n const b20 = other.get(2, 0);\n const b21 = other.get(2, 1);\n const b22 = other.get(2, 2);\n\n const m1 = (a00 + a01 + a02 - a10 - a11 - a21 - a22) * b11;\n const m2 = (a00 - a10) * (-b01 + b11);\n const m3 = a11 * (-b00 + b01 + b10 - b11 - b12 - b20 + b22);\n const m4 = (-a00 + a10 + a11) * (b00 - b01 + b11);\n const m5 = (a10 + a11) * (-b00 + b01);\n const m6 = a00 * b00;\n const m7 = (-a00 + a20 + a21) * (b00 - b02 + b12);\n const m8 = (-a00 + a20) * (b02 - b12);\n const m9 = (a20 + a21) * (-b00 + b02);\n const m10 = (a00 + a01 + a02 - a11 - a12 - a20 - a21) * b12;\n const m11 = a21 * (-b00 + b02 + b10 - b11 - b12 - b20 + b21);\n const m12 = (-a02 + a21 + a22) * (b11 + b20 - b21);\n const m13 = (a02 - a22) * (b11 - b21);\n const m14 = a02 * b20;\n const m15 = (a21 + a22) * (-b20 + b21);\n const m16 = (-a02 + a11 + a12) * (b12 + b20 - b22);\n const m17 = (a02 - a12) * (b12 - b22);\n const m18 = (a11 + a12) * (-b20 + b22);\n const m19 = a01 * b10;\n const m20 = a12 * b21;\n const m21 = a10 * b02;\n const m22 = a20 * b01;\n const m23 = a22 * b22;\n\n const c00 = m6 + m14 + m19;\n const c01 = m1 + m4 + m5 + m6 + m12 + m14 + m15;\n const c02 = m6 + m7 + m9 + m10 + m14 + m16 + m18;\n const c10 = m2 + m3 + m4 + m6 + m14 + m16 + m17;\n const c11 = m2 + m4 + m5 + m6 + m20;\n const c12 = m14 + m16 + m17 + m18 + m21;\n const c20 = m6 + m7 + m8 + m11 + m12 + m13 + m14;\n const c21 = m12 + m13 + m14 + m15 + m22;\n const c22 = m6 + m7 + m8 + m9 + m23;\n\n result.set(0, 0, c00);\n result.set(0, 1, c01);\n result.set(0, 2, c02);\n result.set(1, 0, c10);\n result.set(1, 1, c11);\n result.set(1, 2, c12);\n result.set(2, 0, c20);\n result.set(2, 1, c21);\n result.set(2, 2, c22);\n return result;\n }\n\n mmulStrassen(y) {\n y = Matrix.checkMatrix(y);\n let x = this.clone();\n let r1 = x.rows;\n let c1 = x.columns;\n let r2 = y.rows;\n let c2 = y.columns;\n if (c1 !== r2) {\n // eslint-disable-next-line no-console\n console.warn(\n `Multiplying ${r1} x ${c1} and ${r2} x ${c2} matrix: dimensions do not match.`,\n );\n }\n\n // Put a matrix into the top left of a matrix of zeros.\n // `rows` and `cols` are the dimensions of the output matrix.\n function embed(mat, rows, cols) {\n let r = mat.rows;\n let c = mat.columns;\n if (r === rows && c === cols) {\n return mat;\n } else {\n let resultat = AbstractMatrix.zeros(rows, cols);\n resultat = resultat.setSubMatrix(mat, 0, 0);\n return resultat;\n }\n }\n\n // Make sure both matrices are the same size.\n // This is exclusively for simplicity:\n // this algorithm can be implemented with matrices of different sizes.\n\n let r = Math.max(r1, r2);\n let c = Math.max(c1, c2);\n x = embed(x, r, c);\n y = embed(y, r, c);\n\n // Our recursive multiplication function.\n function blockMult(a, b, rows, cols) {\n // For small matrices, resort to naive multiplication.\n if (rows <= 512 || cols <= 512) {\n return a.mmul(b); // a is equivalent to this\n }\n\n // Apply dynamic padding.\n if (rows % 2 === 1 && cols % 2 === 1) {\n a = embed(a, rows + 1, cols + 1);\n b = embed(b, rows + 1, cols + 1);\n } else if (rows % 2 === 1) {\n a = embed(a, rows + 1, cols);\n b = embed(b, rows + 1, cols);\n } else if (cols % 2 === 1) {\n a = embed(a, rows, cols + 1);\n b = embed(b, rows, cols + 1);\n }\n\n let halfRows = parseInt(a.rows / 2, 10);\n let halfCols = parseInt(a.columns / 2, 10);\n // Subdivide input matrices.\n let a11 = a.subMatrix(0, halfRows - 1, 0, halfCols - 1);\n let b11 = b.subMatrix(0, halfRows - 1, 0, halfCols - 1);\n\n let a12 = a.subMatrix(0, halfRows - 1, halfCols, a.columns - 1);\n let b12 = b.subMatrix(0, halfRows - 1, halfCols, b.columns - 1);\n\n let a21 = a.subMatrix(halfRows, a.rows - 1, 0, halfCols - 1);\n let b21 = b.subMatrix(halfRows, b.rows - 1, 0, halfCols - 1);\n\n let a22 = a.subMatrix(halfRows, a.rows - 1, halfCols, a.columns - 1);\n let b22 = b.subMatrix(halfRows, b.rows - 1, halfCols, b.columns - 1);\n\n // Compute intermediate values.\n let m1 = blockMult(\n AbstractMatrix.add(a11, a22),\n AbstractMatrix.add(b11, b22),\n halfRows,\n halfCols,\n );\n let m2 = blockMult(AbstractMatrix.add(a21, a22), b11, halfRows, halfCols);\n let m3 = blockMult(a11, AbstractMatrix.sub(b12, b22), halfRows, halfCols);\n let m4 = blockMult(a22, AbstractMatrix.sub(b21, b11), halfRows, halfCols);\n let m5 = blockMult(AbstractMatrix.add(a11, a12), b22, halfRows, halfCols);\n let m6 = blockMult(\n AbstractMatrix.sub(a21, a11),\n AbstractMatrix.add(b11, b12),\n halfRows,\n halfCols,\n );\n let m7 = blockMult(\n AbstractMatrix.sub(a12, a22),\n AbstractMatrix.add(b21, b22),\n halfRows,\n halfCols,\n );\n\n // Combine intermediate values into the output.\n let c11 = AbstractMatrix.add(m1, m4);\n c11.sub(m5);\n c11.add(m7);\n let c12 = AbstractMatrix.add(m3, m5);\n let c21 = AbstractMatrix.add(m2, m4);\n let c22 = AbstractMatrix.sub(m1, m2);\n c22.add(m3);\n c22.add(m6);\n\n // Crop output to the desired size (undo dynamic padding).\n let resultat = AbstractMatrix.zeros(2 * c11.rows, 2 * c11.columns);\n resultat = resultat.setSubMatrix(c11, 0, 0);\n resultat = resultat.setSubMatrix(c12, c11.rows, 0);\n resultat = resultat.setSubMatrix(c21, 0, c11.columns);\n resultat = resultat.setSubMatrix(c22, c11.rows, c11.columns);\n return resultat.subMatrix(0, rows - 1, 0, cols - 1);\n }\n return blockMult(x, y, r, c);\n }\n\n scaleRows(options = {}) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { min = 0, max = 1 } = options;\n if (!Number.isFinite(min)) throw new TypeError('min must be a number');\n if (!Number.isFinite(max)) throw new TypeError('max must be a number');\n if (min >= max) throw new RangeError('min must be smaller than max');\n let newMatrix = new Matrix(this.rows, this.columns);\n for (let i = 0; i < this.rows; i++) {\n const row = this.getRow(i);\n rescale(row, { min, max, output: row });\n newMatrix.setRow(i, row);\n }\n return newMatrix;\n }\n\n scaleColumns(options = {}) {\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { min = 0, max = 1 } = options;\n if (!Number.isFinite(min)) throw new TypeError('min must be a number');\n if (!Number.isFinite(max)) throw new TypeError('max must be a number');\n if (min >= max) throw new RangeError('min must be smaller than max');\n let newMatrix = new Matrix(this.rows, this.columns);\n for (let i = 0; i < this.columns; i++) {\n const column = this.getColumn(i);\n rescale(column, {\n min: min,\n max: max,\n output: column,\n });\n newMatrix.setColumn(i, column);\n }\n return newMatrix;\n }\n\n flipRows() {\n const middle = Math.ceil(this.columns / 2);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < middle; j++) {\n let first = this.get(i, j);\n let last = this.get(i, this.columns - 1 - j);\n this.set(i, j, last);\n this.set(i, this.columns - 1 - j, first);\n }\n }\n return this;\n }\n\n flipColumns() {\n const middle = Math.ceil(this.rows / 2);\n for (let j = 0; j < this.columns; j++) {\n for (let i = 0; i < middle; i++) {\n let first = this.get(i, j);\n let last = this.get(this.rows - 1 - i, j);\n this.set(i, j, last);\n this.set(this.rows - 1 - i, j, first);\n }\n }\n return this;\n }\n\n kroneckerProduct(other) {\n other = Matrix.checkMatrix(other);\n\n let m = this.rows;\n let n = this.columns;\n let p = other.rows;\n let q = other.columns;\n\n let result = new Matrix(m * p, n * q);\n for (let i = 0; i < m; i++) {\n for (let j = 0; j < n; j++) {\n for (let k = 0; k < p; k++) {\n for (let l = 0; l < q; l++) {\n result.set(p * i + k, q * j + l, this.get(i, j) * other.get(k, l));\n }\n }\n }\n }\n return result;\n }\n\n transpose() {\n let result = new Matrix(this.columns, this.rows);\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n result.set(j, i, this.get(i, j));\n }\n }\n return result;\n }\n\n sortRows(compareFunction = compareNumbers) {\n for (let i = 0; i < this.rows; i++) {\n this.setRow(i, this.getRow(i).sort(compareFunction));\n }\n return this;\n }\n\n sortColumns(compareFunction = compareNumbers) {\n for (let i = 0; i < this.columns; i++) {\n this.setColumn(i, this.getColumn(i).sort(compareFunction));\n }\n return this;\n }\n\n subMatrix(startRow, endRow, startColumn, endColumn) {\n checkRange(this, startRow, endRow, startColumn, endColumn);\n let newMatrix = new Matrix(\n endRow - startRow + 1,\n endColumn - startColumn + 1,\n );\n for (let i = startRow; i <= endRow; i++) {\n for (let j = startColumn; j <= endColumn; j++) {\n newMatrix.set(i - startRow, j - startColumn, this.get(i, j));\n }\n }\n return newMatrix;\n }\n\n subMatrixRow(indices, startColumn, endColumn) {\n if (startColumn === undefined) startColumn = 0;\n if (endColumn === undefined) endColumn = this.columns - 1;\n if (\n startColumn > endColumn ||\n startColumn < 0 ||\n startColumn >= this.columns ||\n endColumn < 0 ||\n endColumn >= this.columns\n ) {\n throw new RangeError('Argument out of range');\n }\n\n let newMatrix = new Matrix(indices.length, endColumn - startColumn + 1);\n for (let i = 0; i < indices.length; i++) {\n for (let j = startColumn; j <= endColumn; j++) {\n if (indices[i] < 0 || indices[i] >= this.rows) {\n throw new RangeError(`Row index out of range: ${indices[i]}`);\n }\n newMatrix.set(i, j - startColumn, this.get(indices[i], j));\n }\n }\n return newMatrix;\n }\n\n subMatrixColumn(indices, startRow, endRow) {\n if (startRow === undefined) startRow = 0;\n if (endRow === undefined) endRow = this.rows - 1;\n if (\n startRow > endRow ||\n startRow < 0 ||\n startRow >= this.rows ||\n endRow < 0 ||\n endRow >= this.rows\n ) {\n throw new RangeError('Argument out of range');\n }\n\n let newMatrix = new Matrix(endRow - startRow + 1, indices.length);\n for (let i = 0; i < indices.length; i++) {\n for (let j = startRow; j <= endRow; j++) {\n if (indices[i] < 0 || indices[i] >= this.columns) {\n throw new RangeError(`Column index out of range: ${indices[i]}`);\n }\n newMatrix.set(j - startRow, i, this.get(j, indices[i]));\n }\n }\n return newMatrix;\n }\n\n setSubMatrix(matrix, startRow, startColumn) {\n matrix = Matrix.checkMatrix(matrix);\n let endRow = startRow + matrix.rows - 1;\n let endColumn = startColumn + matrix.columns - 1;\n checkRange(this, startRow, endRow, startColumn, endColumn);\n for (let i = 0; i < matrix.rows; i++) {\n for (let j = 0; j < matrix.columns; j++) {\n this.set(startRow + i, startColumn + j, matrix.get(i, j));\n }\n }\n return this;\n }\n\n selection(rowIndices, columnIndices) {\n let indices = checkIndices(this, rowIndices, columnIndices);\n let newMatrix = new Matrix(rowIndices.length, columnIndices.length);\n for (let i = 0; i < indices.row.length; i++) {\n let rowIndex = indices.row[i];\n for (let j = 0; j < indices.column.length; j++) {\n let columnIndex = indices.column[j];\n newMatrix.set(i, j, this.get(rowIndex, columnIndex));\n }\n }\n return newMatrix;\n }\n\n trace() {\n let min = Math.min(this.rows, this.columns);\n let trace = 0;\n for (let i = 0; i < min; i++) {\n trace += this.get(i, i);\n }\n return trace;\n }\n\n clone() {\n let newMatrix = new Matrix(this.rows, this.columns);\n for (let row = 0; row < this.rows; row++) {\n for (let column = 0; column < this.columns; column++) {\n newMatrix.set(row, column, this.get(row, column));\n }\n }\n return newMatrix;\n }\n\n sum(by) {\n switch (by) {\n case 'row':\n return sumByRow(this);\n case 'column':\n return sumByColumn(this);\n case undefined:\n return sumAll(this);\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n product(by) {\n switch (by) {\n case 'row':\n return productByRow(this);\n case 'column':\n return productByColumn(this);\n case undefined:\n return productAll(this);\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n mean(by) {\n const sum = this.sum(by);\n switch (by) {\n case 'row': {\n for (let i = 0; i < this.rows; i++) {\n sum[i] /= this.columns;\n }\n return sum;\n }\n case 'column': {\n for (let i = 0; i < this.columns; i++) {\n sum[i] /= this.rows;\n }\n return sum;\n }\n case undefined:\n return sum / this.size;\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n variance(by, options = {}) {\n if (typeof by === 'object') {\n options = by;\n by = undefined;\n }\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { unbiased = true, mean = this.mean(by) } = options;\n if (typeof unbiased !== 'boolean') {\n throw new TypeError('unbiased must be a boolean');\n }\n switch (by) {\n case 'row': {\n if (!Array.isArray(mean)) {\n throw new TypeError('mean must be an array');\n }\n return varianceByRow(this, unbiased, mean);\n }\n case 'column': {\n if (!Array.isArray(mean)) {\n throw new TypeError('mean must be an array');\n }\n return varianceByColumn(this, unbiased, mean);\n }\n case undefined: {\n if (typeof mean !== 'number') {\n throw new TypeError('mean must be a number');\n }\n return varianceAll(this, unbiased, mean);\n }\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n standardDeviation(by, options) {\n if (typeof by === 'object') {\n options = by;\n by = undefined;\n }\n const variance = this.variance(by, options);\n if (by === undefined) {\n return Math.sqrt(variance);\n } else {\n for (let i = 0; i < variance.length; i++) {\n variance[i] = Math.sqrt(variance[i]);\n }\n return variance;\n }\n }\n\n center(by, options = {}) {\n if (typeof by === 'object') {\n options = by;\n by = undefined;\n }\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n const { center = this.mean(by) } = options;\n switch (by) {\n case 'row': {\n if (!Array.isArray(center)) {\n throw new TypeError('center must be an array');\n }\n centerByRow(this, center);\n return this;\n }\n case 'column': {\n if (!Array.isArray(center)) {\n throw new TypeError('center must be an array');\n }\n centerByColumn(this, center);\n return this;\n }\n case undefined: {\n if (typeof center !== 'number') {\n throw new TypeError('center must be a number');\n }\n centerAll(this, center);\n return this;\n }\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n scale(by, options = {}) {\n if (typeof by === 'object') {\n options = by;\n by = undefined;\n }\n if (typeof options !== 'object') {\n throw new TypeError('options must be an object');\n }\n let scale = options.scale;\n switch (by) {\n case 'row': {\n if (scale === undefined) {\n scale = getScaleByRow(this);\n } else if (!Array.isArray(scale)) {\n throw new TypeError('scale must be an array');\n }\n scaleByRow(this, scale);\n return this;\n }\n case 'column': {\n if (scale === undefined) {\n scale = getScaleByColumn(this);\n } else if (!Array.isArray(scale)) {\n throw new TypeError('scale must be an array');\n }\n scaleByColumn(this, scale);\n return this;\n }\n case undefined: {\n if (scale === undefined) {\n scale = getScaleAll(this);\n } else if (typeof scale !== 'number') {\n throw new TypeError('scale must be a number');\n }\n scaleAll(this, scale);\n return this;\n }\n default:\n throw new Error(`invalid option: ${by}`);\n }\n }\n\n toString(options) {\n return inspectMatrixWithOptions(this, options);\n }\n}\n\nAbstractMatrix.prototype.klass = 'Matrix';\nif (typeof Symbol !== 'undefined') {\n AbstractMatrix.prototype[\n Symbol.for('nodejs.util.inspect.custom')\n ] = inspectMatrix;\n}\n\nfunction compareNumbers(a, b) {\n return a - b;\n}\n\n// Synonyms\nAbstractMatrix.random = AbstractMatrix.rand;\nAbstractMatrix.randomInt = AbstractMatrix.randInt;\nAbstractMatrix.diagonal = AbstractMatrix.diag;\nAbstractMatrix.prototype.diagonal = AbstractMatrix.prototype.diag;\nAbstractMatrix.identity = AbstractMatrix.eye;\nAbstractMatrix.prototype.negate = AbstractMatrix.prototype.neg;\nAbstractMatrix.prototype.tensorProduct =\n AbstractMatrix.prototype.kroneckerProduct;\n\nexport default class Matrix extends AbstractMatrix {\n constructor(nRows, nColumns) {\n super();\n if (Matrix.isMatrix(nRows)) {\n return nRows.clone();\n } else if (Number.isInteger(nRows) && nRows > 0) {\n // Create an empty matrix\n this.data = [];\n if (Number.isInteger(nColumns) && nColumns > 0) {\n for (let i = 0; i < nRows; i++) {\n this.data.push(new Float64Array(nColumns));\n }\n } else {\n throw new TypeError('nColumns must be a positive integer');\n }\n } else if (Array.isArray(nRows)) {\n // Copy the values from the 2D array\n const arrayData = nRows;\n nRows = arrayData.length;\n nColumns = arrayData[0].length;\n if (typeof nColumns !== 'number' || nColumns === 0) {\n throw new TypeError(\n 'Data must be a 2D array with at least one element',\n );\n }\n this.data = [];\n for (let i = 0; i < nRows; i++) {\n if (arrayData[i].length !== nColumns) {\n throw new RangeError('Inconsistent array dimensions');\n }\n this.data.push(Float64Array.from(arrayData[i]));\n }\n } else {\n throw new TypeError(\n 'First argument must be a positive number or an array',\n );\n }\n this.rows = nRows;\n this.columns = nColumns;\n return this;\n }\n\n set(rowIndex, columnIndex, value) {\n this.data[rowIndex][columnIndex] = value;\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.data[rowIndex][columnIndex];\n }\n\n removeRow(index) {\n checkRowIndex(this, index);\n if (this.rows === 1) {\n throw new RangeError('A matrix cannot have less than one row');\n }\n this.data.splice(index, 1);\n this.rows -= 1;\n return this;\n }\n\n addRow(index, array) {\n if (array === undefined) {\n array = index;\n index = this.rows;\n }\n checkRowIndex(this, index, true);\n array = Float64Array.from(checkRowVector(this, array, true));\n this.data.splice(index, 0, array);\n this.rows += 1;\n return this;\n }\n\n removeColumn(index) {\n checkColumnIndex(this, index);\n if (this.columns === 1) {\n throw new RangeError('A matrix cannot have less than one column');\n }\n for (let i = 0; i < this.rows; i++) {\n const newRow = new Float64Array(this.columns - 1);\n for (let j = 0; j < index; j++) {\n newRow[j] = this.data[i][j];\n }\n for (let j = index + 1; j < this.columns; j++) {\n newRow[j - 1] = this.data[i][j];\n }\n this.data[i] = newRow;\n }\n this.columns -= 1;\n return this;\n }\n\n addColumn(index, array) {\n if (typeof array === 'undefined') {\n array = index;\n index = this.columns;\n }\n checkColumnIndex(this, index, true);\n array = checkColumnVector(this, array);\n for (let i = 0; i < this.rows; i++) {\n const newRow = new Float64Array(this.columns + 1);\n let j = 0;\n for (; j < index; j++) {\n newRow[j] = this.data[i][j];\n }\n newRow[j++] = array[i];\n for (; j < this.columns + 1; j++) {\n newRow[j] = this.data[i][j - 1];\n }\n this.data[i] = newRow;\n }\n this.columns += 1;\n return this;\n }\n}\n\ninstallMathOperations(AbstractMatrix, Matrix);\n","import { AbstractMatrix } from '../matrix';\n\nexport default class BaseView extends AbstractMatrix {\n constructor(matrix, rows, columns) {\n super();\n this.matrix = matrix;\n this.rows = rows;\n this.columns = columns;\n }\n}\n","import { checkColumnIndex } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixColumnView extends BaseView {\n constructor(matrix, column) {\n checkColumnIndex(matrix, column);\n super(matrix, matrix.rows, 1);\n this.column = column;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(rowIndex, this.column, value);\n return this;\n }\n\n get(rowIndex) {\n return this.matrix.get(rowIndex, this.column);\n }\n}\n","import { checkColumnIndices } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixColumnSelectionView extends BaseView {\n constructor(matrix, columnIndices) {\n columnIndices = checkColumnIndices(matrix, columnIndices);\n super(matrix, matrix.rows, columnIndices.length);\n this.columnIndices = columnIndices;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(rowIndex, this.columnIndices[columnIndex], value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(rowIndex, this.columnIndices[columnIndex]);\n }\n}\n","import BaseView from './base';\n\nexport default class MatrixFlipColumnView extends BaseView {\n constructor(matrix) {\n super(matrix, matrix.rows, matrix.columns);\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(rowIndex, this.columns - columnIndex - 1, value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(rowIndex, this.columns - columnIndex - 1);\n }\n}\n","import BaseView from './base';\n\nexport default class MatrixFlipRowView extends BaseView {\n constructor(matrix) {\n super(matrix, matrix.rows, matrix.columns);\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(this.rows - rowIndex - 1, columnIndex, value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(this.rows - rowIndex - 1, columnIndex);\n }\n}\n","import { checkRowIndex } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixRowView extends BaseView {\n constructor(matrix, row) {\n checkRowIndex(matrix, row);\n super(matrix, 1, matrix.columns);\n this.row = row;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(this.row, columnIndex, value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(this.row, columnIndex);\n }\n}\n","import { checkRowIndices } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixRowSelectionView extends BaseView {\n constructor(matrix, rowIndices) {\n rowIndices = checkRowIndices(matrix, rowIndices);\n super(matrix, rowIndices.length, matrix.columns);\n this.rowIndices = rowIndices;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(this.rowIndices[rowIndex], columnIndex, value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(this.rowIndices[rowIndex], columnIndex);\n }\n}\n","import { checkIndices } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixSelectionView extends BaseView {\n constructor(matrix, rowIndices, columnIndices) {\n let indices = checkIndices(matrix, rowIndices, columnIndices);\n super(matrix, indices.row.length, indices.column.length);\n this.rowIndices = indices.row;\n this.columnIndices = indices.column;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(\n this.rowIndices[rowIndex],\n this.columnIndices[columnIndex],\n value,\n );\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(\n this.rowIndices[rowIndex],\n this.columnIndices[columnIndex],\n );\n }\n}\n","import { checkRange } from '../util';\n\nimport BaseView from './base';\n\nexport default class MatrixSubView extends BaseView {\n constructor(matrix, startRow, endRow, startColumn, endColumn) {\n checkRange(matrix, startRow, endRow, startColumn, endColumn);\n super(matrix, endRow - startRow + 1, endColumn - startColumn + 1);\n this.startRow = startRow;\n this.startColumn = startColumn;\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(\n this.startRow + rowIndex,\n this.startColumn + columnIndex,\n value,\n );\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(\n this.startRow + rowIndex,\n this.startColumn + columnIndex,\n );\n }\n}\n","import BaseView from './base';\n\nexport default class MatrixTransposeView extends BaseView {\n constructor(matrix) {\n super(matrix, matrix.columns, matrix.rows);\n }\n\n set(rowIndex, columnIndex, value) {\n this.matrix.set(columnIndex, rowIndex, value);\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.matrix.get(columnIndex, rowIndex);\n }\n}\n","import { AbstractMatrix } from '../matrix';\n\nexport default class WrapperMatrix1D extends AbstractMatrix {\n constructor(data, options = {}) {\n const { rows = 1 } = options;\n\n if (data.length % rows !== 0) {\n throw new Error('the data length is not divisible by the number of rows');\n }\n super();\n this.rows = rows;\n this.columns = data.length / rows;\n this.data = data;\n }\n\n set(rowIndex, columnIndex, value) {\n let index = this._calculateIndex(rowIndex, columnIndex);\n this.data[index] = value;\n return this;\n }\n\n get(rowIndex, columnIndex) {\n let index = this._calculateIndex(rowIndex, columnIndex);\n return this.data[index];\n }\n\n _calculateIndex(row, column) {\n return row * this.columns + column;\n }\n}\n","import { AbstractMatrix } from '../matrix';\n\nexport default class WrapperMatrix2D extends AbstractMatrix {\n constructor(data) {\n super();\n this.data = data;\n this.rows = data.length;\n this.columns = data[0].length;\n }\n\n set(rowIndex, columnIndex, value) {\n this.data[rowIndex][columnIndex] = value;\n return this;\n }\n\n get(rowIndex, columnIndex) {\n return this.data[rowIndex][columnIndex];\n }\n}\n","import WrapperMatrix1D from './WrapperMatrix1D';\nimport WrapperMatrix2D from './WrapperMatrix2D';\n\nexport function wrap(array, options) {\n if (Array.isArray(array)) {\n if (array[0] && Array.isArray(array[0])) {\n return new WrapperMatrix2D(array);\n } else {\n return new WrapperMatrix1D(array, options);\n }\n } else {\n throw new Error('the argument is not an array');\n }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nexport default class LuDecomposition {\n constructor(matrix) {\n matrix = WrapperMatrix2D.checkMatrix(matrix);\n\n let lu = matrix.clone();\n let rows = lu.rows;\n let columns = lu.columns;\n let pivotVector = new Float64Array(rows);\n let pivotSign = 1;\n let i, j, k, p, s, t, v;\n let LUcolj, kmax;\n\n for (i = 0; i < rows; i++) {\n pivotVector[i] = i;\n }\n\n LUcolj = new Float64Array(rows);\n\n for (j = 0; j < columns; j++) {\n for (i = 0; i < rows; i++) {\n LUcolj[i] = lu.get(i, j);\n }\n\n for (i = 0; i < rows; i++) {\n kmax = Math.min(i, j);\n s = 0;\n for (k = 0; k < kmax; k++) {\n s += lu.get(i, k) * LUcolj[k];\n }\n LUcolj[i] -= s;\n lu.set(i, j, LUcolj[i]);\n }\n\n p = j;\n for (i = j + 1; i < rows; i++) {\n if (Math.abs(LUcolj[i]) > Math.abs(LUcolj[p])) {\n p = i;\n }\n }\n\n if (p !== j) {\n for (k = 0; k < columns; k++) {\n t = lu.get(p, k);\n lu.set(p, k, lu.get(j, k));\n lu.set(j, k, t);\n }\n\n v = pivotVector[p];\n pivotVector[p] = pivotVector[j];\n pivotVector[j] = v;\n\n pivotSign = -pivotSign;\n }\n\n if (j < rows && lu.get(j, j) !== 0) {\n for (i = j + 1; i < rows; i++) {\n lu.set(i, j, lu.get(i, j) / lu.get(j, j));\n }\n }\n }\n\n this.LU = lu;\n this.pivotVector = pivotVector;\n this.pivotSign = pivotSign;\n }\n\n isSingular() {\n let data = this.LU;\n let col = data.columns;\n for (let j = 0; j < col; j++) {\n if (data.get(j, j) === 0) {\n return true;\n }\n }\n return false;\n }\n\n solve(value) {\n value = Matrix.checkMatrix(value);\n\n let lu = this.LU;\n let rows = lu.rows;\n\n if (rows !== value.rows) {\n throw new Error('Invalid matrix dimensions');\n }\n if (this.isSingular()) {\n throw new Error('LU matrix is singular');\n }\n\n let count = value.columns;\n let X = value.subMatrixRow(this.pivotVector, 0, count - 1);\n let columns = lu.columns;\n let i, j, k;\n\n for (k = 0; k < columns; k++) {\n for (i = k + 1; i < columns; i++) {\n for (j = 0; j < count; j++) {\n X.set(i, j, X.get(i, j) - X.get(k, j) * lu.get(i, k));\n }\n }\n }\n for (k = columns - 1; k >= 0; k--) {\n for (j = 0; j < count; j++) {\n X.set(k, j, X.get(k, j) / lu.get(k, k));\n }\n for (i = 0; i < k; i++) {\n for (j = 0; j < count; j++) {\n X.set(i, j, X.get(i, j) - X.get(k, j) * lu.get(i, k));\n }\n }\n }\n return X;\n }\n\n get determinant() {\n let data = this.LU;\n if (!data.isSquare()) {\n throw new Error('Matrix must be square');\n }\n let determinant = this.pivotSign;\n let col = data.columns;\n for (let j = 0; j < col; j++) {\n determinant *= data.get(j, j);\n }\n return determinant;\n }\n\n get lowerTriangularMatrix() {\n let data = this.LU;\n let rows = data.rows;\n let columns = data.columns;\n let X = new Matrix(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n if (i > j) {\n X.set(i, j, data.get(i, j));\n } else if (i === j) {\n X.set(i, j, 1);\n } else {\n X.set(i, j, 0);\n }\n }\n }\n return X;\n }\n\n get upperTriangularMatrix() {\n let data = this.LU;\n let rows = data.rows;\n let columns = data.columns;\n let X = new Matrix(rows, columns);\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < columns; j++) {\n if (i <= j) {\n X.set(i, j, data.get(i, j));\n } else {\n X.set(i, j, 0);\n }\n }\n }\n return X;\n }\n\n get pivotPermutationVector() {\n return Array.from(this.pivotVector);\n }\n}\n","export function hypotenuse(a, b) {\n let r = 0;\n if (Math.abs(a) > Math.abs(b)) {\n r = b / a;\n return Math.abs(a) * Math.sqrt(1 + r * r);\n }\n if (b !== 0) {\n r = a / b;\n return Math.abs(b) * Math.sqrt(1 + r * r);\n }\n return 0;\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nimport { hypotenuse } from './util';\n\nexport default class QrDecomposition {\n constructor(value) {\n value = WrapperMatrix2D.checkMatrix(value);\n\n let qr = value.clone();\n let m = value.rows;\n let n = value.columns;\n let rdiag = new Float64Array(n);\n let i, j, k, s;\n\n for (k = 0; k < n; k++) {\n let nrm = 0;\n for (i = k; i < m; i++) {\n nrm = hypotenuse(nrm, qr.get(i, k));\n }\n if (nrm !== 0) {\n if (qr.get(k, k) < 0) {\n nrm = -nrm;\n }\n for (i = k; i < m; i++) {\n qr.set(i, k, qr.get(i, k) / nrm);\n }\n qr.set(k, k, qr.get(k, k) + 1);\n for (j = k + 1; j < n; j++) {\n s = 0;\n for (i = k; i < m; i++) {\n s += qr.get(i, k) * qr.get(i, j);\n }\n s = -s / qr.get(k, k);\n for (i = k; i < m; i++) {\n qr.set(i, j, qr.get(i, j) + s * qr.get(i, k));\n }\n }\n }\n rdiag[k] = -nrm;\n }\n\n this.QR = qr;\n this.Rdiag = rdiag;\n }\n\n solve(value) {\n value = Matrix.checkMatrix(value);\n\n let qr = this.QR;\n let m = qr.rows;\n\n if (value.rows !== m) {\n throw new Error('Matrix row dimensions must agree');\n }\n if (!this.isFullRank()) {\n throw new Error('Matrix is rank deficient');\n }\n\n let count = value.columns;\n let X = value.clone();\n let n = qr.columns;\n let i, j, k, s;\n\n for (k = 0; k < n; k++) {\n for (j = 0; j < count; j++) {\n s = 0;\n for (i = k; i < m; i++) {\n s += qr.get(i, k) * X.get(i, j);\n }\n s = -s / qr.get(k, k);\n for (i = k; i < m; i++) {\n X.set(i, j, X.get(i, j) + s * qr.get(i, k));\n }\n }\n }\n for (k = n - 1; k >= 0; k--) {\n for (j = 0; j < count; j++) {\n X.set(k, j, X.get(k, j) / this.Rdiag[k]);\n }\n for (i = 0; i < k; i++) {\n for (j = 0; j < count; j++) {\n X.set(i, j, X.get(i, j) - X.get(k, j) * qr.get(i, k));\n }\n }\n }\n\n return X.subMatrix(0, n - 1, 0, count - 1);\n }\n\n isFullRank() {\n let columns = this.QR.columns;\n for (let i = 0; i < columns; i++) {\n if (this.Rdiag[i] === 0) {\n return false;\n }\n }\n return true;\n }\n\n get upperTriangularMatrix() {\n let qr = this.QR;\n let n = qr.columns;\n let X = new Matrix(n, n);\n let i, j;\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n if (i < j) {\n X.set(i, j, qr.get(i, j));\n } else if (i === j) {\n X.set(i, j, this.Rdiag[i]);\n } else {\n X.set(i, j, 0);\n }\n }\n }\n return X;\n }\n\n get orthogonalMatrix() {\n let qr = this.QR;\n let rows = qr.rows;\n let columns = qr.columns;\n let X = new Matrix(rows, columns);\n let i, j, k, s;\n\n for (k = columns - 1; k >= 0; k--) {\n for (i = 0; i < rows; i++) {\n X.set(i, k, 0);\n }\n X.set(k, k, 1);\n for (j = k; j < columns; j++) {\n if (qr.get(k, k) !== 0) {\n s = 0;\n for (i = k; i < rows; i++) {\n s += qr.get(i, k) * X.get(i, j);\n }\n\n s = -s / qr.get(k, k);\n\n for (i = k; i < rows; i++) {\n X.set(i, j, X.get(i, j) + s * qr.get(i, k));\n }\n }\n }\n }\n return X;\n }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nimport { hypotenuse } from './util';\n\nexport default class SingularValueDecomposition {\n constructor(value, options = {}) {\n value = WrapperMatrix2D.checkMatrix(value);\n\n let m = value.rows;\n let n = value.columns;\n\n const {\n computeLeftSingularVectors = true,\n computeRightSingularVectors = true,\n autoTranspose = false,\n } = options;\n\n let wantu = Boolean(computeLeftSingularVectors);\n let wantv = Boolean(computeRightSingularVectors);\n\n let swapped = false;\n let a;\n if (m < n) {\n if (!autoTranspose) {\n a = value.clone();\n // eslint-disable-next-line no-console\n console.warn(\n 'Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose',\n );\n } else {\n a = value.transpose();\n m = a.rows;\n n = a.columns;\n swapped = true;\n let aux = wantu;\n wantu = wantv;\n wantv = aux;\n }\n } else {\n a = value.clone();\n }\n\n let nu = Math.min(m, n);\n let ni = Math.min(m + 1, n);\n let s = new Float64Array(ni);\n let U = new Matrix(m, nu);\n let V = new Matrix(n, n);\n\n let e = new Float64Array(n);\n let work = new Float64Array(m);\n\n let si = new Float64Array(ni);\n for (let i = 0; i < ni; i++) si[i] = i;\n\n let nct = Math.min(m - 1, n);\n let nrt = Math.max(0, Math.min(n - 2, m));\n let mrc = Math.max(nct, nrt);\n\n for (let k = 0; k < mrc; k++) {\n if (k < nct) {\n s[k] = 0;\n for (let i = k; i < m; i++) {\n s[k] = hypotenuse(s[k], a.get(i, k));\n }\n if (s[k] !== 0) {\n if (a.get(k, k) < 0) {\n s[k] = -s[k];\n }\n for (let i = k; i < m; i++) {\n a.set(i, k, a.get(i, k) / s[k]);\n }\n a.set(k, k, a.get(k, k) + 1);\n }\n s[k] = -s[k];\n }\n\n for (let j = k + 1; j < n; j++) {\n if (k < nct && s[k] !== 0) {\n let t = 0;\n for (let i = k; i < m; i++) {\n t += a.get(i, k) * a.get(i, j);\n }\n t = -t / a.get(k, k);\n for (let i = k; i < m; i++) {\n a.set(i, j, a.get(i, j) + t * a.get(i, k));\n }\n }\n e[j] = a.get(k, j);\n }\n\n if (wantu && k < nct) {\n for (let i = k; i < m; i++) {\n U.set(i, k, a.get(i, k));\n }\n }\n\n if (k < nrt) {\n e[k] = 0;\n for (let i = k + 1; i < n; i++) {\n e[k] = hypotenuse(e[k], e[i]);\n }\n if (e[k] !== 0) {\n if (e[k + 1] < 0) {\n e[k] = 0 - e[k];\n }\n for (let i = k + 1; i < n; i++) {\n e[i] /= e[k];\n }\n e[k + 1] += 1;\n }\n e[k] = -e[k];\n if (k + 1 < m && e[k] !== 0) {\n for (let i = k + 1; i < m; i++) {\n work[i] = 0;\n }\n for (let i = k + 1; i < m; i++) {\n for (let j = k + 1; j < n; j++) {\n work[i] += e[j] * a.get(i, j);\n }\n }\n for (let j = k + 1; j < n; j++) {\n let t = -e[j] / e[k + 1];\n for (let i = k + 1; i < m; i++) {\n a.set(i, j, a.get(i, j) + t * work[i]);\n }\n }\n }\n if (wantv) {\n for (let i = k + 1; i < n; i++) {\n V.set(i, k, e[i]);\n }\n }\n }\n }\n\n let p = Math.min(n, m + 1);\n if (nct < n) {\n s[nct] = a.get(nct, nct);\n }\n if (m < p) {\n s[p - 1] = 0;\n }\n if (nrt + 1 < p) {\n e[nrt] = a.get(nrt, p - 1);\n }\n e[p - 1] = 0;\n\n if (wantu) {\n for (let j = nct; j < nu; j++) {\n for (let i = 0; i < m; i++) {\n U.set(i, j, 0);\n }\n U.set(j, j, 1);\n }\n for (let k = nct - 1; k >= 0; k--) {\n if (s[k] !== 0) {\n for (let j = k + 1; j < nu; j++) {\n let t = 0;\n for (let i = k; i < m; i++) {\n t += U.get(i, k) * U.get(i, j);\n }\n t = -t / U.get(k, k);\n for (let i = k; i < m; i++) {\n U.set(i, j, U.get(i, j) + t * U.get(i, k));\n }\n }\n for (let i = k; i < m; i++) {\n U.set(i, k, -U.get(i, k));\n }\n U.set(k, k, 1 + U.get(k, k));\n for (let i = 0; i < k - 1; i++) {\n U.set(i, k, 0);\n }\n } else {\n for (let i = 0; i < m; i++) {\n U.set(i, k, 0);\n }\n U.set(k, k, 1);\n }\n }\n }\n\n if (wantv) {\n for (let k = n - 1; k >= 0; k--) {\n if (k < nrt && e[k] !== 0) {\n for (let j = k + 1; j < n; j++) {\n let t = 0;\n for (let i = k + 1; i < n; i++) {\n t += V.get(i, k) * V.get(i, j);\n }\n t = -t / V.get(k + 1, k);\n for (let i = k + 1; i < n; i++) {\n V.set(i, j, V.get(i, j) + t * V.get(i, k));\n }\n }\n }\n for (let i = 0; i < n; i++) {\n V.set(i, k, 0);\n }\n V.set(k, k, 1);\n }\n }\n\n let pp = p - 1;\n let iter = 0;\n let eps = Number.EPSILON;\n while (p > 0) {\n let k, kase;\n for (k = p - 2; k >= -1; k--) {\n if (k === -1) {\n break;\n }\n const alpha =\n Number.MIN_VALUE + eps * Math.abs(s[k] + Math.abs(s[k + 1]));\n if (Math.abs(e[k]) <= alpha || Number.isNaN(e[k])) {\n e[k] = 0;\n break;\n }\n }\n if (k === p - 2) {\n kase = 4;\n } else {\n let ks;\n for (ks = p - 1; ks >= k; ks--) {\n if (ks === k) {\n break;\n }\n let t =\n (ks !== p ? Math.abs(e[ks]) : 0) +\n (ks !== k + 1 ? Math.abs(e[ks - 1]) : 0);\n if (Math.abs(s[ks]) <= eps * t) {\n s[ks] = 0;\n break;\n }\n }\n if (ks === k) {\n kase = 3;\n } else if (ks === p - 1) {\n kase = 1;\n } else {\n kase = 2;\n k = ks;\n }\n }\n\n k++;\n\n switch (kase) {\n case 1: {\n let f = e[p - 2];\n e[p - 2] = 0;\n for (let j = p - 2; j >= k; j--) {\n let t = hypotenuse(s[j], f);\n let cs = s[j] / t;\n let sn = f / t;\n s[j] = t;\n if (j !== k) {\n f = -sn * e[j - 1];\n e[j - 1] = cs * e[j - 1];\n }\n if (wantv) {\n for (let i = 0; i < n; i++) {\n t = cs * V.get(i, j) + sn * V.get(i, p - 1);\n V.set(i, p - 1, -sn * V.get(i, j) + cs * V.get(i, p - 1));\n V.set(i, j, t);\n }\n }\n }\n break;\n }\n case 2: {\n let f = e[k - 1];\n e[k - 1] = 0;\n for (let j = k; j < p; j++) {\n let t = hypotenuse(s[j], f);\n let cs = s[j] / t;\n let sn = f / t;\n s[j] = t;\n f = -sn * e[j];\n e[j] = cs * e[j];\n if (wantu) {\n for (let i = 0; i < m; i++) {\n t = cs * U.get(i, j) + sn * U.get(i, k - 1);\n U.set(i, k - 1, -sn * U.get(i, j) + cs * U.get(i, k - 1));\n U.set(i, j, t);\n }\n }\n }\n break;\n }\n case 3: {\n const scale = Math.max(\n Math.abs(s[p - 1]),\n Math.abs(s[p - 2]),\n Math.abs(e[p - 2]),\n Math.abs(s[k]),\n Math.abs(e[k]),\n );\n const sp = s[p - 1] / scale;\n const spm1 = s[p - 2] / scale;\n const epm1 = e[p - 2] / scale;\n const sk = s[k] / scale;\n const ek = e[k] / scale;\n const b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2;\n const c = sp * epm1 * (sp * epm1);\n let shift = 0;\n if (b !== 0 || c !== 0) {\n if (b < 0) {\n shift = 0 - Math.sqrt(b * b + c);\n } else {\n shift = Math.sqrt(b * b + c);\n }\n shift = c / (b + shift);\n }\n let f = (sk + sp) * (sk - sp) + shift;\n let g = sk * ek;\n for (let j = k; j < p - 1; j++) {\n let t = hypotenuse(f, g);\n if (t === 0) t = Number.MIN_VALUE;\n let cs = f / t;\n let sn = g / t;\n if (j !== k) {\n e[j - 1] = t;\n }\n f = cs * s[j] + sn * e[j];\n e[j] = cs * e[j] - sn * s[j];\n g = sn * s[j + 1];\n s[j + 1] = cs * s[j + 1];\n if (wantv) {\n for (let i = 0; i < n; i++) {\n t = cs * V.get(i, j) + sn * V.get(i, j + 1);\n V.set(i, j + 1, -sn * V.get(i, j) + cs * V.get(i, j + 1));\n V.set(i, j, t);\n }\n }\n t = hypotenuse(f, g);\n if (t === 0) t = Number.MIN_VALUE;\n cs = f / t;\n sn = g / t;\n s[j] = t;\n f = cs * e[j] + sn * s[j + 1];\n s[j + 1] = -sn * e[j] + cs * s[j + 1];\n g = sn * e[j + 1];\n e[j + 1] = cs * e[j + 1];\n if (wantu && j < m - 1) {\n for (let i = 0; i < m; i++) {\n t = cs * U.get(i, j) + sn * U.get(i, j + 1);\n U.set(i, j + 1, -sn * U.get(i, j) + cs * U.get(i, j + 1));\n U.set(i, j, t);\n }\n }\n }\n e[p - 2] = f;\n iter = iter + 1;\n break;\n }\n case 4: {\n if (s[k] <= 0) {\n s[k] = s[k] < 0 ? -s[k] : 0;\n if (wantv) {\n for (let i = 0; i <= pp; i++) {\n V.set(i, k, -V.get(i, k));\n }\n }\n }\n while (k < pp) {\n if (s[k] >= s[k + 1]) {\n break;\n }\n let t = s[k];\n s[k] = s[k + 1];\n s[k + 1] = t;\n if (wantv && k < n - 1) {\n for (let i = 0; i < n; i++) {\n t = V.get(i, k + 1);\n V.set(i, k + 1, V.get(i, k));\n V.set(i, k, t);\n }\n }\n if (wantu && k < m - 1) {\n for (let i = 0; i < m; i++) {\n t = U.get(i, k + 1);\n U.set(i, k + 1, U.get(i, k));\n U.set(i, k, t);\n }\n }\n k++;\n }\n iter = 0;\n p--;\n break;\n }\n // no default\n }\n }\n\n if (swapped) {\n let tmp = V;\n V = U;\n U = tmp;\n }\n\n this.m = m;\n this.n = n;\n this.s = s;\n this.U = U;\n this.V = V;\n }\n\n solve(value) {\n let Y = value;\n let e = this.threshold;\n let scols = this.s.length;\n let Ls = Matrix.zeros(scols, scols);\n\n for (let i = 0; i < scols; i++) {\n if (Math.abs(this.s[i]) <= e) {\n Ls.set(i, i, 0);\n } else {\n Ls.set(i, i, 1 / this.s[i]);\n }\n }\n\n let U = this.U;\n let V = this.rightSingularVectors;\n\n let VL = V.mmul(Ls);\n let vrows = V.rows;\n let urows = U.rows;\n let VLU = Matrix.zeros(vrows, urows);\n\n for (let i = 0; i < vrows; i++) {\n for (let j = 0; j < urows; j++) {\n let sum = 0;\n for (let k = 0; k < scols; k++) {\n sum += VL.get(i, k) * U.get(j, k);\n }\n VLU.set(i, j, sum);\n }\n }\n\n return VLU.mmul(Y);\n }\n\n solveForDiagonal(value) {\n return this.solve(Matrix.diag(value));\n }\n\n inverse() {\n let V = this.V;\n let e = this.threshold;\n let vrows = V.rows;\n let vcols = V.columns;\n let X = new Matrix(vrows, this.s.length);\n\n for (let i = 0; i < vrows; i++) {\n for (let j = 0; j < vcols; j++) {\n if (Math.abs(this.s[j]) > e) {\n X.set(i, j, V.get(i, j) / this.s[j]);\n }\n }\n }\n\n let U = this.U;\n\n let urows = U.rows;\n let ucols = U.columns;\n let Y = new Matrix(vrows, urows);\n\n for (let i = 0; i < vrows; i++) {\n for (let j = 0; j < urows; j++) {\n let sum = 0;\n for (let k = 0; k < ucols; k++) {\n sum += X.get(i, k) * U.get(j, k);\n }\n Y.set(i, j, sum);\n }\n }\n\n return Y;\n }\n\n get condition() {\n return this.s[0] / this.s[Math.min(this.m, this.n) - 1];\n }\n\n get norm2() {\n return this.s[0];\n }\n\n get rank() {\n let tol = Math.max(this.m, this.n) * this.s[0] * Number.EPSILON;\n let r = 0;\n let s = this.s;\n for (let i = 0, ii = s.length; i < ii; i++) {\n if (s[i] > tol) {\n r++;\n }\n }\n return r;\n }\n\n get diagonal() {\n return Array.from(this.s);\n }\n\n get threshold() {\n return (Number.EPSILON / 2) * Math.max(this.m, this.n) * this.s[0];\n }\n\n get leftSingularVectors() {\n return this.U;\n }\n\n get rightSingularVectors() {\n return this.V;\n }\n\n get diagonalMatrix() {\n return Matrix.diag(this.s);\n }\n}\n","import LuDecomposition from './dc/lu';\nimport QrDecomposition from './dc/qr';\nimport SingularValueDecomposition from './dc/svd';\nimport Matrix from './matrix';\nimport WrapperMatrix2D from './wrap/WrapperMatrix2D';\n\nexport function inverse(matrix, useSVD = false) {\n matrix = WrapperMatrix2D.checkMatrix(matrix);\n if (useSVD) {\n return new SingularValueDecomposition(matrix).inverse();\n } else {\n return solve(matrix, Matrix.eye(matrix.rows));\n }\n}\n\nexport function solve(leftHandSide, rightHandSide, useSVD = false) {\n leftHandSide = WrapperMatrix2D.checkMatrix(leftHandSide);\n rightHandSide = WrapperMatrix2D.checkMatrix(rightHandSide);\n if (useSVD) {\n return new SingularValueDecomposition(leftHandSide).solve(rightHandSide);\n } else {\n return leftHandSide.isSquare()\n ? new LuDecomposition(leftHandSide).solve(rightHandSide)\n : new QrDecomposition(leftHandSide).solve(rightHandSide);\n }\n}\n","import LuDecomposition from './dc/lu';\nimport Matrix from './matrix';\nimport MatrixSelectionView from './views/selection';\n\nexport function determinant(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (matrix.isSquare()) {\n let a, b, c, d;\n if (matrix.columns === 2) {\n // 2 x 2 matrix\n a = matrix.get(0, 0);\n b = matrix.get(0, 1);\n c = matrix.get(1, 0);\n d = matrix.get(1, 1);\n\n return a * d - b * c;\n } else if (matrix.columns === 3) {\n // 3 x 3 matrix\n let subMatrix0, subMatrix1, subMatrix2;\n subMatrix0 = new MatrixSelectionView(matrix, [1, 2], [1, 2]);\n subMatrix1 = new MatrixSelectionView(matrix, [1, 2], [0, 2]);\n subMatrix2 = new MatrixSelectionView(matrix, [1, 2], [0, 1]);\n a = matrix.get(0, 0);\n b = matrix.get(0, 1);\n c = matrix.get(0, 2);\n\n return (\n a * determinant(subMatrix0) -\n b * determinant(subMatrix1) +\n c * determinant(subMatrix2)\n );\n } else {\n // general purpose determinant using the LU decomposition\n return new LuDecomposition(matrix).determinant;\n }\n } else {\n throw Error('determinant can only be calculated for a square matrix');\n }\n}\n","import SingularValueDecomposition from './dc/svd';\nimport Matrix from './matrix';\n\nfunction xrange(n, exception) {\n let range = [];\n for (let i = 0; i < n; i++) {\n if (i !== exception) {\n range.push(i);\n }\n }\n return range;\n}\n\nfunction dependenciesOneRow(\n error,\n matrix,\n index,\n thresholdValue = 10e-10,\n thresholdError = 10e-10,\n) {\n if (error > thresholdError) {\n return new Array(matrix.rows + 1).fill(0);\n } else {\n let returnArray = matrix.addRow(index, [0]);\n for (let i = 0; i < returnArray.rows; i++) {\n if (Math.abs(returnArray.get(i, 0)) < thresholdValue) {\n returnArray.set(i, 0, 0);\n }\n }\n return returnArray.to1DArray();\n }\n}\n\nexport function linearDependencies(matrix, options = {}) {\n const { thresholdValue = 10e-10, thresholdError = 10e-10 } = options;\n matrix = Matrix.checkMatrix(matrix);\n\n let n = matrix.rows;\n let results = new Matrix(n, n);\n\n for (let i = 0; i < n; i++) {\n let b = Matrix.columnVector(matrix.getRow(i));\n let Abis = matrix.subMatrixRow(xrange(n, i)).transpose();\n let svd = new SingularValueDecomposition(Abis);\n let x = svd.solve(b);\n let error = Matrix.sub(b, Abis.mmul(x)).abs().max();\n results.setRow(\n i,\n dependenciesOneRow(error, x, i, thresholdValue, thresholdError),\n );\n }\n return results;\n}\n","import SVD from './dc/svd';\nimport Matrix from './matrix';\n\nexport function pseudoInverse(matrix, threshold = Number.EPSILON) {\n matrix = Matrix.checkMatrix(matrix);\n let svdSolution = new SVD(matrix, { autoTranspose: true });\n\n let U = svdSolution.leftSingularVectors;\n let V = svdSolution.rightSingularVectors;\n let s = svdSolution.diagonal;\n\n for (let i = 0; i < s.length; i++) {\n if (Math.abs(s[i]) > threshold) {\n s[i] = 1.0 / s[i];\n } else {\n s[i] = 0.0;\n }\n }\n\n return V.mmul(Matrix.diag(s).mmul(U.transpose()));\n}\n","import Matrix from './matrix';\n\nexport function covariance(xMatrix, yMatrix = xMatrix, options = {}) {\n xMatrix = new Matrix(xMatrix);\n let yIsSame = false;\n if (\n typeof yMatrix === 'object' &&\n !Matrix.isMatrix(yMatrix) &&\n !Array.isArray(yMatrix)\n ) {\n options = yMatrix;\n yMatrix = xMatrix;\n yIsSame = true;\n } else {\n yMatrix = new Matrix(yMatrix);\n }\n if (xMatrix.rows !== yMatrix.rows) {\n throw new TypeError('Both matrices must have the same number of rows');\n }\n const { center = true } = options;\n if (center) {\n xMatrix = xMatrix.center('column');\n if (!yIsSame) {\n yMatrix = yMatrix.center('column');\n }\n }\n const cov = xMatrix.transpose().mmul(yMatrix);\n for (let i = 0; i < cov.rows; i++) {\n for (let j = 0; j < cov.columns; j++) {\n cov.set(i, j, cov.get(i, j) * (1 / (xMatrix.rows - 1)));\n }\n }\n return cov;\n}\n","import Matrix from './matrix';\n\nexport function correlation(xMatrix, yMatrix = xMatrix, options = {}) {\n xMatrix = new Matrix(xMatrix);\n let yIsSame = false;\n if (\n typeof yMatrix === 'object' &&\n !Matrix.isMatrix(yMatrix) &&\n !Array.isArray(yMatrix)\n ) {\n options = yMatrix;\n yMatrix = xMatrix;\n yIsSame = true;\n } else {\n yMatrix = new Matrix(yMatrix);\n }\n if (xMatrix.rows !== yMatrix.rows) {\n throw new TypeError('Both matrices must have the same number of rows');\n }\n\n const { center = true, scale = true } = options;\n if (center) {\n xMatrix.center('column');\n if (!yIsSame) {\n yMatrix.center('column');\n }\n }\n if (scale) {\n xMatrix.scale('column');\n if (!yIsSame) {\n yMatrix.scale('column');\n }\n }\n\n const sdx = xMatrix.standardDeviation('column', { unbiased: true });\n const sdy = yIsSame\n ? sdx\n : yMatrix.standardDeviation('column', { unbiased: true });\n\n const corr = xMatrix.transpose().mmul(yMatrix);\n for (let i = 0; i < corr.rows; i++) {\n for (let j = 0; j < corr.columns; j++) {\n corr.set(\n i,\n j,\n corr.get(i, j) * (1 / (sdx[i] * sdy[j])) * (1 / (xMatrix.rows - 1)),\n );\n }\n }\n return corr;\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nimport { hypotenuse } from './util';\n\nexport default class EigenvalueDecomposition {\n constructor(matrix, options = {}) {\n const { assumeSymmetric = false } = options;\n\n matrix = WrapperMatrix2D.checkMatrix(matrix);\n if (!matrix.isSquare()) {\n throw new Error('Matrix is not a square matrix');\n }\n\n let n = matrix.columns;\n let V = new Matrix(n, n);\n let d = new Float64Array(n);\n let e = new Float64Array(n);\n let value = matrix;\n let i, j;\n\n let isSymmetric = false;\n if (assumeSymmetric) {\n isSymmetric = true;\n } else {\n isSymmetric = matrix.isSymmetric();\n }\n\n if (isSymmetric) {\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n V.set(i, j, value.get(i, j));\n }\n }\n tred2(n, e, d, V);\n tql2(n, e, d, V);\n } else {\n let H = new Matrix(n, n);\n let ort = new Float64Array(n);\n for (j = 0; j < n; j++) {\n for (i = 0; i < n; i++) {\n H.set(i, j, value.get(i, j));\n }\n }\n orthes(n, H, ort, V);\n hqr2(n, e, d, V, H);\n }\n\n this.n = n;\n this.e = e;\n this.d = d;\n this.V = V;\n }\n\n get realEigenvalues() {\n return Array.from(this.d);\n }\n\n get imaginaryEigenvalues() {\n return Array.from(this.e);\n }\n\n get eigenvectorMatrix() {\n return this.V;\n }\n\n get diagonalMatrix() {\n let n = this.n;\n let e = this.e;\n let d = this.d;\n let X = new Matrix(n, n);\n let i, j;\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n X.set(i, j, 0);\n }\n X.set(i, i, d[i]);\n if (e[i] > 0) {\n X.set(i, i + 1, e[i]);\n } else if (e[i] < 0) {\n X.set(i, i - 1, e[i]);\n }\n }\n return X;\n }\n}\n\nfunction tred2(n, e, d, V) {\n let f, g, h, i, j, k, hh, scale;\n\n for (j = 0; j < n; j++) {\n d[j] = V.get(n - 1, j);\n }\n\n for (i = n - 1; i > 0; i--) {\n scale = 0;\n h = 0;\n for (k = 0; k < i; k++) {\n scale = scale + Math.abs(d[k]);\n }\n\n if (scale === 0) {\n e[i] = d[i - 1];\n for (j = 0; j < i; j++) {\n d[j] = V.get(i - 1, j);\n V.set(i, j, 0);\n V.set(j, i, 0);\n }\n } else {\n for (k = 0; k < i; k++) {\n d[k] /= scale;\n h += d[k] * d[k];\n }\n\n f = d[i - 1];\n g = Math.sqrt(h);\n if (f > 0) {\n g = -g;\n }\n\n e[i] = scale * g;\n h = h - f * g;\n d[i - 1] = f - g;\n for (j = 0; j < i; j++) {\n e[j] = 0;\n }\n\n for (j = 0; j < i; j++) {\n f = d[j];\n V.set(j, i, f);\n g = e[j] + V.get(j, j) * f;\n for (k = j + 1; k <= i - 1; k++) {\n g += V.get(k, j) * d[k];\n e[k] += V.get(k, j) * f;\n }\n e[j] = g;\n }\n\n f = 0;\n for (j = 0; j < i; j++) {\n e[j] /= h;\n f += e[j] * d[j];\n }\n\n hh = f / (h + h);\n for (j = 0; j < i; j++) {\n e[j] -= hh * d[j];\n }\n\n for (j = 0; j < i; j++) {\n f = d[j];\n g = e[j];\n for (k = j; k <= i - 1; k++) {\n V.set(k, j, V.get(k, j) - (f * e[k] + g * d[k]));\n }\n d[j] = V.get(i - 1, j);\n V.set(i, j, 0);\n }\n }\n d[i] = h;\n }\n\n for (i = 0; i < n - 1; i++) {\n V.set(n - 1, i, V.get(i, i));\n V.set(i, i, 1);\n h = d[i + 1];\n if (h !== 0) {\n for (k = 0; k <= i; k++) {\n d[k] = V.get(k, i + 1) / h;\n }\n\n for (j = 0; j <= i; j++) {\n g = 0;\n for (k = 0; k <= i; k++) {\n g += V.get(k, i + 1) * V.get(k, j);\n }\n for (k = 0; k <= i; k++) {\n V.set(k, j, V.get(k, j) - g * d[k]);\n }\n }\n }\n\n for (k = 0; k <= i; k++) {\n V.set(k, i + 1, 0);\n }\n }\n\n for (j = 0; j < n; j++) {\n d[j] = V.get(n - 1, j);\n V.set(n - 1, j, 0);\n }\n\n V.set(n - 1, n - 1, 1);\n e[0] = 0;\n}\n\nfunction tql2(n, e, d, V) {\n let g, h, i, j, k, l, m, p, r, dl1, c, c2, c3, el1, s, s2, iter;\n\n for (i = 1; i < n; i++) {\n e[i - 1] = e[i];\n }\n\n e[n - 1] = 0;\n\n let f = 0;\n let tst1 = 0;\n let eps = Number.EPSILON;\n\n for (l = 0; l < n; l++) {\n tst1 = Math.max(tst1, Math.abs(d[l]) + Math.abs(e[l]));\n m = l;\n while (m < n) {\n if (Math.abs(e[m]) <= eps * tst1) {\n break;\n }\n m++;\n }\n\n if (m > l) {\n iter = 0;\n do {\n iter = iter + 1;\n\n g = d[l];\n p = (d[l + 1] - g) / (2 * e[l]);\n r = hypotenuse(p, 1);\n if (p < 0) {\n r = -r;\n }\n\n d[l] = e[l] / (p + r);\n d[l + 1] = e[l] * (p + r);\n dl1 = d[l + 1];\n h = g - d[l];\n for (i = l + 2; i < n; i++) {\n d[i] -= h;\n }\n\n f = f + h;\n\n p = d[m];\n c = 1;\n c2 = c;\n c3 = c;\n el1 = e[l + 1];\n s = 0;\n s2 = 0;\n for (i = m - 1; i >= l; i--) {\n c3 = c2;\n c2 = c;\n s2 = s;\n g = c * e[i];\n h = c * p;\n r = hypotenuse(p, e[i]);\n e[i + 1] = s * r;\n s = e[i] / r;\n c = p / r;\n p = c * d[i] - s * g;\n d[i + 1] = h + s * (c * g + s * d[i]);\n\n for (k = 0; k < n; k++) {\n h = V.get(k, i + 1);\n V.set(k, i + 1, s * V.get(k, i) + c * h);\n V.set(k, i, c * V.get(k, i) - s * h);\n }\n }\n\n p = (-s * s2 * c3 * el1 * e[l]) / dl1;\n e[l] = s * p;\n d[l] = c * p;\n } while (Math.abs(e[l]) > eps * tst1);\n }\n d[l] = d[l] + f;\n e[l] = 0;\n }\n\n for (i = 0; i < n - 1; i++) {\n k = i;\n p = d[i];\n for (j = i + 1; j < n; j++) {\n if (d[j] < p) {\n k = j;\n p = d[j];\n }\n }\n\n if (k !== i) {\n d[k] = d[i];\n d[i] = p;\n for (j = 0; j < n; j++) {\n p = V.get(j, i);\n V.set(j, i, V.get(j, k));\n V.set(j, k, p);\n }\n }\n }\n}\n\nfunction orthes(n, H, ort, V) {\n let low = 0;\n let high = n - 1;\n let f, g, h, i, j, m;\n let scale;\n\n for (m = low + 1; m <= high - 1; m++) {\n scale = 0;\n for (i = m; i <= high; i++) {\n scale = scale + Math.abs(H.get(i, m - 1));\n }\n\n if (scale !== 0) {\n h = 0;\n for (i = high; i >= m; i--) {\n ort[i] = H.get(i, m - 1) / scale;\n h += ort[i] * ort[i];\n }\n\n g = Math.sqrt(h);\n if (ort[m] > 0) {\n g = -g;\n }\n\n h = h - ort[m] * g;\n ort[m] = ort[m] - g;\n\n for (j = m; j < n; j++) {\n f = 0;\n for (i = high; i >= m; i--) {\n f += ort[i] * H.get(i, j);\n }\n\n f = f / h;\n for (i = m; i <= high; i++) {\n H.set(i, j, H.get(i, j) - f * ort[i]);\n }\n }\n\n for (i = 0; i <= high; i++) {\n f = 0;\n for (j = high; j >= m; j--) {\n f += ort[j] * H.get(i, j);\n }\n\n f = f / h;\n for (j = m; j <= high; j++) {\n H.set(i, j, H.get(i, j) - f * ort[j]);\n }\n }\n\n ort[m] = scale * ort[m];\n H.set(m, m - 1, scale * g);\n }\n }\n\n for (i = 0; i < n; i++) {\n for (j = 0; j < n; j++) {\n V.set(i, j, i === j ? 1 : 0);\n }\n }\n\n for (m = high - 1; m >= low + 1; m--) {\n if (H.get(m, m - 1) !== 0) {\n for (i = m + 1; i <= high; i++) {\n ort[i] = H.get(i, m - 1);\n }\n\n for (j = m; j <= high; j++) {\n g = 0;\n for (i = m; i <= high; i++) {\n g += ort[i] * V.get(i, j);\n }\n\n g = g / ort[m] / H.get(m, m - 1);\n for (i = m; i <= high; i++) {\n V.set(i, j, V.get(i, j) + g * ort[i]);\n }\n }\n }\n }\n}\n\nfunction hqr2(nn, e, d, V, H) {\n let n = nn - 1;\n let low = 0;\n let high = nn - 1;\n let eps = Number.EPSILON;\n let exshift = 0;\n let norm = 0;\n let p = 0;\n let q = 0;\n let r = 0;\n let s = 0;\n let z = 0;\n let iter = 0;\n let i, j, k, l, m, t, w, x, y;\n let ra, sa, vr, vi;\n let notlast, cdivres;\n\n for (i = 0; i < nn; i++) {\n if (i < low || i > high) {\n d[i] = H.get(i, i);\n e[i] = 0;\n }\n\n for (j = Math.max(i - 1, 0); j < nn; j++) {\n norm = norm + Math.abs(H.get(i, j));\n }\n }\n\n while (n >= low) {\n l = n;\n while (l > low) {\n s = Math.abs(H.get(l - 1, l - 1)) + Math.abs(H.get(l, l));\n if (s === 0) {\n s = norm;\n }\n if (Math.abs(H.get(l, l - 1)) < eps * s) {\n break;\n }\n l--;\n }\n\n if (l === n) {\n H.set(n, n, H.get(n, n) + exshift);\n d[n] = H.get(n, n);\n e[n] = 0;\n n--;\n iter = 0;\n } else if (l === n - 1) {\n w = H.get(n, n - 1) * H.get(n - 1, n);\n p = (H.get(n - 1, n - 1) - H.get(n, n)) / 2;\n q = p * p + w;\n z = Math.sqrt(Math.abs(q));\n H.set(n, n, H.get(n, n) + exshift);\n H.set(n - 1, n - 1, H.get(n - 1, n - 1) + exshift);\n x = H.get(n, n);\n\n if (q >= 0) {\n z = p >= 0 ? p + z : p - z;\n d[n - 1] = x + z;\n d[n] = d[n - 1];\n if (z !== 0) {\n d[n] = x - w / z;\n }\n e[n - 1] = 0;\n e[n] = 0;\n x = H.get(n, n - 1);\n s = Math.abs(x) + Math.abs(z);\n p = x / s;\n q = z / s;\n r = Math.sqrt(p * p + q * q);\n p = p / r;\n q = q / r;\n\n for (j = n - 1; j < nn; j++) {\n z = H.get(n - 1, j);\n H.set(n - 1, j, q * z + p * H.get(n, j));\n H.set(n, j, q * H.get(n, j) - p * z);\n }\n\n for (i = 0; i <= n; i++) {\n z = H.get(i, n - 1);\n H.set(i, n - 1, q * z + p * H.get(i, n));\n H.set(i, n, q * H.get(i, n) - p * z);\n }\n\n for (i = low; i <= high; i++) {\n z = V.get(i, n - 1);\n V.set(i, n - 1, q * z + p * V.get(i, n));\n V.set(i, n, q * V.get(i, n) - p * z);\n }\n } else {\n d[n - 1] = x + p;\n d[n] = x + p;\n e[n - 1] = z;\n e[n] = -z;\n }\n\n n = n - 2;\n iter = 0;\n } else {\n x = H.get(n, n);\n y = 0;\n w = 0;\n if (l < n) {\n y = H.get(n - 1, n - 1);\n w = H.get(n, n - 1) * H.get(n - 1, n);\n }\n\n if (iter === 10) {\n exshift += x;\n for (i = low; i <= n; i++) {\n H.set(i, i, H.get(i, i) - x);\n }\n s = Math.abs(H.get(n, n - 1)) + Math.abs(H.get(n - 1, n - 2));\n x = y = 0.75 * s;\n w = -0.4375 * s * s;\n }\n\n if (iter === 30) {\n s = (y - x) / 2;\n s = s * s + w;\n if (s > 0) {\n s = Math.sqrt(s);\n if (y < x) {\n s = -s;\n }\n s = x - w / ((y - x) / 2 + s);\n for (i = low; i <= n; i++) {\n H.set(i, i, H.get(i, i) - s);\n }\n exshift += s;\n x = y = w = 0.964;\n }\n }\n\n iter = iter + 1;\n\n m = n - 2;\n while (m >= l) {\n z = H.get(m, m);\n r = x - z;\n s = y - z;\n p = (r * s - w) / H.get(m + 1, m) + H.get(m, m + 1);\n q = H.get(m + 1, m + 1) - z - r - s;\n r = H.get(m + 2, m + 1);\n s = Math.abs(p) + Math.abs(q) + Math.abs(r);\n p = p / s;\n q = q / s;\n r = r / s;\n if (m === l) {\n break;\n }\n if (\n Math.abs(H.get(m, m - 1)) * (Math.abs(q) + Math.abs(r)) <\n eps *\n (Math.abs(p) *\n (Math.abs(H.get(m - 1, m - 1)) +\n Math.abs(z) +\n Math.abs(H.get(m + 1, m + 1))))\n ) {\n break;\n }\n m--;\n }\n\n for (i = m + 2; i <= n; i++) {\n H.set(i, i - 2, 0);\n if (i > m + 2) {\n H.set(i, i - 3, 0);\n }\n }\n\n for (k = m; k <= n - 1; k++) {\n notlast = k !== n - 1;\n if (k !== m) {\n p = H.get(k, k - 1);\n q = H.get(k + 1, k - 1);\n r = notlast ? H.get(k + 2, k - 1) : 0;\n x = Math.abs(p) + Math.abs(q) + Math.abs(r);\n if (x !== 0) {\n p = p / x;\n q = q / x;\n r = r / x;\n }\n }\n\n if (x === 0) {\n break;\n }\n\n s = Math.sqrt(p * p + q * q + r * r);\n if (p < 0) {\n s = -s;\n }\n\n if (s !== 0) {\n if (k !== m) {\n H.set(k, k - 1, -s * x);\n } else if (l !== m) {\n H.set(k, k - 1, -H.get(k, k - 1));\n }\n\n p = p + s;\n x = p / s;\n y = q / s;\n z = r / s;\n q = q / p;\n r = r / p;\n\n for (j = k; j < nn; j++) {\n p = H.get(k, j) + q * H.get(k + 1, j);\n if (notlast) {\n p = p + r * H.get(k + 2, j);\n H.set(k + 2, j, H.get(k + 2, j) - p * z);\n }\n\n H.set(k, j, H.get(k, j) - p * x);\n H.set(k + 1, j, H.get(k + 1, j) - p * y);\n }\n\n for (i = 0; i <= Math.min(n, k + 3); i++) {\n p = x * H.get(i, k) + y * H.get(i, k + 1);\n if (notlast) {\n p = p + z * H.get(i, k + 2);\n H.set(i, k + 2, H.get(i, k + 2) - p * r);\n }\n\n H.set(i, k, H.get(i, k) - p);\n H.set(i, k + 1, H.get(i, k + 1) - p * q);\n }\n\n for (i = low; i <= high; i++) {\n p = x * V.get(i, k) + y * V.get(i, k + 1);\n if (notlast) {\n p = p + z * V.get(i, k + 2);\n V.set(i, k + 2, V.get(i, k + 2) - p * r);\n }\n\n V.set(i, k, V.get(i, k) - p);\n V.set(i, k + 1, V.get(i, k + 1) - p * q);\n }\n }\n }\n }\n }\n\n if (norm === 0) {\n return;\n }\n\n for (n = nn - 1; n >= 0; n--) {\n p = d[n];\n q = e[n];\n\n if (q === 0) {\n l = n;\n H.set(n, n, 1);\n for (i = n - 1; i >= 0; i--) {\n w = H.get(i, i) - p;\n r = 0;\n for (j = l; j <= n; j++) {\n r = r + H.get(i, j) * H.get(j, n);\n }\n\n if (e[i] < 0) {\n z = w;\n s = r;\n } else {\n l = i;\n if (e[i] === 0) {\n H.set(i, n, w !== 0 ? -r / w : -r / (eps * norm));\n } else {\n x = H.get(i, i + 1);\n y = H.get(i + 1, i);\n q = (d[i] - p) * (d[i] - p) + e[i] * e[i];\n t = (x * s - z * r) / q;\n H.set(i, n, t);\n H.set(\n i + 1,\n n,\n Math.abs(x) > Math.abs(z) ? (-r - w * t) / x : (-s - y * t) / z,\n );\n }\n\n t = Math.abs(H.get(i, n));\n if (eps * t * t > 1) {\n for (j = i; j <= n; j++) {\n H.set(j, n, H.get(j, n) / t);\n }\n }\n }\n }\n } else if (q < 0) {\n l = n - 1;\n\n if (Math.abs(H.get(n, n - 1)) > Math.abs(H.get(n - 1, n))) {\n H.set(n - 1, n - 1, q / H.get(n, n - 1));\n H.set(n - 1, n, -(H.get(n, n) - p) / H.get(n, n - 1));\n } else {\n cdivres = cdiv(0, -H.get(n - 1, n), H.get(n - 1, n - 1) - p, q);\n H.set(n - 1, n - 1, cdivres[0]);\n H.set(n - 1, n, cdivres[1]);\n }\n\n H.set(n, n - 1, 0);\n H.set(n, n, 1);\n for (i = n - 2; i >= 0; i--) {\n ra = 0;\n sa = 0;\n for (j = l; j <= n; j++) {\n ra = ra + H.get(i, j) * H.get(j, n - 1);\n sa = sa + H.get(i, j) * H.get(j, n);\n }\n\n w = H.get(i, i) - p;\n\n if (e[i] < 0) {\n z = w;\n r = ra;\n s = sa;\n } else {\n l = i;\n if (e[i] === 0) {\n cdivres = cdiv(-ra, -sa, w, q);\n H.set(i, n - 1, cdivres[0]);\n H.set(i, n, cdivres[1]);\n } else {\n x = H.get(i, i + 1);\n y = H.get(i + 1, i);\n vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q;\n vi = (d[i] - p) * 2 * q;\n if (vr === 0 && vi === 0) {\n vr =\n eps *\n norm *\n (Math.abs(w) +\n Math.abs(q) +\n Math.abs(x) +\n Math.abs(y) +\n Math.abs(z));\n }\n cdivres = cdiv(\n x * r - z * ra + q * sa,\n x * s - z * sa - q * ra,\n vr,\n vi,\n );\n H.set(i, n - 1, cdivres[0]);\n H.set(i, n, cdivres[1]);\n if (Math.abs(x) > Math.abs(z) + Math.abs(q)) {\n H.set(\n i + 1,\n n - 1,\n (-ra - w * H.get(i, n - 1) + q * H.get(i, n)) / x,\n );\n H.set(\n i + 1,\n n,\n (-sa - w * H.get(i, n) - q * H.get(i, n - 1)) / x,\n );\n } else {\n cdivres = cdiv(\n -r - y * H.get(i, n - 1),\n -s - y * H.get(i, n),\n z,\n q,\n );\n H.set(i + 1, n - 1, cdivres[0]);\n H.set(i + 1, n, cdivres[1]);\n }\n }\n\n t = Math.max(Math.abs(H.get(i, n - 1)), Math.abs(H.get(i, n)));\n if (eps * t * t > 1) {\n for (j = i; j <= n; j++) {\n H.set(j, n - 1, H.get(j, n - 1) / t);\n H.set(j, n, H.get(j, n) / t);\n }\n }\n }\n }\n }\n }\n\n for (i = 0; i < nn; i++) {\n if (i < low || i > high) {\n for (j = i; j < nn; j++) {\n V.set(i, j, H.get(i, j));\n }\n }\n }\n\n for (j = nn - 1; j >= low; j--) {\n for (i = low; i <= high; i++) {\n z = 0;\n for (k = low; k <= Math.min(j, high); k++) {\n z = z + V.get(i, k) * H.get(k, j);\n }\n V.set(i, j, z);\n }\n }\n}\n\nfunction cdiv(xr, xi, yr, yi) {\n let r, d;\n if (Math.abs(yr) > Math.abs(yi)) {\n r = yi / yr;\n d = yr + r * yi;\n return [(xr + r * xi) / d, (xi - r * xr) / d];\n } else {\n r = yr / yi;\n d = yi + r * yr;\n return [(r * xr + xi) / d, (r * xi - xr) / d];\n }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nexport default class CholeskyDecomposition {\n constructor(value) {\n value = WrapperMatrix2D.checkMatrix(value);\n if (!value.isSymmetric()) {\n throw new Error('Matrix is not symmetric');\n }\n\n let a = value;\n let dimension = a.rows;\n let l = new Matrix(dimension, dimension);\n let positiveDefinite = true;\n let i, j, k;\n\n for (j = 0; j < dimension; j++) {\n let d = 0;\n for (k = 0; k < j; k++) {\n let s = 0;\n for (i = 0; i < k; i++) {\n s += l.get(k, i) * l.get(j, i);\n }\n s = (a.get(j, k) - s) / l.get(k, k);\n l.set(j, k, s);\n d = d + s * s;\n }\n\n d = a.get(j, j) - d;\n\n positiveDefinite &= d > 0;\n l.set(j, j, Math.sqrt(Math.max(d, 0)));\n for (k = j + 1; k < dimension; k++) {\n l.set(j, k, 0);\n }\n }\n\n this.L = l;\n this.positiveDefinite = Boolean(positiveDefinite);\n }\n\n isPositiveDefinite() {\n return this.positiveDefinite;\n }\n\n solve(value) {\n value = WrapperMatrix2D.checkMatrix(value);\n\n let l = this.L;\n let dimension = l.rows;\n\n if (value.rows !== dimension) {\n throw new Error('Matrix dimensions do not match');\n }\n if (this.isPositiveDefinite() === false) {\n throw new Error('Matrix is not positive definite');\n }\n\n let count = value.columns;\n let B = value.clone();\n let i, j, k;\n\n for (k = 0; k < dimension; k++) {\n for (j = 0; j < count; j++) {\n for (i = 0; i < k; i++) {\n B.set(k, j, B.get(k, j) - B.get(i, j) * l.get(k, i));\n }\n B.set(k, j, B.get(k, j) / l.get(k, k));\n }\n }\n\n for (k = dimension - 1; k >= 0; k--) {\n for (j = 0; j < count; j++) {\n for (i = k + 1; i < dimension; i++) {\n B.set(k, j, B.get(k, j) - B.get(i, j) * l.get(i, k));\n }\n B.set(k, j, B.get(k, j) / l.get(k, k));\n }\n }\n\n return B;\n }\n\n get lowerTriangularMatrix() {\n return this.L;\n }\n}\n","import Matrix from '../matrix';\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\n\nexport default class nipals {\n constructor(X, options = {}) {\n X = WrapperMatrix2D.checkMatrix(X);\n let { Y } = options;\n const {\n scaleScores = false,\n maxIterations = 1000,\n terminationCriteria = 1e-10,\n } = options;\n\n let u;\n if (Y) {\n if (Array.isArray(Y) && typeof Y[0] === 'number') {\n Y = Matrix.columnVector(Y);\n } else {\n Y = WrapperMatrix2D.checkMatrix(Y);\n }\n if (!Y.isColumnVector() || Y.rows !== X.rows) {\n throw new Error('Y must be a column vector of length X.rows');\n }\n u = Y;\n } else {\n u = X.getColumnVector(0);\n }\n\n let diff = 1;\n let t, q, w, tOld;\n\n for (\n let counter = 0;\n counter < maxIterations && diff > terminationCriteria;\n counter++\n ) {\n w = X.transpose().mmul(u).div(u.transpose().mmul(u).get(0, 0));\n w = w.div(w.norm());\n\n t = X.mmul(w).div(w.transpose().mmul(w).get(0, 0));\n\n if (counter > 0) {\n diff = t.clone().sub(tOld).pow(2).sum();\n }\n tOld = t.clone();\n\n if (Y) {\n q = Y.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\n q = q.div(q.norm());\n\n u = Y.mmul(q).div(q.transpose().mmul(q).get(0, 0));\n } else {\n u = t;\n }\n }\n\n if (Y) {\n let p = X.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\n p = p.div(p.norm());\n let xResidual = X.clone().sub(t.clone().mmul(p.transpose()));\n let residual = u.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\n let yResidual = Y.clone().sub(\n t.clone().mulS(residual.get(0, 0)).mmul(q.transpose()),\n );\n\n this.t = t;\n this.p = p.transpose();\n this.w = w.transpose();\n this.q = q;\n this.u = u;\n this.s = t.transpose().mmul(t);\n this.xResidual = xResidual;\n this.yResidual = yResidual;\n this.betas = residual;\n } else {\n this.w = w.transpose();\n this.s = t.transpose().mmul(t).sqrt();\n if (scaleScores) {\n this.t = t.clone().div(this.s.get(0, 0));\n } else {\n this.t = t;\n }\n this.xResidual = X.sub(t.mmul(w.transpose()));\n }\n }\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction sum(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var sumValue = 0;\n\n for (var i = 0; i < input.length; i++) {\n sumValue += input[i];\n }\n\n return sumValue;\n}\n\nexport default sum;\n","import sum from 'ml-array-sum';\n\nfunction mean(input) {\n return sum(input) / input.length;\n}\n\nexport default mean;\n","import Matrix from 'ml-matrix';\nimport meanArray from 'ml-array-mean';\n\n/**\n * @private\n * return an array of probabilities of each class\n * @param {Array} array - contains the classes\n * @param {number} numberOfClasses\n * @return {Matrix} - rowVector of probabilities.\n */\nexport function toDiscreteDistribution(array, numberOfClasses) {\n let counts = new Array(numberOfClasses).fill(0);\n for (let i = 0; i < array.length; ++i) {\n counts[array[i]] += 1 / array.length;\n }\n\n return Matrix.rowVector(counts);\n}\n\n/**\n * @private\n * Retrieves the impurity of array of predictions\n * @param {Array} array - predictions.\n * @return {number} Gini impurity\n */\nexport function giniImpurity(array) {\n if (array.length === 0) {\n return 0;\n }\n\n let probabilities = toDiscreteDistribution(\n array,\n getNumberOfClasses(array),\n ).getRow(0);\n\n let sum = 0.0;\n for (let i = 0; i < probabilities.length; ++i) {\n sum += probabilities[i] * probabilities[i];\n }\n\n return 1 - sum;\n}\n\n/**\n * @private\n * Return the number of classes given the array of predictions.\n * @param {Array} array - predictions.\n * @return {number} Number of classes.\n */\nexport function getNumberOfClasses(array) {\n return array\n .filter(function(val, i, arr) {\n return arr.indexOf(val) === i;\n })\n .map((val) => val + 1)\n .reduce((a, b) => Math.max(a, b));\n}\n\n/**\n * @private\n * Calculates the Gini Gain of an array of predictions and those predictions splitted by a feature.\n * @param {Array} array - Predictions\n * @param {object} splitted - Object with elements \"greater\" and \"lesser\" that contains an array of predictions splitted.\n * @return {number} - Gini Gain.\n */\n\nexport function giniGain(array, splitted) {\n let splitsImpurity = 0.0;\n let splits = ['greater', 'lesser'];\n\n for (let i = 0; i < splits.length; ++i) {\n let currentSplit = splitted[splits[i]];\n splitsImpurity +=\n (giniImpurity(currentSplit) * currentSplit.length) / array.length;\n }\n\n return giniImpurity(array) - splitsImpurity;\n}\n\n/**\n * @private\n * Calculates the squared error of a predictions values.\n * @param {Array} array - predictions values\n * @return {number} squared error.\n */\nexport function squaredError(array) {\n let l = array.length;\n\n let m = meanArray(array);\n let error = 0.0;\n\n for (let i = 0; i < l; ++i) {\n let currentElement = array[i];\n error += (currentElement - m) * (currentElement - m);\n }\n\n return error;\n}\n\n/**\n * @private\n * Calculates the sum of squared error of the two arrays that contains the splitted values.\n * @param {Array} array - this argument is no necessary but is used to fit with the main interface.\n * @param {object} splitted - Object with elements \"greater\" and \"lesser\" that contains an array of predictions splitted.\n * @return {number} - sum of squared errors.\n */\nexport function regressionError(array, splitted) {\n let error = 0.0;\n let splits = ['greater', 'lesser'];\n\n for (let i = 0; i < splits.length; ++i) {\n let currentSplit = splitted[splits[i]];\n error += squaredError(currentSplit);\n }\n return error;\n}\n\n/**\n * @private\n * Split the training set and values from a given column of the training set if is less than a value\n * @param {Matrix} X - Training set.\n * @param {Array} y - Training values.\n * @param {number} column - Column to split.\n * @param {number} value - value to split the Training set and values.\n * @return {object} - Object that contains the splitted values.\n */\nexport function matrixSplitter(X, y, column, value) {\n let lesserX = [];\n let greaterX = [];\n let lesserY = [];\n let greaterY = [];\n\n for (let i = 0; i < X.rows; ++i) {\n if (X.get(i, column) < value) {\n lesserX.push(X.getRow(i));\n lesserY.push(y[i]);\n } else {\n greaterX.push(X.getRow(i));\n greaterY.push(y[i]);\n }\n }\n\n return {\n greaterX: greaterX,\n greaterY: greaterY,\n lesserX: lesserX,\n lesserY: lesserY,\n };\n}\n\n/**\n * @private\n * Calculates the mean between two values\n * @param {number} a\n * @param {number} b\n * @return {number}\n */\nexport function mean(a, b) {\n return (a + b) / 2;\n}\n\n/**\n * @private\n * Returns a list of tuples that contains the i-th element of each array.\n * @param {Array} a\n * @param {Array} b\n * @return {Array} list of tuples.\n */\nexport function zip(a, b) {\n if (a.length !== b.length) {\n throw new TypeError(\n `Error on zip: the size of a: ${a.length} is different from b: ${b.length}`,\n );\n }\n\n let ret = new Array(a.length);\n for (let i = 0; i < a.length; ++i) {\n ret[i] = [a[i], b[i]];\n }\n\n return ret;\n}\n","import Matrix from 'ml-matrix';\nimport mean from 'ml-array-mean';\n\nimport * as Utils from './utils';\n\nconst gainFunctions = {\n gini: Utils.giniGain,\n regression: Utils.regressionError,\n};\n\nconst splitFunctions = {\n mean: Utils.mean,\n};\n\nexport default class TreeNode {\n /**\n * @private\n * Constructor for a tree node given the options received on the main classes (DecisionTreeClassifier, DecisionTreeRegression)\n * @param {object|TreeNode} options for loading\n * @constructor\n */\n constructor(options) {\n // options parameters\n this.kind = options.kind;\n this.gainFunction = options.gainFunction;\n this.splitFunction = options.splitFunction;\n this.minNumSamples = options.minNumSamples;\n this.maxDepth = options.maxDepth;\n }\n\n /**\n * @private\n * Function that retrieve the best feature to make the split.\n * @param {Matrix} XTranspose - Training set transposed\n * @param {Array} y - labels or values (depending of the decision tree)\n * @return {object} - return tree values, the best gain, column and the split value.\n */\n bestSplit(XTranspose, y) {\n // Depending in the node tree class, we set the variables to check information gain (to classify)\n // or error (for regression)\n\n let bestGain = this.kind === 'classifier' ? -Infinity : Infinity;\n let check = this.kind === 'classifier' ? (a, b) => a > b : (a, b) => a < b;\n\n let maxColumn;\n let maxValue;\n\n for (let i = 0; i < XTranspose.rows; ++i) {\n let currentFeature = XTranspose.getRow(i);\n let splitValues = this.featureSplit(currentFeature, y);\n for (let j = 0; j < splitValues.length; ++j) {\n let currentSplitVal = splitValues[j];\n let splitted = this.split(currentFeature, y, currentSplitVal);\n\n let gain = gainFunctions[this.gainFunction](y, splitted);\n if (check(gain, bestGain)) {\n maxColumn = i;\n maxValue = currentSplitVal;\n bestGain = gain;\n }\n }\n }\n\n return {\n maxGain: bestGain,\n maxColumn: maxColumn,\n maxValue: maxValue,\n };\n }\n\n /**\n * @private\n * Makes the split of the training labels or values from the training set feature given a split value.\n * @param {Array} x - Training set feature\n * @param {Array} y - Training set value or label\n * @param {number} splitValue\n * @return {object}\n */\n split(x, y, splitValue) {\n let lesser = [];\n let greater = [];\n\n for (let i = 0; i < x.length; ++i) {\n if (x[i] < splitValue) {\n lesser.push(y[i]);\n } else {\n greater.push(y[i]);\n }\n }\n\n return {\n greater: greater,\n lesser: lesser,\n };\n }\n\n /**\n * @private\n * Calculates the possible points to split over the tree given a training set feature and corresponding labels or values.\n * @param {Array} x - Training set feature\n * @param {Array} y - Training set value or label\n * @return {Array} possible split values.\n */\n featureSplit(x, y) {\n let splitValues = [];\n let arr = Utils.zip(x, y);\n arr.sort(function(a, b) {\n return a[0] - b[0];\n });\n\n for (let i = 1; i < arr.length; ++i) {\n if (arr[i - 1][1] !== arr[i][1]) {\n splitValues.push(\n splitFunctions[this.splitFunction](arr[i - 1][0], arr[i][0]),\n );\n }\n }\n\n return splitValues;\n }\n\n /**\n * @private\n * Calculate the predictions of a leaf tree node given the training labels or values\n * @param {Array} y\n */\n calculatePrediction(y) {\n if (this.kind === 'classifier') {\n this.distribution = Utils.toDiscreteDistribution(\n y,\n Utils.getNumberOfClasses(y),\n );\n if (this.distribution.columns === 0) {\n throw new TypeError('Error on calculate the prediction');\n }\n } else {\n this.distribution = mean(y);\n }\n }\n\n /**\n * @private\n * Train a node given the training set and labels, because it trains recursively, it also receive\n * the current depth of the node, parent gain to avoid infinite recursion and boolean value to check if\n * the training set is transposed.\n * @param {Matrix} X - Training set (could be transposed or not given transposed).\n * @param {Array} y - Training labels or values.\n * @param {number} currentDepth - Current depth of the node.\n * @param {number} parentGain - parent node gain or error.\n */\n train(X, y, currentDepth, parentGain) {\n if (X.rows <= this.minNumSamples) {\n this.calculatePrediction(y);\n return;\n }\n if (parentGain === undefined) parentGain = 0.0;\n\n let XTranspose = X.transpose();\n let split = this.bestSplit(XTranspose, y);\n\n this.splitValue = split.maxValue;\n this.splitColumn = split.maxColumn;\n this.gain = split.maxGain;\n\n let splittedMatrix = Utils.matrixSplitter(\n X,\n y,\n this.splitColumn,\n this.splitValue,\n );\n\n if (\n currentDepth < this.maxDepth &&\n (this.gain > 0.01 && this.gain !== parentGain) &&\n (splittedMatrix.lesserX.length > 0 && splittedMatrix.greaterX.length > 0)\n ) {\n this.left = new TreeNode(this);\n this.right = new TreeNode(this);\n\n let lesserX = new Matrix(splittedMatrix.lesserX);\n let greaterX = new Matrix(splittedMatrix.greaterX);\n\n this.left.train(\n lesserX,\n splittedMatrix.lesserY,\n currentDepth + 1,\n this.gain,\n );\n this.right.train(\n greaterX,\n splittedMatrix.greaterY,\n currentDepth + 1,\n this.gain,\n );\n } else {\n this.calculatePrediction(y);\n }\n }\n\n /**\n * @private\n * Calculates the prediction of a given element.\n * @param {Array} row\n * @return {number|Array} prediction\n * * if a node is a classifier returns an array of probabilities of each class.\n * * if a node is for regression returns a number with the prediction.\n */\n classify(row) {\n if (this.right && this.left) {\n if (row[this.splitColumn] < this.splitValue) {\n return this.left.classify(row);\n } else {\n return this.right.classify(row);\n }\n }\n\n return this.distribution;\n }\n\n /**\n * @private\n * Set the parameter of the current node and their children.\n * @param {object} node - parameters of the current node and the children.\n */\n setNodeParameters(node) {\n if (node.distribution !== undefined) {\n this.distribution =\n node.distribution.constructor === Array\n ? new Matrix(node.distribution)\n : node.distribution;\n } else {\n this.distribution = undefined;\n this.splitValue = node.splitValue;\n this.splitColumn = node.splitColumn;\n this.gain = node.gain;\n\n this.left = new TreeNode(this);\n this.right = new TreeNode(this);\n\n if (node.left !== {}) {\n this.left.setNodeParameters(node.left);\n }\n if (node.right !== {}) {\n this.right.setNodeParameters(node.right);\n }\n }\n }\n}\n","import Matrix from 'ml-matrix';\n\nimport Tree from './TreeNode';\n\nconst defaultOptions = {\n gainFunction: 'gini',\n splitFunction: 'mean',\n minNumSamples: 3,\n maxDepth: Infinity,\n};\n\nexport class DecisionTreeClassifier {\n /**\n * Create new Decision Tree Classifier with CART implementation with the given options\n * @param {object} options\n * @param {string} [options.gainFunction=\"gini\"] - gain function to get the best split, \"gini\" the only one supported.\n * @param {string} [options.splitFunction=\"mean\"] - given two integers from a split feature, get the value to split, \"mean\" the only one supported.\n * @param {number} [options.minNumSamples=3] - minimum number of samples to create a leaf node to decide a class.\n * @param {number} [options.maxDepth=Infinity] - Max depth of the tree.\n * @param {object} model - for load purposes.\n * @constructor\n */\n constructor(options, model) {\n if (options === true) {\n this.options = model.options;\n this.root = new Tree(model.options);\n this.root.setNodeParameters(model.root);\n } else {\n this.options = Object.assign({}, defaultOptions, options);\n this.options.kind = 'classifier';\n }\n }\n\n /**\n * Train the decision tree with the given training set and labels.\n * @param {Matrix|MatrixTransposeView|Array} trainingSet\n * @param {Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n this.root = new Tree(this.options);\n trainingSet = Matrix.checkMatrix(trainingSet);\n this.root.train(trainingSet, trainingLabels, 0, null);\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|MatrixTransposeView|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n toPredict = Matrix.checkMatrix(toPredict);\n let predictions = new Array(toPredict.rows);\n\n for (let i = 0; i < toPredict.rows; ++i) {\n predictions[i] = this.root\n .classify(toPredict.getRow(i))\n .maxRowIndex(0)[1];\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n options: this.options,\n root: this.root,\n name: 'DTClassifier',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {DecisionTreeClassifier}\n */\n static load(model) {\n if (model.name !== 'DTClassifier') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new DecisionTreeClassifier(true, model);\n }\n}\n","import Matrix from 'ml-matrix';\n\nimport Tree from './TreeNode';\n\nconst defaultOptions = {\n gainFunction: 'regression',\n splitFunction: 'mean',\n minNumSamples: 3,\n maxDepth: Infinity,\n};\n\nexport class DecisionTreeRegression {\n /**\n * Create new Decision Tree Regression with CART implementation with the given options.\n * @param {object} options\n * @param {string} [options.gainFunction=\"regression\"] - gain function to get the best split, \"regression\" the only one supported.\n * @param {string} [options.splitFunction=\"mean\"] - given two integers from a split feature, get the value to split, \"mean\" the only one supported.\n * @param {number} [options.minNumSamples=3] - minimum number of samples to create a leaf node to decide a class.\n * @param {number} [options.maxDepth=Infinity] - Max depth of the tree.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.options = model.options;\n this.root = new Tree(model.options);\n this.root.setNodeParameters(model.root);\n } else {\n this.options = Object.assign({}, defaultOptions, options);\n this.options.kind = 'regression';\n }\n }\n\n /**\n * Train the decision tree with the given training set and values.\n * @param {Matrix|MatrixTransposeView|Array} trainingSet\n * @param {Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n this.root = new Tree(this.options);\n\n if (\n typeof trainingSet[0] !== 'undefined' &&\n trainingSet[0].length === undefined\n ) {\n trainingSet = Matrix.columnVector(trainingSet);\n } else {\n trainingSet = Matrix.checkMatrix(trainingSet);\n }\n this.root.train(trainingSet, trainingValues, 0);\n }\n\n /**\n * Predicts the values given the matrix to predict.\n * @param {Matrix|MatrixTransposeView|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n if (\n typeof toPredict[0] !== 'undefined' &&\n toPredict[0].length === undefined\n ) {\n toPredict = Matrix.columnVector(toPredict);\n }\n toPredict = Matrix.checkMatrix(toPredict);\n\n let predictions = new Array(toPredict.rows);\n for (let i = 0; i < toPredict.rows; ++i) {\n predictions[i] = this.root.classify(toPredict.getRow(i));\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n options: this.options,\n root: this.root,\n name: 'DTRegression',\n };\n }\n\n /**\n * Load a Decision tree regression with the given model.\n * @param {object} model\n * @return {DecisionTreeRegression}\n */\n static load(model) {\n if (model.name !== 'DTRegression') {\n throw new RangeError(`Invalid model:${model.name}`);\n }\n\n return new DecisionTreeRegression(true, model);\n }\n}\n","const SMALLEST_UNSAFE_INTEGER = 0x20000000000000;\r\nconst LARGEST_SAFE_INTEGER = SMALLEST_UNSAFE_INTEGER - 1;\r\nconst UINT32_MAX = -1 >>> 0;\r\nconst UINT32_SIZE = UINT32_MAX + 1;\r\nconst INT32_SIZE = UINT32_SIZE / 2;\r\nconst INT32_MAX = INT32_SIZE - 1;\r\nconst UINT21_SIZE = 1 << 21;\r\nconst UINT21_MAX = UINT21_SIZE - 1;\n\n/**\r\n * Returns a value within [-0x80000000, 0x7fffffff]\r\n */\r\nfunction int32(engine) {\r\n return engine.next() | 0;\r\n}\n\nfunction add(distribution, addend) {\r\n if (addend === 0) {\r\n return distribution;\r\n }\r\n else {\r\n return engine => distribution(engine) + addend;\r\n }\r\n}\n\n/**\r\n * Returns a value within [-0x20000000000000, 0x1fffffffffffff]\r\n */\r\nfunction int53(engine) {\r\n const high = engine.next() | 0;\r\n const low = engine.next() >>> 0;\r\n return ((high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0));\r\n}\n\n/**\r\n * Returns a value within [-0x20000000000000, 0x20000000000000]\r\n */\r\nfunction int53Full(engine) {\r\n while (true) {\r\n const high = engine.next() | 0;\r\n if (high & 0x400000) {\r\n if ((high & 0x7fffff) === 0x400000 && (engine.next() | 0) === 0) {\r\n return SMALLEST_UNSAFE_INTEGER;\r\n }\r\n }\r\n else {\r\n const low = engine.next() >>> 0;\r\n return ((high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0));\r\n }\r\n }\r\n}\n\n/**\r\n * Returns a value within [0, 0xffffffff]\r\n */\r\nfunction uint32(engine) {\r\n return engine.next() >>> 0;\r\n}\n\n/**\r\n * Returns a value within [0, 0x1fffffffffffff]\r\n */\r\nfunction uint53(engine) {\r\n const high = engine.next() & UINT21_MAX;\r\n const low = engine.next() >>> 0;\r\n return high * UINT32_SIZE + low;\r\n}\n\n/**\r\n * Returns a value within [0, 0x20000000000000]\r\n */\r\nfunction uint53Full(engine) {\r\n while (true) {\r\n const high = engine.next() | 0;\r\n if (high & UINT21_SIZE) {\r\n if ((high & UINT21_MAX) === 0 && (engine.next() | 0) === 0) {\r\n return SMALLEST_UNSAFE_INTEGER;\r\n }\r\n }\r\n else {\r\n const low = engine.next() >>> 0;\r\n return (high & UINT21_MAX) * UINT32_SIZE + low;\r\n }\r\n }\r\n}\n\nfunction isPowerOfTwoMinusOne(value) {\r\n return ((value + 1) & value) === 0;\r\n}\r\nfunction bitmask(masking) {\r\n return (engine) => engine.next() & masking;\r\n}\r\nfunction downscaleToLoopCheckedRange(range) {\r\n const extendedRange = range + 1;\r\n const maximum = extendedRange * Math.floor(UINT32_SIZE / extendedRange);\r\n return engine => {\r\n let value = 0;\r\n do {\r\n value = engine.next() >>> 0;\r\n } while (value >= maximum);\r\n return value % extendedRange;\r\n };\r\n}\r\nfunction downscaleToRange(range) {\r\n if (isPowerOfTwoMinusOne(range)) {\r\n return bitmask(range);\r\n }\r\n else {\r\n return downscaleToLoopCheckedRange(range);\r\n }\r\n}\r\nfunction isEvenlyDivisibleByMaxInt32(value) {\r\n return (value | 0) === 0;\r\n}\r\nfunction upscaleWithHighMasking(masking) {\r\n return engine => {\r\n const high = engine.next() & masking;\r\n const low = engine.next() >>> 0;\r\n return high * UINT32_SIZE + low;\r\n };\r\n}\r\nfunction upscaleToLoopCheckedRange(extendedRange) {\r\n const maximum = extendedRange * Math.floor(SMALLEST_UNSAFE_INTEGER / extendedRange);\r\n return engine => {\r\n let ret = 0;\r\n do {\r\n const high = engine.next() & UINT21_MAX;\r\n const low = engine.next() >>> 0;\r\n ret = high * UINT32_SIZE + low;\r\n } while (ret >= maximum);\r\n return ret % extendedRange;\r\n };\r\n}\r\nfunction upscaleWithinU53(range) {\r\n const extendedRange = range + 1;\r\n if (isEvenlyDivisibleByMaxInt32(extendedRange)) {\r\n const highRange = ((extendedRange / UINT32_SIZE) | 0) - 1;\r\n if (isPowerOfTwoMinusOne(highRange)) {\r\n return upscaleWithHighMasking(highRange);\r\n }\r\n }\r\n return upscaleToLoopCheckedRange(extendedRange);\r\n}\r\nfunction upscaleWithinI53AndLoopCheck(min, max) {\r\n return engine => {\r\n let ret = 0;\r\n do {\r\n const high = engine.next() | 0;\r\n const low = engine.next() >>> 0;\r\n ret =\r\n (high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0);\r\n } while (ret < min || ret > max);\r\n return ret;\r\n };\r\n}\r\n/**\r\n * Returns a Distribution to return a value within [min, max]\r\n * @param min The minimum integer value, inclusive. No less than -0x20000000000000.\r\n * @param max The maximum integer value, inclusive. No greater than 0x20000000000000.\r\n */\r\nfunction integer(min, max) {\r\n min = Math.floor(min);\r\n max = Math.floor(max);\r\n if (min < -SMALLEST_UNSAFE_INTEGER || !isFinite(min)) {\r\n throw new RangeError(`Expected min to be at least ${-SMALLEST_UNSAFE_INTEGER}`);\r\n }\r\n else if (max > SMALLEST_UNSAFE_INTEGER || !isFinite(max)) {\r\n throw new RangeError(`Expected max to be at most ${SMALLEST_UNSAFE_INTEGER}`);\r\n }\r\n const range = max - min;\r\n if (range <= 0 || !isFinite(range)) {\r\n return () => min;\r\n }\r\n else if (range === UINT32_MAX) {\r\n if (min === 0) {\r\n return uint32;\r\n }\r\n else {\r\n return add(int32, min + INT32_SIZE);\r\n }\r\n }\r\n else if (range < UINT32_MAX) {\r\n return add(downscaleToRange(range), min);\r\n }\r\n else if (range === LARGEST_SAFE_INTEGER) {\r\n return add(uint53, min);\r\n }\r\n else if (range < LARGEST_SAFE_INTEGER) {\r\n return add(upscaleWithinU53(range), min);\r\n }\r\n else if (max - 1 - min === LARGEST_SAFE_INTEGER) {\r\n return add(uint53Full, min);\r\n }\r\n else if (min === -SMALLEST_UNSAFE_INTEGER &&\r\n max === SMALLEST_UNSAFE_INTEGER) {\r\n return int53Full;\r\n }\r\n else if (min === -SMALLEST_UNSAFE_INTEGER && max === LARGEST_SAFE_INTEGER) {\r\n return int53;\r\n }\r\n else if (min === -LARGEST_SAFE_INTEGER && max === SMALLEST_UNSAFE_INTEGER) {\r\n return add(int53, 1);\r\n }\r\n else if (max === SMALLEST_UNSAFE_INTEGER) {\r\n return add(upscaleWithinI53AndLoopCheck(min - 1, max - 1), 1);\r\n }\r\n else {\r\n return upscaleWithinI53AndLoopCheck(min, max);\r\n }\r\n}\n\nfunction isLeastBitTrue(engine) {\r\n return (engine.next() & 1) === 1;\r\n}\r\nfunction lessThan(distribution, value) {\r\n return engine => distribution(engine) < value;\r\n}\r\nfunction probability(percentage) {\r\n if (percentage <= 0) {\r\n return () => false;\r\n }\r\n else if (percentage >= 1) {\r\n return () => true;\r\n }\r\n else {\r\n const scaled = percentage * UINT32_SIZE;\r\n if (scaled % 1 === 0) {\r\n return lessThan(int32, (scaled - INT32_SIZE) | 0);\r\n }\r\n else {\r\n return lessThan(uint53, Math.round(percentage * SMALLEST_UNSAFE_INTEGER));\r\n }\r\n }\r\n}\r\nfunction bool(numerator, denominator) {\r\n if (denominator == null) {\r\n if (numerator == null) {\r\n return isLeastBitTrue;\r\n }\r\n return probability(numerator);\r\n }\r\n else {\r\n if (numerator <= 0) {\r\n return () => false;\r\n }\r\n else if (numerator >= denominator) {\r\n return () => true;\r\n }\r\n return lessThan(integer(0, denominator - 1), numerator);\r\n }\r\n}\n\n/**\r\n * Returns a Distribution that returns a random `Date` within the inclusive\r\n * range of [`start`, `end`].\r\n * @param start The minimum `Date`\r\n * @param end The maximum `Date`\r\n */\r\nfunction date(start, end) {\r\n const distribution = integer(+start, +end);\r\n return engine => new Date(distribution(engine));\r\n}\n\n/**\r\n * Returns a Distribution to return a value within [1, sideCount]\r\n * @param sideCount The number of sides of the die\r\n */\r\nfunction die(sideCount) {\r\n return integer(1, sideCount);\r\n}\n\n/**\r\n * Returns a distribution that returns an array of length `dieCount` of values\r\n * within [1, `sideCount`]\r\n * @param sideCount The number of sides of each die\r\n * @param dieCount The number of dice\r\n */\r\nfunction dice(sideCount, dieCount) {\r\n const distribution = die(sideCount);\r\n return engine => {\r\n const result = [];\r\n for (let i = 0; i < dieCount; ++i) {\r\n result.push(distribution(engine));\r\n }\r\n return result;\r\n };\r\n}\n\n// tslint:disable:unified-signatures\r\n// has 2**x chars, for faster uniform distribution\r\nconst DEFAULT_STRING_POOL = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\";\r\nfunction string(pool = DEFAULT_STRING_POOL) {\r\n const poolLength = pool.length;\r\n if (!poolLength) {\r\n throw new Error(\"Expected pool not to be an empty string\");\r\n }\r\n const distribution = integer(0, poolLength - 1);\r\n return (engine, length) => {\r\n let result = \"\";\r\n for (let i = 0; i < length; ++i) {\r\n const j = distribution(engine);\r\n result += pool.charAt(j);\r\n }\r\n return result;\r\n };\r\n}\n\nconst LOWER_HEX_POOL = \"0123456789abcdef\";\r\nconst lowerHex = string(LOWER_HEX_POOL);\r\nconst upperHex = string(LOWER_HEX_POOL.toUpperCase());\r\n/**\r\n * Returns a Distribution that returns a random string comprised of numbers\r\n * or the characters `abcdef` (or `ABCDEF`) of length `length`.\r\n * @param length Length of the result string\r\n * @param uppercase Whether the string should use `ABCDEF` instead of `abcdef`\r\n */\r\nfunction hex(uppercase) {\r\n if (uppercase) {\r\n return upperHex;\r\n }\r\n else {\r\n return lowerHex;\r\n }\r\n}\n\nfunction convertSliceArgument(value, length) {\r\n if (value < 0) {\r\n return Math.max(value + length, 0);\r\n }\r\n else {\r\n return Math.min(value, length);\r\n }\r\n}\n\nfunction toInteger(value) {\r\n const num = +value;\r\n if (num < 0) {\r\n return Math.ceil(num);\r\n }\r\n else {\r\n return Math.floor(num);\r\n }\r\n}\n\n/**\r\n * Returns a random value within the provided `source` within the sliced\r\n * bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\nfunction pick(engine, source, begin, end) {\r\n const length = source.length;\r\n if (length === 0) {\r\n throw new RangeError(\"Cannot pick from an empty array\");\r\n }\r\n const start = begin == null ? 0 : convertSliceArgument(toInteger(begin), length);\r\n const finish = end === void 0 ? length : convertSliceArgument(toInteger(end), length);\r\n if (start >= finish) {\r\n throw new RangeError(`Cannot pick between bounds ${start} and ${finish}`);\r\n }\r\n const distribution = integer(start, finish - 1);\r\n return source[distribution(engine)];\r\n}\n\nfunction multiply(distribution, multiplier) {\r\n if (multiplier === 1) {\r\n return distribution;\r\n }\r\n else if (multiplier === 0) {\r\n return () => 0;\r\n }\r\n else {\r\n return engine => distribution(engine) * multiplier;\r\n }\r\n}\n\n/**\r\n * Returns a floating-point value within [0.0, 1.0)\r\n */\r\nfunction realZeroToOneExclusive(engine) {\r\n return uint53(engine) / SMALLEST_UNSAFE_INTEGER;\r\n}\n\n/**\r\n * Returns a floating-point value within [0.0, 1.0]\r\n */\r\nfunction realZeroToOneInclusive(engine) {\r\n return uint53Full(engine) / SMALLEST_UNSAFE_INTEGER;\r\n}\n\n/**\r\n * Returns a floating-point value within [min, max) or [min, max]\r\n * @param min The minimum floating-point value, inclusive.\r\n * @param max The maximum floating-point value.\r\n * @param inclusive If true, `max` will be inclusive.\r\n */\r\nfunction real(min, max, inclusive = false) {\r\n if (!isFinite(min)) {\r\n throw new RangeError(\"Expected min to be a finite number\");\r\n }\r\n else if (!isFinite(max)) {\r\n throw new RangeError(\"Expected max to be a finite number\");\r\n }\r\n return add(multiply(inclusive ? realZeroToOneInclusive : realZeroToOneExclusive, max - min), min);\r\n}\n\nconst sliceArray = Array.prototype.slice;\n\n/**\r\n * Shuffles an array in-place\r\n * @param engine The Engine to use when choosing random values\r\n * @param array The array to shuffle\r\n * @param downTo minimum index to shuffle. Only used internally.\r\n */\r\nfunction shuffle(engine, array, downTo = 0) {\r\n const length = array.length;\r\n if (length) {\r\n for (let i = (length - 1) >>> 0; i > downTo; --i) {\r\n const distribution = integer(0, i);\r\n const j = distribution(engine);\r\n if (i !== j) {\r\n const tmp = array[i];\r\n array[i] = array[j];\r\n array[j] = tmp;\r\n }\r\n }\r\n }\r\n return array;\r\n}\n\n/**\r\n * From the population array, produce an array with sampleSize elements that\r\n * are randomly chosen without repeats.\r\n * @param engine The Engine to use when choosing random values\r\n * @param population An array that has items to choose a sample from\r\n * @param sampleSize The size of the result array\r\n */\r\nfunction sample(engine, population, sampleSize) {\r\n if (sampleSize < 0 ||\r\n sampleSize > population.length ||\r\n !isFinite(sampleSize)) {\r\n throw new RangeError(\"Expected sampleSize to be within 0 and the length of the population\");\r\n }\r\n if (sampleSize === 0) {\r\n return [];\r\n }\r\n const clone = sliceArray.call(population);\r\n const length = clone.length;\r\n if (length === sampleSize) {\r\n return shuffle(engine, clone, 0);\r\n }\r\n const tailLength = length - sampleSize;\r\n return shuffle(engine, clone, tailLength - 1).slice(tailLength);\r\n}\n\nconst stringRepeat = (() => {\r\n try {\r\n if (\"x\".repeat(3) === \"xxx\") {\r\n return (pattern, count) => pattern.repeat(count);\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n return (pattern, count) => {\r\n let result = \"\";\r\n while (count > 0) {\r\n if (count & 1) {\r\n result += pattern;\r\n }\r\n count >>= 1;\r\n pattern += pattern;\r\n }\r\n return result;\r\n };\r\n})();\n\nfunction zeroPad(text, zeroCount) {\r\n return stringRepeat(\"0\", zeroCount - text.length) + text;\r\n}\r\n/**\r\n * Returns a Universally Unique Identifier Version 4.\r\n *\r\n * See http://en.wikipedia.org/wiki/Universally_unique_identifier\r\n */\r\nfunction uuid4(engine) {\r\n const a = engine.next() >>> 0;\r\n const b = engine.next() | 0;\r\n const c = engine.next() | 0;\r\n const d = engine.next() >>> 0;\r\n return (zeroPad(a.toString(16), 8) +\r\n \"-\" +\r\n zeroPad((b & 0xffff).toString(16), 4) +\r\n \"-\" +\r\n zeroPad((((b >> 4) & 0x0fff) | 0x4000).toString(16), 4) +\r\n \"-\" +\r\n zeroPad(((c & 0x3fff) | 0x8000).toString(16), 4) +\r\n \"-\" +\r\n zeroPad(((c >> 4) & 0xffff).toString(16), 4) +\r\n zeroPad(d.toString(16), 8));\r\n}\n\n/**\r\n * An int32-producing Engine that uses `Math.random()`\r\n */\r\nconst nativeMath = {\r\n next() {\r\n return (Math.random() * UINT32_SIZE) | 0;\r\n }\r\n};\n\n// tslint:disable:unified-signatures\r\n/**\r\n * A wrapper around an Engine that provides easy-to-use methods for\r\n * producing values based on known distributions\r\n */\r\nclass Random {\r\n /**\r\n * Creates a new Random wrapper\r\n * @param engine The engine to use (defaults to a `Math.random`-based implementation)\r\n */\r\n constructor(engine = nativeMath) {\r\n this.engine = engine;\r\n }\r\n /**\r\n * Returns a value within [-0x80000000, 0x7fffffff]\r\n */\r\n int32() {\r\n return int32(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0xffffffff]\r\n */\r\n uint32() {\r\n return uint32(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0x1fffffffffffff]\r\n */\r\n uint53() {\r\n return uint53(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0x20000000000000]\r\n */\r\n uint53Full() {\r\n return uint53Full(this.engine);\r\n }\r\n /**\r\n * Returns a value within [-0x20000000000000, 0x1fffffffffffff]\r\n */\r\n int53() {\r\n return int53(this.engine);\r\n }\r\n /**\r\n * Returns a value within [-0x20000000000000, 0x20000000000000]\r\n */\r\n int53Full() {\r\n return int53Full(this.engine);\r\n }\r\n /**\r\n * Returns a value within [min, max]\r\n * @param min The minimum integer value, inclusive. No less than -0x20000000000000.\r\n * @param max The maximum integer value, inclusive. No greater than 0x20000000000000.\r\n */\r\n integer(min, max) {\r\n return integer(min, max)(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [0.0, 1.0]\r\n */\r\n realZeroToOneInclusive() {\r\n return realZeroToOneInclusive(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [0.0, 1.0)\r\n */\r\n realZeroToOneExclusive() {\r\n return realZeroToOneExclusive(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [min, max) or [min, max]\r\n * @param min The minimum floating-point value, inclusive.\r\n * @param max The maximum floating-point value.\r\n * @param inclusive If true, `max` will be inclusive.\r\n */\r\n real(min, max, inclusive = false) {\r\n return real(min, max, inclusive)(this.engine);\r\n }\r\n bool(numerator, denominator) {\r\n return bool(numerator, denominator)(this.engine);\r\n }\r\n /**\r\n * Return a random value within the provided `source` within the sliced\r\n * bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\n pick(source, begin, end) {\r\n return pick(this.engine, source, begin, end);\r\n }\r\n /**\r\n * Shuffles an array in-place\r\n * @param array The array to shuffle\r\n */\r\n shuffle(array) {\r\n return shuffle(this.engine, array);\r\n }\r\n /**\r\n * From the population array, returns an array with sampleSize elements that\r\n * are randomly chosen without repeats.\r\n * @param population An array that has items to choose a sample from\r\n * @param sampleSize The size of the result array\r\n */\r\n sample(population, sampleSize) {\r\n return sample(this.engine, population, sampleSize);\r\n }\r\n /**\r\n * Returns a value within [1, sideCount]\r\n * @param sideCount The number of sides of the die\r\n */\r\n die(sideCount) {\r\n return die(sideCount)(this.engine);\r\n }\r\n /**\r\n * Returns an array of length `dieCount` of values within [1, sideCount]\r\n * @param sideCount The number of sides of each die\r\n * @param dieCount The number of dice\r\n */\r\n dice(sideCount, dieCount) {\r\n return dice(sideCount, dieCount)(this.engine);\r\n }\r\n /**\r\n * Returns a Universally Unique Identifier Version 4.\r\n *\r\n * See http://en.wikipedia.org/wiki/Universally_unique_identifier\r\n */\r\n uuid4() {\r\n return uuid4(this.engine);\r\n }\r\n string(length, pool) {\r\n return string(pool)(this.engine, length);\r\n }\r\n /**\r\n * Returns a random string comprised of numbers or the characters `abcdef`\r\n * (or `ABCDEF`) of length `length`.\r\n * @param length Length of the result string\r\n * @param uppercase Whether the string should use `ABCDEF` instead of `abcdef`\r\n */\r\n hex(length, uppercase) {\r\n return hex(uppercase)(this.engine, length);\r\n }\r\n /**\r\n * Returns a random `Date` within the inclusive range of [`start`, `end`].\r\n * @param start The minimum `Date`\r\n * @param end The maximum `Date`\r\n */\r\n date(start, end) {\r\n return date(start, end)(this.engine);\r\n }\r\n}\n\n/**\r\n * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array\r\n */\r\nconst I32Array = (() => {\r\n try {\r\n const buffer = new ArrayBuffer(4);\r\n const view = new Int32Array(buffer);\r\n view[0] = INT32_SIZE;\r\n if (view[0] === -INT32_SIZE) {\r\n return Int32Array;\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n return Array;\r\n})();\n\nlet data = null;\r\nconst COUNT = 128;\r\nlet index = COUNT;\r\n/**\r\n * An Engine that relies on the globally-available `crypto.getRandomValues`,\r\n * which is typically available in modern browsers.\r\n *\r\n * See https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues\r\n *\r\n * If unavailable or otherwise non-functioning, then `browserCrypto` will\r\n * likely `throw` on the first call to `next()`.\r\n */\r\nconst browserCrypto = {\r\n next() {\r\n if (index >= COUNT) {\r\n if (data === null) {\r\n data = new I32Array(COUNT);\r\n }\r\n crypto.getRandomValues(data);\r\n index = 0;\r\n }\r\n return data[index++] | 0;\r\n }\r\n};\n\n/**\r\n * Returns an array of random int32 values, based on current time\r\n * and a random number engine\r\n *\r\n * @param engine an Engine to pull random values from, default `nativeMath`\r\n * @param length the length of the Array, minimum 1, default 16\r\n */\r\nfunction createEntropy(engine = nativeMath, length = 16) {\r\n const array = [];\r\n array.push(new Date().getTime() | 0);\r\n for (let i = 1; i < length; ++i) {\r\n array[i] = engine.next() | 0;\r\n }\r\n return array;\r\n}\n\n/**\r\n * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul\r\n */\r\nconst imul = (() => {\r\n try {\r\n if (Math.imul(UINT32_MAX, 5) === -5) {\r\n return Math.imul;\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n const UINT16_MAX = 0xffff;\r\n return (a, b) => {\r\n const ah = (a >>> 16) & UINT16_MAX;\r\n const al = a & UINT16_MAX;\r\n const bh = (b >>> 16) & UINT16_MAX;\r\n const bl = b & UINT16_MAX;\r\n // the shift by 0 fixes the sign on the high part\r\n // the final |0 converts the unsigned value into a signed value\r\n return (al * bl + (((ah * bl + al * bh) << 16) >>> 0)) | 0;\r\n };\r\n})();\n\nconst ARRAY_SIZE = 624;\r\nconst ARRAY_MAX = ARRAY_SIZE - 1;\r\nconst M = 397;\r\nconst ARRAY_SIZE_MINUS_M = ARRAY_SIZE - M;\r\nconst A = 0x9908b0df;\r\n/**\r\n * An Engine that is a pseudorandom number generator using the Mersenne\r\n * Twister algorithm based on the prime 2**19937 − 1\r\n *\r\n * See http://en.wikipedia.org/wiki/Mersenne_twister\r\n */\r\nclass MersenneTwister19937 {\r\n /**\r\n * MersenneTwister19937 should not be instantiated directly.\r\n * Instead, use the static methods `seed`, `seedWithArray`, or `autoSeed`.\r\n */\r\n constructor() {\r\n this.data = new I32Array(ARRAY_SIZE);\r\n this.index = 0; // integer within [0, 624]\r\n this.uses = 0;\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with an initial int32 value\r\n * @param initial the initial seed value\r\n */\r\n static seed(initial) {\r\n return new MersenneTwister19937().seed(initial);\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with zero or more int32 values\r\n * @param source A series of int32 values\r\n */\r\n static seedWithArray(source) {\r\n return new MersenneTwister19937().seedWithArray(source);\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with the current time and\r\n * a series of natively-generated random values\r\n */\r\n static autoSeed() {\r\n return MersenneTwister19937.seedWithArray(createEntropy());\r\n }\r\n /**\r\n * Returns the next int32 value of the sequence\r\n */\r\n next() {\r\n if ((this.index | 0) >= ARRAY_SIZE) {\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n const value = this.data[this.index];\r\n this.index = (this.index + 1) | 0;\r\n this.uses += 1;\r\n return temper(value) | 0;\r\n }\r\n /**\r\n * Returns the number of times that the Engine has been used.\r\n *\r\n * This can be provided to an unused MersenneTwister19937 with the same\r\n * seed, bringing it to the exact point that was left off.\r\n */\r\n getUseCount() {\r\n return this.uses;\r\n }\r\n /**\r\n * Discards one or more items from the engine\r\n * @param count The count of items to discard\r\n */\r\n discard(count) {\r\n if (count <= 0) {\r\n return this;\r\n }\r\n this.uses += count;\r\n if ((this.index | 0) >= ARRAY_SIZE) {\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n while (count + this.index > ARRAY_SIZE) {\r\n count -= ARRAY_SIZE - this.index;\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n this.index = (this.index + count) | 0;\r\n return this;\r\n }\r\n seed(initial) {\r\n let previous = 0;\r\n this.data[0] = previous = initial | 0;\r\n for (let i = 1; i < ARRAY_SIZE; i = (i + 1) | 0) {\r\n this.data[i] = previous =\r\n (imul(previous ^ (previous >>> 30), 0x6c078965) + i) | 0;\r\n }\r\n this.index = ARRAY_SIZE;\r\n this.uses = 0;\r\n return this;\r\n }\r\n seedWithArray(source) {\r\n this.seed(0x012bd6aa);\r\n seedWithArray(this.data, source);\r\n return this;\r\n }\r\n}\r\nfunction refreshData(data) {\r\n let k = 0;\r\n let tmp = 0;\r\n for (; (k | 0) < ARRAY_SIZE_MINUS_M; k = (k + 1) | 0) {\r\n tmp = (data[k] & INT32_SIZE) | (data[(k + 1) | 0] & INT32_MAX);\r\n data[k] = data[(k + M) | 0] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n }\r\n for (; (k | 0) < ARRAY_MAX; k = (k + 1) | 0) {\r\n tmp = (data[k] & INT32_SIZE) | (data[(k + 1) | 0] & INT32_MAX);\r\n data[k] =\r\n data[(k - ARRAY_SIZE_MINUS_M) | 0] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n }\r\n tmp = (data[ARRAY_MAX] & INT32_SIZE) | (data[0] & INT32_MAX);\r\n data[ARRAY_MAX] = data[M - 1] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n}\r\nfunction temper(value) {\r\n value ^= value >>> 11;\r\n value ^= (value << 7) & 0x9d2c5680;\r\n value ^= (value << 15) & 0xefc60000;\r\n return value ^ (value >>> 18);\r\n}\r\nfunction seedWithArray(data, source) {\r\n let i = 1;\r\n let j = 0;\r\n const sourceLength = source.length;\r\n let k = Math.max(sourceLength, ARRAY_SIZE) | 0;\r\n let previous = data[0] | 0;\r\n for (; (k | 0) > 0; --k) {\r\n data[i] = previous =\r\n ((data[i] ^ imul(previous ^ (previous >>> 30), 0x0019660d)) +\r\n (source[j] | 0) +\r\n (j | 0)) |\r\n 0;\r\n i = (i + 1) | 0;\r\n ++j;\r\n if ((i | 0) > ARRAY_MAX) {\r\n data[0] = data[ARRAY_MAX];\r\n i = 1;\r\n }\r\n if (j >= sourceLength) {\r\n j = 0;\r\n }\r\n }\r\n for (k = ARRAY_MAX; (k | 0) > 0; --k) {\r\n data[i] = previous =\r\n ((data[i] ^ imul(previous ^ (previous >>> 30), 0x5d588b65)) - i) | 0;\r\n i = (i + 1) | 0;\r\n if ((i | 0) > ARRAY_MAX) {\r\n data[0] = data[ARRAY_MAX];\r\n i = 1;\r\n }\r\n }\r\n data[0] = INT32_SIZE;\r\n}\n\nlet data$1 = null;\r\nconst COUNT$1 = 128;\r\nlet index$1 = COUNT$1;\r\n/**\r\n * An Engine that relies on the node-available\r\n * `require('crypto').randomBytes`, which has been available since 0.58.\r\n *\r\n * See https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback\r\n *\r\n * If unavailable or otherwise non-functioning, then `nodeCrypto` will\r\n * likely `throw` on the first call to `next()`.\r\n */\r\nconst nodeCrypto = {\r\n next() {\r\n if (index$1 >= COUNT$1) {\r\n data$1 = new Int32Array(new Int8Array(require(\"crypto\").randomBytes(4 * COUNT$1)).buffer);\r\n index$1 = 0;\r\n }\r\n return data$1[index$1++] | 0;\r\n }\r\n};\n\n/**\r\n * Returns a Distribution to random value within the provided `source`\r\n * within the sliced bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\nfunction picker(source, begin, end) {\r\n const clone = sliceArray.call(source, begin, end);\r\n if (clone.length === 0) {\r\n throw new RangeError(`Cannot pick from a source with no items`);\r\n }\r\n const distribution = integer(0, clone.length - 1);\r\n return engine => clone[distribution(engine)];\r\n}\n\nexport { Random, browserCrypto, nativeMath, MersenneTwister19937, nodeCrypto, bool, date, dice, die, hex, int32, int53, int53Full, integer, pick, picker, real, realZeroToOneExclusive, realZeroToOneInclusive, sample, shuffle, string, uint32, uint53, uint53Full, uuid4, createEntropy };\n//# sourceMappingURL=random-js.esm.js.map\n","import * as Random from 'random-js';\nimport Matrix from 'ml-matrix';\n\nexport function checkFloat(n) {\n return n > 0.0 && n <= 1.0;\n}\n\n/**\n * Select n with replacement elements on the training set and values, where n is the size of the training set.\n * @ignore\n * @param {Matrix} trainingSet\n * @param {Array} trainingValue\n * @param {number} seed - seed for the random selection, must be a 32-bit integer.\n * @return {object} with new X and y.\n */\nexport function examplesBaggingWithReplacement(\n trainingSet,\n trainingValue,\n seed,\n) {\n let engine;\n let distribution = Random.integer(0, trainingSet.rows - 1);\n if (seed === undefined) {\n engine = Random.MersenneTwister19937.autoSeed();\n } else if (Number.isInteger(seed)) {\n engine = Random.MersenneTwister19937.seed(seed);\n } else {\n throw new RangeError(\n `Expected seed must be undefined or integer not ${seed}`,\n );\n }\n\n let Xr = new Array(trainingSet.rows);\n let yr = new Array(trainingSet.rows);\n\n for (let i = 0; i < trainingSet.rows; ++i) {\n let index = distribution(engine);\n Xr[i] = trainingSet.getRow(index);\n yr[i] = trainingValue[index];\n }\n\n return {\n X: new Matrix(Xr),\n y: yr,\n };\n}\n\n/**\n * selects n features from the training set with or without replacement, returns the new training set and the indexes used.\n * @ignore\n * @param {Matrix} trainingSet\n * @param {number} n - features.\n * @param {boolean} replacement\n * @param {number} seed - seed for the random selection, must be a 32-bit integer.\n * @return {object}\n */\nexport function featureBagging(trainingSet, n, replacement, seed) {\n if (trainingSet.columns < n) {\n throw new RangeError(\n 'N should be less or equal to the number of columns of X',\n );\n }\n\n let distribution = Random.integer(0, trainingSet.columns - 1);\n let engine;\n if (seed === undefined) {\n engine = Random.MersenneTwister19937.autoSeed();\n } else if (Number.isInteger(seed)) {\n engine = Random.MersenneTwister19937.seed(seed);\n } else {\n throw new RangeError(\n `Expected seed must be undefined or integer not ${seed}`,\n );\n }\n\n let toRet = new Matrix(trainingSet.rows, n);\n\n let usedIndex;\n let index;\n if (replacement) {\n usedIndex = new Array(n);\n for (let i = 0; i < n; ++i) {\n index = distribution(engine);\n usedIndex[i] = index;\n toRet.setColumn(i, trainingSet.getColumn(index));\n }\n } else {\n usedIndex = new Set();\n index = distribution(engine);\n for (let i = 0; i < n; ++i) {\n while (usedIndex.has(index)) {\n index = distribution(engine);\n }\n toRet.setColumn(i, trainingSet.getColumn(index));\n usedIndex.add(index);\n }\n usedIndex = Array.from(usedIndex);\n }\n\n return {\n X: toRet,\n usedIndex: usedIndex,\n };\n}\n","import {\n DecisionTreeClassifier as DTClassifier,\n DecisionTreeRegression as DTRegression,\n} from 'ml-cart';\nimport {\n Matrix,\n WrapperMatrix2D,\n MatrixTransposeView,\n MatrixColumnSelectionView,\n} from 'ml-matrix';\n\nimport * as Utils from './utils';\n\n/**\n * @class RandomForestBase\n */\nexport class RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number|String} [options.maxFeatures] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement] - use replacement over the sample features.\n * @param {number} [options.seed] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators] - number of estimator to use.\n * @param {object} [options.treeOptions] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {boolean} [options.isClassifier] - boolean to check if is a classifier or regression model (used by subclasses).\n * @param {boolean} [options.useSampleBagging] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.replacement = model.replacement;\n this.maxFeatures = model.maxFeatures;\n this.nEstimators = model.nEstimators;\n this.treeOptions = model.treeOptions;\n this.isClassifier = model.isClassifier;\n this.seed = model.seed;\n this.n = model.n;\n this.indexes = model.indexes;\n this.useSampleBagging = model.useSampleBagging;\n\n let Estimator = this.isClassifier ? DTClassifier : DTRegression;\n this.estimators = model.estimators.map((est) => Estimator.load(est));\n } else {\n this.replacement = options.replacement;\n this.maxFeatures = options.maxFeatures;\n this.nEstimators = options.nEstimators;\n this.treeOptions = options.treeOptions;\n this.isClassifier = options.isClassifier;\n this.seed = options.seed;\n this.useSampleBagging = options.useSampleBagging;\n }\n }\n\n /**\n * Train the decision tree with the given training set and labels.\n * @param {Matrix|Array} trainingSet\n * @param {Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n this.maxFeatures = this.maxFeatures || trainingSet.columns;\n\n if (Utils.checkFloat(this.maxFeatures)) {\n this.n = Math.floor(trainingSet.columns * this.maxFeatures);\n } else if (Number.isInteger(this.maxFeatures)) {\n if (this.maxFeatures > trainingSet.columns) {\n throw new RangeError(\n `The maxFeatures parameter should be less than ${trainingSet.columns}`,\n );\n } else {\n this.n = this.maxFeatures;\n }\n } else {\n throw new RangeError(\n `Cannot process the maxFeatures parameter ${this.maxFeatures}`,\n );\n }\n\n let Estimator;\n if (this.isClassifier) {\n Estimator = DTClassifier;\n } else {\n Estimator = DTRegression;\n }\n\n this.estimators = new Array(this.nEstimators);\n this.indexes = new Array(this.nEstimators);\n\n for (let i = 0; i < this.nEstimators; ++i) {\n let res = this.useSampleBagging\n ? Utils.examplesBaggingWithReplacement(\n trainingSet,\n trainingValues,\n this.seed,\n )\n : { X: trainingSet, y: trainingValues };\n let X = res.X;\n let y = res.y;\n\n res = Utils.featureBagging(X, this.n, this.replacement, this.seed);\n X = res.X;\n\n this.indexes[i] = res.usedIndex;\n this.estimators[i] = new Estimator(this.treeOptions);\n this.estimators[i].train(X, y);\n }\n }\n\n /**\n * Method that returns the way the algorithm generates the predictions, for example, in classification\n * you can return the mode of all predictions retrieved by the trees, or in case of regression you can\n * use the mean or the median.\n * @abstract\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction.\n */\n // eslint-disable-next-line no-unused-vars\n selection(values) {\n throw new Error(\"Abstract method 'selection' not implemented!\");\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n let predictionValues = new Array(this.nEstimators);\n toPredict = Matrix.checkMatrix(toPredict);\n for (let i = 0; i < this.nEstimators; ++i) {\n let X = new MatrixColumnSelectionView(toPredict, this.indexes[i]); // get features for estimator\n predictionValues[i] = this.estimators[i].predict(X);\n }\n\n predictionValues = new MatrixTransposeView(\n new WrapperMatrix2D(predictionValues),\n );\n let predictions = new Array(predictionValues.rows);\n for (let i = 0; i < predictionValues.rows; ++i) {\n predictions[i] = this.selection(predictionValues.getRow(i));\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n indexes: this.indexes,\n n: this.n,\n replacement: this.replacement,\n maxFeatures: this.maxFeatures,\n nEstimators: this.nEstimators,\n treeOptions: this.treeOptions,\n isClassifier: this.isClassifier,\n seed: this.seed,\n estimators: this.estimators.map((est) => est.toJSON()),\n useSampleBagging: this.useSampleBagging,\n };\n }\n}\n","import { RandomForestBase } from './RandomForestBase';\n\nconst defaultOptions = {\n maxFeatures: 1.0,\n replacement: true,\n nEstimators: 10,\n seed: 42,\n useSampleBagging: false,\n};\n\n/**\n * @class RandomForestClassifier\n * @augments RandomForestBase\n */\nexport class RandomForestClassifier extends RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number} [options.maxFeatures=1.0] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement=true] - use replacement over the sample features.\n * @param {number} [options.seed=42] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators=10] - number of estimator to use.\n * @param {object} [options.treeOptions={}] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {boolean} [options.useSampleBagging=false] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n super(true, model.baseModel);\n } else {\n options = Object.assign({}, defaultOptions, options);\n options.isClassifier = true;\n super(options);\n }\n }\n\n /**\n * retrieve the prediction given the selection method.\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction\n */\n selection(values) {\n return mode(values);\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n let baseModel = super.toJSON();\n return {\n baseModel: baseModel,\n name: 'RFClassifier',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {RandomForestClassifier}\n */\n static load(model) {\n if (model.name !== 'RFClassifier') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new RandomForestClassifier(true, model);\n }\n}\n\n/**\n * Return the most repeated element on the array.\n * @param {Array} arr\n * @return {number} mode\n */\nfunction mode(arr) {\n return arr\n .sort(\n (a, b) =>\n arr.filter((v) => v === a).length - arr.filter((v) => v === b).length,\n )\n .pop();\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","(function(){function a(d){for(var e=0,f=d.length-1,g=void 0,h=void 0,i=void 0,j=c(e,f);!0;){if(f<=e)return d[j];if(f==e+1)return d[e]>d[f]&&b(d,e,f),d[j];for(g=c(e,f),d[g]>d[f]&&b(d,g,f),d[e]>d[f]&&b(d,e,f),d[g]>d[e]&&b(d,g,e),b(d,g,e+1),h=e+1,i=f;!0;){do h++;while(d[e]>d[h]);do i--;while(d[i]>d[e]);if(i=j&&(f=i-1)}}var b=function b(d,e,f){var _ref;return _ref=[d[f],d[e]],d[e]=_ref[0],d[f]=_ref[1],_ref},c=function c(d,e){return~~((d+e)/2)};'undefined'!=typeof module&&module.exports?module.exports=a:window.median=a})();\n","import isArray from 'is-any-array';\nimport quickSelectMedian from 'median-quickselect';\n\nfunction median(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n return quickSelectMedian(input.slice());\n}\n\nexport default median;\n","import arrayMean from 'ml-array-mean';\nimport arrayMedian from 'ml-array-median';\n\nimport { RandomForestBase } from './RandomForestBase';\n\nconst selectionMethods = {\n mean: arrayMean,\n median: arrayMedian,\n};\n\nconst defaultOptions = {\n maxFeatures: 1.0,\n replacement: false,\n nEstimators: 10,\n treeOptions: {},\n selectionMethod: 'mean',\n seed: 42,\n useSampleBagging: false,\n};\n\n/**\n * @class RandomForestRegression\n * @augments RandomForestBase\n */\nexport class RandomForestRegression extends RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number} [options.maxFeatures=1.0] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement=true] - use replacement over the sample features.\n * @param {number} [options.seed=42] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators=10] - number of estimator to use.\n * @param {object} [options.treeOptions={}] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {string} [options.selectionMethod=\"mean\"] - the way to calculate the prediction from estimators, \"mean\" and \"median\" are supported.\n * @param {boolean} [options.useSampleBagging=false] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n super(true, model.baseModel);\n this.selectionMethod = model.selectionMethod;\n } else {\n options = Object.assign({}, defaultOptions, options);\n\n if (\n !(\n options.selectionMethod === 'mean' ||\n options.selectionMethod === 'median'\n )\n ) {\n throw new RangeError(\n `Unsupported selection method ${options.selectionMethod}`,\n );\n }\n\n options.isClassifier = false;\n\n super(options);\n this.selectionMethod = options.selectionMethod;\n }\n }\n\n /**\n * retrieve the prediction given the selection method.\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction\n */\n selection(values) {\n return selectionMethods[this.selectionMethod](values);\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n let baseModel = super.toJSON();\n return {\n baseModel: baseModel,\n selectionMethod: this.selectionMethod,\n name: 'RFRegression',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {RandomForestRegression}\n */\n static load(model) {\n if (model.name !== 'RFRegression') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new RandomForestRegression(true, model);\n }\n}\n","import { Matrix, MatrixTransposeView, EVD, SVD, NIPALS } from 'ml-matrix';\n\n/**\n * Creates new PCA (Principal Component Analysis) from the dataset\n * @param {Matrix} dataset - dataset or covariance matrix.\n * @param {Object} [options]\n * @param {boolean} [options.isCovarianceMatrix=false] - true if the dataset is a covariance matrix.\n * @param {string} [options.method='SVD'] - select which method to use: SVD (default), covarianceMatrirx or NIPALS.\n * @param {number} [options.nCompNIPALS=2] - number of components to be computed with NIPALS.\n * @param {boolean} [options.center=true] - should the data be centered (subtract the mean).\n * @param {boolean} [options.scale=false] - should the data be scaled (divide by the standard deviation).\n * @param {boolean} [options.ignoreZeroVariance=false] - ignore columns with zero variance if `scale` is `true`.\n * */\nexport class PCA {\n constructor(dataset, options = {}) {\n if (dataset === true) {\n const model = options;\n this.center = model.center;\n this.scale = model.scale;\n this.means = model.means;\n this.stdevs = model.stdevs;\n this.U = Matrix.checkMatrix(model.U);\n this.S = model.S;\n this.R = model.R;\n this.excludedFeatures = model.excludedFeatures || [];\n return;\n }\n\n dataset = new Matrix(dataset);\n\n const {\n isCovarianceMatrix = false,\n method = 'SVD',\n nCompNIPALS = 2,\n center = true,\n scale = false,\n ignoreZeroVariance = false,\n } = options;\n\n this.center = center;\n this.scale = scale;\n this.means = null;\n this.stdevs = null;\n this.excludedFeatures = [];\n\n if (isCovarianceMatrix) {\n // User provided a covariance matrix instead of dataset.\n this._computeFromCovarianceMatrix(dataset);\n return;\n }\n\n this._adjust(dataset, ignoreZeroVariance);\n switch (method) {\n case 'covarianceMatrix': {\n // User provided a dataset but wants us to compute and use the covariance matrix.\n const covarianceMatrix = new MatrixTransposeView(dataset)\n .mmul(dataset)\n .div(dataset.rows - 1);\n this._computeFromCovarianceMatrix(covarianceMatrix);\n break;\n }\n case 'NIPALS': {\n this._computeWithNIPALS(dataset, nCompNIPALS);\n break;\n }\n case 'SVD': {\n const svd = new SVD(dataset, {\n computeLeftSingularVectors: false,\n computeRightSingularVectors: true,\n autoTranspose: true,\n });\n\n this.U = svd.rightSingularVectors;\n\n const singularValues = svd.diagonal;\n const eigenvalues = [];\n for (const singularValue of singularValues) {\n eigenvalues.push((singularValue * singularValue) / (dataset.rows - 1));\n }\n this.S = eigenvalues;\n break;\n }\n default: {\n throw new Error(`unknown method: ${method}`);\n }\n }\n }\n\n /**\n * Load a PCA model from JSON\n * @param {Object} model\n * @return {PCA}\n */\n static load(model) {\n if (typeof model.name !== 'string') {\n throw new TypeError('model must have a name property');\n }\n if (model.name !== 'PCA') {\n throw new RangeError(`invalid model: ${model.name}`);\n }\n return new PCA(true, model);\n }\n\n /**\n * Project the dataset into the PCA space\n * @param {Matrix} dataset\n * @param {Object} options\n * @return {Matrix} dataset projected in the PCA space\n */\n predict(dataset, options = {}) {\n const { nComponents = this.U.columns } = options;\n dataset = new Matrix(dataset);\n if (this.center) {\n dataset.subRowVector(this.means);\n if (this.scale) {\n for (let i of this.excludedFeatures) {\n dataset.removeColumn(i);\n }\n dataset.divRowVector(this.stdevs);\n }\n }\n var predictions = dataset.mmul(this.U);\n return predictions.subMatrix(0, predictions.rows - 1, 0, nComponents - 1);\n }\n\n /**\n * Calculates the inverse PCA transform\n * @param {Matrix} dataset\n * @return {Matrix} dataset projected in the PCA space\n */\n invert(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n\n var inverse = dataset.mmul(this.U.transpose());\n\n if (this.center) {\n if (this.scale) {\n inverse.mulRowVector(this.stdevs);\n }\n inverse.addRowVector(this.means);\n }\n\n return inverse;\n }\n\n\n /**\n * Returns the proportion of variance for each component\n * @return {[number]}\n */\n getExplainedVariance() {\n var sum = 0;\n for (const s of this.S) {\n sum += s;\n }\n return this.S.map((value) => value / sum);\n }\n\n /**\n * Returns the cumulative proportion of variance\n * @return {[number]}\n */\n getCumulativeVariance() {\n var explained = this.getExplainedVariance();\n for (var i = 1; i < explained.length; i++) {\n explained[i] += explained[i - 1];\n }\n return explained;\n }\n\n /**\n * Returns the Eigenvectors of the covariance matrix\n * @returns {Matrix}\n */\n getEigenvectors() {\n return this.U;\n }\n\n /**\n * Returns the Eigenvalues (on the diagonal)\n * @returns {[number]}\n */\n getEigenvalues() {\n return this.S;\n }\n\n /**\n * Returns the standard deviations of the principal components\n * @returns {[number]}\n */\n getStandardDeviations() {\n return this.S.map((x) => Math.sqrt(x));\n }\n\n /**\n * Returns the loadings matrix\n * @return {Matrix}\n */\n getLoadings() {\n return this.U.transpose();\n }\n\n /**\n * Export the current model to a JSON object\n * @return {Object} model\n */\n toJSON() {\n return {\n name: 'PCA',\n center: this.center,\n scale: this.scale,\n means: this.means,\n stdevs: this.stdevs,\n U: this.U,\n S: this.S,\n excludedFeatures: this.excludedFeatures,\n };\n }\n\n _adjust(dataset, ignoreZeroVariance) {\n if (this.center) {\n const mean = dataset.mean('column');\n const stdevs = this.scale\n ? dataset.standardDeviation('column', { mean })\n : null;\n this.means = mean;\n dataset.subRowVector(mean);\n if (this.scale) {\n for (let i = 0; i < stdevs.length; i++) {\n if (stdevs[i] === 0) {\n if (ignoreZeroVariance) {\n dataset.removeColumn(i);\n stdevs.splice(i, 1);\n this.excludedFeatures.push(i);\n i--;\n } else {\n throw new RangeError(\n `Cannot scale the dataset (standard deviation is zero at index ${i}`,\n );\n }\n }\n }\n this.stdevs = stdevs;\n dataset.divRowVector(stdevs);\n }\n }\n }\n\n _computeFromCovarianceMatrix(dataset) {\n const evd = new EVD(dataset, { assumeSymmetric: true });\n this.U = evd.eigenvectorMatrix;\n this.U.flipRows();\n this.S = evd.realEigenvalues;\n this.S.reverse();\n }\n\n _computeWithNIPALS(dataset, nCompNIPALS) {\n this.U = new Matrix(nCompNIPALS, dataset.columns);\n this.S = [];\n\n let x = dataset;\n for (let i = 0; i < nCompNIPALS; i++) {\n let dc = new NIPALS(x);\n\n this.U.setRow(i, dc.w.transpose());\n this.S.push(Math.pow(dc.s.get(0, 0), 2));\n\n x = dc.xResidual;\n }\n this.U = this.U.transpose(); // to be compatible with API\n }\n}\n","export function squaredEuclidean(p, q) {\r\n let d = 0;\r\n for (let i = 0; i < p.length; i++) {\r\n d += (p[i] - q[i]) * (p[i] - q[i]);\r\n }\r\n return d;\r\n}\r\nexport function euclidean(p, q) {\r\n return Math.sqrt(squaredEuclidean(p, q));\r\n}\r\n","/**\n * Computes a distance/similarity matrix given an array of data and a distance/similarity function.\n * @param {Array} data An array of data\n * @param {function} distanceFn A function that accepts two arguments and computes a distance/similarity between them\n * @return {Array} The distance/similarity matrix. The matrix is square and has a size equal to the length of\n * the data array\n */\nexport default function distanceMatrix(data, distanceFn) {\n const result = getMatrix(data.length);\n\n // Compute upper distance matrix\n for (let i = 0; i < data.length; i++) {\n for (let j = 0; j <= i; j++) {\n result[i][j] = distanceFn(data[i], data[j]);\n result[j][i] = result[i][j];\n }\n }\n\n return result;\n}\n\nfunction getMatrix(size) {\n const matrix = [];\n for (let i = 0; i < size; i++) {\n const row = [];\n matrix.push(row);\n for (let j = 0; j < size; j++) {\n row.push(0);\n }\n }\n return matrix;\n}\n","// Generated by CoffeeScript 1.8.0\n(function() {\n var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup;\n\n floor = Math.floor, min = Math.min;\n\n\n /*\n Default comparison function to be used\n */\n\n defaultCmp = function(x, y) {\n if (x < y) {\n return -1;\n }\n if (x > y) {\n return 1;\n }\n return 0;\n };\n\n\n /*\n Insert item x in list a, and keep it sorted assuming a is sorted.\n \n If x is already in a, insert it to the right of the rightmost x.\n \n Optional args lo (default 0) and hi (default a.length) bound the slice\n of a to be searched.\n */\n\n insort = function(a, x, lo, hi, cmp) {\n var mid;\n if (lo == null) {\n lo = 0;\n }\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (lo < 0) {\n throw new Error('lo must be non-negative');\n }\n if (hi == null) {\n hi = a.length;\n }\n while (lo < hi) {\n mid = floor((lo + hi) / 2);\n if (cmp(x, a[mid]) < 0) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n return ([].splice.apply(a, [lo, lo - lo].concat(x)), x);\n };\n\n\n /*\n Push item onto heap, maintaining the heap invariant.\n */\n\n heappush = function(array, item, cmp) {\n if (cmp == null) {\n cmp = defaultCmp;\n }\n array.push(item);\n return _siftdown(array, 0, array.length - 1, cmp);\n };\n\n\n /*\n Pop the smallest item off the heap, maintaining the heap invariant.\n */\n\n heappop = function(array, cmp) {\n var lastelt, returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n lastelt = array.pop();\n if (array.length) {\n returnitem = array[0];\n array[0] = lastelt;\n _siftup(array, 0, cmp);\n } else {\n returnitem = lastelt;\n }\n return returnitem;\n };\n\n\n /*\n Pop and return the current smallest value, and add the new item.\n \n This is more efficient than heappop() followed by heappush(), and can be\n more appropriate when using a fixed size heap. Note that the value\n returned may be larger than item! That constrains reasonable use of\n this routine unless written as part of a conditional replacement:\n if item > array[0]\n item = heapreplace(array, item)\n */\n\n heapreplace = function(array, item, cmp) {\n var returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n returnitem = array[0];\n array[0] = item;\n _siftup(array, 0, cmp);\n return returnitem;\n };\n\n\n /*\n Fast version of a heappush followed by a heappop.\n */\n\n heappushpop = function(array, item, cmp) {\n var _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (array.length && cmp(array[0], item) < 0) {\n _ref = [array[0], item], item = _ref[0], array[0] = _ref[1];\n _siftup(array, 0, cmp);\n }\n return item;\n };\n\n\n /*\n Transform list into a heap, in-place, in O(array.length) time.\n */\n\n heapify = function(array, cmp) {\n var i, _i, _j, _len, _ref, _ref1, _results, _results1;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n _ref1 = (function() {\n _results1 = [];\n for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); }\n return _results1;\n }).apply(this).reverse();\n _results = [];\n for (_i = 0, _len = _ref1.length; _i < _len; _i++) {\n i = _ref1[_i];\n _results.push(_siftup(array, i, cmp));\n }\n return _results;\n };\n\n\n /*\n Update the position of the given item in the heap.\n This function should be called every time the item is being modified.\n */\n\n updateItem = function(array, item, cmp) {\n var pos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n pos = array.indexOf(item);\n if (pos === -1) {\n return;\n }\n _siftdown(array, 0, pos, cmp);\n return _siftup(array, pos, cmp);\n };\n\n\n /*\n Find the n largest elements in a dataset.\n */\n\n nlargest = function(array, n, cmp) {\n var elem, result, _i, _len, _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n result = array.slice(0, n);\n if (!result.length) {\n return result;\n }\n heapify(result, cmp);\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n heappushpop(result, elem, cmp);\n }\n return result.sort(cmp).reverse();\n };\n\n\n /*\n Find the n smallest elements in a dataset.\n */\n\n nsmallest = function(array, n, cmp) {\n var elem, i, los, result, _i, _j, _len, _ref, _ref1, _results;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (n * 10 <= array.length) {\n result = array.slice(0, n).sort(cmp);\n if (!result.length) {\n return result;\n }\n los = result[result.length - 1];\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n if (cmp(elem, los) < 0) {\n insort(result, elem, 0, null, cmp);\n result.pop();\n los = result[result.length - 1];\n }\n }\n return result;\n }\n heapify(array, cmp);\n _results = [];\n for (i = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {\n _results.push(heappop(array, cmp));\n }\n return _results;\n };\n\n _siftdown = function(array, startpos, pos, cmp) {\n var newitem, parent, parentpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n newitem = array[pos];\n while (pos > startpos) {\n parentpos = (pos - 1) >> 1;\n parent = array[parentpos];\n if (cmp(newitem, parent) < 0) {\n array[pos] = parent;\n pos = parentpos;\n continue;\n }\n break;\n }\n return array[pos] = newitem;\n };\n\n _siftup = function(array, pos, cmp) {\n var childpos, endpos, newitem, rightpos, startpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n endpos = array.length;\n startpos = pos;\n newitem = array[pos];\n childpos = 2 * pos + 1;\n while (childpos < endpos) {\n rightpos = childpos + 1;\n if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {\n childpos = rightpos;\n }\n array[pos] = array[childpos];\n pos = childpos;\n childpos = 2 * pos + 1;\n }\n array[pos] = newitem;\n return _siftdown(array, startpos, pos, cmp);\n };\n\n Heap = (function() {\n Heap.push = heappush;\n\n Heap.pop = heappop;\n\n Heap.replace = heapreplace;\n\n Heap.pushpop = heappushpop;\n\n Heap.heapify = heapify;\n\n Heap.updateItem = updateItem;\n\n Heap.nlargest = nlargest;\n\n Heap.nsmallest = nsmallest;\n\n function Heap(cmp) {\n this.cmp = cmp != null ? cmp : defaultCmp;\n this.nodes = [];\n }\n\n Heap.prototype.push = function(x) {\n return heappush(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pop = function() {\n return heappop(this.nodes, this.cmp);\n };\n\n Heap.prototype.peek = function() {\n return this.nodes[0];\n };\n\n Heap.prototype.contains = function(x) {\n return this.nodes.indexOf(x) !== -1;\n };\n\n Heap.prototype.replace = function(x) {\n return heapreplace(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pushpop = function(x) {\n return heappushpop(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.heapify = function() {\n return heapify(this.nodes, this.cmp);\n };\n\n Heap.prototype.updateItem = function(x) {\n return updateItem(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.clear = function() {\n return this.nodes = [];\n };\n\n Heap.prototype.empty = function() {\n return this.nodes.length === 0;\n };\n\n Heap.prototype.size = function() {\n return this.nodes.length;\n };\n\n Heap.prototype.clone = function() {\n var heap;\n heap = new Heap();\n heap.nodes = this.nodes.slice(0);\n return heap;\n };\n\n Heap.prototype.toArray = function() {\n return this.nodes.slice(0);\n };\n\n Heap.prototype.insert = Heap.prototype.push;\n\n Heap.prototype.top = Heap.prototype.peek;\n\n Heap.prototype.front = Heap.prototype.peek;\n\n Heap.prototype.has = Heap.prototype.contains;\n\n Heap.prototype.copy = Heap.prototype.clone;\n\n return Heap;\n\n })();\n\n (function(root, factory) {\n if (typeof define === 'function' && define.amd) {\n return define([], factory);\n } else if (typeof exports === 'object') {\n return module.exports = factory();\n } else {\n return root.Heap = factory();\n }\n })(this, function() {\n return Heap;\n });\n\n}).call(this);\n","module.exports = require('./lib/heap');\n","import Heap from 'heap';\n\nexport default class Cluster {\n constructor() {\n this.children = [];\n this.height = 0;\n this.size = 1;\n this.index = -1;\n this.isLeaf = false;\n }\n\n /**\n * Creates an array of clusters where the maximum height is smaller than the threshold\n * @param {number} threshold\n * @return {Array}\n */\n cut(threshold) {\n if (typeof threshold !== 'number') {\n throw new TypeError('threshold must be a number');\n }\n if (threshold < 0) {\n throw new RangeError('threshold must be a positive number');\n }\n let list = [this];\n const ans = [];\n while (list.length > 0) {\n const aux = list.shift();\n if (threshold >= aux.height) {\n ans.push(aux);\n } else {\n list = list.concat(aux.children);\n }\n }\n return ans;\n }\n\n /**\n * Merge the leaves in the minimum way to have `groups` number of clusters.\n * @param {number} groups - Them number of children the first level of the tree should have.\n * @return {Cluster}\n */\n group(groups) {\n if (!Number.isInteger(groups) || groups < 1) {\n throw new RangeError('groups must be a positive integer');\n }\n\n const heap = new Heap((a, b) => {\n return b.height - a.height;\n });\n\n heap.push(this);\n\n while (heap.size() < groups) {\n var first = heap.pop();\n if (first.children.length === 0) {\n break;\n }\n first.children.forEach((child) => heap.push(child));\n }\n\n var root = new Cluster();\n root.children = heap.toArray();\n root.height = this.height;\n\n return root;\n }\n\n /**\n * Traverses the tree depth-first and calls the provided callback with each individual node\n * @param {function} cb - The callback to be called on each node encounter\n */\n traverse(cb) {\n function visit(root, callback) {\n callback(root);\n if (root.children) {\n for (const child of root.children) {\n visit(child, callback);\n }\n }\n }\n visit(this, cb);\n }\n\n /**\n * Returns a list of indices for all the leaves of this cluster.\n * The list is ordered in such a way that a dendrogram could be drawn without crossing branches.\n * @returns {Array}\n */\n indices() {\n const result = [];\n this.traverse((cluster) => {\n if (cluster.isLeaf) {\n result.push(cluster.index);\n }\n });\n return result;\n }\n}\n","import { euclidean } from 'ml-distance-euclidean';\nimport getDistanceMatrix from 'ml-distance-matrix';\nimport { Matrix } from 'ml-matrix';\n\nimport Cluster from './Cluster';\n\nfunction singleLink(dKI, dKJ) {\n return Math.min(dKI, dKJ);\n}\n\nfunction completeLink(dKI, dKJ) {\n return Math.max(dKI, dKJ);\n}\n\nfunction averageLink(dKI, dKJ, dIJ, ni, nj) {\n const ai = ni / (ni + nj);\n const aj = nj / (ni + nj);\n return ai * dKI + aj * dKJ;\n}\n\nfunction weightedAverageLink(dKI, dKJ) {\n return (dKI + dKJ) / 2;\n}\n\nfunction centroidLink(dKI, dKJ, dIJ, ni, nj) {\n const ai = ni / (ni + nj);\n const aj = nj / (ni + nj);\n const b = -(ni * nj) / (ni + nj) ** 2;\n return ai * dKI + aj * dKJ + b * dIJ;\n}\n\nfunction medianLink(dKI, dKJ, dIJ) {\n return dKI / 2 + dKJ / 2 - dIJ / 4;\n}\n\nfunction wardLink(dKI, dKJ, dIJ, ni, nj, nk) {\n const ai = (ni + nk) / (ni + nj + nk);\n const aj = (nj + nk) / (ni + nj + nk);\n const b = -nk / (ni + nj + nk);\n return ai * dKI + aj * dKJ + b * dIJ;\n}\n\nfunction wardLink2(dKI, dKJ, dIJ, ni, nj, nk) {\n const ai = (ni + nk) / (ni + nj + nk);\n const aj = (nj + nk) / (ni + nj + nk);\n const b = -nk / (ni + nj + nk);\n return Math.sqrt(ai * dKI * dKI + aj * dKJ * dKJ + b * dIJ * dIJ);\n}\n\n/**\n * Continuously merge nodes that have the least dissimilarity\n * @param {Array>} data - Array of points to be clustered\n * @param {object} [options]\n * @param {Function} [options.distanceFunction]\n * @param {string} [options.method] - Default: `'complete'`\n * @param {boolean} [options.isDistanceMatrix] - Is the input already a distance matrix?\n * @constructor\n */\nexport function agnes(data, options = {}) {\n const {\n distanceFunction = euclidean,\n method = 'complete',\n isDistanceMatrix = false,\n } = options;\n\n let updateFunc;\n if (!isDistanceMatrix) {\n data = getDistanceMatrix(data, distanceFunction);\n }\n let distanceMatrix = new Matrix(data);\n const numLeaves = distanceMatrix.rows;\n\n // allows to use a string or a given function\n if (typeof method === 'string') {\n switch (method.toLowerCase()) {\n case 'single':\n updateFunc = singleLink;\n break;\n case 'complete':\n updateFunc = completeLink;\n break;\n case 'average':\n case 'upgma':\n updateFunc = averageLink;\n break;\n case 'wpgma':\n updateFunc = weightedAverageLink;\n break;\n case 'centroid':\n case 'upgmc':\n updateFunc = centroidLink;\n break;\n case 'median':\n case 'wpgmc':\n updateFunc = medianLink;\n break;\n case 'ward':\n updateFunc = wardLink;\n break;\n case 'ward2':\n updateFunc = wardLink2;\n break;\n default:\n throw new RangeError(`unknown clustering method: ${method}`);\n }\n } else if (typeof method !== 'function') {\n throw new TypeError('method must be a string or function');\n }\n\n let clusters = [];\n for (let i = 0; i < numLeaves; i++) {\n const cluster = new Cluster();\n cluster.isLeaf = true;\n cluster.index = i;\n clusters.push(cluster);\n }\n\n for (let n = 0; n < numLeaves - 1; n++) {\n const [row, column, distance] = getSmallestDistance(distanceMatrix);\n const cluster1 = clusters[row];\n const cluster2 = clusters[column];\n const newCluster = new Cluster();\n newCluster.size = cluster1.size + cluster2.size;\n newCluster.children.push(cluster1, cluster2);\n newCluster.height = distance;\n\n const newClusters = [newCluster];\n const newDistanceMatrix = new Matrix(\n distanceMatrix.rows - 1,\n distanceMatrix.rows - 1,\n );\n const previous = (newIndex) =>\n getPreviousIndex(newIndex, Math.min(row, column), Math.max(row, column));\n\n for (let i = 1; i < newDistanceMatrix.rows; i++) {\n const prevI = previous(i);\n const prevICluster = clusters[prevI];\n newClusters.push(prevICluster);\n for (let j = 0; j < i; j++) {\n if (j === 0) {\n const dKI = distanceMatrix.get(row, prevI);\n const dKJ = distanceMatrix.get(prevI, column);\n const val = updateFunc(\n dKI,\n dKJ,\n distance,\n cluster1.size,\n cluster2.size,\n prevICluster.size,\n );\n newDistanceMatrix.set(i, j, val);\n newDistanceMatrix.set(j, i, val);\n } else {\n // Just copy distance from previous matrix\n const val = distanceMatrix.get(prevI, previous(j));\n newDistanceMatrix.set(i, j, val);\n newDistanceMatrix.set(j, i, val);\n }\n }\n }\n\n clusters = newClusters;\n distanceMatrix = newDistanceMatrix;\n }\n\n return clusters[0];\n}\n\nfunction getSmallestDistance(distance) {\n let smallest = Infinity;\n let smallestI = 0;\n let smallestJ = 0;\n for (let i = 1; i < distance.rows; i++) {\n for (let j = 0; j < i; j++) {\n if (distance.get(i, j) < smallest) {\n smallest = distance.get(i, j);\n smallestI = i;\n smallestJ = j;\n }\n }\n }\n return [smallestI, smallestJ, smallest];\n}\n\nfunction getPreviousIndex(newIndex, prev1, prev2) {\n newIndex -= 1;\n if (newIndex >= prev1) newIndex++;\n if (newIndex >= prev2) newIndex++;\n return newIndex;\n}\n","'use strict';\nimport { squaredEuclidean } from 'ml-distance-euclidean';\nconst defaultOptions = {\n distanceFunction: squaredEuclidean\n};\nexport default function nearestVector(listVectors, vector, options = defaultOptions) {\n const distanceFunction = options.distanceFunction || defaultOptions.distanceFunction;\n const similarityFunction = options.similarityFunction || defaultOptions.similarityFunction;\n let vectorIndex = -1;\n if (typeof similarityFunction === 'function') {\n // maximum similarity\n let maxSim = Number.MIN_VALUE;\n for (let j = 0; j < listVectors.length; j++) {\n const sim = similarityFunction(vector, listVectors[j]);\n if (sim > maxSim) {\n maxSim = sim;\n vectorIndex = j;\n }\n }\n }\n else if (typeof distanceFunction === 'function') {\n // minimum distance\n let minDist = Number.MAX_VALUE;\n for (let i = 0; i < listVectors.length; i++) {\n const dist = distanceFunction(vector, listVectors[i]);\n if (dist < minDist) {\n minDist = dist;\n vectorIndex = i;\n }\n }\n }\n else {\n throw new Error(\"A similarity or distance function it's required\");\n }\n return vectorIndex;\n}\nexport function findNearestVector(vectorList, vector, options = defaultOptions) {\n const index = nearestVector(vectorList, vector, options);\n return vectorList[index];\n}\n","import nearestVector from 'ml-nearest-vector';\n\n/**\n * Calculates the distance matrix for a given array of points\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @param {function} distance - Distance function to use between the points\n * @return {Array>} - matrix with the distance values\n */\nexport function calculateDistanceMatrix(data, distance) {\n var distanceMatrix = new Array(data.length);\n for (var i = 0; i < data.length; ++i) {\n for (var j = i; j < data.length; ++j) {\n if (!distanceMatrix[i]) {\n distanceMatrix[i] = new Array(data.length);\n }\n if (!distanceMatrix[j]) {\n distanceMatrix[j] = new Array(data.length);\n }\n const dist = distance(data[i], data[j]);\n distanceMatrix[i][j] = dist;\n distanceMatrix[j][i] = dist;\n }\n }\n return distanceMatrix;\n}\n\n/**\n * Updates the cluster identifier based in the new data\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @param {Array>} centers - the K centers in format [x,y,z,...]\n * @param {Array } clusterID - the cluster identifier for each data dot\n * @param {function} distance - Distance function to use between the points\n * @return {Array} the cluster identifier for each data dot\n */\nexport function updateClusterID(data, centers, clusterID, distance) {\n for (var i = 0; i < data.length; i++) {\n clusterID[i] = nearestVector(centers, data[i], {\n distanceFunction: distance\n });\n }\n return clusterID;\n}\n\n/**\n * Update the center values based in the new configurations of the clusters\n * @ignore\n * @param {Array>} prevCenters - Centroids from the previous iteration\n * @param {Array >} data - the [x,y,z,...] points to cluster\n * @param {Array } clusterID - the cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @return {Array} he K centers in format [x,y,z,...]\n */\nexport function updateCenters(prevCenters, data, clusterID, K) {\n const nDim = data[0].length;\n\n // copy previous centers\n var centers = new Array(K);\n var centersLen = new Array(K);\n for (var i = 0; i < K; i++) {\n centers[i] = new Array(nDim);\n centersLen[i] = 0;\n for (var j = 0; j < nDim; j++) {\n centers[i][j] = 0;\n }\n }\n\n // add the value for all dimensions of the point\n for (var l = 0; l < data.length; l++) {\n centersLen[clusterID[l]]++;\n for (var dim = 0; dim < nDim; dim++) {\n centers[clusterID[l]][dim] += data[l][dim];\n }\n }\n\n // divides by length\n for (var id = 0; id < K; id++) {\n for (var d = 0; d < nDim; d++) {\n if (centersLen[id]) {\n centers[id][d] /= centersLen[id];\n } else {\n centers[id][d] = prevCenters[id][d];\n }\n }\n }\n return centers;\n}\n\n/**\n * The centers have moved more than the tolerance value?\n * @ignore\n * @param {Array>} centers - the K centers in format [x,y,z,...]\n * @param {Array>} oldCenters - the K old centers in format [x,y,z,...]\n * @param {function} distanceFunction - Distance function to use between the points\n * @param {number} tolerance - Allowed distance for the centroids to move\n * @return {boolean}\n */\nexport function hasConverged(centers, oldCenters, distanceFunction, tolerance) {\n for (var i = 0; i < centers.length; i++) {\n if (distanceFunction(centers[i], oldCenters[i]) > tolerance) {\n return false;\n }\n }\n return true;\n}\n","const LOOP = 8;\nconst FLOAT_MUL = 1 / 16777216;\nconst sh1 = 15;\nconst sh2 = 18;\nconst sh3 = 11;\nfunction multiply_uint32(n, m) {\n n >>>= 0;\n m >>>= 0;\n const nlo = n & 0xffff;\n const nhi = n - nlo;\n return (((nhi * m) >>> 0) + nlo * m) >>> 0;\n}\nexport default class XSadd {\n constructor(seed = Date.now()) {\n this.state = new Uint32Array(4);\n this.init(seed);\n this.random = this.getFloat.bind(this);\n }\n /**\n * Returns a 32-bit integer r (0 <= r < 2^32)\n */\n getUint32() {\n this.nextState();\n return (this.state[3] + this.state[2]) >>> 0;\n }\n /**\n * Returns a floating point number r (0.0 <= r < 1.0)\n */\n getFloat() {\n return (this.getUint32() >>> 8) * FLOAT_MUL;\n }\n init(seed) {\n if (!Number.isInteger(seed)) {\n throw new TypeError('seed must be an integer');\n }\n this.state[0] = seed;\n this.state[1] = 0;\n this.state[2] = 0;\n this.state[3] = 0;\n for (let i = 1; i < LOOP; i++) {\n this.state[i & 3] ^=\n (i +\n multiply_uint32(1812433253, this.state[(i - 1) & 3] ^ ((this.state[(i - 1) & 3] >>> 30) >>> 0))) >>>\n 0;\n }\n this.periodCertification();\n for (let i = 0; i < LOOP; i++) {\n this.nextState();\n }\n }\n periodCertification() {\n if (this.state[0] === 0 &&\n this.state[1] === 0 &&\n this.state[2] === 0 &&\n this.state[3] === 0) {\n this.state[0] = 88; // X\n this.state[1] = 83; // S\n this.state[2] = 65; // A\n this.state[3] = 68; // D\n }\n }\n nextState() {\n let t = this.state[0];\n t ^= t << sh1;\n t ^= t >>> sh2;\n t ^= this.state[3] << sh3;\n this.state[0] = this.state[1];\n this.state[1] = this.state[2];\n this.state[2] = this.state[3];\n this.state[3] = t;\n }\n}\n","const PROB_TOLERANCE = 0.00000001;\nfunction randomChoice(values, options = {}, random = Math.random) {\n const { size = 1, replace = false, probabilities } = options;\n let valuesArr;\n let cumSum;\n if (typeof values === 'number') {\n valuesArr = getArray(values);\n }\n else {\n valuesArr = values.slice();\n }\n if (probabilities) {\n if (!replace) {\n throw new Error('choice with probabilities and no replacement is not implemented');\n }\n // check input is sane\n if (probabilities.length !== valuesArr.length) {\n throw new Error('the length of probabilities option should be equal to the number of choices');\n }\n cumSum = [probabilities[0]];\n for (let i = 1; i < probabilities.length; i++) {\n cumSum[i] = cumSum[i - 1] + probabilities[i];\n }\n if (Math.abs(1 - cumSum[cumSum.length - 1]) > PROB_TOLERANCE) {\n throw new Error(`probabilities should sum to 1, but instead sums to ${cumSum[cumSum.length - 1]}`);\n }\n }\n if (replace === false && size > valuesArr.length) {\n throw new Error('size option is too large');\n }\n const result = [];\n for (let i = 0; i < size; i++) {\n const index = randomIndex(valuesArr.length, random, cumSum);\n result.push(valuesArr[index]);\n if (!replace) {\n valuesArr.splice(index, 1);\n }\n }\n return result;\n}\nfunction getArray(n) {\n const arr = [];\n for (let i = 0; i < n; i++) {\n arr.push(i);\n }\n return arr;\n}\nfunction randomIndex(n, random, cumSum) {\n const rand = random();\n if (!cumSum) {\n return Math.floor(rand * n);\n }\n else {\n let idx = 0;\n while (rand > cumSum[idx]) {\n idx++;\n }\n return idx;\n }\n}\nexport default randomChoice;\n","// tslint:disable-next-line\nimport XSAdd from 'ml-xsadd';\nimport choice from './choice';\n/**\n * @classdesc Random class\n */\nexport default class Random {\n /**\n * @param [seedOrRandom=Math.random] - Control the random number generator used by the Random class instance. Pass a random number generator function with a uniform distribution over the half-open interval [0, 1[. If seed will pass it to ml-xsadd to create a seeded random number generator. If undefined will use Math.random.\n */\n constructor(seedOrRandom = Math.random) {\n if (typeof seedOrRandom === 'number') {\n const xsadd = new XSAdd(seedOrRandom);\n this.randomGenerator = xsadd.random;\n }\n else {\n this.randomGenerator = seedOrRandom;\n }\n }\n choice(values, options) {\n if (typeof values === 'number') {\n return choice(values, options, this.randomGenerator);\n }\n return choice(values, options, this.randomGenerator);\n }\n /**\n * Draw a random number from a uniform distribution on [0,1)\n * @return The random number\n */\n random() {\n return this.randomGenerator();\n }\n /**\n * Draw a random integer from a uniform distribution on [low, high). If only low is specified, the number is drawn on [0, low)\n * @param low - The lower bound of the uniform distribution interval.\n * @param high - The higher bound of the uniform distribution interval.\n */\n randInt(low, high) {\n if (high === undefined) {\n high = low;\n low = 0;\n }\n return low + Math.floor(this.randomGenerator() * (high - low));\n }\n /**\n * Draw several random number from a uniform distribution on [0, 1)\n * @param size - The number of number to draw\n * @return - The list of drawn numbers.\n */\n randomSample(size) {\n const result = [];\n for (let i = 0; i < size; i++) {\n result.push(this.random());\n }\n return result;\n }\n}\n","import Random from 'ml-random';\nimport { squaredEuclidean } from 'ml-distance-euclidean';\nimport { Matrix } from 'ml-matrix';\n\n/**\n * Choose K different random points from the original data\n * @ignore\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - number of clusters\n * @param {number} seed - seed for random number generation\n * @return {Array>} - Initial random points\n */\nexport function random(data, K, seed) {\n const random = new Random(seed);\n return random.choice(data, { size: K });\n}\n\n/**\n * Chooses the most distant points to a first random pick\n * @ignore\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - number of clusters\n * @param {Array>} distanceMatrix - matrix with the distance values\n * @param {number} seed - seed for random number generation\n * @return {Array>} - Initial random points\n */\nexport function mostDistant(data, K, distanceMatrix, seed) {\n const random = new Random(seed);\n var ans = new Array(K);\n // chooses a random point as initial cluster\n ans[0] = Math.floor(random.random() * data.length);\n\n if (K > 1) {\n // chooses the more distant point\n var maxDist = { dist: -1, index: -1 };\n for (var l = 0; l < data.length; ++l) {\n if (distanceMatrix[ans[0]][l] > maxDist.dist) {\n maxDist.dist = distanceMatrix[ans[0]][l];\n maxDist.index = l;\n }\n }\n ans[1] = maxDist.index;\n\n if (K > 2) {\n // chooses the set of points that maximises the min distance\n for (var k = 2; k < K; ++k) {\n var center = { dist: -1, index: -1 };\n for (var m = 0; m < data.length; ++m) {\n // minimum distance to centers\n var minDistCent = { dist: Number.MAX_VALUE, index: -1 };\n for (var n = 0; n < k; ++n) {\n if (\n distanceMatrix[n][m] < minDistCent.dist &&\n ans.indexOf(m) === -1\n ) {\n minDistCent = {\n dist: distanceMatrix[n][m],\n index: m\n };\n }\n }\n\n if (\n minDistCent.dist !== Number.MAX_VALUE &&\n minDistCent.dist > center.dist\n ) {\n center = Object.assign({}, minDistCent);\n }\n }\n\n ans[k] = center.index;\n }\n }\n }\n\n return ans.map((index) => data[index]);\n}\n\n// Implementation inspired from scikit\nexport function kmeanspp(X, K, options = {}) {\n X = new Matrix(X);\n const nSamples = X.rows;\n const random = new Random(options.seed);\n // Set the number of trials\n const centers = [];\n const localTrials = options.localTrials || 2 + Math.floor(Math.log(K));\n\n // Pick the first center at random from the dataset\n const firstCenterIdx = random.randInt(nSamples);\n centers.push(X.getRow(firstCenterIdx));\n\n // Init closest distances\n let closestDistSquared = new Matrix(1, X.rows);\n for (let i = 0; i < X.rows; i++) {\n closestDistSquared.set(0, i, squaredEuclidean(X.getRow(i), centers[0]));\n }\n let cumSumClosestDistSquared = [cumSum(closestDistSquared.getRow(0))];\n const factor = 1 / cumSumClosestDistSquared[0][nSamples - 1];\n let probabilities = Matrix.mul(closestDistSquared, factor);\n\n // Iterate over the remaining centers\n for (let i = 1; i < K; i++) {\n const candidateIdx = random.choice(nSamples, {\n replace: true,\n size: localTrials,\n probabilities: probabilities[0]\n });\n\n const candidates = X.selection(candidateIdx, range(X.columns));\n const distanceToCandidates = euclideanDistances(candidates, X);\n\n let bestCandidate;\n let bestPot;\n let bestDistSquared;\n\n for (let j = 0; j < localTrials; j++) {\n const newDistSquared = Matrix.min(closestDistSquared, [distanceToCandidates.getRow(j)]);\n const newPot = newDistSquared.sum();\n if (bestCandidate === undefined || newPot < bestPot) {\n bestCandidate = candidateIdx[j];\n bestPot = newPot;\n bestDistSquared = newDistSquared;\n }\n }\n centers[i] = X.getRow(bestCandidate);\n closestDistSquared = bestDistSquared;\n cumSumClosestDistSquared = [cumSum(closestDistSquared.getRow(0))];\n probabilities = Matrix.mul(\n closestDistSquared,\n 1 / cumSumClosestDistSquared[0][nSamples - 1]\n );\n }\n return centers;\n}\n\nfunction euclideanDistances(A, B) {\n const result = new Matrix(A.rows, B.rows);\n for (let i = 0; i < A.rows; i++) {\n for (let j = 0; j < B.rows; j++) {\n result.set(i, j, squaredEuclidean(A.getRow(i), B.getRow(j)));\n }\n }\n return result;\n}\n\nfunction range(l) {\n let r = [];\n for (let i = 0; i < l; i++) {\n r.push(i);\n }\n return r;\n}\n\nfunction cumSum(arr) {\n let cumSum = [arr[0]];\n for (let i = 1; i < arr.length; i++) {\n cumSum[i] = cumSum[i - 1] + arr[i];\n }\n return cumSum;\n}\n","import { updateClusterID } from './utils';\n\nconst distanceSymbol = Symbol('distance');\n\nexport default class KMeansResult {\n /**\n * Result of the kmeans algorithm\n * @param {Array} clusters - the cluster identifier for each data dot\n * @param {Array>} centroids - the K centers in format [x,y,z,...], the error and size of the cluster\n * @param {boolean} converged - Converge criteria satisfied\n * @param {number} iterations - Current number of iterations\n * @param {function} distance - (*Private*) Distance function to use between the points\n * @constructor\n */\n constructor(clusters, centroids, converged, iterations, distance) {\n this.clusters = clusters;\n this.centroids = centroids;\n this.converged = converged;\n this.iterations = iterations;\n this[distanceSymbol] = distance;\n }\n\n /**\n * Allows to compute for a new array of points their cluster id\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @return {Array} - cluster id for each point\n */\n nearest(data) {\n const clusterID = new Array(data.length);\n const centroids = this.centroids.map(function (centroid) {\n return centroid.centroid;\n });\n return updateClusterID(data, centroids, clusterID, this[distanceSymbol]);\n }\n\n /**\n * Returns a KMeansResult with the error and size of the cluster\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @return {KMeansResult}\n */\n computeInformation(data) {\n var enrichedCentroids = this.centroids.map(function (centroid) {\n return {\n centroid: centroid,\n error: 0,\n size: 0\n };\n });\n\n for (var i = 0; i < data.length; i++) {\n enrichedCentroids[this.clusters[i]].error += this[distanceSymbol](\n data[i],\n this.centroids[this.clusters[i]]\n );\n enrichedCentroids[this.clusters[i]].size++;\n }\n\n for (var j = 0; j < this.centroids.length; j++) {\n if (enrichedCentroids[j].size) {\n enrichedCentroids[j].error /= enrichedCentroids[j].size;\n } else {\n enrichedCentroids[j].error = null;\n }\n }\n\n return new KMeansResult(\n this.clusters,\n enrichedCentroids,\n this.converged,\n this.iterations,\n this[distanceSymbol]\n );\n }\n}\n","import { squaredEuclidean } from 'ml-distance-euclidean';\n\nimport {\n updateClusterID,\n updateCenters,\n hasConverged,\n calculateDistanceMatrix\n} from './utils';\nimport { mostDistant, random, kmeanspp } from './initialization';\nimport KMeansResult from './KMeansResult';\n\nconst defaultOptions = {\n maxIterations: 100,\n tolerance: 1e-6,\n withIterations: false,\n initialization: 'kmeans++',\n distanceFunction: squaredEuclidean\n};\n\n/**\n * Each step operation for kmeans\n * @ignore\n * @param {Array>} centers - K centers in format [x,y,z,...]\n * @param {Array>} data - Points [x,y,z,...] to cluster\n * @param {Array} clusterID - Cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n * @param {number} iterations - Current number of iterations\n * @return {KMeansResult}\n */\nfunction step(centers, data, clusterID, K, options, iterations) {\n clusterID = updateClusterID(\n data,\n centers,\n clusterID,\n options.distanceFunction\n );\n var newCenters = updateCenters(centers, data, clusterID, K);\n var converged = hasConverged(\n newCenters,\n centers,\n options.distanceFunction,\n options.tolerance\n );\n return new KMeansResult(\n clusterID,\n newCenters,\n converged,\n iterations,\n options.distanceFunction\n );\n}\n\n/**\n * Generator version for the algorithm\n * @ignore\n * @param {Array>} centers - K centers in format [x,y,z,...]\n * @param {Array>} data - Points [x,y,z,...] to cluster\n * @param {Array} clusterID - Cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n */\nfunction* kmeansGenerator(centers, data, clusterID, K, options) {\n var converged = false;\n var stepNumber = 0;\n var stepResult;\n while (!converged && stepNumber < options.maxIterations) {\n stepResult = step(centers, data, clusterID, K, options, ++stepNumber);\n yield stepResult.computeInformation(data);\n converged = stepResult.converged;\n centers = stepResult.centroids;\n }\n}\n\n/**\n * K-means algorithm\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n * @param {number} [options.maxIterations = 100] - Maximum of iterations allowed\n * @param {number} [options.tolerance = 1e-6] - Error tolerance\n * @param {boolean} [options.withIterations = false] - Store clusters and centroids for each iteration\n * @param {function} [options.distanceFunction = squaredDistance] - Distance function to use between the points\n * @param {number} [options.seed] - Seed for random initialization.\n * @param {string|Array>} [options.initialization = 'kmeans++'] - K centers in format [x,y,z,...] or a method for initialize the data:\n * * You can either specify your custom start centroids, or select one of the following initialization method:\n * * `'kmeans++'` will use the kmeans++ method as described by http://ilpubs.stanford.edu:8090/778/1/2006-13.pdf\n * * `'random'` will choose K random different values.\n * * `'mostDistant'` will choose the more distant points to a first random pick\n * @return {KMeansResult} - Cluster identifier for each data dot and centroids with the following fields:\n * * `'clusters'`: Array of indexes for the clusters.\n * * `'centroids'`: Array with the resulting centroids.\n * * `'iterations'`: Number of iterations that took to converge\n */\nexport default function kmeans(data, K, options) {\n options = Object.assign({}, defaultOptions, options);\n\n if (K <= 0 || K > data.length || !Number.isInteger(K)) {\n throw new Error(\n 'K should be a positive integer smaller than the number of points'\n );\n }\n\n var centers;\n if (Array.isArray(options.initialization)) {\n if (options.initialization.length !== K) {\n throw new Error('The initial centers should have the same length as K');\n } else {\n centers = options.initialization;\n }\n } else {\n switch (options.initialization) {\n case 'kmeans++':\n centers = kmeanspp(data, K, options);\n break;\n case 'random':\n centers = random(data, K, options.seed);\n break;\n case 'mostDistant':\n centers = mostDistant(\n data,\n K,\n calculateDistanceMatrix(data, options.distanceFunction),\n options.seed\n );\n break;\n default:\n throw new Error(\n `Unknown initialization method: \"${options.initialization}\"`\n );\n }\n }\n\n // infinite loop until convergence\n if (options.maxIterations === 0) {\n options.maxIterations = Number.MAX_VALUE;\n }\n\n var clusterID = new Array(data.length);\n if (options.withIterations) {\n return kmeansGenerator(centers, data, clusterID, K, options);\n } else {\n var converged = false;\n var stepNumber = 0;\n var stepResult;\n while (!converged && stepNumber < options.maxIterations) {\n stepResult = step(centers, data, clusterID, K, options, ++stepNumber);\n converged = stepResult.converged;\n centers = stepResult.centroids;\n }\n return stepResult.computeInformation(data);\n }\n}\n","import Matrix from 'ml-matrix';\n\n/**\n * @private\n * Function that retuns an array of matrices of the cases that belong to each class.\n * @param {Matrix} X - dataset\n * @param {Array} y - predictions\n * @return {Array}\n */\nexport function separateClasses(X, y) {\n var features = X.columns;\n\n var classes = 0;\n var totalPerClasses = new Array(10000); // max upperbound of classes\n for (var i = 0; i < y.length; i++) {\n if (totalPerClasses[y[i]] === undefined) {\n totalPerClasses[y[i]] = 0;\n classes++;\n }\n totalPerClasses[y[i]]++;\n }\n var separatedClasses = new Array(classes);\n var currentIndex = new Array(classes);\n for (i = 0; i < classes; ++i) {\n separatedClasses[i] = new Matrix(totalPerClasses[i], features);\n currentIndex[i] = 0;\n }\n for (i = 0; i < X.rows; ++i) {\n separatedClasses[y[i]].setRow(currentIndex[y[i]], X.getRow(i));\n currentIndex[y[i]]++;\n }\n return separatedClasses;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { separateClasses } from './utils';\n\nexport class GaussianNB {\n /**\n * Constructor for the Gaussian Naive Bayes classifier, the parameters here is just for loading purposes.\n * @constructor\n * @param {boolean} reload\n * @param {object} model\n */\n constructor(reload, model) {\n if (reload) {\n this.means = model.means;\n this.calculateProbabilities = model.calculateProbabilities;\n }\n }\n\n /**\n * Function that trains the classifier with a matrix that represents the training set and an array that\n * represents the label of each row in the training set. the labels must be numbers between 0 to n-1 where\n * n represents the number of classes.\n *\n * WARNING: in the case that one class, all the cases in one or more features have the same value, the\n * Naive Bayes classifier will not work well.\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n var C1 = Math.sqrt(2 * Math.PI); // constant to precalculate the squared root\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n if (trainingSet.rows !== trainingLabels.length) {\n throw new RangeError(\n 'the size of the training set and the training labels must be the same.'\n );\n }\n\n var separatedClasses = separateClasses(trainingSet, trainingLabels);\n var calculateProbabilities = new Array(separatedClasses.length);\n this.means = new Array(separatedClasses.length);\n for (var i = 0; i < separatedClasses.length; ++i) {\n var means = separatedClasses[i].mean('column');\n var std = separatedClasses[i].standardDeviation('column', {\n mean: means\n });\n\n var logPriorProbability = Math.log(\n separatedClasses[i].rows / trainingSet.rows\n );\n calculateProbabilities[i] = new Array(means.length + 1);\n\n calculateProbabilities[i][0] = logPriorProbability;\n for (var j = 1; j < means.length + 1; ++j) {\n var currentStd = std[j - 1];\n calculateProbabilities[i][j] = [\n 1 / (C1 * currentStd),\n -2 * currentStd * currentStd\n ];\n }\n\n this.means[i] = means;\n }\n\n this.calculateProbabilities = calculateProbabilities;\n }\n\n /**\n * function that predicts each row of the dataset (must be a matrix).\n *\n * @param {Matrix|Array} dataset\n * @return {Array}\n */\n predict(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n if (dataset.rows === this.calculateProbabilities[0].length) {\n throw new RangeError(\n 'the dataset must have the same features as the training set'\n );\n }\n\n var predictions = new Array(dataset.rows);\n\n for (var i = 0; i < predictions.length; ++i) {\n predictions[i] = getCurrentClass(\n dataset.getRow(i),\n this.means,\n this.calculateProbabilities\n );\n }\n\n return predictions;\n }\n\n /**\n * Function that export the NaiveBayes model.\n * @return {object}\n */\n toJSON() {\n return {\n modelName: 'NaiveBayes',\n means: this.means,\n calculateProbabilities: this.calculateProbabilities\n };\n }\n\n /**\n * Function that create a GaussianNB classifier with the given model.\n * @param {object} model\n * @return {GaussianNB}\n */\n static load(model) {\n if (model.modelName !== 'NaiveBayes') {\n throw new RangeError(\n 'The current model is not a Multinomial Naive Bayes, current model:',\n model.name\n );\n }\n\n return new GaussianNB(true, model);\n }\n}\n\n/**\n * @private\n * Function the retrieves a prediction with one case.\n *\n * @param {Array} currentCase\n * @param {Array} mean - Precalculated means of each class trained\n * @param {Array} classes - Precalculated value of each class (Prior probability and probability function of each feature)\n * @return {number}\n */\nfunction getCurrentClass(currentCase, mean, classes) {\n var maxProbability = 0;\n var predictedClass = -1;\n\n // going through all precalculated values for the classes\n for (var i = 0; i < classes.length; ++i) {\n var currentProbability = classes[i][0]; // initialize with the prior probability\n for (var j = 1; j < classes[0][1].length + 1; ++j) {\n currentProbability += calculateLogProbability(\n currentCase[j - 1],\n mean[i][j - 1],\n classes[i][j][0],\n classes[i][j][1]\n );\n }\n\n currentProbability = Math.exp(currentProbability);\n if (currentProbability > maxProbability) {\n maxProbability = currentProbability;\n predictedClass = i;\n }\n }\n\n return predictedClass;\n}\n\n/**\n * @private\n * function that retrieves the probability of the feature given the class.\n * @param {number} value - value of the feature.\n * @param {number} mean - mean of the feature for the given class.\n * @param {number} C1 - precalculated value of (1 / (sqrt(2*pi) * std)).\n * @param {number} C2 - precalculated value of (2 * std^2) for the denominator of the exponential.\n * @return {number}\n */\nfunction calculateLogProbability(value, mean, C1, C2) {\n value = value - mean;\n return Math.log(C1 * Math.exp((value * value) / C2));\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { separateClasses } from './utils';\n\nexport class MultinomialNB {\n /**\n * Constructor for Multinomial Naive Bayes, the model parameter is for load purposes.\n * @constructor\n * @param {object} model - for load purposes.\n */\n constructor(model) {\n if (model) {\n this.conditionalProbability = Matrix.checkMatrix(\n model.conditionalProbability\n );\n this.priorProbability = Matrix.checkMatrix(model.priorProbability);\n }\n }\n\n /**\n * Train the classifier with the current training set and labels, the labels must be numbers between 0 and n.\n * @param {Matrix|Array} trainingSet\n * @param {Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n if (trainingSet.rows !== trainingLabels.length) {\n throw new RangeError(\n 'the size of the training set and the training labels must be the same.'\n );\n }\n\n var separateClass = separateClasses(trainingSet, trainingLabels);\n\n this.priorProbability = new Matrix(separateClass.length, 1);\n\n for (var i = 0; i < separateClass.length; ++i) {\n this.priorProbability.set(i, 0, Math.log(\n separateClass[i].rows / trainingSet.rows\n ));\n }\n\n var features = trainingSet.columns;\n this.conditionalProbability = new Matrix(separateClass.length, features);\n for (i = 0; i < separateClass.length; ++i) {\n var classValues = Matrix.checkMatrix(separateClass[i]);\n var total = classValues.sum();\n var divisor = total + features;\n this.conditionalProbability.setRow(\n i,\n Matrix.rowVector(classValues\n .sum('column'))\n .add(1)\n .div(divisor)\n .apply(matrixLog)\n );\n }\n }\n\n /**\n * Retrieves the predictions for the dataset with the current model.\n * @param {Matrix|Array} dataset\n * @return {Array} - predictions from the dataset.\n */\n predict(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n var predictions = new Array(dataset.rows);\n for (var i = 0; i < dataset.rows; ++i) {\n var currentElement = dataset.getRowVector(i);\n const v = Matrix.columnVector(this.conditionalProbability\n .clone()\n .mulRowVector(currentElement)\n .sum('row'));\n predictions[i] = v\n .add(this.priorProbability)\n .maxIndex()[0];\n }\n\n return predictions;\n }\n\n /**\n * Function that saves the current model.\n * @return {object} - model in JSON format.\n */\n toJSON() {\n return {\n name: 'MultinomialNB',\n priorProbability: this.priorProbability,\n conditionalProbability: this.conditionalProbability\n };\n }\n\n /**\n * Creates a new MultinomialNB from the given model\n * @param {object} model\n * @return {MultinomialNB}\n */\n static load(model) {\n if (model.name !== 'MultinomialNB') {\n throw new RangeError(`${model.name} is not a Multinomial Naive Bayes`);\n }\n\n return new MultinomialNB(model);\n }\n}\n\nfunction matrixLog(i, j) {\n this.set(i, j, Math.log(this.get(i, j)));\n}\n","/*\n * Original code from:\n *\n * k-d Tree JavaScript - V 1.01\n *\n * https://github.com/ubilabs/kd-tree-javascript\n *\n * @author Mircea Pricop , 2012\n * @author Martin Kleppe , 2012\n * @author Ubilabs http://ubilabs.net, 2012\n * @license MIT License \n */\n\nfunction Node(obj, dimension, parent) {\n this.obj = obj;\n this.left = null;\n this.right = null;\n this.parent = parent;\n this.dimension = dimension;\n}\n\nexport default class KDTree {\n constructor(points, metric) {\n // If points is not an array, assume we're loading a pre-built tree\n if (!Array.isArray(points)) {\n this.dimensions = points.dimensions;\n this.root = points;\n restoreParent(this.root);\n } else {\n this.dimensions = new Array(points[0].length);\n for (var i = 0; i < this.dimensions.length; i++) {\n this.dimensions[i] = i;\n }\n this.root = buildTree(points, 0, null, this.dimensions);\n }\n this.metric = metric;\n }\n\n // Convert to a JSON serializable structure; this just requires removing\n // the `parent` property\n toJSON() {\n const result = toJSONImpl(this.root, true);\n result.dimensions = this.dimensions;\n return result;\n }\n\n nearest(point, maxNodes, maxDistance) {\n const metric = this.metric;\n const dimensions = this.dimensions;\n var i;\n\n const bestNodes = new BinaryHeap(function (e) {\n return -e[1];\n });\n\n function nearestSearch(node) {\n const dimension = dimensions[node.dimension];\n const ownDistance = metric(point, node.obj);\n const linearPoint = {};\n var bestChild, linearDistance, otherChild, i;\n\n function saveNode(node, distance) {\n bestNodes.push([node, distance]);\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop();\n }\n }\n\n for (i = 0; i < dimensions.length; i += 1) {\n if (i === node.dimension) {\n linearPoint[dimensions[i]] = point[dimensions[i]];\n } else {\n linearPoint[dimensions[i]] = node.obj[dimensions[i]];\n }\n }\n\n linearDistance = metric(linearPoint, node.obj);\n\n if (node.right === null && node.left === null) {\n if (bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1]) {\n saveNode(node, ownDistance);\n }\n return;\n }\n\n if (node.right === null) {\n bestChild = node.left;\n } else if (node.left === null) {\n bestChild = node.right;\n } else {\n if (point[dimension] < node.obj[dimension]) {\n bestChild = node.left;\n } else {\n bestChild = node.right;\n }\n }\n\n nearestSearch(bestChild);\n\n if (bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1]) {\n saveNode(node, ownDistance);\n }\n\n if (\n bestNodes.size() < maxNodes ||\n Math.abs(linearDistance) < bestNodes.peek()[1]\n ) {\n if (bestChild === node.left) {\n otherChild = node.right;\n } else {\n otherChild = node.left;\n }\n if (otherChild !== null) {\n nearestSearch(otherChild);\n }\n }\n }\n\n if (maxDistance) {\n for (i = 0; i < maxNodes; i += 1) {\n bestNodes.push([null, maxDistance]);\n }\n }\n\n if (this.root) {\n nearestSearch(this.root);\n }\n\n const result = [];\n for (i = 0; i < Math.min(maxNodes, bestNodes.content.length); i += 1) {\n if (bestNodes.content[i][0]) {\n result.push([bestNodes.content[i][0].obj, bestNodes.content[i][1]]);\n }\n }\n return result;\n }\n}\n\nfunction toJSONImpl(src) {\n const dest = new Node(src.obj, src.dimension, null);\n if (src.left) dest.left = toJSONImpl(src.left);\n if (src.right) dest.right = toJSONImpl(src.right);\n return dest;\n}\n\nfunction buildTree(points, depth, parent, dimensions) {\n const dim = depth % dimensions.length;\n\n if (points.length === 0) {\n return null;\n }\n if (points.length === 1) {\n return new Node(points[0], dim, parent);\n }\n\n points.sort((a, b) => a[dimensions[dim]] - b[dimensions[dim]]);\n\n const median = Math.floor(points.length / 2);\n const node = new Node(points[median], dim, parent);\n node.left = buildTree(points.slice(0, median), depth + 1, node, dimensions);\n node.right = buildTree(points.slice(median + 1), depth + 1, node, dimensions);\n\n return node;\n}\n\nfunction restoreParent(root) {\n if (root.left) {\n root.left.parent = root;\n restoreParent(root.left);\n }\n\n if (root.right) {\n root.right.parent = root;\n restoreParent(root.right);\n }\n}\n\n// Binary heap implementation from:\n// http://eloquentjavascript.net/appendix2.html\nclass BinaryHeap {\n constructor(scoreFunction) {\n this.content = [];\n this.scoreFunction = scoreFunction;\n }\n\n push(element) {\n // Add the new element to the end of the array.\n this.content.push(element);\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1);\n }\n\n pop() {\n // Store the first element so we can return it later.\n var result = this.content[0];\n // Get the element at the end of the array.\n var end = this.content.pop();\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (this.content.length > 0) {\n this.content[0] = end;\n this.sinkDown(0);\n }\n return result;\n }\n\n peek() {\n return this.content[0];\n }\n\n size() {\n return this.content.length;\n }\n\n bubbleUp(n) {\n // Fetch the element that has to be moved.\n var element = this.content[n];\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1;\n const parent = this.content[parentN];\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[parentN] = element;\n this.content[n] = parent;\n // Update 'n' to continue at the new position.\n n = parentN;\n } else {\n // Found a parent that is less, no need to move it further.\n break;\n }\n }\n }\n\n sinkDown(n) {\n // Look up the target element and its score.\n var length = this.content.length;\n var element = this.content[n];\n var elemScore = this.scoreFunction(element);\n\n while (true) {\n // Compute the indices of the child elements.\n var child2N = (n + 1) * 2;\n var child1N = child2N - 1;\n // This is used to store the new position of the element,\n // if any.\n var swap = null;\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n var child1 = this.content[child1N];\n var child1Score = this.scoreFunction(child1);\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) {\n swap = child1N;\n }\n }\n // Do the same checks for the other child.\n if (child2N < length) {\n var child2 = this.content[child2N];\n var child2Score = this.scoreFunction(child2);\n if (child2Score < (swap === null ? elemScore : child1Score)) {\n swap = child2N;\n }\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[n] = this.content[swap];\n this.content[swap] = element;\n n = swap;\n } else {\n // Otherwise, we are done.\n break;\n }\n }\n }\n}\n","import { euclidean as euclideanDistance } from 'ml-distance-euclidean';\n\nimport KDTree from './KDTree';\n\nexport default class KNN {\n /**\n * @param {Array} dataset\n * @param {Array} labels\n * @param {object} options\n * @param {number} [options.k=numberOfClasses + 1] - Number of neighbors to classify.\n * @param {function} [options.distance=euclideanDistance] - Distance function that takes two parameters.\n */\n constructor(dataset, labels, options = {}) {\n if (dataset === true) {\n const model = labels;\n this.kdTree = new KDTree(model.kdTree, options);\n this.k = model.k;\n this.classes = new Set(model.classes);\n this.isEuclidean = model.isEuclidean;\n return;\n }\n\n const classes = new Set(labels);\n\n const { distance = euclideanDistance, k = classes.size + 1 } = options;\n\n const points = new Array(dataset.length);\n for (var i = 0; i < points.length; ++i) {\n points[i] = dataset[i].slice();\n }\n\n for (i = 0; i < labels.length; ++i) {\n points[i].push(labels[i]);\n }\n\n this.kdTree = new KDTree(points, distance);\n this.k = k;\n this.classes = classes;\n this.isEuclidean = distance === euclideanDistance;\n }\n\n /**\n * Create a new KNN instance with the given model.\n * @param {object} model\n * @param {function} distance=euclideanDistance - distance function must be provided if the model wasn't trained with euclidean distance.\n * @return {KNN}\n */\n static load(model, distance = euclideanDistance) {\n if (model.name !== 'KNN') {\n throw new Error(`invalid model: ${model.name}`);\n }\n if (!model.isEuclidean && distance === euclideanDistance) {\n throw new Error(\n 'a custom distance function was used to create the model. Please provide it again'\n );\n }\n if (model.isEuclidean && distance !== euclideanDistance) {\n throw new Error(\n 'the model was created with the default distance function. Do not load it with another one'\n );\n }\n return new KNN(true, model, distance);\n }\n\n /**\n * Return a JSON containing the kd-tree model.\n * @return {object} JSON KNN model.\n */\n toJSON() {\n return {\n name: 'KNN',\n kdTree: this.kdTree,\n k: this.k,\n classes: Array.from(this.classes),\n isEuclidean: this.isEuclidean\n };\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Array} dataset\n * @return {Array} predictions\n */\n predict(dataset) {\n if (Array.isArray(dataset)) {\n if (typeof dataset[0] === 'number') {\n return getSinglePrediction(this, dataset);\n } else if (\n Array.isArray(dataset[0]) &&\n typeof dataset[0][0] === 'number'\n ) {\n const predictions = new Array(dataset.length);\n for (var i = 0; i < dataset.length; i++) {\n predictions[i] = getSinglePrediction(this, dataset[i]);\n }\n return predictions;\n }\n }\n throw new TypeError('dataset to predict must be an array or a matrix');\n }\n}\n\nfunction getSinglePrediction(knn, currentCase) {\n var nearestPoints = knn.kdTree.nearest(currentCase, knn.k);\n var pointsPerClass = {};\n var predictedClass = -1;\n var maxPoints = -1;\n var lastElement = nearestPoints[0][0].length - 1;\n\n for (var element of knn.classes) {\n pointsPerClass[element] = 0;\n }\n\n for (var i = 0; i < nearestPoints.length; ++i) {\n var currentClass = nearestPoints[i][0][lastElement];\n var currentPoints = ++pointsPerClass[currentClass];\n if (currentPoints > maxPoints) {\n predictedClass = currentClass;\n maxPoints = currentPoints;\n }\n }\n\n return predictedClass;\n}\n","import Matrix from 'ml-matrix';\n\n/**\n * @private\n * Function that given vector, returns its norm\n * @param {Vector} X\n * @return {number} Norm of the vector\n */\nexport function norm(X) {\n return Math.sqrt(\n X.clone()\n .apply(pow2array)\n .sum(),\n );\n}\n\n/**\n * @private\n * Function that pow 2 each element of a Matrix or a Vector,\n * used in the apply method of the Matrix object\n * @param {number} i - index i.\n * @param {number} j - index j.\n * @return {Matrix} The Matrix object modified at the index i, j.\n * */\nexport function pow2array(i, j) {\n this.set(i, j, this.get(i, j) ** 2);\n}\n\n/**\n * @private\n * Function that normalize the dataset and return the means and\n * standard deviation of each feature.\n * @param {Matrix} dataset\n * @return {object} dataset normalized, means and standard deviations\n */\nexport function featureNormalize(dataset) {\n let means = dataset.mean('column');\n let std = dataset.standardDeviation('column', {\n mean: means,\n unbiased: true,\n });\n let result = Matrix.checkMatrix(dataset).subRowVector(means);\n return { result: result.divRowVector(std), means: means, std: std };\n}\n\n/**\n * @private\n * Function that initialize an array of matrices.\n * @param {Array} array\n * @param {boolean} isMatrix\n * @return {Array} array with the matrices initialized.\n */\nexport function initializeMatrices(array, isMatrix) {\n if (isMatrix) {\n for (let i = 0; i < array.length; ++i) {\n for (let j = 0; j < array[i].length; ++j) {\n let elem = array[i][j];\n array[i][j] = elem !== null ? new Matrix(array[i][j]) : undefined;\n }\n }\n } else {\n for (let i = 0; i < array.length; ++i) {\n array[i] = new Matrix(array[i]);\n }\n }\n\n return array;\n}\n","import Matrix from 'ml-matrix';\n\nimport * as Utils from './util/utils';\n\n/**\n * @class PLS\n */\nexport class PLS {\n /**\n * Constructor for Partial Least Squares (PLS)\n * @param {object} options\n * @param {number} [options.latentVectors] - Number of latent vector to get (if the algorithm doesn't find a good model below the tolerance)\n * @param {number} [options.tolerance=1e-5]\n * @param {boolean} [options.scale=true] - rescale dataset using mean.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.meanX = model.meanX;\n this.stdDevX = model.stdDevX;\n this.meanY = model.meanY;\n this.stdDevY = model.stdDevY;\n this.PBQ = Matrix.checkMatrix(model.PBQ);\n this.R2X = model.R2X;\n this.scale = model.scale;\n this.scaleMethod = model.scaleMethod;\n this.tolerance = model.tolerance;\n } else {\n let { tolerance = 1e-5, scale = true } = options;\n this.tolerance = tolerance;\n this.scale = scale;\n this.latentVectors = options.latentVectors;\n }\n }\n\n /**\n * Fits the model with the given data and predictions, in this function is calculated the\n * following outputs:\n *\n * T - Score matrix of X\n * P - Loading matrix of X\n * U - Score matrix of Y\n * Q - Loading matrix of Y\n * B - Matrix of regression coefficient\n * W - Weight matrix of X\n *\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n trainingValues = Matrix.checkMatrix(trainingValues);\n\n if (trainingSet.length !== trainingValues.length) {\n throw new RangeError(\n 'The number of X rows must be equal to the number of Y rows',\n );\n }\n\n this.meanX = trainingSet.mean('column');\n this.stdDevX = trainingSet.standardDeviation('column', {\n mean: this.meanX,\n unbiased: true,\n });\n this.meanY = trainingValues.mean('column');\n this.stdDevY = trainingValues.standardDeviation('column', {\n mean: this.meanY,\n unbiased: true,\n });\n\n if (this.scale) {\n trainingSet = trainingSet\n .clone()\n .subRowVector(this.meanX)\n .divRowVector(this.stdDevX);\n trainingValues = trainingValues\n .clone()\n .subRowVector(this.meanY)\n .divRowVector(this.stdDevY);\n }\n\n if (this.latentVectors === undefined) {\n this.latentVectors = Math.min(trainingSet.rows - 1, trainingSet.columns);\n }\n\n let rx = trainingSet.rows;\n let cx = trainingSet.columns;\n let ry = trainingValues.rows;\n let cy = trainingValues.columns;\n\n let ssqXcal = trainingSet\n .clone()\n .mul(trainingSet)\n .sum(); // for the r²\n let sumOfSquaresY = trainingValues\n .clone()\n .mul(trainingValues)\n .sum();\n\n let tolerance = this.tolerance;\n let n = this.latentVectors;\n let T = Matrix.zeros(rx, n);\n let P = Matrix.zeros(cx, n);\n let U = Matrix.zeros(ry, n);\n let Q = Matrix.zeros(cy, n);\n let B = Matrix.zeros(n, n);\n let W = P.clone();\n let k = 0;\n let t;\n let w;\n let q;\n let p;\n\n while (Utils.norm(trainingValues) > tolerance && k < n) {\n let transposeX = trainingSet.transpose();\n let transposeY = trainingValues.transpose();\n\n let tIndex = maxSumColIndex(trainingSet.clone().mul(trainingSet));\n let uIndex = maxSumColIndex(trainingValues.clone().mul(trainingValues));\n\n let t1 = trainingSet.getColumnVector(tIndex);\n let u = trainingValues.getColumnVector(uIndex);\n t = Matrix.zeros(rx, 1);\n\n while (Utils.norm(t1.clone().sub(t)) > tolerance) {\n w = transposeX.mmul(u);\n w.div(Utils.norm(w));\n t = t1;\n t1 = trainingSet.mmul(w);\n q = transposeY.mmul(t1);\n q.div(Utils.norm(q));\n u = trainingValues.mmul(q);\n }\n\n t = t1;\n let num = transposeX.mmul(t);\n let den = t\n .transpose()\n .mmul(t)\n .get(0, 0);\n p = num.div(den);\n let pnorm = Utils.norm(p);\n p.div(pnorm);\n t.mul(pnorm);\n w.mul(pnorm);\n\n num = u.transpose().mmul(t);\n den = t\n .transpose()\n .mmul(t)\n .get(0, 0);\n let b = num.div(den).get(0, 0);\n trainingSet.sub(t.mmul(p.transpose()));\n trainingValues.sub(\n t\n .clone()\n .mul(b)\n .mmul(q.transpose()),\n );\n\n T.setColumn(k, t);\n P.setColumn(k, p);\n U.setColumn(k, u);\n Q.setColumn(k, q);\n W.setColumn(k, w);\n\n B.set(k, k, b);\n k++;\n }\n\n k--;\n T = T.subMatrix(0, T.rows - 1, 0, k);\n P = P.subMatrix(0, P.rows - 1, 0, k);\n U = U.subMatrix(0, U.rows - 1, 0, k);\n Q = Q.subMatrix(0, Q.rows - 1, 0, k);\n W = W.subMatrix(0, W.rows - 1, 0, k);\n B = B.subMatrix(0, k, 0, k);\n\n this.ssqYcal = sumOfSquaresY;\n this.E = trainingSet;\n this.F = trainingValues;\n this.T = T;\n this.P = P;\n this.U = U;\n this.Q = Q;\n this.W = W;\n this.B = B;\n this.PBQ = P.mmul(B).mmul(Q.transpose());\n this.R2X = t\n .transpose()\n .mmul(t)\n .mmul(p.transpose().mmul(p))\n .div(ssqXcal)\n .get(0, 0);\n }\n\n /**\n * Predicts the behavior of the given dataset.\n * @param {Matrix|Array} dataset - data to be predicted.\n * @return {Matrix} - predictions of each element of the dataset.\n */\n predict(dataset) {\n let X = Matrix.checkMatrix(dataset);\n if (this.scale) {\n X = X.subRowVector(this.meanX).divRowVector(this.stdDevX);\n }\n let Y = X.mmul(this.PBQ);\n Y = Y.mulRowVector(this.stdDevY).addRowVector(this.meanY);\n return Y;\n }\n\n /**\n * Returns the explained variance on training of the PLS model\n * @return {number}\n */\n getExplainedVariance() {\n return this.R2X;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n name: 'PLS',\n R2X: this.R2X,\n meanX: this.meanX,\n stdDevX: this.stdDevX,\n meanY: this.meanY,\n stdDevY: this.stdDevY,\n PBQ: this.PBQ,\n tolerance: this.tolerance,\n scale: this.scale,\n };\n }\n\n /**\n * Load a PLS model from a JSON Object\n * @param {object} model\n * @return {PLS} - PLS object from the given model\n */\n static load(model) {\n if (model.name !== 'PLS') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n return new PLS(true, model);\n }\n}\n\n/**\n * @private\n * Function that returns the index where the sum of each\n * column vector is maximum.\n * @param {Matrix} data\n * @return {number} index of the maximum\n */\nfunction maxSumColIndex(data) {\n return Matrix.rowVector(data.sum('column')).maxIndex()[0];\n}\n","import { Matrix, SingularValueDecomposition, inverse } from 'ml-matrix';\n\nimport { initializeMatrices } from './util/utils';\n\n/**\n * @class KOPLS\n */\nexport class KOPLS {\n /**\n * Constructor for Kernel-based Orthogonal Projections to Latent Structures (K-OPLS)\n * @param {object} options\n * @param {number} [options.predictiveComponents] - Number of predictive components to use.\n * @param {number} [options.orthogonalComponents] - Number of Y-Orthogonal components.\n * @param {Kernel} [options.kernel] - Kernel object to apply, see [ml-kernel](https://github.com/mljs/kernel).\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.trainingSet = new Matrix(model.trainingSet);\n this.YLoadingMat = new Matrix(model.YLoadingMat);\n this.SigmaPow = new Matrix(model.SigmaPow);\n this.YScoreMat = new Matrix(model.YScoreMat);\n this.predScoreMat = initializeMatrices(model.predScoreMat, false);\n this.YOrthLoadingVec = initializeMatrices(model.YOrthLoadingVec, false);\n this.YOrthEigen = model.YOrthEigen;\n this.YOrthScoreMat = initializeMatrices(model.YOrthScoreMat, false);\n this.toNorm = initializeMatrices(model.toNorm, false);\n this.TURegressionCoeff = initializeMatrices(\n model.TURegressionCoeff,\n false,\n );\n this.kernelX = initializeMatrices(model.kernelX, true);\n this.kernel = model.kernel;\n this.orthogonalComp = model.orthogonalComp;\n this.predictiveComp = model.predictiveComp;\n } else {\n if (options.predictiveComponents === undefined) {\n throw new RangeError('no predictive components found!');\n }\n if (options.orthogonalComponents === undefined) {\n throw new RangeError('no orthogonal components found!');\n }\n if (options.kernel === undefined) {\n throw new RangeError('no kernel found!');\n }\n\n this.orthogonalComp = options.orthogonalComponents;\n this.predictiveComp = options.predictiveComponents;\n this.kernel = options.kernel;\n }\n }\n\n /**\n * Train the K-OPLS model with the given training set and labels.\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n trainingValues = Matrix.checkMatrix(trainingValues);\n\n // to save and compute kernel with the prediction dataset.\n this.trainingSet = trainingSet.clone();\n\n let kernelX = this.kernel.compute(trainingSet);\n\n let Identity = Matrix.eye(kernelX.rows, kernelX.rows, 1);\n let temp = kernelX;\n kernelX = new Array(this.orthogonalComp + 1);\n for (let i = 0; i < this.orthogonalComp + 1; i++) {\n kernelX[i] = new Array(this.orthogonalComp + 1);\n }\n kernelX[0][0] = temp;\n\n let result = new SingularValueDecomposition(\n trainingValues\n .transpose()\n .mmul(kernelX[0][0])\n .mmul(trainingValues),\n {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false,\n },\n );\n let YLoadingMat = result.leftSingularVectors;\n let Sigma = result.diagonalMatrix;\n\n YLoadingMat = YLoadingMat.subMatrix(\n 0,\n YLoadingMat.rows - 1,\n 0,\n this.predictiveComp - 1,\n );\n Sigma = Sigma.subMatrix(\n 0,\n this.predictiveComp - 1,\n 0,\n this.predictiveComp - 1,\n );\n\n let YScoreMat = trainingValues.mmul(YLoadingMat);\n\n let predScoreMat = new Array(this.orthogonalComp + 1);\n let TURegressionCoeff = new Array(this.orthogonalComp + 1);\n let YOrthScoreMat = new Array(this.orthogonalComp);\n let YOrthLoadingVec = new Array(this.orthogonalComp);\n let YOrthEigen = new Array(this.orthogonalComp);\n let YOrthScoreNorm = new Array(this.orthogonalComp);\n\n let SigmaPow = Matrix.pow(Sigma, -0.5);\n // to avoid errors, check infinity\n SigmaPow.apply(function(i, j) {\n if (this.get(i, j) === Infinity) {\n this.set(i, j, 0);\n }\n });\n\n for (let i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = kernelX[0][i]\n .transpose()\n .mmul(YScoreMat)\n .mmul(SigmaPow);\n\n let TpiPrime = predScoreMat[i].transpose();\n TURegressionCoeff[i] = inverse(TpiPrime.mmul(predScoreMat[i]))\n .mmul(TpiPrime)\n .mmul(YScoreMat);\n\n result = new SingularValueDecomposition(\n TpiPrime.mmul(\n Matrix.sub(kernelX[i][i], predScoreMat[i].mmul(TpiPrime)),\n ).mmul(predScoreMat[i]),\n {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false,\n },\n );\n let CoTemp = result.leftSingularVectors;\n let SoTemp = result.diagonalMatrix;\n\n YOrthLoadingVec[i] = CoTemp.subMatrix(0, CoTemp.rows - 1, 0, 0);\n YOrthEigen[i] = SoTemp.get(0, 0);\n\n YOrthScoreMat[i] = Matrix.sub(\n kernelX[i][i],\n predScoreMat[i].mmul(TpiPrime),\n )\n .mmul(predScoreMat[i])\n .mmul(YOrthLoadingVec[i])\n .mul(Math.pow(YOrthEigen[i], -0.5));\n\n let toiPrime = YOrthScoreMat[i].transpose();\n YOrthScoreNorm[i] = Matrix.sqrt(toiPrime.mmul(YOrthScoreMat[i]));\n\n YOrthScoreMat[i] = YOrthScoreMat[i].divRowVector(YOrthScoreNorm[i]);\n\n let ITo = Matrix.sub(\n Identity,\n YOrthScoreMat[i].mmul(YOrthScoreMat[i].transpose()),\n );\n\n kernelX[0][i + 1] = kernelX[0][i].mmul(ITo);\n kernelX[i + 1][i + 1] = ITo.mmul(kernelX[i][i]).mmul(ITo);\n }\n\n let lastScoreMat = (predScoreMat[this.orthogonalComp] = kernelX[0][\n this.orthogonalComp\n ]\n .transpose()\n .mmul(YScoreMat)\n .mmul(SigmaPow));\n\n let lastTpPrime = lastScoreMat.transpose();\n TURegressionCoeff[this.orthogonalComp] = inverse(\n lastTpPrime.mmul(lastScoreMat),\n )\n .mmul(lastTpPrime)\n .mmul(YScoreMat);\n\n this.YLoadingMat = YLoadingMat;\n this.SigmaPow = SigmaPow;\n this.YScoreMat = YScoreMat;\n this.predScoreMat = predScoreMat;\n this.YOrthLoadingVec = YOrthLoadingVec;\n this.YOrthEigen = YOrthEigen;\n this.YOrthScoreMat = YOrthScoreMat;\n this.toNorm = YOrthScoreNorm;\n this.TURegressionCoeff = TURegressionCoeff;\n this.kernelX = kernelX;\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|Array} toPredict\n * @return {{y: Matrix, predScoreMat: Array, predYOrthVectors: Array}} predictions\n */\n predict(toPredict) {\n let KTestTrain = this.kernel.compute(toPredict, this.trainingSet);\n\n let temp = KTestTrain;\n KTestTrain = new Array(this.orthogonalComp + 1);\n for (let i = 0; i < this.orthogonalComp + 1; i++) {\n KTestTrain[i] = new Array(this.orthogonalComp + 1);\n }\n KTestTrain[0][0] = temp;\n\n let YOrthScoreVector = new Array(this.orthogonalComp);\n let predScoreMat = new Array(this.orthogonalComp);\n\n let i;\n for (i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = KTestTrain[i][0]\n .mmul(this.YScoreMat)\n .mmul(this.SigmaPow);\n\n YOrthScoreVector[i] = Matrix.sub(\n KTestTrain[i][i],\n predScoreMat[i].mmul(this.predScoreMat[i].transpose()),\n )\n .mmul(this.predScoreMat[i])\n .mmul(this.YOrthLoadingVec[i])\n .mul(Math.pow(this.YOrthEigen[i], -0.5));\n\n YOrthScoreVector[i] = YOrthScoreVector[i].divRowVector(this.toNorm[i]);\n\n let scoreMatPrime = this.YOrthScoreMat[i].transpose();\n KTestTrain[i + 1][0] = Matrix.sub(\n KTestTrain[i][0],\n YOrthScoreVector[i]\n .mmul(scoreMatPrime)\n .mmul(this.kernelX[0][i].transpose()),\n );\n\n let p1 = Matrix.sub(\n KTestTrain[i][0],\n KTestTrain[i][i].mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime),\n );\n let p2 = YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[i][i]);\n let p3 = p2.mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime);\n\n KTestTrain[i + 1][i + 1] = p1.sub(p2).add(p3);\n }\n\n predScoreMat[i] = KTestTrain[i][0].mmul(this.YScoreMat).mmul(this.SigmaPow);\n let prediction = predScoreMat[i]\n .mmul(this.TURegressionCoeff[i])\n .mmul(this.YLoadingMat.transpose());\n\n return {\n prediction: prediction,\n predScoreMat: predScoreMat,\n predYOrthVectors: YOrthScoreVector,\n };\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n name: 'K-OPLS',\n YLoadingMat: this.YLoadingMat,\n SigmaPow: this.SigmaPow,\n YScoreMat: this.YScoreMat,\n predScoreMat: this.predScoreMat,\n YOrthLoadingVec: this.YOrthLoadingVec,\n YOrthEigen: this.YOrthEigen,\n YOrthScoreMat: this.YOrthScoreMat,\n toNorm: this.toNorm,\n TURegressionCoeff: this.TURegressionCoeff,\n kernelX: this.kernelX,\n trainingSet: this.trainingSet,\n orthogonalComp: this.orthogonalComp,\n predictiveComp: this.predictiveComp,\n };\n }\n\n /**\n * Load a K-OPLS with the given model.\n * @param {object} model\n * @param {Kernel} kernel - kernel used on the model, see [ml-kernel](https://github.com/mljs/kernel).\n * @return {KOPLS}\n */\n static load(model, kernel) {\n if (model.name !== 'K-OPLS') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n if (!kernel) {\n throw new RangeError('You must provide a kernel for the model!');\n }\n\n model.kernel = kernel;\n return new KOPLS(true, model);\n }\n}\n","/**\n * Constructs a confusion matrix\n * @class ConfusionMatrix\n * @example\n * const CM = new ConfusionMatrix([[13, 2], [10, 5]], ['cat', 'dog'])\n * @param {Array>} matrix - The confusion matrix, a 2D Array. Rows represent the actual label and columns\n * the predicted label.\n * @param {Array} labels - Labels of the confusion matrix, a 1D Array\n */\nexport default class ConfusionMatrix {\n constructor(matrix, labels) {\n if (matrix.length !== matrix[0].length) {\n throw new Error('Confusion matrix must be square');\n }\n if (labels.length !== matrix.length) {\n throw new Error(\n 'Confusion matrix and labels should have the same length',\n );\n }\n this.labels = labels;\n this.matrix = matrix;\n }\n\n /**\n * Construct confusion matrix from the predicted and actual labels (classes). Be sure to provide the arguments in\n * the correct order!\n * @param {Array} actual - The predicted labels of the classification\n * @param {Array} predicted - The actual labels of the classification. Has to be of same length as\n * predicted.\n * @param {object} [options] - Additional options\n * @param {Array} [options.labels] - The list of labels that should be used. If not provided the distinct set\n * of labels present in predicted and actual is used. Labels are compared using the strict equality operator\n * '==='\n * @return {ConfusionMatrix} - Confusion matrix\n */\n static fromLabels(actual, predicted, options = {}) {\n if (predicted.length !== actual.length) {\n throw new Error('predicted and actual must have the same length');\n }\n let distinctLabels;\n if (options.labels) {\n distinctLabels = new Set(options.labels);\n } else {\n distinctLabels = new Set([...actual, ...predicted]);\n }\n distinctLabels = Array.from(distinctLabels);\n if (options.sort) {\n distinctLabels.sort(options.sort);\n }\n\n // Create confusion matrix and fill with 0's\n const matrix = Array.from({ length: distinctLabels.length });\n for (let i = 0; i < matrix.length; i++) {\n matrix[i] = new Array(matrix.length);\n matrix[i].fill(0);\n }\n\n for (let i = 0; i < predicted.length; i++) {\n const actualIdx = distinctLabels.indexOf(actual[i]);\n const predictedIdx = distinctLabels.indexOf(predicted[i]);\n if (actualIdx >= 0 && predictedIdx >= 0) {\n matrix[actualIdx][predictedIdx]++;\n }\n }\n\n return new ConfusionMatrix(matrix, distinctLabels);\n }\n\n /**\n * Get the confusion matrix\n * @return {Array >}\n */\n getMatrix() {\n return this.matrix;\n }\n\n getLabels() {\n return this.labels;\n }\n\n /**\n * Get the total number of samples\n * @return {number}\n */\n getTotalCount() {\n let predicted = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n predicted += this.matrix[i][j];\n }\n }\n return predicted;\n }\n\n /**\n * Get the total number of true predictions\n * @return {number}\n */\n getTrueCount() {\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n count += this.matrix[i][i];\n }\n return count;\n }\n\n /**\n * Get the total number of false predictions.\n * @return {number}\n */\n getFalseCount() {\n return this.getTotalCount() - this.getTrueCount();\n }\n\n /**\n * Get the number of true positive predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTruePositiveCount(label) {\n const index = this.getIndex(label);\n return this.matrix[index][index];\n }\n\n /**\n * Get the number of true negative predictions\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTrueNegativeCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n if (i !== index && j !== index) {\n count += this.matrix[i][j];\n }\n }\n }\n return count;\n }\n\n /**\n * Get the number of false positive predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalsePositiveCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n if (i !== index) {\n count += this.matrix[i][index];\n }\n }\n return count;\n }\n\n /**\n * Get the number of false negative predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseNegativeCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n if (i !== index) {\n count += this.matrix[index][i];\n }\n }\n return count;\n }\n\n /**\n * Get the number of real positive samples.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getPositiveCount(label) {\n return this.getTruePositiveCount(label) + this.getFalseNegativeCount(label);\n }\n\n /**\n * Get the number of real negative samples.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getNegativeCount(label) {\n return this.getTrueNegativeCount(label) + this.getFalsePositiveCount(label);\n }\n\n /**\n * Get the index in the confusion matrix that corresponds to the given label\n * @param {any} label - The label to search for\n * @throws if the label is not found\n * @return {number}\n */\n getIndex(label) {\n const index = this.labels.indexOf(label);\n if (index === -1) throw new Error('The label does not exist');\n return index;\n }\n\n /**\n * Get the true positive rate a.k.a. sensitivity. Computes the ratio between the number of true positive predictions and the total number of positive samples.\n * {@link https://en.wikipedia.org/wiki/Sensitivity_and_specificity}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number} - The true positive rate [0-1]\n */\n getTruePositiveRate(label) {\n return this.getTruePositiveCount(label) / this.getPositiveCount(label);\n }\n\n /**\n * Get the true negative rate a.k.a. specificity. Computes the ration between the number of true negative predictions and the total number of negative samples.\n * {@link https://en.wikipedia.org/wiki/Sensitivity_and_specificity}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTrueNegativeRate(label) {\n return this.getTrueNegativeCount(label) / this.getNegativeCount(label);\n }\n\n /**\n * Get the positive predictive value a.k.a. precision. Computes TP / (TP + FP)\n * {@link https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getPositivePredictiveValue(label) {\n const TP = this.getTruePositiveCount(label);\n return TP / (TP + this.getFalsePositiveCount(label));\n }\n\n /**\n * Negative predictive value\n * {@link https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getNegativePredictiveValue(label) {\n const TN = this.getTrueNegativeCount(label);\n return TN / (TN + this.getFalseNegativeCount(label));\n }\n\n /**\n * False negative rate a.k.a. miss rate.\n * {@link https://en.wikipedia.org/wiki/Type_I_and_type_II_errors#False_positive_and_false_negative_rates}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseNegativeRate(label) {\n return 1 - this.getTruePositiveRate(label);\n }\n\n /**\n * False positive rate a.k.a. fall-out rate.\n * {@link https://en.wikipedia.org/wiki/Type_I_and_type_II_errors#False_positive_and_false_negative_rates}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalsePositiveRate(label) {\n return 1 - this.getTrueNegativeRate(label);\n }\n\n /**\n * False discovery rate (FDR)\n * {@link https://en.wikipedia.org/wiki/False_discovery_rate}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseDiscoveryRate(label) {\n const FP = this.getFalsePositiveCount(label);\n return FP / (FP + this.getTruePositiveCount(label));\n }\n\n /**\n * False omission rate (FOR)\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseOmissionRate(label) {\n const FN = this.getFalseNegativeCount(label);\n return FN / (FN + this.getTruePositiveCount(label));\n }\n\n /**\n * F1 score\n * {@link https://en.wikipedia.org/wiki/F1_score}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getF1Score(label) {\n const TP = this.getTruePositiveCount(label);\n return (\n (2 * TP) /\n (2 * TP +\n this.getFalsePositiveCount(label) +\n this.getFalseNegativeCount(label))\n );\n }\n\n /**\n * Matthews correlation coefficient (MCC)\n * {@link https://en.wikipedia.org/wiki/Matthews_correlation_coefficient}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getMatthewsCorrelationCoefficient(label) {\n const TP = this.getTruePositiveCount(label);\n const TN = this.getTrueNegativeCount(label);\n const FP = this.getFalsePositiveCount(label);\n const FN = this.getFalseNegativeCount(label);\n return (\n (TP * TN - FP * FN) /\n Math.sqrt((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN))\n );\n }\n\n /**\n * Informedness\n * {@link https://en.wikipedia.org/wiki/Youden%27s_J_statistic}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getInformedness(label) {\n return (\n this.getTruePositiveRate(label) + this.getTrueNegativeRate(label) - 1\n );\n }\n\n /**\n * Markedness\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getMarkedness(label) {\n return (\n this.getPositivePredictiveValue(label) +\n this.getNegativePredictiveValue(label) -\n 1\n );\n }\n\n /**\n * Get the confusion table.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {Array >} - The 2x2 confusion table. [[TP, FN], [FP, TN]]\n */\n getConfusionTable(label) {\n return [\n [this.getTruePositiveCount(label), this.getFalseNegativeCount(label)],\n [this.getFalsePositiveCount(label), this.getTrueNegativeCount(label)],\n ];\n }\n\n /**\n * Get total accuracy.\n * @return {number} - The ratio between the number of true predictions and total number of classifications ([0-1])\n */\n getAccuracy() {\n let correct = 0;\n let incorrect = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n if (i === j) correct += this.matrix[i][j];\n else incorrect += this.matrix[i][j];\n }\n }\n return correct / (correct + incorrect);\n }\n\n /**\n * Returns the element in the confusion matrix that corresponds to the given actual and predicted labels.\n * @param {any} actual - The true label\n * @param {any} predicted - The predicted label\n * @return {number} - The element in the confusion matrix\n */\n getCount(actual, predicted) {\n const actualIndex = this.getIndex(actual);\n const predictedIndex = this.getIndex(predicted);\n return this.matrix[actualIndex][predictedIndex];\n }\n\n /**\n * Compute the general prediction accuracy\n * @deprecated Use getAccuracy\n * @return {number} - The prediction accuracy ([0-1]\n */\n get accuracy() {\n return this.getAccuracy();\n }\n\n /**\n * Compute the number of predicted observations\n * @deprecated Use getTotalCount\n * @return {number}\n */\n get total() {\n return this.getTotalCount();\n }\n}\n","(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(factory());\n}(this, (function () { 'use strict';\n\n\tfunction createCommonjsModule(fn, module) {\n\t\treturn module = { exports: {} }, fn(module, module.exports), module.exports;\n\t}\n\n\tvar runtime = createCommonjsModule(function (module) {\n\t/**\n\t * Copyright (c) 2014-present, Facebook, Inc.\n\t *\n\t * This source code is licensed under the MIT license found in the\n\t * LICENSE file in the root directory of this source tree.\n\t */\n\n\t!(function(global) {\n\n\t var Op = Object.prototype;\n\t var hasOwn = Op.hasOwnProperty;\n\t var undefined; // More compressible than void 0.\n\t var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n\t var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n\t var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n\t var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\t var runtime = global.regeneratorRuntime;\n\t if (runtime) {\n\t {\n\t // If regeneratorRuntime is defined globally and we're in a module,\n\t // make the exports object identical to regeneratorRuntime.\n\t module.exports = runtime;\n\t }\n\t // Don't bother evaluating the rest of this file if the runtime was\n\t // already defined globally.\n\t return;\n\t }\n\n\t // Define the runtime globally (as expected by generated code) as either\n\t // module.exports (if we're in a module) or a new, empty object.\n\t runtime = global.regeneratorRuntime = module.exports;\n\n\t function wrap(innerFn, outerFn, self, tryLocsList) {\n\t // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n\t var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n\t var generator = Object.create(protoGenerator.prototype);\n\t var context = new Context(tryLocsList || []);\n\n\t // The ._invoke method unifies the implementations of the .next,\n\t // .throw, and .return methods.\n\t generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n\t return generator;\n\t }\n\t runtime.wrap = wrap;\n\n\t // Try/catch helper to minimize deoptimizations. Returns a completion\n\t // record like context.tryEntries[i].completion. This interface could\n\t // have been (and was previously) designed to take a closure to be\n\t // invoked without arguments, but in all the cases we care about we\n\t // already have an existing method we want to call, so there's no need\n\t // to create a new function object. We can even get away with assuming\n\t // the method takes exactly one argument, since that happens to be true\n\t // in every case, so we don't have to touch the arguments object. The\n\t // only additional allocation required is the completion record, which\n\t // has a stable shape and so hopefully should be cheap to allocate.\n\t function tryCatch(fn, obj, arg) {\n\t try {\n\t return { type: \"normal\", arg: fn.call(obj, arg) };\n\t } catch (err) {\n\t return { type: \"throw\", arg: err };\n\t }\n\t }\n\n\t var GenStateSuspendedStart = \"suspendedStart\";\n\t var GenStateSuspendedYield = \"suspendedYield\";\n\t var GenStateExecuting = \"executing\";\n\t var GenStateCompleted = \"completed\";\n\n\t // Returning this object from the innerFn has the same effect as\n\t // breaking out of the dispatch switch statement.\n\t var ContinueSentinel = {};\n\n\t // Dummy constructor functions that we use as the .constructor and\n\t // .constructor.prototype properties for functions that return Generator\n\t // objects. For full spec compliance, you may wish to configure your\n\t // minifier not to mangle the names of these two functions.\n\t function Generator() {}\n\t function GeneratorFunction() {}\n\t function GeneratorFunctionPrototype() {}\n\n\t // This is a polyfill for %IteratorPrototype% for environments that\n\t // don't natively support it.\n\t var IteratorPrototype = {};\n\t IteratorPrototype[iteratorSymbol] = function () {\n\t return this;\n\t };\n\n\t var getProto = Object.getPrototypeOf;\n\t var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n\t if (NativeIteratorPrototype &&\n\t NativeIteratorPrototype !== Op &&\n\t hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n\t // This environment has a native %IteratorPrototype%; use it instead\n\t // of the polyfill.\n\t IteratorPrototype = NativeIteratorPrototype;\n\t }\n\n\t var Gp = GeneratorFunctionPrototype.prototype =\n\t Generator.prototype = Object.create(IteratorPrototype);\n\t GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n\t GeneratorFunctionPrototype.constructor = GeneratorFunction;\n\t GeneratorFunctionPrototype[toStringTagSymbol] =\n\t GeneratorFunction.displayName = \"GeneratorFunction\";\n\n\t // Helper for defining the .next, .throw, and .return methods of the\n\t // Iterator interface in terms of a single ._invoke method.\n\t function defineIteratorMethods(prototype) {\n\t [\"next\", \"throw\", \"return\"].forEach(function(method) {\n\t prototype[method] = function(arg) {\n\t return this._invoke(method, arg);\n\t };\n\t });\n\t }\n\n\t runtime.isGeneratorFunction = function(genFun) {\n\t var ctor = typeof genFun === \"function\" && genFun.constructor;\n\t return ctor\n\t ? ctor === GeneratorFunction ||\n\t // For the native GeneratorFunction constructor, the best we can\n\t // do is to check its .name property.\n\t (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n\t : false;\n\t };\n\n\t runtime.mark = function(genFun) {\n\t if (Object.setPrototypeOf) {\n\t Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n\t } else {\n\t genFun.__proto__ = GeneratorFunctionPrototype;\n\t if (!(toStringTagSymbol in genFun)) {\n\t genFun[toStringTagSymbol] = \"GeneratorFunction\";\n\t }\n\t }\n\t genFun.prototype = Object.create(Gp);\n\t return genFun;\n\t };\n\n\t // Within the body of any async function, `await x` is transformed to\n\t // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n\t // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n\t // meant to be awaited.\n\t runtime.awrap = function(arg) {\n\t return { __await: arg };\n\t };\n\n\t function AsyncIterator(generator) {\n\t function invoke(method, arg, resolve, reject) {\n\t var record = tryCatch(generator[method], generator, arg);\n\t if (record.type === \"throw\") {\n\t reject(record.arg);\n\t } else {\n\t var result = record.arg;\n\t var value = result.value;\n\t if (value &&\n\t typeof value === \"object\" &&\n\t hasOwn.call(value, \"__await\")) {\n\t return Promise.resolve(value.__await).then(function(value) {\n\t invoke(\"next\", value, resolve, reject);\n\t }, function(err) {\n\t invoke(\"throw\", err, resolve, reject);\n\t });\n\t }\n\n\t return Promise.resolve(value).then(function(unwrapped) {\n\t // When a yielded Promise is resolved, its final value becomes\n\t // the .value of the Promise<{value,done}> result for the\n\t // current iteration. If the Promise is rejected, however, the\n\t // result for this iteration will be rejected with the same\n\t // reason. Note that rejections of yielded Promises are not\n\t // thrown back into the generator function, as is the case\n\t // when an awaited Promise is rejected. This difference in\n\t // behavior between yield and await is important, because it\n\t // allows the consumer to decide what to do with the yielded\n\t // rejection (swallow it and continue, manually .throw it back\n\t // into the generator, abandon iteration, whatever). With\n\t // await, by contrast, there is no opportunity to examine the\n\t // rejection reason outside the generator function, so the\n\t // only option is to throw it from the await expression, and\n\t // let the generator function handle the exception.\n\t result.value = unwrapped;\n\t resolve(result);\n\t }, reject);\n\t }\n\t }\n\n\t var previousPromise;\n\n\t function enqueue(method, arg) {\n\t function callInvokeWithMethodAndArg() {\n\t return new Promise(function(resolve, reject) {\n\t invoke(method, arg, resolve, reject);\n\t });\n\t }\n\n\t return previousPromise =\n\t // If enqueue has been called before, then we want to wait until\n\t // all previous Promises have been resolved before calling invoke,\n\t // so that results are always delivered in the correct order. If\n\t // enqueue has not been called before, then it is important to\n\t // call invoke immediately, without waiting on a callback to fire,\n\t // so that the async generator function has the opportunity to do\n\t // any necessary setup in a predictable way. This predictability\n\t // is why the Promise constructor synchronously invokes its\n\t // executor callback, and why async functions synchronously\n\t // execute code before the first await. Since we implement simple\n\t // async functions in terms of async generators, it is especially\n\t // important to get this right, even though it requires care.\n\t previousPromise ? previousPromise.then(\n\t callInvokeWithMethodAndArg,\n\t // Avoid propagating failures to Promises returned by later\n\t // invocations of the iterator.\n\t callInvokeWithMethodAndArg\n\t ) : callInvokeWithMethodAndArg();\n\t }\n\n\t // Define the unified helper method that is used to implement .next,\n\t // .throw, and .return (see defineIteratorMethods).\n\t this._invoke = enqueue;\n\t }\n\n\t defineIteratorMethods(AsyncIterator.prototype);\n\t AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n\t return this;\n\t };\n\t runtime.AsyncIterator = AsyncIterator;\n\n\t // Note that simple async functions are implemented on top of\n\t // AsyncIterator objects; they just return a Promise for the value of\n\t // the final result produced by the iterator.\n\t runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n\t var iter = new AsyncIterator(\n\t wrap(innerFn, outerFn, self, tryLocsList)\n\t );\n\n\t return runtime.isGeneratorFunction(outerFn)\n\t ? iter // If outerFn is a generator, return the full iterator.\n\t : iter.next().then(function(result) {\n\t return result.done ? result.value : iter.next();\n\t });\n\t };\n\n\t function makeInvokeMethod(innerFn, self, context) {\n\t var state = GenStateSuspendedStart;\n\n\t return function invoke(method, arg) {\n\t if (state === GenStateExecuting) {\n\t throw new Error(\"Generator is already running\");\n\t }\n\n\t if (state === GenStateCompleted) {\n\t if (method === \"throw\") {\n\t throw arg;\n\t }\n\n\t // Be forgiving, per 25.3.3.3.3 of the spec:\n\t // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n\t return doneResult();\n\t }\n\n\t context.method = method;\n\t context.arg = arg;\n\n\t while (true) {\n\t var delegate = context.delegate;\n\t if (delegate) {\n\t var delegateResult = maybeInvokeDelegate(delegate, context);\n\t if (delegateResult) {\n\t if (delegateResult === ContinueSentinel) continue;\n\t return delegateResult;\n\t }\n\t }\n\n\t if (context.method === \"next\") {\n\t // Setting context._sent for legacy support of Babel's\n\t // function.sent implementation.\n\t context.sent = context._sent = context.arg;\n\n\t } else if (context.method === \"throw\") {\n\t if (state === GenStateSuspendedStart) {\n\t state = GenStateCompleted;\n\t throw context.arg;\n\t }\n\n\t context.dispatchException(context.arg);\n\n\t } else if (context.method === \"return\") {\n\t context.abrupt(\"return\", context.arg);\n\t }\n\n\t state = GenStateExecuting;\n\n\t var record = tryCatch(innerFn, self, context);\n\t if (record.type === \"normal\") {\n\t // If an exception is thrown from innerFn, we leave state ===\n\t // GenStateExecuting and loop back for another invocation.\n\t state = context.done\n\t ? GenStateCompleted\n\t : GenStateSuspendedYield;\n\n\t if (record.arg === ContinueSentinel) {\n\t continue;\n\t }\n\n\t return {\n\t value: record.arg,\n\t done: context.done\n\t };\n\n\t } else if (record.type === \"throw\") {\n\t state = GenStateCompleted;\n\t // Dispatch the exception by looping back around to the\n\t // context.dispatchException(context.arg) call above.\n\t context.method = \"throw\";\n\t context.arg = record.arg;\n\t }\n\t }\n\t };\n\t }\n\n\t // Call delegate.iterator[context.method](context.arg) and handle the\n\t // result, either by returning a { value, done } result from the\n\t // delegate iterator, or by modifying context.method and context.arg,\n\t // setting context.delegate to null, and returning the ContinueSentinel.\n\t function maybeInvokeDelegate(delegate, context) {\n\t var method = delegate.iterator[context.method];\n\t if (method === undefined) {\n\t // A .throw or .return when the delegate iterator has no .throw\n\t // method always terminates the yield* loop.\n\t context.delegate = null;\n\n\t if (context.method === \"throw\") {\n\t if (delegate.iterator.return) {\n\t // If the delegate iterator has a return method, give it a\n\t // chance to clean up.\n\t context.method = \"return\";\n\t context.arg = undefined;\n\t maybeInvokeDelegate(delegate, context);\n\n\t if (context.method === \"throw\") {\n\t // If maybeInvokeDelegate(context) changed context.method from\n\t // \"return\" to \"throw\", let that override the TypeError below.\n\t return ContinueSentinel;\n\t }\n\t }\n\n\t context.method = \"throw\";\n\t context.arg = new TypeError(\n\t \"The iterator does not provide a 'throw' method\");\n\t }\n\n\t return ContinueSentinel;\n\t }\n\n\t var record = tryCatch(method, delegate.iterator, context.arg);\n\n\t if (record.type === \"throw\") {\n\t context.method = \"throw\";\n\t context.arg = record.arg;\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t var info = record.arg;\n\n\t if (! info) {\n\t context.method = \"throw\";\n\t context.arg = new TypeError(\"iterator result is not an object\");\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t if (info.done) {\n\t // Assign the result of the finished delegate to the temporary\n\t // variable specified by delegate.resultName (see delegateYield).\n\t context[delegate.resultName] = info.value;\n\n\t // Resume execution at the desired location (see delegateYield).\n\t context.next = delegate.nextLoc;\n\n\t // If context.method was \"throw\" but the delegate handled the\n\t // exception, let the outer generator proceed normally. If\n\t // context.method was \"next\", forget context.arg since it has been\n\t // \"consumed\" by the delegate iterator. If context.method was\n\t // \"return\", allow the original .return call to continue in the\n\t // outer generator.\n\t if (context.method !== \"return\") {\n\t context.method = \"next\";\n\t context.arg = undefined;\n\t }\n\n\t } else {\n\t // Re-yield the result returned by the delegate method.\n\t return info;\n\t }\n\n\t // The delegate iterator is finished, so forget it and continue with\n\t // the outer generator.\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t // Define Generator.prototype.{next,throw,return} in terms of the\n\t // unified ._invoke helper method.\n\t defineIteratorMethods(Gp);\n\n\t Gp[toStringTagSymbol] = \"Generator\";\n\n\t // A Generator should always return itself as the iterator object when the\n\t // @@iterator function is called on it. Some browsers' implementations of the\n\t // iterator prototype chain incorrectly implement this, causing the Generator\n\t // object to not be returned from this call. This ensures that doesn't happen.\n\t // See https://github.com/facebook/regenerator/issues/274 for more details.\n\t Gp[iteratorSymbol] = function() {\n\t return this;\n\t };\n\n\t Gp.toString = function() {\n\t return \"[object Generator]\";\n\t };\n\n\t function pushTryEntry(locs) {\n\t var entry = { tryLoc: locs[0] };\n\n\t if (1 in locs) {\n\t entry.catchLoc = locs[1];\n\t }\n\n\t if (2 in locs) {\n\t entry.finallyLoc = locs[2];\n\t entry.afterLoc = locs[3];\n\t }\n\n\t this.tryEntries.push(entry);\n\t }\n\n\t function resetTryEntry(entry) {\n\t var record = entry.completion || {};\n\t record.type = \"normal\";\n\t delete record.arg;\n\t entry.completion = record;\n\t }\n\n\t function Context(tryLocsList) {\n\t // The root entry object (effectively a try statement without a catch\n\t // or a finally block) gives us a place to store values thrown from\n\t // locations where there is no enclosing try statement.\n\t this.tryEntries = [{ tryLoc: \"root\" }];\n\t tryLocsList.forEach(pushTryEntry, this);\n\t this.reset(true);\n\t }\n\n\t runtime.keys = function(object) {\n\t var keys = [];\n\t for (var key in object) {\n\t keys.push(key);\n\t }\n\t keys.reverse();\n\n\t // Rather than returning an object with a next method, we keep\n\t // things simple and return the next function itself.\n\t return function next() {\n\t while (keys.length) {\n\t var key = keys.pop();\n\t if (key in object) {\n\t next.value = key;\n\t next.done = false;\n\t return next;\n\t }\n\t }\n\n\t // To avoid creating an additional object, we just hang the .value\n\t // and .done properties off the next function object itself. This\n\t // also ensures that the minifier will not anonymize the function.\n\t next.done = true;\n\t return next;\n\t };\n\t };\n\n\t function values(iterable) {\n\t if (iterable) {\n\t var iteratorMethod = iterable[iteratorSymbol];\n\t if (iteratorMethod) {\n\t return iteratorMethod.call(iterable);\n\t }\n\n\t if (typeof iterable.next === \"function\") {\n\t return iterable;\n\t }\n\n\t if (!isNaN(iterable.length)) {\n\t var i = -1, next = function next() {\n\t while (++i < iterable.length) {\n\t if (hasOwn.call(iterable, i)) {\n\t next.value = iterable[i];\n\t next.done = false;\n\t return next;\n\t }\n\t }\n\n\t next.value = undefined;\n\t next.done = true;\n\n\t return next;\n\t };\n\n\t return next.next = next;\n\t }\n\t }\n\n\t // Return an iterator with no values.\n\t return { next: doneResult };\n\t }\n\t runtime.values = values;\n\n\t function doneResult() {\n\t return { value: undefined, done: true };\n\t }\n\n\t Context.prototype = {\n\t constructor: Context,\n\n\t reset: function(skipTempReset) {\n\t this.prev = 0;\n\t this.next = 0;\n\t // Resetting context._sent for legacy support of Babel's\n\t // function.sent implementation.\n\t this.sent = this._sent = undefined;\n\t this.done = false;\n\t this.delegate = null;\n\n\t this.method = \"next\";\n\t this.arg = undefined;\n\n\t this.tryEntries.forEach(resetTryEntry);\n\n\t if (!skipTempReset) {\n\t for (var name in this) {\n\t // Not sure about the optimal order of these conditions:\n\t if (name.charAt(0) === \"t\" &&\n\t hasOwn.call(this, name) &&\n\t !isNaN(+name.slice(1))) {\n\t this[name] = undefined;\n\t }\n\t }\n\t }\n\t },\n\n\t stop: function() {\n\t this.done = true;\n\n\t var rootEntry = this.tryEntries[0];\n\t var rootRecord = rootEntry.completion;\n\t if (rootRecord.type === \"throw\") {\n\t throw rootRecord.arg;\n\t }\n\n\t return this.rval;\n\t },\n\n\t dispatchException: function(exception) {\n\t if (this.done) {\n\t throw exception;\n\t }\n\n\t var context = this;\n\t function handle(loc, caught) {\n\t record.type = \"throw\";\n\t record.arg = exception;\n\t context.next = loc;\n\n\t if (caught) {\n\t // If the dispatched exception was caught by a catch block,\n\t // then let that catch block handle the exception normally.\n\t context.method = \"next\";\n\t context.arg = undefined;\n\t }\n\n\t return !! caught;\n\t }\n\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t var record = entry.completion;\n\n\t if (entry.tryLoc === \"root\") {\n\t // Exception thrown outside of any try block that could handle\n\t // it, so set the completion value of the entire function to\n\t // throw the exception.\n\t return handle(\"end\");\n\t }\n\n\t if (entry.tryLoc <= this.prev) {\n\t var hasCatch = hasOwn.call(entry, \"catchLoc\");\n\t var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n\t if (hasCatch && hasFinally) {\n\t if (this.prev < entry.catchLoc) {\n\t return handle(entry.catchLoc, true);\n\t } else if (this.prev < entry.finallyLoc) {\n\t return handle(entry.finallyLoc);\n\t }\n\n\t } else if (hasCatch) {\n\t if (this.prev < entry.catchLoc) {\n\t return handle(entry.catchLoc, true);\n\t }\n\n\t } else if (hasFinally) {\n\t if (this.prev < entry.finallyLoc) {\n\t return handle(entry.finallyLoc);\n\t }\n\n\t } else {\n\t throw new Error(\"try statement without catch or finally\");\n\t }\n\t }\n\t }\n\t },\n\n\t abrupt: function(type, arg) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.tryLoc <= this.prev &&\n\t hasOwn.call(entry, \"finallyLoc\") &&\n\t this.prev < entry.finallyLoc) {\n\t var finallyEntry = entry;\n\t break;\n\t }\n\t }\n\n\t if (finallyEntry &&\n\t (type === \"break\" ||\n\t type === \"continue\") &&\n\t finallyEntry.tryLoc <= arg &&\n\t arg <= finallyEntry.finallyLoc) {\n\t // Ignore the finally entry if control is not jumping to a\n\t // location outside the try/catch block.\n\t finallyEntry = null;\n\t }\n\n\t var record = finallyEntry ? finallyEntry.completion : {};\n\t record.type = type;\n\t record.arg = arg;\n\n\t if (finallyEntry) {\n\t this.method = \"next\";\n\t this.next = finallyEntry.finallyLoc;\n\t return ContinueSentinel;\n\t }\n\n\t return this.complete(record);\n\t },\n\n\t complete: function(record, afterLoc) {\n\t if (record.type === \"throw\") {\n\t throw record.arg;\n\t }\n\n\t if (record.type === \"break\" ||\n\t record.type === \"continue\") {\n\t this.next = record.arg;\n\t } else if (record.type === \"return\") {\n\t this.rval = this.arg = record.arg;\n\t this.method = \"return\";\n\t this.next = \"end\";\n\t } else if (record.type === \"normal\" && afterLoc) {\n\t this.next = afterLoc;\n\t }\n\n\t return ContinueSentinel;\n\t },\n\n\t finish: function(finallyLoc) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.finallyLoc === finallyLoc) {\n\t this.complete(entry.completion, entry.afterLoc);\n\t resetTryEntry(entry);\n\t return ContinueSentinel;\n\t }\n\t }\n\t },\n\n\t \"catch\": function(tryLoc) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.tryLoc === tryLoc) {\n\t var record = entry.completion;\n\t if (record.type === \"throw\") {\n\t var thrown = record.arg;\n\t resetTryEntry(entry);\n\t }\n\t return thrown;\n\t }\n\t }\n\n\t // The context.catch method must only be called with a location\n\t // argument that corresponds to a known catch block.\n\t throw new Error(\"illegal catch attempt\");\n\t },\n\n\t delegateYield: function(iterable, resultName, nextLoc) {\n\t this.delegate = {\n\t iterator: values(iterable),\n\t resultName: resultName,\n\t nextLoc: nextLoc\n\t };\n\n\t if (this.method === \"next\") {\n\t // Deliberately forget the last sent value so that we don't\n\t // accidentally pass it on to the delegate.\n\t this.arg = undefined;\n\t }\n\n\t return ContinueSentinel;\n\t }\n\t };\n\t})(\n\t // In sloppy mode, unbound `this` refers to the global object, fallback to\n\t // Function constructor if we're in global strict mode. That is sadly a form\n\t // of indirect eval which violates Content Security Policy.\n\t (function() { return this })() || Function(\"return this\")()\n\t);\n\t});\n\n\t/**\n\t * Copyright (c) 2014-present, Facebook, Inc.\n\t *\n\t * This source code is licensed under the MIT license found in the\n\t * LICENSE file in the root directory of this source tree.\n\t */\n\n\t// This method of obtaining a reference to the global object needs to be\n\t// kept identical to the way it is obtained in runtime.js\n\tvar g = (function() { return this })() || Function(\"return this\")();\n\n\t// Use `getOwnPropertyNames` because not all browsers support calling\n\t// `hasOwnProperty` on the global `self` object in a worker. See #183.\n\tvar hadRuntime = g.regeneratorRuntime &&\n\t Object.getOwnPropertyNames(g).indexOf(\"regeneratorRuntime\") >= 0;\n\n\t// Save the old regeneratorRuntime in case it needs to be restored later.\n\tvar oldRuntime = hadRuntime && g.regeneratorRuntime;\n\n\t// Force reevalutation of runtime.js.\n\tg.regeneratorRuntime = undefined;\n\n\tvar runtimeModule = runtime;\n\n\tif (hadRuntime) {\n\t // Restore the original runtime.\n\t g.regeneratorRuntime = oldRuntime;\n\t} else {\n\t // Remove the global property added by runtime.js.\n\t try {\n\t delete g.regeneratorRuntime;\n\t } catch(e) {\n\t g.regeneratorRuntime = undefined;\n\t }\n\t}\n\n\tvar regenerator = runtimeModule;\n\n\tvar defaultOptions = {\n\t mode: 'index'\n\t};\n\n\tmodule.exports = /*#__PURE__*/regenerator.mark(function _callee(M, N, options) {\n\t var a, c, b, p, x, y, z, i, twiddle;\n\t return regenerator.wrap(function _callee$(_context) {\n\t while (1) {\n\t switch (_context.prev = _context.next) {\n\t case 0:\n\t twiddle = function twiddle() {\n\t var i, j, k;\n\t j = 1;\n\t while (p[j] <= 0) {\n\t j++;\n\t }\n\t if (p[j - 1] === 0) {\n\t for (i = j - 1; i !== 1; i--) {\n\t p[i] = -1;\n\t }\n\t p[j] = 0;\n\t x = z = 0;\n\t p[1] = 1;\n\t y = j - 1;\n\t } else {\n\t if (j > 1) {\n\t p[j - 1] = 0;\n\t }\n\t do {\n\t j++;\n\t } while (p[j] > 0);\n\t k = j - 1;\n\t i = j;\n\t while (p[i] === 0) {\n\t p[i++] = -1;\n\t }\n\t if (p[i] === -1) {\n\t p[i] = p[k];\n\t z = p[k] - 1;\n\t x = i - 1;\n\t y = k - 1;\n\t p[k] = -1;\n\t } else {\n\t if (i === p[0]) {\n\t return 0;\n\t } else {\n\t p[j] = p[i];\n\t z = p[i] - 1;\n\t p[i] = 0;\n\t x = j - 1;\n\t y = i - 1;\n\t }\n\t }\n\t }\n\t return 1;\n\t };\n\n\t options = Object.assign({}, defaultOptions, options);\n\t a = new Array(N);\n\t c = new Array(M);\n\t b = new Array(N);\n\t p = new Array(N + 2);\n\n\n\t // init a and b\n\t for (i = 0; i < N; i++) {\n\t a[i] = i;\n\t if (i < N - M) b[i] = 0;else b[i] = 1;\n\t }\n\n\t // init c\n\t for (i = 0; i < M; i++) {\n\t c[i] = N - M + i;\n\t }\n\n\t // init p\n\t for (i = 0; i < p.length; i++) {\n\t if (i === 0) p[i] = N + 1;else if (i <= N - M) p[i] = 0;else if (i <= N) p[i] = i - N + M;else p[i] = -2;\n\t }\n\n\t if (!(options.mode === 'index')) {\n\t _context.next = 20;\n\t break;\n\t }\n\n\t _context.next = 12;\n\t return c.slice();\n\n\t case 12:\n\t if (!twiddle()) {\n\t _context.next = 18;\n\t break;\n\t }\n\n\t c[z] = a[x];\n\t _context.next = 16;\n\t return c.slice();\n\n\t case 16:\n\t _context.next = 12;\n\t break;\n\n\t case 18:\n\t _context.next = 33;\n\t break;\n\n\t case 20:\n\t if (!(options.mode === 'mask')) {\n\t _context.next = 32;\n\t break;\n\t }\n\n\t _context.next = 23;\n\t return b.slice();\n\n\t case 23:\n\t if (!twiddle()) {\n\t _context.next = 30;\n\t break;\n\t }\n\n\t b[x] = 1;\n\t b[y] = 0;\n\t _context.next = 28;\n\t return b.slice();\n\n\t case 28:\n\t _context.next = 23;\n\t break;\n\n\t case 30:\n\t _context.next = 33;\n\t break;\n\n\t case 32:\n\t throw new Error('Invalid mode');\n\n\t case 33:\n\t case 'end':\n\t return _context.stop();\n\t }\n\t }\n\t }, _callee, this);\n\t});\n\n})));\n","/**\n * get folds indexes\n * @param {Array} features\n * @param {Number} k - number of folds, a\n */\nexport function getFolds(features, k = 5) {\n let N = features.length;\n let allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n\n let l = Math.floor(N / k);\n // create random k-folds\n let current = [];\n let folds = [];\n while (allIdx.length) {\n let randi = Math.floor(Math.random() * allIdx.length);\n current.push(allIdx[randi]);\n allIdx.splice(randi, 1);\n if (current.length === l) {\n folds.push(current);\n current = [];\n }\n }\n // we push the remaining to the last fold so that the total length is\n // preserved. Otherwise the Q2 will fail.\n if (current.length) current.forEach((e) => folds[k - 1].push(e));\n folds = folds.slice(0, k);\n\n let foldsIndex = folds.map((x, idx) => ({\n testIndex: x,\n trainIndex: [].concat(...folds.filter((el, idx2) => idx2 !== idx)),\n }));\n return foldsIndex;\n}\n","/**\n * A function to sample a dataset maintaining classes equilibrated\n * @param {Array} classVector - an array containing class or group information\n * @param {Number} fraction - a fraction of the class to sample\n * @return {Object} - an object with indexes\n */\n\nexport function sampleAClass(classVector, fraction) {\n // sort the vector\n let classVectorSorted = JSON.parse(JSON.stringify(classVector));\n let result = Array.from(Array(classVectorSorted.length).keys()).sort((a, b) =>\n classVectorSorted[a] < classVectorSorted[b]\n ? -1\n : (classVectorSorted[b] < classVectorSorted[a]) | 0,\n );\n classVectorSorted.sort((a, b) => (a < b ? -1 : (b < a) | 0));\n\n // counts the class elements\n let counts = {};\n classVectorSorted.forEach((x) => (counts[x] = (counts[x] || 0) + 1));\n\n // pick a few per class\n let indexOfSelected = [];\n\n Object.keys(counts).forEach((e, i) => {\n let shift = [];\n Object.values(counts).reduce((a, c, item) => (shift[item] = a + c), 0);\n\n let arr = [...Array(counts[e]).keys()];\n\n let r = [];\n for (let j = 0; j < Math.floor(counts[e] * fraction); j++) {\n let n = arr[Math.floor(Math.random() * arr.length)];\n r.push(n);\n let ind = arr.indexOf(n);\n arr.splice(ind, 1);\n }\n\n if (i === 0) {\n indexOfSelected = indexOfSelected.concat(r);\n } else {\n indexOfSelected = indexOfSelected.concat(r.map((x) => x + shift[i - 1]));\n }\n });\n\n // sort back the index\n let trainIndex = [];\n indexOfSelected.forEach((e) => trainIndex.push(result[e]));\n\n let testIndex = [];\n let mask = [];\n classVector.forEach((el, idx) => {\n if (trainIndex.includes(idx)) {\n mask.push(true);\n } else {\n mask.push(false);\n testIndex.push(idx);\n }\n });\n return { trainIndex, testIndex, mask };\n}\n","import ConfusionMatrix from 'ml-confusion-matrix';\nimport combinations from 'ml-combinations';\n\nimport { getFolds } from './getFolds.js';\n\nexport { sampleAClass } from './sampleAClass.js';\nexport { getFolds } from './getFolds.js';\n\n/**\n * Performs a leave-one-out cross-validation (LOO-CV) of the given samples. In LOO-CV, 1 observation is used as the\n * validation set while the rest is used as the training set. This is repeated once for each observation. LOO-CV is a\n * special case of LPO-CV. @see leavePout\n * @param {function} Classifier - The classifier's constructor to use for the cross validation. Expect ml-classifier\n * api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\n\nexport function leaveOneOut(Classifier, features, labels, classifierOptions) {\n if (typeof labels === 'function') {\n let callback = labels;\n labels = features;\n features = Classifier;\n return leavePOut(features, labels, 1, callback);\n }\n return leavePOut(Classifier, features, labels, classifierOptions, 1);\n}\n\n/**\n * Performs a leave-p-out cross-validation (LPO-CV) of the given samples. In LPO-CV, p observations are used as the\n * validation set while the rest is used as the training set. This is repeated as many times as there are possible\n * ways to combine p observations from the set (unordered without replacement). Be aware that for relatively small\n * data-set size this can require a very large number of training and testing to do!\n * @param {function} Classifier - The classifier's constructor to use for the cross validation. Expect ml-classifier\n * api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @param {number} p - The size of the validation sub-samples' set\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\nexport function leavePOut(Classifier, features, labels, classifierOptions, p) {\n let callback;\n if (typeof classifierOptions === 'function') {\n callback = classifierOptions;\n p = labels;\n labels = features;\n features = Classifier;\n }\n check(features, labels);\n const distinct = getDistinct(labels);\n const confusionMatrix = initMatrix(distinct.length, distinct.length);\n\n let N = features.length;\n let gen = combinations(p, N);\n let allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n for (const testIdx of gen) {\n let trainIdx = allIdx.slice();\n\n for (let i = testIdx.length - 1; i >= 0; i--) {\n trainIdx.splice(testIdx[i], 1);\n }\n\n if (callback) {\n validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n );\n } else {\n validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n );\n }\n }\n\n return new ConfusionMatrix(confusionMatrix, distinct);\n}\n\n/**\n * Performs k-fold cross-validation (KF-CV). KF-CV separates the data-set into k random equally sized partitions, and\n * uses each as a validation set, with all other partitions used in the training set. Observations left over from if k\n * does not divide the number of observations are left out of the cross-validation process.\n * @param {function} Classifier - The classifier's to use for the cross validation. Expect ml-classifier api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @param {number} k - The number of partitions to create\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\nexport function kFold(Classifier, features, labels, classifierOptions, k) {\n let callback;\n if (typeof classifierOptions === 'function') {\n callback = classifierOptions;\n k = labels;\n labels = features;\n features = Classifier;\n }\n check(features, labels);\n const distinct = getDistinct(labels);\n const confusionMatrix = initMatrix(distinct.length, distinct.length);\n\n let folds = getFolds(features, k);\n\n for (let i = 0; i < folds.length; i++) {\n let testIdx = folds[i].testIndex;\n let trainIdx = folds[i].trainIndex;\n\n if (callback) {\n validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n );\n } else {\n validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n );\n }\n }\n\n return new ConfusionMatrix(confusionMatrix, distinct);\n}\n\nfunction check(features, labels) {\n if (features.length !== labels.length) {\n throw new Error('features and labels should have the same length');\n }\n}\n\nfunction initMatrix(rows, columns) {\n return new Array(rows).fill(0).map(() => new Array(columns).fill(0));\n}\n\nfunction getDistinct(arr) {\n let s = new Set();\n for (let i = 0; i < arr.length; i++) {\n s.add(arr[i]);\n }\n return Array.from(s);\n}\n\nfunction validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n) {\n const { testFeatures, trainFeatures, testLabels, trainLabels } = getTrainTest(\n features,\n labels,\n testIdx,\n trainIdx,\n );\n\n let classifier;\n if (Classifier.prototype.train) {\n classifier = new Classifier(classifierOptions);\n classifier.train(trainFeatures, trainLabels);\n } else {\n classifier = new Classifier(trainFeatures, trainLabels, classifierOptions);\n }\n\n let predictedLabels = classifier.predict(testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n) {\n const { testFeatures, trainFeatures, testLabels, trainLabels } = getTrainTest(\n features,\n labels,\n testIdx,\n trainIdx,\n );\n const predictedLabels = callback(trainFeatures, trainLabels, testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction updateConfusionMatrix(\n confusionMatrix,\n testLabels,\n predictedLabels,\n distinct,\n) {\n for (let i = 0; i < predictedLabels.length; i++) {\n const actualIdx = distinct.indexOf(testLabels[i]);\n const predictedIdx = distinct.indexOf(predictedLabels[i]);\n if (actualIdx < 0 || predictedIdx < 0) {\n // eslint-disable-next-line no-console\n console.warn(`ignore unknown predicted label ${predictedLabels[i]}`);\n }\n confusionMatrix[actualIdx][predictedIdx]++;\n }\n}\n\nexport function getTrainTest(features, labels, testIdx, trainIdx) {\n return {\n testFeatures: testIdx.map(function(index) {\n return features[index];\n }),\n trainFeatures: trainIdx.map(function(index) {\n return features[index];\n }),\n testLabels: testIdx.map(function(index) {\n return labels[index];\n }),\n trainLabels: trainIdx.map(function(index) {\n return labels[index];\n }),\n };\n}\n","import Matrix from 'ml-matrix';\n\nimport { norm } from './util/utils.js';\n\n/**\n * OPLS loop\n * @param {Array} x a matrix with features\n * @param {Array} y an array of labels (dependent variable)\n * @param {Object} options an object with options\n * @return {Object} an object with model (filteredX: err,\n loadingsXOrtho: pOrtho,\n scoresXOrtho: tOrtho,\n weightsXOrtho: wOrtho,\n weightsPred: w,\n loadingsXpred: p,\n scoresXpred: t,\n loadingsY:)\n */\nexport function OPLSNipals(x, y, options = {}) {\n const { numberOSC = 100 } = options;\n\n let X = Matrix.checkMatrix(x);\n let Y = Matrix.checkMatrix(y);\n\n let u = Y.getColumnVector(0);\n\n let diff = 1;\n let t, c, w, uNew;\n for (let i = 0; i < numberOSC && diff > 1e-10; i++) {\n w = u\n .transpose()\n .mmul(X)\n .div(\n u\n .transpose()\n .mmul(u)\n .get(0, 0),\n );\n w = w.transpose().div(norm(w));\n\n t = X.mmul(w).div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n ); // t_h paso 3\n\n // calc loading\n c = t\n .transpose()\n .mmul(Y)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n\n // calc new u and compare with one in previus iteration (stop criterion)\n uNew = Y.mmul(c.transpose());\n uNew = uNew.div(\n c\n .transpose()\n .mmul(c)\n .get(0, 0),\n );\n\n if (i > 0) {\n diff =\n uNew\n .clone()\n .sub(u)\n .pow(2)\n .sum() /\n uNew\n .clone()\n .pow(2)\n .sum();\n }\n\n u = uNew.clone();\n }\n\n // calc loadings\n let p = t\n .transpose()\n .mmul(X)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n\n let wOrtho = p.clone().sub(\n w\n .transpose()\n .mmul(p.transpose())\n .div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n )\n .mmul(w.transpose()),\n );\n wOrtho.div(norm(wOrtho));\n\n // orthogonal scores\n let tOrtho = X.mmul(wOrtho.transpose()).div(\n wOrtho.mmul(wOrtho.transpose()).get(0, 0),\n );\n\n // orthogonal loadings\n let pOrtho = tOrtho\n .transpose()\n .mmul(X)\n .div(\n tOrtho\n .transpose()\n .mmul(tOrtho)\n .get(0, 0),\n );\n\n // filtered data\n let err = X.clone().sub(tOrtho.mmul(pOrtho));\n return {\n filteredX: err,\n weightsXOrtho: wOrtho,\n loadingsXOrtho: pOrtho,\n scoresXOrtho: tOrtho,\n weightsXPred: w,\n loadingsXpred: p,\n scoresXpred: t,\n loadingsY: c,\n };\n}\n","import { Matrix } from 'ml-matrix';\n\n/**\n * Get total sum of square\n * @param {Array} x an array\n * @return {Number} - the sum of the squares\n */\nexport function tss(x) {\n return Matrix.mul(x, x).sum();\n}\n","import { Matrix, NIPALS } from 'ml-matrix';\nimport ConfusionMatrix from 'ml-confusion-matrix';\nimport { getFolds } from 'ml-cross-validation';\n\nimport { OPLSNipals } from './OPLSNipals.js';\nimport { tss } from './util/tss.js';\n\n/**\n * Creates new OPLS (orthogonal partial latent structures) from features and labels.\n * @param {Matrix} data - matrix containing data (X).\n * @param {Array} labels - 1D Array containing metadata (Y).\n * @param {Object} [options]\n * @param {number} [options.nComp = 3] - number of latent structures computed.\n * @param {boolean} [options.center = true] - should the data be centered (subtract the mean).\n * @param {boolean} [options.scale = false] - should the data be scaled (divide by the standard deviation).\n * @param {Array} [options.cvFolds = []] - allows to provide folds as 2D array for testing purpose.\n * */\n\nexport class OPLS {\n constructor(data, labels, options = {}) {\n if (data === true) {\n const opls = options;\n this.center = opls.center;\n this.scale = opls.scale;\n this.means = opls.means;\n this.meansY = opls.meansY;\n this.stdevs = opls.stdevs;\n this.stdevs = opls.stdevsY;\n this.model = opls.model;\n this.tCV = opls.tCV;\n this.tOrthCV = opls.tOrthCV;\n this.yHatCV = opls.yHatCV;\n this.mode = opls.mode;\n return;\n }\n\n let features = data.clone();\n // set default values\n // cvFolds allows to define folds for testing purpose\n const { nComp = 3, center = true, scale = true, cvFolds = [] } = options;\n\n let group;\n if (typeof labels[0] === 'number') {\n // numeric labels: OPLS regression is used\n this.mode = 'regression';\n group = Matrix.from1DArray(labels.length, 1, labels);\n } else if (typeof labels[0] === 'string') {\n // non-numeric labels: OPLS-DA is used\n this.mode = 'discriminantAnalysis';\n group = labels;\n throw new Error('discriminant analysis is not yet supported');\n }\n\n // check types of features and labels\n if (features.constructor.name !== 'Matrix') {\n throw new TypeError('features must be of class Matrix');\n }\n // getting center and scale the features (all)\n this.center = center;\n if (this.center) {\n this.means = features.mean('column');\n this.meansY = group.mean('column');\n } else {\n this.stdevs = null;\n }\n this.scale = scale;\n if (this.scale) {\n this.stdevs = features.standardDeviation('column');\n this.stdevsY = group.standardDeviation('column');\n } else {\n this.means = null;\n }\n\n // check and remove for features with sd = 0 TODO here\n // check opls.R line 70\n\n let folds;\n if (cvFolds.length > 0) {\n folds = cvFolds;\n } else {\n folds = getFolds(labels, 5);\n }\n\n let Q2 = [];\n this.model = [];\n\n this.tCV = [];\n this.tOrthCV = [];\n this.yHatCV = [];\n let oplsCV = [];\n\n let modelNC = [];\n\n // this code could be made more efficient by reverting the order of the loops\n // this is a legacy loop to be consistent with R code from MetaboMate package\n // this allows for having statistic (R2) from CV to decide wether to continue\n // with more latent structures\n let nc;\n for (nc = 0; nc < nComp; nc++) {\n let yHatk = new Matrix(group.rows, 1);\n let tPredk = new Matrix(group.rows, 1);\n let tOrthk = new Matrix(group.rows, 1);\n let oplsk = [];\n\n let f = 0;\n for (let fold of folds) {\n let trainTest = this._getTrainTest(features, group, fold);\n let testXk = trainTest.testFeatures;\n let Xk = trainTest.trainFeatures;\n let Yk = trainTest.trainLabels;\n\n // determine center and scale of training set\n let dataCenter = Xk.mean('column');\n let dataSD = Xk.standardDeviation('column');\n\n // center and scale training set\n if (center) {\n Xk.center('column');\n Yk.center('column');\n }\n\n if (scale) {\n Xk.scale('column');\n Yk.scale('column');\n }\n\n // perform opls\n if (nc === 0) {\n oplsk[f] = OPLSNipals(Xk, Yk);\n } else {\n oplsk[f] = OPLSNipals(oplsCV[nc - 1][f].filteredX, Yk);\n }\n // store model for next component\n oplsCV[nc] = oplsk;\n\n let plsCV = new NIPALS(oplsk[f].filteredX, { Y: Yk });\n\n // scaling the test dataset with respect to the train\n testXk.center('column', { center: dataCenter });\n testXk.scale('column', { scale: dataSD });\n\n let Eh = testXk;\n // removing the orthogonal components from PLS\n let scores;\n for (let idx = 0; idx < nc + 1; idx++) {\n scores = Eh.mmul(oplsCV[idx][f].weightsXOrtho.transpose()); // ok\n Eh.sub(scores.mmul(oplsCV[idx][f].loadingsXOrtho));\n }\n\n // prediction\n let tPred = Eh.mmul(plsCV.w.transpose());\n // this should be summed over ncomp (pls_prediction.R line 23)\n let yHat = tPred.mmul(plsCV.betas); // ok\n\n // adding all prediction from all folds\n for (let i = 0; i < fold.testIndex.length; i++) {\n yHatk.setRow(fold.testIndex[i], [yHat.get(i, 0)]);\n tPredk.setRow(fold.testIndex[i], [tPred.get(i, 0)]);\n tOrthk.setRow(fold.testIndex[i], [scores.get(i, 0)]);\n }\n f++;\n } // end of loop over folds\n\n this.tCV.push(tPredk);\n this.tOrthCV.push(tOrthk);\n this.yHatCV.push(yHatk);\n\n // calculate Q2y for all the prediction (all folds)\n // ROC for DA is not implemented (check opls.R line 183) TODO\n if (this.mode === 'regression') {\n let tssy = tss(group.center('column').scale('column'));\n let press = tss(group.clone().sub(yHatk));\n let Q2y = 1 - press / tssy;\n Q2.push(Q2y);\n } else if (this.mode === 'discriminantAnalysis') {\n throw new Error('discriminant analysis is not yet supported');\n }\n\n // calculate the R2y for the complete data\n if (nc === 0) {\n modelNC = this._predictAll(features, group);\n } else {\n modelNC = this._predictAll(\n modelNC.xRes,\n group,\n (options = { scale: false, center: false }),\n );\n }\n\n // adding the predictive statistics from CV\n modelNC.Q2y = Q2;\n // store the model for each component\n this.model.push(modelNC);\n // console.warn(`OPLS iteration over # of Components: ${nc + 1}`);\n } // end of loop over nc\n\n // store scores from CV\n let tCV = this.tCV;\n let tOrthCV = this.tOrthCV;\n\n let m = this.model[nc - 1];\n let XOrth = m.XOrth;\n let FeaturesCS = features.center('column').scale('column');\n let labelsCS = group.center('column').scale('column');\n let Xres = FeaturesCS.clone().sub(XOrth);\n let plsCall = new NIPALS(Xres, { Y: labelsCS });\n let E = Xres.clone().sub(plsCall.t.mmul(plsCall.p));\n\n let R2x = this.model.map((x) => x.R2x);\n let R2y = this.model.map((x) => x.R2y);\n\n this.output = {\n Q2y: Q2,\n R2x,\n R2y,\n tPred: m.plsC.t,\n pPred: m.plsC.p,\n wPred: m.plsC.w,\n betasPred: m.plsC.betas,\n Qpc: m.plsC.q,\n tCV,\n tOrthCV,\n tOrth: m.tOrth,\n pOrth: m.pOrth,\n wOrth: m.wOrth,\n XOrth,\n yHat: m.totalPred,\n Yres: m.plsC.yResidual,\n E,\n };\n }\n\n /**\n * get access to all the computed elements\n * Mainly for debug and testing\n * @return {Object} output object\n */\n getLogs() {\n return this.output;\n }\n\n getScores() {\n let scoresX = this.tCV.map((x) => x.to1DArray());\n let scoresY = this.tOrthCV.map((x) => x.to1DArray());\n return { scoresX, scoresY };\n }\n\n /**\n * Load an OPLS model from JSON\n * @param {Object} model\n * @return {OPLS}\n */\n static load(model) {\n if (typeof model.name !== 'string') {\n throw new TypeError('model must have a name property');\n }\n if (model.name !== 'OPLS') {\n throw new RangeError(`invalid model: ${model.name}`);\n }\n return new OPLS(true, [], model);\n }\n\n /**\n * Export the current model to a JSON object\n * @return {Object} model\n */\n toJSON() {\n return {\n name: 'OPLS',\n center: this.center,\n scale: this.scale,\n means: this.means,\n stdevs: this.stdevs,\n model: this.model,\n tCV: this.tCV,\n tOrthCV: this.tOrthCV,\n yHatCV: this.yHatCV,\n };\n }\n\n /**\n * Predict scores for new data\n * @param {Matrix} features - a matrix containing new data\n * @param {Object} [options]\n * @param {Array} [options.trueLabel] - an array with true values to compute confusion matrix\n * @param {Number} [options.nc] - the number of components to be used\n * @return {Object} - predictions\n */\n predict(newData, options = {}) {\n let { trueLabels = [], nc = 1 } = options;\n let labels = [];\n if (trueLabels.length > 0) {\n trueLabels = Matrix.from1DArray(trueLabels.length, 1, trueLabels);\n labels = trueLabels.clone();\n }\n\n let features = newData.clone();\n\n // scaling the test dataset with respect to the train\n if (this.center) {\n features.center('column', { center: this.means });\n if (labels.rows > 0 && this.mode === 'regression') {\n labels.center('column', { center: this.meansY });\n }\n }\n if (this.scale) {\n features.scale('column', { scale: this.stdevs });\n if (labels.rows > 0 && this.mode === 'regression') {\n labels.scale('column', { scale: this.stdevsY });\n }\n }\n\n let Eh = features.clone();\n // removing the orthogonal components from PLS\n let tOrth;\n let wOrth;\n let pOrth;\n let yHat;\n let tPred;\n\n for (let idx = 0; idx < nc; idx++) {\n wOrth = this.model[idx].wOrth.transpose();\n pOrth = this.model[idx].pOrth;\n tOrth = Eh.mmul(wOrth);\n Eh.sub(tOrth.mmul(pOrth));\n // prediction\n tPred = Eh.mmul(this.model[idx].plsC.w.transpose());\n // this should be summed over ncomp (pls_prediction.R line 23)\n yHat = tPred.mmul(this.model[idx].plsC.betas);\n }\n\n if (labels.rows > 0) {\n if (this.mode === 'regression') {\n let tssy = tss(labels);\n let press = tss(labels.clone().sub(yHat));\n let Q2y = 1 - press / tssy;\n\n return { tPred, tOrth, yHat, Q2y };\n } else if (this.mode === 'discriminantAnalysis') {\n let confusionMatrix = [];\n confusionMatrix = ConfusionMatrix.fromLabels(\n trueLabels.to1DArray(),\n yHat.to1DArray(),\n );\n\n return { tPred, tOrth, yHat, confusionMatrix };\n }\n } else {\n return { tPred, tOrth, yHat };\n }\n }\n\n _predictAll(features, labels, options = {}) {\n // cannot use the global this.center here\n // since it is used in the NC loop and\n // centering and scaling should only be\n // performed once\n const { center = true, scale = true } = options;\n\n if (center) {\n features.center('column');\n labels.center('column');\n }\n\n if (scale) {\n features.scale('column');\n labels.scale('column');\n // reevaluate tssy and tssx after scaling\n // must be global because re-used for next nc iteration\n // tssx is only evaluate the first time\n this.tssy = tss(labels);\n this.tssx = tss(features);\n }\n\n let oplsC = OPLSNipals(features, labels);\n let plsC = new NIPALS(oplsC.filteredX, { Y: labels });\n\n let tPred = oplsC.filteredX.mmul(plsC.w.transpose());\n let yHat = tPred.mmul(plsC.betas);\n\n let rss = tss(labels.clone().sub(yHat));\n let R2y = 1 - rss / this.tssy;\n\n let xEx = plsC.t.mmul(plsC.p);\n let rssx = tss(xEx);\n let R2x = rssx / this.tssx;\n\n return {\n R2y,\n R2x,\n xRes: oplsC.filteredX,\n tOrth: oplsC.scoresXOrtho,\n pOrth: oplsC.loadingsXOrtho,\n wOrth: oplsC.weightsXOrtho,\n tPred: tPred,\n totalPred: yHat,\n XOrth: oplsC.scoresXOrtho.mmul(oplsC.loadingsXOrtho),\n oplsC,\n plsC,\n };\n }\n /**\n *\n * @param {*} X - dataset matrix object\n * @param {*} group - labels matrix object\n * @param {*} index - train and test index (output from getFold())\n */\n _getTrainTest(X, group, index) {\n let testFeatures = new Matrix(index.testIndex.length, X.columns);\n let testLabels = new Matrix(index.testIndex.length, 1);\n index.testIndex.forEach((el, idx) => {\n testFeatures.setRow(idx, X.getRow(el));\n testLabels.setRow(idx, group.getRow(el));\n });\n\n let trainFeatures = new Matrix(index.trainIndex.length, X.columns);\n let trainLabels = new Matrix(index.trainIndex.length, 1);\n index.trainIndex.forEach((el, idx) => {\n trainFeatures.setRow(idx, X.getRow(el));\n trainLabels.setRow(idx, group.getRow(el));\n });\n\n return {\n trainFeatures,\n testFeatures,\n trainLabels,\n testLabels,\n };\n }\n}\n","'use strict';\n\nvar mlMatrix = require('ml-matrix');\n\nfunction logistic(val) {\n return 1 / (1 + Math.exp(-val));\n}\n\nfunction expELU(val, param) {\n return val < 0 ? param * (Math.exp(val) - 1) : val;\n}\n\nfunction softExponential(val, param) {\n if (param < 0) {\n return -Math.log(1 - param * (val + param)) / param;\n }\n if (param > 0) {\n return ((Math.exp(param * val) - 1) / param) + param;\n }\n return val;\n}\n\nfunction softExponentialPrime(val, param) {\n if (param < 0) {\n return 1 / (1 - param * (param + val));\n } else {\n return Math.exp(param * val);\n }\n}\n\nconst ACTIVATION_FUNCTIONS = {\n tanh: {\n activation: Math.tanh,\n derivate: (val) => 1 - (val * val)\n },\n identity: {\n activation: (val) => val,\n derivate: () => 1\n },\n logistic: {\n activation: logistic,\n derivate: (val) => logistic(val) * (1 - logistic(val))\n },\n arctan: {\n activation: Math.atan,\n derivate: (val) => 1 / (val * val + 1)\n },\n softsign: {\n activation: (val) => val / (1 + Math.abs(val)),\n derivate: (val) => 1 / ((1 + Math.abs(val)) * (1 + Math.abs(val)))\n },\n relu: {\n activation: (val) => (val < 0 ? 0 : val),\n derivate: (val) => (val < 0 ? 0 : 1)\n },\n softplus: {\n activation: (val) => Math.log(1 + Math.exp(val)),\n derivate: (val) => 1 / (1 + Math.exp(-val))\n },\n bent: {\n activation: (val) => ((Math.sqrt(val * val + 1) - 1) / 2) + val,\n derivate: (val) => (val / (2 * Math.sqrt(val * val + 1))) + 1\n },\n sinusoid: {\n activation: Math.sin,\n derivate: Math.cos\n },\n sinc: {\n activation: (val) => (val === 0 ? 1 : Math.sin(val) / val),\n derivate: (val) => (val === 0 ? 0 : (Math.cos(val) / val) - (Math.sin(val) / (val * val)))\n },\n gaussian: {\n activation: (val) => Math.exp(-(val * val)),\n derivate: (val) => -2 * val * Math.exp(-(val * val))\n },\n 'parametric-relu': {\n activation: (val, param) => (val < 0 ? param * val : val),\n derivate: (val, param) => (val < 0 ? param : 1)\n },\n 'exponential-elu': {\n activation: expELU,\n derivate: (val, param) => (val < 0 ? expELU(val, param) + param : 1)\n },\n 'soft-exponential': {\n activation: softExponential,\n derivate: softExponentialPrime\n }\n};\n\nclass Layer {\n /**\n * @private\n * Create a new layer with the given options\n * @param {object} options\n * @param {number} [options.inputSize] - Number of conections that enter the neurons.\n * @param {number} [options.outputSize] - Number of conections that leave the neurons.\n * @param {number} [options.regularization] - Regularization parameter.\n * @param {number} [options.epsilon] - Learning rate parameter.\n * @param {string} [options.activation] - Activation function parameter from the FeedForwardNeuralNetwork class.\n * @param {number} [options.activationParam] - Activation parameter if needed.\n */\n constructor(options) {\n this.inputSize = options.inputSize;\n this.outputSize = options.outputSize;\n this.regularization = options.regularization;\n this.epsilon = options.epsilon;\n this.activation = options.activation;\n this.activationParam = options.activationParam;\n\n var selectedFunction = ACTIVATION_FUNCTIONS[options.activation];\n var params = selectedFunction.activation.length;\n\n var actFunction = params > 1 ? (val) => selectedFunction.activation(val, options.activationParam) : selectedFunction.activation;\n var derFunction = params > 1 ? (val) => selectedFunction.derivate(val, options.activationParam) : selectedFunction.derivate;\n\n this.activationFunction = function (i, j) {\n this.set(i, j, actFunction(this.get(i, j)));\n };\n this.derivate = function (i, j) {\n this.set(i, j, derFunction(this.get(i, j)));\n };\n\n if (options.model) {\n // load model\n this.W = mlMatrix.Matrix.checkMatrix(options.W);\n this.b = mlMatrix.Matrix.checkMatrix(options.b);\n } else {\n // default constructor\n this.W = mlMatrix.Matrix.rand(this.inputSize, this.outputSize);\n this.b = mlMatrix.Matrix.zeros(1, this.outputSize);\n\n this.W.apply(function (i, j) {\n this.set(i, j, this.get(i, j) / Math.sqrt(options.inputSize));\n });\n }\n }\n\n /**\n * @private\n * propagate the given input through the current layer.\n * @param {Matrix} X - input.\n * @return {Matrix} output at the current layer.\n */\n forward(X) {\n var z = X.mmul(this.W).addRowVector(this.b);\n z.apply(this.activationFunction);\n this.a = z.clone();\n return z;\n }\n\n /**\n * @private\n * apply backpropagation algorithm at the current layer\n * @param {Matrix} delta - delta values estimated at the following layer.\n * @param {Matrix} a - 'a' values from the following layer.\n * @return {Matrix} the new delta values for the next layer.\n */\n backpropagation(delta, a) {\n this.dW = a.transpose().mmul(delta);\n this.db = mlMatrix.Matrix.rowVector(delta.sum('column'));\n\n var aCopy = a.clone();\n return delta.mmul(this.W.transpose()).mul(aCopy.apply(this.derivate));\n }\n\n /**\n * @private\n * Function that updates the weights at the current layer with the derivatives.\n */\n update() {\n this.dW.add(this.W.clone().mul(this.regularization));\n this.W.add(this.dW.mul(-this.epsilon));\n this.b.add(this.db.mul(-this.epsilon));\n }\n\n /**\n * @private\n * Export the current layer to JSON.\n * @return {object} model\n */\n toJSON() {\n return {\n model: 'Layer',\n inputSize: this.inputSize,\n outputSize: this.outputSize,\n regularization: this.regularization,\n epsilon: this.epsilon,\n activation: this.activation,\n W: this.W,\n b: this.b\n };\n }\n\n /**\n * @private\n * Creates a new Layer with the given model.\n * @param {object} model\n * @return {Layer}\n */\n static load(model) {\n if (model.model !== 'Layer') {\n throw new RangeError('the current model is not a Layer model');\n }\n return new Layer(model);\n }\n}\n\nclass OutputLayer extends Layer {\n constructor(options) {\n super(options);\n\n this.activationFunction = function (i, j) {\n this.set(i, j, Math.exp(this.get(i, j)));\n };\n }\n\n static load(model) {\n if (model.model !== 'Layer') {\n throw new RangeError('the current model is not a Layer model');\n }\n\n return new OutputLayer(model);\n }\n}\n\nclass FeedForwardNeuralNetworks {\n /**\n * Create a new Feedforward neural network model.\n * @class FeedForwardNeuralNetworks\n * @param {object} [options]\n * @param {Array} [options.hiddenLayers=[10]] - Array that contains the sizes of the hidden layers.\n * @param {number} [options.iterations=50] - Number of iterations at the training step.\n * @param {number} [options.learningRate=0.01] - Learning rate of the neural net (also known as epsilon).\n * @param {number} [options.regularization=0.01] - Regularization parameter af the neural net.\n * @param {string} [options.activation='tanh'] - activation function to be used. (options: 'tanh'(default),\n * 'identity', 'logistic', 'arctan', 'softsign', 'relu', 'softplus', 'bent', 'sinusoid', 'sinc', 'gaussian').\n * (single-parametric options: 'parametric-relu', 'exponential-relu', 'soft-exponential').\n * @param {number} [options.activationParam=1] - if the selected activation function needs a parameter.\n */\n constructor(options) {\n options = options || {};\n if (options.model) {\n // load network\n this.hiddenLayers = options.hiddenLayers;\n this.iterations = options.iterations;\n this.learningRate = options.learningRate;\n this.regularization = options.regularization;\n this.dicts = options.dicts;\n this.activation = options.activation;\n this.activationParam = options.activationParam;\n this.model = new Array(options.layers.length);\n\n for (var i = 0; i < this.model.length - 1; ++i) {\n this.model[i] = Layer.load(options.layers[i]);\n }\n this.model[this.model.length - 1] = OutputLayer.load(options.layers[this.model.length - 1]);\n } else {\n // default constructor\n this.hiddenLayers = options.hiddenLayers || [10];\n this.iterations = options.iterations || 50;\n\n this.learningRate = options.learningRate || 0.01;\n this.regularization = options.regularization || 0.01;\n\n this.activation = options.activation || 'tanh';\n this.activationParam = options.activationParam || 1;\n if (!(this.activation in Object.keys(ACTIVATION_FUNCTIONS))) {\n this.activation = 'tanh';\n }\n }\n }\n\n /**\n * @private\n * Function that build and initialize the neural net.\n * @param {number} inputSize - total of features to fit.\n * @param {number} outputSize - total of labels of the prediction set.\n */\n buildNetwork(inputSize, outputSize) {\n var size = 2 + (this.hiddenLayers.length - 1);\n this.model = new Array(size);\n\n // input layer\n this.model[0] = new Layer({\n inputSize: inputSize,\n outputSize: this.hiddenLayers[0],\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n\n // hidden layers\n for (var i = 1; i < this.hiddenLayers.length; ++i) {\n this.model[i] = new Layer({\n inputSize: this.hiddenLayers[i - 1],\n outputSize: this.hiddenLayers[i],\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n }\n\n // output layer\n this.model[size - 1] = new OutputLayer({\n inputSize: this.hiddenLayers[this.hiddenLayers.length - 1],\n outputSize: outputSize,\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n }\n\n /**\n * Train the neural net with the given features and labels.\n * @param {Matrix|Array} features\n * @param {Matrix|Array} labels\n */\n train(features, labels) {\n features = mlMatrix.Matrix.checkMatrix(features);\n this.dicts = dictOutputs(labels);\n\n var inputSize = features.columns;\n var outputSize = Object.keys(this.dicts.inputs).length;\n\n if (!this.model) {\n this.buildNetwork(inputSize, outputSize);\n }\n\n for (var i = 0; i < this.iterations; ++i) {\n var probabilities = this.propagate(features);\n this.backpropagation(features, labels, probabilities);\n }\n }\n\n /**\n * @private\n * Propagate the input(training set) and retrives the probabilities of each class.\n * @param {Matrix} X\n * @return {Matrix} probabilities of each class.\n */\n propagate(X) {\n var input = X;\n for (var i = 0; i < this.model.length; ++i) {\n input = this.model[i].forward(input);\n }\n\n // get probabilities\n return input.divColumnVector(input.sum('row'));\n }\n\n /**\n * @private\n * Function that applies the backpropagation algorithm on each layer of the network\n * in order to fit the features and labels.\n * @param {Matrix} features\n * @param {Array} labels\n * @param {Matrix} probabilities - probabilities of each class of the feature set.\n */\n backpropagation(features, labels, probabilities) {\n for (var i = 0; i < probabilities.rows; ++i) {\n probabilities.set(i, this.dicts.inputs[labels[i]], probabilities.get(i, this.dicts.inputs[labels[i]]) - 1);\n }\n\n // remember, the last delta doesn't matter\n var delta = probabilities;\n for (i = this.model.length - 1; i >= 0; --i) {\n var a = i > 0 ? this.model[i - 1].a : features;\n delta = this.model[i].backpropagation(delta, a);\n }\n\n for (i = 0; i < this.model.length; ++i) {\n this.model[i].update();\n }\n }\n\n /**\n * Predict the output given the feature set.\n * @param {Array|Matrix} features\n * @return {Array}\n */\n predict(features) {\n features = mlMatrix.Matrix.checkMatrix(features);\n var outputs = new Array(features.rows);\n var probabilities = this.propagate(features);\n for (var i = 0; i < features.rows; ++i) {\n outputs[i] = this.dicts.outputs[probabilities.maxRowIndex(i)[1]];\n }\n\n return outputs;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} model\n */\n toJSON() {\n var model = {\n model: 'FNN',\n hiddenLayers: this.hiddenLayers,\n iterations: this.iterations,\n learningRate: this.learningRate,\n regularization: this.regularization,\n activation: this.activation,\n activationParam: this.activationParam,\n dicts: this.dicts,\n layers: new Array(this.model.length)\n };\n\n for (var i = 0; i < this.model.length; ++i) {\n model.layers[i] = this.model[i].toJSON();\n }\n\n return model;\n }\n\n /**\n * Load a Feedforward Neural Network with the current model.\n * @param {object} model\n * @return {FeedForwardNeuralNetworks}\n */\n static load(model) {\n if (model.model !== 'FNN') {\n throw new RangeError('the current model is not a feed forward network');\n }\n\n return new FeedForwardNeuralNetworks(model);\n }\n}\n\n/**\n * @private\n * Method that given an array of labels(predictions), returns two dictionaries, one to transform from labels to\n * numbers and other in the reverse way\n * @param {Array} array\n * @return {object}\n */\nfunction dictOutputs(array) {\n var inputs = {};\n var outputs = {};\n var index = 0;\n for (var i = 0; i < array.length; i += 1) {\n if (inputs[array[i]] === undefined) {\n inputs[array[i]] = index;\n outputs[index] = array[i];\n index++;\n }\n }\n\n return {\n inputs: inputs,\n outputs: outputs\n };\n}\n\nmodule.exports = FeedForwardNeuralNetworks;\n","function NodeSquare(x, y, weights, som) {\n this.x = x;\n this.y = y;\n this.weights = weights;\n this.som = som;\n this.neighbors = {};\n}\n\nNodeSquare.prototype.adjustWeights = function adjustWeights(target, learningRate, influence) {\n for (var i = 0, ii = this.weights.length; i < ii; i++) {\n this.weights[i] += learningRate * influence * (target[i] - this.weights[i]);\n }\n};\n\nNodeSquare.prototype.getDistance = function getDistance(otherNode) {\n return Math.max(Math.abs(this.x - otherNode.x), Math.abs(this.y - otherNode.y));\n};\n\nNodeSquare.prototype.getDistanceTorus = function getDistanceTorus(otherNode) {\n var distX = Math.abs(this.x - otherNode.x),\n distY = Math.abs(this.y - otherNode.y);\n return Math.max(Math.min(distX, this.som.gridDim.x - distX), Math.min(distY, this.som.gridDim.y - distY));\n};\n\nNodeSquare.prototype.getNeighbors = function getNeighbors(xy) {\n if (!this.neighbors[xy]) {\n this.neighbors[xy] = new Array(2);\n\n // left or bottom neighbor\n var v;\n if (this[xy] > 0) {\n v = this[xy] - 1;\n } else if (this.som.torus) {\n v = this.som.gridDim[xy] - 1\n }\n if (typeof v !== 'undefined') {\n var x, y;\n if (xy === 'x') {\n x = v;\n y = this.y;\n } else {\n x = this.x;\n y = v;\n }\n this.neighbors[xy][0] = this.som.nodes[x][y];\n }\n\n // top or right neighbor\n var w;\n if (this[xy] < (this.som.gridDim[xy] - 1)) {\n w = this[xy] + 1;\n } else if (this.som.torus) {\n w = 0;\n }\n if (typeof w !== 'undefined') {\n if (xy === 'x') {\n x = w;\n y = this.y;\n } else {\n x = this.x;\n y = w;\n }\n this.neighbors[xy][1] = this.som.nodes[x][y];\n }\n }\n return this.neighbors[xy];\n};\n\nNodeSquare.prototype.getPos = function getPos(xy, element) {\n var neighbors = this.getNeighbors(xy),\n distance = this.som.distance,\n bestNeighbor,\n direction;\n if(neighbors[0]) {\n if (neighbors[1]) {\n var dist1 = distance(element, neighbors[0].weights),\n dist2 = distance(element, neighbors[1].weights);\n if(dist1 < dist2) {\n bestNeighbor = neighbors[0];\n direction = -1;\n } else {\n bestNeighbor = neighbors[1];\n direction = 1;\n }\n } else {\n bestNeighbor = neighbors[0];\n direction = -1;\n }\n } else {\n bestNeighbor = neighbors[1];\n direction = 1;\n }\n var simA = 1 - distance(element, this.weights),\n simB = 1 - distance(element, bestNeighbor.weights);\n var factor = ((simA - simB) / (2 - simA - simB));\n return 0.5 + 0.5 * factor * direction;\n};\n\nNodeSquare.prototype.getPosition = function getPosition(element) {\n return [\n this.getPos('x', element),\n this.getPos('y', element)\n ];\n};\n\nmodule.exports = NodeSquare;","var NodeSquare = require('./node-square');\n\nfunction NodeHexagonal(x, y, weights, som) {\n\n NodeSquare.call(this, x, y, weights, som);\n\n this.hX = x - Math.floor(y / 2);\n this.z = 0 - this.hX - y;\n\n}\n\nNodeHexagonal.prototype = new NodeSquare;\nNodeHexagonal.prototype.constructor = NodeHexagonal;\n\nNodeHexagonal.prototype.getDistance = function getDistanceHexagonal(otherNode) {\n return Math.max(Math.abs(this.hX - otherNode.hX), Math.abs(this.y - otherNode.y), Math.abs(this.z - otherNode.z));\n};\n\nNodeHexagonal.prototype.getDistanceTorus = function getDistanceTorus(otherNode) {\n var distX = Math.abs(this.hX - otherNode.hX),\n distY = Math.abs(this.y - otherNode.y),\n distZ = Math.abs(this.z - otherNode.z);\n return Math.max(Math.min(distX, this.som.gridDim.x - distX), Math.min(distY, this.som.gridDim.y - distY), Math.min(distZ, this.som.gridDim.z - distZ));\n};\n\nNodeHexagonal.prototype.getPosition = function getPosition() {\n throw new Error('Unimplemented : cannot get position of the points for hexagonal grid');\n};\n\nmodule.exports = NodeHexagonal;","'use strict';\n\nvar NodeSquare = require('./node-square'),\n NodeHexagonal = require('./node-hexagonal');\n\nvar defaultOptions = {\n fields: 3,\n randomizer: Math.random,\n distance: squareEuclidean,\n iterations: 10,\n learningRate: 0.1,\n gridType: 'rect',\n torus: true,\n method: 'random'\n};\n\nfunction SOM(x, y, options, reload) {\n\n this.x = x;\n this.y = y;\n\n options = options || {};\n this.options = {};\n for (var i in defaultOptions) {\n if (options.hasOwnProperty(i)) {\n this.options[i] = options[i];\n } else {\n this.options[i] = defaultOptions[i];\n }\n }\n\n if (typeof this.options.fields === 'number') {\n this.numWeights = this.options.fields;\n } else if (Array.isArray(this.options.fields)) {\n this.numWeights = this.options.fields.length;\n var converters = getConverters(this.options.fields);\n this.extractor = converters.extractor;\n this.creator = converters.creator;\n } else {\n throw new Error('Invalid fields definition');\n }\n\n if (this.options.gridType === 'rect') {\n this.nodeType = NodeSquare;\n this.gridDim = {\n x: x,\n y: y\n };\n } else {\n this.nodeType = NodeHexagonal;\n var hx = this.x - Math.floor(this.y / 2);\n this.gridDim = {\n x: hx,\n y: this.y,\n z: -(0 - hx - this.y)\n };\n }\n\n this.torus = this.options.torus;\n this.distanceMethod = this.torus ? 'getDistanceTorus' : 'getDistance';\n\n this.distance = this.options.distance;\n\n this.maxDistance = getMaxDistance(this.distance, this.numWeights);\n\n if (reload === true) { // For model loading\n this.done = true;\n return;\n }\n if (!(x > 0 && y > 0)) {\n throw new Error('x and y must be positive');\n }\n\n this.times = {\n findBMU: 0,\n adjust: 0\n };\n\n this.randomizer = this.options.randomizer;\n\n this.iterationCount = 0;\n this.iterations = this.options.iterations;\n\n this.startLearningRate = this.learningRate = this.options.learningRate;\n\n this.mapRadius = Math.floor(Math.max(x, y) / 2);\n\n this.algorithmMethod = this.options.method;\n\n this._initNodes();\n\n this.done = false;\n}\n\nSOM.load = function loadModel(model, distance) {\n if (model.name === 'SOM') {\n var x = model.data.length,\n y = model.data[0].length;\n if (distance) {\n model.options.distance = distance;\n } else if (model.options.distance) {\n model.options.distance = eval('(' + model.options.distance + ')');\n }\n var som = new SOM(x, y, model.options, true);\n som.nodes = new Array(x);\n for (var i = 0; i < x; i++) {\n som.nodes[i] = new Array(y);\n for (var j = 0; j < y; j++) {\n som.nodes[i][j] = new som.nodeType(i, j, model.data[i][j], som);\n }\n }\n return som;\n } else {\n throw new Error('expecting a SOM model');\n }\n};\n\nSOM.prototype.export = function exportModel(includeDistance) {\n if (!this.done) {\n throw new Error('model is not ready yet');\n }\n var model = {\n name: 'SOM'\n };\n model.options = {\n fields: this.options.fields,\n gridType: this.options.gridType,\n torus: this.options.torus\n };\n model.data = new Array(this.x);\n for (var i = 0; i < this.x; i++) {\n model.data[i] = new Array(this.y);\n for (var j = 0; j < this.y; j++) {\n model.data[i][j] = this.nodes[i][j].weights;\n }\n }\n if (includeDistance) {\n model.options.distance = this.distance.toString();\n }\n return model;\n};\n\nSOM.prototype._initNodes = function initNodes() {\n var now = Date.now(),\n i, j, k;\n this.nodes = new Array(this.x);\n for (i = 0; i < this.x; i++) {\n this.nodes[i] = new Array(this.y);\n for (j = 0; j < this.y; j++) {\n var weights = new Array(this.numWeights);\n for (k = 0; k < this.numWeights; k++) {\n weights[k] = this.randomizer();\n }\n this.nodes[i][j] = new this.nodeType(i, j, weights, this);\n }\n }\n this.times.initNodes = Date.now() - now;\n};\n\nSOM.prototype.setTraining = function setTraining(trainingSet) {\n if (this.trainingSet) {\n throw new Error('training set has already been set');\n }\n var now = Date.now();\n var convertedSet = trainingSet;\n var i, l = trainingSet.length;\n if (this.extractor) {\n convertedSet = new Array(l);\n for (i = 0; i < l; i++) {\n convertedSet[i] = this.extractor(trainingSet[i]);\n }\n }\n this.numIterations = this.iterations * l;\n\n if (this.algorithmMethod === 'random') {\n this.timeConstant = this.numIterations / Math.log(this.mapRadius);\n } else {\n this.timeConstant = l / Math.log(this.mapRadius);\n }\n this.trainingSet = convertedSet;\n this.times.setTraining = Date.now() - now;\n};\n\nSOM.prototype.trainOne = function trainOne() {\n if (this.done) {\n\n return false;\n\n } else if (this.numIterations-- > 0) {\n\n var neighbourhoodRadius,\n trainingValue,\n trainingSetFactor;\n\n if (this.algorithmMethod === 'random') { // Pick a random value of the training set at each step\n neighbourhoodRadius = this.mapRadius * Math.exp(-this.iterationCount / this.timeConstant);\n trainingValue = getRandomValue(this.trainingSet, this.randomizer);\n this._adjust(trainingValue, neighbourhoodRadius);\n this.learningRate = this.startLearningRate * Math.exp(-this.iterationCount / this.numIterations);\n } else { // Get next input vector\n trainingSetFactor = -Math.floor(this.iterationCount / this.trainingSet.length);\n neighbourhoodRadius = this.mapRadius * Math.exp(trainingSetFactor / this.timeConstant);\n trainingValue = this.trainingSet[this.iterationCount % this.trainingSet.length];\n this._adjust(trainingValue, neighbourhoodRadius);\n if (((this.iterationCount + 1) % this.trainingSet.length) === 0) {\n this.learningRate = this.startLearningRate * Math.exp(trainingSetFactor / Math.floor(this.numIterations / this.trainingSet.length));\n }\n }\n\n this.iterationCount++;\n\n return true;\n\n } else {\n\n this.done = true;\n return false;\n\n }\n};\n\nSOM.prototype._adjust = function adjust(trainingValue, neighbourhoodRadius) {\n var now = Date.now(),\n x, y, dist, influence;\n\n var bmu = this._findBestMatchingUnit(trainingValue);\n\n var now2 = Date.now();\n this.times.findBMU += now2 - now;\n\n var radiusLimit = Math.floor(neighbourhoodRadius);\n var xMin = bmu.x - radiusLimit,\n xMax = bmu.x + radiusLimit,\n yMin = bmu.y - radiusLimit,\n yMax = bmu.y + radiusLimit;\n\n for (x = xMin; x <= xMax; x++) {\n var theX = x;\n if (x < 0) {\n theX += this.x;\n } else if (x >= this.x) {\n theX -= this.x;\n }\n for (y = yMin; y <= yMax; y++) {\n var theY = y;\n if (y < 0) {\n theY += this.y;\n } else if (y >= this.y) {\n theY -= this.y;\n }\n\n dist = bmu[this.distanceMethod](this.nodes[theX][theY]);\n\n if (dist < neighbourhoodRadius) {\n influence = Math.exp(-dist / (2 * neighbourhoodRadius));\n this.nodes[theX][theY].adjustWeights(trainingValue, this.learningRate, influence);\n }\n\n }\n }\n\n this.times.adjust += (Date.now() - now2);\n\n};\n\nSOM.prototype.train = function train(trainingSet) {\n if (!this.done) {\n this.setTraining(trainingSet);\n while (this.trainOne()) {\n }\n }\n};\n\nSOM.prototype.getConvertedNodes = function getConvertedNodes() {\n var result = new Array(this.x);\n for (var i = 0; i < this.x; i++) {\n result[i] = new Array(this.y);\n for (var j = 0; j < this.y; j++) {\n var node = this.nodes[i][j];\n result[i][j] = this.creator ? this.creator(node.weights) : node.weights;\n }\n }\n return result;\n};\n\nSOM.prototype._findBestMatchingUnit = function findBestMatchingUnit(candidate) {\n\n var bmu,\n lowest = Infinity,\n dist;\n\n for (var i = 0; i < this.x; i++) {\n for (var j = 0; j < this.y; j++) {\n dist = this.distance(this.nodes[i][j].weights, candidate);\n if (dist < lowest) {\n lowest = dist;\n bmu = this.nodes[i][j];\n }\n }\n }\n\n return bmu;\n\n};\n\nSOM.prototype.predict = function predict(data, computePosition) {\n if (typeof data === 'boolean') {\n computePosition = data;\n data = null;\n }\n if (!data) {\n data = this.trainingSet;\n }\n if (Array.isArray(data) && (Array.isArray(data[0]) || (typeof data[0] === 'object'))) { // predict a dataset\n var self = this;\n return data.map(function (element) {\n return self._predict(element, computePosition);\n });\n } else { // predict a single element\n return this._predict(data, computePosition);\n }\n};\n\nSOM.prototype._predict = function _predict(element, computePosition) {\n if (!Array.isArray(element)) {\n element = this.extractor(element);\n }\n var bmu = this._findBestMatchingUnit(element);\n var result = [bmu.x, bmu.y];\n if (computePosition) {\n result[2] = bmu.getPosition(element);\n }\n return result;\n};\n\n// As seen in http://www.scholarpedia.org/article/Kohonen_network\nSOM.prototype.getQuantizationError = function getQuantizationError() {\n var fit = this.getFit(),\n l = fit.length,\n sum = 0;\n for (var i = 0; i < l; i++) {\n sum += fit[i];\n }\n return sum / l;\n};\n\nSOM.prototype.getFit = function getFit(dataset) {\n if (!dataset) {\n dataset = this.trainingSet;\n }\n var l = dataset.length,\n bmu,\n result = new Array(l);\n for (var i = 0; i < l; i++) {\n bmu = this._findBestMatchingUnit(dataset[i]);\n result[i] = Math.sqrt(this.distance(dataset[i], bmu.weights));\n }\n return result;\n};\n\nfunction getConverters(fields) {\n var l = fields.length,\n normalizers = new Array(l),\n denormalizers = new Array(l);\n for (var i = 0; i < l; i++) {\n normalizers[i] = getNormalizer(fields[i].range);\n denormalizers[i] = getDenormalizer(fields[i].range);\n }\n return {\n extractor: function extractor(value) {\n var result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = normalizers[i](value[fields[i].name]);\n }\n return result;\n },\n creator: function creator(value) {\n var result = {};\n for (var i = 0; i < l; i++) {\n result[fields[i].name] = denormalizers[i](value[i]);\n }\n return result;\n }\n };\n}\n\nfunction getNormalizer(minMax) {\n return function normalizer(value) {\n return (value - minMax[0]) / (minMax[1] - minMax[0]);\n };\n}\n\nfunction getDenormalizer(minMax) {\n return function denormalizer(value) {\n return (minMax[0] + value * (minMax[1] - minMax[0]));\n };\n}\n\nfunction squareEuclidean(a, b) {\n var d = 0;\n for (var i = 0, ii = a.length; i < ii; i++) {\n d += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return d;\n}\n\nfunction getRandomValue(arr, randomizer) {\n return arr[Math.floor(randomizer() * arr.length)];\n}\n\nfunction getMaxDistance(distance, numWeights) {\n var zero = new Array(numWeights),\n one = new Array(numWeights);\n for (var i = 0; i < numWeights; i++) {\n zero[i] = 0;\n one[i] = 1;\n }\n return distance(zero, one);\n}\n\nmodule.exports = SOM;","export default function maybeToPrecision(value, digits) {\n if (value < 0) {\n value = 0 - value;\n if (typeof digits === 'number') {\n return `- ${value.toPrecision(digits)}`;\n } else {\n return `- ${value.toString()}`;\n }\n } else {\n if (typeof digits === 'number') {\n return value.toPrecision(digits);\n } else {\n return value.toString();\n }\n }\n}\n","export default function checkArraySize(x, y) {\n if (!Array.isArray(x) || !Array.isArray(y)) {\n throw new TypeError('x and y must be arrays');\n }\n if (x.length !== y.length) {\n throw new RangeError('x and y arrays must have the same length');\n }\n}\n","export { default as maybeToPrecision } from './maybeToPrecision';\nexport { default as checkArrayLength } from './checkArrayLength';\n\nexport default class BaseRegression {\n constructor() {\n if (new.target === BaseRegression) {\n throw new Error('BaseRegression must be subclassed');\n }\n }\n\n predict(x) {\n if (typeof x === 'number') {\n return this._predict(x);\n } else if (Array.isArray(x)) {\n const y = [];\n for (let i = 0; i < x.length; i++) {\n y.push(this._predict(x[i]));\n }\n return y;\n } else {\n throw new TypeError('x must be a number or array');\n }\n }\n\n _predict() {\n throw new Error('_predict must be implemented');\n }\n\n train() {\n // Do nothing for this package\n }\n\n toString() {\n return '';\n }\n\n toLaTeX() {\n return '';\n }\n\n /**\n * Return the correlation coefficient of determination (r) and chi-square.\n * @param {Array} x\n * @param {Array} y\n * @return {object}\n */\n score(x, y) {\n if (!Array.isArray(x) || !Array.isArray(y) || x.length !== y.length) {\n throw new Error('x and y must be arrays of the same length');\n }\n\n const n = x.length;\n const y2 = new Array(n);\n for (let i = 0; i < n; i++) {\n y2[i] = this._predict(x[i]);\n }\n\n let xSum = 0;\n let ySum = 0;\n let chi2 = 0;\n let rmsd = 0;\n let xSquared = 0;\n let ySquared = 0;\n let xY = 0;\n for (let i = 0; i < n; i++) {\n xSum += y2[i];\n ySum += y[i];\n xSquared += y2[i] * y2[i];\n ySquared += y[i] * y[i];\n xY += y2[i] * y[i];\n if (y[i] !== 0) {\n chi2 += ((y[i] - y2[i]) * (y[i] - y2[i])) / y[i];\n }\n rmsd += (y[i] - y2[i]) * (y[i] - y2[i]);\n }\n\n const r =\n (n * xY - xSum * ySum) /\n Math.sqrt((n * xSquared - xSum * xSum) * (n * ySquared - ySum * ySum));\n\n return {\n r: r,\n r2: r * r,\n chi2: chi2,\n rmsd: Math.sqrt(rmsd / n)\n };\n }\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport { Matrix, MatrixTransposeView, solve } from 'ml-matrix';\n\nexport default class PolynomialRegression extends BaseRegression {\n constructor(x, y, degree) {\n super();\n if (x === true) {\n this.degree = y.degree;\n this.powers = y.powers;\n this.coefficients = y.coefficients;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y, degree);\n }\n }\n\n _predict(x) {\n let y = 0;\n for (let k = 0; k < this.powers.length; k++) {\n y += this.coefficients[k] * Math.pow(x, this.powers[k]);\n }\n return y;\n }\n\n toJSON() {\n return {\n name: 'polynomialRegression',\n degree: this.degree,\n powers: this.powers,\n coefficients: this.coefficients\n };\n }\n\n toString(precision) {\n return this._toFormula(precision, false);\n }\n\n toLaTeX(precision) {\n return this._toFormula(precision, true);\n }\n\n _toFormula(precision, isLaTeX) {\n let sup = '^';\n let closeSup = '';\n let times = ' * ';\n if (isLaTeX) {\n sup = '^{';\n closeSup = '}';\n times = '';\n }\n\n let fn = '';\n let str = '';\n for (let k = 0; k < this.coefficients.length; k++) {\n str = '';\n if (this.coefficients[k] !== 0) {\n if (this.powers[k] === 0) {\n str = maybeToPrecision(this.coefficients[k], precision);\n } else {\n if (this.powers[k] === 1) {\n str =\n `${maybeToPrecision(this.coefficients[k], precision) + times}x`;\n } else {\n str =\n `${maybeToPrecision(this.coefficients[k], precision) +\n times\n }x${\n sup\n }${this.powers[k]\n }${closeSup}`;\n }\n }\n\n if (this.coefficients[k] > 0 && k !== this.coefficients.length - 1) {\n str = ` + ${str}`;\n } else if (k !== this.coefficients.length - 1) {\n str = ` ${str}`;\n }\n }\n fn = str + fn;\n }\n if (fn.charAt(0) === '+') {\n fn = fn.slice(1);\n }\n\n return `f(x) = ${fn}`;\n }\n\n static load(json) {\n if (json.name !== 'polynomialRegression') {\n throw new TypeError('not a polynomial regression model');\n }\n return new PolynomialRegression(true, json);\n }\n}\n\nfunction regress(pr, x, y, degree) {\n const n = x.length;\n let powers;\n if (Array.isArray(degree)) {\n powers = degree;\n degree = powers.length;\n } else {\n degree++;\n powers = new Array(degree);\n for (let k = 0; k < degree; k++) {\n powers[k] = k;\n }\n }\n const F = new Matrix(n, degree);\n const Y = new Matrix([y]);\n for (let k = 0; k < degree; k++) {\n for (let i = 0; i < n; i++) {\n if (powers[k] === 0) {\n F.set(i, k, 1);\n } else {\n F.set(i, k, Math.pow(x[i], powers[k]));\n }\n }\n }\n\n const FT = new MatrixTransposeView(F);\n const A = FT.mmul(F);\n const B = FT.mmul(new MatrixTransposeView(Y));\n\n pr.degree = degree - 1;\n pr.powers = powers;\n pr.coefficients = solve(A, B).to1DArray();\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\n\nexport default class SimpleLinearRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n this.slope = y.slope;\n this.intercept = y.intercept;\n this.coefficients = [y.intercept, y.slope];\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n toJSON() {\n return {\n name: 'simpleLinearRegression',\n slope: this.slope,\n intercept: this.intercept\n };\n }\n\n _predict(x) {\n return this.slope * x + this.intercept;\n }\n\n computeX(y) {\n return (y - this.intercept) / this.slope;\n }\n\n toString(precision) {\n let result = 'f(x) = ';\n if (this.slope !== 0) {\n const xFactor = maybeToPrecision(this.slope, precision);\n result += `${xFactor === '1' ? '' : `${xFactor} * `}x`;\n if (this.intercept !== 0) {\n const absIntercept = Math.abs(this.intercept);\n const operator = absIntercept === this.intercept ? '+' : '-';\n result += ` ${operator} ${maybeToPrecision(absIntercept, precision)}`;\n }\n } else {\n result += maybeToPrecision(this.intercept, precision);\n }\n return result;\n }\n\n toLaTeX(precision) {\n return this.toString(precision);\n }\n\n static load(json) {\n if (json.name !== 'simpleLinearRegression') {\n throw new TypeError('not a SLR model');\n }\n return new SimpleLinearRegression(true, json);\n }\n}\n\nfunction regress(slr, x, y) {\n const n = x.length;\n let xSum = 0;\n let ySum = 0;\n\n let xSquared = 0;\n let xY = 0;\n\n for (let i = 0; i < n; i++) {\n xSum += x[i];\n ySum += y[i];\n xSquared += x[i] * x[i];\n xY += x[i] * y[i];\n }\n\n const numerator = n * xY - xSum * ySum;\n slr.slope = numerator / (n * xSquared - xSum * xSum);\n slr.intercept = (1 / n) * ySum - slr.slope * (1 / n) * xSum;\n slr.coefficients = [slr.intercept, slr.slope];\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport SimpleLinearRegression from 'ml-regression-simple-linear';\n\nexport default class ExponentialRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n this.A = y.A;\n this.B = y.B;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n _predict(input) {\n return this.B * Math.exp(input * this.A);\n }\n\n toJSON() {\n return {\n name: 'exponentialRegression',\n A: this.A,\n B: this.B\n };\n }\n\n toString(precision) {\n return (\n `f(x) = ${\n maybeToPrecision(this.B, precision)\n } * e^(${\n maybeToPrecision(this.A, precision)\n } * x)`\n );\n }\n\n toLaTeX(precision) {\n if (this.A >= 0) {\n return (\n `f(x) = ${\n maybeToPrecision(this.B, precision)\n }e^{${\n maybeToPrecision(this.A, precision)\n }x}`\n );\n } else {\n return (\n `f(x) = \\\\frac{${\n maybeToPrecision(this.B, precision)\n }}{e^{${\n maybeToPrecision(-this.A, precision)\n }x}}`\n );\n }\n }\n\n static load(json) {\n if (json.name !== 'exponentialRegression') {\n throw new TypeError('not a exponential regression model');\n }\n return new ExponentialRegression(true, json);\n }\n}\n\nfunction regress(er, x, y) {\n const n = x.length;\n const yl = new Array(n);\n for (let i = 0; i < n; i++) {\n yl[i] = Math.log(y[i]);\n }\n\n const linear = new SimpleLinearRegression(x, yl);\n er.A = linear.slope;\n er.B = Math.exp(linear.intercept);\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport SimpleLinearRegression from 'ml-regression-simple-linear';\n\nexport default class PowerRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n // reloading model\n this.A = y.A;\n this.B = y.B;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n _predict(newInputs) {\n return this.A * Math.pow(newInputs, this.B);\n }\n\n toJSON() {\n return {\n name: 'powerRegression',\n A: this.A,\n B: this.B\n };\n }\n\n toString(precision) {\n return `f(x) = ${maybeToPrecision(\n this.A,\n precision\n )} * x^${maybeToPrecision(this.B, precision)}`;\n }\n\n toLaTeX(precision) {\n let latex = '';\n if (this.B >= 0) {\n latex = `f(x) = ${maybeToPrecision(\n this.A,\n precision\n )}x^{${maybeToPrecision(this.B, precision)}}`;\n } else {\n latex = `f(x) = \\\\frac{${maybeToPrecision(\n this.A,\n precision\n )}}{x^{${maybeToPrecision(-this.B, precision)}}}`;\n }\n latex = latex.replace(/e([+-]?[0-9]+)/g, 'e^{$1}');\n return latex;\n }\n\n static load(json) {\n if (json.name !== 'powerRegression') {\n throw new TypeError('not a power regression model');\n }\n return new PowerRegression(true, json);\n }\n}\n\nfunction regress(pr, x, y) {\n const n = x.length;\n const xl = new Array(n);\n const yl = new Array(n);\n for (let i = 0; i < n; i++) {\n xl[i] = Math.log(x[i]);\n yl[i] = Math.log(y[i]);\n }\n\n const linear = new SimpleLinearRegression(xl, yl);\n pr.A = Math.exp(linear.intercept);\n pr.B = linear.slope;\n}\n","import Matrix, { SVD, pseudoInverse } from 'ml-matrix';\n\nexport default class MultivariateLinearRegression {\n constructor(x, y, options = {}) {\n const { intercept = true, statistics = true } = options;\n this.statistics = statistics;\n if (x === true) {\n this.weights = y.weights;\n this.inputs = y.inputs;\n this.outputs = y.outputs;\n this.intercept = y.intercept;\n } else {\n x = new Matrix(x);\n y = new Matrix(y);\n if (intercept) {\n x.addColumn(new Array(x.rows).fill(1));\n }\n let xt = x.transpose();\n const xx = xt\n .mmul(x);\n const xy = xt\n .mmul(y);\n const invxx = new SVD(xx)\n .inverse();\n const beta = xy\n .transpose()\n .mmul(invxx)\n .transpose();\n this.weights = beta.to2DArray();\n this.inputs = x.columns;\n this.outputs = y.columns;\n if (intercept) this.inputs--;\n this.intercept = intercept;\n if (statistics) {\n /*\n * Let's add some basic statistics about the beta's to be able to interpret them.\n * source: http://dept.stat.lsa.umich.edu/~kshedden/Courses/Stat401/Notes/401-multreg.pdf\n * validated against Excel Regression AddIn\n * test: \"datamining statistics test\"\n */\n const fittedValues = x.mmul(beta);\n const residuals = y.clone().addM(fittedValues.neg());\n const variance =\n residuals\n .to2DArray()\n .map((ri) => Math.pow(ri[0], 2))\n .reduce((a, b) => a + b) /\n (y.rows - x.columns);\n this.stdError = Math.sqrt(variance);\n this.stdErrorMatrix = pseudoInverse(xx).mul(variance);\n this.stdErrors = this.stdErrorMatrix\n .diagonal()\n .map((d) => Math.sqrt(d));\n this.tStats = this.weights.map((d, i) =>\n (this.stdErrors[i] === 0 ? 0 : d[0] / this.stdErrors[i])\n );\n }\n }\n }\n\n predict(x) {\n if (Array.isArray(x)) {\n if (typeof x[0] === 'number') {\n return this._predict(x);\n } else if (Array.isArray(x[0])) {\n const y = new Array(x.length);\n for (let i = 0; i < x.length; i++) {\n y[i] = this._predict(x[i]);\n }\n return y;\n }\n } else if (Matrix.isMatrix(x)) {\n const y = new Matrix(x.rows, this.outputs);\n for (let i = 0; i < x.rows; i++) {\n y.setRow(i, this._predict(x.getRow(i)));\n }\n return y;\n }\n throw new TypeError('x must be a matrix or array of numbers');\n }\n\n _predict(x) {\n const result = new Array(this.outputs);\n if (this.intercept) {\n for (let i = 0; i < this.outputs; i++) {\n result[i] = this.weights[this.inputs][i];\n }\n } else {\n result.fill(0);\n }\n for (let i = 0; i < this.inputs; i++) {\n for (let j = 0; j < this.outputs; j++) {\n result[j] += this.weights[i][j] * x[i];\n }\n }\n return result;\n }\n\n score() {\n throw new Error('score method is not implemented yet');\n }\n\n toJSON() {\n return {\n name: 'multivariateLinearRegression',\n weights: this.weights,\n inputs: this.inputs,\n outputs: this.outputs,\n intercept: this.intercept,\n summary: this.statistics\n ? {\n regressionStatistics: {\n standardError: this.stdError,\n observations: this.outputs\n },\n variables: this.weights.map((d, i) => {\n return {\n label:\n i === this.weights.length - 1\n ? 'Intercept'\n : `X Variable ${i + 1}`,\n coefficients: d,\n standardError: this.stdErrors[i],\n tStat: this.tStats[i]\n };\n })\n }\n : undefined\n };\n }\n\n static load(model) {\n if (model.name !== 'multivariateLinearRegression') {\n throw new Error('not a MLR model');\n }\n return new MultivariateLinearRegression(true, model);\n }\n}\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass GaussianKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.divisor = 2 * options.sigma * options.sigma;\n }\n compute(x, y) {\n const distance = squaredEuclidean(x, y);\n return Math.exp(-distance / this.divisor);\n }\n}\n\nmodule.exports = GaussianKernel;\n","'use strict';\n\nconst defaultOptions = {\n degree: 1,\n constant: 1,\n scale: 1\n};\n\nclass PolynomialKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n\n this.degree = options.degree;\n this.constant = options.constant;\n this.scale = options.scale;\n }\n\n compute(x, y) {\n var sum = 0;\n for (var i = 0; i < x.length; i++) {\n sum += x[i] * y[i];\n }\n return Math.pow(this.scale * sum + this.constant, this.degree);\n }\n}\n\nmodule.exports = PolynomialKernel;\n","'use strict';\n\nconst defaultOptions = {\n alpha: 0.01,\n constant: -Math.E\n};\n\nclass SigmoidKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.alpha = options.alpha;\n this.constant = options.constant;\n }\n\n compute(x, y) {\n var sum = 0;\n for (var i = 0; i < x.length; i++) {\n sum += x[i] * y[i];\n }\n return Math.tanh(this.alpha * sum + this.constant);\n }\n}\n\nmodule.exports = SigmoidKernel;\n","'use strict';\n\nconst defaultOptions = {\n sigma: 1,\n degree: 1\n};\n\nclass ANOVAKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.degree = options.degree;\n }\n\n compute(x, y) {\n var sum = 0;\n var len = Math.min(x.length, y.length);\n for (var i = 1; i <= len; ++i) {\n sum += Math.pow(\n Math.exp(\n -this.sigma *\n Math.pow(Math.pow(x[i - 1], i) - Math.pow(y[i - 1], i), 2)\n ),\n this.degree\n );\n }\n return sum;\n }\n}\n\nmodule.exports = ANOVAKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass CauchyKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n }\n\n compute(x, y) {\n return 1 / (1 + squaredEuclidean(x, y) / (this.sigma * this.sigma));\n }\n}\n\nmodule.exports = CauchyKernel;\n","'use strict';\n\nconst { euclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass ExponentialKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.divisor = 2 * options.sigma * options.sigma;\n }\n\n compute(x, y) {\n const distance = euclidean(x, y);\n return Math.exp(-distance / this.divisor);\n }\n}\n\nmodule.exports = ExponentialKernel;\n","'use strict';\n\nclass HistogramIntersectionKernel {\n compute(x, y) {\n var min = Math.min(x.length, y.length);\n var sum = 0;\n for (var i = 0; i < min; ++i) {\n sum += Math.min(x[i], y[i]);\n }\n\n return sum;\n }\n}\n\nmodule.exports = HistogramIntersectionKernel;\n","'use strict';\n\nconst { euclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass LaplacianKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n }\n\n compute(x, y) {\n const distance = euclidean(x, y);\n return Math.exp(-distance / this.sigma);\n }\n}\n\nmodule.exports = LaplacianKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n constant: 1\n};\n\nclass MultiquadraticKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.constant = options.constant;\n }\n\n compute(x, y) {\n return Math.sqrt(squaredEuclidean(x, y) + this.constant * this.constant);\n }\n}\n\nmodule.exports = MultiquadraticKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n constant: 1\n};\n\nclass RationalQuadraticKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.constant = options.constant;\n }\n\n compute(x, y) {\n const distance = squaredEuclidean(x, y);\n return 1 - distance / (distance + this.constant);\n }\n}\n\nmodule.exports = RationalQuadraticKernel;\n","'use strict';\n\nconst { Matrix, MatrixTransposeView } = require('ml-matrix');\nconst GaussianKernel = require('ml-kernel-gaussian');\nconst PolynomialKernel = require('ml-kernel-polynomial');\nconst SigmoidKernel = require('ml-kernel-sigmoid');\n\nconst ANOVAKernel = require('./kernels/anova-kernel');\nconst CauchyKernel = require('./kernels/cauchy-kernel');\nconst ExponentialKernel = require('./kernels/exponential-kernel');\nconst HistogramKernel = require('./kernels/histogram-intersection-kernel');\nconst LaplacianKernel = require('./kernels/laplacian-kernel');\nconst MultiquadraticKernel = require('./kernels/multiquadratic-kernel');\nconst RationalKernel = require('./kernels/rational-quadratic-kernel');\n\nconst kernelType = {\n gaussian: GaussianKernel,\n rbf: GaussianKernel,\n polynomial: PolynomialKernel,\n poly: PolynomialKernel,\n anova: ANOVAKernel,\n cauchy: CauchyKernel,\n exponential: ExponentialKernel,\n histogram: HistogramKernel,\n min: HistogramKernel,\n laplacian: LaplacianKernel,\n multiquadratic: MultiquadraticKernel,\n rational: RationalKernel,\n sigmoid: SigmoidKernel,\n mlp: SigmoidKernel\n};\n\nclass Kernel {\n constructor(type, options) {\n this.kernelType = type;\n if (type === 'linear') return;\n\n if (typeof type === 'string') {\n type = type.toLowerCase();\n\n var KernelConstructor = kernelType[type];\n if (KernelConstructor) {\n this.kernelFunction = new KernelConstructor(options);\n } else {\n throw new Error(`unsupported kernel type: ${type}`);\n }\n } else if (typeof type === 'object' && typeof type.compute === 'function') {\n this.kernelFunction = type;\n } else {\n throw new TypeError(\n 'first argument must be a valid kernel type or instance'\n );\n }\n }\n\n compute(inputs, landmarks) {\n inputs = Matrix.checkMatrix(inputs);\n if (landmarks === undefined) {\n landmarks = inputs;\n } else {\n landmarks = Matrix.checkMatrix(landmarks);\n }\n if (this.kernelType === 'linear') {\n return inputs.mmul(new MatrixTransposeView(landmarks));\n }\n\n const kernelMatrix = new Matrix(inputs.rows, landmarks.rows);\n if (inputs === landmarks) {\n // fast path, matrix is symmetric\n for (let i = 0; i < inputs.rows; i++) {\n for (let j = i; j < inputs.rows; j++) {\n const value = this.kernelFunction.compute(\n inputs.getRow(i),\n inputs.getRow(j)\n );\n kernelMatrix.set(i, j, value);\n kernelMatrix.set(j, i, value);\n }\n }\n } else {\n for (let i = 0; i < inputs.rows; i++) {\n for (let j = 0; j < landmarks.rows; j++) {\n kernelMatrix.set(\n i,\n j,\n this.kernelFunction.compute(inputs.getRow(i), landmarks.getRow(j))\n );\n }\n }\n }\n return kernelMatrix;\n }\n}\n\nmodule.exports = Kernel;\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport median from 'ml-array-median';\n\nexport default class TheilSenRegression extends BaseRegression {\n /**\n * Theil–Sen estimator\n * https://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator\n * @param {Array|boolean} x\n * @param {Array|object} y\n * @constructor\n */\n constructor(x, y) {\n super();\n if (x === true) {\n // loads the model\n this.slope = y.slope;\n this.intercept = y.intercept;\n this.coefficients = y.coefficients;\n } else {\n // creates the model\n checkArrayLength(x, y);\n theilSen(this, x, y);\n }\n }\n\n toJSON() {\n return {\n name: 'TheilSenRegression',\n slope: this.slope,\n intercept: this.intercept\n };\n }\n\n _predict(input) {\n return this.slope * input + this.intercept;\n }\n\n computeX(input) {\n return (input - this.intercept) / this.slope;\n }\n\n toString(precision) {\n var result = 'f(x) = ';\n if (this.slope) {\n var xFactor = maybeToPrecision(this.slope, precision);\n result += `${Math.abs(xFactor - 1) < 1e-5 ? '' : `${xFactor} * `}x`;\n if (this.intercept) {\n var absIntercept = Math.abs(this.intercept);\n var operator = absIntercept === this.intercept ? '+' : '-';\n result +=\n ` ${operator} ${maybeToPrecision(absIntercept, precision)}`;\n }\n } else {\n result += maybeToPrecision(this.intercept, precision);\n }\n return result;\n }\n\n toLaTeX(precision) {\n return this.toString(precision);\n }\n\n static load(json) {\n if (json.name !== 'TheilSenRegression') {\n throw new TypeError('not a Theil-Sen model');\n }\n return new TheilSenRegression(true, json);\n }\n}\n\nfunction theilSen(regression, x, y) {\n let len = x.length;\n let slopes = new Array(len * len);\n let count = 0;\n for (let i = 0; i < len; ++i) {\n for (let j = i + 1; j < len; ++j) {\n if (x[i] !== x[j]) {\n slopes[count++] = (y[j] - y[i]) / (x[j] - x[i]);\n }\n }\n }\n slopes.length = count;\n let medianSlope = median(slopes);\n\n let cuts = new Array(len);\n for (let i = 0; i < len; ++i) {\n cuts[i] = y[i] - medianSlope * x[i];\n }\n\n regression.slope = medianSlope;\n regression.intercept = median(cuts);\n regression.coefficients = [regression.intercept, regression.slope];\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport { solve } from 'ml-matrix';\n\n/**\n * @class RobustPolynomialRegression\n * @param {Array} x\n * @param {Array} y\n * @param {number} degree - polynomial degree\n */\nexport default class RobustPolynomialRegression extends BaseRegression {\n constructor(x, y, degree) {\n super();\n if (x === true) {\n this.degree = y.degree;\n this.powers = y.powers;\n this.coefficients = y.coefficients;\n } else {\n checkArrayLength(x, y);\n robustPolynomial(this, x, y, degree);\n }\n }\n\n toJSON() {\n return {\n name: 'robustPolynomialRegression',\n degree: this.degree,\n powers: this.powers,\n coefficients: this.coefficients\n };\n }\n\n _predict(x) {\n return predict(x, this.powers, this.coefficients);\n }\n\n /**\n * Display the formula\n * @param {number} precision - precision for the numbers\n * @return {string}\n */\n toString(precision) {\n return this._toFormula(precision, false);\n }\n\n /**\n * Display the formula in LaTeX format\n * @param {number} precision - precision for the numbers\n * @return {string}\n */\n toLaTeX(precision) {\n return this._toFormula(precision, true);\n }\n\n _toFormula(precision, isLaTeX) {\n let sup = '^';\n let closeSup = '';\n let times = ' * ';\n if (isLaTeX) {\n sup = '^{';\n closeSup = '}';\n times = '';\n }\n\n let fn = '';\n let str = '';\n for (let k = 0; k < this.coefficients.length; k++) {\n str = '';\n if (this.coefficients[k] !== 0) {\n if (this.powers[k] === 0) {\n str = maybeToPrecision(this.coefficients[k], precision);\n } else {\n if (this.powers[k] === 1) {\n str = `${maybeToPrecision(this.coefficients[k], precision) +\n times}x`;\n } else {\n str = `${maybeToPrecision(this.coefficients[k], precision) +\n times}x${sup}${this.powers[k]}${closeSup}`;\n }\n }\n\n if (this.coefficients[k] > 0 && k !== this.coefficients.length - 1) {\n str = ` + ${str}`;\n } else if (k !== this.coefficients.length - 1) {\n str = ` ${str}`;\n }\n }\n fn = str + fn;\n }\n if (fn.charAt(0) === '+') {\n fn = fn.slice(1);\n }\n\n return `f(x) = ${fn}`;\n }\n\n static load(json) {\n if (json.name !== 'robustPolynomialRegression') {\n throw new TypeError('not a RobustPolynomialRegression model');\n }\n return new RobustPolynomialRegression(true, json);\n }\n}\n\nfunction robustPolynomial(regression, x, y, degree) {\n let powers = Array(degree)\n .fill(0)\n .map((_, index) => index);\n\n const tuples = getRandomTuples(x, y, degree);\n\n var min;\n for (var i = 0; i < tuples.length; i++) {\n var tuple = tuples[i];\n var coefficients = calcCoefficients(tuple, powers);\n\n var residuals = x.slice();\n for (var j = 0; j < x.length; j++) {\n residuals[j] = y[j] - predict(x[j], powers, coefficients);\n residuals[j] = {\n residual: residuals[j] * residuals[j],\n coefficients\n };\n }\n\n var median = residualsMedian(residuals);\n if (!min || median.residual < min.residual) {\n min = median;\n }\n }\n\n regression.degree = degree;\n regression.powers = powers;\n regression.coefficients = min.coefficients;\n}\n\n/**\n * @ignore\n * @param {Array} x\n * @param {Array} y\n * @param {number} degree\n * @return {Array<{x:number,y:number}>}\n */\nfunction getRandomTuples(x, y, degree) {\n var len = Math.floor(x.length / degree);\n var tuples = new Array(len);\n\n for (var i = 0; i < x.length; i++) {\n var pos = Math.floor(Math.random() * len);\n\n var counter = 0;\n while (counter < x.length) {\n if (!tuples[pos]) {\n tuples[pos] = [\n {\n x: x[i],\n y: y[i]\n }\n ];\n break;\n } else if (tuples[pos].length < degree) {\n tuples[pos].push({\n x: x[i],\n y: y[i]\n });\n break;\n } else {\n counter++;\n pos = (pos + 1) % len;\n }\n }\n\n if (counter === x.length) {\n return tuples;\n }\n }\n return tuples;\n}\n\n/**\n * @ignore\n * @param {{x:number,y:number}} tuple\n * @param {Array} powers\n * @return {Array}\n */\nfunction calcCoefficients(tuple, powers) {\n var X = tuple.slice();\n var Y = tuple.slice();\n for (var i = 0; i < X.length; i++) {\n Y[i] = [tuple[i].y];\n X[i] = new Array(powers.length);\n for (var j = 0; j < powers.length; j++) {\n X[i][j] = Math.pow(tuple[i].x, powers[j]);\n }\n }\n\n return solve(X, Y).to1DArray();\n}\n\nfunction predict(x, powers, coefficients) {\n let y = 0;\n for (let k = 0; k < powers.length; k++) {\n y += coefficients[k] * Math.pow(x, powers[k]);\n }\n return y;\n}\n\nfunction residualsMedian(residuals) {\n residuals.sort((a, b) => a.residual - b.residual);\n\n var l = residuals.length;\n var half = Math.floor(l / 2);\n return l % 2 === 0 ? residuals[half - 1] : residuals[half];\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","/**\n * Calculate current error\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} parameters - Array of current parameter values\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {number}\n */\nexport default function errorCalculation(\n data,\n parameters,\n parameterizedFunction,\n) {\n let error = 0;\n const func = parameterizedFunction(parameters);\n\n for (let i = 0; i < data.x.length; i++) {\n error += Math.abs(data.y[i] - func(data.x[i]));\n }\n\n return error;\n}\n","import { inverse, Matrix } from 'ml-matrix';\n\n/**\n * Difference of the matrix function over the parameters\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} evaluatedData - Array of previous evaluated function values\n * @param {Array} params - Array of previous parameter values\n * @param {number} gradientDifference - Adjustment for decrease the damping parameter\n * @param {function} paramFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {Matrix}\n */\nfunction gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n paramFunction,\n) {\n const n = params.length;\n const m = data.x.length;\n\n let ans = new Array(n);\n\n for (let param = 0; param < n; param++) {\n ans[param] = new Array(m);\n let auxParams = params.slice();\n auxParams[param] += gradientDifference;\n let funcParam = paramFunction(auxParams);\n\n for (let point = 0; point < m; point++) {\n ans[param][point] = evaluatedData[point] - funcParam(data.x[point]);\n }\n }\n return new Matrix(ans);\n}\n\n/**\n * Matrix function over the samples\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} evaluatedData - Array of previous evaluated function values\n * @return {Matrix}\n */\nfunction matrixFunction(data, evaluatedData) {\n const m = data.x.length;\n\n let ans = new Array(m);\n\n for (let point = 0; point < m; point++) {\n ans[point] = [data.y[point] - evaluatedData[point]];\n }\n\n return new Matrix(ans);\n}\n\n/**\n * Iteration for Levenberg-Marquardt\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} params - Array of previous parameter values\n * @param {number} damping - Levenberg-Marquardt parameter\n * @param {number} gradientDifference - Adjustment for decrease the damping parameter\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {Array}\n */\nexport default function step(\n data,\n params,\n damping,\n gradientDifference,\n parameterizedFunction,\n) {\n let value = damping * gradientDifference * gradientDifference;\n let identity = Matrix.eye(params.length, params.length, value);\n\n const func = parameterizedFunction(params);\n\n let evaluatedData = new Float64Array(data.x.length);\n for (let i = 0; i < data.x.length; i++) {\n evaluatedData[i] = func(data.x[i]);\n }\n\n let gradientFunc = gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n parameterizedFunction,\n );\n let matrixFunc = matrixFunction(data, evaluatedData);\n let inverseMatrix = inverse(\n identity.add(gradientFunc.mmul(gradientFunc.transpose())),\n );\n\n params = new Matrix([params]);\n params = params.sub(\n inverseMatrix\n .mmul(gradientFunc)\n .mmul(matrixFunc)\n .mul(gradientDifference)\n .transpose(),\n );\n\n return params.to1DArray();\n}\n","import isArray from 'is-any-array';\n\nimport errorCalculation from './errorCalculation';\nimport step from './step';\n\n/**\n * Curve fitting algorithm\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @param {object} [options] - Options object\n * @param {number} [options.damping] - Levenberg-Marquardt parameter\n * @param {number} [options.gradientDifference = 10e-2] - Adjustment for decrease the damping parameter\n * @param {Array} [options.minValues] - Minimum allowed values for parameters\n * @param {Array} [options.maxValues] - Maximum allowed values for parameters\n * @param {Array} [options.initialValues] - Array of initial parameter values\n * @param {number} [options.maxIterations = 100] - Maximum of allowed iterations\n * @param {number} [options.errorTolerance = 10e-3] - Minimum uncertainty allowed for each point\n * @return {{parameterValues: Array, parameterError: number, iterations: number}}\n */\nexport default function levenbergMarquardt(\n data,\n parameterizedFunction,\n options = {},\n) {\n let {\n maxIterations = 100,\n gradientDifference = 10e-2,\n damping = 0,\n errorTolerance = 10e-3,\n minValues,\n maxValues,\n initialValues,\n } = options;\n\n if (damping <= 0) {\n throw new Error('The damping option must be a positive number');\n } else if (!data.x || !data.y) {\n throw new Error('The data parameter must have x and y elements');\n } else if (\n !isArray(data.x) ||\n data.x.length < 2 ||\n !isArray(data.y) ||\n data.y.length < 2\n ) {\n throw new Error(\n 'The data parameter elements must be an array with more than 2 points',\n );\n } else if (data.x.length !== data.y.length) {\n throw new Error('The data parameter elements must have the same size');\n }\n\n let parameters =\n initialValues || new Array(parameterizedFunction.length).fill(1);\n let parLen = parameters.length;\n maxValues = maxValues || new Array(parLen).fill(Number.MAX_SAFE_INTEGER);\n minValues = minValues || new Array(parLen).fill(Number.MIN_SAFE_INTEGER);\n\n if (maxValues.length !== minValues.length) {\n throw new Error('minValues and maxValues must be the same size');\n }\n\n if (!isArray(parameters)) {\n throw new Error('initialValues must be an array');\n }\n\n let error = errorCalculation(data, parameters, parameterizedFunction);\n\n let converged = error <= errorTolerance;\n\n let iteration;\n for (iteration = 0; iteration < maxIterations && !converged; iteration++) {\n parameters = step(\n data,\n parameters,\n damping,\n gradientDifference,\n parameterizedFunction,\n );\n\n for (let k = 0; k < parLen; k++) {\n parameters[k] = Math.min(\n Math.max(minValues[k], parameters[k]),\n maxValues[k],\n );\n }\n\n error = errorCalculation(data, parameters, parameterizedFunction);\n if (isNaN(error)) break;\n converged = error <= errorTolerance;\n }\n\n return {\n parameterValues: parameters,\n parameterError: error,\n iterations: iteration,\n };\n}\n","/**\n * Returns a new array based on extraction of specific indices of an array\n * @private\n * @param {Array} vector\n * @param {Array} indices\n */\nexport default function selection(vector, indices) {\n let u = []; //new Float64Array(indices.length);\n for (let i = 0; i < indices.length; i++) {\n u[i] = vector[indices[i]];\n }\n return u;\n}\n","/**\n *\n * @private\n * @param {Array of arrays} collection\n */\nexport default function sortCollectionSet(collection) {\n let objectCollection = collection\n .map((value, index) => {\n let key = BigInt(0);\n value.forEach((item) => (key |= BigInt(1) << BigInt(item)));\n return { value, index, key };\n })\n .sort((a, b) => {\n if (a.key - b.key < 0) return -1;\n return 1;\n });\n\n let sorted = [];\n let indices = [];\n\n let key;\n for (let set of objectCollection) {\n if (set.key !== key) {\n key = set.key;\n indices.push([]);\n sorted.push(set.value);\n }\n indices[indices.length - 1].push(set.index);\n }\n\n let result = {\n values: sorted,\n indices: indices,\n };\n return result;\n}\n","import {\n Matrix,\n LuDecomposition,\n solve,\n CholeskyDecomposition,\n} from 'ml-matrix';\n\nimport sortCollectionSet from './util/sortCollectionSet';\n\n/**\n * (Combinatorial Subspace Least Squares) - subfunction for the FC-NNLS\n * @private\n * @param {Matrix} XtX\n * @param {Matrix} XtY\n * @param {Array} Pset\n * @param {Numbers} l\n * @param {Numbers} p\n */\nexport default function cssls(XtX, XtY, Pset, l, p) {\n // Solves the set of equation XtX*K = XtY for the variables in Pset\n // if XtX (or XtX(vars,vars)) is singular, performs the svd and find pseudoinverse, otherwise (even if ill-conditioned) finds inverse with LU decomposition and solves the set of equation\n // it is consistent with matlab results for ill-conditioned matrices (at least consistent with test 'ill-conditionned square X rank 2, Y 3x1' in cssls.test)\n\n let K = Matrix.zeros(l, p);\n if (Pset === null) {\n let choXtX = new CholeskyDecomposition(XtX);\n if (choXtX.isPositiveDefinite() === true) {\n K = choXtX.solve(XtY);\n } else {\n let luXtX = new LuDecomposition(XtX);\n if (luXtX.isSingular() === false) {\n K = luXtX.solve(Matrix.eye(l)).mmul(XtY);\n } else {\n K = solve(XtX, XtY, { useSVD: true });\n }\n }\n } else {\n let sortedPset = sortCollectionSet(Pset).values;\n let sortedEset = sortCollectionSet(Pset).indices;\n if (\n sortedPset.length === 1 &&\n sortedPset[0].length === 0 &&\n sortedEset[0].length === p\n ) {\n return K;\n } else if (\n sortedPset.length === 1 &&\n sortedPset[0].length === l &&\n sortedEset[0].length === p\n ) {\n let choXtX = new CholeskyDecomposition(XtX);\n if (choXtX.isPositiveDefinite() === true) {\n K = choXtX.solve(XtY);\n } else {\n let luXtX = new LuDecomposition(XtX);\n if (luXtX.isSingular() === false) {\n K = luXtX.solve(Matrix.eye(l)).mmul(XtY);\n } else {\n K = solve(XtX, XtY, { useSVD: true });\n }\n }\n } else {\n for (let k = 0; k < sortedPset.length; k++) {\n let cols2Solve = sortedEset[k];\n let vars = sortedPset[k];\n let L;\n let choXtX = new CholeskyDecomposition(XtX.selection(vars, vars));\n if (choXtX.isPositiveDefinite() === true) {\n L = choXtX.solve(XtY.selection(vars, cols2Solve));\n } else {\n let luXtX = new LuDecomposition(XtX.selection(vars, vars));\n if (luXtX.isSingular() === false) {\n L = luXtX\n .solve(Matrix.eye(vars.length))\n .mmul(XtY.selection(vars, cols2Solve));\n } else {\n L = solve(\n XtX.selection(vars, vars),\n XtY.selection(vars, cols2Solve),\n { useSVD: true },\n );\n }\n }\n for (let i = 0; i < L.rows; i++) {\n for (let j = 0; j < L.columns; j++) {\n K.set(vars[i], cols2Solve[j], L.get(i, j));\n }\n }\n }\n }\n }\n return K;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport cssls from './cssls';\n\nexport default function initialisation(X, Y) {\n let n = X.rows;\n let l = X.columns;\n let p = Y.columns;\n let iter = 0;\n\n if (Y.rows !== n) throw new Error('ERROR: matrix size not compatible');\n\n let W = Matrix.zeros(l, p);\n\n // precomputes part of pseudoinverse\n let XtX = X.transpose().mmul(X);\n let XtY = X.transpose().mmul(Y);\n\n let K = cssls(XtX, XtY, null, l, p); // K is lxp\n let Pset = [];\n for (let j = 0; j < p; j++) {\n Pset[j] = [];\n for (let i = 0; i < l; i++) {\n if (K.get(i, j) > 0) {\n Pset[j].push(i);\n } else {\n K.set(i, j, 0);\n } //This is our initial solution, it's the solution found by overwriting the unconstrained least square solution\n }\n }\n let Fset = [];\n for (let j = 0; j < p; j++) {\n if (Pset[j].length !== l) {\n Fset.push(j);\n }\n }\n\n let D = K.clone();\n\n return { n, l, p, iter, W, XtX, XtY, K, Pset, Fset, D };\n}\n","/**\n * Computes the set difference A\\B\n * @private\n * @param {A} set A as an array\n * @param {B} set B as an array\n */\nexport default function setDifference(A, B) {\n let C = [];\n for (let i of A) {\n if (!B.includes(i)) C.push(i);\n }\n return C;\n}\n","import setDifference from './util/setDifference';\n\n// Makes sure the solution has converged\nexport default function optimality(\n iter,\n maxIter,\n XtX,\n XtY,\n Fset,\n Pset,\n W,\n K,\n l,\n p,\n D,\n) {\n if (iter === maxIter) {\n throw new Error('Maximum number of iterations exceeded');\n }\n\n // Check solution for optimality\n let V = XtY.subMatrixColumn(Fset).subtract(XtX.mmul(K.subMatrixColumn(Fset)));\n for (let j = 0; j < Fset.length; j++) {\n W.setColumn(Fset[j], V.subMatrixColumn([j]));\n }\n let Jset = [];\n let fullSet = [];\n for (let i = 0; i < l; i++) {\n fullSet.push(i);\n }\n for (let j = 0; j < Fset.length; j++) {\n let notPset = setDifference(fullSet, Pset[Fset[j]]);\n if (notPset.length === 0) {\n Jset.push(Fset[j]);\n } else if (W.selection(notPset, [Fset[j]]).max() <= 0) {\n Jset.push(Fset[j]);\n }\n }\n Fset = setDifference(Fset, Jset);\n\n // For non-optimal solutions, add the appropriate variables to Pset\n if (Fset.length !== 0) {\n for (let j = 0; j < Fset.length; j++) {\n for (let i = 0; i < l; i++) {\n if (Pset[Fset[j]].includes(i)) W.set(i, Fset[j], -Infinity);\n }\n Pset[Fset[j]].push(W.subMatrixColumn(Fset).maxColumnIndex(j)[0]);\n }\n for (let j = 0; j < Fset.length; j++) {\n D.setColumn(Fset[j], K.getColumn(Fset[j]));\n }\n }\n for (let j = 0; j < p; j++) {\n Pset[j].sort((a, b) => a - b);\n }\n return { Pset, Fset, W };\n}\n","import { Matrix } from 'ml-matrix';\n\nimport selection from './util/selection';\nimport cssls from './cssls';\nimport initialisation from './initialisation';\nimport optimality from './optimality';\n\n/**\n * Fast Combinatorial Non-negative Least Squares with multiple Right Hand Side\n * @param {Matrix|number[][]} X\n * @param {Matrix|number[][]} Y\n * @param {object} [options={}]\n * @param {number} [options.maxIterations] if empty maxIterations is set at 3 times the number of columns of X\n * @returns {Matrix} K\n */\nexport default function fcnnls(X, Y, options = {}) {\n X = Matrix.checkMatrix(X);\n Y = Matrix.checkMatrix(Y);\n let { l, p, iter, W, XtX, XtY, K, Pset, Fset, D } = initialisation(X, Y);\n const { maxIterations = X.columns * 3 } = options;\n\n // Active set algorithm for NNLS main loop\n while (Fset.length > 0) {\n // Solves for the passive variables (uses subroutine below)\n let L = cssls(\n XtX,\n XtY.subMatrixColumn(Fset),\n selection(Pset, Fset),\n l,\n Fset.length,\n );\n for (let i = 0; i < l; i++) {\n for (let j = 0; j < Fset.length; j++) {\n K.set(i, Fset[j], L.get(i, j));\n }\n }\n\n // Finds any infeasible solutions\n let infeasIndex = [];\n for (let j = 0; j < Fset.length; j++) {\n for (let i = 0; i < l; i++) {\n if (L.get(i, j) < 0) {\n infeasIndex.push(j);\n break;\n }\n }\n }\n let Hset = selection(Fset, infeasIndex);\n\n // Makes infeasible solutions feasible (standard NNLS inner loop)\n if (Hset.length > 0) {\n let m = Hset.length;\n let alpha = Matrix.ones(l, m);\n\n while (m > 0 && iter < maxIterations) {\n iter++;\n\n alpha.mul(Infinity);\n\n // Finds indices of negative variables in passive set\n let hRowColIdx = [[], []]; // Indexes work in pairs, each pair reprensents a single element, first array is row index, second array is column index\n let negRowColIdx = [[], []]; // Same as before\n for (let j = 0; j < m; j++) {\n for (let i = 0; i < Pset[Hset[j]].length; i++) {\n if (K.get(Pset[Hset[j]][i], Hset[j]) < 0) {\n hRowColIdx[0].push(Pset[Hset[j]][i]); // i\n hRowColIdx[1].push(j);\n negRowColIdx[0].push(Pset[Hset[j]][i]); // i\n negRowColIdx[1].push(Hset[j]);\n } // Compared to matlab, here we keep the row/column indexing (we are not taking the linear indexing)\n }\n }\n\n for (let k = 0; k < hRowColIdx[0].length; k++) {\n // could be hRowColIdx[1].length as well\n alpha.set(\n hRowColIdx[0][k],\n hRowColIdx[1][k],\n D.get(negRowColIdx[0][k], negRowColIdx[1][k]) /\n (D.get(negRowColIdx[0][k], negRowColIdx[1][k]) -\n K.get(negRowColIdx[0][k], negRowColIdx[1][k])),\n );\n }\n\n let alphaMin = [];\n let minIdx = [];\n for (let j = 0; j < m; j++) {\n alphaMin[j] = alpha.minColumn(j);\n minIdx[j] = alpha.minColumnIndex(j)[0];\n }\n\n alphaMin = Matrix.rowVector(alphaMin);\n for (let i = 0; i < l; i++) {\n alpha.setSubMatrix(alphaMin, i, 0);\n }\n\n let E = new Matrix(l, m);\n E = D.subMatrixColumn(Hset).subtract(\n alpha\n .subMatrix(0, l - 1, 0, m - 1)\n .mul(D.subMatrixColumn(Hset).subtract(K.subMatrixColumn(Hset))),\n );\n for (let j = 0; j < m; j++) {\n D.setColumn(Hset[j], E.subMatrixColumn([j]));\n }\n\n let idx2zero = [minIdx, Hset];\n for (let k = 0; k < m; k++) {\n D.set(idx2zero[0][k], idx2zero[1][k], 0);\n }\n\n for (let j = 0; j < m; j++) {\n Pset[Hset[j]].splice(\n Pset[Hset[j]].findIndex((item) => item === minIdx[j]),\n 1,\n );\n }\n\n L = cssls(XtX, XtY.subMatrixColumn(Hset), selection(Pset, Hset), l, m);\n for (let j = 0; j < m; j++) {\n K.setColumn(Hset[j], L.subMatrixColumn([j]));\n }\n\n Hset = [];\n for (let j = 0; j < K.columns; j++) {\n for (let i = 0; i < l; i++) {\n if (K.get(i, j) < 0) {\n Hset.push(j);\n\n break;\n }\n }\n }\n m = Hset.length;\n }\n }\n\n let newParam = optimality(\n iter,\n maxIterations,\n XtX,\n XtY,\n Fset,\n Pset,\n W,\n K,\n l,\n p,\n D,\n );\n Pset = newParam.Pset;\n Fset = newParam.Fset;\n W = newParam.W;\n }\n\n return K;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport fcnnls from './fcnnls';\n\n/**\n * Fast Combinatorial Non-negative Least Squares with single Right Hand Side\n * @param {Matrix|number[][]} X\n * @param {number[]} y\n * @param {object} [options={}]\n * @param {boolean} [maxIterations] if true or empty maxIterations is set at 3 times the number of columns of X\n * @returns {Array} k\n */\nexport default function fcnnlsVector(X, y, options = {}) {\n if (Array.isArray(y) === false) {\n throw new TypeError('y must be a 1D Array');\n }\n let Y = Matrix.columnVector(y);\n let K = fcnnls(X, Y, options);\n let k = K.to1DArray();\n return k;\n}\n","module.exports = function(haystack, needle, comparator, low, high) {\n var mid, cmp;\n\n if(low === undefined)\n low = 0;\n\n else {\n low = low|0;\n if(low < 0 || low >= haystack.length)\n throw new RangeError(\"invalid lower bound\");\n }\n\n if(high === undefined)\n high = haystack.length - 1;\n\n else {\n high = high|0;\n if(high < low || high >= haystack.length)\n throw new RangeError(\"invalid upper bound\");\n }\n\n while(low <= high) {\n // The naive `low + high >>> 1` could fail for array lengths > 2**31\n // because `>>>` converts its operands to int32. `low + (high - low >>> 1)`\n // works for array lengths <= 2**32-1 which is also Javascript's max array\n // length.\n mid = low + ((high - low) >>> 1);\n cmp = +comparator(haystack[mid], needle, mid, haystack);\n\n // Too low.\n if(cmp < 0.0)\n low = mid + 1;\n\n // Too high.\n else if(cmp > 0.0)\n high = mid - 1;\n\n // Key found.\n else\n return mid;\n }\n\n // Key not found.\n return ~low;\n}\n","'use strict';\n\nfunction assertNumber(number) {\n\tif (typeof number !== 'number') {\n\t\tthrow new TypeError('Expected a number');\n\t}\n}\n\nexports.ascending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\n\tif (Number.isNaN(left)) {\n\t\treturn -1;\n\t}\n\n\tif (Number.isNaN(right)) {\n\t\treturn 1;\n\t}\n\n\treturn left - right;\n};\n\nexports.descending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\n\tif (Number.isNaN(left)) {\n\t\treturn 1;\n\t}\n\n\tif (Number.isNaN(right)) {\n\t\treturn -1;\n\t}\n\n\treturn right - left;\n};\n","import binarySearch from 'binary-search';\nimport { ascending } from 'num-sort';\n\nexport const largestPrime = 0x7fffffff;\n\nconst primeNumbers = [\n // chunk #0\n largestPrime, // 2^31-1\n\n // chunk #1\n 5,\n 11,\n 23,\n 47,\n 97,\n 197,\n 397,\n 797,\n 1597,\n 3203,\n 6421,\n 12853,\n 25717,\n 51437,\n 102877,\n 205759,\n 411527,\n 823117,\n 1646237,\n 3292489,\n 6584983,\n 13169977,\n 26339969,\n 52679969,\n 105359939,\n 210719881,\n 421439783,\n 842879579,\n 1685759167,\n\n // chunk #2\n 433,\n 877,\n 1759,\n 3527,\n 7057,\n 14143,\n 28289,\n 56591,\n 113189,\n 226379,\n 452759,\n 905551,\n 1811107,\n 3622219,\n 7244441,\n 14488931,\n 28977863,\n 57955739,\n 115911563,\n 231823147,\n 463646329,\n 927292699,\n 1854585413,\n\n // chunk #3\n 953,\n 1907,\n 3821,\n 7643,\n 15287,\n 30577,\n 61169,\n 122347,\n 244703,\n 489407,\n 978821,\n 1957651,\n 3915341,\n 7830701,\n 15661423,\n 31322867,\n 62645741,\n 125291483,\n 250582987,\n 501165979,\n 1002331963,\n 2004663929,\n\n // chunk #4\n 1039,\n 2081,\n 4177,\n 8363,\n 16729,\n 33461,\n 66923,\n 133853,\n 267713,\n 535481,\n 1070981,\n 2141977,\n 4283963,\n 8567929,\n 17135863,\n 34271747,\n 68543509,\n 137087021,\n 274174111,\n 548348231,\n 1096696463,\n\n // chunk #5\n 31,\n 67,\n 137,\n 277,\n 557,\n 1117,\n 2237,\n 4481,\n 8963,\n 17929,\n 35863,\n 71741,\n 143483,\n 286973,\n 573953,\n 1147921,\n 2295859,\n 4591721,\n 9183457,\n 18366923,\n 36733847,\n 73467739,\n 146935499,\n 293871013,\n 587742049,\n 1175484103,\n\n // chunk #6\n 599,\n 1201,\n 2411,\n 4831,\n 9677,\n 19373,\n 38747,\n 77509,\n 155027,\n 310081,\n 620171,\n 1240361,\n 2480729,\n 4961459,\n 9922933,\n 19845871,\n 39691759,\n 79383533,\n 158767069,\n 317534141,\n 635068283,\n 1270136683,\n\n // chunk #7\n 311,\n 631,\n 1277,\n 2557,\n 5119,\n 10243,\n 20507,\n 41017,\n 82037,\n 164089,\n 328213,\n 656429,\n 1312867,\n 2625761,\n 5251529,\n 10503061,\n 21006137,\n 42012281,\n 84024581,\n 168049163,\n 336098327,\n 672196673,\n 1344393353,\n\n // chunk #8\n 3,\n 7,\n 17,\n 37,\n 79,\n 163,\n 331,\n 673,\n 1361,\n 2729,\n 5471,\n 10949,\n 21911,\n 43853,\n 87719,\n 175447,\n 350899,\n 701819,\n 1403641,\n 2807303,\n 5614657,\n 11229331,\n 22458671,\n 44917381,\n 89834777,\n 179669557,\n 359339171,\n 718678369,\n 1437356741,\n\n // chunk #9\n 43,\n 89,\n 179,\n 359,\n 719,\n 1439,\n 2879,\n 5779,\n 11579,\n 23159,\n 46327,\n 92657,\n 185323,\n 370661,\n 741337,\n 1482707,\n 2965421,\n 5930887,\n 11861791,\n 23723597,\n 47447201,\n 94894427,\n 189788857,\n 379577741,\n 759155483,\n 1518310967,\n\n // chunk #10\n 379,\n 761,\n 1523,\n 3049,\n 6101,\n 12203,\n 24407,\n 48817,\n 97649,\n 195311,\n 390647,\n 781301,\n 1562611,\n 3125257,\n 6250537,\n 12501169,\n 25002389,\n 50004791,\n 100009607,\n 200019221,\n 400038451,\n 800076929,\n 1600153859,\n\n // chunk #11\n 13,\n 29,\n 59,\n 127,\n 257,\n 521,\n 1049,\n 2099,\n 4201,\n 8419,\n 16843,\n 33703,\n 67409,\n 134837,\n 269683,\n 539389,\n 1078787,\n 2157587,\n 4315183,\n 8630387,\n 17260781,\n 34521589,\n 69043189,\n 138086407,\n 276172823,\n 552345671,\n 1104691373,\n\n // chunk #12\n 19,\n 41,\n 83,\n 167,\n 337,\n 677,\n 1361,\n 2729,\n 5471,\n 10949,\n 21911,\n 43853,\n 87719,\n 175447,\n 350899,\n 701819,\n 1403641,\n 2807303,\n 5614657,\n 11229331,\n 22458671,\n 44917381,\n 89834777,\n 179669557,\n 359339171,\n 718678369,\n 1437356741,\n\n // chunk #13\n 53,\n 107,\n 223,\n 449,\n 907,\n 1823,\n 3659,\n 7321,\n 14653,\n 29311,\n 58631,\n 117269,\n 234539,\n 469099,\n 938207,\n 1876417,\n 3752839,\n 7505681,\n 15011389,\n 30022781,\n 60045577,\n 120091177,\n 240182359,\n 480364727,\n 960729461,\n 1921458943\n];\n\nprimeNumbers.sort(ascending);\n\nexport function nextPrime(value) {\n let index = binarySearch(primeNumbers, value, ascending);\n if (index < 0) {\n index = ~index;\n }\n return primeNumbers[index];\n}\n","import { largestPrime, nextPrime } from './primeFinder';\n\nconst FREE = 0;\nconst FULL = 1;\nconst REMOVED = 2;\n\nconst defaultInitialCapacity = 150;\nconst defaultMinLoadFactor = 1 / 6;\nconst defaultMaxLoadFactor = 2 / 3;\n\nexport default class HashTable {\n constructor(options = {}) {\n if (options instanceof HashTable) {\n this.table = options.table.slice();\n this.values = options.values.slice();\n this.state = options.state.slice();\n this.minLoadFactor = options.minLoadFactor;\n this.maxLoadFactor = options.maxLoadFactor;\n this.distinct = options.distinct;\n this.freeEntries = options.freeEntries;\n this.lowWaterMark = options.lowWaterMark;\n this.highWaterMark = options.maxLoadFactor;\n return;\n }\n\n const initialCapacity =\n options.initialCapacity === undefined\n ? defaultInitialCapacity\n : options.initialCapacity;\n if (initialCapacity < 0) {\n throw new RangeError(\n `initial capacity must not be less than zero: ${initialCapacity}`\n );\n }\n\n const minLoadFactor =\n options.minLoadFactor === undefined\n ? defaultMinLoadFactor\n : options.minLoadFactor;\n const maxLoadFactor =\n options.maxLoadFactor === undefined\n ? defaultMaxLoadFactor\n : options.maxLoadFactor;\n if (minLoadFactor < 0 || minLoadFactor >= 1) {\n throw new RangeError(`invalid minLoadFactor: ${minLoadFactor}`);\n }\n if (maxLoadFactor <= 0 || maxLoadFactor >= 1) {\n throw new RangeError(`invalid maxLoadFactor: ${maxLoadFactor}`);\n }\n if (minLoadFactor >= maxLoadFactor) {\n throw new RangeError(\n `minLoadFactor (${minLoadFactor}) must be smaller than maxLoadFactor (${maxLoadFactor})`\n );\n }\n\n let capacity = initialCapacity;\n // User wants to put at least capacity elements. We need to choose the size based on the maxLoadFactor to\n // avoid the need to rehash before this capacity is reached.\n // actualCapacity * maxLoadFactor >= capacity\n capacity = (capacity / maxLoadFactor) | 0;\n capacity = nextPrime(capacity);\n if (capacity === 0) capacity = 1;\n\n this.table = newArray(capacity);\n this.values = newArray(capacity);\n this.state = newArray(capacity);\n\n this.minLoadFactor = minLoadFactor;\n if (capacity === largestPrime) {\n this.maxLoadFactor = 1;\n } else {\n this.maxLoadFactor = maxLoadFactor;\n }\n\n this.distinct = 0;\n this.freeEntries = capacity;\n\n this.lowWaterMark = 0;\n this.highWaterMark = chooseHighWaterMark(capacity, this.maxLoadFactor);\n }\n\n clone() {\n return new HashTable(this);\n }\n\n get size() {\n return this.distinct;\n }\n\n get(key) {\n const i = this.indexOfKey(key);\n if (i < 0) return 0;\n return this.values[i];\n }\n\n set(key, value) {\n let i = this.indexOfInsertion(key);\n if (i < 0) {\n i = -i - 1;\n this.values[i] = value;\n return false;\n }\n\n if (this.distinct > this.highWaterMark) {\n const newCapacity = chooseGrowCapacity(\n this.distinct + 1,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n return this.set(key, value);\n }\n\n this.table[i] = key;\n this.values[i] = value;\n if (this.state[i] === FREE) this.freeEntries--;\n this.state[i] = FULL;\n this.distinct++;\n\n if (this.freeEntries < 1) {\n const newCapacity = chooseGrowCapacity(\n this.distinct + 1,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n }\n\n return true;\n }\n\n remove(key, noRehash) {\n const i = this.indexOfKey(key);\n if (i < 0) return false;\n\n this.state[i] = REMOVED;\n this.distinct--;\n\n if (!noRehash) this.maybeShrinkCapacity();\n\n return true;\n }\n\n delete(key, noRehash) {\n const i = this.indexOfKey(key);\n if (i < 0) return false;\n\n this.state[i] = FREE;\n this.distinct--;\n\n if (!noRehash) this.maybeShrinkCapacity();\n\n return true;\n }\n\n maybeShrinkCapacity() {\n if (this.distinct < this.lowWaterMark) {\n const newCapacity = chooseShrinkCapacity(\n this.distinct,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n }\n }\n\n containsKey(key) {\n return this.indexOfKey(key) >= 0;\n }\n\n indexOfKey(key) {\n const table = this.table;\n const state = this.state;\n const length = this.table.length;\n\n const hash = key & 0x7fffffff;\n let i = hash % length;\n let decrement = hash % (length - 2);\n if (decrement === 0) decrement = 1;\n\n while (state[i] !== FREE && (state[i] === REMOVED || table[i] !== key)) {\n i -= decrement;\n if (i < 0) i += length;\n }\n\n if (state[i] === FREE) return -1;\n return i;\n }\n\n containsValue(value) {\n return this.indexOfValue(value) >= 0;\n }\n\n indexOfValue(value) {\n const values = this.values;\n const state = this.state;\n\n for (var i = 0; i < state.length; i++) {\n if (state[i] === FULL && values[i] === value) {\n return i;\n }\n }\n\n return -1;\n }\n\n indexOfInsertion(key) {\n const table = this.table;\n const state = this.state;\n const length = table.length;\n\n const hash = key & 0x7fffffff;\n let i = hash % length;\n let decrement = hash % (length - 2);\n if (decrement === 0) decrement = 1;\n\n while (state[i] === FULL && table[i] !== key) {\n i -= decrement;\n if (i < 0) i += length;\n }\n\n if (state[i] === REMOVED) {\n const j = i;\n while (state[i] !== FREE && (state[i] === REMOVED || table[i] !== key)) {\n i -= decrement;\n if (i < 0) i += length;\n }\n if (state[i] === FREE) i = j;\n }\n\n if (state[i] === FULL) {\n return -i - 1;\n }\n\n return i;\n }\n\n ensureCapacity(minCapacity) {\n if (this.table.length < minCapacity) {\n const newCapacity = nextPrime(minCapacity);\n this.rehash(newCapacity);\n }\n }\n\n rehash(newCapacity) {\n const oldCapacity = this.table.length;\n\n if (newCapacity <= this.distinct) throw new Error('Unexpected');\n\n const oldTable = this.table;\n const oldValues = this.values;\n const oldState = this.state;\n\n const newTable = newArray(newCapacity);\n const newValues = newArray(newCapacity);\n const newState = newArray(newCapacity);\n\n this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor);\n this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor);\n\n this.table = newTable;\n this.values = newValues;\n this.state = newState;\n this.freeEntries = newCapacity - this.distinct;\n\n for (var i = 0; i < oldCapacity; i++) {\n if (oldState[i] === FULL) {\n var element = oldTable[i];\n var index = this.indexOfInsertion(element);\n newTable[index] = element;\n newValues[index] = oldValues[i];\n newState[index] = FULL;\n }\n }\n }\n\n forEachKey(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.table[i])) return false;\n }\n }\n return true;\n }\n\n forEachValue(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.values[i])) return false;\n }\n }\n return true;\n }\n\n forEachPair(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.table[i], this.values[i])) return false;\n }\n }\n return true;\n }\n}\n\nfunction chooseLowWaterMark(capacity, minLoad) {\n return (capacity * minLoad) | 0;\n}\n\nfunction chooseHighWaterMark(capacity, maxLoad) {\n return Math.min(capacity - 2, (capacity * maxLoad) | 0);\n}\n\nfunction chooseGrowCapacity(size, minLoad, maxLoad) {\n return nextPrime(\n Math.max(size + 1, ((4 * size) / (3 * minLoad + maxLoad)) | 0)\n );\n}\n\nfunction chooseShrinkCapacity(size, minLoad, maxLoad) {\n return nextPrime(\n Math.max(size + 1, ((4 * size) / (minLoad + 3 * maxLoad)) | 0)\n );\n}\n\nfunction newArray(size) {\n return Array(size).fill(0);\n}\n","import HashTable from 'ml-hash-table';\n\nexport class SparseMatrix {\n constructor(rows, columns, options = {}) {\n if (rows instanceof SparseMatrix) {\n // clone\n const other = rows;\n this._init(\n other.rows,\n other.columns,\n other.elements.clone(),\n other.threshold\n );\n return;\n }\n\n if (Array.isArray(rows)) {\n const matrix = rows;\n rows = matrix.length;\n options = columns || {};\n columns = matrix[0].length;\n this._init(rows, columns, new HashTable(options), options.threshold);\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n var value = matrix[i][j];\n if (this.threshold && Math.abs(value) < this.threshold) value = 0;\n if (value !== 0) {\n this.elements.set(i * columns + j, matrix[i][j]);\n }\n }\n }\n } else {\n this._init(rows, columns, new HashTable(options), options.threshold);\n }\n }\n\n _init(rows, columns, elements, threshold) {\n this.rows = rows;\n this.columns = columns;\n this.elements = elements;\n this.threshold = threshold || 0;\n }\n\n static eye(rows = 1, columns = rows) {\n const min = Math.min(rows, columns);\n const matrix = new SparseMatrix(rows, columns, { initialCapacity: min });\n for (var i = 0; i < min; i++) {\n matrix.set(i, i, 1);\n }\n return matrix;\n }\n\n clone() {\n return new SparseMatrix(this);\n }\n\n to2DArray() {\n const copy = new Array(this.rows);\n for (var i = 0; i < this.rows; i++) {\n copy[i] = new Array(this.columns);\n for (var j = 0; j < this.columns; j++) {\n copy[i][j] = this.get(i, j);\n }\n }\n return copy;\n }\n\n isSquare() {\n return this.rows === this.columns;\n }\n\n isSymmetric() {\n if (!this.isSquare()) return false;\n\n var symmetric = true;\n this.forEachNonZero((i, j, v) => {\n if (this.get(j, i) !== v) {\n symmetric = false;\n return false;\n }\n return v;\n });\n return symmetric;\n }\n\n /**\n * Search for the wither band in the main diagonals\n * @return {number}\n */\n bandWidth() {\n let min = this.columns;\n let max = -1;\n this.forEachNonZero((i, j, v) => {\n let diff = i - j;\n min = Math.min(min, diff);\n max = Math.max(max, diff);\n return v;\n });\n return max - min;\n }\n\n /**\n * Test if a matrix is consider banded using a threshold\n * @param {number} width\n * @return {boolean}\n */\n isBanded(width) {\n let bandWidth = this.bandWidth();\n return bandWidth <= width;\n }\n\n get cardinality() {\n return this.elements.size;\n }\n\n get size() {\n return this.rows * this.columns;\n }\n\n get(row, column) {\n return this.elements.get(row * this.columns + column);\n }\n\n set(row, column, value) {\n if (this.threshold && Math.abs(value) < this.threshold) value = 0;\n if (value === 0) {\n this.elements.remove(row * this.columns + column);\n } else {\n this.elements.set(row * this.columns + column, value);\n }\n return this;\n }\n\n mmul(other) {\n if (this.columns !== other.rows) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Number of columns of left matrix are not equal to number of rows of right matrix.'\n );\n }\n\n const m = this.rows;\n const p = other.columns;\n\n const result = new SparseMatrix(m, p);\n this.forEachNonZero((i, j, v1) => {\n other.forEachNonZero((k, l, v2) => {\n if (j === k) {\n result.set(i, l, result.get(i, l) + v1 * v2);\n }\n return v2;\n });\n return v1;\n });\n return result;\n }\n\n kroneckerProduct(other) {\n const m = this.rows;\n const n = this.columns;\n const p = other.rows;\n const q = other.columns;\n\n const result = new SparseMatrix(m * p, n * q, {\n initialCapacity: this.cardinality * other.cardinality\n });\n this.forEachNonZero((i, j, v1) => {\n other.forEachNonZero((k, l, v2) => {\n result.set(p * i + k, q * j + l, v1 * v2);\n return v2;\n });\n return v1;\n });\n return result;\n }\n\n forEachNonZero(callback) {\n this.elements.forEachPair((key, value) => {\n const i = (key / this.columns) | 0;\n const j = key % this.columns;\n let r = callback(i, j, value);\n if (r === false) return false; // stop iteration\n if (this.threshold && Math.abs(r) < this.threshold) r = 0;\n if (r !== value) {\n if (r === 0) {\n this.elements.remove(key, true);\n } else {\n this.elements.set(key, r);\n }\n }\n return true;\n });\n this.elements.maybeShrinkCapacity();\n return this;\n }\n\n getNonZeros() {\n const cardinality = this.cardinality;\n const rows = new Array(cardinality);\n const columns = new Array(cardinality);\n const values = new Array(cardinality);\n var idx = 0;\n this.forEachNonZero((i, j, value) => {\n rows[idx] = i;\n columns[idx] = j;\n values[idx] = value;\n idx++;\n return value;\n });\n return { rows, columns, values };\n }\n\n setThreshold(newThreshold) {\n if (newThreshold !== 0 && newThreshold !== this.threshold) {\n this.threshold = newThreshold;\n this.forEachNonZero((i, j, v) => v);\n }\n return this;\n }\n\n /**\n * @return {SparseMatrix} - New transposed sparse matrix\n */\n transpose() {\n let trans = new SparseMatrix(this.columns, this.rows, {\n initialCapacity: this.cardinality\n });\n this.forEachNonZero((i, j, value) => {\n trans.set(j, i, value);\n return value;\n });\n return trans;\n }\n}\n\nSparseMatrix.prototype.klass = 'Matrix';\n\nSparseMatrix.identity = SparseMatrix.eye;\nSparseMatrix.prototype.tensorProduct = SparseMatrix.prototype.kroneckerProduct;\n\n/*\n Add dynamically instance and static methods for mathematical operations\n */\n\nvar inplaceOperator = `\n(function %name%(value) {\n if (typeof value === 'number') return this.%name%S(value);\n return this.%name%M(value);\n})\n`;\n\nvar inplaceOperatorScalar = `\n(function %name%S(value) {\n this.forEachNonZero((i, j, v) => v %op% value);\n return this;\n})\n`;\n\nvar inplaceOperatorMatrix = `\n(function %name%M(matrix) {\n matrix.forEachNonZero((i, j, v) => {\n this.set(i, j, this.get(i, j) %op% v);\n return v;\n });\n return this;\n})\n`;\n\nvar staticOperator = `\n(function %name%(matrix, value) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%(value);\n})\n`;\n\nvar inplaceMethod = `\n(function %name%() {\n this.forEachNonZero((i, j, v) => %method%(v));\n return this;\n})\n`;\n\nvar staticMethod = `\n(function %name%(matrix) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%();\n})\n`;\n\nconst operators = [\n // Arithmetic operators\n ['+', 'add'],\n ['-', 'sub', 'subtract'],\n ['*', 'mul', 'multiply'],\n ['/', 'div', 'divide'],\n ['%', 'mod', 'modulus'],\n // Bitwise operators\n ['&', 'and'],\n ['|', 'or'],\n ['^', 'xor'],\n ['<<', 'leftShift'],\n ['>>', 'signPropagatingRightShift'],\n ['>>>', 'rightShift', 'zeroFillRightShift']\n];\n\nfor (const operator of operators) {\n for (let i = 1; i < operator.length; i++) {\n SparseMatrix.prototype[operator[i]] = eval(\n fillTemplateFunction(inplaceOperator, {\n name: operator[i],\n op: operator[0]\n })\n );\n SparseMatrix.prototype[`${operator[i]}S`] = eval(\n fillTemplateFunction(inplaceOperatorScalar, {\n name: `${operator[i]}S`,\n op: operator[0]\n })\n );\n SparseMatrix.prototype[`${operator[i]}M`] = eval(\n fillTemplateFunction(inplaceOperatorMatrix, {\n name: `${operator[i]}M`,\n op: operator[0]\n })\n );\n\n SparseMatrix[operator[i]] = eval(\n fillTemplateFunction(staticOperator, { name: operator[i] })\n );\n }\n}\n\nvar methods = [['~', 'not']];\n\n[\n 'abs',\n 'acos',\n 'acosh',\n 'asin',\n 'asinh',\n 'atan',\n 'atanh',\n 'cbrt',\n 'ceil',\n 'clz32',\n 'cos',\n 'cosh',\n 'exp',\n 'expm1',\n 'floor',\n 'fround',\n 'log',\n 'log1p',\n 'log10',\n 'log2',\n 'round',\n 'sign',\n 'sin',\n 'sinh',\n 'sqrt',\n 'tan',\n 'tanh',\n 'trunc'\n].forEach(function (mathMethod) {\n methods.push([`Math.${mathMethod}`, mathMethod]);\n});\n\nfor (const method of methods) {\n for (let i = 1; i < method.length; i++) {\n SparseMatrix.prototype[method[i]] = eval(\n fillTemplateFunction(inplaceMethod, {\n name: method[i],\n method: method[0]\n })\n );\n SparseMatrix[method[i]] = eval(\n fillTemplateFunction(staticMethod, { name: method[i] })\n );\n }\n}\n\nfunction fillTemplateFunction(template, values) {\n for (const i in values) {\n template = template.replace(new RegExp(`%${i}%`, 'g'), values[i]);\n }\n return template;\n}\n","export default function additiveSymmetric(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i]) * (a[i] + b[i])) / (a[i] * b[i]);\n }\n return 2 * d;\n}\n","export default function avg(a, b) {\n var ii = a.length;\n var max = 0;\n var ans = 0;\n var aux = 0;\n for (var i = 0; i < ii; i++) {\n aux = Math.abs(a[i] - b[i]);\n ans += aux;\n if (max < aux) {\n max = aux;\n }\n }\n return (max + ans) / 2;\n}\n","export default function bhattacharyya(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return -Math.log(ans);\n}\n","export default function canberra(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.abs(a[i] - b[i]) / (a[i] + b[i]);\n }\n return ans;\n}\n","export default function chebyshev(a, b) {\n var ii = a.length;\n var max = 0;\n var aux = 0;\n for (var i = 0; i < ii; i++) {\n aux = Math.abs(a[i] - b[i]);\n if (max < aux) {\n max = aux;\n }\n }\n return max;\n}\n","export default function clark(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.sqrt(\n ((a[i] - b[i]) * (a[i] - b[i])) / ((a[i] + b[i]) * (a[i] + b[i]))\n );\n }\n return 2 * d;\n}\n","export default function czekanowskiSimilarity(a, b) {\n var up = 0;\n var down = 0;\n for (var i = 0; i < a.length; i++) {\n up += Math.min(a[i], b[i]);\n down += a[i] + b[i];\n }\n return (2 * up) / down;\n}\n","import czekanowskiSimilarity from '../similarities/czekanowski';\n\nexport default function czekanowskiDistance(a, b) {\n return 1 - czekanowskiSimilarity(a, b);\n}\n","export default function dice(a, b) {\n var ii = a.length;\n var p = 0;\n var q1 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * a[i];\n q1 += b[i] * b[i];\n q2 += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return q2 / (p + q1);\n}\n","export default function divergence(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / ((a[i] + b[i]) * (a[i] + b[i]));\n }\n return 2 * d;\n}\n","export default function fidelity(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return ans;\n}\n","export default function gower(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.abs(a[i] - b[i]);\n }\n return ans / ii;\n}\n","export default function harmonicMean(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += (a[i] * b[i]) / (a[i] + b[i]);\n }\n return 2 * ans;\n}\n","export default function hellinger(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return 2 * Math.sqrt(1 - ans);\n}\n","export default function innerProduct(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * b[i];\n }\n return ans;\n}\n","export default function intersection(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.min(a[i], b[i]);\n }\n return 1 - ans;\n}\n","export default function jaccard(a, b) {\n var ii = a.length;\n var p1 = 0;\n var p2 = 0;\n var q1 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p1 += a[i] * b[i];\n p2 += a[i] * a[i];\n q1 += b[i] * b[i];\n q2 += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return q2 / (p2 + q1 - p1);\n}\n","export default function jeffreys(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += (a[i] - b[i]) * Math.log(a[i] / b[i]);\n }\n return ans;\n}\n","export default function jensenDifference(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n (a[i] * Math.log(a[i]) + b[i] * Math.log(b[i])) / 2 -\n ((a[i] + b[i]) / 2) * Math.log((a[i] + b[i]) / 2);\n }\n return ans;\n}\n","export default function jensenShannon(a, b) {\n var ii = a.length;\n var p = 0;\n var q = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * Math.log((2 * a[i]) / (a[i] + b[i]));\n q += b[i] * Math.log((2 * b[i]) / (a[i] + b[i]));\n }\n return (p + q) / 2;\n}\n","export default function kdivergence(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * Math.log((2 * a[i]) / (a[i] + b[i]));\n }\n return ans;\n}\n","export default function kulczynski(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += Math.min(a[i], b[i]);\n }\n return up / down;\n}\n","export default function kullbackLeibler(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * Math.log(a[i] / b[i]);\n }\n return ans;\n}\n","export default function kumarHassebrook(a, b) {\n var ii = a.length;\n var p = 0;\n var p2 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * b[i];\n p2 += a[i] * a[i];\n q2 += b[i] * b[i];\n }\n return p / (p2 + q2 - p);\n}\n","export default function kumarJohnson(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n Math.pow(a[i] * a[i] - b[i] * b[i], 2) / (2 * Math.pow(a[i] * b[i], 1.5));\n }\n return ans;\n}\n","export default function lorentzian(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.log(Math.abs(a[i] - b[i]) + 1);\n }\n return ans;\n}\n","export default function manhattan(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.abs(a[i] - b[i]);\n }\n return d;\n}\n","export default function matusita(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return Math.sqrt(2 - 2 * ans);\n}\n","export default function minkowski(a, b, p) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.pow(Math.abs(a[i] - b[i]), p);\n }\n return Math.pow(d, 1 / p);\n}\n","export default function motyka(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.min(a[i], b[i]);\n down += a[i] + b[i];\n }\n return 1 - up / down;\n}\n","export default function neyman(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / a[i];\n }\n return d;\n}\n","export default function pearson(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / b[i];\n }\n return d;\n}\n","export default function probabilisticSymmetric(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / (a[i] + b[i]);\n }\n return 2 * d;\n}\n","export default function ruzicka(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.min(a[i], b[i]);\n down += Math.max(a[i], b[i]);\n }\n return up / down;\n}\n","export default function soergel(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += Math.max(a[i], b[i]);\n }\n return up / down;\n}\n","export default function sorensen(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += a[i] + b[i];\n }\n return up / down;\n}\n","export default function squared(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / (a[i] + b[i]);\n }\n return d;\n}\n","export default function squaredChord(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n (Math.sqrt(a[i]) - Math.sqrt(b[i])) * (Math.sqrt(a[i]) - Math.sqrt(b[i]));\n }\n return ans;\n}\n","export default function taneja(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n ((a[i] + b[i]) / 2) *\n Math.log((a[i] + b[i]) / (2 * Math.sqrt(a[i] * b[i])));\n }\n return ans;\n}\n","export default function tanimoto(a, b, bitvector) {\n if (bitvector) {\n var inter = 0;\n var union = 0;\n for (var j = 0; j < a.length; j++) {\n inter += a[j] && b[j];\n union += a[j] || b[j];\n }\n if (union === 0) {\n return 1;\n }\n return inter / union;\n } else {\n var ii = a.length;\n var p = 0;\n var q = 0;\n var m = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i];\n q += b[i];\n m += Math.min(a[i], b[i]);\n }\n return 1 - (p + q - 2 * m) / (p + q - m);\n }\n}\n","import tanimotoS from '../similarities/tanimoto';\n\nexport default function tanimoto(a, b, bitvector) {\n if (bitvector) {\n return 1 - tanimotoS(a, b, bitvector);\n } else {\n var ii = a.length;\n var p = 0;\n var q = 0;\n var m = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i];\n q += b[i];\n m += Math.min(a[i], b[i]);\n }\n return (p + q - 2 * m) / (p + q - m);\n }\n}\n","export default function topsoe(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n a[i] * Math.log((2 * a[i]) / (a[i] + b[i])) +\n b[i] * Math.log((2 * b[i]) / (a[i] + b[i]));\n }\n return ans;\n}\n","export default function waveHedges(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += 1 - Math.min(a[i], b[i]) / Math.max(a[i], b[i]);\n }\n return ans;\n}\n","import binarySearch from 'binary-search';\nimport { ascending } from 'num-sort';\n\n/**\n * Function that creates the tree\n * @param {Array>} spectrum\n * @param {object} [options]\n * @return {Tree|null}\n * left and right have the same structure than the parent,\n * or are null if they are leaves\n */\nexport function createTree(spectrum, options = {}) {\n var X = spectrum[0];\n const {\n minWindow = 0.16,\n threshold = 0.01,\n from = X[0],\n to = X[X.length - 1]\n } = options;\n\n return mainCreateTree(\n spectrum[0],\n spectrum[1],\n from,\n to,\n minWindow,\n threshold\n );\n}\n\nfunction mainCreateTree(X, Y, from, to, minWindow, threshold) {\n if (to - from < minWindow) {\n return null;\n }\n\n // search first point\n var start = binarySearch(X, from, ascending);\n if (start < 0) {\n start = ~start;\n }\n\n // stop at last point\n var sum = 0;\n var center = 0;\n for (var i = start; i < X.length; i++) {\n if (X[i] >= to) {\n break;\n }\n sum += Y[i];\n center += X[i] * Y[i];\n }\n\n if (sum < threshold) {\n return null;\n }\n\n center /= sum;\n if (center - from < 1e-6 || to - center < 1e-6) {\n return null;\n }\n if (center - from < minWindow / 4) {\n return mainCreateTree(X, Y, center, to, minWindow, threshold);\n } else {\n if (to - center < minWindow / 4) {\n return mainCreateTree(X, Y, from, center, minWindow, threshold);\n } else {\n return new Tree(\n sum,\n center,\n mainCreateTree(X, Y, from, center, minWindow, threshold),\n mainCreateTree(X, Y, center, to, minWindow, threshold)\n );\n }\n }\n}\n\nclass Tree {\n constructor(sum, center, left, right) {\n this.sum = sum;\n this.center = center;\n this.left = left;\n this.right = right;\n }\n}\n","import { createTree } from './createTree';\n\n/**\n * Similarity between two nodes\n * @param {Tree|Array>} a - tree A node\n * @param {Tree|Array>} b - tree B node\n * @param {object} [options]\n * @return {number} similarity measure between tree nodes\n */\nexport function getSimilarity(a, b, options = {}) {\n const { alpha = 0.1, beta = 0.33, gamma = 0.001 } = options;\n\n if (a === null || b === null) {\n return 0;\n }\n if (Array.isArray(a)) {\n a = createTree(a);\n }\n if (Array.isArray(b)) {\n b = createTree(b);\n }\n\n var C =\n (alpha * Math.min(a.sum, b.sum)) / Math.max(a.sum, b.sum) +\n (1 - alpha) * Math.exp(-gamma * Math.abs(a.center - b.center));\n\n return (\n beta * C +\n ((1 - beta) *\n (getSimilarity(a.left, b.left, options) +\n getSimilarity(a.right, b.right, options))) /\n 2\n );\n}\n","import { getSimilarity } from './getSimilarity';\n\nexport { createTree } from './createTree';\n\nexport function treeSimilarity(A, B, options = {}) {\n return getSimilarity(A, B, options);\n}\n\nexport function getFunction(options = {}) {\n return (A, B) => getSimilarity(A, B, options);\n}\n","export default function cosine(a, b) {\n var ii = a.length;\n var p = 0;\n var p2 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * b[i];\n p2 += a[i] * a[i];\n q2 += b[i] * b[i];\n }\n return p / (Math.sqrt(p2) * Math.sqrt(q2));\n}\n","import diceD from '../distances/dice';\n\nexport default function dice(a, b) {\n return 1 - diceD(a, b);\n}\n","import intersectionD from '../distances/intersection';\n\nexport default function intersection(a, b) {\n return 1 - intersectionD(a, b);\n}\n","import jaccardD from '../distances/jaccard';\n\nexport default function jaccard(a, b) {\n return 1 - jaccardD(a, b);\n}\n","import kulczynskiD from '../distances/kulczynski';\n\nexport default function kulczynski(a, b) {\n return 1 / kulczynskiD(a, b);\n}\n","import motykaD from '../distances/motyka';\n\nexport default function motyka(a, b) {\n return 1 - motykaD(a, b);\n}\n","import mean from 'ml-array-mean';\n\nimport cosine from './cosine';\n\nexport default function pearson(a, b) {\n var avgA = mean(a);\n var avgB = mean(b);\n\n var newA = new Array(a.length);\n var newB = new Array(b.length);\n for (var i = 0; i < newA.length; i++) {\n newA[i] = a[i] - avgA;\n newB[i] = b[i] - avgB;\n }\n\n return cosine(newA, newB);\n}\n","import squaredChordD from '../distances/squaredChord';\n\nexport default function squaredChord(a, b) {\n return 1 - squaredChordD(a, b);\n}\n","'use strict';\n\n// Accuracy\nexports.acc = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.tn[i] + pred.tp[i]) / (l - 1);\n }\n return result;\n};\n\n// Error rate\nexports.err = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.fp[i] / (l - 1));\n }\n return result;\n};\n\n// False positive rate\nexports.fpr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.fp[i] / pred.nNeg;\n }\n return result;\n};\n\n// True positive rate\nexports.tpr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.tp[i] / pred.nPos;\n }\n return result;\n};\n\n// False negative rate\nexports.fnr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.fn[i] / pred.nPos;\n }\n return result;\n};\n\n// True negative rate\nexports.tnr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.tn[i] / pred.nNeg;\n }\n return result;\n};\n\n// Positive predictive value\nexports.ppv = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fp[i] + pred.tp[i] !== 0) ? (pred.tp[i] / (pred.fp[i] + pred.tp[i])) : 0;\n }\n return result;\n};\n\n// Negative predictive value\nexports.npv = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.tn[i] !== 0) ? (pred.tn[i] / (pred.fn[i] + pred.tn[i])) : 0;\n }\n return result;\n};\n\n// Prediction conditioned fallout\nexports.pcfall = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fp[i] + pred.tp[i] !== 0) ? 1 - (pred.tp[i] / (pred.fp[i] + pred.tp[i])) : 1;\n }\n return result;\n};\n\n// Prediction conditioned miss\nexports.pcmiss = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.tn[i] !== 0) ? 1 - (pred.tn[i] / (pred.fn[i] + pred.tn[i])) : 1;\n }\n return result;\n};\n\n// Lift value\nexports.lift = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.nPosPred[i] !== 0) ? ((pred.tp[i] / pred.nPos) / (pred.nPosPred[i] / pred.nSamples)) : 0;\n }\n return result;\n};\n\n// Rate of positive predictions\nexports.rpp = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.nPosPred[i] / pred.nSamples;\n }\n return result;\n};\n\n// Rate of negative predictions\nexports.rnp = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.nNegPred[i] / pred.nSamples;\n }\n return result;\n};\n\n// Threshold\nexports.threshold = pred => {\n const clone = pred.cutoffs.slice();\n clone[0] = clone[1]; // Remove the infinite value\n return clone;\n};\n","'use strict';\n\nconst measures = require('./measures');\n\nclass Performance {\n /**\n *\n * @param prediction - The prediction matrix\n * @param target - The target matrix (values: truthy for same class, falsy for different class)\n * @param options\n *\n * @option all True if the entire matrix must be used. False to ignore the diagonal and lower part (default is false, for similarity/distance matrices)\n * @option max True if the max value corresponds to a perfect match (like in similarity matrices), false if it is the min value (default is false, like in distance matrices. All values will be multiplied by -1)\n */\n constructor(prediction, target, options) {\n options = options || {};\n if (prediction.length !== target.length || prediction[0].length !== target[0].length) {\n throw new Error('dimensions of prediction and target do not match');\n }\n const rows = prediction.length;\n const columns = prediction[0].length;\n const isDistance = !options.max;\n\n const predP = [];\n\n if (options.all) {\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n predP.push({\n pred: prediction[i][j],\n targ: target[i][j]\n });\n }\n }\n } else {\n if (rows < 3 || rows !== columns) {\n throw new Error('When \"all\" option is false, the prediction matrix must be square and have at least 3 columns');\n }\n for (var i = 0; i < rows - 1; i++) {\n for (var j = i + 1; j < columns; j++) {\n predP.push({\n pred: prediction[i][j],\n targ: target[i][j]\n });\n }\n }\n }\n\n if (isDistance) {\n predP.sort((a, b) => a.pred - b.pred);\n } else {\n predP.sort((a, b) => b.pred - a.pred);\n }\n \n const cutoffs = this.cutoffs = [isDistance ? Number.MIN_VALUE : Number.MAX_VALUE];\n const fp = this.fp = [0];\n const tp = this.tp = [0];\n\n var nPos = 0;\n var nNeg = 0;\n\n var currentPred = predP[0].pred;\n var nTp = 0;\n var nFp = 0;\n for (var i = 0; i < predP.length; i++) {\n if (predP[i].pred !== currentPred) {\n cutoffs.push(currentPred);\n fp.push(nFp);\n tp.push(nTp);\n currentPred = predP[i].pred;\n }\n if (predP[i].targ) {\n nPos++;\n nTp++;\n } else {\n nNeg++;\n nFp++;\n }\n }\n cutoffs.push(currentPred);\n fp.push(nFp);\n tp.push(nTp);\n\n const l = cutoffs.length;\n const fn = this.fn = new Array(l);\n const tn = this.tn = new Array(l);\n const nPosPred = this.nPosPred = new Array(l);\n const nNegPred = this.nNegPred = new Array(l);\n\n for (var i = 0; i < l; i++) {\n fn[i] = nPos - tp[i];\n tn[i] = nNeg - fp[i];\n\n nPosPred[i] = tp[i] + fp[i];\n nNegPred[i] = tn[i] + fn[i];\n }\n\n this.nPos = nPos;\n this.nNeg = nNeg;\n this.nSamples = nPos + nNeg;\n }\n\n /**\n * Computes a measure from the prediction object.\n *\n * Many measures are available and can be combined :\n * To create a ROC curve, you need fpr and tpr\n * To create a DET curve, you need fnr and fpr\n * To create a Lift chart, you need rpp and lift\n *\n * Possible measures are : threshold (Threshold), acc (Accuracy), err (Error rate),\n * fpr (False positive rate), tpr (True positive rate), fnr (False negative rate), tnr (True negative rate), ppv (Positive predictive value),\n * npv (Negative predictive value), pcfall (Prediction-conditioned fallout), pcmiss (Prediction-conditioned miss), lift (Lift value), rpp (Rate of positive predictions), rnp (Rate of negative predictions)\n *\n * @param measure - The short name of the measure\n *\n * @return [number]\n */\n getMeasure(measure) {\n if (typeof measure !== 'string') {\n throw new Error('No measure specified');\n }\n if (!measures[measure]) {\n throw new Error(`The specified measure (${measure}) does not exist`);\n }\n return measures[measure](this);\n }\n\n /**\n * Returns the area under the ROC curve\n */\n getAURC() {\n const l = this.cutoffs.length;\n const x = new Array(l);\n const y = new Array(l);\n for (var i = 0; i < l; i++) {\n x[i] = this.fp[i] / this.nNeg;\n y[i] = this.tp[i] / this.nPos;\n }\n var auc = 0;\n for (i = 1; i < l; i++) {\n auc += 0.5 * (x[i] - x[i - 1]) * (y[i] + y[i - 1]);\n }\n return auc;\n }\n\n /**\n * Returns the area under the DET curve\n */\n getAUDC() {\n const l = this.cutoffs.length;\n const x = new Array(l);\n const y = new Array(l);\n for (var i = 0; i < l; i++) {\n x[i] = this.fn[i] / this.nPos;\n y[i] = this.fp[i] / this.nNeg;\n }\n var auc = 0;\n for (i = 1; i < l; i++) {\n auc += 0.5 * (x[i] + x[i - 1]) * (y[i] - y[i - 1]);\n }\n return auc;\n }\n\n getDistribution(options) {\n options = options || {};\n var cutLength = this.cutoffs.length;\n var cutLow = options.xMin || Math.floor(this.cutoffs[cutLength - 1] * 100) / 100;\n var cutHigh = options.xMax || Math.ceil(this.cutoffs[1] * 100) / 100;\n var interval = options.interval || Math.floor(((cutHigh - cutLow) / 20 * 10000000) - 1) / 10000000; // Trick to avoid the precision problem of float numbers\n\n var xLabels = [];\n var interValues = [];\n var intraValues = [];\n var interCumPercent = [];\n var intraCumPercent = [];\n\n var nTP = this.tp[cutLength - 1], currentTP = 0;\n var nFP = this.fp[cutLength - 1], currentFP = 0;\n\n for (var i = cutLow, j = (cutLength - 1); i <= cutHigh; i += interval) {\n while (this.cutoffs[j] < i)\n j--;\n\n xLabels.push(i);\n\n var thisTP = nTP - currentTP - this.tp[j];\n var thisFP = nFP - currentFP - this.fp[j];\n\n currentTP += thisTP;\n currentFP += thisFP;\n\n interValues.push(thisFP);\n intraValues.push(thisTP);\n\n interCumPercent.push(100 - (nFP - this.fp[j]) / nFP * 100);\n intraCumPercent.push(100 - (nTP - this.tp[j]) / nTP * 100);\n }\n\n return {\n xLabels: xLabels,\n interValues: interValues,\n intraValues: intraValues,\n interCumPercent: interCumPercent,\n intraCumPercent: intraCumPercent\n };\n }\n}\n\nPerformance.names = {\n acc: 'Accuracy',\n err: 'Error rate',\n fpr: 'False positive rate',\n tpr: 'True positive rate',\n fnr: 'False negative rate',\n tnr: 'True negative rate',\n ppv: 'Positive predictive value',\n npv: 'Negative predictive value',\n pcfall: 'Prediction-conditioned fallout',\n pcmiss: 'Prediction-conditioned miss',\n lift: 'Lift value',\n rpp: 'Rate of positive predictions',\n rnp: 'Rate of negative predictions',\n threshold: 'Threshold'\n};\n\nmodule.exports = Performance;\n","'use strict';\n\nvar defaultOptions = {\n size: 1,\n value: 0\n};\n\n/**\n * Case when the entry is an array\n * @param data\n * @param options\n * @returns {Array}\n */\nfunction arrayCase(data, options) {\n var len = data.length;\n if (typeof options.size === 'number') {\n options.size = [options.size, options.size];\n }\n\n var cond = len + options.size[0] + options.size[1];\n\n var output;\n if (options.output) {\n if (options.output.length !== cond) {\n throw new RangeError('Wrong output size');\n }\n output = options.output;\n } else {\n output = new Array(cond);\n }\n\n var i;\n if (options.value === 'circular') {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) {\n output[i] = data[(len - (options.size[0] % len) + i) % len];\n } else if (i < options.size[0] + len) {\n output[i] = data[i - options.size[0]];\n } else {\n output[i] = data[(i - options.size[0]) % len];\n }\n }\n } else if (options.value === 'replicate') {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = data[0];\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = data[len - 1];\n }\n } else if (options.value === 'symmetric') {\n if (options.size[0] > len || options.size[1] > len) {\n throw new RangeError(\n 'expanded value should not be bigger than the data length'\n );\n }\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = data[options.size[0] - 1 - i];\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = data[2 * len + options.size[0] - i - 1];\n }\n } else {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = options.value;\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = options.value;\n }\n }\n\n return output;\n}\n\n/**\n * Case when the entry is a matrix\n * @param data\n * @param options\n * @returns {Array}\n */\nfunction matrixCase(data, options) {\n // var row = data.length;\n // var col = data[0].length;\n if (options.size[0] === undefined) {\n options.size = [options.size, options.size, options.size, options.size];\n }\n throw new Error('matrix not supported yet, sorry');\n}\n\n/**\n * Pads and array\n * @param {Array } data\n * @param {object} options\n */\nfunction padArray(data, options) {\n options = Object.assign({}, defaultOptions, options);\n if (Array.isArray(data)) {\n if (Array.isArray(data[0])) return matrixCase(data, options);\n else return arrayCase(data, options);\n } else {\n throw new TypeError('data should be an array');\n }\n}\n\nmodule.exports = padArray;\n","import { Matrix, MatrixTransposeView, inverse } from 'ml-matrix';\nimport padArray from 'ml-pad-array';\n\n/**\n * Factorial of a number\n * @ignore\n * @param n\n * @return {number}\n */\nfunction factorial(n) {\n let r = 1;\n while (n > 0) r *= n--;\n return r;\n}\n\nconst defaultOptions = {\n windowSize: 5,\n derivative: 1,\n polynomial: 2,\n pad: 'none',\n padValue: 'replicate',\n};\n\n/**\n * Savitzky-Golay filter\n * @param {Array } data\n * @param {number} h\n * @param {Object} options\n * @returns {Array}\n */\nexport default function savitzkyGolay(data, h, options) {\n options = Object.assign({}, defaultOptions, options);\n if (\n options.windowSize % 2 === 0 ||\n options.windowSize < 5 ||\n !Number.isInteger(options.windowSize)\n ) {\n throw new RangeError(\n 'Invalid window size (should be odd and at least 5 integer number)',\n );\n }\n if (options.derivative < 0 || !Number.isInteger(options.derivative)) {\n throw new RangeError('Derivative should be a positive integer');\n }\n if (options.polynomial < 1 || !Number.isInteger(options.polynomial)) {\n throw new RangeError('Polynomial should be a positive integer');\n }\n\n let C, norm;\n let step = Math.floor(options.windowSize / 2);\n\n if (options.pad === 'pre') {\n data = padArray(data, { size: step, value: options.padValue });\n }\n\n let ans = new Array(data.length - 2 * step);\n\n if (\n options.windowSize === 5 &&\n options.polynomial === 2 &&\n (options.derivative === 1 || options.derivative === 2)\n ) {\n if (options.derivative === 1) {\n C = [-2, -1, 0, 1, 2];\n norm = 10;\n } else {\n C = [2, -1, -2, -1, 2];\n norm = 7;\n }\n } else {\n let J = Matrix.ones(options.windowSize, options.polynomial + 1);\n let inic = -(options.windowSize - 1) / 2;\n for (let i = 0; i < J.rows; i++) {\n for (let j = 0; j < J.columns; j++) {\n if (inic + 1 !== 0 || j !== 0) J.set(i, j, Math.pow(inic + i, j));\n }\n }\n let Jtranspose = new MatrixTransposeView(J);\n let Jinv = inverse(Jtranspose.mmul(J));\n C = Jinv.mmul(Jtranspose);\n C = C.getRow(options.derivative);\n norm = 1 / factorial(options.derivative);\n }\n let det = norm * Math.pow(h, options.derivative);\n for (let k = step; k < data.length - step; k++) {\n let d = 0;\n for (let l = 0; l < C.length; l++) d += (C[l] * data[l + k - step]) / det;\n ans[k - step] = d;\n }\n\n if (options.pad === 'post') {\n ans = padArray(ans, { size: step, value: options.padValue });\n }\n\n return ans;\n}\n","// auxiliary file to create the 256 look at table elements\n\nvar ans = new Array(256);\nfor (var i = 0; i < 256; i++) {\n var num = i;\n var c = 0;\n while (num) {\n num = num & (num - 1);\n c++;\n }\n ans[i] = c;\n}\n\nmodule.exports = ans;","'use strict';\n\nvar eightBits = require('./creator');\n\n/**\n * Count the number of true values in an array\n * @param {Array} arr\n * @return {number}\n */\nfunction count(arr) {\n var c = 0;\n for (var i = 0; i < arr.length; i++) {\n c += eightBits[arr[i] & 0xff] + eightBits[(arr[i] >> 8) & 0xff] + eightBits[(arr[i] >> 16) & 0xff] + eightBits[(arr[i] >> 24) & 0xff];\n }\n return c;\n}\n\n/**\n * Logical AND operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction and(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] & arr2[i];\n return ans;\n}\n\n/**\n * Logical OR operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction or(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] | arr2[i];\n return ans;\n}\n\n/**\n * Logical XOR operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction xor(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] ^ arr2[i];\n return ans;\n}\n\n/**\n * Logical NOT operation\n * @param {Array} arr\n * @return {Array}\n */\nfunction not(arr) {\n var ans = new Array(arr.length);\n for (var i = 0; i < ans.length; i++)\n ans[i] = ~arr[i];\n return ans;\n}\n\n/**\n * Gets the n value of array arr\n * @param {Array} arr\n * @param {number} n\n * @return {boolean}\n */\nfunction getBit(arr, n) {\n var index = n >> 5; // Same as Math.floor(n/32)\n var mask = 1 << (31 - n % 32);\n return Boolean(arr[index] & mask);\n}\n\n/**\n * Sets the n value of array arr to the value val\n * @param {Array} arr\n * @param {number} n\n * @param {boolean} val\n * @return {Array}\n */\nfunction setBit(arr, n, val) {\n var index = n >> 5; // Same as Math.floor(n/32)\n var mask = 1 << (31 - n % 32);\n if (val)\n arr[index] = mask | arr[index];\n else\n arr[index] = ~mask & arr[index];\n return arr;\n}\n\n/**\n * Translates an array of numbers to a string of bits\n * @param {Array} arr\n * @returns {string}\n */\nfunction toBinaryString(arr) {\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n var obj = (arr[i] >>> 0).toString(2);\n str += '00000000000000000000000000000000'.substr(obj.length) + obj;\n }\n return str;\n}\n\n/**\n * Creates an array of numbers based on a string of bits\n * @param {string} str\n * @returns {Array}\n */\nfunction parseBinaryString(str) {\n var len = str.length / 32;\n var ans = new Array(len);\n for (var i = 0; i < len; i++) {\n ans[i] = parseInt(str.substr(i*32, 32), 2) | 0;\n }\n return ans;\n}\n\n/**\n * Translates an array of numbers to a hex string\n * @param {Array} arr\n * @returns {string}\n */\nfunction toHexString(arr) {\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n var obj = (arr[i] >>> 0).toString(16);\n str += '00000000'.substr(obj.length) + obj;\n }\n return str;\n}\n\n/**\n * Creates an array of numbers based on a hex string\n * @param {string} str\n * @returns {Array}\n */\nfunction parseHexString(str) {\n var len = str.length / 8;\n var ans = new Array(len);\n for (var i = 0; i < len; i++) {\n ans[i] = parseInt(str.substr(i*8, 8), 16) | 0;\n }\n return ans;\n}\n\n/**\n * Creates a human readable string of the array\n * @param {Array} arr\n * @returns {string}\n */\nfunction toDebug(arr) {\n var binary = toBinaryString(arr);\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n str += '0000'.substr((i * 32).toString(16).length) + (i * 32).toString(16) + ':';\n for (var j = 0; j < 32; j += 4) {\n str += ' ' + binary.substr(i * 32 + j, 4);\n }\n if (i < arr.length - 1) str += '\\n';\n }\n return str\n}\n\nmodule.exports = {\n count: count,\n and: and,\n or: or,\n xor: xor,\n not: not,\n getBit: getBit,\n setBit: setBit,\n toBinaryString: toBinaryString,\n parseBinaryString: parseBinaryString,\n toHexString: toHexString,\n parseHexString: parseHexString,\n toDebug: toDebug\n};\n","export default function SavitzkyGolay(data, h, options = {}) {\n let { windowSize = 9, derivative = 0, polynomial = 3 } = options;\n\n if (windowSize % 2 === 0 || windowSize < 5 || !Number.isInteger(windowSize)) {\n throw new RangeError(\n 'Invalid window size (should be odd and at least 5 integer number)',\n );\n }\n if (windowSize > data.length) {\n throw new RangeError(\n `Window size is higher than the data length ${windowSize}>${data.length}`,\n );\n }\n if (derivative < 0 || !Number.isInteger(derivative)) {\n throw new RangeError('Derivative should be a positive integer');\n }\n if (polynomial < 1 || !Number.isInteger(polynomial)) {\n throw new RangeError('Polynomial should be a positive integer');\n }\n if (polynomial >= 6) {\n // eslint-disable-next-line no-console\n console.warn(\n 'You should not use polynomial grade higher than 5 if you are' +\n ' not sure that your data arises from such a model. Possible polynomial oscillation problems',\n );\n }\n\n let half = Math.floor(windowSize / 2);\n let np = data.length;\n let ans = new Array(np);\n let weights = fullWeights(windowSize, polynomial, derivative);\n let hs = 0;\n let constantH = true;\n if (Array.isArray(h)) {\n constantH = false;\n } else {\n hs = Math.pow(h, derivative);\n }\n\n //For the borders\n for (let i = 0; i < half; i++) {\n let wg1 = weights[half - i - 1];\n let wg2 = weights[half + i + 1];\n let d1 = 0;\n let d2 = 0;\n for (let l = 0; l < windowSize; l++) {\n d1 += wg1[l] * data[l];\n d2 += wg2[l] * data[np - windowSize + l];\n }\n if (constantH) {\n ans[half - i - 1] = d1 / hs;\n ans[np - half + i] = d2 / hs;\n } else {\n hs = getHs(h, half - i - 1, half, derivative);\n ans[half - i - 1] = d1 / hs;\n hs = getHs(h, np - half + i, half, derivative);\n ans[np - half + i] = d2 / hs;\n }\n }\n\n //For the internal points\n let wg = weights[half];\n for (let i = windowSize; i <= np; i++) {\n let d = 0;\n for (let l = 0; l < windowSize; l++) d += wg[l] * data[l + i - windowSize];\n if (!constantH) hs = getHs(h, i - half - 1, half, derivative);\n ans[i - half - 1] = d / hs;\n }\n return ans;\n}\n\nfunction getHs(h, center, half, derivative) {\n let hs = 0;\n let count = 0;\n for (let i = center - half; i < center + half; i++) {\n if (i >= 0 && i < h.length - 1) {\n hs += h[i + 1] - h[i];\n count++;\n }\n }\n return Math.pow(hs / count, derivative);\n}\n\nfunction GramPoly(i, m, k, s) {\n let Grampoly = 0;\n if (k > 0) {\n Grampoly =\n ((4 * k - 2) / (k * (2 * m - k + 1))) *\n (i * GramPoly(i, m, k - 1, s) + s * GramPoly(i, m, k - 1, s - 1)) -\n (((k - 1) * (2 * m + k)) / (k * (2 * m - k + 1))) *\n GramPoly(i, m, k - 2, s);\n } else {\n if (k === 0 && s === 0) {\n Grampoly = 1;\n } else {\n Grampoly = 0;\n }\n }\n return Grampoly;\n}\n\nfunction GenFact(a, b) {\n let gf = 1;\n if (a >= b) {\n for (let j = a - b + 1; j <= a; j++) {\n gf *= j;\n }\n }\n return gf;\n}\n\nfunction Weight(i, t, m, n, s) {\n let sum = 0;\n for (let k = 0; k <= n; k++) {\n //console.log(k);\n sum +=\n (2 * k + 1) *\n (GenFact(2 * m, k) / GenFact(2 * m + k + 1, k + 1)) *\n GramPoly(i, m, k, 0) *\n GramPoly(t, m, k, s);\n }\n return sum;\n}\n\n/**\n *\n * @param m Number of points\n * @param n Polynomial grade\n * @param s Derivative\n */\nfunction fullWeights(m, n, s) {\n let weights = new Array(m);\n let np = Math.floor(m / 2);\n for (let t = -np; t <= np; t++) {\n weights[t + np] = new Array(m);\n for (let j = -np; j <= np; j++) {\n weights[t + np][j + np] = Weight(j, t, np, n, s);\n }\n }\n return weights;\n}\n\n/*function entropy(data,h,options){\n var trend = SavitzkyGolay(data,h,trendOptions);\n var copy = new Array(data.length);\n var sum = 0;\n var max = 0;\n for(var i=0;i} x - Independent variable\n * @param {Array} yIn - Dependent variable\n * @param {object} [options] - Options object\n * @param {object} [options.sgOptions] - Options object for Savitzky-Golay filter. See https://github.com/mljs/savitzky-golay-generalized#options\n * @param {number} [options.sgOptions.windowSize = 9] - points to use in the approximations\n * @param {number} [options.sgOptions.polynomial = 3] - degree of the polynomial to use in the approximations\n * @param {number} [options.minMaxRatio = 0.00025] - Threshold to determine if a given peak should be considered as a noise\n * @param {number} [options.broadRatio = 0.00] - If `broadRatio` is higher than 0, then all the peaks which second derivative\n * smaller than `broadRatio * maxAbsSecondDerivative` will be marked with the soft mask equal to true.\n * @param {number} [options.noiseLevel = 0] - Noise threshold in spectrum units\n * @param {boolean} [options.maxCriteria = true] - Peaks are local maximum(true) or minimum(false)\n * @param {boolean} [options.smoothY = true] - Select the peak intensities from a smoothed version of the independent variables\n * @param {boolean} [options.realTopDetection = false] - Use a quadratic optimizations with the peak and its 3 closest neighbors\n * to determine the true x,y values of the peak?\n * @param {number} [options.heightFactor = 0] - Factor to multiply the calculated height (usually 2)\n * @param {number} [options.derivativeThreshold = -1] - Filters based on the amplitude of the first derivative\n * @return {Array}\n */\nexport function gsd(x, yIn, options = {}) {\n let {\n noiseLevel,\n sgOptions = {\n windowSize: 9,\n polynomial: 3,\n },\n smoothY = true,\n heightFactor = 0,\n broadRatio = 0.0,\n maxCriteria = true,\n minMaxRatio = 0.00025,\n derivativeThreshold = -1,\n realTopDetection = false,\n } = options;\n\n const y = yIn.slice();\n let equalSpaced = isEqualSpaced(x);\n\n if (noiseLevel === undefined) {\n noiseLevel = equalSpaced ? getNoiseLevel(y) : 0;\n }\n\n const yCorrection = { m: 1, b: noiseLevel };\n\n if (!maxCriteria) {\n yCorrection.m = -1;\n yCorrection.b *= -1;\n }\n\n for (let i = 0; i < y.length; i++) {\n y[i] = yCorrection.m * y[i] - yCorrection.b;\n }\n\n for (let i = 0; i < y.length; i++) {\n if (y[i] < 0) {\n y[i] = 0;\n }\n }\n // If the max difference between delta x is less than 5%, then,\n // we can assume it to be equally spaced variable\n let yData = y;\n let dY, ddY;\n const { windowSize, polynomial } = sgOptions;\n\n if (equalSpaced) {\n if (smoothY) {\n yData = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 0,\n });\n }\n dY = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 1,\n });\n ddY = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 2,\n });\n } else {\n if (smoothY) {\n yData = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 0,\n });\n }\n dY = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 1,\n });\n ddY = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 2,\n });\n }\n\n const xData = x;\n const dX = x[1] - x[0];\n let maxDdy = 0;\n let maxY = 0;\n for (let i = 0; i < yData.length; i++) {\n if (Math.abs(ddY[i]) > maxDdy) {\n maxDdy = Math.abs(ddY[i]);\n }\n if (Math.abs(yData[i]) > maxY) {\n maxY = Math.abs(yData[i]);\n }\n }\n\n let lastMax = null;\n let lastMin = null;\n let minddY = new Array(yData.length - 2);\n let intervalL = new Array(yData.length);\n let intervalR = new Array(yData.length);\n let broadMask = new Array(yData.length - 2);\n let minddYLen = 0;\n let intervalLLen = 0;\n let intervalRLen = 0;\n let broadMaskLen = 0;\n // By the intermediate value theorem We cannot find 2 consecutive maximum or minimum\n for (let i = 1; i < yData.length - 1; ++i) {\n // filter based on derivativeThreshold\n // console.log('pasa', y[i], dY[i], ddY[i]);\n if (Math.abs(dY[i]) > derivativeThreshold) {\n // Minimum in first derivative\n if (\n (dY[i] < dY[i - 1] && dY[i] <= dY[i + 1]) ||\n (dY[i] <= dY[i - 1] && dY[i] < dY[i + 1])\n ) {\n lastMin = {\n x: xData[i],\n index: i,\n };\n if (dX > 0 && lastMax !== null) {\n intervalL[intervalLLen++] = lastMax;\n intervalR[intervalRLen++] = lastMin;\n }\n }\n\n // Maximum in first derivative\n if (\n (dY[i] >= dY[i - 1] && dY[i] > dY[i + 1]) ||\n (dY[i] > dY[i - 1] && dY[i] >= dY[i + 1])\n ) {\n lastMax = {\n x: xData[i],\n index: i,\n };\n if (dX < 0 && lastMin !== null) {\n intervalL[intervalLLen++] = lastMax;\n intervalR[intervalRLen++] = lastMin;\n }\n }\n }\n\n // Minimum in second derivative\n if (ddY[i] < ddY[i - 1] && ddY[i] < ddY[i + 1]) {\n // TODO should we change this to have 3 arrays ? Huge overhead creating arrays\n minddY[minddYLen++] = i; // ( [xData[i], yData[i], i] );\n broadMask[broadMaskLen++] = Math.abs(ddY[i]) <= broadRatio * maxDdy;\n }\n }\n minddY.length = minddYLen;\n intervalL.length = intervalLLen;\n intervalR.length = intervalRLen;\n broadMask.length = broadMaskLen;\n\n let signals = new Array(minddY.length);\n let signalsLen = 0;\n let lastK = -1;\n let possible, frequency, distanceJ, minDistance, gettingCloser;\n for (let j = 0; j < minddY.length; ++j) {\n frequency = xData[minddY[j]];\n possible = -1;\n let k = lastK + 1;\n minDistance = Number.MAX_VALUE;\n distanceJ = 0;\n gettingCloser = true;\n while (possible === -1 && k < intervalL.length && gettingCloser) {\n distanceJ = Math.abs(frequency - (intervalL[k].x + intervalR[k].x) / 2);\n\n // Still getting closer?\n if (distanceJ < minDistance) {\n minDistance = distanceJ;\n } else {\n gettingCloser = false;\n }\n if (distanceJ < Math.abs(intervalL[k].x - intervalR[k].x) / 2) {\n possible = k;\n lastK = k;\n }\n ++k;\n }\n\n if (possible !== -1) {\n if (Math.abs(yData[minddY[j]]) > minMaxRatio * maxY) {\n signals[signalsLen++] = {\n index: minddY[j],\n x: frequency,\n y: (yData[minddY[j]] + yCorrection.b) / yCorrection.m,\n width: Math.abs(intervalR[possible].x - intervalL[possible].x), // widthCorrection\n soft: broadMask[j],\n };\n\n signals[signalsLen - 1].left = intervalL[possible];\n signals[signalsLen - 1].right = intervalR[possible];\n\n if (heightFactor) {\n let yLeft = yData[intervalL[possible].index];\n let yRight = yData[intervalR[possible].index];\n signals[signalsLen - 1].height =\n heightFactor * (signals[signalsLen - 1].y - (yLeft + yRight) / 2);\n }\n }\n }\n }\n signals.length = signalsLen;\n\n if (realTopDetection) {\n determineRealTop(signals, xData, yData);\n }\n\n // Correct the values to fit the original spectra data\n for (let j = 0; j < signals.length; j++) {\n signals[j].base = noiseLevel;\n }\n\n signals.sort(function (a, b) {\n return a.x - b.x;\n });\n\n return signals;\n}\n\nconst isEqualSpaced = (x) => {\n let tmp;\n let maxDx = 0;\n let minDx = Number.MAX_SAFE_INTEGER;\n for (let i = 0; i < x.length - 1; ++i) {\n tmp = Math.abs(x[i + 1] - x[i]);\n if (tmp < minDx) {\n minDx = tmp;\n }\n if (tmp > maxDx) {\n maxDx = tmp;\n }\n }\n return (maxDx - minDx) / maxDx < 0.05;\n};\n\nconst getNoiseLevel = (y) => {\n let mean = 0;\n\n let stddev = 0;\n let length = y.length;\n for (let i = 0; i < length; ++i) {\n mean += y[i];\n }\n mean /= length;\n let averageDeviations = new Array(length);\n for (let i = 0; i < length; ++i) {\n averageDeviations[i] = Math.abs(y[i] - mean);\n }\n averageDeviations.sort((a, b) => a - b);\n if (length % 2 === 1) {\n stddev = averageDeviations[(length - 1) / 2] / 0.6745;\n } else {\n stddev =\n (0.5 *\n (averageDeviations[length / 2] + averageDeviations[length / 2 - 1])) /\n 0.6745;\n }\n\n return stddev;\n};\n\nconst determineRealTop = (peakList, x, y) => {\n let alpha, beta, gamma, p, currentPoint;\n for (let j = 0; j < peakList.length; j++) {\n currentPoint = peakList[j].index; // peakList[j][2];\n // The detected peak could be moved 1 or 2 units to left or right.\n if (\n y[currentPoint - 1] >= y[currentPoint - 2] &&\n y[currentPoint - 1] >= y[currentPoint]\n ) {\n currentPoint--;\n } else {\n if (\n y[currentPoint + 1] >= y[currentPoint] &&\n y[currentPoint + 1] >= y[currentPoint + 2]\n ) {\n currentPoint++;\n } else {\n if (\n y[currentPoint - 2] >= y[currentPoint - 3] &&\n y[currentPoint - 2] >= y[currentPoint - 1]\n ) {\n currentPoint -= 2;\n } else {\n if (\n y[currentPoint + 2] >= y[currentPoint + 1] &&\n y[currentPoint + 2] >= y[currentPoint + 3]\n ) {\n currentPoint += 2;\n }\n }\n }\n }\n // interpolation to a sin() function\n if (\n y[currentPoint - 1] > 0 &&\n y[currentPoint + 1] > 0 &&\n y[currentPoint] >= y[currentPoint - 1] &&\n y[currentPoint] >= y[currentPoint + 1] &&\n (y[currentPoint] !== y[currentPoint - 1] ||\n y[currentPoint] !== y[currentPoint + 1])\n ) {\n alpha = 20 * Math.log10(y[currentPoint - 1]);\n beta = 20 * Math.log10(y[currentPoint]);\n gamma = 20 * Math.log10(y[currentPoint + 1]);\n p = (0.5 * (alpha - gamma)) / (alpha - 2 * beta + gamma);\n // console.log(alpha, beta, gamma, `p: ${p}`);\n // console.log(x[currentPoint]+\" \"+tmp+\" \"+currentPoint);\n peakList[j].x =\n x[currentPoint] + (x[currentPoint] - x[currentPoint - 1]) * p;\n peakList[j].y =\n y[currentPoint] -\n 0.25 * (y[currentPoint - 1] - y[currentPoint + 1]) * p;\n }\n }\n};\n","/**\n * This function calculates the spectrum as a sum of gaussian functions. The Gaussian\n * parameters are divided in 3 batches. 1st: centers; 2nd: height; 3th: std's;\n * @param t Ordinate values\n * @param p Gaussian parameters\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\nexport function sumOfGaussians(p) {\n return function (t) {\n let nL = p.length / 3;\n let factor;\n let rows = t.length;\n let result = rows === undefined ? 0 : new Float64Array(rows).fill(0);\n for (let i = 0; i < nL; i++) {\n factor = Math.pow(p[i + nL * 2], 2) * 2;\n if (rows === undefined) {\n result += p[i + nL] * Math.exp(-Math.pow(t - p[i], 2) / factor);\n } else {\n for (let j = 0; j < rows; j++) {\n result[j] += p[i + nL] * Math.exp(-Math.pow(t[j] - p[i], 2) / factor);\n }\n }\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { sumOfGaussians } from './sumOfGaussians';\n\n/**\n *\n * @param xy A two column matrix containing the x and y data to be fitted\n * @param group A set of initial lorentzian parameters to be optimized [center, heigth, half_width_at_half_height]\n * @returns {Array} A set of final lorentzian parameters [center, heigth, hwhh*2]\n */\nexport function optimizeGaussianSum(xy, group, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let nL = group.length;\n let pInit = new Float64Array(nL * 3);\n let pMin = new Float64Array(nL * 3);\n let pMax = new Float64Array(nL * 3);\n let dt = Math.abs(t[0] - t[1]);\n\n for (let i = 0; i < nL; i++) {\n pInit[i] = group[i].x;\n pInit[i + nL] = group[i].y / maxY;\n pInit[i + 2 * nL] = group[i].width;\n\n pMin[i] = group[i].x - dt;\n pMin[i + nL] = 0;\n pMin[i + 2 * nL] = group[i].width / 4;\n\n pMax[i] = group[i].x + dt;\n pMax[i + nL] = (group[i].y * 1.2) / maxY;\n pMax[i + 2 * nL] = group[i].width * 4;\n }\n\n let data = {\n x: t,\n y: yData,\n };\n let result = new Array(nL);\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n\n let pFit = LM(data, sumOfGaussians, opts);\n for (let i = 0; i < nL; i++) {\n result[i] = {\n parameters: [\n pFit.parameterValues[i],\n pFit.parameterValues[i + nL] * maxY,\n pFit.parameterValues[i + nL * 2],\n ],\n error: pFit.parameterError,\n };\n }\n return result;\n}\n","/**\n * Single 3 parameter gaussian function\n * @param t Ordinate values\n * @param p Gaussian parameters [mean, height, std]\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\n\nexport function singleGaussian(p) {\n return function (t) {\n let factor2 = (p[2] * p[2]) / 2;\n let rows = t.length;\n if (!rows) return p[1] * Math.exp((-(t - p[0]) * (t - p[0])) / factor2);\n let result = new Float64Array(t.length);\n for (let i = 0; i < t.length; i++) {\n result[i] = p[1] * Math.exp((-(t[i] - p[0]) * (t[i] - p[0])) / factor2);\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { singleGaussian } from './singleGaussian';\n\n/**\n * Fits a set of points to a gaussian bell. Returns the mean of the peak, the std and the height of the signal.\n * @param data,[y]\n * @returns {*[]}\n */\nexport function optimizeSingleGaussian(xy, peak, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let dt = Math.abs(t[0] - t[1]);\n let pInit = new Float64Array([peak.x, 1, peak.width]);\n let pMin = new Float64Array([peak.x - dt, 0, peak.width / 4]);\n let pMax = new Float64Array([peak.x + dt, 1.25, peak.width * 4]);\n\n let data = {\n x: t,\n y: yData,\n };\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n let pFit = LM(data, singleGaussian, opts);\n return {\n parameters: [\n pFit.parameterValues[0],\n pFit.parameterValues[1] * maxY,\n pFit.parameterValues[2],\n ],\n error: pFit.parameterError,\n };\n}\n","/**\n * This function calculates the spectrum as a sum of lorentzian functions. The Lorentzian\n * parameters are divided in 3 batches. 1st: centers; 2nd: heights; 3th: widths;\n * @param t Ordinate values\n * @param p Lorentzian parameters\n * @returns {*}\n */\n\nexport function sumOfLorentzians(p) {\n return function (t) {\n let nL = p.length / 3;\n let factor;\n let p2;\n let rows = t.length;\n let result = rows === undefined ? 0 : new Float64Array(rows).fill(0);\n for (let i = 0; i < nL; i++) {\n p2 = Math.pow(p[i + nL * 2] / 2, 2);\n factor = p[i + nL] * p2;\n if (rows === undefined) {\n result += factor / (Math.pow(t - p[i], 2) + p2);\n } else {\n for (let j = 0; j < rows; j++) {\n result[j] += factor / (Math.pow(t[j] - p[i], 2) + p2);\n }\n }\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { sumOfLorentzians } from './sumOfLorentzians';\n\n/**\n *\n * @param xy A two column matrix containing the x and y data to be fitted\n * @param group A set of initial lorentzian parameters to be optimized [center, heigth, half_width_at_half_height]\n * @returns {Array} A set of final lorentzian parameters [center, heigth, hwhh*2]\n */\nexport function optimizeLorentzianSum(xy, group, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n\n let nL = group.length;\n let pInit = new Float64Array(nL * 3);\n let pMin = new Float64Array(nL * 3);\n let pMax = new Float64Array(nL * 3);\n let dt = Math.abs(t[0] - t[1]);\n\n for (let i = 0; i < nL; i++) {\n pInit[i] = group[i].x;\n pInit[i + nL] = 1;\n pInit[i + 2 * nL] = group[i].width;\n\n pMin[i] = group[i].x - dt;\n pMin[i + nL] = 0;\n pMin[i + 2 * nL] = group[i].width / 4;\n\n pMax[i] = group[i].x + dt;\n pMax[i + nL] = 1.5;\n pMax[i + 2 * nL] = group[i].width * 4;\n }\n\n let data = {\n x: t,\n y: yData,\n };\n\n let result = new Array(nL);\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n\n let pFit = LM(data, sumOfLorentzians, opts);\n for (let i = 0; i < nL; i++) {\n result[i] = {\n parameters: [\n pFit.parameterValues[i],\n pFit.parameterValues[i + nL] * maxY,\n pFit.parameterValues[i + nL * 2],\n ],\n error: pFit.parameterError,\n };\n }\n return result;\n}\n","/**\n * Single 4 parameter lorentzian function\n * @param t Ordinate values\n * @param p Lorentzian parameters\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\n\nexport function singleLorentzian(p) {\n return function (t) {\n let factor = p[1] * Math.pow(p[2] / 2, 2);\n let rows = t.length;\n if (!rows) return factor / (Math.pow(t - p[0], 2) + Math.pow(p[2] / 2, 2));\n let result = new Float64Array(rows);\n for (let i = 0; i < rows; i++) {\n result[i] = factor / (Math.pow(t[i] - p[0], 2) + Math.pow(p[2] / 2, 2));\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { singleLorentzian } from './singleLorentzian';\n\n/**\n * * Fits a set of points to a Lorentzian function. Returns the center of the peak, the width at half height, and the height of the signal.\n * @param data,[y]\n * @returns {*[]}\n */\nexport function optimizeSingleLorentzian(xy, peak, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let dt = Math.abs(t[0] - t[1]);\n let pInit = new Float64Array([peak.x, 1, peak.width]);\n let pMin = new Float64Array([peak.x - dt, 0.75, peak.width / 4]);\n let pMax = new Float64Array([peak.x + dt, 1.25, peak.width * 4]);\n\n let data = {\n x: t,\n y: yData,\n };\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n opts = Object.assign({}, lmOptions, opts);\n let pFit = LM(data, singleLorentzian, opts);\n return {\n parameters: [\n pFit.parameterValues[0],\n pFit.parameterValues[1] * maxY,\n pFit.parameterValues[2],\n ],\n error: pFit.parameterError,\n };\n}\n","import {\n optimizeGaussianSum,\n optimizeLorentzianSum,\n optimizeSingleGaussian,\n optimizeSingleLorentzian,\n} from 'ml-optimize-lorentzian';\n\nexport function optimizePeaks(peakList, x, y, options = {}) {\n const {\n functionName = 'gaussian',\n factorWidth = 4,\n optimizationOptions = {\n damping: 1.5,\n maxIterations: 100,\n errorTolerance: 10e-5,\n },\n } = options;\n\n let lastIndex = [0];\n let groups = groupPeaks(peakList, factorWidth);\n let result = [];\n let factor = 1;\n if (functionName === 'gaussian') {\n factor = 1.17741;\n } // From https://en.wikipedia.org/wiki/Gaussian_function#Properties\n let sampling;\n for (let i = 0; i < groups.length; i++) {\n let peaks = groups[i].group;\n if (peaks.length > 1) {\n // Multiple peaks\n sampling = sampleFunction(\n groups[i].limits[0] - groups[i].limits[1],\n groups[i].limits[0] + groups[i].limits[1],\n x,\n y,\n lastIndex,\n );\n if (sampling[0].length > 5) {\n let optPeaks = [];\n if (functionName === 'gaussian') {\n optPeaks = optimizeGaussianSum(sampling, peaks, optimizationOptions);\n } else {\n if (functionName === 'lorentzian') {\n optPeaks = optimizeLorentzianSum(\n sampling,\n peaks,\n optimizationOptions,\n );\n }\n }\n\n for (let j = 0; j < optPeaks.length; j++) {\n let { parameters } = optPeaks[j];\n result.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2] * factor,\n index: peaks[j].index,\n });\n }\n }\n } else {\n // Single peak\n peaks = peaks[0];\n sampling = sampleFunction(\n peaks.x - factorWidth * peaks.width,\n peaks.x + factorWidth * peaks.width,\n x,\n y,\n lastIndex,\n );\n\n if (sampling[0].length > 5) {\n let fitResult = [];\n if (functionName === 'gaussian') {\n fitResult = optimizeSingleGaussian(\n [sampling[0], sampling[1]],\n peaks,\n optimizationOptions,\n );\n } else {\n if (functionName === 'lorentzian') {\n fitResult = optimizeSingleLorentzian(\n [sampling[0], sampling[1]],\n peaks,\n optimizationOptions,\n );\n }\n }\n\n let { parameters } = fitResult;\n result.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2] * factor,\n index: peaks.index,\n }); // From https://en.wikipedia.org/wiki/Gaussian_function#Properties}\n }\n }\n }\n return result;\n}\n\nfunction sampleFunction(from, to, x, y, lastIndex) {\n let nbPoints = x.length;\n let sampleX = [];\n let sampleY = [];\n let direction = Math.sign(x[1] - x[0]); // Direction of the derivative\n if (direction === -1) {\n lastIndex[0] = x.length - 1;\n }\n\n let delta = Math.abs(to - from) / 2;\n let mid = (from + to) / 2;\n let stop = false;\n let index = lastIndex[0];\n while (!stop && index < nbPoints && index >= 0) {\n if (Math.abs(x[index] - mid) <= delta) {\n sampleX.push(x[index]);\n sampleY.push(y[index]);\n index += direction;\n } else {\n // It is outside the range.\n if (Math.sign(mid - x[index]) === 1) {\n // We'll reach the mid going in the current direction\n index += direction;\n } else {\n // There is not more peaks in the current range\n stop = true;\n }\n }\n }\n lastIndex[0] = index;\n return [sampleX, sampleY];\n}\n\nfunction groupPeaks(peakList, nL) {\n let group = [];\n let groups = [];\n let limits = [peakList[0].x, nL * peakList[0].width];\n let upperLimit, lowerLimit;\n // Merge forward\n for (let i = 0; i < peakList.length; i++) {\n // If the 2 things overlaps\n if (\n Math.abs(peakList[i].x - limits[0]) <\n nL * peakList[i].width + limits[1]\n ) {\n // Add the peak to the group\n group.push(peakList[i]);\n // Update the group limits\n upperLimit = limits[0] + limits[1];\n if (peakList[i].x + nL * peakList[i].width > upperLimit) {\n upperLimit = peakList[i].x + nL * peakList[i].width;\n }\n lowerLimit = limits[0] - limits[1];\n if (peakList[i].x - nL * peakList[i].width < lowerLimit) {\n lowerLimit = peakList[i].x - nL * peakList[i].width;\n }\n limits = [\n (upperLimit + lowerLimit) / 2,\n Math.abs(upperLimit - lowerLimit) / 2,\n ];\n } else {\n groups.push({ limits: limits, group: group });\n // var optmimalPeak = fitSpectrum(group,limits,spectrum);\n group = [peakList[i]];\n limits = [peakList[i].x, nL * peakList[i].width];\n }\n }\n groups.push({ limits: limits, group: group });\n // Merge backward\n for (let i = groups.length - 2; i >= 0; i--) {\n // The groups overlaps\n if (\n Math.abs(groups[i].limits[0] - groups[i + 1].limits[0]) <\n (groups[i].limits[1] + groups[i + 1].limits[1]) / 2\n ) {\n for (let j = 0; j < groups[i + 1].group.length; j++) {\n groups[i].group.push(groups[i + 1].group[j]);\n }\n upperLimit = groups[i].limits[0] + groups[i].limits[1];\n if (groups[i + 1].limits[0] + groups[i + 1].limits[1] > upperLimit) {\n upperLimit = groups[i + 1].limits[0] + groups[i + 1].limits[1];\n }\n lowerLimit = groups[i].limits[0] - groups[i].limits[1];\n if (groups[i + 1].limits[0] - groups[i + 1].limits[1] < lowerLimit) {\n lowerLimit = groups[i + 1].limits[0] - groups[i + 1].limits[1];\n }\n\n groups[i].limits = [\n (upperLimit + lowerLimit) / 2,\n Math.abs(upperLimit - lowerLimit) / 2,\n ];\n\n groups.splice(i + 1, 1);\n }\n }\n return groups;\n}\n","import { optimizeSingleLorentzian } from 'ml-optimize-lorentzian';\n\n/**\n * This function try to join the peaks that seems to belong to a broad signal in a single broad peak.\n * @param peakList\n * @param options\n */\nexport function joinBroadPeaks(peakList, options = {}) {\n let width = options.width;\n let broadLines = [];\n // Optimize the possible broad lines\n let max = 0;\n\n let maxI = 0;\n\n let count = 1;\n for (let i = peakList.length - 1; i >= 0; i--) {\n if (peakList[i].soft) {\n broadLines.push(peakList.splice(i, 1)[0]);\n }\n }\n // Push a feke peak\n broadLines.push({ x: Number.MAX_VALUE });\n\n let candidates = [[broadLines[0].x, broadLines[0].y]];\n let indexes = [broadLines[0].index];\n\n for (let i = 1; i < broadLines.length; i++) {\n // console.log(broadLines[i-1].x+\" \"+broadLines[i].x);\n if (Math.abs(broadLines[i - 1].x - broadLines[i].x) < width) {\n candidates.push([broadLines[i].x, broadLines[i].y]);\n if (broadLines[i].y > max) {\n max = broadLines[i].y;\n maxI = i;\n }\n indexes.push(broadLines[i].index);\n count++;\n } else {\n if (count > 2) {\n let fitted = optimizeSingleLorentzian(candidates, {\n x: broadLines[maxI].x,\n y: max,\n width: Math.abs(\n candidates[0][0] - candidates[candidates.length - 1][0],\n ),\n });\n let { parameters } = fitted;\n peakList.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2],\n index: Math.floor(\n indexes.reduce((a, b) => a + b, 0) / indexes.length,\n ),\n soft: false,\n });\n } else {\n // Put back the candidates to the signals list\n indexes.forEach((index) => {\n peakList.push(broadLines[index]);\n });\n }\n candidates = [[broadLines[i].x, broadLines[i].y]];\n indexes = [i];\n max = broadLines[i].y;\n maxI = i;\n count = 1;\n }\n }\n\n peakList.sort(function (a, b) {\n return a.x - b.x;\n });\n\n return peakList;\n}\n","/**\n * This method will allow to enlarge peaks and prevent overlap between peaks\n * Because peaks may not be symmetric after we add 2 properties, from and to.\n * @param {Array} peakList\n * @param {object} [options={}]\n * @param {number} [factor=2]\n * @param {boolean} [overlap=false] by default we don't allow overlap\n * @return {Array} peakList\n */\nexport function broadenPeaks(peakList, options = {}) {\n const { factor = 2, overlap = false } = options;\n\n for (let peak of peakList) {\n if (!peak.right || !peak.left) {\n peak.from = peak.x - (peak.width / 2) * factor;\n peak.to = peak.x + (peak.width / 2) * factor;\n } else {\n peak.from = peak.x - (peak.x - peak.left.x) * factor;\n peak.to = peak.x + (peak.right.x - peak.x) * factor;\n }\n }\n\n if (!overlap) {\n for (let i = 0; i < peakList.length - 1; i++) {\n let peak = peakList[i];\n let nextPeak = peakList[i + 1];\n if (peak.to > nextPeak.from) {\n peak.to = nextPeak.from = (peak.to + nextPeak.from) / 2;\n }\n }\n }\n\n for (let peak of peakList) {\n peak.width = peak.to - peak.from;\n }\n\n return peakList;\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction min(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var minValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\n\nfunction mode(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var maxValue = 0;\n var maxCount = 0;\n var count = 0;\n var counts = {};\n\n for (var i = 0; i < input.length; ++i) {\n var element = input[i];\n count = counts[element];\n\n if (count) {\n counts[element]++;\n count++;\n } else {\n counts[element] = count = 1;\n }\n\n if (count > maxCount) {\n maxCount = count;\n maxValue = input[i];\n }\n }\n\n return maxValue;\n}\n\nexport default mode;\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\nimport max from 'ml-array-max';\nimport sum from 'ml-array-sum';\n\nfunction norm(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var _options$algorithm = options.algorithm,\n algorithm = _options$algorithm === void 0 ? 'absolute' : _options$algorithm,\n _options$sumValue = options.sumValue,\n sumValue = _options$sumValue === void 0 ? 1 : _options$sumValue,\n _options$maxValue = options.maxValue,\n maxValue = _options$maxValue === void 0 ? 1 : _options$maxValue;\n\n if (!isArray(input)) {\n throw new Error('input must be an array');\n }\n\n var output;\n\n if (options.output !== undefined) {\n if (!isArray(options.output)) {\n throw new TypeError('output option must be an array if specified');\n }\n\n output = options.output;\n } else {\n output = new Array(input.length);\n }\n\n if (input.length === 0) {\n throw new Error('input must not be empty');\n }\n\n switch (algorithm.toLowerCase()) {\n case 'absolute':\n {\n var absoluteSumValue = absoluteSum(input) / sumValue;\n if (absoluteSumValue === 0) return input.slice(0);\n\n for (var i = 0; i < input.length; i++) {\n output[i] = input[i] / absoluteSumValue;\n }\n\n return output;\n }\n\n case 'max':\n {\n var currentMaxValue = max(input);\n if (currentMaxValue === 0) return input.slice(0);\n var factor = maxValue / currentMaxValue;\n\n for (var _i = 0; _i < input.length; _i++) {\n output[_i] = input[_i] * factor;\n }\n\n return output;\n }\n\n case 'sum':\n {\n var sumFactor = sum(input) / sumValue;\n if (sumFactor === 0) return input.slice(0);\n\n for (var _i2 = 0; _i2 < input.length; _i2++) {\n output[_i2] = input[_i2] / sumFactor;\n }\n\n return output;\n }\n\n default:\n throw new Error(\"norm: unknown algorithm: \".concat(algorithm));\n }\n}\n\nfunction absoluteSum(input) {\n var sumValue = 0;\n\n for (var i = 0; i < input.length; i++) {\n sumValue += Math.abs(input[i]);\n }\n\n return sumValue;\n}\n\nexport default norm;\n","import isArray from 'is-any-array';\n\nfunction _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n _typeof = function (obj) {\n return typeof obj;\n };\n } else {\n _typeof = function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n }\n\n return _typeof(obj);\n}\n\n/**\r\n * Fill an array with sequential numbers\r\n * @param {Array} [input] - optional destination array (if not provided a new array will be created)\r\n * @param {object} [options={}]\r\n * @param {number} [options.from=0] - first value in the array\r\n * @param {number} [options.to=10] - last value in the array\r\n * @param {number} [options.size=input.length] - size of the array (if not provided calculated from step)\r\n * @param {number} [options.step] - if not provided calculated from size\r\n * @return {Array}\r\n */\n\nfunction sequentialFill() {\n var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (_typeof(input) === 'object' && !isArray(input)) {\n options = input;\n input = [];\n }\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n var _options = options,\n _options$from = _options.from,\n from = _options$from === void 0 ? 0 : _options$from,\n _options$to = _options.to,\n to = _options$to === void 0 ? 10 : _options$to,\n _options$size = _options.size,\n size = _options$size === void 0 ? input.length : _options$size,\n step = _options.step;\n\n if (size !== 0 && step) {\n throw new Error('step is defined by the array size');\n }\n\n if (!size) {\n if (step) {\n size = Math.floor((to - from) / step) + 1;\n } else {\n size = to - from + 1;\n }\n }\n\n if (!step && size) {\n step = (to - from) / (size - 1);\n }\n\n if (Array.isArray(input)) {\n // only works with normal array\n input.length = 0;\n\n for (var i = 0; i < size; i++) {\n input.push(from);\n from += step;\n }\n } else {\n if (input.length !== size) {\n throw new Error('sequentialFill typed array must have the correct length');\n }\n\n for (var _i = 0; _i < size; _i++) {\n input[_i] = from;\n from += step;\n }\n }\n\n return input;\n}\n\nexport default sequentialFill;\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\nimport arrayMean from 'ml-array-mean';\n\nfunction variance(values) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(values)) {\n throw new TypeError('input must be an array');\n }\n\n var _options$unbiased = options.unbiased,\n unbiased = _options$unbiased === void 0 ? true : _options$unbiased,\n _options$mean = options.mean,\n mean = _options$mean === void 0 ? arrayMean(values) : _options$mean;\n var sqrError = 0;\n\n for (var i = 0; i < values.length; i++) {\n var x = values[i] - mean;\n sqrError += x * x;\n }\n\n if (unbiased) {\n return sqrError / (values.length - 1);\n } else {\n return sqrError / values.length;\n }\n}\n\nexport default variance;\n","import variance from 'ml-array-variance';\n\nfunction standardDeviation(values) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return Math.sqrt(variance(values, options));\n}\n\nexport default standardDeviation;\n","/**\n * Merge abscissa values if the ordinate value is in a list of centroids\n * @param {object} originalPoints\n * @param {Array} originalPoints.x\n * @param {Array} originalPoints.y\n * @param {Array} centroids\n * @param {object} [options]\n * @param {number} [options.window = 0.01] - has to be a positive number\n * @return {{x: Array, y: Array}}\n */\nexport default function mergeByCentroids(\n originalPoints,\n centroids,\n options = {}\n) {\n const { window = 0.01 } = options;\n\n var mergedPoints = {\n x: centroids.slice(),\n y: new Array(centroids.length).fill(0)\n };\n\n var originalIndex = 0;\n var mergedIndex = 0;\n while (\n originalIndex < originalPoints.x.length &&\n mergedIndex < centroids.length\n ) {\n var diff = originalPoints.x[originalIndex] - centroids[mergedIndex];\n if (Math.abs(diff) < window) {\n mergedPoints.y[mergedIndex] += originalPoints.y[originalIndex++];\n } else if (diff < 0) {\n originalIndex++;\n } else {\n mergedIndex++;\n }\n }\n\n return mergedPoints;\n}\n","import binarySearch from 'binary-search';\nimport { ascending, descending } from 'num-sort';\n\n/**\n *\n * @param {object} points\n * @param {Array} originalPoints.x\n * @param {Array} originalPoints.y\n * @param {*} options\n * @return {{x: Array, y: Array}}\n */\nexport default function closestX(points, options) {\n const { x, y } = points;\n const { target = x[0], reverse = false } = options;\n\n let index;\n if (reverse) {\n index = binarySearch(x, target, descending);\n } else {\n index = binarySearch(x, target, ascending);\n }\n\n if (index >= 0) {\n return {\n x: x[index],\n y: y[index]\n };\n } else {\n index = ~index;\n if (\n (index !== 0 && Math.abs(x[index] - target) > 0.5) ||\n index === x.length\n ) {\n return {\n x: x[index - 1],\n y: y[index - 1]\n };\n } else {\n return {\n x: x[index],\n y: y[index]\n };\n }\n }\n}\n","import mean from 'ml-array-mean';\n\n/**\n *\n * @param {object} points\n * @param {Array} points.x\n * @param {Array} points.y\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @return {number}\n */\nexport default function covariance(points, options = {}) {\n const { x, y } = points;\n const { unbiased = true } = options;\n\n const meanX = mean(x);\n const meanY = mean(y);\n\n var error = 0;\n\n for (let i = 0; i < x.length; i++) {\n error += (x[i] - meanX) * (y[i] - meanY);\n }\n\n if (unbiased) {\n return error / (x.length - 1);\n } else {\n return error / x.length;\n }\n}\n","/**\n * Merge abscissas values on similar ordinates and weight the group of abscissas\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {number} [options.groupWidth = 0.001] - window for abscissas to merge\n * @return {{x: Array, y: Array}}\n */\nexport default function maxMerge(points, options = {}) {\n const { x, y } = points;\n const { groupWidth = 0.001 } = options;\n\n var merged = { x: [], y: [] };\n var maxAbscissa = { x: [], y: [] };\n var size = 0;\n var index = 0;\n\n while (index < x.length) {\n if (size === 0 || x[index] - merged.x[size - 1] > groupWidth) {\n maxAbscissa.x.push(x[index]);\n maxAbscissa.y.push(y[index]);\n merged.x.push(x[index]);\n merged.y.push(y[index]);\n index++;\n size++;\n } else {\n if (y[index] > maxAbscissa.y[size - 1]) {\n maxAbscissa.x[size - 1] = x[index];\n maxAbscissa.y[size - 1] = y[index];\n }\n merged.x[size - 1] = x[index];\n merged.y[size - 1] += y[index];\n index++;\n }\n }\n\n merged.x = maxAbscissa.x.slice();\n\n return merged;\n}\n","import binarySearch from 'binary-search';\nimport { ascending, descending } from 'num-sort';\n\n/**\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {object} [options.from = {index: 0}]\n * @param {object} [options.to = {index: x.length-1}]\n * @param {boolean} [options.reverse = false]\n * @return {{index: number, value: number}}\n */\nexport default function maxY(points, options = {}) {\n const { x, y } = points;\n let {\n from = { index: 0 },\n to = { index: x.length },\n reverse = false\n } = options;\n\n if (from.value !== undefined && from.index === undefined) {\n from.index = calculateIndex(from.value, x, reverse);\n }\n\n if (to.value !== undefined && to.index === undefined) {\n to.index = calculateIndex(to.value, x, reverse);\n }\n\n var currentMax = Number.MIN_VALUE;\n var currentIndex;\n for (var i = from.index; i < to.index; i++) {\n if (currentMax < y[i]) {\n currentMax = y[i];\n currentIndex = i;\n }\n }\n\n return {\n index: currentIndex,\n value: currentMax\n };\n}\n\n/**\n * @param {number} value\n * @param {Array} x\n * @param {boolean} reverse\n * @return {number} index of the value in the array\n */\nfunction calculateIndex(value, x, reverse) {\n let index;\n if (reverse) {\n index = binarySearch(x, value, descending);\n } else {\n index = binarySearch(x, value, ascending);\n }\n\n if (index < 0) {\n throw new Error(`the value ${value} doesn't belongs to the abscissa value`);\n }\n\n return index;\n}\n","export default function sortX(points, options = {}) {\n const { x, y } = points;\n const { reverse = false } = options;\n\n var sortFunc;\n if (!reverse) {\n sortFunc = (a, b) => a.x - b.x;\n } else {\n sortFunc = (a, b) => b.x - a.x;\n }\n\n var grouped = x\n .map((val, index) => ({\n x: val,\n y: y[index]\n }))\n .sort(sortFunc);\n\n var response = { x: x.slice(), y: y.slice() };\n for (var i = 0; i < x.length; i++) {\n response.x[i] = grouped[i].x;\n response.y[i] = grouped[i].y;\n }\n\n return response;\n}\n","\n/**\n * In place modification of the 2 arrays to make X unique and sum the Y if X has the same value\n * @param {object} [points={}] : Object of points contains property x (an array) and y (an array)\n * @return points\n */\n\nexport default function uniqueX(points = {}) {\n const { x, y } = points;\n if (x.length < 2) return;\n if (x.length !== y.length) {\n throw new Error('The X and Y arrays mush have the same length');\n }\n\n let current = x[0];\n let counter = 0;\n\n for (let i = 1; i < x.length; i++) {\n if (current !== x[i]) {\n counter++;\n current = x[i];\n x[counter] = x[i];\n if (i !== counter) {\n y[counter] = 0;\n }\n }\n if (i !== counter) {\n y[counter] += y[i];\n }\n }\n\n x.length = counter + 1;\n y.length = counter + 1;\n}\n","/**\n * Merge abscissas values on similar ordinates and weight the group of abscissas\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {number} [options.groupWidth = 0.001] - window for abscissas to merge\n * @return {{x: Array, y: Array}}\n */\nexport default function weightedMerge(points, options = {}) {\n const { x, y } = points;\n const { groupWidth = 0.001 } = options;\n\n var merged = { x: [], y: [] };\n var weightedAbscissa = { x: [], y: [] };\n var size = 0;\n var index = 0;\n\n while (index < x.length) {\n if (size === 0 || x[index] - merged.x[size - 1] > groupWidth) {\n weightedAbscissa.x.push(x[index] * y[index]);\n weightedAbscissa.y.push(y[index]);\n merged.x.push(x[index]);\n merged.y.push(y[index]);\n index++;\n size++;\n } else {\n weightedAbscissa.x[size - 1] += x[index] * y[index];\n weightedAbscissa.y[size - 1] += y[index];\n merged.x[size - 1] = x[index];\n merged.y[size - 1] += y[index];\n index++;\n }\n }\n\n for (var i = 0; i < merged.x.length; i++) {\n merged.x[i] = weightedAbscissa.x[i] / weightedAbscissa.y[i];\n }\n\n return merged;\n}\n","/**\n * Normalize an array of zones:\n * - ensure than from < to\n * - merge overlapping zones\n *\n * The method will always check if from if lower than to and will swap if required.\n * @param {Array} [zones=[]]\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of a zone\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of a zone\n */\n\nexport function normalize(zones = [], options = {}) {\n if (zones.length === 0) return [];\n let {\n from = Number.NEGATIVE_INFINITY,\n to = Number.POSITIVE_INFINITY,\n } = options;\n if (from > to) [from, to] = [to, from];\n\n zones = JSON.parse(JSON.stringify(zones)).map((zone) =>\n zone.from > zone.to ? { from: zone.to, to: zone.from } : zone,\n );\n zones = zones.sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return a.to - b.to;\n });\n\n zones.forEach((zone) => {\n if (from > zone.from) zone.from = from;\n if (to < zone.to) zone.to = to;\n });\n\n zones = zones.filter((zone) => zone.from <= zone.to);\n if (zones.length === 0) return [];\n\n let currentZone = zones[0];\n let result = [currentZone];\n for (let i = 1; i < zones.length; i++) {\n let zone = zones[i];\n if (zone.from <= currentZone.to) {\n currentZone.to = zone.to;\n } else {\n currentZone = zone;\n result.push(currentZone);\n }\n }\n return result;\n}\n","import { normalize } from './normalize';\n\n/**\n * Convert an array of exclusions and keep only from / to\n *\n * The method will always check if from if lower than to and will swap if required.\n * @param {Array} [exclusions=[]]\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of zones (after inversion)\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of zones (after inversion)\n */\n\nexport function invert(exclusions = [], options = {}) {\n let {\n from = Number.NEGATIVE_INFINITY,\n to = Number.POSITIVE_INFINITY,\n } = options;\n if (from > to) [from, to] = [to, from];\n\n exclusions = normalize(exclusions, { from, to });\n if (exclusions.length === 0) return [{ from, to }];\n\n let zones = [];\n for (let i = 0; i < exclusions.length; i++) {\n let exclusion = exclusions[i];\n let nextExclusion = exclusions[i + 1];\n if (i === 0) {\n if (exclusion.from > from) {\n zones.push({ from, to: exclusion.from });\n }\n }\n if (i === exclusions.length - 1) {\n if (exclusion.to < to) {\n zones.push({ from: exclusion.to, to });\n }\n } else {\n zones.push({ from: exclusion.to, to: nextExclusion.from });\n }\n }\n\n return zones;\n}\n","import { normalize } from './normalize';\n\n/**\n * Add the number of points per zone to reach a specified total\n * @param {Array} [zones=[]]\n * @param {number} [numberOfPoints] Total number of points to distribute between zones\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of a zone\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of a zone\n */\n\nexport function zonesWithPoints(zones, numberOfPoints, options = {}) {\n if (zones.length === 0) return zones;\n zones = normalize(zones, options);\n\n const totalSize = zones.reduce((previous, current) => {\n return previous + (current.to - current.from);\n }, 0);\n\n let unitsPerPoint = totalSize / numberOfPoints;\n let currentTotal = 0;\n for (let i = 0; i < zones.length - 1; i++) {\n let zone = zones[i];\n zone.numberOfPoints = Math.min(\n Math.round((zone.to - zone.from) / unitsPerPoint),\n numberOfPoints - currentTotal,\n );\n currentTotal += zone.numberOfPoints;\n }\n\n zones[zones.length - 1].numberOfPoints = numberOfPoints - currentTotal;\n\n return zones;\n}\n","/**\n * Function that calculates the integral of the line between two\n * x-coordinates, given the slope and intercept of the line.\n * @param {number} x0\n * @param {number} x1\n * @param {number} slope\n * @param {number} intercept\n * @return {number} integral value.\n */\nexport default function integral(x0, x1, slope, intercept) {\n return (\n 0.5 * slope * x1 * x1 +\n intercept * x1 -\n (0.5 * slope * x0 * x0 + intercept * x0)\n );\n}\n","import integral from './integral';\n\n/**\n * function that retrieves the getEquallySpacedData with the variant \"smooth\"\n *\n * @param {Array} x\n * @param {Array} y\n * @param {number} from - Initial point\n * @param {number} to - Final point\n * @param {number} numberOfPoints\n * @return {Array} - Array of y's equally spaced with the variant \"smooth\"\n */\nexport default function equallySpacedSmooth(x, y, from, to, numberOfPoints) {\n let xLength = x.length;\n\n let step = (to - from) / (numberOfPoints - 1);\n let halfStep = step / 2;\n\n let output = new Array(numberOfPoints);\n\n let initialOriginalStep = x[1] - x[0];\n let lastOriginalStep = x[xLength - 1] - x[xLength - 2];\n\n // Init main variables\n let min = from - halfStep;\n let max = from + halfStep;\n\n let previousX = Number.MIN_VALUE;\n let previousY = 0;\n let nextX = x[0] - initialOriginalStep;\n let nextY = 0;\n\n let currentValue = 0;\n let slope = 0;\n let intercept = 0;\n let sumAtMin = 0;\n let sumAtMax = 0;\n\n let i = 0; // index of input\n let j = 0; // index of output\n\n function getSlope(x0, y0, x1, y1) {\n return (y1 - y0) / (x1 - x0);\n }\n\n let add = 0;\n main: while (true) {\n if (previousX <= min && min <= nextX) {\n add = integral(0, min - previousX, slope, previousY);\n sumAtMin = currentValue + add;\n }\n\n while (nextX - max >= 0) {\n // no overlap with original point, just consume current value\n add = integral(0, max - previousX, slope, previousY);\n sumAtMax = currentValue + add;\n\n output[j++] = (sumAtMax - sumAtMin) / step;\n\n if (j === numberOfPoints) {\n break main;\n }\n\n min = max;\n max += step;\n sumAtMin = sumAtMax;\n }\n\n currentValue += integral(previousX, nextX, slope, intercept);\n\n previousX = nextX;\n previousY = nextY;\n\n if (i < xLength) {\n nextX = x[i];\n nextY = y[i];\n i++;\n } else if (i === xLength) {\n nextX += lastOriginalStep;\n nextY = 0;\n }\n\n slope = getSlope(previousX, previousY, nextX, nextY);\n intercept = -slope * previousX + previousY;\n }\n\n return output;\n}\n","/**\n * function that retrieves the getEquallySpacedData with the variant \"slot\"\n *\n * @param {Array} x\n * @param {Array} y\n * @param {number} from - Initial point\n * @param {number} to - Final point\n * @param {number} numberOfPoints\n * @return {Array} - Array of y's equally spaced with the variant \"slot\"\n */\nexport default function equallySpacedSlot(x, y, from, to, numberOfPoints) {\n let xLength = x.length;\n\n let step = (to - from) / (numberOfPoints - 1);\n let halfStep = step / 2;\n let lastStep = x[x.length - 1] - x[x.length - 2];\n\n let start = from - halfStep;\n let output = new Array(numberOfPoints);\n\n // Init main variables\n let min = start;\n let max = start + step;\n\n let previousX = -Number.MAX_VALUE;\n let previousY = 0;\n let nextX = x[0];\n let nextY = y[0];\n let frontOutsideSpectra = 0;\n let backOutsideSpectra = true;\n\n let currentValue = 0;\n\n // for slot algorithm\n let currentPoints = 0;\n\n let i = 1; // index of input\n let j = 0; // index of output\n\n main: while (true) {\n if (previousX >= nextX) throw new Error('x must be an increasing serie');\n while (previousX - max > 0) {\n // no overlap with original point, just consume current value\n if (backOutsideSpectra) {\n currentPoints++;\n backOutsideSpectra = false;\n }\n\n output[j] = currentPoints <= 0 ? 0 : currentValue / currentPoints;\n j++;\n\n if (j === numberOfPoints) {\n break main;\n }\n\n min = max;\n max += step;\n currentValue = 0;\n currentPoints = 0;\n }\n\n if (previousX > min) {\n currentValue += previousY;\n currentPoints++;\n }\n\n if (previousX === -Number.MAX_VALUE || frontOutsideSpectra > 1) {\n currentPoints--;\n }\n\n previousX = nextX;\n previousY = nextY;\n\n if (i < xLength) {\n nextX = x[i];\n nextY = y[i];\n i++;\n } else {\n nextX += lastStep;\n nextY = 0;\n frontOutsideSpectra++;\n }\n }\n\n return output;\n}\n","import sequentialFill from 'ml-array-sequential-fill';\nimport { zonesWithPoints, invert } from 'ml-zones';\n\nimport equallySpacedSmooth from './equallySpacedSmooth';\nimport equallySpacedSlot from './equallySpacedSlot';\n\n/**\n * Function that returns a Number array of equally spaced numberOfPoints\n * containing a representation of intensities of the spectra arguments x\n * and y.\n *\n * The options parameter contains an object in the following form:\n * from: starting point\n * to: last point\n * numberOfPoints: number of points between from and to\n * variant: \"slot\" or \"smooth\" - smooth is the default option\n *\n * The slot variant consist that each point in the new array is calculated\n * averaging the existing points between the slot that belongs to the current\n * value. The smooth variant is the same but takes the integral of the range\n * of the slot and divide by the step size between two points in the new array.\n *\n * If exclusions zone are present, zones are ignored !\n * @param {object} [arrayXY={}] - object containing 2 properties x and y (both an array)\n * @param {object} [options={}]\n * @param {number} [options.from=x[0]]\n * @param {number} [options.to=x[x.length-1]]\n * @param {string} [options.variant='smooth']\n * @param {number} [options.numberOfPoints=100]\n * @param {Array} [options.exclusions=[]] array of from / to that should be skipped for the generation of the points\n * @param {Array} [options.zones=[]] array of from / to that should be kept\n * @return {object} new object with x / y array with the equally spaced data.\n */\n\nexport default function equallySpaced(arrayXY = {}, options = {}) {\n let { x, y } = arrayXY;\n let xLength = x.length;\n let reverse = false;\n if (x.length > 1 && x[0] > x[1]) {\n x = x.slice().reverse();\n y = y.slice().reverse();\n reverse = true;\n }\n\n let {\n from = x[0],\n to = x[xLength - 1],\n variant = 'smooth',\n numberOfPoints = 100,\n exclusions = [],\n zones = [],\n } = options;\n\n if (xLength !== y.length) {\n throw new RangeError(\"the x and y vector doesn't have the same size.\");\n }\n\n if (typeof from !== 'number' || isNaN(from)) {\n throw new RangeError(\"'from' option must be a number\");\n }\n\n if (typeof to !== 'number' || isNaN(to)) {\n throw new RangeError(\"'to' option must be a number\");\n }\n\n if (typeof numberOfPoints !== 'number' || isNaN(numberOfPoints)) {\n throw new RangeError(\"'numberOfPoints' option must be a number\");\n }\n\n if (numberOfPoints < 2) {\n throw new RangeError(\"'numberOfPoints' option must be greater than 1\");\n }\n\n if (zones.length === 0) {\n zones = invert(exclusions, { from, to });\n }\n\n zones = zonesWithPoints(zones, numberOfPoints, { from, to });\n\n let xResult = [];\n let yResult = [];\n for (let zone of zones) {\n let zoneResult = processZone(\n x,\n y,\n zone.from,\n zone.to,\n zone.numberOfPoints,\n variant,\n reverse,\n );\n\n xResult = xResult.concat(zoneResult.x);\n yResult = yResult.concat(zoneResult.y);\n }\n if (reverse) {\n if (from < to) {\n return { x: xResult.reverse(), y: yResult.reverse() };\n } else {\n return { x: xResult, y: yResult };\n }\n } else {\n if (from < to) {\n return { x: xResult, y: yResult };\n } else {\n return { x: xResult.reverse(), y: yResult.reverse() };\n }\n }\n}\n\nfunction processZone(x, y, from, to, numberOfPoints, variant) {\n if (numberOfPoints < 1) {\n throw new RangeError('the number of points must be at least 1');\n }\n\n let output =\n variant === 'slot'\n ? equallySpacedSlot(x, y, from, to, numberOfPoints)\n : equallySpacedSmooth(x, y, from, to, numberOfPoints);\n\n return {\n x: sequentialFill({\n from,\n to,\n size: numberOfPoints,\n }),\n y: output,\n };\n}\n","export default function getZones(from, to, exclusions = []) {\n if (from > to) {\n [from, to] = [to, from];\n }\n\n // in exclusions from and to have to be defined\n exclusions = exclusions.filter(\n (exclusion) => exclusion.from !== undefined && exclusion.to !== undefined\n );\n\n exclusions = JSON.parse(JSON.stringify(exclusions));\n // we ensure that from before to\n exclusions.forEach((exclusion) => {\n if (exclusion.from > exclusion.to) {\n [exclusion.to, exclusion.from] = [exclusion.from, exclusion.to];\n }\n });\n\n exclusions.sort((a, b) => a.from - b.from);\n\n // we will rework the exclusions in order to remove overlap and outside range (from / to)\n exclusions.forEach((exclusion) => {\n if (exclusion.from < from) exclusion.from = from;\n if (exclusion.to > to) exclusion.to = to;\n });\n for (let i = 0; i < exclusions.length - 1; i++) {\n if (exclusions[i].to > exclusions[i + 1].from) {\n exclusions[i].to = exclusions[i + 1].from;\n }\n }\n exclusions = exclusions.filter((exclusion) => exclusion.from < exclusion.to);\n\n if (!exclusions || exclusions.length === 0) {\n return [{ from, to }];\n }\n\n let zones = [];\n let currentFrom = from;\n for (let exclusion of exclusions) {\n if (currentFrom < exclusion.from) {\n zones.push({\n from: currentFrom,\n to: exclusion.from\n });\n }\n\n currentFrom = exclusion.to;\n }\n if (currentFrom < to) {\n zones.push({\n from: currentFrom,\n to: to\n });\n }\n\n return zones;\n}\n","import getZones from './getZones';\n\n/**\n * Filter an array x/y based on various criteria\n * x points are expected to be sorted\n *\n * @param {object} points\n * @param {object} [options={}]\n * @param {array} [options.from]\n * @param {array} [options.to]\n * @param {array} [options.exclusions=[]]\n * @return {{x: Array, y: Array}}\n */\n\nexport default function filterX(points, options = {}) {\n const { x, y } = points;\n const { from = x[0], to = x[x.length - 1], exclusions = [] } = options;\n\n let zones = getZones(from, to, exclusions);\n\n\n let currentZoneIndex = 0;\n let newX = [];\n let newY = [];\n let position = 0;\n while (position < x.length) {\n if (\n x[position] <= zones[currentZoneIndex].to &&\n x[position] >= zones[currentZoneIndex].from\n ) {\n newX.push(x[position]);\n newY.push(y[position]);\n } else {\n if (x[position] > zones[currentZoneIndex].to) {\n currentZoneIndex++;\n if (!zones[currentZoneIndex]) break;\n }\n }\n position++;\n }\n\n return {\n x: newX,\n y: newY\n };\n}\n","import { DecisionTreeClassifier, DecisionTreeRegression } from \"ml-cart\";\nimport {\n RandomForestClassifier,\n RandomForestRegression\n} from \"ml-random-forest\";\n\n// Try to keep this list in the same structure as the README.\n\n// Unsupervised learning\nexport { PCA } from \"ml-pca\";\nimport * as HClust from \"ml-hclust\";\nexport { HClust };\nexport { default as KMeans } from \"ml-kmeans\";\n\n// Supervised learning\nimport * as NaiveBayes from \"ml-naivebayes\";\nexport { NaiveBayes };\nexport { default as KNN } from \"ml-knn\";\nexport { PLS, KOPLS, OPLS, OPLSNipals } from \"ml-pls\";\nimport * as CrossValidation from \"ml-cross-validation\";\nexport { CrossValidation };\nexport { default as ConfusionMatrix } from \"ml-confusion-matrix\";\nexport { DecisionTreeClassifier };\nexport { RandomForestClassifier };\n\n// Artificial neural networks\nexport { default as FNN } from \"ml-fnn\";\nexport { default as SOM } from \"ml-som\";\n\n// Regression\nexport {\n SimpleLinearRegression,\n PolynomialRegression,\n MultivariateLinearRegression,\n PowerRegression,\n ExponentialRegression,\n TheilSenRegression,\n RobustPolynomialRegression\n} from \"ml-regression\";\nexport { DecisionTreeRegression };\nexport { RandomForestRegression };\n\n// Optimization\nexport { default as levenbergMarquardt } from \"ml-levenberg-marquardt\";\nimport * as FCNNLS from \"ml-fcnnls\";\nexport { FCNNLS };\n\n// Math\nimport * as MatrixLib from \"ml-matrix\";\nconst {\n Matrix,\n SVD,\n EVD,\n CholeskyDecomposition,\n LuDecomposition,\n QrDecomposition\n} = MatrixLib;\nexport {\n MatrixLib,\n Matrix,\n SVD,\n EVD,\n CholeskyDecomposition,\n LuDecomposition,\n QrDecomposition\n};\n\nexport { SparseMatrix } from \"ml-sparse-matrix\";\nexport { default as Kernel } from \"ml-kernel\";\nimport { distance, similarity } from \"ml-distance\";\nexport { distance as Distance, similarity as Similarity };\nexport { default as distanceMatrix } from \"ml-distance-matrix\";\nexport { default as XSadd } from \"ml-xsadd\";\n\n// Statistics\nexport { default as Performance } from \"ml-performance\";\n\n// Data preprocessing\nexport { default as savitzkyGolay } from \"ml-savitzky-golay\";\n\n// Utility\nexport { default as BitArray } from \"ml-bit-array\";\nexport { default as HashTable } from \"ml-hash-table\";\nexport { default as padArray } from \"ml-pad-array\";\nexport { default as binarySearch } from \"binary-search\";\nimport * as numSort from \"num-sort\";\nexport { numSort };\nexport { default as Random } from \"ml-random\";\nimport * as GSD from 'ml-gsd';\nexport { GSD };\n\nimport min from \"ml-array-min\";\nimport max from \"ml-array-max\";\nimport median from \"ml-array-median\";\nimport mean from \"ml-array-mean\";\nimport mode from \"ml-array-mode\";\nimport normed from \"ml-array-normed\";\nimport rescale from \"ml-array-rescale\";\nimport sequentialFill from \"ml-array-sequential-fill\";\nimport sum from \"ml-array-sum\";\nimport standardDeviation from \"ml-array-standard-deviation\";\nimport variance from \"ml-array-variance\";\nexport const Array = {\n min,\n max,\n median,\n mean,\n mode,\n normed,\n rescale,\n sequentialFill,\n standardDeviation,\n sum,\n variance\n};\n\nimport centroidsMerge from \"ml-array-xy-centroids-merge\";\nimport closestX from \"ml-arrayxy-closestx\";\nimport covariance from \"ml-array-xy-covariance\";\nimport maxMerge from \"ml-array-xy-max-merge\";\nimport maxY from \"ml-array-xy-max-y\";\nimport sortX from \"ml-array-xy-sort-x\";\nimport uniqueX from \"ml-arrayxy-uniquex\";\nimport weightedMerge from \"ml-array-xy-weighted-merge\";\nimport equallySpaced from \"ml-array-xy-equally-spaced\";\nimport filterX from \"ml-array-xy-filter-x\";\nexport const ArrayXY = {\n centroidsMerge,\n closestX,\n covariance,\n maxMerge,\n maxY,\n sortX,\n uniqueX,\n weightedMerge,\n equallySpaced,\n filterX\n};\n"],"names":["toString","Object","prototype","isAnyArray","object","call","endsWith","max","input","options","arguments","length","undefined","isArray","TypeError","_options$fromIndex","fromIndex","_options$toIndex","toIndex","Number","isInteger","Error","maxValue","i","min","minValue","rescale","output","Array","currentMin","currentMax","RangeError","_options$min","autoMinMax","_options$max","factor","indent","repeat","indentData","inspectMatrix","inspectMatrixWithOptions","this","matrix","maxRows","maxColumns","maxNumSize","constructor","name","inspectData","rows","columns","maxI","Math","maxJ","result","line","j","push","formatNumber","get","join","num","numStr","String","padEnd","precise","toPrecision","exponential","toExponential","eIndex","indexOf","e","slice","installMathOperations","AbstractMatrix","Matrix","add","value","addS","addM","set","checkMatrix","sub","subS","subM","subtract","subtractS","subtractM","mul","mulS","mulM","multiply","multiplyS","multiplyM","div","divS","divM","divide","divideS","divideM","mod","modS","modM","modulus","modulusS","modulusM","and","andS","andM","or","orS","orM","xor","xorS","xorM","leftShift","leftShiftS","leftShiftM","signPropagatingRightShift","signPropagatingRightShiftS","signPropagatingRightShiftM","rightShift","rightShiftS","rightShiftM","zeroFillRightShift","zeroFillRightShiftS","zeroFillRightShiftM","not","abs","acos","acosh","asin","asinh","atan","atanh","cbrt","ceil","clz32","cos","cosh","exp","expm1","floor","fround","log","log1p","log10","log2","round","sign","sin","sinh","sqrt","tan","tanh","trunc","pow","arg0","powS","powM","checkRowIndex","index","outer","checkColumnIndex","checkRowVector","vector","to1DArray","checkColumnVector","checkIndices","rowIndices","columnIndices","row","checkRowIndices","column","checkColumnIndices","some","r","from","c","checkRange","startRow","endRow","startColumn","endColumn","checkNumber","newArray","array","sumByRow","sum","sumByColumn","sumAll","v","productByRow","productByColumn","productAll","varianceByRow","unbiased","mean","cols","variance","sum1","sum2","x","varianceByColumn","varianceAll","size","centerByRow","centerByColumn","centerAll","getScaleByRow","scale","scaleByRow","getScaleByColumn","scaleByColumn","getScaleAll","divider","scaleAll","newRows","newColumns","newData","newMatrix","fill","random","interval","zeros","data","l","matrix1","matrix2","isMatrix","klass","apply","callback","to2DArray","copy","toJSON","isRowVector","isColumnVector","isVector","isSquare","isSymmetric","isEchelonForm","previousColumn","checked","isReducedEchelonForm","k","echelonForm","clone","h","iMax","swapRows","tmp","reducedEchelonForm","m","n","maxRow","p","pivot","setSubMatrix","neg","getRow","getRowVector","rowVector","setRow","row1","row2","temp","getColumn","getColumnVector","columnVector","setColumn","swapColumns","column1","column2","addRowVector","subRowVector","mulRowVector","divRowVector","addColumnVector","subColumnVector","mulColumnVector","divColumnVector","mulRow","mulColumn","maxIndex","idx","minIndex","maxRowIndex","minRow","minRowIndex","maxColumn","maxColumnIndex","minColumn","minColumnIndex","diag","norm","type","cumulativeSum","dot","vector2","vector1","mmul","other","Bcolj","Float64Array","s","strassen2x2","a11","b11","a12","b12","a21","b21","a22","b22","m1","m2","m3","m4","m5","c00","c01","c10","c11","strassen3x3","a00","a01","a02","a10","a20","b00","b01","b02","b10","b20","m6","m7","m8","m9","m12","m13","m14","m15","m16","m17","m18","c02","c12","c20","c21","c22","mmulStrassen","y","r1","c1","r2","c2","embed","mat","resultat","console","warn","blockMult","a","b","halfRows","parseInt","halfCols","subMatrix","scaleRows","isFinite","scaleColumns","flipRows","middle","first","last","flipColumns","kroneckerProduct","q","transpose","sortRows","compareFunction","compareNumbers","sort","sortColumns","subMatrixRow","indices","subMatrixColumn","selection","rowIndex","columnIndex","trace","by","product","standardDeviation","center","Symbol","for","rand","randomInt","randInt","diagonal","identity","eye","negate","tensorProduct","nRows","nColumns","arrayData","removeRow","splice","addRow","removeColumn","newRow","addColumn","BaseView","MatrixColumnView","MatrixColumnSelectionView","MatrixFlipColumnView","MatrixFlipRowView","MatrixRowView","MatrixRowSelectionView","MatrixSelectionView","MatrixSubView","MatrixTransposeView","WrapperMatrix1D","_calculateIndex","WrapperMatrix2D","wrap","LuDecomposition","t","LUcolj","kmax","lu","pivotVector","pivotSign","LU","isSingular","col","solve","count","X","determinant","hypotenuse","QrDecomposition","qr","rdiag","nrm","QR","Rdiag","isFullRank","SingularValueDecomposition","computeLeftSingularVectors","computeRightSingularVectors","autoTranspose","wantu","Boolean","wantv","swapped","aux","nu","ni","U","V","work","si","nct","nrt","mrc","pp","eps","EPSILON","kase","alpha","MIN_VALUE","isNaN","ks","f","cs","sn","sp","spm1","epm1","sk","ek","shift","g","Y","threshold","scols","Ls","rightSingularVectors","VL","vrows","urows","VLU","solveForDiagonal","inverse","vcols","ucols","tol","ii","useSVD","leftHandSide","rightHandSide","d","subMatrix0","subMatrix1","subMatrix2","xrange","exception","range","dependenciesOneRow","error","thresholdValue","thresholdError","returnArray","linearDependencies","results","Abis","pseudoInverse","svdSolution","SVD","leftSingularVectors","covariance","xMatrix","yMatrix","yIsSame","cov","correlation","sdx","sdy","corr","EigenvalueDecomposition","assumeSymmetric","tred2","tql2","H","ort","orthes","hqr2","hh","dl1","c3","el1","s2","tst1","high","low","nn","w","ra","sa","vr","vi","notlast","cdivres","exshift","z","iter","cdiv","xr","xi","yr","yi","CholeskyDecomposition","dimension","positiveDefinite","L","isPositiveDefinite","B","nipals","scaleScores","maxIterations","terminationCriteria","u","tOld","diff","counter","xResidual","residual","yResidual","betas","sumValue","toDiscreteDistribution","numberOfClasses","counts","giniImpurity","probabilities","getNumberOfClasses","filter","val","arr","map","reduce","giniGain","splitted","splitsImpurity","splits","currentSplit","squaredError","meanArray","currentElement","regressionError","matrixSplitter","lesserX","greaterX","lesserY","greaterY","zip","ret","gainFunctions","gini","Utils","regression","splitFunctions","TreeNode","kind","gainFunction","splitFunction","minNumSamples","maxDepth","bestSplit","XTranspose","bestGain","Infinity","check","currentFeature","splitValues","featureSplit","currentSplitVal","split","gain","maxGain","splitValue","lesser","greater","calculatePrediction","distribution","train","currentDepth","parentGain","splitColumn","splittedMatrix","left","right","classify","setNodeParameters","node","defaultOptions","DecisionTreeClassifier","model","root","Tree","assign","trainingSet","trainingLabels","predict","toPredict","predictions","DecisionTreeRegression","trainingValues","SMALLEST_UNSAFE_INTEGER","LARGEST_SAFE_INTEGER","UINT32_MAX","UINT32_SIZE","INT32_SIZE","INT32_MAX","UINT21_SIZE","UINT21_MAX","checkFloat","examplesBaggingWithReplacement","trainingValue","seed","engine","Random","autoSeed","Xr","featureBagging","replacement","usedIndex","toRet","Set","has","RandomForestBase","maxFeatures","nEstimators","treeOptions","isClassifier","indexes","useSampleBagging","Estimator","DTClassifier","DTRegression","estimators","est","load","res","values","predictionValues","RandomForestClassifier","baseModel","mode","super","pop","_ref","module","exports","window","median","quickSelectMedian","selectionMethods","arrayMean","arrayMedian","selectionMethod","RandomForestRegression","PCA","dataset","means","stdevs","S","R","excludedFeatures","isCovarianceMatrix","method","nCompNIPALS","ignoreZeroVariance","_computeFromCovarianceMatrix","_adjust","covarianceMatrix","_computeWithNIPALS","svd","singularValues","eigenvalues","singularValue","nComponents","invert","getExplainedVariance","getCumulativeVariance","explained","getEigenvectors","getEigenvalues","getStandardDeviations","getLoadings","evd","EVD","eigenvectorMatrix","realEigenvalues","reverse","dc","NIPALS","squaredEuclidean","euclidean","distanceMatrix","distanceFn","getMatrix","Heap","defaultCmp","heapify","heappop","heappush","heappushpop","heapreplace","insort","nlargest","nsmallest","updateItem","_siftdown","_siftup","lo","hi","cmp","mid","concat","item","lastelt","returnitem","_i","_len","_ref1","_results","_results1","_j","pos","elem","los","startpos","newitem","parent","parentpos","childpos","endpos","rightpos","nodes","replace","pushpop","peek","contains","clear","empty","heap","toArray","insert","top","front","require$$0","Cluster","children","height","isLeaf","cut","list","ans","group","groups","forEach","child","traverse","cb","visit","cluster","singleLink","dKI","dKJ","completeLink","averageLink","dIJ","nj","weightedAverageLink","centroidLink","medianLink","wardLink","nk","wardLink2","ai","aj","agnes","distanceFunction","isDistanceMatrix","updateFunc","getDistanceMatrix","numLeaves","toLowerCase","clusters","distance","getSmallestDistance","cluster1","cluster2","newCluster","newClusters","newDistanceMatrix","previous","newIndex","getPreviousIndex","prevI","prevICluster","smallest","smallestI","smallestJ","prev1","prev2","nearestVector","listVectors","similarityFunction","vectorIndex","maxSim","sim","minDist","MAX_VALUE","dist","calculateDistanceMatrix","updateClusterID","centers","clusterID","updateCenters","prevCenters","K","nDim","centersLen","dim","id","hasConverged","oldCenters","tolerance","LOOP","FLOAT_MUL","sh1","sh2","sh3","multiply_uint32","nlo","XSadd","Date","now","state","Uint32Array","init","getFloat","bind","getUint32","nextState","periodCertification","PROB_TOLERANCE","randomChoice","valuesArr","cumSum","getArray","randomIndex","seedOrRandom","xsadd","XSAdd","randomGenerator","choice","randomSample","mostDistant","maxDist","minDistCent","kmeanspp","nSamples","localTrials","firstCenterIdx","closestDistSquared","cumSumClosestDistSquared","candidateIdx","distanceToCandidates","euclideanDistances","bestCandidate","bestPot","bestDistSquared","newDistSquared","newPot","A","distanceSymbol","KMeansResult","centroids","converged","iterations","nearest","centroid","computeInformation","enrichedCentroids","withIterations","initialization","step","newCenters","kmeansGenerator","stepResult","stepNumber","kmeans","separateClasses","features","classes","totalPerClasses","separatedClasses","currentIndex","GaussianNB","reload","calculateProbabilities","C1","PI","std","logPriorProbability","currentStd","getCurrentClass","modelName","currentCase","maxProbability","predictedClass","currentProbability","calculateLogProbability","C2","MultinomialNB","conditionalProbability","priorProbability","separateClass","classValues","divisor","matrixLog","Node","obj","KDTree","points","metric","dimensions","buildTree","restoreParent","toJSONImpl","point","maxNodes","maxDistance","bestNodes","BinaryHeap","nearestSearch","ownDistance","linearPoint","bestChild","linearDistance","otherChild","saveNode","content","src","dest","depth","scoreFunction","element","bubbleUp","end","sinkDown","parentN","elemScore","child2N","child1N","swap","child1","child1Score","child2","KNN","labels","kdTree","isEuclidean","euclideanDistance","getSinglePrediction","knn","nearestPoints","pointsPerClass","maxPoints","lastElement","currentClass","currentPoints","pow2array","initializeMatrices","PLS","meanX","stdDevX","meanY","stdDevY","PBQ","R2X","scaleMethod","latentVectors","rx","cx","ry","cy","ssqXcal","sumOfSquaresY","T","P","Q","W","transposeX","transposeY","tIndex","maxSumColIndex","uIndex","t1","den","pnorm","ssqYcal","E","F","KOPLS","YLoadingMat","SigmaPow","YScoreMat","predScoreMat","YOrthLoadingVec","YOrthEigen","YOrthScoreMat","toNorm","TURegressionCoeff","kernelX","kernel","orthogonalComp","predictiveComp","predictiveComponents","orthogonalComponents","compute","Identity","Sigma","diagonalMatrix","YOrthScoreNorm","TpiPrime","CoTemp","SoTemp","toiPrime","ITo","lastScoreMat","lastTpPrime","KTestTrain","YOrthScoreVector","scoreMatPrime","p1","p2","p3","prediction","predYOrthVectors","ConfusionMatrix","actual","predicted","distinctLabels","actualIdx","predictedIdx","getLabels","getTotalCount","getTrueCount","getFalseCount","getTruePositiveCount","label","getIndex","getTrueNegativeCount","getFalsePositiveCount","getFalseNegativeCount","getPositiveCount","getNegativeCount","getTruePositiveRate","getTrueNegativeRate","getPositivePredictiveValue","TP","getNegativePredictiveValue","TN","getFalseNegativeRate","getFalsePositiveRate","getFalseDiscoveryRate","FP","getFalseOmissionRate","FN","getF1Score","getMatthewsCorrelationCoefficient","getInformedness","getMarkedness","getConfusionTable","getAccuracy","correct","incorrect","getCount","actualIndex","predictedIndex","createCommonjsModule","fn","runtime","global","Op","hasOwn","hasOwnProperty","$Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","regeneratorRuntime","GenStateSuspendedStart","GenStateSuspendedYield","GenStateExecuting","GenStateCompleted","ContinueSentinel","IteratorPrototype","getProto","getPrototypeOf","NativeIteratorPrototype","Gp","GeneratorFunctionPrototype","Generator","create","GeneratorFunction","displayName","isGeneratorFunction","genFun","ctor","mark","setPrototypeOf","__proto__","awrap","arg","__await","defineIteratorMethods","AsyncIterator","async","innerFn","outerFn","self","tryLocsList","next","then","done","keys","key","Context","reset","skipTempReset","prev","sent","_sent","delegate","tryEntries","resetTryEntry","charAt","stop","rootRecord","completion","rval","dispatchException","context","handle","loc","caught","record","entry","tryLoc","hasCatch","hasFinally","catchLoc","finallyLoc","abrupt","finallyEntry","complete","afterLoc","finish","thrown","delegateYield","iterable","resultName","nextLoc","protoGenerator","generator","_invoke","makeInvokeMethod","tryCatch","err","invoke","resolve","reject","Promise","unwrapped","previousPromise","enqueue","callInvokeWithMethodAndArg","doneResult","delegateResult","maybeInvokeDelegate","return","info","pushTryEntry","locs","iteratorMethod","Function","hadRuntime","getOwnPropertyNames","oldRuntime","runtimeModule","regenerator","_callee","M","N","twiddle","_context","factory","getFolds","allIdx","current","folds","randi","testIndex","trainIndex","el","idx2","sampleAClass","classVector","fraction","classVectorSorted","JSON","parse","stringify","indexOfSelected","ind","mask","includes","leaveOneOut","Classifier","classifierOptions","leavePOut","distinct","getDistinct","confusionMatrix","initMatrix","gen","combinations","testIdx","trainIdx","validateWithCallback","validate","kFold","testFeatures","trainFeatures","testLabels","trainLabels","getTrainTest","classifier","updateConfusionMatrix","predictedLabels","OPLSNipals","numberOSC","uNew","wOrtho","tOrtho","pOrtho","filteredX","weightsXOrtho","loadingsXOrtho","scoresXOrtho","weightsXPred","loadingsXpred","scoresXpred","loadingsY","tss","OPLS","opls","meansY","stdevsY","tCV","tOrthCV","yHatCV","nComp","cvFolds","from1DArray","Q2","nc","oplsCV","modelNC","yHatk","tPredk","tOrthk","oplsk","fold","trainTest","_getTrainTest","testXk","Xk","Yk","dataCenter","dataSD","plsCV","scores","Eh","tPred","yHat","tssy","Q2y","_predictAll","xRes","XOrth","FeaturesCS","labelsCS","Xres","plsCall","R2x","R2y","plsC","pPred","wPred","betasPred","Qpc","tOrth","pOrth","wOrth","totalPred","Yres","getLogs","getScores","scoresX","scoresY","trueLabels","fromLabels","tssx","oplsC","logistic","expELU","param","softExponential","softExponentialPrime","ACTIVATION_FUNCTIONS","activation","derivate","arctan","softsign","relu","softplus","bent","sinusoid","sinc","gaussian","Layer","inputSize","outputSize","regularization","epsilon","activationParam","selectedFunction","params","actFunction","derFunction","activationFunction","mlMatrix","forward","backpropagation","delta","dW","db","aCopy","update","OutputLayer","FeedForwardNeuralNetworks","hiddenLayers","learningRate","dicts","layers","buildNetwork","dictOutputs","inputs","propagate","outputs","NodeSquare","weights","som","neighbors","adjustWeights","target","influence","getDistance","otherNode","getDistanceTorus","distX","distY","gridDim","getNeighbors","xy","torus","getPos","bestNeighbor","direction","simA","simB","getPosition","NodeHexagonal","hX","distZ","fields","randomizer","squareEuclidean","gridType","SOM","numWeights","converters","getConverters","extractor","creator","nodeType","hx","distanceMethod","getMaxDistance","times","findBMU","adjust","iterationCount","startLearningRate","mapRadius","algorithmMethod","_initNodes","normalizers","denormalizers","getNormalizer","getDenormalizer","minMax","getRandomValue","zero","one","loadModel","eval","export","includeDistance","initNodes","setTraining","convertedSet","numIterations","timeConstant","trainOne","neighbourhoodRadius","trainingSetFactor","bmu","_findBestMatchingUnit","now2","radiusLimit","xMin","xMax","yMin","yMax","theX","theY","getConvertedNodes","candidate","lowest","computePosition","_predict","getQuantizationError","fit","getFit","maybeToPrecision","digits","checkArraySize","BaseRegression","toLaTeX","score","y2","xSum","ySum","chi2","rmsd","xSquared","ySquared","xY","PolynomialRegression","degree","powers","coefficients","checkArrayLength","regress","precision","_toFormula","isLaTeX","sup","closeSup","str","json","pr","FT","SimpleLinearRegression","slope","intercept","computeX","xFactor","absIntercept","slr","numerator","ExponentialRegression","er","yl","linear","PowerRegression","newInputs","latex","xl","MultivariateLinearRegression","statistics","xt","xx","invxx","beta","fittedValues","ri","stdError","stdErrorMatrix","stdErrors","tStats","summary","regressionStatistics","standardError","observations","variables","tStat","sigma","GaussianKernel","constant","PolynomialKernel","SigmoidKernel","ANOVAKernel","len","CauchyKernel","ExponentialKernel","HistogramIntersectionKernel","LaplacianKernel","MultiquadraticKernel","RationalQuadraticKernel","kernelType","rbf","polynomial","poly","anova","cauchy","histogram","HistogramKernel","laplacian","multiquadratic","rational","RationalKernel","sigmoid","mlp","Kernel","KernelConstructor","kernelFunction","landmarks","kernelMatrix","TheilSenRegression","theilSen","slopes","medianSlope","cuts","RobustPolynomialRegression","robustPolynomial","_","tuples","getRandomTuples","calcCoefficients","residuals","residualsMedian","tuple","half","errorCalculation","parameters","parameterizedFunction","func","gradientFunction","evaluatedData","gradientDifference","paramFunction","auxParams","funcParam","matrixFunction","damping","gradientFunc","matrixFunc","inverseMatrix","levenbergMarquardt","errorTolerance","minValues","maxValues","initialValues","parLen","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","iteration","parameterValues","parameterError","sortCollectionSet","collection","objectCollection","BigInt","sorted","cssls","XtX","XtY","Pset","choXtX","luXtX","sortedPset","sortedEset","cols2Solve","vars","initialisation","Fset","D","setDifference","C","optimality","maxIter","Jset","fullSet","notPset","fcnnls","infeasIndex","Hset","ones","hRowColIdx","negRowColIdx","alphaMin","minIdx","idx2zero","findIndex","newParam","fcnnlsVector","haystack","needle","comparator","assertNumber","number","largestPrime","primeNumbers","nextPrime","binarySearch","ascending","FREE","FULL","REMOVED","defaultInitialCapacity","defaultMinLoadFactor","defaultMaxLoadFactor","HashTable","table","minLoadFactor","maxLoadFactor","freeEntries","lowWaterMark","highWaterMark","initialCapacity","capacity","chooseHighWaterMark","indexOfKey","indexOfInsertion","newCapacity","chooseGrowCapacity","rehash","remove","noRehash","maybeShrinkCapacity","delete","chooseShrinkCapacity","containsKey","hash","decrement","containsValue","indexOfValue","ensureCapacity","minCapacity","oldCapacity","oldTable","oldValues","oldState","newTable","newValues","newState","chooseLowWaterMark","forEachKey","forEachValue","forEachPair","minLoad","maxLoad","SparseMatrix","_init","elements","symmetric","forEachNonZero","bandWidth","isBanded","width","v1","v2","cardinality","getNonZeros","setThreshold","newThreshold","trans","inplaceOperator","inplaceOperatorScalar","inplaceOperatorMatrix","staticOperator","inplaceMethod","staticMethod","operators","operator","fillTemplateFunction","op","methods","mathMethod","template","RegExp","additiveSymmetric","avg","bhattacharyya","canberra","chebyshev","clark","czekanowskiSimilarity","up","down","czekanowskiDistance","dice","q1","q2","divergence","fidelity","gower","harmonicMean","hellinger","innerProduct","intersection","jaccard","jeffreys","jensenDifference","jensenShannon","kdivergence","kulczynski","kullbackLeibler","kumarHassebrook","kumarJohnson","lorentzian","manhattan","matusita","minkowski","motyka","neyman","pearson","probabilisticSymmetric","ruzicka","soergel","sorensen","squared","squaredChord","taneja","tanimoto","bitvector","inter","union","tanimotoS","topsoe","waveHedges","createTree","spectrum","minWindow","to","mainCreateTree","start","getSimilarity","gamma","treeSimilarity","getFunction","cosine","diceD","intersectionD","jaccardD","kulczynskiD","motykaD","avgA","avgB","newA","newB","squaredChordD","pred","cutoffs","tn","tp","fp","nNeg","nPos","nPosPred","nNegPred","Performance","isDistance","predP","all","targ","currentPred","nTp","nFp","getMeasure","measure","measures","getAURC","auc","getAUDC","getDistribution","cutLength","cutLow","cutHigh","xLabels","interValues","intraValues","interCumPercent","intraCumPercent","nTP","currentTP","nFP","currentFP","thisTP","thisFP","names","acc","fpr","tpr","fnr","tnr","ppv","npv","pcfall","pcmiss","lift","rpp","rnp","arrayCase","cond","matrixCase","padArray","factorial","windowSize","derivative","pad","padValue","savitzkyGolay","J","inic","Jtranspose","det","eightBits","arr1","arr2","getBit","setBit","toBinaryString","substr","parseBinaryString","toHexString","parseHexString","toDebug","binary","SavitzkyGolay","np","fullWeights","hs","constantH","wg1","wg2","d1","d2","getHs","wg","GramPoly","Grampoly","GenFact","gf","Weight","gsd","yIn","noiseLevel","sgOptions","smoothY","heightFactor","broadRatio","maxCriteria","minMaxRatio","derivativeThreshold","realTopDetection","equalSpaced","isEqualSpaced","getNoiseLevel","yCorrection","dY","ddY","yData","SG","xData","dX","maxDdy","maxY","lastMax","lastMin","minddY","intervalL","intervalR","broadMask","minddYLen","intervalLLen","intervalRLen","broadMaskLen","possible","frequency","distanceJ","minDistance","gettingCloser","signals","signalsLen","lastK","soft","yLeft","yRight","determineRealTop","base","maxDx","minDx","stddev","averageDeviations","peakList","currentPoint","sumOfGaussians","nL","optimizeGaussianSum","opts","pInit","pMin","pMax","dt","lmOptions","pFit","LM","singleGaussian","factor2","optimizeSingleGaussian","peak","sumOfLorentzians","optimizeLorentzianSum","singleLorentzian","optimizeSingleLorentzian","optimizePeaks","functionName","factorWidth","optimizationOptions","sampling","lastIndex","groupPeaks","peaks","sampleFunction","limits","optPeaks","fitResult","nbPoints","sampleX","sampleY","upperLimit","lowerLimit","joinBroadPeaks","broadLines","candidates","fitted","broadenPeaks","overlap","nextPeak","maxCount","_options$algorithm","algorithm","_options$sumValue","_options$maxValue","absoluteSumValue","absoluteSum","currentMaxValue","sumFactor","_i2","_typeof","sequentialFill","_options","_options$from","_options$to","_options$size","_options$unbiased","_options$mean","sqrError","mergeByCentroids","originalPoints","mergedPoints","originalIndex","mergedIndex","closestX","descending","maxMerge","groupWidth","merged","maxAbscissa","calculateIndex","sortX","sortFunc","grouped","response","uniqueX","weightedMerge","weightedAbscissa","normalize","zones","NEGATIVE_INFINITY","POSITIVE_INFINITY","zone","currentZone","exclusions","exclusion","nextExclusion","zonesWithPoints","numberOfPoints","unitsPerPoint","currentTotal","integral","x0","x1","equallySpacedSmooth","xLength","halfStep","initialOriginalStep","lastOriginalStep","previousX","previousY","nextX","nextY","currentValue","sumAtMin","sumAtMax","main","equallySpacedSlot","lastStep","frontOutsideSpectra","backOutsideSpectra","equallySpaced","arrayXY","variant","xResult","yResult","zoneResult","processZone","getZones","currentFrom","filterX","currentZoneIndex","newX","newY","position","MatrixLib","normed","ArrayXY","centroidsMerge"],"mappings":"gPAAA,MAAMA,SAAWC,OAAOC,UAAUF,SAEnB,SAASG,WAAWC,UAC1BJ,SAASK,KAAKD,GAAQE,SAAS,UCDxC,SAASC,IAAIC,OACPC,EAAUC,UAAUC,OAAS,QAAsBC,IAAjBF,UAAU,GAAmBA,UAAU,GAAK,OAE7EG,WAAQL,SACL,IAAIM,UAAU,6BAGD,IAAjBN,EAAMG,aACF,IAAIG,UAAU,+BAGlBC,EAAqBN,EAAQO,UAC7BA,OAAmC,IAAvBD,EAAgC,EAAIA,EAChDE,EAAmBR,EAAQS,QAC3BA,OAA+B,IAArBD,EAA8BT,EAAMG,OAASM,KAEvDD,EAAY,GAAKA,GAAaR,EAAMG,SAAWQ,OAAOC,UAAUJ,SAC5D,IAAIK,MAAM,+DAGdH,GAAWF,GAAaE,EAAUV,EAAMG,SAAWQ,OAAOC,UAAUF,SAChE,IAAIG,MAAM,yFAGdC,EAAWd,EAAMQ,GAEZO,EAAIP,EAAY,EAAGO,EAAIL,EAASK,IACnCf,EAAMe,GAAKD,IAAUA,EAAWd,EAAMe,WAGrCD,EC9BT,SAASE,IAAIhB,OACPC,EAAUC,UAAUC,OAAS,QAAsBC,IAAjBF,UAAU,GAAmBA,UAAU,GAAK,OAE7EG,WAAQL,SACL,IAAIM,UAAU,6BAGD,IAAjBN,EAAMG,aACF,IAAIG,UAAU,+BAGlBC,EAAqBN,EAAQO,UAC7BA,OAAmC,IAAvBD,EAAgC,EAAIA,EAChDE,EAAmBR,EAAQS,QAC3BA,OAA+B,IAArBD,EAA8BT,EAAMG,OAASM,KAEvDD,EAAY,GAAKA,GAAaR,EAAMG,SAAWQ,OAAOC,UAAUJ,SAC5D,IAAIK,MAAM,+DAGdH,GAAWF,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,KAC1B+gC,aAAahhC,GACbghC,aAAa/gC,GAETlnB,OAAOwc,MAAMyK,IACR,EAGLjnB,OAAOwc,MAAM0K,GACT,EAGDD,EAAOC,cAGM,CAACD,EAAMC,KAC3B+gC,aAAahhC,GACbghC,aAAa/gC,GAETlnB,OAAOwc,MAAMyK,GACT,EAGJjnB,OAAOwc,MAAM0K,IACR,EAGFA,EAAQD,qLChCT,MAAMkhC,aAAe,WAEtBC,aAAe,CAEnBD,aAGA,EACA,GACA,GACA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,WAGA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,WAGA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,WACA,WAGA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,IACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,EACA,EACA,GACA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,WAGA,GACA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,GACA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,GACA,IACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,YAKK,SAASE,UAAU3kD,OACpBoF,EAAQw/C,aAAaF,aAAc1kD,EAAO6kD,kBAC1Cz/C,EAAQ,IACVA,GAASA,GAEJs/C,aAAat/C,GAPtBs/C,aAAaxxC,KAAK2xC,WCtWlB,MAAMC,KAAO,EACPC,KAAO,EACPC,QAAU,EAEVC,uBAAyB,IACzBC,qBAAuB,EAAI,EAC3BC,qBAAuB,EAAI,EAElB,MAAMC,UACnBnnD,YAAYrC,EAAU,OAChBA,aAAmBwpD,sBAChBC,MAAQzpD,EAAQypD,MAAM1lD,aACtBknB,OAASjrB,EAAQirB,OAAOlnB,aACxBszB,MAAQr3B,EAAQq3B,MAAMtzB,aACtB2lD,cAAgB1pD,EAAQ0pD,mBACxBC,cAAgB3pD,EAAQ2pD,mBACxBja,SAAW1vC,EAAQ0vC,cACnBka,YAAc5pD,EAAQ4pD,iBACtBC,aAAe7pD,EAAQ6pD,uBACvBC,cAAgB9pD,EAAQ2pD,qBAIz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EAAM0C,GAAkB/R,IACvCjlD,EAAEm3D,IAAa7C,EAAM0C,GAAkBz4D,KAEvC04D,EAAKlgE,KAAKiJ,EAAEm3D,IACZD,EAAKngE,KAAKuS,EAAE6tD,YAERn3D,EAAEm3D,GAAY7C,EAAM0C,GAAkB/R,KACxC+R,KACK1C,EAAM0C,IAAmB,MAGlCG,UAGK,CACLn3D,EAAGi3D,EACH3tD,EAAG4tD,gBCOLj/D,SADI+b,IAEJA,IAFI+N,IAGJA,0BACApL,wCACAxI,kCACAe,mBACEkoD,UA8CSliE,QAAQ,KACnBJ,UACAjB,MACA8rB,OAAAA,OACAhgB,KAAAA,UACAyf,cACAi4C,OACAriE,QAAAA,QACA09D,eAAAA,eACA1mD,kBAAAA,kBACA9M,IAAAA,IACAW,SAAAA,UAaWy3D,QAAU,gBACrBC,iBACAhE,SAAAA,oBACAr/C,aACAu/C,SAAAA,SACAnG,KAAAA,KACAwG,MAAAA,MACAI,QAAAA,QACAC,cAAAA,cACAmC,cAAAA,cACAS,QAAAA"} \ No newline at end of file +{"version":3,"file":"ml.min.js","sources":["../node_modules/ml-array-rescale/node_modules/is-any-array/src/index.js","../node_modules/ml-array-rescale/node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-rescale/node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-rescale/lib-es6/index.js","../node_modules/ml-matrix/src/inspect.js","../node_modules/ml-matrix/src/mathOperations.js","../node_modules/ml-matrix/src/util.js","../node_modules/ml-matrix/src/stat.js","../node_modules/ml-matrix/src/matrix.js","../node_modules/ml-matrix/src/views/base.js","../node_modules/ml-matrix/src/views/column.js","../node_modules/ml-matrix/src/views/columnSelection.js","../node_modules/ml-matrix/src/views/flipColumn.js","../node_modules/ml-matrix/src/views/flipRow.js","../node_modules/ml-matrix/src/views/row.js","../node_modules/ml-matrix/src/views/rowSelection.js","../node_modules/ml-matrix/src/views/selection.js","../node_modules/ml-matrix/src/views/sub.js","../node_modules/ml-matrix/src/views/transpose.js","../node_modules/ml-matrix/src/wrap/WrapperMatrix1D.js","../node_modules/ml-matrix/src/wrap/WrapperMatrix2D.js","../node_modules/ml-matrix/src/wrap/wrap.js","../node_modules/ml-matrix/src/dc/lu.js","../node_modules/ml-matrix/src/dc/util.js","../node_modules/ml-matrix/src/dc/qr.js","../node_modules/ml-matrix/src/dc/svd.js","../node_modules/ml-matrix/src/decompositions.js","../node_modules/ml-matrix/src/determinant.js","../node_modules/ml-matrix/src/linearDependencies.js","../node_modules/ml-matrix/src/pseudoInverse.js","../node_modules/ml-matrix/src/covariance.js","../node_modules/ml-matrix/src/correlation.js","../node_modules/ml-matrix/src/dc/evd.js","../node_modules/ml-matrix/src/dc/cholesky.js","../node_modules/ml-matrix/src/dc/nipals.js","../node_modules/ml-array-sum/node_modules/is-any-array/src/index.js","../node_modules/ml-array-sum/lib-es6/index.js","../node_modules/ml-array-mean/lib-es6/index.js","../node_modules/ml-cart/src/utils.js","../node_modules/ml-cart/src/TreeNode.js","../node_modules/ml-cart/src/DecisionTreeClassifier.js","../node_modules/ml-cart/src/DecisionTreeRegression.js","../node_modules/random-js/dist/random-js.esm.js","../node_modules/ml-random-forest/src/utils.js","../node_modules/ml-random-forest/src/RandomForestBase.js","../node_modules/ml-random-forest/src/RandomForestClassifier.js","../node_modules/ml-array-median/node_modules/is-any-array/src/index.js","../node_modules/median-quickselect/lib/median-quickselect.min.js","../node_modules/ml-array-median/lib-es6/index.js","../node_modules/ml-random-forest/src/RandomForestRegression.js","../node_modules/ml-pca/src/pca.js","../node_modules/ml-distance-euclidean/lib-es6/euclidean.js","../node_modules/ml-distance-matrix/src/index.js","../node_modules/heap/lib/heap.js","../node_modules/heap/index.js","../node_modules/ml-hclust/src/Cluster.js","../node_modules/ml-hclust/src/agnes.js","../node_modules/ml-nearest-vector/lib-es6/index.js","../node_modules/ml-kmeans/src/utils.js","../node_modules/ml-xsadd/lib-es6/xsadd.js","../node_modules/ml-random/lib-es6/choice.js","../node_modules/ml-random/lib-es6/index.js","../node_modules/ml-kmeans/src/initialization.js","../node_modules/ml-kmeans/src/KMeansResult.js","../node_modules/ml-kmeans/src/kmeans.js","../node_modules/ml-naivebayes/src/utils.js","../node_modules/ml-naivebayes/src/GaussianNB.js","../node_modules/ml-naivebayes/src/MultinomialNB.js","../node_modules/ml-knn/src/KDTree.js","../node_modules/ml-knn/src/index.js","../node_modules/ml-pls/src/util/utils.js","../node_modules/ml-pls/src/PLS.js","../node_modules/ml-pls/src/KOPLS.js","../node_modules/ml-confusion-matrix/src/index.js","../node_modules/ml-combinations/lib/index.js","../node_modules/ml-cross-validation/src/getFolds.js","../node_modules/ml-cross-validation/src/sampleAClass.js","../node_modules/ml-cross-validation/src/index.js","../node_modules/ml-pls/src/OPLSNipals.js","../node_modules/ml-pls/src/util/tss.js","../node_modules/ml-pls/src/OPLS.js","../node_modules/ml-fnn/FeedForwardNeuralNetwork.js","../node_modules/ml-som/src/node-square.js","../node_modules/ml-som/src/node-hexagonal.js","../node_modules/ml-som/src/index.js","../node_modules/ml-regression-base/src/maybeToPrecision.js","../node_modules/ml-regression-base/src/checkArrayLength.js","../node_modules/ml-regression-base/src/index.js","../node_modules/ml-regression-polynomial/src/index.js","../node_modules/ml-regression-simple-linear/src/index.js","../node_modules/ml-regression-exponential/src/index.js","../node_modules/ml-regression-power/src/index.js","../node_modules/ml-regression-multivariate-linear/src/index.js","../node_modules/ml-kernel-gaussian/gaussian-kernel.js","../node_modules/ml-kernel-polynomial/polynomial-kernel.js","../node_modules/ml-kernel-sigmoid/sigmoid-kernel.js","../node_modules/ml-kernel/src/kernels/anova-kernel.js","../node_modules/ml-kernel/src/kernels/cauchy-kernel.js","../node_modules/ml-kernel/src/kernels/exponential-kernel.js","../node_modules/ml-kernel/src/kernels/histogram-intersection-kernel.js","../node_modules/ml-kernel/src/kernels/laplacian-kernel.js","../node_modules/ml-kernel/src/kernels/multiquadratic-kernel.js","../node_modules/ml-kernel/src/kernels/rational-quadratic-kernel.js","../node_modules/ml-kernel/src/kernel.js","../node_modules/ml-regression-theil-sen/src/index.js","../node_modules/ml-regression-robust-polynomial/src/index.js","../node_modules/ml-levenberg-marquardt/node_modules/is-any-array/src/index.js","../node_modules/ml-levenberg-marquardt/src/errorCalculation.js","../node_modules/ml-levenberg-marquardt/src/step.js","../node_modules/ml-levenberg-marquardt/src/index.js","../node_modules/ml-fcnnls/src/util/selection.js","../node_modules/ml-fcnnls/src/util/sortCollectionSet.js","../node_modules/ml-fcnnls/src/cssls.js","../node_modules/ml-fcnnls/src/initialisation.js","../node_modules/ml-fcnnls/src/util/setDifference.js","../node_modules/ml-fcnnls/src/optimality.js","../node_modules/ml-fcnnls/src/fcnnls.js","../node_modules/ml-fcnnls/src/fcnnlsVector.js","../node_modules/binary-search/index.js","../node_modules/num-sort/index.js","../node_modules/ml-hash-table/src/primeFinder.js","../node_modules/ml-hash-table/src/HashTable.js","../node_modules/ml-sparse-matrix/src/index.js","../node_modules/ml-distance/src/distances/additiveSymmetric.js","../node_modules/ml-distance/src/distances/avg.js","../node_modules/ml-distance/src/distances/bhattacharyya.js","../node_modules/ml-distance/src/distances/canberra.js","../node_modules/ml-distance/src/distances/chebyshev.js","../node_modules/ml-distance/src/distances/clark.js","../node_modules/ml-distance/src/similarities/czekanowski.js","../node_modules/ml-distance/src/distances/czekanowski.js","../node_modules/ml-distance/src/distances/dice.js","../node_modules/ml-distance/src/distances/divergence.js","../node_modules/ml-distance/src/distances/fidelity.js","../node_modules/ml-distance/src/distances/gower.js","../node_modules/ml-distance/src/distances/harmonicMean.js","../node_modules/ml-distance/src/distances/hellinger.js","../node_modules/ml-distance/src/distances/innerProduct.js","../node_modules/ml-distance/src/distances/intersection.js","../node_modules/ml-distance/src/distances/jaccard.js","../node_modules/ml-distance/src/distances/jeffreys.js","../node_modules/ml-distance/src/distances/jensenDifference.js","../node_modules/ml-distance/src/distances/jensenShannon.js","../node_modules/ml-distance/src/distances/kdivergence.js","../node_modules/ml-distance/src/distances/kulczynski.js","../node_modules/ml-distance/src/distances/kullbackLeibler.js","../node_modules/ml-distance/src/distances/kumarHassebrook.js","../node_modules/ml-distance/src/distances/kumarJohnson.js","../node_modules/ml-distance/src/distances/lorentzian.js","../node_modules/ml-distance/src/distances/manhattan.js","../node_modules/ml-distance/src/distances/matusita.js","../node_modules/ml-distance/src/distances/minkowski.js","../node_modules/ml-distance/src/distances/motyka.js","../node_modules/ml-distance/src/distances/neyman.js","../node_modules/ml-distance/src/distances/pearson.js","../node_modules/ml-distance/src/distances/probabilisticSymmetric.js","../node_modules/ml-distance/src/distances/ruzicka.js","../node_modules/ml-distance/src/distances/soergel.js","../node_modules/ml-distance/src/distances/sorensen.js","../node_modules/ml-distance/src/distances/squared.js","../node_modules/ml-distance/src/distances/squaredChord.js","../node_modules/ml-distance/src/distances/taneja.js","../node_modules/ml-distance/src/similarities/tanimoto.js","../node_modules/ml-distance/src/distances/tanimoto.js","../node_modules/ml-distance/src/distances/topsoe.js","../node_modules/ml-distance/src/distances/waveHedges.js","../node_modules/ml-tree-similarity/src/createTree.js","../node_modules/ml-tree-similarity/src/getSimilarity.js","../node_modules/ml-tree-similarity/src/index.js","../node_modules/ml-distance/src/similarities/cosine.js","../node_modules/ml-distance/src/similarities/dice.js","../node_modules/ml-distance/src/similarities/intersection.js","../node_modules/ml-distance/src/similarities/jaccard.js","../node_modules/ml-distance/src/similarities/kulczynski.js","../node_modules/ml-distance/src/similarities/motyka.js","../node_modules/ml-distance/src/similarities/pearson.js","../node_modules/ml-distance/src/similarities/squaredChord.js","../node_modules/ml-ngmca/src/util/zeroInsteadOfNegative.js","../node_modules/ml-ngmca/src/stages/checkMatrixS.js","../node_modules/ml-ngmca/src/util/normBy.js","../node_modules/ml-ngmca/src/util/normProj.js","../node_modules/ml-ngmca/src/stages/updateMatrixA.js","../node_modules/ml-ngmca/src/util/getMax.js","../node_modules/ml-ngmca/src/stages/updateMatrixS.js","../node_modules/ml-ngmca/src/stages/initialize.js","../node_modules/ml-ngmca/src/stages/normalize.js","../node_modules/ml-ngmca/src/util/getMedians.js","../node_modules/ml-ngmca/src/util/dimMADstd.js","../node_modules/ml-ngmca/src/stages/updateLambda.js","../node_modules/ml-ngmca/src/nGMCA.js","../node_modules/ml-performance/src/measures.js","../node_modules/ml-performance/src/index.js","../node_modules/ml-pad-array/src/index.js","../node_modules/ml-savitzky-golay/src/index.js","../node_modules/ml-bit-array/src/creator.js","../node_modules/ml-bit-array/src/index.js","../node_modules/ml-gsd/node_modules/ml-savitzky-golay-generalized/src/index.js","../node_modules/ml-gsd/src/gsd.js","../node_modules/ml-optimize-lorentzian/src/sumOfGaussians.js","../node_modules/ml-optimize-lorentzian/src/optimizeGaussianSum.js","../node_modules/ml-optimize-lorentzian/src/singleGaussian.js","../node_modules/ml-optimize-lorentzian/src/optimizeSingleGaussian.js","../node_modules/ml-optimize-lorentzian/src/sumOfLorentzians.js","../node_modules/ml-optimize-lorentzian/src/optimizeLorentzianSum.js","../node_modules/ml-optimize-lorentzian/src/singleLorentzian.js","../node_modules/ml-optimize-lorentzian/src/optimizeSingleLorentzian.js","../node_modules/ml-gsd/src/post/optimizePeaks.js","../node_modules/ml-gsd/src/post/joinBroadPeaks.js","../node_modules/ml-gsd/src/post/broadenPeaks.js","../node_modules/is-any-array/src/index.js","../node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-mode/lib-es6/index.js","../node_modules/ml-array-normed/node_modules/is-any-array/src/index.js","../node_modules/ml-array-normed/node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-normed/lib-es6/index.js","../node_modules/ml-array-sequential-fill/lib-es6/index.js","../node_modules/ml-array-variance/node_modules/is-any-array/src/index.js","../node_modules/ml-array-variance/lib-es6/index.js","../node_modules/ml-array-standard-deviation/lib-es6/index.js","../node_modules/ml-array-xy-centroids-merge/src/index.js","../node_modules/ml-arrayxy-closestx/src/index.js","../node_modules/ml-array-xy-covariance/src/index.js","../node_modules/ml-array-xy-max-merge/src/index.js","../node_modules/ml-array-xy-max-y/src/index.js","../node_modules/ml-array-xy-sort-x/src/index.js","../node_modules/ml-arrayxy-uniquex/src/index.js","../node_modules/ml-array-xy-weighted-merge/src/index.js","../node_modules/ml-zones/src/normalize.js","../node_modules/ml-zones/src/invert.js","../node_modules/ml-zones/src/zonesWithPoints.js","../node_modules/ml-array-xy-equally-spaced/src/integral.js","../node_modules/ml-array-xy-equally-spaced/src/equallySpacedSmooth.js","../node_modules/ml-array-xy-equally-spaced/src/equallySpacedSlot.js","../node_modules/ml-array-xy-equally-spaced/src/index.js","../node_modules/ml-array-xy-filter-x/src/getZones.js","../node_modules/ml-array-xy-filter-x/src/index.js","../src/index.js"],"sourcesContent":["const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\n\nfunction min(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var minValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import isArray from 'is-any-array';\nimport max from 'ml-array-max';\nimport min from 'ml-array-min';\n\nfunction rescale(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n } else if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var output;\n\n if (options.output !== undefined) {\n if (!isArray(options.output)) {\n throw new TypeError('output option must be an array if specified');\n }\n\n output = options.output;\n } else {\n output = new Array(input.length);\n }\n\n var currentMin = min(input);\n var currentMax = max(input);\n\n if (currentMin === currentMax) {\n throw new RangeError('minimum and maximum input values are equal. Cannot rescale a constant array');\n }\n\n var _options$min = options.min,\n minValue = _options$min === void 0 ? options.autoMinMax ? currentMin : 0 : _options$min,\n _options$max = options.max,\n maxValue = _options$max === void 0 ? options.autoMinMax ? currentMax : 1 : _options$max;\n\n if (minValue >= maxValue) {\n throw new RangeError('min option must be smaller than max option');\n }\n\n var factor = (maxValue - minValue) / (currentMax - currentMin);\n\n for (var i = 0; i < input.length; i++) {\n output[i] = (input[i] - currentMin) * factor + minValue;\n }\n\n return output;\n}\n\nexport default rescale;\n","const indent = ' '.repeat(2);\r\nconst indentData = ' '.repeat(4);\r\n\r\nexport function inspectMatrix() {\r\n return inspectMatrixWithOptions(this);\r\n}\r\n\r\nexport function inspectMatrixWithOptions(matrix, options = {}) {\r\n const { maxRows = 15, maxColumns = 10, maxNumSize = 8 } = options;\r\n return `${matrix.constructor.name} {\r\n${indent}[\r\n${indentData}${inspectData(matrix, maxRows, maxColumns, maxNumSize)}\r\n${indent}]\r\n${indent}rows: ${matrix.rows}\r\n${indent}columns: ${matrix.columns}\r\n}`;\r\n}\r\n\r\nfunction inspectData(matrix, maxRows, maxColumns, maxNumSize) {\r\n const { rows, columns } = matrix;\r\n const maxI = Math.min(rows, maxRows);\r\n const maxJ = Math.min(columns, maxColumns);\r\n const result = [];\r\n for (let i = 0; i < maxI; i++) {\r\n let line = [];\r\n for (let j = 0; j < maxJ; j++) {\r\n line.push(formatNumber(matrix.get(i, j), maxNumSize));\r\n }\r\n result.push(`${line.join(' ')}`);\r\n }\r\n if (maxJ !== columns) {\r\n result[result.length - 1] += ` ... ${columns - maxColumns} more columns`;\r\n }\r\n if (maxI !== rows) {\r\n result.push(`... ${rows - maxRows} more rows`);\r\n }\r\n return result.join(`\\n${indentData}`);\r\n}\r\n\r\nfunction formatNumber(num, maxNumSize) {\r\n const numStr = String(num);\r\n if (numStr.length <= maxNumSize) {\r\n return numStr.padEnd(maxNumSize, ' ');\r\n }\r\n const precise = num.toPrecision(maxNumSize - 2);\r\n if (precise.length <= maxNumSize) {\r\n return precise;\r\n }\r\n const exponential = num.toExponential(maxNumSize - 2);\r\n const eIndex = exponential.indexOf('e');\r\n const e = exponential.slice(eIndex);\r\n return exponential.slice(0, maxNumSize - e.length) + e;\r\n}\r\n","export function installMathOperations(AbstractMatrix, Matrix) {\r\n AbstractMatrix.prototype.add = function add(value) {\r\n if (typeof value === 'number') return this.addS(value);\r\n return this.addM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.addS = function addS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.addM = function addM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.add = function add(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.add(value);\r\n };\r\n\r\n AbstractMatrix.prototype.sub = function sub(value) {\r\n if (typeof value === 'number') return this.subS(value);\r\n return this.subM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.subS = function subS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.subM = function subM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sub = function sub(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sub(value);\r\n };\r\n AbstractMatrix.prototype.subtract = AbstractMatrix.prototype.sub;\r\n AbstractMatrix.prototype.subtractS = AbstractMatrix.prototype.subS;\r\n AbstractMatrix.prototype.subtractM = AbstractMatrix.prototype.subM;\r\n AbstractMatrix.subtract = AbstractMatrix.sub;\r\n\r\n AbstractMatrix.prototype.mul = function mul(value) {\r\n if (typeof value === 'number') return this.mulS(value);\r\n return this.mulM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.mulS = function mulS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.mulM = function mulM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.mul = function mul(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.mul(value);\r\n };\r\n AbstractMatrix.prototype.multiply = AbstractMatrix.prototype.mul;\r\n AbstractMatrix.prototype.multiplyS = AbstractMatrix.prototype.mulS;\r\n AbstractMatrix.prototype.multiplyM = AbstractMatrix.prototype.mulM;\r\n AbstractMatrix.multiply = AbstractMatrix.mul;\r\n\r\n AbstractMatrix.prototype.div = function div(value) {\r\n if (typeof value === 'number') return this.divS(value);\r\n return this.divM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.divS = function divS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.divM = function divM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.div = function div(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.div(value);\r\n };\r\n AbstractMatrix.prototype.divide = AbstractMatrix.prototype.div;\r\n AbstractMatrix.prototype.divideS = AbstractMatrix.prototype.divS;\r\n AbstractMatrix.prototype.divideM = AbstractMatrix.prototype.divM;\r\n AbstractMatrix.divide = AbstractMatrix.div;\r\n\r\n AbstractMatrix.prototype.mod = function mod(value) {\r\n if (typeof value === 'number') return this.modS(value);\r\n return this.modM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.modS = function modS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) % value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.modM = function modM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) % matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.mod = function mod(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.mod(value);\r\n };\r\n AbstractMatrix.prototype.modulus = AbstractMatrix.prototype.mod;\r\n AbstractMatrix.prototype.modulusS = AbstractMatrix.prototype.modS;\r\n AbstractMatrix.prototype.modulusM = AbstractMatrix.prototype.modM;\r\n AbstractMatrix.modulus = AbstractMatrix.mod;\r\n\r\n AbstractMatrix.prototype.and = function and(value) {\r\n if (typeof value === 'number') return this.andS(value);\r\n return this.andM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.andS = function andS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) & value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.andM = function andM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) & matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.and = function and(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.and(value);\r\n };\r\n\r\n AbstractMatrix.prototype.or = function or(value) {\r\n if (typeof value === 'number') return this.orS(value);\r\n return this.orM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.orS = function orS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) | value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.orM = function orM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) | matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.or = function or(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.or(value);\r\n };\r\n\r\n AbstractMatrix.prototype.xor = function xor(value) {\r\n if (typeof value === 'number') return this.xorS(value);\r\n return this.xorM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.xorS = function xorS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) ^ value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.xorM = function xorM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) ^ matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.xor = function xor(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.xor(value);\r\n };\r\n\r\n AbstractMatrix.prototype.leftShift = function leftShift(value) {\r\n if (typeof value === 'number') return this.leftShiftS(value);\r\n return this.leftShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.leftShiftS = function leftShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) << value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.leftShiftM = function leftShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) << matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.leftShift = function leftShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.leftShift(value);\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShift = function signPropagatingRightShift(value) {\r\n if (typeof value === 'number') return this.signPropagatingRightShiftS(value);\r\n return this.signPropagatingRightShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShiftS = function signPropagatingRightShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >> value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.signPropagatingRightShiftM = function signPropagatingRightShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >> matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.signPropagatingRightShift = function signPropagatingRightShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.signPropagatingRightShift(value);\r\n };\r\n\r\n AbstractMatrix.prototype.rightShift = function rightShift(value) {\r\n if (typeof value === 'number') return this.rightShiftS(value);\r\n return this.rightShiftM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.rightShiftS = function rightShiftS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >>> value);\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.rightShiftM = function rightShiftM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) >>> matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.rightShift = function rightShift(matrix, value) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.rightShift(value);\r\n };\r\n AbstractMatrix.prototype.zeroFillRightShift = AbstractMatrix.prototype.rightShift;\r\n AbstractMatrix.prototype.zeroFillRightShiftS = AbstractMatrix.prototype.rightShiftS;\r\n AbstractMatrix.prototype.zeroFillRightShiftM = AbstractMatrix.prototype.rightShiftM;\r\n AbstractMatrix.zeroFillRightShift = AbstractMatrix.rightShift;\r\n\r\n AbstractMatrix.prototype.not = function not() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, ~(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.not = function not(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.not();\r\n };\r\n\r\n AbstractMatrix.prototype.abs = function abs() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.abs(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.abs = function abs(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.abs();\r\n };\r\n\r\n AbstractMatrix.prototype.acos = function acos() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.acos(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.acos = function acos(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.acos();\r\n };\r\n\r\n AbstractMatrix.prototype.acosh = function acosh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.acosh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.acosh = function acosh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.acosh();\r\n };\r\n\r\n AbstractMatrix.prototype.asin = function asin() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.asin(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.asin = function asin(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.asin();\r\n };\r\n\r\n AbstractMatrix.prototype.asinh = function asinh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.asinh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.asinh = function asinh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.asinh();\r\n };\r\n\r\n AbstractMatrix.prototype.atan = function atan() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.atan(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.atan = function atan(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.atan();\r\n };\r\n\r\n AbstractMatrix.prototype.atanh = function atanh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.atanh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.atanh = function atanh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.atanh();\r\n };\r\n\r\n AbstractMatrix.prototype.cbrt = function cbrt() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cbrt(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cbrt = function cbrt(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cbrt();\r\n };\r\n\r\n AbstractMatrix.prototype.ceil = function ceil() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.ceil(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.ceil = function ceil(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.ceil();\r\n };\r\n\r\n AbstractMatrix.prototype.clz32 = function clz32() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.clz32(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.clz32 = function clz32(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.clz32();\r\n };\r\n\r\n AbstractMatrix.prototype.cos = function cos() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cos(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cos = function cos(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cos();\r\n };\r\n\r\n AbstractMatrix.prototype.cosh = function cosh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.cosh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.cosh = function cosh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.cosh();\r\n };\r\n\r\n AbstractMatrix.prototype.exp = function exp() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.exp(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.exp = function exp(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.exp();\r\n };\r\n\r\n AbstractMatrix.prototype.expm1 = function expm1() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.expm1(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.expm1 = function expm1(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.expm1();\r\n };\r\n\r\n AbstractMatrix.prototype.floor = function floor() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.floor(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.floor = function floor(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.floor();\r\n };\r\n\r\n AbstractMatrix.prototype.fround = function fround() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.fround(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.fround = function fround(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.fround();\r\n };\r\n\r\n AbstractMatrix.prototype.log = function log() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log = function log(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log();\r\n };\r\n\r\n AbstractMatrix.prototype.log1p = function log1p() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log1p(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log1p = function log1p(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log1p();\r\n };\r\n\r\n AbstractMatrix.prototype.log10 = function log10() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log10(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log10 = function log10(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log10();\r\n };\r\n\r\n AbstractMatrix.prototype.log2 = function log2() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.log2(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.log2 = function log2(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.log2();\r\n };\r\n\r\n AbstractMatrix.prototype.round = function round() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.round(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.round = function round(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.round();\r\n };\r\n\r\n AbstractMatrix.prototype.sign = function sign() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sign(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sign = function sign(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sign();\r\n };\r\n\r\n AbstractMatrix.prototype.sin = function sin() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sin(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sin = function sin(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sin();\r\n };\r\n\r\n AbstractMatrix.prototype.sinh = function sinh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sinh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sinh = function sinh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sinh();\r\n };\r\n\r\n AbstractMatrix.prototype.sqrt = function sqrt() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.sqrt(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.sqrt = function sqrt(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.sqrt();\r\n };\r\n\r\n AbstractMatrix.prototype.tan = function tan() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.tan(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.tan = function tan(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.tan();\r\n };\r\n\r\n AbstractMatrix.prototype.tanh = function tanh() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.tanh(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.tanh = function tanh(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.tanh();\r\n };\r\n\r\n AbstractMatrix.prototype.trunc = function trunc() {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.trunc(this.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.trunc = function trunc(matrix) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.trunc();\r\n };\r\n\r\n AbstractMatrix.pow = function pow(matrix, arg0) {\r\n const newMatrix = new Matrix(matrix);\r\n return newMatrix.pow(arg0);\r\n };\r\n\r\n AbstractMatrix.prototype.pow = function pow(value) {\r\n if (typeof value === 'number') return this.powS(value);\r\n return this.powM(value);\r\n };\r\n\r\n AbstractMatrix.prototype.powS = function powS(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.pow(this.get(i, j), value));\r\n }\r\n }\r\n return this;\r\n };\r\n\r\n AbstractMatrix.prototype.powM = function powM(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (this.rows !== matrix.rows ||\r\n this.columns !== matrix.columns) {\r\n throw new RangeError('Matrices dimensions must be equal');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j)));\r\n }\r\n }\r\n return this;\r\n };\r\n}\r\n","/**\r\n * @private\r\n * Check that a row index is not out of bounds\r\n * @param {Matrix} matrix\r\n * @param {number} index\r\n * @param {boolean} [outer]\r\n */\r\nexport function checkRowIndex(matrix, index, outer) {\r\n let max = outer ? matrix.rows : matrix.rows - 1;\r\n if (index < 0 || index > max) {\r\n throw new RangeError('Row index out of range');\r\n }\r\n}\r\n\r\n/**\r\n * @private\r\n * Check that a column index is not out of bounds\r\n * @param {Matrix} matrix\r\n * @param {number} index\r\n * @param {boolean} [outer]\r\n */\r\nexport function checkColumnIndex(matrix, index, outer) {\r\n let max = outer ? matrix.columns : matrix.columns - 1;\r\n if (index < 0 || index > max) {\r\n throw new RangeError('Column index out of range');\r\n }\r\n}\r\n\r\n/**\r\n * @private\r\n * Check that the provided vector is an array with the right length\r\n * @param {Matrix} matrix\r\n * @param {Array|Matrix} vector\r\n * @return {Array}\r\n * @throws {RangeError}\r\n */\r\nexport function checkRowVector(matrix, vector) {\r\n if (vector.to1DArray) {\r\n vector = vector.to1DArray();\r\n }\r\n if (vector.length !== matrix.columns) {\r\n throw new RangeError(\r\n 'vector size must be the same as the number of columns',\r\n );\r\n }\r\n return vector;\r\n}\r\n\r\n/**\r\n * @private\r\n * Check that the provided vector is an array with the right length\r\n * @param {Matrix} matrix\r\n * @param {Array|Matrix} vector\r\n * @return {Array}\r\n * @throws {RangeError}\r\n */\r\nexport function checkColumnVector(matrix, vector) {\r\n if (vector.to1DArray) {\r\n vector = vector.to1DArray();\r\n }\r\n if (vector.length !== matrix.rows) {\r\n throw new RangeError('vector size must be the same as the number of rows');\r\n }\r\n return vector;\r\n}\r\n\r\nexport function checkIndices(matrix, rowIndices, columnIndices) {\r\n return {\r\n row: checkRowIndices(matrix, rowIndices),\r\n column: checkColumnIndices(matrix, columnIndices),\r\n };\r\n}\r\n\r\nexport function checkRowIndices(matrix, rowIndices) {\r\n if (typeof rowIndices !== 'object') {\r\n throw new TypeError('unexpected type for row indices');\r\n }\r\n\r\n let rowOut = rowIndices.some((r) => {\r\n return r < 0 || r >= matrix.rows;\r\n });\r\n\r\n if (rowOut) {\r\n throw new RangeError('row indices are out of range');\r\n }\r\n\r\n if (!Array.isArray(rowIndices)) rowIndices = Array.from(rowIndices);\r\n\r\n return rowIndices;\r\n}\r\n\r\nexport function checkColumnIndices(matrix, columnIndices) {\r\n if (typeof columnIndices !== 'object') {\r\n throw new TypeError('unexpected type for column indices');\r\n }\r\n\r\n let columnOut = columnIndices.some((c) => {\r\n return c < 0 || c >= matrix.columns;\r\n });\r\n\r\n if (columnOut) {\r\n throw new RangeError('column indices are out of range');\r\n }\r\n if (!Array.isArray(columnIndices)) columnIndices = Array.from(columnIndices);\r\n\r\n return columnIndices;\r\n}\r\n\r\nexport function checkRange(matrix, startRow, endRow, startColumn, endColumn) {\r\n if (arguments.length !== 5) {\r\n throw new RangeError('expected 4 arguments');\r\n }\r\n checkNumber('startRow', startRow);\r\n checkNumber('endRow', endRow);\r\n checkNumber('startColumn', startColumn);\r\n checkNumber('endColumn', endColumn);\r\n if (\r\n startRow > endRow ||\r\n startColumn > endColumn ||\r\n startRow < 0 ||\r\n startRow >= matrix.rows ||\r\n endRow < 0 ||\r\n endRow >= matrix.rows ||\r\n startColumn < 0 ||\r\n startColumn >= matrix.columns ||\r\n endColumn < 0 ||\r\n endColumn >= matrix.columns\r\n ) {\r\n throw new RangeError('Submatrix indices are out of range');\r\n }\r\n}\r\n\r\nexport function newArray(length, value = 0) {\r\n let array = [];\r\n for (let i = 0; i < length; i++) {\r\n array.push(value);\r\n }\r\n return array;\r\n}\r\n\r\nfunction checkNumber(name, value) {\r\n if (typeof value !== 'number') {\r\n throw new TypeError(`${name} must be a number`);\r\n }\r\n}\r\n","import { newArray } from './util';\r\n\r\nexport function sumByRow(matrix) {\r\n let sum = newArray(matrix.rows);\r\n for (let i = 0; i < matrix.rows; ++i) {\r\n for (let j = 0; j < matrix.columns; ++j) {\r\n sum[i] += matrix.get(i, j);\r\n }\r\n }\r\n return sum;\r\n}\r\n\r\nexport function sumByColumn(matrix) {\r\n let sum = newArray(matrix.columns);\r\n for (let i = 0; i < matrix.rows; ++i) {\r\n for (let j = 0; j < matrix.columns; ++j) {\r\n sum[j] += matrix.get(i, j);\r\n }\r\n }\r\n return sum;\r\n}\r\n\r\nexport function sumAll(matrix) {\r\n let v = 0;\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n v += matrix.get(i, j);\r\n }\r\n }\r\n return v;\r\n}\r\n\r\nexport function productByRow(matrix) {\r\n let sum = newArray(matrix.rows, 1);\r\n for (let i = 0; i < matrix.rows; ++i) {\r\n for (let j = 0; j < matrix.columns; ++j) {\r\n sum[i] *= matrix.get(i, j);\r\n }\r\n }\r\n return sum;\r\n}\r\n\r\nexport function productByColumn(matrix) {\r\n let sum = newArray(matrix.columns, 1);\r\n for (let i = 0; i < matrix.rows; ++i) {\r\n for (let j = 0; j < matrix.columns; ++j) {\r\n sum[j] *= matrix.get(i, j);\r\n }\r\n }\r\n return sum;\r\n}\r\n\r\nexport function productAll(matrix) {\r\n let v = 1;\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n v *= matrix.get(i, j);\r\n }\r\n }\r\n return v;\r\n}\r\n\r\nexport function varianceByRow(matrix, unbiased, mean) {\r\n const rows = matrix.rows;\r\n const cols = matrix.columns;\r\n const variance = [];\r\n\r\n for (let i = 0; i < rows; i++) {\r\n let sum1 = 0;\r\n let sum2 = 0;\r\n let x = 0;\r\n for (let j = 0; j < cols; j++) {\r\n x = matrix.get(i, j) - mean[i];\r\n sum1 += x;\r\n sum2 += x * x;\r\n }\r\n if (unbiased) {\r\n variance.push((sum2 - (sum1 * sum1) / cols) / (cols - 1));\r\n } else {\r\n variance.push((sum2 - (sum1 * sum1) / cols) / cols);\r\n }\r\n }\r\n return variance;\r\n}\r\n\r\nexport function varianceByColumn(matrix, unbiased, mean) {\r\n const rows = matrix.rows;\r\n const cols = matrix.columns;\r\n const variance = [];\r\n\r\n for (let j = 0; j < cols; j++) {\r\n let sum1 = 0;\r\n let sum2 = 0;\r\n let x = 0;\r\n for (let i = 0; i < rows; i++) {\r\n x = matrix.get(i, j) - mean[j];\r\n sum1 += x;\r\n sum2 += x * x;\r\n }\r\n if (unbiased) {\r\n variance.push((sum2 - (sum1 * sum1) / rows) / (rows - 1));\r\n } else {\r\n variance.push((sum2 - (sum1 * sum1) / rows) / rows);\r\n }\r\n }\r\n return variance;\r\n}\r\n\r\nexport function varianceAll(matrix, unbiased, mean) {\r\n const rows = matrix.rows;\r\n const cols = matrix.columns;\r\n const size = rows * cols;\r\n\r\n let sum1 = 0;\r\n let sum2 = 0;\r\n let x = 0;\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < cols; j++) {\r\n x = matrix.get(i, j) - mean;\r\n sum1 += x;\r\n sum2 += x * x;\r\n }\r\n }\r\n if (unbiased) {\r\n return (sum2 - (sum1 * sum1) / size) / (size - 1);\r\n } else {\r\n return (sum2 - (sum1 * sum1) / size) / size;\r\n }\r\n}\r\n\r\nexport function centerByRow(matrix, mean) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) - mean[i]);\r\n }\r\n }\r\n}\r\n\r\nexport function centerByColumn(matrix, mean) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) - mean[j]);\r\n }\r\n }\r\n}\r\n\r\nexport function centerAll(matrix, mean) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) - mean);\r\n }\r\n }\r\n}\r\n\r\nexport function getScaleByRow(matrix) {\r\n const scale = [];\r\n for (let i = 0; i < matrix.rows; i++) {\r\n let sum = 0;\r\n for (let j = 0; j < matrix.columns; j++) {\r\n sum += Math.pow(matrix.get(i, j), 2) / (matrix.columns - 1);\r\n }\r\n scale.push(Math.sqrt(sum));\r\n }\r\n return scale;\r\n}\r\n\r\nexport function scaleByRow(matrix, scale) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) / scale[i]);\r\n }\r\n }\r\n}\r\n\r\nexport function getScaleByColumn(matrix) {\r\n const scale = [];\r\n for (let j = 0; j < matrix.columns; j++) {\r\n let sum = 0;\r\n for (let i = 0; i < matrix.rows; i++) {\r\n sum += Math.pow(matrix.get(i, j), 2) / (matrix.rows - 1);\r\n }\r\n scale.push(Math.sqrt(sum));\r\n }\r\n return scale;\r\n}\r\n\r\nexport function scaleByColumn(matrix, scale) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) / scale[j]);\r\n }\r\n }\r\n}\r\n\r\nexport function getScaleAll(matrix) {\r\n const divider = matrix.size - 1;\r\n let sum = 0;\r\n for (let j = 0; j < matrix.columns; j++) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n sum += Math.pow(matrix.get(i, j), 2) / divider;\r\n }\r\n }\r\n return Math.sqrt(sum);\r\n}\r\n\r\nexport function scaleAll(matrix, scale) {\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n matrix.set(i, j, matrix.get(i, j) / scale);\r\n }\r\n }\r\n}\r\n","import rescale from 'ml-array-rescale';\r\n\r\nimport { inspectMatrix, inspectMatrixWithOptions } from './inspect';\r\nimport { installMathOperations } from './mathOperations';\r\nimport {\r\n sumByRow,\r\n sumByColumn,\r\n sumAll,\r\n productByRow,\r\n productByColumn,\r\n productAll,\r\n varianceByRow,\r\n varianceByColumn,\r\n varianceAll,\r\n centerByRow,\r\n centerByColumn,\r\n centerAll,\r\n scaleByRow,\r\n scaleByColumn,\r\n scaleAll,\r\n getScaleByRow,\r\n getScaleByColumn,\r\n getScaleAll,\r\n} from './stat';\r\nimport {\r\n checkRowVector,\r\n checkRowIndex,\r\n checkColumnIndex,\r\n checkColumnVector,\r\n checkRange,\r\n checkIndices,\r\n} from './util';\r\n\r\nexport class AbstractMatrix {\r\n static from1DArray(newRows, newColumns, newData) {\r\n let length = newRows * newColumns;\r\n if (length !== newData.length) {\r\n throw new RangeError('data length does not match given dimensions');\r\n }\r\n let newMatrix = new Matrix(newRows, newColumns);\r\n for (let row = 0; row < newRows; row++) {\r\n for (let column = 0; column < newColumns; column++) {\r\n newMatrix.set(row, column, newData[row * newColumns + column]);\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n static rowVector(newData) {\r\n let vector = new Matrix(1, newData.length);\r\n for (let i = 0; i < newData.length; i++) {\r\n vector.set(0, i, newData[i]);\r\n }\r\n return vector;\r\n }\r\n\r\n static columnVector(newData) {\r\n let vector = new Matrix(newData.length, 1);\r\n for (let i = 0; i < newData.length; i++) {\r\n vector.set(i, 0, newData[i]);\r\n }\r\n return vector;\r\n }\r\n\r\n static zeros(rows, columns) {\r\n return new Matrix(rows, columns);\r\n }\r\n\r\n static ones(rows, columns) {\r\n return new Matrix(rows, columns).fill(1);\r\n }\r\n\r\n static rand(rows, columns, options = {}) {\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { random = Math.random } = options;\r\n let matrix = new Matrix(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n matrix.set(i, j, random());\r\n }\r\n }\r\n return matrix;\r\n }\r\n\r\n static randInt(rows, columns, options = {}) {\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { min = 0, max = 1000, random = Math.random } = options;\r\n if (!Number.isInteger(min)) throw new TypeError('min must be an integer');\r\n if (!Number.isInteger(max)) throw new TypeError('max must be an integer');\r\n if (min >= max) throw new RangeError('min must be smaller than max');\r\n let interval = max - min;\r\n let matrix = new Matrix(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n let value = min + Math.round(random() * interval);\r\n matrix.set(i, j, value);\r\n }\r\n }\r\n return matrix;\r\n }\r\n\r\n static eye(rows, columns, value) {\r\n if (columns === undefined) columns = rows;\r\n if (value === undefined) value = 1;\r\n let min = Math.min(rows, columns);\r\n let matrix = this.zeros(rows, columns);\r\n for (let i = 0; i < min; i++) {\r\n matrix.set(i, i, value);\r\n }\r\n return matrix;\r\n }\r\n\r\n static diag(data, rows, columns) {\r\n let l = data.length;\r\n if (rows === undefined) rows = l;\r\n if (columns === undefined) columns = rows;\r\n let min = Math.min(l, rows, columns);\r\n let matrix = this.zeros(rows, columns);\r\n for (let i = 0; i < min; i++) {\r\n matrix.set(i, i, data[i]);\r\n }\r\n return matrix;\r\n }\r\n\r\n static min(matrix1, matrix2) {\r\n matrix1 = this.checkMatrix(matrix1);\r\n matrix2 = this.checkMatrix(matrix2);\r\n let rows = matrix1.rows;\r\n let columns = matrix1.columns;\r\n let result = new Matrix(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n result.set(i, j, Math.min(matrix1.get(i, j), matrix2.get(i, j)));\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n static max(matrix1, matrix2) {\r\n matrix1 = this.checkMatrix(matrix1);\r\n matrix2 = this.checkMatrix(matrix2);\r\n let rows = matrix1.rows;\r\n let columns = matrix1.columns;\r\n let result = new this(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n result.set(i, j, Math.max(matrix1.get(i, j), matrix2.get(i, j)));\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n static checkMatrix(value) {\r\n return AbstractMatrix.isMatrix(value) ? value : new Matrix(value);\r\n }\r\n\r\n static isMatrix(value) {\r\n return value != null && value.klass === 'Matrix';\r\n }\r\n\r\n get size() {\r\n return this.rows * this.columns;\r\n }\r\n\r\n apply(callback) {\r\n if (typeof callback !== 'function') {\r\n throw new TypeError('callback must be a function');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n callback.call(this, i, j);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n to1DArray() {\r\n let array = [];\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n array.push(this.get(i, j));\r\n }\r\n }\r\n return array;\r\n }\r\n\r\n to2DArray() {\r\n let copy = [];\r\n for (let i = 0; i < this.rows; i++) {\r\n copy.push([]);\r\n for (let j = 0; j < this.columns; j++) {\r\n copy[i].push(this.get(i, j));\r\n }\r\n }\r\n return copy;\r\n }\r\n\r\n toJSON() {\r\n return this.to2DArray();\r\n }\r\n\r\n isRowVector() {\r\n return this.rows === 1;\r\n }\r\n\r\n isColumnVector() {\r\n return this.columns === 1;\r\n }\r\n\r\n isVector() {\r\n return this.rows === 1 || this.columns === 1;\r\n }\r\n\r\n isSquare() {\r\n return this.rows === this.columns;\r\n }\r\n\r\n isSymmetric() {\r\n if (this.isSquare()) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j <= i; j++) {\r\n if (this.get(i, j) !== this.get(j, i)) {\r\n return false;\r\n }\r\n }\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n isEchelonForm() {\r\n let i = 0;\r\n let j = 0;\r\n let previousColumn = -1;\r\n let isEchelonForm = true;\r\n let checked = false;\r\n while (i < this.rows && isEchelonForm) {\r\n j = 0;\r\n checked = false;\r\n while (j < this.columns && checked === false) {\r\n if (this.get(i, j) === 0) {\r\n j++;\r\n } else if (this.get(i, j) === 1 && j > previousColumn) {\r\n checked = true;\r\n previousColumn = j;\r\n } else {\r\n isEchelonForm = false;\r\n checked = true;\r\n }\r\n }\r\n i++;\r\n }\r\n return isEchelonForm;\r\n }\r\n\r\n isReducedEchelonForm() {\r\n let i = 0;\r\n let j = 0;\r\n let previousColumn = -1;\r\n let isReducedEchelonForm = true;\r\n let checked = false;\r\n while (i < this.rows && isReducedEchelonForm) {\r\n j = 0;\r\n checked = false;\r\n while (j < this.columns && checked === false) {\r\n if (this.get(i, j) === 0) {\r\n j++;\r\n } else if (this.get(i, j) === 1 && j > previousColumn) {\r\n checked = true;\r\n previousColumn = j;\r\n } else {\r\n isReducedEchelonForm = false;\r\n checked = true;\r\n }\r\n }\r\n for (let k = j + 1; k < this.rows; k++) {\r\n if (this.get(i, k) !== 0) {\r\n isReducedEchelonForm = false;\r\n }\r\n }\r\n i++;\r\n }\r\n return isReducedEchelonForm;\r\n }\r\n\r\n echelonForm() {\r\n let result = this.clone();\r\n let h = 0;\r\n let k = 0;\r\n while (h < result.rows && k < result.columns) {\r\n let iMax = h;\r\n for (let i = h; i < result.rows; i++) {\r\n if (result.get(i, k) > result.get(iMax, k)) {\r\n iMax = i;\r\n }\r\n }\r\n if (result.get(iMax, k) === 0) {\r\n k++;\r\n } else {\r\n result.swapRows(h, iMax);\r\n let tmp = result.get(h, k);\r\n for (let j = k; j < result.columns; j++) {\r\n result.set(h, j, result.get(h, j) / tmp);\r\n }\r\n for (let i = h + 1; i < result.rows; i++) {\r\n let factor = result.get(i, k) / result.get(h, k);\r\n result.set(i, k, 0);\r\n for (let j = k + 1; j < result.columns; j++) {\r\n result.set(i, j, result.get(i, j) - result.get(h, j) * factor);\r\n }\r\n }\r\n h++;\r\n k++;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n reducedEchelonForm() {\r\n let result = this.echelonForm();\r\n let m = result.columns;\r\n let n = result.rows;\r\n let h = n - 1;\r\n while (h >= 0) {\r\n if (result.maxRow(h) === 0) {\r\n h--;\r\n } else {\r\n let p = 0;\r\n let pivot = false;\r\n while (p < n && pivot === false) {\r\n if (result.get(h, p) === 1) {\r\n pivot = true;\r\n } else {\r\n p++;\r\n }\r\n }\r\n for (let i = 0; i < h; i++) {\r\n let factor = result.get(i, p);\r\n for (let j = p; j < m; j++) {\r\n let tmp = result.get(i, j) - factor * result.get(h, j);\r\n result.set(i, j, tmp);\r\n }\r\n }\r\n h--;\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n set() {\r\n throw new Error('set method is unimplemented');\r\n }\r\n\r\n get() {\r\n throw new Error('get method is unimplemented');\r\n }\r\n\r\n repeat(options = {}) {\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { rows = 1, columns = 1 } = options;\r\n if (!Number.isInteger(rows) || rows <= 0) {\r\n throw new TypeError('rows must be a positive integer');\r\n }\r\n if (!Number.isInteger(columns) || columns <= 0) {\r\n throw new TypeError('columns must be a positive integer');\r\n }\r\n let matrix = new Matrix(this.rows * rows, this.columns * columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n matrix.setSubMatrix(this, this.rows * i, this.columns * j);\r\n }\r\n }\r\n return matrix;\r\n }\r\n\r\n fill(value) {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, value);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n neg() {\r\n return this.mulS(-1);\r\n }\r\n\r\n getRow(index) {\r\n checkRowIndex(this, index);\r\n let row = [];\r\n for (let i = 0; i < this.columns; i++) {\r\n row.push(this.get(index, i));\r\n }\r\n return row;\r\n }\r\n\r\n getRowVector(index) {\r\n return Matrix.rowVector(this.getRow(index));\r\n }\r\n\r\n setRow(index, array) {\r\n checkRowIndex(this, index);\r\n array = checkRowVector(this, array);\r\n for (let i = 0; i < this.columns; i++) {\r\n this.set(index, i, array[i]);\r\n }\r\n return this;\r\n }\r\n\r\n swapRows(row1, row2) {\r\n checkRowIndex(this, row1);\r\n checkRowIndex(this, row2);\r\n for (let i = 0; i < this.columns; i++) {\r\n let temp = this.get(row1, i);\r\n this.set(row1, i, this.get(row2, i));\r\n this.set(row2, i, temp);\r\n }\r\n return this;\r\n }\r\n\r\n getColumn(index) {\r\n checkColumnIndex(this, index);\r\n let column = [];\r\n for (let i = 0; i < this.rows; i++) {\r\n column.push(this.get(i, index));\r\n }\r\n return column;\r\n }\r\n\r\n getColumnVector(index) {\r\n return Matrix.columnVector(this.getColumn(index));\r\n }\r\n\r\n setColumn(index, array) {\r\n checkColumnIndex(this, index);\r\n array = checkColumnVector(this, array);\r\n for (let i = 0; i < this.rows; i++) {\r\n this.set(i, index, array[i]);\r\n }\r\n return this;\r\n }\r\n\r\n swapColumns(column1, column2) {\r\n checkColumnIndex(this, column1);\r\n checkColumnIndex(this, column2);\r\n for (let i = 0; i < this.rows; i++) {\r\n let temp = this.get(i, column1);\r\n this.set(i, column1, this.get(i, column2));\r\n this.set(i, column2, temp);\r\n }\r\n return this;\r\n }\r\n\r\n addRowVector(vector) {\r\n vector = checkRowVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + vector[j]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n subRowVector(vector) {\r\n vector = checkRowVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - vector[j]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n mulRowVector(vector) {\r\n vector = checkRowVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * vector[j]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n divRowVector(vector) {\r\n vector = checkRowVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / vector[j]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n addColumnVector(vector) {\r\n vector = checkColumnVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) + vector[i]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n subColumnVector(vector) {\r\n vector = checkColumnVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) - vector[i]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n mulColumnVector(vector) {\r\n vector = checkColumnVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) * vector[i]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n divColumnVector(vector) {\r\n vector = checkColumnVector(this, vector);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n this.set(i, j, this.get(i, j) / vector[i]);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n mulRow(index, value) {\r\n checkRowIndex(this, index);\r\n for (let i = 0; i < this.columns; i++) {\r\n this.set(index, i, this.get(index, i) * value);\r\n }\r\n return this;\r\n }\r\n\r\n mulColumn(index, value) {\r\n checkColumnIndex(this, index);\r\n for (let i = 0; i < this.rows; i++) {\r\n this.set(i, index, this.get(i, index) * value);\r\n }\r\n return this;\r\n }\r\n\r\n max() {\r\n let v = this.get(0, 0);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n if (this.get(i, j) > v) {\r\n v = this.get(i, j);\r\n }\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n maxIndex() {\r\n let v = this.get(0, 0);\r\n let idx = [0, 0];\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n if (this.get(i, j) > v) {\r\n v = this.get(i, j);\r\n idx[0] = i;\r\n idx[1] = j;\r\n }\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n min() {\r\n let v = this.get(0, 0);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n if (this.get(i, j) < v) {\r\n v = this.get(i, j);\r\n }\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n minIndex() {\r\n let v = this.get(0, 0);\r\n let idx = [0, 0];\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n if (this.get(i, j) < v) {\r\n v = this.get(i, j);\r\n idx[0] = i;\r\n idx[1] = j;\r\n }\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n maxRow(row) {\r\n checkRowIndex(this, row);\r\n let v = this.get(row, 0);\r\n for (let i = 1; i < this.columns; i++) {\r\n if (this.get(row, i) > v) {\r\n v = this.get(row, i);\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n maxRowIndex(row) {\r\n checkRowIndex(this, row);\r\n let v = this.get(row, 0);\r\n let idx = [row, 0];\r\n for (let i = 1; i < this.columns; i++) {\r\n if (this.get(row, i) > v) {\r\n v = this.get(row, i);\r\n idx[1] = i;\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n minRow(row) {\r\n checkRowIndex(this, row);\r\n let v = this.get(row, 0);\r\n for (let i = 1; i < this.columns; i++) {\r\n if (this.get(row, i) < v) {\r\n v = this.get(row, i);\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n minRowIndex(row) {\r\n checkRowIndex(this, row);\r\n let v = this.get(row, 0);\r\n let idx = [row, 0];\r\n for (let i = 1; i < this.columns; i++) {\r\n if (this.get(row, i) < v) {\r\n v = this.get(row, i);\r\n idx[1] = i;\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n maxColumn(column) {\r\n checkColumnIndex(this, column);\r\n let v = this.get(0, column);\r\n for (let i = 1; i < this.rows; i++) {\r\n if (this.get(i, column) > v) {\r\n v = this.get(i, column);\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n maxColumnIndex(column) {\r\n checkColumnIndex(this, column);\r\n let v = this.get(0, column);\r\n let idx = [0, column];\r\n for (let i = 1; i < this.rows; i++) {\r\n if (this.get(i, column) > v) {\r\n v = this.get(i, column);\r\n idx[0] = i;\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n minColumn(column) {\r\n checkColumnIndex(this, column);\r\n let v = this.get(0, column);\r\n for (let i = 1; i < this.rows; i++) {\r\n if (this.get(i, column) < v) {\r\n v = this.get(i, column);\r\n }\r\n }\r\n return v;\r\n }\r\n\r\n minColumnIndex(column) {\r\n checkColumnIndex(this, column);\r\n let v = this.get(0, column);\r\n let idx = [0, column];\r\n for (let i = 1; i < this.rows; i++) {\r\n if (this.get(i, column) < v) {\r\n v = this.get(i, column);\r\n idx[0] = i;\r\n }\r\n }\r\n return idx;\r\n }\r\n\r\n diag() {\r\n let min = Math.min(this.rows, this.columns);\r\n let diag = [];\r\n for (let i = 0; i < min; i++) {\r\n diag.push(this.get(i, i));\r\n }\r\n return diag;\r\n }\r\n\r\n norm(type = 'frobenius') {\r\n let result = 0;\r\n if (type === 'max') {\r\n return this.max();\r\n } else if (type === 'frobenius') {\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n result = result + this.get(i, j) * this.get(i, j);\r\n }\r\n }\r\n return Math.sqrt(result);\r\n } else {\r\n throw new RangeError(`unknown norm type: ${type}`);\r\n }\r\n }\r\n\r\n cumulativeSum() {\r\n let sum = 0;\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n sum += this.get(i, j);\r\n this.set(i, j, sum);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n dot(vector2) {\r\n if (AbstractMatrix.isMatrix(vector2)) vector2 = vector2.to1DArray();\r\n let vector1 = this.to1DArray();\r\n if (vector1.length !== vector2.length) {\r\n throw new RangeError('vectors do not have the same size');\r\n }\r\n let dot = 0;\r\n for (let i = 0; i < vector1.length; i++) {\r\n dot += vector1[i] * vector2[i];\r\n }\r\n return dot;\r\n }\r\n\r\n mmul(other) {\r\n other = Matrix.checkMatrix(other);\r\n\r\n let m = this.rows;\r\n let n = this.columns;\r\n let p = other.columns;\r\n\r\n let result = new Matrix(m, p);\r\n\r\n let Bcolj = new Float64Array(n);\r\n for (let j = 0; j < p; j++) {\r\n for (let k = 0; k < n; k++) {\r\n Bcolj[k] = other.get(k, j);\r\n }\r\n\r\n for (let i = 0; i < m; i++) {\r\n let s = 0;\r\n for (let k = 0; k < n; k++) {\r\n s += this.get(i, k) * Bcolj[k];\r\n }\r\n\r\n result.set(i, j, s);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n strassen2x2(other) {\r\n other = Matrix.checkMatrix(other);\r\n let result = new Matrix(2, 2);\r\n const a11 = this.get(0, 0);\r\n const b11 = other.get(0, 0);\r\n const a12 = this.get(0, 1);\r\n const b12 = other.get(0, 1);\r\n const a21 = this.get(1, 0);\r\n const b21 = other.get(1, 0);\r\n const a22 = this.get(1, 1);\r\n const b22 = other.get(1, 1);\r\n\r\n // Compute intermediate values.\r\n const m1 = (a11 + a22) * (b11 + b22);\r\n const m2 = (a21 + a22) * b11;\r\n const m3 = a11 * (b12 - b22);\r\n const m4 = a22 * (b21 - b11);\r\n const m5 = (a11 + a12) * b22;\r\n const m6 = (a21 - a11) * (b11 + b12);\r\n const m7 = (a12 - a22) * (b21 + b22);\r\n\r\n // Combine intermediate values into the output.\r\n const c00 = m1 + m4 - m5 + m7;\r\n const c01 = m3 + m5;\r\n const c10 = m2 + m4;\r\n const c11 = m1 - m2 + m3 + m6;\r\n\r\n result.set(0, 0, c00);\r\n result.set(0, 1, c01);\r\n result.set(1, 0, c10);\r\n result.set(1, 1, c11);\r\n return result;\r\n }\r\n\r\n strassen3x3(other) {\r\n other = Matrix.checkMatrix(other);\r\n let result = new Matrix(3, 3);\r\n\r\n const a00 = this.get(0, 0);\r\n const a01 = this.get(0, 1);\r\n const a02 = this.get(0, 2);\r\n const a10 = this.get(1, 0);\r\n const a11 = this.get(1, 1);\r\n const a12 = this.get(1, 2);\r\n const a20 = this.get(2, 0);\r\n const a21 = this.get(2, 1);\r\n const a22 = this.get(2, 2);\r\n\r\n const b00 = other.get(0, 0);\r\n const b01 = other.get(0, 1);\r\n const b02 = other.get(0, 2);\r\n const b10 = other.get(1, 0);\r\n const b11 = other.get(1, 1);\r\n const b12 = other.get(1, 2);\r\n const b20 = other.get(2, 0);\r\n const b21 = other.get(2, 1);\r\n const b22 = other.get(2, 2);\r\n\r\n const m1 = (a00 + a01 + a02 - a10 - a11 - a21 - a22) * b11;\r\n const m2 = (a00 - a10) * (-b01 + b11);\r\n const m3 = a11 * (-b00 + b01 + b10 - b11 - b12 - b20 + b22);\r\n const m4 = (-a00 + a10 + a11) * (b00 - b01 + b11);\r\n const m5 = (a10 + a11) * (-b00 + b01);\r\n const m6 = a00 * b00;\r\n const m7 = (-a00 + a20 + a21) * (b00 - b02 + b12);\r\n const m8 = (-a00 + a20) * (b02 - b12);\r\n const m9 = (a20 + a21) * (-b00 + b02);\r\n const m10 = (a00 + a01 + a02 - a11 - a12 - a20 - a21) * b12;\r\n const m11 = a21 * (-b00 + b02 + b10 - b11 - b12 - b20 + b21);\r\n const m12 = (-a02 + a21 + a22) * (b11 + b20 - b21);\r\n const m13 = (a02 - a22) * (b11 - b21);\r\n const m14 = a02 * b20;\r\n const m15 = (a21 + a22) * (-b20 + b21);\r\n const m16 = (-a02 + a11 + a12) * (b12 + b20 - b22);\r\n const m17 = (a02 - a12) * (b12 - b22);\r\n const m18 = (a11 + a12) * (-b20 + b22);\r\n const m19 = a01 * b10;\r\n const m20 = a12 * b21;\r\n const m21 = a10 * b02;\r\n const m22 = a20 * b01;\r\n const m23 = a22 * b22;\r\n\r\n const c00 = m6 + m14 + m19;\r\n const c01 = m1 + m4 + m5 + m6 + m12 + m14 + m15;\r\n const c02 = m6 + m7 + m9 + m10 + m14 + m16 + m18;\r\n const c10 = m2 + m3 + m4 + m6 + m14 + m16 + m17;\r\n const c11 = m2 + m4 + m5 + m6 + m20;\r\n const c12 = m14 + m16 + m17 + m18 + m21;\r\n const c20 = m6 + m7 + m8 + m11 + m12 + m13 + m14;\r\n const c21 = m12 + m13 + m14 + m15 + m22;\r\n const c22 = m6 + m7 + m8 + m9 + m23;\r\n\r\n result.set(0, 0, c00);\r\n result.set(0, 1, c01);\r\n result.set(0, 2, c02);\r\n result.set(1, 0, c10);\r\n result.set(1, 1, c11);\r\n result.set(1, 2, c12);\r\n result.set(2, 0, c20);\r\n result.set(2, 1, c21);\r\n result.set(2, 2, c22);\r\n return result;\r\n }\r\n\r\n mmulStrassen(y) {\r\n y = Matrix.checkMatrix(y);\r\n let x = this.clone();\r\n let r1 = x.rows;\r\n let c1 = x.columns;\r\n let r2 = y.rows;\r\n let c2 = y.columns;\r\n if (c1 !== r2) {\r\n // eslint-disable-next-line no-console\r\n console.warn(\r\n `Multiplying ${r1} x ${c1} and ${r2} x ${c2} matrix: dimensions do not match.`,\r\n );\r\n }\r\n\r\n // Put a matrix into the top left of a matrix of zeros.\r\n // `rows` and `cols` are the dimensions of the output matrix.\r\n function embed(mat, rows, cols) {\r\n let r = mat.rows;\r\n let c = mat.columns;\r\n if (r === rows && c === cols) {\r\n return mat;\r\n } else {\r\n let resultat = AbstractMatrix.zeros(rows, cols);\r\n resultat = resultat.setSubMatrix(mat, 0, 0);\r\n return resultat;\r\n }\r\n }\r\n\r\n // Make sure both matrices are the same size.\r\n // This is exclusively for simplicity:\r\n // this algorithm can be implemented with matrices of different sizes.\r\n\r\n let r = Math.max(r1, r2);\r\n let c = Math.max(c1, c2);\r\n x = embed(x, r, c);\r\n y = embed(y, r, c);\r\n\r\n // Our recursive multiplication function.\r\n function blockMult(a, b, rows, cols) {\r\n // For small matrices, resort to naive multiplication.\r\n if (rows <= 512 || cols <= 512) {\r\n return a.mmul(b); // a is equivalent to this\r\n }\r\n\r\n // Apply dynamic padding.\r\n if (rows % 2 === 1 && cols % 2 === 1) {\r\n a = embed(a, rows + 1, cols + 1);\r\n b = embed(b, rows + 1, cols + 1);\r\n } else if (rows % 2 === 1) {\r\n a = embed(a, rows + 1, cols);\r\n b = embed(b, rows + 1, cols);\r\n } else if (cols % 2 === 1) {\r\n a = embed(a, rows, cols + 1);\r\n b = embed(b, rows, cols + 1);\r\n }\r\n\r\n let halfRows = parseInt(a.rows / 2, 10);\r\n let halfCols = parseInt(a.columns / 2, 10);\r\n // Subdivide input matrices.\r\n let a11 = a.subMatrix(0, halfRows - 1, 0, halfCols - 1);\r\n let b11 = b.subMatrix(0, halfRows - 1, 0, halfCols - 1);\r\n\r\n let a12 = a.subMatrix(0, halfRows - 1, halfCols, a.columns - 1);\r\n let b12 = b.subMatrix(0, halfRows - 1, halfCols, b.columns - 1);\r\n\r\n let a21 = a.subMatrix(halfRows, a.rows - 1, 0, halfCols - 1);\r\n let b21 = b.subMatrix(halfRows, b.rows - 1, 0, halfCols - 1);\r\n\r\n let a22 = a.subMatrix(halfRows, a.rows - 1, halfCols, a.columns - 1);\r\n let b22 = b.subMatrix(halfRows, b.rows - 1, halfCols, b.columns - 1);\r\n\r\n // Compute intermediate values.\r\n let m1 = blockMult(\r\n AbstractMatrix.add(a11, a22),\r\n AbstractMatrix.add(b11, b22),\r\n halfRows,\r\n halfCols,\r\n );\r\n let m2 = blockMult(AbstractMatrix.add(a21, a22), b11, halfRows, halfCols);\r\n let m3 = blockMult(a11, AbstractMatrix.sub(b12, b22), halfRows, halfCols);\r\n let m4 = blockMult(a22, AbstractMatrix.sub(b21, b11), halfRows, halfCols);\r\n let m5 = blockMult(AbstractMatrix.add(a11, a12), b22, halfRows, halfCols);\r\n let m6 = blockMult(\r\n AbstractMatrix.sub(a21, a11),\r\n AbstractMatrix.add(b11, b12),\r\n halfRows,\r\n halfCols,\r\n );\r\n let m7 = blockMult(\r\n AbstractMatrix.sub(a12, a22),\r\n AbstractMatrix.add(b21, b22),\r\n halfRows,\r\n halfCols,\r\n );\r\n\r\n // Combine intermediate values into the output.\r\n let c11 = AbstractMatrix.add(m1, m4);\r\n c11.sub(m5);\r\n c11.add(m7);\r\n let c12 = AbstractMatrix.add(m3, m5);\r\n let c21 = AbstractMatrix.add(m2, m4);\r\n let c22 = AbstractMatrix.sub(m1, m2);\r\n c22.add(m3);\r\n c22.add(m6);\r\n\r\n // Crop output to the desired size (undo dynamic padding).\r\n let resultat = AbstractMatrix.zeros(2 * c11.rows, 2 * c11.columns);\r\n resultat = resultat.setSubMatrix(c11, 0, 0);\r\n resultat = resultat.setSubMatrix(c12, c11.rows, 0);\r\n resultat = resultat.setSubMatrix(c21, 0, c11.columns);\r\n resultat = resultat.setSubMatrix(c22, c11.rows, c11.columns);\r\n return resultat.subMatrix(0, rows - 1, 0, cols - 1);\r\n }\r\n return blockMult(x, y, r, c);\r\n }\r\n\r\n scaleRows(options = {}) {\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { min = 0, max = 1 } = options;\r\n if (!Number.isFinite(min)) throw new TypeError('min must be a number');\r\n if (!Number.isFinite(max)) throw new TypeError('max must be a number');\r\n if (min >= max) throw new RangeError('min must be smaller than max');\r\n let newMatrix = new Matrix(this.rows, this.columns);\r\n for (let i = 0; i < this.rows; i++) {\r\n const row = this.getRow(i);\r\n rescale(row, { min, max, output: row });\r\n newMatrix.setRow(i, row);\r\n }\r\n return newMatrix;\r\n }\r\n\r\n scaleColumns(options = {}) {\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { min = 0, max = 1 } = options;\r\n if (!Number.isFinite(min)) throw new TypeError('min must be a number');\r\n if (!Number.isFinite(max)) throw new TypeError('max must be a number');\r\n if (min >= max) throw new RangeError('min must be smaller than max');\r\n let newMatrix = new Matrix(this.rows, this.columns);\r\n for (let i = 0; i < this.columns; i++) {\r\n const column = this.getColumn(i);\r\n rescale(column, {\r\n min: min,\r\n max: max,\r\n output: column,\r\n });\r\n newMatrix.setColumn(i, column);\r\n }\r\n return newMatrix;\r\n }\r\n\r\n flipRows() {\r\n const middle = Math.ceil(this.columns / 2);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < middle; j++) {\r\n let first = this.get(i, j);\r\n let last = this.get(i, this.columns - 1 - j);\r\n this.set(i, j, last);\r\n this.set(i, this.columns - 1 - j, first);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n flipColumns() {\r\n const middle = Math.ceil(this.rows / 2);\r\n for (let j = 0; j < this.columns; j++) {\r\n for (let i = 0; i < middle; i++) {\r\n let first = this.get(i, j);\r\n let last = this.get(this.rows - 1 - i, j);\r\n this.set(i, j, last);\r\n this.set(this.rows - 1 - i, j, first);\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n kroneckerProduct(other) {\r\n other = Matrix.checkMatrix(other);\r\n\r\n let m = this.rows;\r\n let n = this.columns;\r\n let p = other.rows;\r\n let q = other.columns;\r\n\r\n let result = new Matrix(m * p, n * q);\r\n for (let i = 0; i < m; i++) {\r\n for (let j = 0; j < n; j++) {\r\n for (let k = 0; k < p; k++) {\r\n for (let l = 0; l < q; l++) {\r\n result.set(p * i + k, q * j + l, this.get(i, j) * other.get(k, l));\r\n }\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n transpose() {\r\n let result = new Matrix(this.columns, this.rows);\r\n for (let i = 0; i < this.rows; i++) {\r\n for (let j = 0; j < this.columns; j++) {\r\n result.set(j, i, this.get(i, j));\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n sortRows(compareFunction = compareNumbers) {\r\n for (let i = 0; i < this.rows; i++) {\r\n this.setRow(i, this.getRow(i).sort(compareFunction));\r\n }\r\n return this;\r\n }\r\n\r\n sortColumns(compareFunction = compareNumbers) {\r\n for (let i = 0; i < this.columns; i++) {\r\n this.setColumn(i, this.getColumn(i).sort(compareFunction));\r\n }\r\n return this;\r\n }\r\n\r\n subMatrix(startRow, endRow, startColumn, endColumn) {\r\n checkRange(this, startRow, endRow, startColumn, endColumn);\r\n let newMatrix = new Matrix(\r\n endRow - startRow + 1,\r\n endColumn - startColumn + 1,\r\n );\r\n for (let i = startRow; i <= endRow; i++) {\r\n for (let j = startColumn; j <= endColumn; j++) {\r\n newMatrix.set(i - startRow, j - startColumn, this.get(i, j));\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n subMatrixRow(indices, startColumn, endColumn) {\r\n if (startColumn === undefined) startColumn = 0;\r\n if (endColumn === undefined) endColumn = this.columns - 1;\r\n if (\r\n startColumn > endColumn ||\r\n startColumn < 0 ||\r\n startColumn >= this.columns ||\r\n endColumn < 0 ||\r\n endColumn >= this.columns\r\n ) {\r\n throw new RangeError('Argument out of range');\r\n }\r\n\r\n let newMatrix = new Matrix(indices.length, endColumn - startColumn + 1);\r\n for (let i = 0; i < indices.length; i++) {\r\n for (let j = startColumn; j <= endColumn; j++) {\r\n if (indices[i] < 0 || indices[i] >= this.rows) {\r\n throw new RangeError(`Row index out of range: ${indices[i]}`);\r\n }\r\n newMatrix.set(i, j - startColumn, this.get(indices[i], j));\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n subMatrixColumn(indices, startRow, endRow) {\r\n if (startRow === undefined) startRow = 0;\r\n if (endRow === undefined) endRow = this.rows - 1;\r\n if (\r\n startRow > endRow ||\r\n startRow < 0 ||\r\n startRow >= this.rows ||\r\n endRow < 0 ||\r\n endRow >= this.rows\r\n ) {\r\n throw new RangeError('Argument out of range');\r\n }\r\n\r\n let newMatrix = new Matrix(endRow - startRow + 1, indices.length);\r\n for (let i = 0; i < indices.length; i++) {\r\n for (let j = startRow; j <= endRow; j++) {\r\n if (indices[i] < 0 || indices[i] >= this.columns) {\r\n throw new RangeError(`Column index out of range: ${indices[i]}`);\r\n }\r\n newMatrix.set(j - startRow, i, this.get(j, indices[i]));\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n setSubMatrix(matrix, startRow, startColumn) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n let endRow = startRow + matrix.rows - 1;\r\n let endColumn = startColumn + matrix.columns - 1;\r\n checkRange(this, startRow, endRow, startColumn, endColumn);\r\n for (let i = 0; i < matrix.rows; i++) {\r\n for (let j = 0; j < matrix.columns; j++) {\r\n this.set(startRow + i, startColumn + j, matrix.get(i, j));\r\n }\r\n }\r\n return this;\r\n }\r\n\r\n selection(rowIndices, columnIndices) {\r\n let indices = checkIndices(this, rowIndices, columnIndices);\r\n let newMatrix = new Matrix(rowIndices.length, columnIndices.length);\r\n for (let i = 0; i < indices.row.length; i++) {\r\n let rowIndex = indices.row[i];\r\n for (let j = 0; j < indices.column.length; j++) {\r\n let columnIndex = indices.column[j];\r\n newMatrix.set(i, j, this.get(rowIndex, columnIndex));\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n trace() {\r\n let min = Math.min(this.rows, this.columns);\r\n let trace = 0;\r\n for (let i = 0; i < min; i++) {\r\n trace += this.get(i, i);\r\n }\r\n return trace;\r\n }\r\n\r\n clone() {\r\n let newMatrix = new Matrix(this.rows, this.columns);\r\n for (let row = 0; row < this.rows; row++) {\r\n for (let column = 0; column < this.columns; column++) {\r\n newMatrix.set(row, column, this.get(row, column));\r\n }\r\n }\r\n return newMatrix;\r\n }\r\n\r\n sum(by) {\r\n switch (by) {\r\n case 'row':\r\n return sumByRow(this);\r\n case 'column':\r\n return sumByColumn(this);\r\n case undefined:\r\n return sumAll(this);\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n product(by) {\r\n switch (by) {\r\n case 'row':\r\n return productByRow(this);\r\n case 'column':\r\n return productByColumn(this);\r\n case undefined:\r\n return productAll(this);\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n mean(by) {\r\n const sum = this.sum(by);\r\n switch (by) {\r\n case 'row': {\r\n for (let i = 0; i < this.rows; i++) {\r\n sum[i] /= this.columns;\r\n }\r\n return sum;\r\n }\r\n case 'column': {\r\n for (let i = 0; i < this.columns; i++) {\r\n sum[i] /= this.rows;\r\n }\r\n return sum;\r\n }\r\n case undefined:\r\n return sum / this.size;\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n variance(by, options = {}) {\r\n if (typeof by === 'object') {\r\n options = by;\r\n by = undefined;\r\n }\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { unbiased = true, mean = this.mean(by) } = options;\r\n if (typeof unbiased !== 'boolean') {\r\n throw new TypeError('unbiased must be a boolean');\r\n }\r\n switch (by) {\r\n case 'row': {\r\n if (!Array.isArray(mean)) {\r\n throw new TypeError('mean must be an array');\r\n }\r\n return varianceByRow(this, unbiased, mean);\r\n }\r\n case 'column': {\r\n if (!Array.isArray(mean)) {\r\n throw new TypeError('mean must be an array');\r\n }\r\n return varianceByColumn(this, unbiased, mean);\r\n }\r\n case undefined: {\r\n if (typeof mean !== 'number') {\r\n throw new TypeError('mean must be a number');\r\n }\r\n return varianceAll(this, unbiased, mean);\r\n }\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n standardDeviation(by, options) {\r\n if (typeof by === 'object') {\r\n options = by;\r\n by = undefined;\r\n }\r\n const variance = this.variance(by, options);\r\n if (by === undefined) {\r\n return Math.sqrt(variance);\r\n } else {\r\n for (let i = 0; i < variance.length; i++) {\r\n variance[i] = Math.sqrt(variance[i]);\r\n }\r\n return variance;\r\n }\r\n }\r\n\r\n center(by, options = {}) {\r\n if (typeof by === 'object') {\r\n options = by;\r\n by = undefined;\r\n }\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n const { center = this.mean(by) } = options;\r\n switch (by) {\r\n case 'row': {\r\n if (!Array.isArray(center)) {\r\n throw new TypeError('center must be an array');\r\n }\r\n centerByRow(this, center);\r\n return this;\r\n }\r\n case 'column': {\r\n if (!Array.isArray(center)) {\r\n throw new TypeError('center must be an array');\r\n }\r\n centerByColumn(this, center);\r\n return this;\r\n }\r\n case undefined: {\r\n if (typeof center !== 'number') {\r\n throw new TypeError('center must be a number');\r\n }\r\n centerAll(this, center);\r\n return this;\r\n }\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n scale(by, options = {}) {\r\n if (typeof by === 'object') {\r\n options = by;\r\n by = undefined;\r\n }\r\n if (typeof options !== 'object') {\r\n throw new TypeError('options must be an object');\r\n }\r\n let scale = options.scale;\r\n switch (by) {\r\n case 'row': {\r\n if (scale === undefined) {\r\n scale = getScaleByRow(this);\r\n } else if (!Array.isArray(scale)) {\r\n throw new TypeError('scale must be an array');\r\n }\r\n scaleByRow(this, scale);\r\n return this;\r\n }\r\n case 'column': {\r\n if (scale === undefined) {\r\n scale = getScaleByColumn(this);\r\n } else if (!Array.isArray(scale)) {\r\n throw new TypeError('scale must be an array');\r\n }\r\n scaleByColumn(this, scale);\r\n return this;\r\n }\r\n case undefined: {\r\n if (scale === undefined) {\r\n scale = getScaleAll(this);\r\n } else if (typeof scale !== 'number') {\r\n throw new TypeError('scale must be a number');\r\n }\r\n scaleAll(this, scale);\r\n return this;\r\n }\r\n default:\r\n throw new Error(`invalid option: ${by}`);\r\n }\r\n }\r\n\r\n toString(options) {\r\n return inspectMatrixWithOptions(this, options);\r\n }\r\n}\r\n\r\nAbstractMatrix.prototype.klass = 'Matrix';\r\nif (typeof Symbol !== 'undefined') {\r\n AbstractMatrix.prototype[\r\n Symbol.for('nodejs.util.inspect.custom')\r\n ] = inspectMatrix;\r\n}\r\n\r\nfunction compareNumbers(a, b) {\r\n return a - b;\r\n}\r\n\r\n// Synonyms\r\nAbstractMatrix.random = AbstractMatrix.rand;\r\nAbstractMatrix.randomInt = AbstractMatrix.randInt;\r\nAbstractMatrix.diagonal = AbstractMatrix.diag;\r\nAbstractMatrix.prototype.diagonal = AbstractMatrix.prototype.diag;\r\nAbstractMatrix.identity = AbstractMatrix.eye;\r\nAbstractMatrix.prototype.negate = AbstractMatrix.prototype.neg;\r\nAbstractMatrix.prototype.tensorProduct =\r\n AbstractMatrix.prototype.kroneckerProduct;\r\n\r\nexport default class Matrix extends AbstractMatrix {\r\n constructor(nRows, nColumns) {\r\n super();\r\n if (Matrix.isMatrix(nRows)) {\r\n return nRows.clone();\r\n } else if (Number.isInteger(nRows) && nRows > 0) {\r\n // Create an empty matrix\r\n this.data = [];\r\n if (Number.isInteger(nColumns) && nColumns > 0) {\r\n for (let i = 0; i < nRows; i++) {\r\n this.data.push(new Float64Array(nColumns));\r\n }\r\n } else {\r\n throw new TypeError('nColumns must be a positive integer');\r\n }\r\n } else if (Array.isArray(nRows)) {\r\n // Copy the values from the 2D array\r\n const arrayData = nRows;\r\n nRows = arrayData.length;\r\n nColumns = arrayData[0].length;\r\n if (typeof nColumns !== 'number' || nColumns === 0) {\r\n throw new TypeError(\r\n 'Data must be a 2D array with at least one element',\r\n );\r\n }\r\n this.data = [];\r\n for (let i = 0; i < nRows; i++) {\r\n if (arrayData[i].length !== nColumns) {\r\n throw new RangeError('Inconsistent array dimensions');\r\n }\r\n this.data.push(Float64Array.from(arrayData[i]));\r\n }\r\n } else {\r\n throw new TypeError(\r\n 'First argument must be a positive number or an array',\r\n );\r\n }\r\n this.rows = nRows;\r\n this.columns = nColumns;\r\n return this;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.data[rowIndex][columnIndex] = value;\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.data[rowIndex][columnIndex];\r\n }\r\n\r\n removeRow(index) {\r\n checkRowIndex(this, index);\r\n if (this.rows === 1) {\r\n throw new RangeError('A matrix cannot have less than one row');\r\n }\r\n this.data.splice(index, 1);\r\n this.rows -= 1;\r\n return this;\r\n }\r\n\r\n addRow(index, array) {\r\n if (array === undefined) {\r\n array = index;\r\n index = this.rows;\r\n }\r\n checkRowIndex(this, index, true);\r\n array = Float64Array.from(checkRowVector(this, array, true));\r\n this.data.splice(index, 0, array);\r\n this.rows += 1;\r\n return this;\r\n }\r\n\r\n removeColumn(index) {\r\n checkColumnIndex(this, index);\r\n if (this.columns === 1) {\r\n throw new RangeError('A matrix cannot have less than one column');\r\n }\r\n for (let i = 0; i < this.rows; i++) {\r\n const newRow = new Float64Array(this.columns - 1);\r\n for (let j = 0; j < index; j++) {\r\n newRow[j] = this.data[i][j];\r\n }\r\n for (let j = index + 1; j < this.columns; j++) {\r\n newRow[j - 1] = this.data[i][j];\r\n }\r\n this.data[i] = newRow;\r\n }\r\n this.columns -= 1;\r\n return this;\r\n }\r\n\r\n addColumn(index, array) {\r\n if (typeof array === 'undefined') {\r\n array = index;\r\n index = this.columns;\r\n }\r\n checkColumnIndex(this, index, true);\r\n array = checkColumnVector(this, array);\r\n for (let i = 0; i < this.rows; i++) {\r\n const newRow = new Float64Array(this.columns + 1);\r\n let j = 0;\r\n for (; j < index; j++) {\r\n newRow[j] = this.data[i][j];\r\n }\r\n newRow[j++] = array[i];\r\n for (; j < this.columns + 1; j++) {\r\n newRow[j] = this.data[i][j - 1];\r\n }\r\n this.data[i] = newRow;\r\n }\r\n this.columns += 1;\r\n return this;\r\n }\r\n}\r\n\r\ninstallMathOperations(AbstractMatrix, Matrix);\r\n","import { AbstractMatrix } from '../matrix';\r\n\r\nexport default class BaseView extends AbstractMatrix {\r\n constructor(matrix, rows, columns) {\r\n super();\r\n this.matrix = matrix;\r\n this.rows = rows;\r\n this.columns = columns;\r\n }\r\n}\r\n","import { checkColumnIndex } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixColumnView extends BaseView {\r\n constructor(matrix, column) {\r\n checkColumnIndex(matrix, column);\r\n super(matrix, matrix.rows, 1);\r\n this.column = column;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(rowIndex, this.column, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex) {\r\n return this.matrix.get(rowIndex, this.column);\r\n }\r\n}\r\n","import { checkColumnIndices } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixColumnSelectionView extends BaseView {\r\n constructor(matrix, columnIndices) {\r\n columnIndices = checkColumnIndices(matrix, columnIndices);\r\n super(matrix, matrix.rows, columnIndices.length);\r\n this.columnIndices = columnIndices;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(rowIndex, this.columnIndices[columnIndex], value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(rowIndex, this.columnIndices[columnIndex]);\r\n }\r\n}\r\n","import BaseView from './base';\r\n\r\nexport default class MatrixFlipColumnView extends BaseView {\r\n constructor(matrix) {\r\n super(matrix, matrix.rows, matrix.columns);\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(rowIndex, this.columns - columnIndex - 1, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(rowIndex, this.columns - columnIndex - 1);\r\n }\r\n}\r\n","import BaseView from './base';\r\n\r\nexport default class MatrixFlipRowView extends BaseView {\r\n constructor(matrix) {\r\n super(matrix, matrix.rows, matrix.columns);\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(this.rows - rowIndex - 1, columnIndex, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(this.rows - rowIndex - 1, columnIndex);\r\n }\r\n}\r\n","import { checkRowIndex } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixRowView extends BaseView {\r\n constructor(matrix, row) {\r\n checkRowIndex(matrix, row);\r\n super(matrix, 1, matrix.columns);\r\n this.row = row;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(this.row, columnIndex, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(this.row, columnIndex);\r\n }\r\n}\r\n","import { checkRowIndices } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixRowSelectionView extends BaseView {\r\n constructor(matrix, rowIndices) {\r\n rowIndices = checkRowIndices(matrix, rowIndices);\r\n super(matrix, rowIndices.length, matrix.columns);\r\n this.rowIndices = rowIndices;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(this.rowIndices[rowIndex], columnIndex, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(this.rowIndices[rowIndex], columnIndex);\r\n }\r\n}\r\n","import { checkIndices } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixSelectionView extends BaseView {\r\n constructor(matrix, rowIndices, columnIndices) {\r\n let indices = checkIndices(matrix, rowIndices, columnIndices);\r\n super(matrix, indices.row.length, indices.column.length);\r\n this.rowIndices = indices.row;\r\n this.columnIndices = indices.column;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(\r\n this.rowIndices[rowIndex],\r\n this.columnIndices[columnIndex],\r\n value,\r\n );\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(\r\n this.rowIndices[rowIndex],\r\n this.columnIndices[columnIndex],\r\n );\r\n }\r\n}\r\n","import { checkRange } from '../util';\r\n\r\nimport BaseView from './base';\r\n\r\nexport default class MatrixSubView extends BaseView {\r\n constructor(matrix, startRow, endRow, startColumn, endColumn) {\r\n checkRange(matrix, startRow, endRow, startColumn, endColumn);\r\n super(matrix, endRow - startRow + 1, endColumn - startColumn + 1);\r\n this.startRow = startRow;\r\n this.startColumn = startColumn;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(\r\n this.startRow + rowIndex,\r\n this.startColumn + columnIndex,\r\n value,\r\n );\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(\r\n this.startRow + rowIndex,\r\n this.startColumn + columnIndex,\r\n );\r\n }\r\n}\r\n","import BaseView from './base';\r\n\r\nexport default class MatrixTransposeView extends BaseView {\r\n constructor(matrix) {\r\n super(matrix, matrix.columns, matrix.rows);\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.matrix.set(columnIndex, rowIndex, value);\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.matrix.get(columnIndex, rowIndex);\r\n }\r\n}\r\n","import { AbstractMatrix } from '../matrix';\r\n\r\nexport default class WrapperMatrix1D extends AbstractMatrix {\r\n constructor(data, options = {}) {\r\n const { rows = 1 } = options;\r\n\r\n if (data.length % rows !== 0) {\r\n throw new Error('the data length is not divisible by the number of rows');\r\n }\r\n super();\r\n this.rows = rows;\r\n this.columns = data.length / rows;\r\n this.data = data;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n let index = this._calculateIndex(rowIndex, columnIndex);\r\n this.data[index] = value;\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n let index = this._calculateIndex(rowIndex, columnIndex);\r\n return this.data[index];\r\n }\r\n\r\n _calculateIndex(row, column) {\r\n return row * this.columns + column;\r\n }\r\n}\r\n","import { AbstractMatrix } from '../matrix';\r\n\r\nexport default class WrapperMatrix2D extends AbstractMatrix {\r\n constructor(data) {\r\n super();\r\n this.data = data;\r\n this.rows = data.length;\r\n this.columns = data[0].length;\r\n }\r\n\r\n set(rowIndex, columnIndex, value) {\r\n this.data[rowIndex][columnIndex] = value;\r\n return this;\r\n }\r\n\r\n get(rowIndex, columnIndex) {\r\n return this.data[rowIndex][columnIndex];\r\n }\r\n}\r\n","import WrapperMatrix1D from './WrapperMatrix1D';\r\nimport WrapperMatrix2D from './WrapperMatrix2D';\r\n\r\nexport function wrap(array, options) {\r\n if (Array.isArray(array)) {\r\n if (array[0] && Array.isArray(array[0])) {\r\n return new WrapperMatrix2D(array);\r\n } else {\r\n return new WrapperMatrix1D(array, options);\r\n }\r\n } else {\r\n throw new Error('the argument is not an array');\r\n }\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nexport default class LuDecomposition {\r\n constructor(matrix) {\r\n matrix = WrapperMatrix2D.checkMatrix(matrix);\r\n\r\n let lu = matrix.clone();\r\n let rows = lu.rows;\r\n let columns = lu.columns;\r\n let pivotVector = new Float64Array(rows);\r\n let pivotSign = 1;\r\n let i, j, k, p, s, t, v;\r\n let LUcolj, kmax;\r\n\r\n for (i = 0; i < rows; i++) {\r\n pivotVector[i] = i;\r\n }\r\n\r\n LUcolj = new Float64Array(rows);\r\n\r\n for (j = 0; j < columns; j++) {\r\n for (i = 0; i < rows; i++) {\r\n LUcolj[i] = lu.get(i, j);\r\n }\r\n\r\n for (i = 0; i < rows; i++) {\r\n kmax = Math.min(i, j);\r\n s = 0;\r\n for (k = 0; k < kmax; k++) {\r\n s += lu.get(i, k) * LUcolj[k];\r\n }\r\n LUcolj[i] -= s;\r\n lu.set(i, j, LUcolj[i]);\r\n }\r\n\r\n p = j;\r\n for (i = j + 1; i < rows; i++) {\r\n if (Math.abs(LUcolj[i]) > Math.abs(LUcolj[p])) {\r\n p = i;\r\n }\r\n }\r\n\r\n if (p !== j) {\r\n for (k = 0; k < columns; k++) {\r\n t = lu.get(p, k);\r\n lu.set(p, k, lu.get(j, k));\r\n lu.set(j, k, t);\r\n }\r\n\r\n v = pivotVector[p];\r\n pivotVector[p] = pivotVector[j];\r\n pivotVector[j] = v;\r\n\r\n pivotSign = -pivotSign;\r\n }\r\n\r\n if (j < rows && lu.get(j, j) !== 0) {\r\n for (i = j + 1; i < rows; i++) {\r\n lu.set(i, j, lu.get(i, j) / lu.get(j, j));\r\n }\r\n }\r\n }\r\n\r\n this.LU = lu;\r\n this.pivotVector = pivotVector;\r\n this.pivotSign = pivotSign;\r\n }\r\n\r\n isSingular() {\r\n let data = this.LU;\r\n let col = data.columns;\r\n for (let j = 0; j < col; j++) {\r\n if (data.get(j, j) === 0) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n\r\n solve(value) {\r\n value = Matrix.checkMatrix(value);\r\n\r\n let lu = this.LU;\r\n let rows = lu.rows;\r\n\r\n if (rows !== value.rows) {\r\n throw new Error('Invalid matrix dimensions');\r\n }\r\n if (this.isSingular()) {\r\n throw new Error('LU matrix is singular');\r\n }\r\n\r\n let count = value.columns;\r\n let X = value.subMatrixRow(this.pivotVector, 0, count - 1);\r\n let columns = lu.columns;\r\n let i, j, k;\r\n\r\n for (k = 0; k < columns; k++) {\r\n for (i = k + 1; i < columns; i++) {\r\n for (j = 0; j < count; j++) {\r\n X.set(i, j, X.get(i, j) - X.get(k, j) * lu.get(i, k));\r\n }\r\n }\r\n }\r\n for (k = columns - 1; k >= 0; k--) {\r\n for (j = 0; j < count; j++) {\r\n X.set(k, j, X.get(k, j) / lu.get(k, k));\r\n }\r\n for (i = 0; i < k; i++) {\r\n for (j = 0; j < count; j++) {\r\n X.set(i, j, X.get(i, j) - X.get(k, j) * lu.get(i, k));\r\n }\r\n }\r\n }\r\n return X;\r\n }\r\n\r\n get determinant() {\r\n let data = this.LU;\r\n if (!data.isSquare()) {\r\n throw new Error('Matrix must be square');\r\n }\r\n let determinant = this.pivotSign;\r\n let col = data.columns;\r\n for (let j = 0; j < col; j++) {\r\n determinant *= data.get(j, j);\r\n }\r\n return determinant;\r\n }\r\n\r\n get lowerTriangularMatrix() {\r\n let data = this.LU;\r\n let rows = data.rows;\r\n let columns = data.columns;\r\n let X = new Matrix(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n if (i > j) {\r\n X.set(i, j, data.get(i, j));\r\n } else if (i === j) {\r\n X.set(i, j, 1);\r\n } else {\r\n X.set(i, j, 0);\r\n }\r\n }\r\n }\r\n return X;\r\n }\r\n\r\n get upperTriangularMatrix() {\r\n let data = this.LU;\r\n let rows = data.rows;\r\n let columns = data.columns;\r\n let X = new Matrix(rows, columns);\r\n for (let i = 0; i < rows; i++) {\r\n for (let j = 0; j < columns; j++) {\r\n if (i <= j) {\r\n X.set(i, j, data.get(i, j));\r\n } else {\r\n X.set(i, j, 0);\r\n }\r\n }\r\n }\r\n return X;\r\n }\r\n\r\n get pivotPermutationVector() {\r\n return Array.from(this.pivotVector);\r\n }\r\n}\r\n","export function hypotenuse(a, b) {\r\n let r = 0;\r\n if (Math.abs(a) > Math.abs(b)) {\r\n r = b / a;\r\n return Math.abs(a) * Math.sqrt(1 + r * r);\r\n }\r\n if (b !== 0) {\r\n r = a / b;\r\n return Math.abs(b) * Math.sqrt(1 + r * r);\r\n }\r\n return 0;\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nimport { hypotenuse } from './util';\r\n\r\nexport default class QrDecomposition {\r\n constructor(value) {\r\n value = WrapperMatrix2D.checkMatrix(value);\r\n\r\n let qr = value.clone();\r\n let m = value.rows;\r\n let n = value.columns;\r\n let rdiag = new Float64Array(n);\r\n let i, j, k, s;\r\n\r\n for (k = 0; k < n; k++) {\r\n let nrm = 0;\r\n for (i = k; i < m; i++) {\r\n nrm = hypotenuse(nrm, qr.get(i, k));\r\n }\r\n if (nrm !== 0) {\r\n if (qr.get(k, k) < 0) {\r\n nrm = -nrm;\r\n }\r\n for (i = k; i < m; i++) {\r\n qr.set(i, k, qr.get(i, k) / nrm);\r\n }\r\n qr.set(k, k, qr.get(k, k) + 1);\r\n for (j = k + 1; j < n; j++) {\r\n s = 0;\r\n for (i = k; i < m; i++) {\r\n s += qr.get(i, k) * qr.get(i, j);\r\n }\r\n s = -s / qr.get(k, k);\r\n for (i = k; i < m; i++) {\r\n qr.set(i, j, qr.get(i, j) + s * qr.get(i, k));\r\n }\r\n }\r\n }\r\n rdiag[k] = -nrm;\r\n }\r\n\r\n this.QR = qr;\r\n this.Rdiag = rdiag;\r\n }\r\n\r\n solve(value) {\r\n value = Matrix.checkMatrix(value);\r\n\r\n let qr = this.QR;\r\n let m = qr.rows;\r\n\r\n if (value.rows !== m) {\r\n throw new Error('Matrix row dimensions must agree');\r\n }\r\n if (!this.isFullRank()) {\r\n throw new Error('Matrix is rank deficient');\r\n }\r\n\r\n let count = value.columns;\r\n let X = value.clone();\r\n let n = qr.columns;\r\n let i, j, k, s;\r\n\r\n for (k = 0; k < n; k++) {\r\n for (j = 0; j < count; j++) {\r\n s = 0;\r\n for (i = k; i < m; i++) {\r\n s += qr.get(i, k) * X.get(i, j);\r\n }\r\n s = -s / qr.get(k, k);\r\n for (i = k; i < m; i++) {\r\n X.set(i, j, X.get(i, j) + s * qr.get(i, k));\r\n }\r\n }\r\n }\r\n for (k = n - 1; k >= 0; k--) {\r\n for (j = 0; j < count; j++) {\r\n X.set(k, j, X.get(k, j) / this.Rdiag[k]);\r\n }\r\n for (i = 0; i < k; i++) {\r\n for (j = 0; j < count; j++) {\r\n X.set(i, j, X.get(i, j) - X.get(k, j) * qr.get(i, k));\r\n }\r\n }\r\n }\r\n\r\n return X.subMatrix(0, n - 1, 0, count - 1);\r\n }\r\n\r\n isFullRank() {\r\n let columns = this.QR.columns;\r\n for (let i = 0; i < columns; i++) {\r\n if (this.Rdiag[i] === 0) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n get upperTriangularMatrix() {\r\n let qr = this.QR;\r\n let n = qr.columns;\r\n let X = new Matrix(n, n);\r\n let i, j;\r\n for (i = 0; i < n; i++) {\r\n for (j = 0; j < n; j++) {\r\n if (i < j) {\r\n X.set(i, j, qr.get(i, j));\r\n } else if (i === j) {\r\n X.set(i, j, this.Rdiag[i]);\r\n } else {\r\n X.set(i, j, 0);\r\n }\r\n }\r\n }\r\n return X;\r\n }\r\n\r\n get orthogonalMatrix() {\r\n let qr = this.QR;\r\n let rows = qr.rows;\r\n let columns = qr.columns;\r\n let X = new Matrix(rows, columns);\r\n let i, j, k, s;\r\n\r\n for (k = columns - 1; k >= 0; k--) {\r\n for (i = 0; i < rows; i++) {\r\n X.set(i, k, 0);\r\n }\r\n X.set(k, k, 1);\r\n for (j = k; j < columns; j++) {\r\n if (qr.get(k, k) !== 0) {\r\n s = 0;\r\n for (i = k; i < rows; i++) {\r\n s += qr.get(i, k) * X.get(i, j);\r\n }\r\n\r\n s = -s / qr.get(k, k);\r\n\r\n for (i = k; i < rows; i++) {\r\n X.set(i, j, X.get(i, j) + s * qr.get(i, k));\r\n }\r\n }\r\n }\r\n }\r\n return X;\r\n }\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nimport { hypotenuse } from './util';\r\n\r\nexport default class SingularValueDecomposition {\r\n constructor(value, options = {}) {\r\n value = WrapperMatrix2D.checkMatrix(value);\r\n\r\n let m = value.rows;\r\n let n = value.columns;\r\n\r\n const {\r\n computeLeftSingularVectors = true,\r\n computeRightSingularVectors = true,\r\n autoTranspose = false,\r\n } = options;\r\n\r\n let wantu = Boolean(computeLeftSingularVectors);\r\n let wantv = Boolean(computeRightSingularVectors);\r\n\r\n let swapped = false;\r\n let a;\r\n if (m < n) {\r\n if (!autoTranspose) {\r\n a = value.clone();\r\n // eslint-disable-next-line no-console\r\n console.warn(\r\n 'Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose',\r\n );\r\n } else {\r\n a = value.transpose();\r\n m = a.rows;\r\n n = a.columns;\r\n swapped = true;\r\n let aux = wantu;\r\n wantu = wantv;\r\n wantv = aux;\r\n }\r\n } else {\r\n a = value.clone();\r\n }\r\n\r\n let nu = Math.min(m, n);\r\n let ni = Math.min(m + 1, n);\r\n let s = new Float64Array(ni);\r\n let U = new Matrix(m, nu);\r\n let V = new Matrix(n, n);\r\n\r\n let e = new Float64Array(n);\r\n let work = new Float64Array(m);\r\n\r\n let si = new Float64Array(ni);\r\n for (let i = 0; i < ni; i++) si[i] = i;\r\n\r\n let nct = Math.min(m - 1, n);\r\n let nrt = Math.max(0, Math.min(n - 2, m));\r\n let mrc = Math.max(nct, nrt);\r\n\r\n for (let k = 0; k < mrc; k++) {\r\n if (k < nct) {\r\n s[k] = 0;\r\n for (let i = k; i < m; i++) {\r\n s[k] = hypotenuse(s[k], a.get(i, k));\r\n }\r\n if (s[k] !== 0) {\r\n if (a.get(k, k) < 0) {\r\n s[k] = -s[k];\r\n }\r\n for (let i = k; i < m; i++) {\r\n a.set(i, k, a.get(i, k) / s[k]);\r\n }\r\n a.set(k, k, a.get(k, k) + 1);\r\n }\r\n s[k] = -s[k];\r\n }\r\n\r\n for (let j = k + 1; j < n; j++) {\r\n if (k < nct && s[k] !== 0) {\r\n let t = 0;\r\n for (let i = k; i < m; i++) {\r\n t += a.get(i, k) * a.get(i, j);\r\n }\r\n t = -t / a.get(k, k);\r\n for (let i = k; i < m; i++) {\r\n a.set(i, j, a.get(i, j) + t * a.get(i, k));\r\n }\r\n }\r\n e[j] = a.get(k, j);\r\n }\r\n\r\n if (wantu && k < nct) {\r\n for (let i = k; i < m; i++) {\r\n U.set(i, k, a.get(i, k));\r\n }\r\n }\r\n\r\n if (k < nrt) {\r\n e[k] = 0;\r\n for (let i = k + 1; i < n; i++) {\r\n e[k] = hypotenuse(e[k], e[i]);\r\n }\r\n if (e[k] !== 0) {\r\n if (e[k + 1] < 0) {\r\n e[k] = 0 - e[k];\r\n }\r\n for (let i = k + 1; i < n; i++) {\r\n e[i] /= e[k];\r\n }\r\n e[k + 1] += 1;\r\n }\r\n e[k] = -e[k];\r\n if (k + 1 < m && e[k] !== 0) {\r\n for (let i = k + 1; i < m; i++) {\r\n work[i] = 0;\r\n }\r\n for (let i = k + 1; i < m; i++) {\r\n for (let j = k + 1; j < n; j++) {\r\n work[i] += e[j] * a.get(i, j);\r\n }\r\n }\r\n for (let j = k + 1; j < n; j++) {\r\n let t = -e[j] / e[k + 1];\r\n for (let i = k + 1; i < m; i++) {\r\n a.set(i, j, a.get(i, j) + t * work[i]);\r\n }\r\n }\r\n }\r\n if (wantv) {\r\n for (let i = k + 1; i < n; i++) {\r\n V.set(i, k, e[i]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n let p = Math.min(n, m + 1);\r\n if (nct < n) {\r\n s[nct] = a.get(nct, nct);\r\n }\r\n if (m < p) {\r\n s[p - 1] = 0;\r\n }\r\n if (nrt + 1 < p) {\r\n e[nrt] = a.get(nrt, p - 1);\r\n }\r\n e[p - 1] = 0;\r\n\r\n if (wantu) {\r\n for (let j = nct; j < nu; j++) {\r\n for (let i = 0; i < m; i++) {\r\n U.set(i, j, 0);\r\n }\r\n U.set(j, j, 1);\r\n }\r\n for (let k = nct - 1; k >= 0; k--) {\r\n if (s[k] !== 0) {\r\n for (let j = k + 1; j < nu; j++) {\r\n let t = 0;\r\n for (let i = k; i < m; i++) {\r\n t += U.get(i, k) * U.get(i, j);\r\n }\r\n t = -t / U.get(k, k);\r\n for (let i = k; i < m; i++) {\r\n U.set(i, j, U.get(i, j) + t * U.get(i, k));\r\n }\r\n }\r\n for (let i = k; i < m; i++) {\r\n U.set(i, k, -U.get(i, k));\r\n }\r\n U.set(k, k, 1 + U.get(k, k));\r\n for (let i = 0; i < k - 1; i++) {\r\n U.set(i, k, 0);\r\n }\r\n } else {\r\n for (let i = 0; i < m; i++) {\r\n U.set(i, k, 0);\r\n }\r\n U.set(k, k, 1);\r\n }\r\n }\r\n }\r\n\r\n if (wantv) {\r\n for (let k = n - 1; k >= 0; k--) {\r\n if (k < nrt && e[k] !== 0) {\r\n for (let j = k + 1; j < n; j++) {\r\n let t = 0;\r\n for (let i = k + 1; i < n; i++) {\r\n t += V.get(i, k) * V.get(i, j);\r\n }\r\n t = -t / V.get(k + 1, k);\r\n for (let i = k + 1; i < n; i++) {\r\n V.set(i, j, V.get(i, j) + t * V.get(i, k));\r\n }\r\n }\r\n }\r\n for (let i = 0; i < n; i++) {\r\n V.set(i, k, 0);\r\n }\r\n V.set(k, k, 1);\r\n }\r\n }\r\n\r\n let pp = p - 1;\r\n let iter = 0;\r\n let eps = Number.EPSILON;\r\n while (p > 0) {\r\n let k, kase;\r\n for (k = p - 2; k >= -1; k--) {\r\n if (k === -1) {\r\n break;\r\n }\r\n const alpha =\r\n Number.MIN_VALUE + eps * Math.abs(s[k] + Math.abs(s[k + 1]));\r\n if (Math.abs(e[k]) <= alpha || Number.isNaN(e[k])) {\r\n e[k] = 0;\r\n break;\r\n }\r\n }\r\n if (k === p - 2) {\r\n kase = 4;\r\n } else {\r\n let ks;\r\n for (ks = p - 1; ks >= k; ks--) {\r\n if (ks === k) {\r\n break;\r\n }\r\n let t =\r\n (ks !== p ? Math.abs(e[ks]) : 0) +\r\n (ks !== k + 1 ? Math.abs(e[ks - 1]) : 0);\r\n if (Math.abs(s[ks]) <= eps * t) {\r\n s[ks] = 0;\r\n break;\r\n }\r\n }\r\n if (ks === k) {\r\n kase = 3;\r\n } else if (ks === p - 1) {\r\n kase = 1;\r\n } else {\r\n kase = 2;\r\n k = ks;\r\n }\r\n }\r\n\r\n k++;\r\n\r\n switch (kase) {\r\n case 1: {\r\n let f = e[p - 2];\r\n e[p - 2] = 0;\r\n for (let j = p - 2; j >= k; j--) {\r\n let t = hypotenuse(s[j], f);\r\n let cs = s[j] / t;\r\n let sn = f / t;\r\n s[j] = t;\r\n if (j !== k) {\r\n f = -sn * e[j - 1];\r\n e[j - 1] = cs * e[j - 1];\r\n }\r\n if (wantv) {\r\n for (let i = 0; i < n; i++) {\r\n t = cs * V.get(i, j) + sn * V.get(i, p - 1);\r\n V.set(i, p - 1, -sn * V.get(i, j) + cs * V.get(i, p - 1));\r\n V.set(i, j, t);\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n case 2: {\r\n let f = e[k - 1];\r\n e[k - 1] = 0;\r\n for (let j = k; j < p; j++) {\r\n let t = hypotenuse(s[j], f);\r\n let cs = s[j] / t;\r\n let sn = f / t;\r\n s[j] = t;\r\n f = -sn * e[j];\r\n e[j] = cs * e[j];\r\n if (wantu) {\r\n for (let i = 0; i < m; i++) {\r\n t = cs * U.get(i, j) + sn * U.get(i, k - 1);\r\n U.set(i, k - 1, -sn * U.get(i, j) + cs * U.get(i, k - 1));\r\n U.set(i, j, t);\r\n }\r\n }\r\n }\r\n break;\r\n }\r\n case 3: {\r\n const scale = Math.max(\r\n Math.abs(s[p - 1]),\r\n Math.abs(s[p - 2]),\r\n Math.abs(e[p - 2]),\r\n Math.abs(s[k]),\r\n Math.abs(e[k]),\r\n );\r\n const sp = s[p - 1] / scale;\r\n const spm1 = s[p - 2] / scale;\r\n const epm1 = e[p - 2] / scale;\r\n const sk = s[k] / scale;\r\n const ek = e[k] / scale;\r\n const b = ((spm1 + sp) * (spm1 - sp) + epm1 * epm1) / 2;\r\n const c = sp * epm1 * (sp * epm1);\r\n let shift = 0;\r\n if (b !== 0 || c !== 0) {\r\n if (b < 0) {\r\n shift = 0 - Math.sqrt(b * b + c);\r\n } else {\r\n shift = Math.sqrt(b * b + c);\r\n }\r\n shift = c / (b + shift);\r\n }\r\n let f = (sk + sp) * (sk - sp) + shift;\r\n let g = sk * ek;\r\n for (let j = k; j < p - 1; j++) {\r\n let t = hypotenuse(f, g);\r\n if (t === 0) t = Number.MIN_VALUE;\r\n let cs = f / t;\r\n let sn = g / t;\r\n if (j !== k) {\r\n e[j - 1] = t;\r\n }\r\n f = cs * s[j] + sn * e[j];\r\n e[j] = cs * e[j] - sn * s[j];\r\n g = sn * s[j + 1];\r\n s[j + 1] = cs * s[j + 1];\r\n if (wantv) {\r\n for (let i = 0; i < n; i++) {\r\n t = cs * V.get(i, j) + sn * V.get(i, j + 1);\r\n V.set(i, j + 1, -sn * V.get(i, j) + cs * V.get(i, j + 1));\r\n V.set(i, j, t);\r\n }\r\n }\r\n t = hypotenuse(f, g);\r\n if (t === 0) t = Number.MIN_VALUE;\r\n cs = f / t;\r\n sn = g / t;\r\n s[j] = t;\r\n f = cs * e[j] + sn * s[j + 1];\r\n s[j + 1] = -sn * e[j] + cs * s[j + 1];\r\n g = sn * e[j + 1];\r\n e[j + 1] = cs * e[j + 1];\r\n if (wantu && j < m - 1) {\r\n for (let i = 0; i < m; i++) {\r\n t = cs * U.get(i, j) + sn * U.get(i, j + 1);\r\n U.set(i, j + 1, -sn * U.get(i, j) + cs * U.get(i, j + 1));\r\n U.set(i, j, t);\r\n }\r\n }\r\n }\r\n e[p - 2] = f;\r\n iter = iter + 1;\r\n break;\r\n }\r\n case 4: {\r\n if (s[k] <= 0) {\r\n s[k] = s[k] < 0 ? -s[k] : 0;\r\n if (wantv) {\r\n for (let i = 0; i <= pp; i++) {\r\n V.set(i, k, -V.get(i, k));\r\n }\r\n }\r\n }\r\n while (k < pp) {\r\n if (s[k] >= s[k + 1]) {\r\n break;\r\n }\r\n let t = s[k];\r\n s[k] = s[k + 1];\r\n s[k + 1] = t;\r\n if (wantv && k < n - 1) {\r\n for (let i = 0; i < n; i++) {\r\n t = V.get(i, k + 1);\r\n V.set(i, k + 1, V.get(i, k));\r\n V.set(i, k, t);\r\n }\r\n }\r\n if (wantu && k < m - 1) {\r\n for (let i = 0; i < m; i++) {\r\n t = U.get(i, k + 1);\r\n U.set(i, k + 1, U.get(i, k));\r\n U.set(i, k, t);\r\n }\r\n }\r\n k++;\r\n }\r\n iter = 0;\r\n p--;\r\n break;\r\n }\r\n // no default\r\n }\r\n }\r\n\r\n if (swapped) {\r\n let tmp = V;\r\n V = U;\r\n U = tmp;\r\n }\r\n\r\n this.m = m;\r\n this.n = n;\r\n this.s = s;\r\n this.U = U;\r\n this.V = V;\r\n }\r\n\r\n solve(value) {\r\n let Y = value;\r\n let e = this.threshold;\r\n let scols = this.s.length;\r\n let Ls = Matrix.zeros(scols, scols);\r\n\r\n for (let i = 0; i < scols; i++) {\r\n if (Math.abs(this.s[i]) <= e) {\r\n Ls.set(i, i, 0);\r\n } else {\r\n Ls.set(i, i, 1 / this.s[i]);\r\n }\r\n }\r\n\r\n let U = this.U;\r\n let V = this.rightSingularVectors;\r\n\r\n let VL = V.mmul(Ls);\r\n let vrows = V.rows;\r\n let urows = U.rows;\r\n let VLU = Matrix.zeros(vrows, urows);\r\n\r\n for (let i = 0; i < vrows; i++) {\r\n for (let j = 0; j < urows; j++) {\r\n let sum = 0;\r\n for (let k = 0; k < scols; k++) {\r\n sum += VL.get(i, k) * U.get(j, k);\r\n }\r\n VLU.set(i, j, sum);\r\n }\r\n }\r\n\r\n return VLU.mmul(Y);\r\n }\r\n\r\n solveForDiagonal(value) {\r\n return this.solve(Matrix.diag(value));\r\n }\r\n\r\n inverse() {\r\n let V = this.V;\r\n let e = this.threshold;\r\n let vrows = V.rows;\r\n let vcols = V.columns;\r\n let X = new Matrix(vrows, this.s.length);\r\n\r\n for (let i = 0; i < vrows; i++) {\r\n for (let j = 0; j < vcols; j++) {\r\n if (Math.abs(this.s[j]) > e) {\r\n X.set(i, j, V.get(i, j) / this.s[j]);\r\n }\r\n }\r\n }\r\n\r\n let U = this.U;\r\n\r\n let urows = U.rows;\r\n let ucols = U.columns;\r\n let Y = new Matrix(vrows, urows);\r\n\r\n for (let i = 0; i < vrows; i++) {\r\n for (let j = 0; j < urows; j++) {\r\n let sum = 0;\r\n for (let k = 0; k < ucols; k++) {\r\n sum += X.get(i, k) * U.get(j, k);\r\n }\r\n Y.set(i, j, sum);\r\n }\r\n }\r\n\r\n return Y;\r\n }\r\n\r\n get condition() {\r\n return this.s[0] / this.s[Math.min(this.m, this.n) - 1];\r\n }\r\n\r\n get norm2() {\r\n return this.s[0];\r\n }\r\n\r\n get rank() {\r\n let tol = Math.max(this.m, this.n) * this.s[0] * Number.EPSILON;\r\n let r = 0;\r\n let s = this.s;\r\n for (let i = 0, ii = s.length; i < ii; i++) {\r\n if (s[i] > tol) {\r\n r++;\r\n }\r\n }\r\n return r;\r\n }\r\n\r\n get diagonal() {\r\n return Array.from(this.s);\r\n }\r\n\r\n get threshold() {\r\n return (Number.EPSILON / 2) * Math.max(this.m, this.n) * this.s[0];\r\n }\r\n\r\n get leftSingularVectors() {\r\n return this.U;\r\n }\r\n\r\n get rightSingularVectors() {\r\n return this.V;\r\n }\r\n\r\n get diagonalMatrix() {\r\n return Matrix.diag(this.s);\r\n }\r\n}\r\n","import LuDecomposition from './dc/lu';\r\nimport QrDecomposition from './dc/qr';\r\nimport SingularValueDecomposition from './dc/svd';\r\nimport Matrix from './matrix';\r\nimport WrapperMatrix2D from './wrap/WrapperMatrix2D';\r\n\r\nexport function inverse(matrix, useSVD = false) {\r\n matrix = WrapperMatrix2D.checkMatrix(matrix);\r\n if (useSVD) {\r\n return new SingularValueDecomposition(matrix).inverse();\r\n } else {\r\n return solve(matrix, Matrix.eye(matrix.rows));\r\n }\r\n}\r\n\r\nexport function solve(leftHandSide, rightHandSide, useSVD = false) {\r\n leftHandSide = WrapperMatrix2D.checkMatrix(leftHandSide);\r\n rightHandSide = WrapperMatrix2D.checkMatrix(rightHandSide);\r\n if (useSVD) {\r\n return new SingularValueDecomposition(leftHandSide).solve(rightHandSide);\r\n } else {\r\n return leftHandSide.isSquare()\r\n ? new LuDecomposition(leftHandSide).solve(rightHandSide)\r\n : new QrDecomposition(leftHandSide).solve(rightHandSide);\r\n }\r\n}\r\n","import LuDecomposition from './dc/lu';\r\nimport Matrix from './matrix';\r\nimport MatrixSelectionView from './views/selection';\r\n\r\nexport function determinant(matrix) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n if (matrix.isSquare()) {\r\n let a, b, c, d;\r\n if (matrix.columns === 2) {\r\n // 2 x 2 matrix\r\n a = matrix.get(0, 0);\r\n b = matrix.get(0, 1);\r\n c = matrix.get(1, 0);\r\n d = matrix.get(1, 1);\r\n\r\n return a * d - b * c;\r\n } else if (matrix.columns === 3) {\r\n // 3 x 3 matrix\r\n let subMatrix0, subMatrix1, subMatrix2;\r\n subMatrix0 = new MatrixSelectionView(matrix, [1, 2], [1, 2]);\r\n subMatrix1 = new MatrixSelectionView(matrix, [1, 2], [0, 2]);\r\n subMatrix2 = new MatrixSelectionView(matrix, [1, 2], [0, 1]);\r\n a = matrix.get(0, 0);\r\n b = matrix.get(0, 1);\r\n c = matrix.get(0, 2);\r\n\r\n return (\r\n a * determinant(subMatrix0) -\r\n b * determinant(subMatrix1) +\r\n c * determinant(subMatrix2)\r\n );\r\n } else {\r\n // general purpose determinant using the LU decomposition\r\n return new LuDecomposition(matrix).determinant;\r\n }\r\n } else {\r\n throw Error('determinant can only be calculated for a square matrix');\r\n }\r\n}\r\n","import SingularValueDecomposition from './dc/svd';\r\nimport Matrix from './matrix';\r\n\r\nfunction xrange(n, exception) {\r\n let range = [];\r\n for (let i = 0; i < n; i++) {\r\n if (i !== exception) {\r\n range.push(i);\r\n }\r\n }\r\n return range;\r\n}\r\n\r\nfunction dependenciesOneRow(\r\n error,\r\n matrix,\r\n index,\r\n thresholdValue = 10e-10,\r\n thresholdError = 10e-10,\r\n) {\r\n if (error > thresholdError) {\r\n return new Array(matrix.rows + 1).fill(0);\r\n } else {\r\n let returnArray = matrix.addRow(index, [0]);\r\n for (let i = 0; i < returnArray.rows; i++) {\r\n if (Math.abs(returnArray.get(i, 0)) < thresholdValue) {\r\n returnArray.set(i, 0, 0);\r\n }\r\n }\r\n return returnArray.to1DArray();\r\n }\r\n}\r\n\r\nexport function linearDependencies(matrix, options = {}) {\r\n const { thresholdValue = 10e-10, thresholdError = 10e-10 } = options;\r\n matrix = Matrix.checkMatrix(matrix);\r\n\r\n let n = matrix.rows;\r\n let results = new Matrix(n, n);\r\n\r\n for (let i = 0; i < n; i++) {\r\n let b = Matrix.columnVector(matrix.getRow(i));\r\n let Abis = matrix.subMatrixRow(xrange(n, i)).transpose();\r\n let svd = new SingularValueDecomposition(Abis);\r\n let x = svd.solve(b);\r\n let error = Matrix.sub(b, Abis.mmul(x)).abs().max();\r\n results.setRow(\r\n i,\r\n dependenciesOneRow(error, x, i, thresholdValue, thresholdError),\r\n );\r\n }\r\n return results;\r\n}\r\n","import SVD from './dc/svd';\r\nimport Matrix from './matrix';\r\n\r\nexport function pseudoInverse(matrix, threshold = Number.EPSILON) {\r\n matrix = Matrix.checkMatrix(matrix);\r\n let svdSolution = new SVD(matrix, { autoTranspose: true });\r\n\r\n let U = svdSolution.leftSingularVectors;\r\n let V = svdSolution.rightSingularVectors;\r\n let s = svdSolution.diagonal;\r\n\r\n for (let i = 0; i < s.length; i++) {\r\n if (Math.abs(s[i]) > threshold) {\r\n s[i] = 1.0 / s[i];\r\n } else {\r\n s[i] = 0.0;\r\n }\r\n }\r\n\r\n return V.mmul(Matrix.diag(s).mmul(U.transpose()));\r\n}\r\n","import Matrix from './matrix';\r\n\r\nexport function covariance(xMatrix, yMatrix = xMatrix, options = {}) {\r\n xMatrix = new Matrix(xMatrix);\r\n let yIsSame = false;\r\n if (\r\n typeof yMatrix === 'object' &&\r\n !Matrix.isMatrix(yMatrix) &&\r\n !Array.isArray(yMatrix)\r\n ) {\r\n options = yMatrix;\r\n yMatrix = xMatrix;\r\n yIsSame = true;\r\n } else {\r\n yMatrix = new Matrix(yMatrix);\r\n }\r\n if (xMatrix.rows !== yMatrix.rows) {\r\n throw new TypeError('Both matrices must have the same number of rows');\r\n }\r\n const { center = true } = options;\r\n if (center) {\r\n xMatrix = xMatrix.center('column');\r\n if (!yIsSame) {\r\n yMatrix = yMatrix.center('column');\r\n }\r\n }\r\n const cov = xMatrix.transpose().mmul(yMatrix);\r\n for (let i = 0; i < cov.rows; i++) {\r\n for (let j = 0; j < cov.columns; j++) {\r\n cov.set(i, j, cov.get(i, j) * (1 / (xMatrix.rows - 1)));\r\n }\r\n }\r\n return cov;\r\n}\r\n","import Matrix from './matrix';\r\n\r\nexport function correlation(xMatrix, yMatrix = xMatrix, options = {}) {\r\n xMatrix = new Matrix(xMatrix);\r\n let yIsSame = false;\r\n if (\r\n typeof yMatrix === 'object' &&\r\n !Matrix.isMatrix(yMatrix) &&\r\n !Array.isArray(yMatrix)\r\n ) {\r\n options = yMatrix;\r\n yMatrix = xMatrix;\r\n yIsSame = true;\r\n } else {\r\n yMatrix = new Matrix(yMatrix);\r\n }\r\n if (xMatrix.rows !== yMatrix.rows) {\r\n throw new TypeError('Both matrices must have the same number of rows');\r\n }\r\n\r\n const { center = true, scale = true } = options;\r\n if (center) {\r\n xMatrix.center('column');\r\n if (!yIsSame) {\r\n yMatrix.center('column');\r\n }\r\n }\r\n if (scale) {\r\n xMatrix.scale('column');\r\n if (!yIsSame) {\r\n yMatrix.scale('column');\r\n }\r\n }\r\n\r\n const sdx = xMatrix.standardDeviation('column', { unbiased: true });\r\n const sdy = yIsSame\r\n ? sdx\r\n : yMatrix.standardDeviation('column', { unbiased: true });\r\n\r\n const corr = xMatrix.transpose().mmul(yMatrix);\r\n for (let i = 0; i < corr.rows; i++) {\r\n for (let j = 0; j < corr.columns; j++) {\r\n corr.set(\r\n i,\r\n j,\r\n corr.get(i, j) * (1 / (sdx[i] * sdy[j])) * (1 / (xMatrix.rows - 1)),\r\n );\r\n }\r\n }\r\n return corr;\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nimport { hypotenuse } from './util';\r\n\r\nexport default class EigenvalueDecomposition {\r\n constructor(matrix, options = {}) {\r\n const { assumeSymmetric = false } = options;\r\n\r\n matrix = WrapperMatrix2D.checkMatrix(matrix);\r\n if (!matrix.isSquare()) {\r\n throw new Error('Matrix is not a square matrix');\r\n }\r\n\r\n let n = matrix.columns;\r\n let V = new Matrix(n, n);\r\n let d = new Float64Array(n);\r\n let e = new Float64Array(n);\r\n let value = matrix;\r\n let i, j;\r\n\r\n let isSymmetric = false;\r\n if (assumeSymmetric) {\r\n isSymmetric = true;\r\n } else {\r\n isSymmetric = matrix.isSymmetric();\r\n }\r\n\r\n if (isSymmetric) {\r\n for (i = 0; i < n; i++) {\r\n for (j = 0; j < n; j++) {\r\n V.set(i, j, value.get(i, j));\r\n }\r\n }\r\n tred2(n, e, d, V);\r\n tql2(n, e, d, V);\r\n } else {\r\n let H = new Matrix(n, n);\r\n let ort = new Float64Array(n);\r\n for (j = 0; j < n; j++) {\r\n for (i = 0; i < n; i++) {\r\n H.set(i, j, value.get(i, j));\r\n }\r\n }\r\n orthes(n, H, ort, V);\r\n hqr2(n, e, d, V, H);\r\n }\r\n\r\n this.n = n;\r\n this.e = e;\r\n this.d = d;\r\n this.V = V;\r\n }\r\n\r\n get realEigenvalues() {\r\n return Array.from(this.d);\r\n }\r\n\r\n get imaginaryEigenvalues() {\r\n return Array.from(this.e);\r\n }\r\n\r\n get eigenvectorMatrix() {\r\n return this.V;\r\n }\r\n\r\n get diagonalMatrix() {\r\n let n = this.n;\r\n let e = this.e;\r\n let d = this.d;\r\n let X = new Matrix(n, n);\r\n let i, j;\r\n for (i = 0; i < n; i++) {\r\n for (j = 0; j < n; j++) {\r\n X.set(i, j, 0);\r\n }\r\n X.set(i, i, d[i]);\r\n if (e[i] > 0) {\r\n X.set(i, i + 1, e[i]);\r\n } else if (e[i] < 0) {\r\n X.set(i, i - 1, e[i]);\r\n }\r\n }\r\n return X;\r\n }\r\n}\r\n\r\nfunction tred2(n, e, d, V) {\r\n let f, g, h, i, j, k, hh, scale;\r\n\r\n for (j = 0; j < n; j++) {\r\n d[j] = V.get(n - 1, j);\r\n }\r\n\r\n for (i = n - 1; i > 0; i--) {\r\n scale = 0;\r\n h = 0;\r\n for (k = 0; k < i; k++) {\r\n scale = scale + Math.abs(d[k]);\r\n }\r\n\r\n if (scale === 0) {\r\n e[i] = d[i - 1];\r\n for (j = 0; j < i; j++) {\r\n d[j] = V.get(i - 1, j);\r\n V.set(i, j, 0);\r\n V.set(j, i, 0);\r\n }\r\n } else {\r\n for (k = 0; k < i; k++) {\r\n d[k] /= scale;\r\n h += d[k] * d[k];\r\n }\r\n\r\n f = d[i - 1];\r\n g = Math.sqrt(h);\r\n if (f > 0) {\r\n g = -g;\r\n }\r\n\r\n e[i] = scale * g;\r\n h = h - f * g;\r\n d[i - 1] = f - g;\r\n for (j = 0; j < i; j++) {\r\n e[j] = 0;\r\n }\r\n\r\n for (j = 0; j < i; j++) {\r\n f = d[j];\r\n V.set(j, i, f);\r\n g = e[j] + V.get(j, j) * f;\r\n for (k = j + 1; k <= i - 1; k++) {\r\n g += V.get(k, j) * d[k];\r\n e[k] += V.get(k, j) * f;\r\n }\r\n e[j] = g;\r\n }\r\n\r\n f = 0;\r\n for (j = 0; j < i; j++) {\r\n e[j] /= h;\r\n f += e[j] * d[j];\r\n }\r\n\r\n hh = f / (h + h);\r\n for (j = 0; j < i; j++) {\r\n e[j] -= hh * d[j];\r\n }\r\n\r\n for (j = 0; j < i; j++) {\r\n f = d[j];\r\n g = e[j];\r\n for (k = j; k <= i - 1; k++) {\r\n V.set(k, j, V.get(k, j) - (f * e[k] + g * d[k]));\r\n }\r\n d[j] = V.get(i - 1, j);\r\n V.set(i, j, 0);\r\n }\r\n }\r\n d[i] = h;\r\n }\r\n\r\n for (i = 0; i < n - 1; i++) {\r\n V.set(n - 1, i, V.get(i, i));\r\n V.set(i, i, 1);\r\n h = d[i + 1];\r\n if (h !== 0) {\r\n for (k = 0; k <= i; k++) {\r\n d[k] = V.get(k, i + 1) / h;\r\n }\r\n\r\n for (j = 0; j <= i; j++) {\r\n g = 0;\r\n for (k = 0; k <= i; k++) {\r\n g += V.get(k, i + 1) * V.get(k, j);\r\n }\r\n for (k = 0; k <= i; k++) {\r\n V.set(k, j, V.get(k, j) - g * d[k]);\r\n }\r\n }\r\n }\r\n\r\n for (k = 0; k <= i; k++) {\r\n V.set(k, i + 1, 0);\r\n }\r\n }\r\n\r\n for (j = 0; j < n; j++) {\r\n d[j] = V.get(n - 1, j);\r\n V.set(n - 1, j, 0);\r\n }\r\n\r\n V.set(n - 1, n - 1, 1);\r\n e[0] = 0;\r\n}\r\n\r\nfunction tql2(n, e, d, V) {\r\n let g, h, i, j, k, l, m, p, r, dl1, c, c2, c3, el1, s, s2, iter;\r\n\r\n for (i = 1; i < n; i++) {\r\n e[i - 1] = e[i];\r\n }\r\n\r\n e[n - 1] = 0;\r\n\r\n let f = 0;\r\n let tst1 = 0;\r\n let eps = Number.EPSILON;\r\n\r\n for (l = 0; l < n; l++) {\r\n tst1 = Math.max(tst1, Math.abs(d[l]) + Math.abs(e[l]));\r\n m = l;\r\n while (m < n) {\r\n if (Math.abs(e[m]) <= eps * tst1) {\r\n break;\r\n }\r\n m++;\r\n }\r\n\r\n if (m > l) {\r\n iter = 0;\r\n do {\r\n iter = iter + 1;\r\n\r\n g = d[l];\r\n p = (d[l + 1] - g) / (2 * e[l]);\r\n r = hypotenuse(p, 1);\r\n if (p < 0) {\r\n r = -r;\r\n }\r\n\r\n d[l] = e[l] / (p + r);\r\n d[l + 1] = e[l] * (p + r);\r\n dl1 = d[l + 1];\r\n h = g - d[l];\r\n for (i = l + 2; i < n; i++) {\r\n d[i] -= h;\r\n }\r\n\r\n f = f + h;\r\n\r\n p = d[m];\r\n c = 1;\r\n c2 = c;\r\n c3 = c;\r\n el1 = e[l + 1];\r\n s = 0;\r\n s2 = 0;\r\n for (i = m - 1; i >= l; i--) {\r\n c3 = c2;\r\n c2 = c;\r\n s2 = s;\r\n g = c * e[i];\r\n h = c * p;\r\n r = hypotenuse(p, e[i]);\r\n e[i + 1] = s * r;\r\n s = e[i] / r;\r\n c = p / r;\r\n p = c * d[i] - s * g;\r\n d[i + 1] = h + s * (c * g + s * d[i]);\r\n\r\n for (k = 0; k < n; k++) {\r\n h = V.get(k, i + 1);\r\n V.set(k, i + 1, s * V.get(k, i) + c * h);\r\n V.set(k, i, c * V.get(k, i) - s * h);\r\n }\r\n }\r\n\r\n p = (-s * s2 * c3 * el1 * e[l]) / dl1;\r\n e[l] = s * p;\r\n d[l] = c * p;\r\n } while (Math.abs(e[l]) > eps * tst1);\r\n }\r\n d[l] = d[l] + f;\r\n e[l] = 0;\r\n }\r\n\r\n for (i = 0; i < n - 1; i++) {\r\n k = i;\r\n p = d[i];\r\n for (j = i + 1; j < n; j++) {\r\n if (d[j] < p) {\r\n k = j;\r\n p = d[j];\r\n }\r\n }\r\n\r\n if (k !== i) {\r\n d[k] = d[i];\r\n d[i] = p;\r\n for (j = 0; j < n; j++) {\r\n p = V.get(j, i);\r\n V.set(j, i, V.get(j, k));\r\n V.set(j, k, p);\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction orthes(n, H, ort, V) {\r\n let low = 0;\r\n let high = n - 1;\r\n let f, g, h, i, j, m;\r\n let scale;\r\n\r\n for (m = low + 1; m <= high - 1; m++) {\r\n scale = 0;\r\n for (i = m; i <= high; i++) {\r\n scale = scale + Math.abs(H.get(i, m - 1));\r\n }\r\n\r\n if (scale !== 0) {\r\n h = 0;\r\n for (i = high; i >= m; i--) {\r\n ort[i] = H.get(i, m - 1) / scale;\r\n h += ort[i] * ort[i];\r\n }\r\n\r\n g = Math.sqrt(h);\r\n if (ort[m] > 0) {\r\n g = -g;\r\n }\r\n\r\n h = h - ort[m] * g;\r\n ort[m] = ort[m] - g;\r\n\r\n for (j = m; j < n; j++) {\r\n f = 0;\r\n for (i = high; i >= m; i--) {\r\n f += ort[i] * H.get(i, j);\r\n }\r\n\r\n f = f / h;\r\n for (i = m; i <= high; i++) {\r\n H.set(i, j, H.get(i, j) - f * ort[i]);\r\n }\r\n }\r\n\r\n for (i = 0; i <= high; i++) {\r\n f = 0;\r\n for (j = high; j >= m; j--) {\r\n f += ort[j] * H.get(i, j);\r\n }\r\n\r\n f = f / h;\r\n for (j = m; j <= high; j++) {\r\n H.set(i, j, H.get(i, j) - f * ort[j]);\r\n }\r\n }\r\n\r\n ort[m] = scale * ort[m];\r\n H.set(m, m - 1, scale * g);\r\n }\r\n }\r\n\r\n for (i = 0; i < n; i++) {\r\n for (j = 0; j < n; j++) {\r\n V.set(i, j, i === j ? 1 : 0);\r\n }\r\n }\r\n\r\n for (m = high - 1; m >= low + 1; m--) {\r\n if (H.get(m, m - 1) !== 0) {\r\n for (i = m + 1; i <= high; i++) {\r\n ort[i] = H.get(i, m - 1);\r\n }\r\n\r\n for (j = m; j <= high; j++) {\r\n g = 0;\r\n for (i = m; i <= high; i++) {\r\n g += ort[i] * V.get(i, j);\r\n }\r\n\r\n g = g / ort[m] / H.get(m, m - 1);\r\n for (i = m; i <= high; i++) {\r\n V.set(i, j, V.get(i, j) + g * ort[i]);\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\nfunction hqr2(nn, e, d, V, H) {\r\n let n = nn - 1;\r\n let low = 0;\r\n let high = nn - 1;\r\n let eps = Number.EPSILON;\r\n let exshift = 0;\r\n let norm = 0;\r\n let p = 0;\r\n let q = 0;\r\n let r = 0;\r\n let s = 0;\r\n let z = 0;\r\n let iter = 0;\r\n let i, j, k, l, m, t, w, x, y;\r\n let ra, sa, vr, vi;\r\n let notlast, cdivres;\r\n\r\n for (i = 0; i < nn; i++) {\r\n if (i < low || i > high) {\r\n d[i] = H.get(i, i);\r\n e[i] = 0;\r\n }\r\n\r\n for (j = Math.max(i - 1, 0); j < nn; j++) {\r\n norm = norm + Math.abs(H.get(i, j));\r\n }\r\n }\r\n\r\n while (n >= low) {\r\n l = n;\r\n while (l > low) {\r\n s = Math.abs(H.get(l - 1, l - 1)) + Math.abs(H.get(l, l));\r\n if (s === 0) {\r\n s = norm;\r\n }\r\n if (Math.abs(H.get(l, l - 1)) < eps * s) {\r\n break;\r\n }\r\n l--;\r\n }\r\n\r\n if (l === n) {\r\n H.set(n, n, H.get(n, n) + exshift);\r\n d[n] = H.get(n, n);\r\n e[n] = 0;\r\n n--;\r\n iter = 0;\r\n } else if (l === n - 1) {\r\n w = H.get(n, n - 1) * H.get(n - 1, n);\r\n p = (H.get(n - 1, n - 1) - H.get(n, n)) / 2;\r\n q = p * p + w;\r\n z = Math.sqrt(Math.abs(q));\r\n H.set(n, n, H.get(n, n) + exshift);\r\n H.set(n - 1, n - 1, H.get(n - 1, n - 1) + exshift);\r\n x = H.get(n, n);\r\n\r\n if (q >= 0) {\r\n z = p >= 0 ? p + z : p - z;\r\n d[n - 1] = x + z;\r\n d[n] = d[n - 1];\r\n if (z !== 0) {\r\n d[n] = x - w / z;\r\n }\r\n e[n - 1] = 0;\r\n e[n] = 0;\r\n x = H.get(n, n - 1);\r\n s = Math.abs(x) + Math.abs(z);\r\n p = x / s;\r\n q = z / s;\r\n r = Math.sqrt(p * p + q * q);\r\n p = p / r;\r\n q = q / r;\r\n\r\n for (j = n - 1; j < nn; j++) {\r\n z = H.get(n - 1, j);\r\n H.set(n - 1, j, q * z + p * H.get(n, j));\r\n H.set(n, j, q * H.get(n, j) - p * z);\r\n }\r\n\r\n for (i = 0; i <= n; i++) {\r\n z = H.get(i, n - 1);\r\n H.set(i, n - 1, q * z + p * H.get(i, n));\r\n H.set(i, n, q * H.get(i, n) - p * z);\r\n }\r\n\r\n for (i = low; i <= high; i++) {\r\n z = V.get(i, n - 1);\r\n V.set(i, n - 1, q * z + p * V.get(i, n));\r\n V.set(i, n, q * V.get(i, n) - p * z);\r\n }\r\n } else {\r\n d[n - 1] = x + p;\r\n d[n] = x + p;\r\n e[n - 1] = z;\r\n e[n] = -z;\r\n }\r\n\r\n n = n - 2;\r\n iter = 0;\r\n } else {\r\n x = H.get(n, n);\r\n y = 0;\r\n w = 0;\r\n if (l < n) {\r\n y = H.get(n - 1, n - 1);\r\n w = H.get(n, n - 1) * H.get(n - 1, n);\r\n }\r\n\r\n if (iter === 10) {\r\n exshift += x;\r\n for (i = low; i <= n; i++) {\r\n H.set(i, i, H.get(i, i) - x);\r\n }\r\n s = Math.abs(H.get(n, n - 1)) + Math.abs(H.get(n - 1, n - 2));\r\n x = y = 0.75 * s;\r\n w = -0.4375 * s * s;\r\n }\r\n\r\n if (iter === 30) {\r\n s = (y - x) / 2;\r\n s = s * s + w;\r\n if (s > 0) {\r\n s = Math.sqrt(s);\r\n if (y < x) {\r\n s = -s;\r\n }\r\n s = x - w / ((y - x) / 2 + s);\r\n for (i = low; i <= n; i++) {\r\n H.set(i, i, H.get(i, i) - s);\r\n }\r\n exshift += s;\r\n x = y = w = 0.964;\r\n }\r\n }\r\n\r\n iter = iter + 1;\r\n\r\n m = n - 2;\r\n while (m >= l) {\r\n z = H.get(m, m);\r\n r = x - z;\r\n s = y - z;\r\n p = (r * s - w) / H.get(m + 1, m) + H.get(m, m + 1);\r\n q = H.get(m + 1, m + 1) - z - r - s;\r\n r = H.get(m + 2, m + 1);\r\n s = Math.abs(p) + Math.abs(q) + Math.abs(r);\r\n p = p / s;\r\n q = q / s;\r\n r = r / s;\r\n if (m === l) {\r\n break;\r\n }\r\n if (\r\n Math.abs(H.get(m, m - 1)) * (Math.abs(q) + Math.abs(r)) <\r\n eps *\r\n (Math.abs(p) *\r\n (Math.abs(H.get(m - 1, m - 1)) +\r\n Math.abs(z) +\r\n Math.abs(H.get(m + 1, m + 1))))\r\n ) {\r\n break;\r\n }\r\n m--;\r\n }\r\n\r\n for (i = m + 2; i <= n; i++) {\r\n H.set(i, i - 2, 0);\r\n if (i > m + 2) {\r\n H.set(i, i - 3, 0);\r\n }\r\n }\r\n\r\n for (k = m; k <= n - 1; k++) {\r\n notlast = k !== n - 1;\r\n if (k !== m) {\r\n p = H.get(k, k - 1);\r\n q = H.get(k + 1, k - 1);\r\n r = notlast ? H.get(k + 2, k - 1) : 0;\r\n x = Math.abs(p) + Math.abs(q) + Math.abs(r);\r\n if (x !== 0) {\r\n p = p / x;\r\n q = q / x;\r\n r = r / x;\r\n }\r\n }\r\n\r\n if (x === 0) {\r\n break;\r\n }\r\n\r\n s = Math.sqrt(p * p + q * q + r * r);\r\n if (p < 0) {\r\n s = -s;\r\n }\r\n\r\n if (s !== 0) {\r\n if (k !== m) {\r\n H.set(k, k - 1, -s * x);\r\n } else if (l !== m) {\r\n H.set(k, k - 1, -H.get(k, k - 1));\r\n }\r\n\r\n p = p + s;\r\n x = p / s;\r\n y = q / s;\r\n z = r / s;\r\n q = q / p;\r\n r = r / p;\r\n\r\n for (j = k; j < nn; j++) {\r\n p = H.get(k, j) + q * H.get(k + 1, j);\r\n if (notlast) {\r\n p = p + r * H.get(k + 2, j);\r\n H.set(k + 2, j, H.get(k + 2, j) - p * z);\r\n }\r\n\r\n H.set(k, j, H.get(k, j) - p * x);\r\n H.set(k + 1, j, H.get(k + 1, j) - p * y);\r\n }\r\n\r\n for (i = 0; i <= Math.min(n, k + 3); i++) {\r\n p = x * H.get(i, k) + y * H.get(i, k + 1);\r\n if (notlast) {\r\n p = p + z * H.get(i, k + 2);\r\n H.set(i, k + 2, H.get(i, k + 2) - p * r);\r\n }\r\n\r\n H.set(i, k, H.get(i, k) - p);\r\n H.set(i, k + 1, H.get(i, k + 1) - p * q);\r\n }\r\n\r\n for (i = low; i <= high; i++) {\r\n p = x * V.get(i, k) + y * V.get(i, k + 1);\r\n if (notlast) {\r\n p = p + z * V.get(i, k + 2);\r\n V.set(i, k + 2, V.get(i, k + 2) - p * r);\r\n }\r\n\r\n V.set(i, k, V.get(i, k) - p);\r\n V.set(i, k + 1, V.get(i, k + 1) - p * q);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (norm === 0) {\r\n return;\r\n }\r\n\r\n for (n = nn - 1; n >= 0; n--) {\r\n p = d[n];\r\n q = e[n];\r\n\r\n if (q === 0) {\r\n l = n;\r\n H.set(n, n, 1);\r\n for (i = n - 1; i >= 0; i--) {\r\n w = H.get(i, i) - p;\r\n r = 0;\r\n for (j = l; j <= n; j++) {\r\n r = r + H.get(i, j) * H.get(j, n);\r\n }\r\n\r\n if (e[i] < 0) {\r\n z = w;\r\n s = r;\r\n } else {\r\n l = i;\r\n if (e[i] === 0) {\r\n H.set(i, n, w !== 0 ? -r / w : -r / (eps * norm));\r\n } else {\r\n x = H.get(i, i + 1);\r\n y = H.get(i + 1, i);\r\n q = (d[i] - p) * (d[i] - p) + e[i] * e[i];\r\n t = (x * s - z * r) / q;\r\n H.set(i, n, t);\r\n H.set(\r\n i + 1,\r\n n,\r\n Math.abs(x) > Math.abs(z) ? (-r - w * t) / x : (-s - y * t) / z,\r\n );\r\n }\r\n\r\n t = Math.abs(H.get(i, n));\r\n if (eps * t * t > 1) {\r\n for (j = i; j <= n; j++) {\r\n H.set(j, n, H.get(j, n) / t);\r\n }\r\n }\r\n }\r\n }\r\n } else if (q < 0) {\r\n l = n - 1;\r\n\r\n if (Math.abs(H.get(n, n - 1)) > Math.abs(H.get(n - 1, n))) {\r\n H.set(n - 1, n - 1, q / H.get(n, n - 1));\r\n H.set(n - 1, n, -(H.get(n, n) - p) / H.get(n, n - 1));\r\n } else {\r\n cdivres = cdiv(0, -H.get(n - 1, n), H.get(n - 1, n - 1) - p, q);\r\n H.set(n - 1, n - 1, cdivres[0]);\r\n H.set(n - 1, n, cdivres[1]);\r\n }\r\n\r\n H.set(n, n - 1, 0);\r\n H.set(n, n, 1);\r\n for (i = n - 2; i >= 0; i--) {\r\n ra = 0;\r\n sa = 0;\r\n for (j = l; j <= n; j++) {\r\n ra = ra + H.get(i, j) * H.get(j, n - 1);\r\n sa = sa + H.get(i, j) * H.get(j, n);\r\n }\r\n\r\n w = H.get(i, i) - p;\r\n\r\n if (e[i] < 0) {\r\n z = w;\r\n r = ra;\r\n s = sa;\r\n } else {\r\n l = i;\r\n if (e[i] === 0) {\r\n cdivres = cdiv(-ra, -sa, w, q);\r\n H.set(i, n - 1, cdivres[0]);\r\n H.set(i, n, cdivres[1]);\r\n } else {\r\n x = H.get(i, i + 1);\r\n y = H.get(i + 1, i);\r\n vr = (d[i] - p) * (d[i] - p) + e[i] * e[i] - q * q;\r\n vi = (d[i] - p) * 2 * q;\r\n if (vr === 0 && vi === 0) {\r\n vr =\r\n eps *\r\n norm *\r\n (Math.abs(w) +\r\n Math.abs(q) +\r\n Math.abs(x) +\r\n Math.abs(y) +\r\n Math.abs(z));\r\n }\r\n cdivres = cdiv(\r\n x * r - z * ra + q * sa,\r\n x * s - z * sa - q * ra,\r\n vr,\r\n vi,\r\n );\r\n H.set(i, n - 1, cdivres[0]);\r\n H.set(i, n, cdivres[1]);\r\n if (Math.abs(x) > Math.abs(z) + Math.abs(q)) {\r\n H.set(\r\n i + 1,\r\n n - 1,\r\n (-ra - w * H.get(i, n - 1) + q * H.get(i, n)) / x,\r\n );\r\n H.set(\r\n i + 1,\r\n n,\r\n (-sa - w * H.get(i, n) - q * H.get(i, n - 1)) / x,\r\n );\r\n } else {\r\n cdivres = cdiv(\r\n -r - y * H.get(i, n - 1),\r\n -s - y * H.get(i, n),\r\n z,\r\n q,\r\n );\r\n H.set(i + 1, n - 1, cdivres[0]);\r\n H.set(i + 1, n, cdivres[1]);\r\n }\r\n }\r\n\r\n t = Math.max(Math.abs(H.get(i, n - 1)), Math.abs(H.get(i, n)));\r\n if (eps * t * t > 1) {\r\n for (j = i; j <= n; j++) {\r\n H.set(j, n - 1, H.get(j, n - 1) / t);\r\n H.set(j, n, H.get(j, n) / t);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n for (i = 0; i < nn; i++) {\r\n if (i < low || i > high) {\r\n for (j = i; j < nn; j++) {\r\n V.set(i, j, H.get(i, j));\r\n }\r\n }\r\n }\r\n\r\n for (j = nn - 1; j >= low; j--) {\r\n for (i = low; i <= high; i++) {\r\n z = 0;\r\n for (k = low; k <= Math.min(j, high); k++) {\r\n z = z + V.get(i, k) * H.get(k, j);\r\n }\r\n V.set(i, j, z);\r\n }\r\n }\r\n}\r\n\r\nfunction cdiv(xr, xi, yr, yi) {\r\n let r, d;\r\n if (Math.abs(yr) > Math.abs(yi)) {\r\n r = yi / yr;\r\n d = yr + r * yi;\r\n return [(xr + r * xi) / d, (xi - r * xr) / d];\r\n } else {\r\n r = yr / yi;\r\n d = yi + r * yr;\r\n return [(r * xr + xi) / d, (r * xi - xr) / d];\r\n }\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nexport default class CholeskyDecomposition {\r\n constructor(value) {\r\n value = WrapperMatrix2D.checkMatrix(value);\r\n if (!value.isSymmetric()) {\r\n throw new Error('Matrix is not symmetric');\r\n }\r\n\r\n let a = value;\r\n let dimension = a.rows;\r\n let l = new Matrix(dimension, dimension);\r\n let positiveDefinite = true;\r\n let i, j, k;\r\n\r\n for (j = 0; j < dimension; j++) {\r\n let d = 0;\r\n for (k = 0; k < j; k++) {\r\n let s = 0;\r\n for (i = 0; i < k; i++) {\r\n s += l.get(k, i) * l.get(j, i);\r\n }\r\n s = (a.get(j, k) - s) / l.get(k, k);\r\n l.set(j, k, s);\r\n d = d + s * s;\r\n }\r\n\r\n d = a.get(j, j) - d;\r\n\r\n positiveDefinite &= d > 0;\r\n l.set(j, j, Math.sqrt(Math.max(d, 0)));\r\n for (k = j + 1; k < dimension; k++) {\r\n l.set(j, k, 0);\r\n }\r\n }\r\n\r\n this.L = l;\r\n this.positiveDefinite = Boolean(positiveDefinite);\r\n }\r\n\r\n isPositiveDefinite() {\r\n return this.positiveDefinite;\r\n }\r\n\r\n solve(value) {\r\n value = WrapperMatrix2D.checkMatrix(value);\r\n\r\n let l = this.L;\r\n let dimension = l.rows;\r\n\r\n if (value.rows !== dimension) {\r\n throw new Error('Matrix dimensions do not match');\r\n }\r\n if (this.isPositiveDefinite() === false) {\r\n throw new Error('Matrix is not positive definite');\r\n }\r\n\r\n let count = value.columns;\r\n let B = value.clone();\r\n let i, j, k;\r\n\r\n for (k = 0; k < dimension; k++) {\r\n for (j = 0; j < count; j++) {\r\n for (i = 0; i < k; i++) {\r\n B.set(k, j, B.get(k, j) - B.get(i, j) * l.get(k, i));\r\n }\r\n B.set(k, j, B.get(k, j) / l.get(k, k));\r\n }\r\n }\r\n\r\n for (k = dimension - 1; k >= 0; k--) {\r\n for (j = 0; j < count; j++) {\r\n for (i = k + 1; i < dimension; i++) {\r\n B.set(k, j, B.get(k, j) - B.get(i, j) * l.get(i, k));\r\n }\r\n B.set(k, j, B.get(k, j) / l.get(k, k));\r\n }\r\n }\r\n\r\n return B;\r\n }\r\n\r\n get lowerTriangularMatrix() {\r\n return this.L;\r\n }\r\n}\r\n","import Matrix from '../matrix';\r\nimport WrapperMatrix2D from '../wrap/WrapperMatrix2D';\r\n\r\nexport default class nipals {\r\n constructor(X, options = {}) {\r\n X = WrapperMatrix2D.checkMatrix(X);\r\n let { Y } = options;\r\n const {\r\n scaleScores = false,\r\n maxIterations = 1000,\r\n terminationCriteria = 1e-10,\r\n } = options;\r\n\r\n let u;\r\n if (Y) {\r\n if (Array.isArray(Y) && typeof Y[0] === 'number') {\r\n Y = Matrix.columnVector(Y);\r\n } else {\r\n Y = WrapperMatrix2D.checkMatrix(Y);\r\n }\r\n if (!Y.isColumnVector() || Y.rows !== X.rows) {\r\n throw new Error('Y must be a column vector of length X.rows');\r\n }\r\n u = Y;\r\n } else {\r\n u = X.getColumnVector(0);\r\n }\r\n\r\n let diff = 1;\r\n let t, q, w, tOld;\r\n\r\n for (\r\n let counter = 0;\r\n counter < maxIterations && diff > terminationCriteria;\r\n counter++\r\n ) {\r\n w = X.transpose().mmul(u).div(u.transpose().mmul(u).get(0, 0));\r\n w = w.div(w.norm());\r\n\r\n t = X.mmul(w).div(w.transpose().mmul(w).get(0, 0));\r\n\r\n if (counter > 0) {\r\n diff = t.clone().sub(tOld).pow(2).sum();\r\n }\r\n tOld = t.clone();\r\n\r\n if (Y) {\r\n q = Y.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\r\n q = q.div(q.norm());\r\n\r\n u = Y.mmul(q).div(q.transpose().mmul(q).get(0, 0));\r\n } else {\r\n u = t;\r\n }\r\n }\r\n\r\n if (Y) {\r\n let p = X.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\r\n p = p.div(p.norm());\r\n let xResidual = X.clone().sub(t.clone().mmul(p.transpose()));\r\n let residual = u.transpose().mmul(t).div(t.transpose().mmul(t).get(0, 0));\r\n let yResidual = Y.clone().sub(\r\n t.clone().mulS(residual.get(0, 0)).mmul(q.transpose()),\r\n );\r\n\r\n this.t = t;\r\n this.p = p.transpose();\r\n this.w = w.transpose();\r\n this.q = q;\r\n this.u = u;\r\n this.s = t.transpose().mmul(t);\r\n this.xResidual = xResidual;\r\n this.yResidual = yResidual;\r\n this.betas = residual;\r\n } else {\r\n this.w = w.transpose();\r\n this.s = t.transpose().mmul(t).sqrt();\r\n if (scaleScores) {\r\n this.t = t.clone().div(this.s.get(0, 0));\r\n } else {\r\n this.t = t;\r\n }\r\n this.xResidual = X.sub(t.mmul(w.transpose()));\r\n }\r\n }\r\n}\r\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction sum(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var sumValue = 0;\n\n for (var i = 0; i < input.length; i++) {\n sumValue += input[i];\n }\n\n return sumValue;\n}\n\nexport default sum;\n","import sum from 'ml-array-sum';\n\nfunction mean(input) {\n return sum(input) / input.length;\n}\n\nexport default mean;\n","import Matrix from 'ml-matrix';\nimport meanArray from 'ml-array-mean';\n\n/**\n * @private\n * return an array of probabilities of each class\n * @param {Array} array - contains the classes\n * @param {number} numberOfClasses\n * @return {Matrix} - rowVector of probabilities.\n */\nexport function toDiscreteDistribution(array, numberOfClasses) {\n let counts = new Array(numberOfClasses).fill(0);\n for (let i = 0; i < array.length; ++i) {\n counts[array[i]] += 1 / array.length;\n }\n\n return Matrix.rowVector(counts);\n}\n\n/**\n * @private\n * Retrieves the impurity of array of predictions\n * @param {Array} array - predictions.\n * @return {number} Gini impurity\n */\nexport function giniImpurity(array) {\n if (array.length === 0) {\n return 0;\n }\n\n let probabilities = toDiscreteDistribution(\n array,\n getNumberOfClasses(array),\n ).getRow(0);\n\n let sum = 0.0;\n for (let i = 0; i < probabilities.length; ++i) {\n sum += probabilities[i] * probabilities[i];\n }\n\n return 1 - sum;\n}\n\n/**\n * @private\n * Return the number of classes given the array of predictions.\n * @param {Array} array - predictions.\n * @return {number} Number of classes.\n */\nexport function getNumberOfClasses(array) {\n return array\n .filter(function(val, i, arr) {\n return arr.indexOf(val) === i;\n })\n .map((val) => val + 1)\n .reduce((a, b) => Math.max(a, b));\n}\n\n/**\n * @private\n * Calculates the Gini Gain of an array of predictions and those predictions splitted by a feature.\n * @param {Array} array - Predictions\n * @param {object} splitted - Object with elements \"greater\" and \"lesser\" that contains an array of predictions splitted.\n * @return {number} - Gini Gain.\n */\n\nexport function giniGain(array, splitted) {\n let splitsImpurity = 0.0;\n let splits = ['greater', 'lesser'];\n\n for (let i = 0; i < splits.length; ++i) {\n let currentSplit = splitted[splits[i]];\n splitsImpurity +=\n (giniImpurity(currentSplit) * currentSplit.length) / array.length;\n }\n\n return giniImpurity(array) - splitsImpurity;\n}\n\n/**\n * @private\n * Calculates the squared error of a predictions values.\n * @param {Array} array - predictions values\n * @return {number} squared error.\n */\nexport function squaredError(array) {\n let l = array.length;\n\n let m = meanArray(array);\n let error = 0.0;\n\n for (let i = 0; i < l; ++i) {\n let currentElement = array[i];\n error += (currentElement - m) * (currentElement - m);\n }\n\n return error;\n}\n\n/**\n * @private\n * Calculates the sum of squared error of the two arrays that contains the splitted values.\n * @param {Array} array - this argument is no necessary but is used to fit with the main interface.\n * @param {object} splitted - Object with elements \"greater\" and \"lesser\" that contains an array of predictions splitted.\n * @return {number} - sum of squared errors.\n */\nexport function regressionError(array, splitted) {\n let error = 0.0;\n let splits = ['greater', 'lesser'];\n\n for (let i = 0; i < splits.length; ++i) {\n let currentSplit = splitted[splits[i]];\n error += squaredError(currentSplit);\n }\n return error;\n}\n\n/**\n * @private\n * Split the training set and values from a given column of the training set if is less than a value\n * @param {Matrix} X - Training set.\n * @param {Array} y - Training values.\n * @param {number} column - Column to split.\n * @param {number} value - value to split the Training set and values.\n * @return {object} - Object that contains the splitted values.\n */\nexport function matrixSplitter(X, y, column, value) {\n let lesserX = [];\n let greaterX = [];\n let lesserY = [];\n let greaterY = [];\n\n for (let i = 0; i < X.rows; ++i) {\n if (X.get(i, column) < value) {\n lesserX.push(X.getRow(i));\n lesserY.push(y[i]);\n } else {\n greaterX.push(X.getRow(i));\n greaterY.push(y[i]);\n }\n }\n\n return {\n greaterX: greaterX,\n greaterY: greaterY,\n lesserX: lesserX,\n lesserY: lesserY,\n };\n}\n\n/**\n * @private\n * Calculates the mean between two values\n * @param {number} a\n * @param {number} b\n * @return {number}\n */\nexport function mean(a, b) {\n return (a + b) / 2;\n}\n\n/**\n * @private\n * Returns a list of tuples that contains the i-th element of each array.\n * @param {Array} a\n * @param {Array} b\n * @return {Array} list of tuples.\n */\nexport function zip(a, b) {\n if (a.length !== b.length) {\n throw new TypeError(\n `Error on zip: the size of a: ${a.length} is different from b: ${b.length}`,\n );\n }\n\n let ret = new Array(a.length);\n for (let i = 0; i < a.length; ++i) {\n ret[i] = [a[i], b[i]];\n }\n\n return ret;\n}\n","import Matrix from 'ml-matrix';\nimport mean from 'ml-array-mean';\n\nimport * as Utils from './utils';\n\nconst gainFunctions = {\n gini: Utils.giniGain,\n regression: Utils.regressionError,\n};\n\nconst splitFunctions = {\n mean: Utils.mean,\n};\n\nexport default class TreeNode {\n /**\n * @private\n * Constructor for a tree node given the options received on the main classes (DecisionTreeClassifier, DecisionTreeRegression)\n * @param {object|TreeNode} options for loading\n * @constructor\n */\n constructor(options) {\n // options parameters\n this.kind = options.kind;\n this.gainFunction = options.gainFunction;\n this.splitFunction = options.splitFunction;\n this.minNumSamples = options.minNumSamples;\n this.maxDepth = options.maxDepth;\n }\n\n /**\n * @private\n * Function that retrieve the best feature to make the split.\n * @param {Matrix} XTranspose - Training set transposed\n * @param {Array} y - labels or values (depending of the decision tree)\n * @return {object} - return tree values, the best gain, column and the split value.\n */\n bestSplit(XTranspose, y) {\n // Depending in the node tree class, we set the variables to check information gain (to classify)\n // or error (for regression)\n\n let bestGain = this.kind === 'classifier' ? -Infinity : Infinity;\n let check = this.kind === 'classifier' ? (a, b) => a > b : (a, b) => a < b;\n\n let maxColumn;\n let maxValue;\n\n for (let i = 0; i < XTranspose.rows; ++i) {\n let currentFeature = XTranspose.getRow(i);\n let splitValues = this.featureSplit(currentFeature, y);\n for (let j = 0; j < splitValues.length; ++j) {\n let currentSplitVal = splitValues[j];\n let splitted = this.split(currentFeature, y, currentSplitVal);\n\n let gain = gainFunctions[this.gainFunction](y, splitted);\n if (check(gain, bestGain)) {\n maxColumn = i;\n maxValue = currentSplitVal;\n bestGain = gain;\n }\n }\n }\n\n return {\n maxGain: bestGain,\n maxColumn: maxColumn,\n maxValue: maxValue,\n };\n }\n\n /**\n * @private\n * Makes the split of the training labels or values from the training set feature given a split value.\n * @param {Array} x - Training set feature\n * @param {Array} y - Training set value or label\n * @param {number} splitValue\n * @return {object}\n */\n split(x, y, splitValue) {\n let lesser = [];\n let greater = [];\n\n for (let i = 0; i < x.length; ++i) {\n if (x[i] < splitValue) {\n lesser.push(y[i]);\n } else {\n greater.push(y[i]);\n }\n }\n\n return {\n greater: greater,\n lesser: lesser,\n };\n }\n\n /**\n * @private\n * Calculates the possible points to split over the tree given a training set feature and corresponding labels or values.\n * @param {Array} x - Training set feature\n * @param {Array} y - Training set value or label\n * @return {Array} possible split values.\n */\n featureSplit(x, y) {\n let splitValues = [];\n let arr = Utils.zip(x, y);\n arr.sort(function(a, b) {\n return a[0] - b[0];\n });\n\n for (let i = 1; i < arr.length; ++i) {\n if (arr[i - 1][1] !== arr[i][1]) {\n splitValues.push(\n splitFunctions[this.splitFunction](arr[i - 1][0], arr[i][0]),\n );\n }\n }\n\n return splitValues;\n }\n\n /**\n * @private\n * Calculate the predictions of a leaf tree node given the training labels or values\n * @param {Array} y\n */\n calculatePrediction(y) {\n if (this.kind === 'classifier') {\n this.distribution = Utils.toDiscreteDistribution(\n y,\n Utils.getNumberOfClasses(y),\n );\n if (this.distribution.columns === 0) {\n throw new TypeError('Error on calculate the prediction');\n }\n } else {\n this.distribution = mean(y);\n }\n }\n\n /**\n * @private\n * Train a node given the training set and labels, because it trains recursively, it also receive\n * the current depth of the node, parent gain to avoid infinite recursion and boolean value to check if\n * the training set is transposed.\n * @param {Matrix} X - Training set (could be transposed or not given transposed).\n * @param {Array} y - Training labels or values.\n * @param {number} currentDepth - Current depth of the node.\n * @param {number} parentGain - parent node gain or error.\n */\n train(X, y, currentDepth, parentGain) {\n if (X.rows <= this.minNumSamples) {\n this.calculatePrediction(y);\n return;\n }\n if (parentGain === undefined) parentGain = 0.0;\n\n let XTranspose = X.transpose();\n let split = this.bestSplit(XTranspose, y);\n\n this.splitValue = split.maxValue;\n this.splitColumn = split.maxColumn;\n this.gain = split.maxGain;\n\n let splittedMatrix = Utils.matrixSplitter(\n X,\n y,\n this.splitColumn,\n this.splitValue,\n );\n\n if (\n currentDepth < this.maxDepth &&\n (this.gain > 0.01 && this.gain !== parentGain) &&\n (splittedMatrix.lesserX.length > 0 && splittedMatrix.greaterX.length > 0)\n ) {\n this.left = new TreeNode(this);\n this.right = new TreeNode(this);\n\n let lesserX = new Matrix(splittedMatrix.lesserX);\n let greaterX = new Matrix(splittedMatrix.greaterX);\n\n this.left.train(\n lesserX,\n splittedMatrix.lesserY,\n currentDepth + 1,\n this.gain,\n );\n this.right.train(\n greaterX,\n splittedMatrix.greaterY,\n currentDepth + 1,\n this.gain,\n );\n } else {\n this.calculatePrediction(y);\n }\n }\n\n /**\n * @private\n * Calculates the prediction of a given element.\n * @param {Array} row\n * @return {number|Array} prediction\n * * if a node is a classifier returns an array of probabilities of each class.\n * * if a node is for regression returns a number with the prediction.\n */\n classify(row) {\n if (this.right && this.left) {\n if (row[this.splitColumn] < this.splitValue) {\n return this.left.classify(row);\n } else {\n return this.right.classify(row);\n }\n }\n\n return this.distribution;\n }\n\n /**\n * @private\n * Set the parameter of the current node and their children.\n * @param {object} node - parameters of the current node and the children.\n */\n setNodeParameters(node) {\n if (node.distribution !== undefined) {\n this.distribution =\n node.distribution.constructor === Array\n ? new Matrix(node.distribution)\n : node.distribution;\n } else {\n this.distribution = undefined;\n this.splitValue = node.splitValue;\n this.splitColumn = node.splitColumn;\n this.gain = node.gain;\n\n this.left = new TreeNode(this);\n this.right = new TreeNode(this);\n\n if (node.left !== {}) {\n this.left.setNodeParameters(node.left);\n }\n if (node.right !== {}) {\n this.right.setNodeParameters(node.right);\n }\n }\n }\n}\n","import Matrix from 'ml-matrix';\n\nimport Tree from './TreeNode';\n\nconst defaultOptions = {\n gainFunction: 'gini',\n splitFunction: 'mean',\n minNumSamples: 3,\n maxDepth: Infinity,\n};\n\nexport class DecisionTreeClassifier {\n /**\n * Create new Decision Tree Classifier with CART implementation with the given options\n * @param {object} options\n * @param {string} [options.gainFunction=\"gini\"] - gain function to get the best split, \"gini\" the only one supported.\n * @param {string} [options.splitFunction=\"mean\"] - given two integers from a split feature, get the value to split, \"mean\" the only one supported.\n * @param {number} [options.minNumSamples=3] - minimum number of samples to create a leaf node to decide a class.\n * @param {number} [options.maxDepth=Infinity] - Max depth of the tree.\n * @param {object} model - for load purposes.\n * @constructor\n */\n constructor(options, model) {\n if (options === true) {\n this.options = model.options;\n this.root = new Tree(model.options);\n this.root.setNodeParameters(model.root);\n } else {\n this.options = Object.assign({}, defaultOptions, options);\n this.options.kind = 'classifier';\n }\n }\n\n /**\n * Train the decision tree with the given training set and labels.\n * @param {Matrix|MatrixTransposeView|Array} trainingSet\n * @param {Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n this.root = new Tree(this.options);\n trainingSet = Matrix.checkMatrix(trainingSet);\n this.root.train(trainingSet, trainingLabels, 0, null);\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|MatrixTransposeView|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n toPredict = Matrix.checkMatrix(toPredict);\n let predictions = new Array(toPredict.rows);\n\n for (let i = 0; i < toPredict.rows; ++i) {\n predictions[i] = this.root\n .classify(toPredict.getRow(i))\n .maxRowIndex(0)[1];\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n options: this.options,\n root: this.root,\n name: 'DTClassifier',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {DecisionTreeClassifier}\n */\n static load(model) {\n if (model.name !== 'DTClassifier') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new DecisionTreeClassifier(true, model);\n }\n}\n","import Matrix from 'ml-matrix';\n\nimport Tree from './TreeNode';\n\nconst defaultOptions = {\n gainFunction: 'regression',\n splitFunction: 'mean',\n minNumSamples: 3,\n maxDepth: Infinity,\n};\n\nexport class DecisionTreeRegression {\n /**\n * Create new Decision Tree Regression with CART implementation with the given options.\n * @param {object} options\n * @param {string} [options.gainFunction=\"regression\"] - gain function to get the best split, \"regression\" the only one supported.\n * @param {string} [options.splitFunction=\"mean\"] - given two integers from a split feature, get the value to split, \"mean\" the only one supported.\n * @param {number} [options.minNumSamples=3] - minimum number of samples to create a leaf node to decide a class.\n * @param {number} [options.maxDepth=Infinity] - Max depth of the tree.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.options = model.options;\n this.root = new Tree(model.options);\n this.root.setNodeParameters(model.root);\n } else {\n this.options = Object.assign({}, defaultOptions, options);\n this.options.kind = 'regression';\n }\n }\n\n /**\n * Train the decision tree with the given training set and values.\n * @param {Matrix|MatrixTransposeView|Array} trainingSet\n * @param {Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n this.root = new Tree(this.options);\n\n if (\n typeof trainingSet[0] !== 'undefined' &&\n trainingSet[0].length === undefined\n ) {\n trainingSet = Matrix.columnVector(trainingSet);\n } else {\n trainingSet = Matrix.checkMatrix(trainingSet);\n }\n this.root.train(trainingSet, trainingValues, 0);\n }\n\n /**\n * Predicts the values given the matrix to predict.\n * @param {Matrix|MatrixTransposeView|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n if (\n typeof toPredict[0] !== 'undefined' &&\n toPredict[0].length === undefined\n ) {\n toPredict = Matrix.columnVector(toPredict);\n }\n toPredict = Matrix.checkMatrix(toPredict);\n\n let predictions = new Array(toPredict.rows);\n for (let i = 0; i < toPredict.rows; ++i) {\n predictions[i] = this.root.classify(toPredict.getRow(i));\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n options: this.options,\n root: this.root,\n name: 'DTRegression',\n };\n }\n\n /**\n * Load a Decision tree regression with the given model.\n * @param {object} model\n * @return {DecisionTreeRegression}\n */\n static load(model) {\n if (model.name !== 'DTRegression') {\n throw new RangeError(`Invalid model:${model.name}`);\n }\n\n return new DecisionTreeRegression(true, model);\n }\n}\n","const SMALLEST_UNSAFE_INTEGER = 0x20000000000000;\r\nconst LARGEST_SAFE_INTEGER = SMALLEST_UNSAFE_INTEGER - 1;\r\nconst UINT32_MAX = -1 >>> 0;\r\nconst UINT32_SIZE = UINT32_MAX + 1;\r\nconst INT32_SIZE = UINT32_SIZE / 2;\r\nconst INT32_MAX = INT32_SIZE - 1;\r\nconst UINT21_SIZE = 1 << 21;\r\nconst UINT21_MAX = UINT21_SIZE - 1;\n\n/**\r\n * Returns a value within [-0x80000000, 0x7fffffff]\r\n */\r\nfunction int32(engine) {\r\n return engine.next() | 0;\r\n}\n\nfunction add(distribution, addend) {\r\n if (addend === 0) {\r\n return distribution;\r\n }\r\n else {\r\n return engine => distribution(engine) + addend;\r\n }\r\n}\n\n/**\r\n * Returns a value within [-0x20000000000000, 0x1fffffffffffff]\r\n */\r\nfunction int53(engine) {\r\n const high = engine.next() | 0;\r\n const low = engine.next() >>> 0;\r\n return ((high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0));\r\n}\n\n/**\r\n * Returns a value within [-0x20000000000000, 0x20000000000000]\r\n */\r\nfunction int53Full(engine) {\r\n while (true) {\r\n const high = engine.next() | 0;\r\n if (high & 0x400000) {\r\n if ((high & 0x7fffff) === 0x400000 && (engine.next() | 0) === 0) {\r\n return SMALLEST_UNSAFE_INTEGER;\r\n }\r\n }\r\n else {\r\n const low = engine.next() >>> 0;\r\n return ((high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0));\r\n }\r\n }\r\n}\n\n/**\r\n * Returns a value within [0, 0xffffffff]\r\n */\r\nfunction uint32(engine) {\r\n return engine.next() >>> 0;\r\n}\n\n/**\r\n * Returns a value within [0, 0x1fffffffffffff]\r\n */\r\nfunction uint53(engine) {\r\n const high = engine.next() & UINT21_MAX;\r\n const low = engine.next() >>> 0;\r\n return high * UINT32_SIZE + low;\r\n}\n\n/**\r\n * Returns a value within [0, 0x20000000000000]\r\n */\r\nfunction uint53Full(engine) {\r\n while (true) {\r\n const high = engine.next() | 0;\r\n if (high & UINT21_SIZE) {\r\n if ((high & UINT21_MAX) === 0 && (engine.next() | 0) === 0) {\r\n return SMALLEST_UNSAFE_INTEGER;\r\n }\r\n }\r\n else {\r\n const low = engine.next() >>> 0;\r\n return (high & UINT21_MAX) * UINT32_SIZE + low;\r\n }\r\n }\r\n}\n\nfunction isPowerOfTwoMinusOne(value) {\r\n return ((value + 1) & value) === 0;\r\n}\r\nfunction bitmask(masking) {\r\n return (engine) => engine.next() & masking;\r\n}\r\nfunction downscaleToLoopCheckedRange(range) {\r\n const extendedRange = range + 1;\r\n const maximum = extendedRange * Math.floor(UINT32_SIZE / extendedRange);\r\n return engine => {\r\n let value = 0;\r\n do {\r\n value = engine.next() >>> 0;\r\n } while (value >= maximum);\r\n return value % extendedRange;\r\n };\r\n}\r\nfunction downscaleToRange(range) {\r\n if (isPowerOfTwoMinusOne(range)) {\r\n return bitmask(range);\r\n }\r\n else {\r\n return downscaleToLoopCheckedRange(range);\r\n }\r\n}\r\nfunction isEvenlyDivisibleByMaxInt32(value) {\r\n return (value | 0) === 0;\r\n}\r\nfunction upscaleWithHighMasking(masking) {\r\n return engine => {\r\n const high = engine.next() & masking;\r\n const low = engine.next() >>> 0;\r\n return high * UINT32_SIZE + low;\r\n };\r\n}\r\nfunction upscaleToLoopCheckedRange(extendedRange) {\r\n const maximum = extendedRange * Math.floor(SMALLEST_UNSAFE_INTEGER / extendedRange);\r\n return engine => {\r\n let ret = 0;\r\n do {\r\n const high = engine.next() & UINT21_MAX;\r\n const low = engine.next() >>> 0;\r\n ret = high * UINT32_SIZE + low;\r\n } while (ret >= maximum);\r\n return ret % extendedRange;\r\n };\r\n}\r\nfunction upscaleWithinU53(range) {\r\n const extendedRange = range + 1;\r\n if (isEvenlyDivisibleByMaxInt32(extendedRange)) {\r\n const highRange = ((extendedRange / UINT32_SIZE) | 0) - 1;\r\n if (isPowerOfTwoMinusOne(highRange)) {\r\n return upscaleWithHighMasking(highRange);\r\n }\r\n }\r\n return upscaleToLoopCheckedRange(extendedRange);\r\n}\r\nfunction upscaleWithinI53AndLoopCheck(min, max) {\r\n return engine => {\r\n let ret = 0;\r\n do {\r\n const high = engine.next() | 0;\r\n const low = engine.next() >>> 0;\r\n ret =\r\n (high & UINT21_MAX) * UINT32_SIZE +\r\n low +\r\n (high & UINT21_SIZE ? -SMALLEST_UNSAFE_INTEGER : 0);\r\n } while (ret < min || ret > max);\r\n return ret;\r\n };\r\n}\r\n/**\r\n * Returns a Distribution to return a value within [min, max]\r\n * @param min The minimum integer value, inclusive. No less than -0x20000000000000.\r\n * @param max The maximum integer value, inclusive. No greater than 0x20000000000000.\r\n */\r\nfunction integer(min, max) {\r\n min = Math.floor(min);\r\n max = Math.floor(max);\r\n if (min < -SMALLEST_UNSAFE_INTEGER || !isFinite(min)) {\r\n throw new RangeError(`Expected min to be at least ${-SMALLEST_UNSAFE_INTEGER}`);\r\n }\r\n else if (max > SMALLEST_UNSAFE_INTEGER || !isFinite(max)) {\r\n throw new RangeError(`Expected max to be at most ${SMALLEST_UNSAFE_INTEGER}`);\r\n }\r\n const range = max - min;\r\n if (range <= 0 || !isFinite(range)) {\r\n return () => min;\r\n }\r\n else if (range === UINT32_MAX) {\r\n if (min === 0) {\r\n return uint32;\r\n }\r\n else {\r\n return add(int32, min + INT32_SIZE);\r\n }\r\n }\r\n else if (range < UINT32_MAX) {\r\n return add(downscaleToRange(range), min);\r\n }\r\n else if (range === LARGEST_SAFE_INTEGER) {\r\n return add(uint53, min);\r\n }\r\n else if (range < LARGEST_SAFE_INTEGER) {\r\n return add(upscaleWithinU53(range), min);\r\n }\r\n else if (max - 1 - min === LARGEST_SAFE_INTEGER) {\r\n return add(uint53Full, min);\r\n }\r\n else if (min === -SMALLEST_UNSAFE_INTEGER &&\r\n max === SMALLEST_UNSAFE_INTEGER) {\r\n return int53Full;\r\n }\r\n else if (min === -SMALLEST_UNSAFE_INTEGER && max === LARGEST_SAFE_INTEGER) {\r\n return int53;\r\n }\r\n else if (min === -LARGEST_SAFE_INTEGER && max === SMALLEST_UNSAFE_INTEGER) {\r\n return add(int53, 1);\r\n }\r\n else if (max === SMALLEST_UNSAFE_INTEGER) {\r\n return add(upscaleWithinI53AndLoopCheck(min - 1, max - 1), 1);\r\n }\r\n else {\r\n return upscaleWithinI53AndLoopCheck(min, max);\r\n }\r\n}\n\nfunction isLeastBitTrue(engine) {\r\n return (engine.next() & 1) === 1;\r\n}\r\nfunction lessThan(distribution, value) {\r\n return engine => distribution(engine) < value;\r\n}\r\nfunction probability(percentage) {\r\n if (percentage <= 0) {\r\n return () => false;\r\n }\r\n else if (percentage >= 1) {\r\n return () => true;\r\n }\r\n else {\r\n const scaled = percentage * UINT32_SIZE;\r\n if (scaled % 1 === 0) {\r\n return lessThan(int32, (scaled - INT32_SIZE) | 0);\r\n }\r\n else {\r\n return lessThan(uint53, Math.round(percentage * SMALLEST_UNSAFE_INTEGER));\r\n }\r\n }\r\n}\r\nfunction bool(numerator, denominator) {\r\n if (denominator == null) {\r\n if (numerator == null) {\r\n return isLeastBitTrue;\r\n }\r\n return probability(numerator);\r\n }\r\n else {\r\n if (numerator <= 0) {\r\n return () => false;\r\n }\r\n else if (numerator >= denominator) {\r\n return () => true;\r\n }\r\n return lessThan(integer(0, denominator - 1), numerator);\r\n }\r\n}\n\n/**\r\n * Returns a Distribution that returns a random `Date` within the inclusive\r\n * range of [`start`, `end`].\r\n * @param start The minimum `Date`\r\n * @param end The maximum `Date`\r\n */\r\nfunction date(start, end) {\r\n const distribution = integer(+start, +end);\r\n return engine => new Date(distribution(engine));\r\n}\n\n/**\r\n * Returns a Distribution to return a value within [1, sideCount]\r\n * @param sideCount The number of sides of the die\r\n */\r\nfunction die(sideCount) {\r\n return integer(1, sideCount);\r\n}\n\n/**\r\n * Returns a distribution that returns an array of length `dieCount` of values\r\n * within [1, `sideCount`]\r\n * @param sideCount The number of sides of each die\r\n * @param dieCount The number of dice\r\n */\r\nfunction dice(sideCount, dieCount) {\r\n const distribution = die(sideCount);\r\n return engine => {\r\n const result = [];\r\n for (let i = 0; i < dieCount; ++i) {\r\n result.push(distribution(engine));\r\n }\r\n return result;\r\n };\r\n}\n\n// tslint:disable:unified-signatures\r\n// has 2**x chars, for faster uniform distribution\r\nconst DEFAULT_STRING_POOL = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-\";\r\nfunction string(pool = DEFAULT_STRING_POOL) {\r\n const poolLength = pool.length;\r\n if (!poolLength) {\r\n throw new Error(\"Expected pool not to be an empty string\");\r\n }\r\n const distribution = integer(0, poolLength - 1);\r\n return (engine, length) => {\r\n let result = \"\";\r\n for (let i = 0; i < length; ++i) {\r\n const j = distribution(engine);\r\n result += pool.charAt(j);\r\n }\r\n return result;\r\n };\r\n}\n\nconst LOWER_HEX_POOL = \"0123456789abcdef\";\r\nconst lowerHex = string(LOWER_HEX_POOL);\r\nconst upperHex = string(LOWER_HEX_POOL.toUpperCase());\r\n/**\r\n * Returns a Distribution that returns a random string comprised of numbers\r\n * or the characters `abcdef` (or `ABCDEF`) of length `length`.\r\n * @param length Length of the result string\r\n * @param uppercase Whether the string should use `ABCDEF` instead of `abcdef`\r\n */\r\nfunction hex(uppercase) {\r\n if (uppercase) {\r\n return upperHex;\r\n }\r\n else {\r\n return lowerHex;\r\n }\r\n}\n\nfunction convertSliceArgument(value, length) {\r\n if (value < 0) {\r\n return Math.max(value + length, 0);\r\n }\r\n else {\r\n return Math.min(value, length);\r\n }\r\n}\n\nfunction toInteger(value) {\r\n const num = +value;\r\n if (num < 0) {\r\n return Math.ceil(num);\r\n }\r\n else {\r\n return Math.floor(num);\r\n }\r\n}\n\n/**\r\n * Returns a random value within the provided `source` within the sliced\r\n * bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\nfunction pick(engine, source, begin, end) {\r\n const length = source.length;\r\n if (length === 0) {\r\n throw new RangeError(\"Cannot pick from an empty array\");\r\n }\r\n const start = begin == null ? 0 : convertSliceArgument(toInteger(begin), length);\r\n const finish = end === void 0 ? length : convertSliceArgument(toInteger(end), length);\r\n if (start >= finish) {\r\n throw new RangeError(`Cannot pick between bounds ${start} and ${finish}`);\r\n }\r\n const distribution = integer(start, finish - 1);\r\n return source[distribution(engine)];\r\n}\n\nfunction multiply(distribution, multiplier) {\r\n if (multiplier === 1) {\r\n return distribution;\r\n }\r\n else if (multiplier === 0) {\r\n return () => 0;\r\n }\r\n else {\r\n return engine => distribution(engine) * multiplier;\r\n }\r\n}\n\n/**\r\n * Returns a floating-point value within [0.0, 1.0)\r\n */\r\nfunction realZeroToOneExclusive(engine) {\r\n return uint53(engine) / SMALLEST_UNSAFE_INTEGER;\r\n}\n\n/**\r\n * Returns a floating-point value within [0.0, 1.0]\r\n */\r\nfunction realZeroToOneInclusive(engine) {\r\n return uint53Full(engine) / SMALLEST_UNSAFE_INTEGER;\r\n}\n\n/**\r\n * Returns a floating-point value within [min, max) or [min, max]\r\n * @param min The minimum floating-point value, inclusive.\r\n * @param max The maximum floating-point value.\r\n * @param inclusive If true, `max` will be inclusive.\r\n */\r\nfunction real(min, max, inclusive = false) {\r\n if (!isFinite(min)) {\r\n throw new RangeError(\"Expected min to be a finite number\");\r\n }\r\n else if (!isFinite(max)) {\r\n throw new RangeError(\"Expected max to be a finite number\");\r\n }\r\n return add(multiply(inclusive ? realZeroToOneInclusive : realZeroToOneExclusive, max - min), min);\r\n}\n\nconst sliceArray = Array.prototype.slice;\n\n/**\r\n * Shuffles an array in-place\r\n * @param engine The Engine to use when choosing random values\r\n * @param array The array to shuffle\r\n * @param downTo minimum index to shuffle. Only used internally.\r\n */\r\nfunction shuffle(engine, array, downTo = 0) {\r\n const length = array.length;\r\n if (length) {\r\n for (let i = (length - 1) >>> 0; i > downTo; --i) {\r\n const distribution = integer(0, i);\r\n const j = distribution(engine);\r\n if (i !== j) {\r\n const tmp = array[i];\r\n array[i] = array[j];\r\n array[j] = tmp;\r\n }\r\n }\r\n }\r\n return array;\r\n}\n\n/**\r\n * From the population array, produce an array with sampleSize elements that\r\n * are randomly chosen without repeats.\r\n * @param engine The Engine to use when choosing random values\r\n * @param population An array that has items to choose a sample from\r\n * @param sampleSize The size of the result array\r\n */\r\nfunction sample(engine, population, sampleSize) {\r\n if (sampleSize < 0 ||\r\n sampleSize > population.length ||\r\n !isFinite(sampleSize)) {\r\n throw new RangeError(\"Expected sampleSize to be within 0 and the length of the population\");\r\n }\r\n if (sampleSize === 0) {\r\n return [];\r\n }\r\n const clone = sliceArray.call(population);\r\n const length = clone.length;\r\n if (length === sampleSize) {\r\n return shuffle(engine, clone, 0);\r\n }\r\n const tailLength = length - sampleSize;\r\n return shuffle(engine, clone, tailLength - 1).slice(tailLength);\r\n}\n\nconst stringRepeat = (() => {\r\n try {\r\n if (\"x\".repeat(3) === \"xxx\") {\r\n return (pattern, count) => pattern.repeat(count);\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n return (pattern, count) => {\r\n let result = \"\";\r\n while (count > 0) {\r\n if (count & 1) {\r\n result += pattern;\r\n }\r\n count >>= 1;\r\n pattern += pattern;\r\n }\r\n return result;\r\n };\r\n})();\n\nfunction zeroPad(text, zeroCount) {\r\n return stringRepeat(\"0\", zeroCount - text.length) + text;\r\n}\r\n/**\r\n * Returns a Universally Unique Identifier Version 4.\r\n *\r\n * See http://en.wikipedia.org/wiki/Universally_unique_identifier\r\n */\r\nfunction uuid4(engine) {\r\n const a = engine.next() >>> 0;\r\n const b = engine.next() | 0;\r\n const c = engine.next() | 0;\r\n const d = engine.next() >>> 0;\r\n return (zeroPad(a.toString(16), 8) +\r\n \"-\" +\r\n zeroPad((b & 0xffff).toString(16), 4) +\r\n \"-\" +\r\n zeroPad((((b >> 4) & 0x0fff) | 0x4000).toString(16), 4) +\r\n \"-\" +\r\n zeroPad(((c & 0x3fff) | 0x8000).toString(16), 4) +\r\n \"-\" +\r\n zeroPad(((c >> 4) & 0xffff).toString(16), 4) +\r\n zeroPad(d.toString(16), 8));\r\n}\n\n/**\r\n * An int32-producing Engine that uses `Math.random()`\r\n */\r\nconst nativeMath = {\r\n next() {\r\n return (Math.random() * UINT32_SIZE) | 0;\r\n }\r\n};\n\n// tslint:disable:unified-signatures\r\n/**\r\n * A wrapper around an Engine that provides easy-to-use methods for\r\n * producing values based on known distributions\r\n */\r\nclass Random {\r\n /**\r\n * Creates a new Random wrapper\r\n * @param engine The engine to use (defaults to a `Math.random`-based implementation)\r\n */\r\n constructor(engine = nativeMath) {\r\n this.engine = engine;\r\n }\r\n /**\r\n * Returns a value within [-0x80000000, 0x7fffffff]\r\n */\r\n int32() {\r\n return int32(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0xffffffff]\r\n */\r\n uint32() {\r\n return uint32(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0x1fffffffffffff]\r\n */\r\n uint53() {\r\n return uint53(this.engine);\r\n }\r\n /**\r\n * Returns a value within [0, 0x20000000000000]\r\n */\r\n uint53Full() {\r\n return uint53Full(this.engine);\r\n }\r\n /**\r\n * Returns a value within [-0x20000000000000, 0x1fffffffffffff]\r\n */\r\n int53() {\r\n return int53(this.engine);\r\n }\r\n /**\r\n * Returns a value within [-0x20000000000000, 0x20000000000000]\r\n */\r\n int53Full() {\r\n return int53Full(this.engine);\r\n }\r\n /**\r\n * Returns a value within [min, max]\r\n * @param min The minimum integer value, inclusive. No less than -0x20000000000000.\r\n * @param max The maximum integer value, inclusive. No greater than 0x20000000000000.\r\n */\r\n integer(min, max) {\r\n return integer(min, max)(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [0.0, 1.0]\r\n */\r\n realZeroToOneInclusive() {\r\n return realZeroToOneInclusive(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [0.0, 1.0)\r\n */\r\n realZeroToOneExclusive() {\r\n return realZeroToOneExclusive(this.engine);\r\n }\r\n /**\r\n * Returns a floating-point value within [min, max) or [min, max]\r\n * @param min The minimum floating-point value, inclusive.\r\n * @param max The maximum floating-point value.\r\n * @param inclusive If true, `max` will be inclusive.\r\n */\r\n real(min, max, inclusive = false) {\r\n return real(min, max, inclusive)(this.engine);\r\n }\r\n bool(numerator, denominator) {\r\n return bool(numerator, denominator)(this.engine);\r\n }\r\n /**\r\n * Return a random value within the provided `source` within the sliced\r\n * bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\n pick(source, begin, end) {\r\n return pick(this.engine, source, begin, end);\r\n }\r\n /**\r\n * Shuffles an array in-place\r\n * @param array The array to shuffle\r\n */\r\n shuffle(array) {\r\n return shuffle(this.engine, array);\r\n }\r\n /**\r\n * From the population array, returns an array with sampleSize elements that\r\n * are randomly chosen without repeats.\r\n * @param population An array that has items to choose a sample from\r\n * @param sampleSize The size of the result array\r\n */\r\n sample(population, sampleSize) {\r\n return sample(this.engine, population, sampleSize);\r\n }\r\n /**\r\n * Returns a value within [1, sideCount]\r\n * @param sideCount The number of sides of the die\r\n */\r\n die(sideCount) {\r\n return die(sideCount)(this.engine);\r\n }\r\n /**\r\n * Returns an array of length `dieCount` of values within [1, sideCount]\r\n * @param sideCount The number of sides of each die\r\n * @param dieCount The number of dice\r\n */\r\n dice(sideCount, dieCount) {\r\n return dice(sideCount, dieCount)(this.engine);\r\n }\r\n /**\r\n * Returns a Universally Unique Identifier Version 4.\r\n *\r\n * See http://en.wikipedia.org/wiki/Universally_unique_identifier\r\n */\r\n uuid4() {\r\n return uuid4(this.engine);\r\n }\r\n string(length, pool) {\r\n return string(pool)(this.engine, length);\r\n }\r\n /**\r\n * Returns a random string comprised of numbers or the characters `abcdef`\r\n * (or `ABCDEF`) of length `length`.\r\n * @param length Length of the result string\r\n * @param uppercase Whether the string should use `ABCDEF` instead of `abcdef`\r\n */\r\n hex(length, uppercase) {\r\n return hex(uppercase)(this.engine, length);\r\n }\r\n /**\r\n * Returns a random `Date` within the inclusive range of [`start`, `end`].\r\n * @param start The minimum `Date`\r\n * @param end The maximum `Date`\r\n */\r\n date(start, end) {\r\n return date(start, end)(this.engine);\r\n }\r\n}\n\n/**\r\n * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int32Array\r\n */\r\nconst I32Array = (() => {\r\n try {\r\n const buffer = new ArrayBuffer(4);\r\n const view = new Int32Array(buffer);\r\n view[0] = INT32_SIZE;\r\n if (view[0] === -INT32_SIZE) {\r\n return Int32Array;\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n return Array;\r\n})();\n\nlet data = null;\r\nconst COUNT = 128;\r\nlet index = COUNT;\r\n/**\r\n * An Engine that relies on the globally-available `crypto.getRandomValues`,\r\n * which is typically available in modern browsers.\r\n *\r\n * See https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues\r\n *\r\n * If unavailable or otherwise non-functioning, then `browserCrypto` will\r\n * likely `throw` on the first call to `next()`.\r\n */\r\nconst browserCrypto = {\r\n next() {\r\n if (index >= COUNT) {\r\n if (data === null) {\r\n data = new I32Array(COUNT);\r\n }\r\n crypto.getRandomValues(data);\r\n index = 0;\r\n }\r\n return data[index++] | 0;\r\n }\r\n};\n\n/**\r\n * Returns an array of random int32 values, based on current time\r\n * and a random number engine\r\n *\r\n * @param engine an Engine to pull random values from, default `nativeMath`\r\n * @param length the length of the Array, minimum 1, default 16\r\n */\r\nfunction createEntropy(engine = nativeMath, length = 16) {\r\n const array = [];\r\n array.push(new Date().getTime() | 0);\r\n for (let i = 1; i < length; ++i) {\r\n array[i] = engine.next() | 0;\r\n }\r\n return array;\r\n}\n\n/**\r\n * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul\r\n */\r\nconst imul = (() => {\r\n try {\r\n if (Math.imul(UINT32_MAX, 5) === -5) {\r\n return Math.imul;\r\n }\r\n }\r\n catch (_) {\r\n // nothing to do here\r\n }\r\n const UINT16_MAX = 0xffff;\r\n return (a, b) => {\r\n const ah = (a >>> 16) & UINT16_MAX;\r\n const al = a & UINT16_MAX;\r\n const bh = (b >>> 16) & UINT16_MAX;\r\n const bl = b & UINT16_MAX;\r\n // the shift by 0 fixes the sign on the high part\r\n // the final |0 converts the unsigned value into a signed value\r\n return (al * bl + (((ah * bl + al * bh) << 16) >>> 0)) | 0;\r\n };\r\n})();\n\nconst ARRAY_SIZE = 624;\r\nconst ARRAY_MAX = ARRAY_SIZE - 1;\r\nconst M = 397;\r\nconst ARRAY_SIZE_MINUS_M = ARRAY_SIZE - M;\r\nconst A = 0x9908b0df;\r\n/**\r\n * An Engine that is a pseudorandom number generator using the Mersenne\r\n * Twister algorithm based on the prime 2**19937 − 1\r\n *\r\n * See http://en.wikipedia.org/wiki/Mersenne_twister\r\n */\r\nclass MersenneTwister19937 {\r\n /**\r\n * MersenneTwister19937 should not be instantiated directly.\r\n * Instead, use the static methods `seed`, `seedWithArray`, or `autoSeed`.\r\n */\r\n constructor() {\r\n this.data = new I32Array(ARRAY_SIZE);\r\n this.index = 0; // integer within [0, 624]\r\n this.uses = 0;\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with an initial int32 value\r\n * @param initial the initial seed value\r\n */\r\n static seed(initial) {\r\n return new MersenneTwister19937().seed(initial);\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with zero or more int32 values\r\n * @param source A series of int32 values\r\n */\r\n static seedWithArray(source) {\r\n return new MersenneTwister19937().seedWithArray(source);\r\n }\r\n /**\r\n * Returns a MersenneTwister19937 seeded with the current time and\r\n * a series of natively-generated random values\r\n */\r\n static autoSeed() {\r\n return MersenneTwister19937.seedWithArray(createEntropy());\r\n }\r\n /**\r\n * Returns the next int32 value of the sequence\r\n */\r\n next() {\r\n if ((this.index | 0) >= ARRAY_SIZE) {\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n const value = this.data[this.index];\r\n this.index = (this.index + 1) | 0;\r\n this.uses += 1;\r\n return temper(value) | 0;\r\n }\r\n /**\r\n * Returns the number of times that the Engine has been used.\r\n *\r\n * This can be provided to an unused MersenneTwister19937 with the same\r\n * seed, bringing it to the exact point that was left off.\r\n */\r\n getUseCount() {\r\n return this.uses;\r\n }\r\n /**\r\n * Discards one or more items from the engine\r\n * @param count The count of items to discard\r\n */\r\n discard(count) {\r\n if (count <= 0) {\r\n return this;\r\n }\r\n this.uses += count;\r\n if ((this.index | 0) >= ARRAY_SIZE) {\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n while (count + this.index > ARRAY_SIZE) {\r\n count -= ARRAY_SIZE - this.index;\r\n refreshData(this.data);\r\n this.index = 0;\r\n }\r\n this.index = (this.index + count) | 0;\r\n return this;\r\n }\r\n seed(initial) {\r\n let previous = 0;\r\n this.data[0] = previous = initial | 0;\r\n for (let i = 1; i < ARRAY_SIZE; i = (i + 1) | 0) {\r\n this.data[i] = previous =\r\n (imul(previous ^ (previous >>> 30), 0x6c078965) + i) | 0;\r\n }\r\n this.index = ARRAY_SIZE;\r\n this.uses = 0;\r\n return this;\r\n }\r\n seedWithArray(source) {\r\n this.seed(0x012bd6aa);\r\n seedWithArray(this.data, source);\r\n return this;\r\n }\r\n}\r\nfunction refreshData(data) {\r\n let k = 0;\r\n let tmp = 0;\r\n for (; (k | 0) < ARRAY_SIZE_MINUS_M; k = (k + 1) | 0) {\r\n tmp = (data[k] & INT32_SIZE) | (data[(k + 1) | 0] & INT32_MAX);\r\n data[k] = data[(k + M) | 0] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n }\r\n for (; (k | 0) < ARRAY_MAX; k = (k + 1) | 0) {\r\n tmp = (data[k] & INT32_SIZE) | (data[(k + 1) | 0] & INT32_MAX);\r\n data[k] =\r\n data[(k - ARRAY_SIZE_MINUS_M) | 0] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n }\r\n tmp = (data[ARRAY_MAX] & INT32_SIZE) | (data[0] & INT32_MAX);\r\n data[ARRAY_MAX] = data[M - 1] ^ (tmp >>> 1) ^ (tmp & 0x1 ? A : 0);\r\n}\r\nfunction temper(value) {\r\n value ^= value >>> 11;\r\n value ^= (value << 7) & 0x9d2c5680;\r\n value ^= (value << 15) & 0xefc60000;\r\n return value ^ (value >>> 18);\r\n}\r\nfunction seedWithArray(data, source) {\r\n let i = 1;\r\n let j = 0;\r\n const sourceLength = source.length;\r\n let k = Math.max(sourceLength, ARRAY_SIZE) | 0;\r\n let previous = data[0] | 0;\r\n for (; (k | 0) > 0; --k) {\r\n data[i] = previous =\r\n ((data[i] ^ imul(previous ^ (previous >>> 30), 0x0019660d)) +\r\n (source[j] | 0) +\r\n (j | 0)) |\r\n 0;\r\n i = (i + 1) | 0;\r\n ++j;\r\n if ((i | 0) > ARRAY_MAX) {\r\n data[0] = data[ARRAY_MAX];\r\n i = 1;\r\n }\r\n if (j >= sourceLength) {\r\n j = 0;\r\n }\r\n }\r\n for (k = ARRAY_MAX; (k | 0) > 0; --k) {\r\n data[i] = previous =\r\n ((data[i] ^ imul(previous ^ (previous >>> 30), 0x5d588b65)) - i) | 0;\r\n i = (i + 1) | 0;\r\n if ((i | 0) > ARRAY_MAX) {\r\n data[0] = data[ARRAY_MAX];\r\n i = 1;\r\n }\r\n }\r\n data[0] = INT32_SIZE;\r\n}\n\nlet data$1 = null;\r\nconst COUNT$1 = 128;\r\nlet index$1 = COUNT$1;\r\n/**\r\n * An Engine that relies on the node-available\r\n * `require('crypto').randomBytes`, which has been available since 0.58.\r\n *\r\n * See https://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback\r\n *\r\n * If unavailable or otherwise non-functioning, then `nodeCrypto` will\r\n * likely `throw` on the first call to `next()`.\r\n */\r\nconst nodeCrypto = {\r\n next() {\r\n if (index$1 >= COUNT$1) {\r\n data$1 = new Int32Array(new Int8Array(require(\"crypto\").randomBytes(4 * COUNT$1)).buffer);\r\n index$1 = 0;\r\n }\r\n return data$1[index$1++] | 0;\r\n }\r\n};\n\n/**\r\n * Returns a Distribution to random value within the provided `source`\r\n * within the sliced bounds of `begin` and `end`.\r\n * @param source an array of items to pick from\r\n * @param begin the beginning slice index (defaults to `0`)\r\n * @param end the ending slice index (defaults to `source.length`)\r\n */\r\nfunction picker(source, begin, end) {\r\n const clone = sliceArray.call(source, begin, end);\r\n if (clone.length === 0) {\r\n throw new RangeError(`Cannot pick from a source with no items`);\r\n }\r\n const distribution = integer(0, clone.length - 1);\r\n return engine => clone[distribution(engine)];\r\n}\n\nexport { Random, browserCrypto, nativeMath, MersenneTwister19937, nodeCrypto, bool, date, dice, die, hex, int32, int53, int53Full, integer, pick, picker, real, realZeroToOneExclusive, realZeroToOneInclusive, sample, shuffle, string, uint32, uint53, uint53Full, uuid4, createEntropy };\n//# sourceMappingURL=random-js.esm.js.map\n","import * as Random from 'random-js';\nimport Matrix from 'ml-matrix';\n\nexport function checkFloat(n) {\n return n > 0.0 && n <= 1.0;\n}\n\n/**\n * Select n with replacement elements on the training set and values, where n is the size of the training set.\n * @ignore\n * @param {Matrix} trainingSet\n * @param {Array} trainingValue\n * @param {number} seed - seed for the random selection, must be a 32-bit integer.\n * @return {object} with new X and y.\n */\nexport function examplesBaggingWithReplacement(\n trainingSet,\n trainingValue,\n seed,\n) {\n let engine;\n let distribution = Random.integer(0, trainingSet.rows - 1);\n if (seed === undefined) {\n engine = Random.MersenneTwister19937.autoSeed();\n } else if (Number.isInteger(seed)) {\n engine = Random.MersenneTwister19937.seed(seed);\n } else {\n throw new RangeError(\n `Expected seed must be undefined or integer not ${seed}`,\n );\n }\n\n let Xr = new Array(trainingSet.rows);\n let yr = new Array(trainingSet.rows);\n\n for (let i = 0; i < trainingSet.rows; ++i) {\n let index = distribution(engine);\n Xr[i] = trainingSet.getRow(index);\n yr[i] = trainingValue[index];\n }\n\n return {\n X: new Matrix(Xr),\n y: yr,\n };\n}\n\n/**\n * selects n features from the training set with or without replacement, returns the new training set and the indexes used.\n * @ignore\n * @param {Matrix} trainingSet\n * @param {number} n - features.\n * @param {boolean} replacement\n * @param {number} seed - seed for the random selection, must be a 32-bit integer.\n * @return {object}\n */\nexport function featureBagging(trainingSet, n, replacement, seed) {\n if (trainingSet.columns < n) {\n throw new RangeError(\n 'N should be less or equal to the number of columns of X',\n );\n }\n\n let distribution = Random.integer(0, trainingSet.columns - 1);\n let engine;\n if (seed === undefined) {\n engine = Random.MersenneTwister19937.autoSeed();\n } else if (Number.isInteger(seed)) {\n engine = Random.MersenneTwister19937.seed(seed);\n } else {\n throw new RangeError(\n `Expected seed must be undefined or integer not ${seed}`,\n );\n }\n\n let toRet = new Matrix(trainingSet.rows, n);\n\n let usedIndex;\n let index;\n if (replacement) {\n usedIndex = new Array(n);\n for (let i = 0; i < n; ++i) {\n index = distribution(engine);\n usedIndex[i] = index;\n toRet.setColumn(i, trainingSet.getColumn(index));\n }\n } else {\n usedIndex = new Set();\n index = distribution(engine);\n for (let i = 0; i < n; ++i) {\n while (usedIndex.has(index)) {\n index = distribution(engine);\n }\n toRet.setColumn(i, trainingSet.getColumn(index));\n usedIndex.add(index);\n }\n usedIndex = Array.from(usedIndex);\n }\n\n return {\n X: toRet,\n usedIndex: usedIndex,\n };\n}\n","import {\n DecisionTreeClassifier as DTClassifier,\n DecisionTreeRegression as DTRegression,\n} from 'ml-cart';\nimport {\n Matrix,\n WrapperMatrix2D,\n MatrixTransposeView,\n MatrixColumnSelectionView,\n} from 'ml-matrix';\n\nimport * as Utils from './utils';\n\n/**\n * @class RandomForestBase\n */\nexport class RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number|String} [options.maxFeatures] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement] - use replacement over the sample features.\n * @param {number} [options.seed] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators] - number of estimator to use.\n * @param {object} [options.treeOptions] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {boolean} [options.isClassifier] - boolean to check if is a classifier or regression model (used by subclasses).\n * @param {boolean} [options.useSampleBagging] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.replacement = model.replacement;\n this.maxFeatures = model.maxFeatures;\n this.nEstimators = model.nEstimators;\n this.treeOptions = model.treeOptions;\n this.isClassifier = model.isClassifier;\n this.seed = model.seed;\n this.n = model.n;\n this.indexes = model.indexes;\n this.useSampleBagging = model.useSampleBagging;\n\n let Estimator = this.isClassifier ? DTClassifier : DTRegression;\n this.estimators = model.estimators.map((est) => Estimator.load(est));\n } else {\n this.replacement = options.replacement;\n this.maxFeatures = options.maxFeatures;\n this.nEstimators = options.nEstimators;\n this.treeOptions = options.treeOptions;\n this.isClassifier = options.isClassifier;\n this.seed = options.seed;\n this.useSampleBagging = options.useSampleBagging;\n }\n }\n\n /**\n * Train the decision tree with the given training set and labels.\n * @param {Matrix|Array} trainingSet\n * @param {Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n this.maxFeatures = this.maxFeatures || trainingSet.columns;\n\n if (Utils.checkFloat(this.maxFeatures)) {\n this.n = Math.floor(trainingSet.columns * this.maxFeatures);\n } else if (Number.isInteger(this.maxFeatures)) {\n if (this.maxFeatures > trainingSet.columns) {\n throw new RangeError(\n `The maxFeatures parameter should be less than ${trainingSet.columns}`,\n );\n } else {\n this.n = this.maxFeatures;\n }\n } else {\n throw new RangeError(\n `Cannot process the maxFeatures parameter ${this.maxFeatures}`,\n );\n }\n\n let Estimator;\n if (this.isClassifier) {\n Estimator = DTClassifier;\n } else {\n Estimator = DTRegression;\n }\n\n this.estimators = new Array(this.nEstimators);\n this.indexes = new Array(this.nEstimators);\n\n for (let i = 0; i < this.nEstimators; ++i) {\n let res = this.useSampleBagging\n ? Utils.examplesBaggingWithReplacement(\n trainingSet,\n trainingValues,\n this.seed,\n )\n : { X: trainingSet, y: trainingValues };\n let X = res.X;\n let y = res.y;\n\n res = Utils.featureBagging(X, this.n, this.replacement, this.seed);\n X = res.X;\n\n this.indexes[i] = res.usedIndex;\n this.estimators[i] = new Estimator(this.treeOptions);\n this.estimators[i].train(X, y);\n }\n }\n\n /**\n * Method that returns the way the algorithm generates the predictions, for example, in classification\n * you can return the mode of all predictions retrieved by the trees, or in case of regression you can\n * use the mean or the median.\n * @abstract\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction.\n */\n // eslint-disable-next-line no-unused-vars\n selection(values) {\n throw new Error(\"Abstract method 'selection' not implemented!\");\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|Array} toPredict\n * @return {Array} predictions\n */\n predict(toPredict) {\n let predictionValues = new Array(this.nEstimators);\n toPredict = Matrix.checkMatrix(toPredict);\n for (let i = 0; i < this.nEstimators; ++i) {\n let X = new MatrixColumnSelectionView(toPredict, this.indexes[i]); // get features for estimator\n predictionValues[i] = this.estimators[i].predict(X);\n }\n\n predictionValues = new MatrixTransposeView(\n new WrapperMatrix2D(predictionValues),\n );\n let predictions = new Array(predictionValues.rows);\n for (let i = 0; i < predictionValues.rows; ++i) {\n predictions[i] = this.selection(predictionValues.getRow(i));\n }\n\n return predictions;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n indexes: this.indexes,\n n: this.n,\n replacement: this.replacement,\n maxFeatures: this.maxFeatures,\n nEstimators: this.nEstimators,\n treeOptions: this.treeOptions,\n isClassifier: this.isClassifier,\n seed: this.seed,\n estimators: this.estimators.map((est) => est.toJSON()),\n useSampleBagging: this.useSampleBagging,\n };\n }\n}\n","import { RandomForestBase } from './RandomForestBase';\n\nconst defaultOptions = {\n maxFeatures: 1.0,\n replacement: true,\n nEstimators: 10,\n seed: 42,\n useSampleBagging: false,\n};\n\n/**\n * @class RandomForestClassifier\n * @augments RandomForestBase\n */\nexport class RandomForestClassifier extends RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number} [options.maxFeatures=1.0] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement=true] - use replacement over the sample features.\n * @param {number} [options.seed=42] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators=10] - number of estimator to use.\n * @param {object} [options.treeOptions={}] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {boolean} [options.useSampleBagging=false] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n super(true, model.baseModel);\n } else {\n options = Object.assign({}, defaultOptions, options);\n options.isClassifier = true;\n super(options);\n }\n }\n\n /**\n * retrieve the prediction given the selection method.\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction\n */\n selection(values) {\n return mode(values);\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n let baseModel = super.toJSON();\n return {\n baseModel: baseModel,\n name: 'RFClassifier',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {RandomForestClassifier}\n */\n static load(model) {\n if (model.name !== 'RFClassifier') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new RandomForestClassifier(true, model);\n }\n}\n\n/**\n * Return the most repeated element on the array.\n * @param {Array} arr\n * @return {number} mode\n */\nfunction mode(arr) {\n return arr\n .sort(\n (a, b) =>\n arr.filter((v) => v === a).length - arr.filter((v) => v === b).length,\n )\n .pop();\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","(function(){function a(d){for(var e=0,f=d.length-1,g=void 0,h=void 0,i=void 0,j=c(e,f);!0;){if(f<=e)return d[j];if(f==e+1)return d[e]>d[f]&&b(d,e,f),d[j];for(g=c(e,f),d[g]>d[f]&&b(d,g,f),d[e]>d[f]&&b(d,e,f),d[g]>d[e]&&b(d,g,e),b(d,g,e+1),h=e+1,i=f;!0;){do h++;while(d[e]>d[h]);do i--;while(d[i]>d[e]);if(i=j&&(f=i-1)}}var b=function b(d,e,f){var _ref;return _ref=[d[f],d[e]],d[e]=_ref[0],d[f]=_ref[1],_ref},c=function c(d,e){return~~((d+e)/2)};'undefined'!=typeof module&&module.exports?module.exports=a:window.median=a})();\n","import isArray from 'is-any-array';\nimport quickSelectMedian from 'median-quickselect';\n\nfunction median(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n return quickSelectMedian(input.slice());\n}\n\nexport default median;\n","import arrayMean from 'ml-array-mean';\nimport arrayMedian from 'ml-array-median';\n\nimport { RandomForestBase } from './RandomForestBase';\n\nconst selectionMethods = {\n mean: arrayMean,\n median: arrayMedian,\n};\n\nconst defaultOptions = {\n maxFeatures: 1.0,\n replacement: false,\n nEstimators: 10,\n treeOptions: {},\n selectionMethod: 'mean',\n seed: 42,\n useSampleBagging: false,\n};\n\n/**\n * @class RandomForestRegression\n * @augments RandomForestBase\n */\nexport class RandomForestRegression extends RandomForestBase {\n /**\n * Create a new base random forest for a classifier or regression model.\n * @constructor\n * @param {object} options\n * @param {number} [options.maxFeatures=1.0] - the number of features used on each estimator.\n * * if is an integer it selects maxFeatures elements over the sample features.\n * * if is a float between (0, 1), it takes the percentage of features.\n * @param {boolean} [options.replacement=true] - use replacement over the sample features.\n * @param {number} [options.seed=42] - seed for feature and samples selection, must be a 32-bit integer.\n * @param {number} [options.nEstimators=10] - number of estimator to use.\n * @param {object} [options.treeOptions={}] - options for the tree classifier, see [ml-cart]{@link https://mljs.github.io/decision-tree-cart/}\n * @param {string} [options.selectionMethod=\"mean\"] - the way to calculate the prediction from estimators, \"mean\" and \"median\" are supported.\n * @param {boolean} [options.useSampleBagging=false] - use bagging over training samples.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n super(true, model.baseModel);\n this.selectionMethod = model.selectionMethod;\n } else {\n options = Object.assign({}, defaultOptions, options);\n\n if (\n !(\n options.selectionMethod === 'mean' ||\n options.selectionMethod === 'median'\n )\n ) {\n throw new RangeError(\n `Unsupported selection method ${options.selectionMethod}`,\n );\n }\n\n options.isClassifier = false;\n\n super(options);\n this.selectionMethod = options.selectionMethod;\n }\n }\n\n /**\n * retrieve the prediction given the selection method.\n * @param {Array} values - predictions of the estimators.\n * @return {number} prediction\n */\n selection(values) {\n return selectionMethods[this.selectionMethod](values);\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n let baseModel = super.toJSON();\n return {\n baseModel: baseModel,\n selectionMethod: this.selectionMethod,\n name: 'RFRegression',\n };\n }\n\n /**\n * Load a Decision tree classifier with the given model.\n * @param {object} model\n * @return {RandomForestRegression}\n */\n static load(model) {\n if (model.name !== 'RFRegression') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n return new RandomForestRegression(true, model);\n }\n}\n","import { Matrix, MatrixTransposeView, EVD, SVD, NIPALS } from 'ml-matrix';\n\n/**\n * Creates new PCA (Principal Component Analysis) from the dataset\n * @param {Matrix} dataset - dataset or covariance matrix.\n * @param {Object} [options]\n * @param {boolean} [options.isCovarianceMatrix=false] - true if the dataset is a covariance matrix.\n * @param {string} [options.method='SVD'] - select which method to use: SVD (default), covarianceMatrirx or NIPALS.\n * @param {number} [options.nCompNIPALS=2] - number of components to be computed with NIPALS.\n * @param {boolean} [options.center=true] - should the data be centered (subtract the mean).\n * @param {boolean} [options.scale=false] - should the data be scaled (divide by the standard deviation).\n * @param {boolean} [options.ignoreZeroVariance=false] - ignore columns with zero variance if `scale` is `true`.\n * */\nexport class PCA {\n constructor(dataset, options = {}) {\n if (dataset === true) {\n const model = options;\n this.center = model.center;\n this.scale = model.scale;\n this.means = model.means;\n this.stdevs = model.stdevs;\n this.U = Matrix.checkMatrix(model.U);\n this.S = model.S;\n this.R = model.R;\n this.excludedFeatures = model.excludedFeatures || [];\n return;\n }\n\n dataset = new Matrix(dataset);\n\n const {\n isCovarianceMatrix = false,\n method = 'SVD',\n nCompNIPALS = 2,\n center = true,\n scale = false,\n ignoreZeroVariance = false,\n } = options;\n\n this.center = center;\n this.scale = scale;\n this.means = null;\n this.stdevs = null;\n this.excludedFeatures = [];\n\n if (isCovarianceMatrix) {\n // User provided a covariance matrix instead of dataset.\n this._computeFromCovarianceMatrix(dataset);\n return;\n }\n\n this._adjust(dataset, ignoreZeroVariance);\n switch (method) {\n case 'covarianceMatrix': {\n // User provided a dataset but wants us to compute and use the covariance matrix.\n const covarianceMatrix = new MatrixTransposeView(dataset)\n .mmul(dataset)\n .div(dataset.rows - 1);\n this._computeFromCovarianceMatrix(covarianceMatrix);\n break;\n }\n case 'NIPALS': {\n this._computeWithNIPALS(dataset, nCompNIPALS);\n break;\n }\n case 'SVD': {\n const svd = new SVD(dataset, {\n computeLeftSingularVectors: false,\n computeRightSingularVectors: true,\n autoTranspose: true,\n });\n\n this.U = svd.rightSingularVectors;\n\n const singularValues = svd.diagonal;\n const eigenvalues = [];\n for (const singularValue of singularValues) {\n eigenvalues.push((singularValue * singularValue) / (dataset.rows - 1));\n }\n this.S = eigenvalues;\n break;\n }\n default: {\n throw new Error(`unknown method: ${method}`);\n }\n }\n }\n\n /**\n * Load a PCA model from JSON\n * @param {Object} model\n * @return {PCA}\n */\n static load(model) {\n if (typeof model.name !== 'string') {\n throw new TypeError('model must have a name property');\n }\n if (model.name !== 'PCA') {\n throw new RangeError(`invalid model: ${model.name}`);\n }\n return new PCA(true, model);\n }\n\n /**\n * Project the dataset into the PCA space\n * @param {Matrix} dataset\n * @param {Object} options\n * @return {Matrix} dataset projected in the PCA space\n */\n predict(dataset, options = {}) {\n const { nComponents = this.U.columns } = options;\n dataset = new Matrix(dataset);\n if (this.center) {\n dataset.subRowVector(this.means);\n if (this.scale) {\n for (let i of this.excludedFeatures) {\n dataset.removeColumn(i);\n }\n dataset.divRowVector(this.stdevs);\n }\n }\n var predictions = dataset.mmul(this.U);\n return predictions.subMatrix(0, predictions.rows - 1, 0, nComponents - 1);\n }\n\n /**\n * Calculates the inverse PCA transform\n * @param {Matrix} dataset\n * @return {Matrix} dataset projected in the PCA space\n */\n invert(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n\n var inverse = dataset.mmul(this.U.transpose());\n\n if (this.center) {\n if (this.scale) {\n inverse.mulRowVector(this.stdevs);\n }\n inverse.addRowVector(this.means);\n }\n\n return inverse;\n }\n\n\n /**\n * Returns the proportion of variance for each component\n * @return {[number]}\n */\n getExplainedVariance() {\n var sum = 0;\n for (const s of this.S) {\n sum += s;\n }\n return this.S.map((value) => value / sum);\n }\n\n /**\n * Returns the cumulative proportion of variance\n * @return {[number]}\n */\n getCumulativeVariance() {\n var explained = this.getExplainedVariance();\n for (var i = 1; i < explained.length; i++) {\n explained[i] += explained[i - 1];\n }\n return explained;\n }\n\n /**\n * Returns the Eigenvectors of the covariance matrix\n * @returns {Matrix}\n */\n getEigenvectors() {\n return this.U;\n }\n\n /**\n * Returns the Eigenvalues (on the diagonal)\n * @returns {[number]}\n */\n getEigenvalues() {\n return this.S;\n }\n\n /**\n * Returns the standard deviations of the principal components\n * @returns {[number]}\n */\n getStandardDeviations() {\n return this.S.map((x) => Math.sqrt(x));\n }\n\n /**\n * Returns the loadings matrix\n * @return {Matrix}\n */\n getLoadings() {\n return this.U.transpose();\n }\n\n /**\n * Export the current model to a JSON object\n * @return {Object} model\n */\n toJSON() {\n return {\n name: 'PCA',\n center: this.center,\n scale: this.scale,\n means: this.means,\n stdevs: this.stdevs,\n U: this.U,\n S: this.S,\n excludedFeatures: this.excludedFeatures,\n };\n }\n\n _adjust(dataset, ignoreZeroVariance) {\n if (this.center) {\n const mean = dataset.mean('column');\n const stdevs = this.scale\n ? dataset.standardDeviation('column', { mean })\n : null;\n this.means = mean;\n dataset.subRowVector(mean);\n if (this.scale) {\n for (let i = 0; i < stdevs.length; i++) {\n if (stdevs[i] === 0) {\n if (ignoreZeroVariance) {\n dataset.removeColumn(i);\n stdevs.splice(i, 1);\n this.excludedFeatures.push(i);\n i--;\n } else {\n throw new RangeError(\n `Cannot scale the dataset (standard deviation is zero at index ${i}`,\n );\n }\n }\n }\n this.stdevs = stdevs;\n dataset.divRowVector(stdevs);\n }\n }\n }\n\n _computeFromCovarianceMatrix(dataset) {\n const evd = new EVD(dataset, { assumeSymmetric: true });\n this.U = evd.eigenvectorMatrix;\n this.U.flipRows();\n this.S = evd.realEigenvalues;\n this.S.reverse();\n }\n\n _computeWithNIPALS(dataset, nCompNIPALS) {\n this.U = new Matrix(nCompNIPALS, dataset.columns);\n this.S = [];\n\n let x = dataset;\n for (let i = 0; i < nCompNIPALS; i++) {\n let dc = new NIPALS(x);\n\n this.U.setRow(i, dc.w.transpose());\n this.S.push(Math.pow(dc.s.get(0, 0), 2));\n\n x = dc.xResidual;\n }\n this.U = this.U.transpose(); // to be compatible with API\n }\n}\n","export function squaredEuclidean(p, q) {\r\n let d = 0;\r\n for (let i = 0; i < p.length; i++) {\r\n d += (p[i] - q[i]) * (p[i] - q[i]);\r\n }\r\n return d;\r\n}\r\nexport function euclidean(p, q) {\r\n return Math.sqrt(squaredEuclidean(p, q));\r\n}\r\n","/**\n * Computes a distance/similarity matrix given an array of data and a distance/similarity function.\n * @param {Array} data An array of data\n * @param {function} distanceFn A function that accepts two arguments and computes a distance/similarity between them\n * @return {Array} The distance/similarity matrix. The matrix is square and has a size equal to the length of\n * the data array\n */\nexport default function distanceMatrix(data, distanceFn) {\n const result = getMatrix(data.length);\n\n // Compute upper distance matrix\n for (let i = 0; i < data.length; i++) {\n for (let j = 0; j <= i; j++) {\n result[i][j] = distanceFn(data[i], data[j]);\n result[j][i] = result[i][j];\n }\n }\n\n return result;\n}\n\nfunction getMatrix(size) {\n const matrix = [];\n for (let i = 0; i < size; i++) {\n const row = [];\n matrix.push(row);\n for (let j = 0; j < size; j++) {\n row.push(0);\n }\n }\n return matrix;\n}\n","// Generated by CoffeeScript 1.8.0\n(function() {\n var Heap, defaultCmp, floor, heapify, heappop, heappush, heappushpop, heapreplace, insort, min, nlargest, nsmallest, updateItem, _siftdown, _siftup;\n\n floor = Math.floor, min = Math.min;\n\n\n /*\n Default comparison function to be used\n */\n\n defaultCmp = function(x, y) {\n if (x < y) {\n return -1;\n }\n if (x > y) {\n return 1;\n }\n return 0;\n };\n\n\n /*\n Insert item x in list a, and keep it sorted assuming a is sorted.\n \n If x is already in a, insert it to the right of the rightmost x.\n \n Optional args lo (default 0) and hi (default a.length) bound the slice\n of a to be searched.\n */\n\n insort = function(a, x, lo, hi, cmp) {\n var mid;\n if (lo == null) {\n lo = 0;\n }\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (lo < 0) {\n throw new Error('lo must be non-negative');\n }\n if (hi == null) {\n hi = a.length;\n }\n while (lo < hi) {\n mid = floor((lo + hi) / 2);\n if (cmp(x, a[mid]) < 0) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n return ([].splice.apply(a, [lo, lo - lo].concat(x)), x);\n };\n\n\n /*\n Push item onto heap, maintaining the heap invariant.\n */\n\n heappush = function(array, item, cmp) {\n if (cmp == null) {\n cmp = defaultCmp;\n }\n array.push(item);\n return _siftdown(array, 0, array.length - 1, cmp);\n };\n\n\n /*\n Pop the smallest item off the heap, maintaining the heap invariant.\n */\n\n heappop = function(array, cmp) {\n var lastelt, returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n lastelt = array.pop();\n if (array.length) {\n returnitem = array[0];\n array[0] = lastelt;\n _siftup(array, 0, cmp);\n } else {\n returnitem = lastelt;\n }\n return returnitem;\n };\n\n\n /*\n Pop and return the current smallest value, and add the new item.\n \n This is more efficient than heappop() followed by heappush(), and can be\n more appropriate when using a fixed size heap. Note that the value\n returned may be larger than item! That constrains reasonable use of\n this routine unless written as part of a conditional replacement:\n if item > array[0]\n item = heapreplace(array, item)\n */\n\n heapreplace = function(array, item, cmp) {\n var returnitem;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n returnitem = array[0];\n array[0] = item;\n _siftup(array, 0, cmp);\n return returnitem;\n };\n\n\n /*\n Fast version of a heappush followed by a heappop.\n */\n\n heappushpop = function(array, item, cmp) {\n var _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (array.length && cmp(array[0], item) < 0) {\n _ref = [array[0], item], item = _ref[0], array[0] = _ref[1];\n _siftup(array, 0, cmp);\n }\n return item;\n };\n\n\n /*\n Transform list into a heap, in-place, in O(array.length) time.\n */\n\n heapify = function(array, cmp) {\n var i, _i, _j, _len, _ref, _ref1, _results, _results1;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n _ref1 = (function() {\n _results1 = [];\n for (var _j = 0, _ref = floor(array.length / 2); 0 <= _ref ? _j < _ref : _j > _ref; 0 <= _ref ? _j++ : _j--){ _results1.push(_j); }\n return _results1;\n }).apply(this).reverse();\n _results = [];\n for (_i = 0, _len = _ref1.length; _i < _len; _i++) {\n i = _ref1[_i];\n _results.push(_siftup(array, i, cmp));\n }\n return _results;\n };\n\n\n /*\n Update the position of the given item in the heap.\n This function should be called every time the item is being modified.\n */\n\n updateItem = function(array, item, cmp) {\n var pos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n pos = array.indexOf(item);\n if (pos === -1) {\n return;\n }\n _siftdown(array, 0, pos, cmp);\n return _siftup(array, pos, cmp);\n };\n\n\n /*\n Find the n largest elements in a dataset.\n */\n\n nlargest = function(array, n, cmp) {\n var elem, result, _i, _len, _ref;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n result = array.slice(0, n);\n if (!result.length) {\n return result;\n }\n heapify(result, cmp);\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n heappushpop(result, elem, cmp);\n }\n return result.sort(cmp).reverse();\n };\n\n\n /*\n Find the n smallest elements in a dataset.\n */\n\n nsmallest = function(array, n, cmp) {\n var elem, i, los, result, _i, _j, _len, _ref, _ref1, _results;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n if (n * 10 <= array.length) {\n result = array.slice(0, n).sort(cmp);\n if (!result.length) {\n return result;\n }\n los = result[result.length - 1];\n _ref = array.slice(n);\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n elem = _ref[_i];\n if (cmp(elem, los) < 0) {\n insort(result, elem, 0, null, cmp);\n result.pop();\n los = result[result.length - 1];\n }\n }\n return result;\n }\n heapify(array, cmp);\n _results = [];\n for (i = _j = 0, _ref1 = min(n, array.length); 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) {\n _results.push(heappop(array, cmp));\n }\n return _results;\n };\n\n _siftdown = function(array, startpos, pos, cmp) {\n var newitem, parent, parentpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n newitem = array[pos];\n while (pos > startpos) {\n parentpos = (pos - 1) >> 1;\n parent = array[parentpos];\n if (cmp(newitem, parent) < 0) {\n array[pos] = parent;\n pos = parentpos;\n continue;\n }\n break;\n }\n return array[pos] = newitem;\n };\n\n _siftup = function(array, pos, cmp) {\n var childpos, endpos, newitem, rightpos, startpos;\n if (cmp == null) {\n cmp = defaultCmp;\n }\n endpos = array.length;\n startpos = pos;\n newitem = array[pos];\n childpos = 2 * pos + 1;\n while (childpos < endpos) {\n rightpos = childpos + 1;\n if (rightpos < endpos && !(cmp(array[childpos], array[rightpos]) < 0)) {\n childpos = rightpos;\n }\n array[pos] = array[childpos];\n pos = childpos;\n childpos = 2 * pos + 1;\n }\n array[pos] = newitem;\n return _siftdown(array, startpos, pos, cmp);\n };\n\n Heap = (function() {\n Heap.push = heappush;\n\n Heap.pop = heappop;\n\n Heap.replace = heapreplace;\n\n Heap.pushpop = heappushpop;\n\n Heap.heapify = heapify;\n\n Heap.updateItem = updateItem;\n\n Heap.nlargest = nlargest;\n\n Heap.nsmallest = nsmallest;\n\n function Heap(cmp) {\n this.cmp = cmp != null ? cmp : defaultCmp;\n this.nodes = [];\n }\n\n Heap.prototype.push = function(x) {\n return heappush(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pop = function() {\n return heappop(this.nodes, this.cmp);\n };\n\n Heap.prototype.peek = function() {\n return this.nodes[0];\n };\n\n Heap.prototype.contains = function(x) {\n return this.nodes.indexOf(x) !== -1;\n };\n\n Heap.prototype.replace = function(x) {\n return heapreplace(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.pushpop = function(x) {\n return heappushpop(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.heapify = function() {\n return heapify(this.nodes, this.cmp);\n };\n\n Heap.prototype.updateItem = function(x) {\n return updateItem(this.nodes, x, this.cmp);\n };\n\n Heap.prototype.clear = function() {\n return this.nodes = [];\n };\n\n Heap.prototype.empty = function() {\n return this.nodes.length === 0;\n };\n\n Heap.prototype.size = function() {\n return this.nodes.length;\n };\n\n Heap.prototype.clone = function() {\n var heap;\n heap = new Heap();\n heap.nodes = this.nodes.slice(0);\n return heap;\n };\n\n Heap.prototype.toArray = function() {\n return this.nodes.slice(0);\n };\n\n Heap.prototype.insert = Heap.prototype.push;\n\n Heap.prototype.top = Heap.prototype.peek;\n\n Heap.prototype.front = Heap.prototype.peek;\n\n Heap.prototype.has = Heap.prototype.contains;\n\n Heap.prototype.copy = Heap.prototype.clone;\n\n return Heap;\n\n })();\n\n (function(root, factory) {\n if (typeof define === 'function' && define.amd) {\n return define([], factory);\n } else if (typeof exports === 'object') {\n return module.exports = factory();\n } else {\n return root.Heap = factory();\n }\n })(this, function() {\n return Heap;\n });\n\n}).call(this);\n","module.exports = require('./lib/heap');\n","import Heap from 'heap';\n\nexport default class Cluster {\n constructor() {\n this.children = [];\n this.height = 0;\n this.size = 1;\n this.index = -1;\n this.isLeaf = false;\n }\n\n /**\n * Creates an array of clusters where the maximum height is smaller than the threshold\n * @param {number} threshold\n * @return {Array}\n */\n cut(threshold) {\n if (typeof threshold !== 'number') {\n throw new TypeError('threshold must be a number');\n }\n if (threshold < 0) {\n throw new RangeError('threshold must be a positive number');\n }\n let list = [this];\n const ans = [];\n while (list.length > 0) {\n const aux = list.shift();\n if (threshold >= aux.height) {\n ans.push(aux);\n } else {\n list = list.concat(aux.children);\n }\n }\n return ans;\n }\n\n /**\n * Merge the leaves in the minimum way to have `groups` number of clusters.\n * @param {number} groups - Them number of children the first level of the tree should have.\n * @return {Cluster}\n */\n group(groups) {\n if (!Number.isInteger(groups) || groups < 1) {\n throw new RangeError('groups must be a positive integer');\n }\n\n const heap = new Heap((a, b) => {\n return b.height - a.height;\n });\n\n heap.push(this);\n\n while (heap.size() < groups) {\n var first = heap.pop();\n if (first.children.length === 0) {\n break;\n }\n first.children.forEach((child) => heap.push(child));\n }\n\n var root = new Cluster();\n root.children = heap.toArray();\n root.height = this.height;\n\n return root;\n }\n\n /**\n * Traverses the tree depth-first and calls the provided callback with each individual node\n * @param {function} cb - The callback to be called on each node encounter\n */\n traverse(cb) {\n function visit(root, callback) {\n callback(root);\n if (root.children) {\n for (const child of root.children) {\n visit(child, callback);\n }\n }\n }\n visit(this, cb);\n }\n\n /**\n * Returns a list of indices for all the leaves of this cluster.\n * The list is ordered in such a way that a dendrogram could be drawn without crossing branches.\n * @returns {Array}\n */\n indices() {\n const result = [];\n this.traverse((cluster) => {\n if (cluster.isLeaf) {\n result.push(cluster.index);\n }\n });\n return result;\n }\n}\n","import { euclidean } from 'ml-distance-euclidean';\nimport getDistanceMatrix from 'ml-distance-matrix';\nimport { Matrix } from 'ml-matrix';\n\nimport Cluster from './Cluster';\n\nfunction singleLink(dKI, dKJ) {\n return Math.min(dKI, dKJ);\n}\n\nfunction completeLink(dKI, dKJ) {\n return Math.max(dKI, dKJ);\n}\n\nfunction averageLink(dKI, dKJ, dIJ, ni, nj) {\n const ai = ni / (ni + nj);\n const aj = nj / (ni + nj);\n return ai * dKI + aj * dKJ;\n}\n\nfunction weightedAverageLink(dKI, dKJ) {\n return (dKI + dKJ) / 2;\n}\n\nfunction centroidLink(dKI, dKJ, dIJ, ni, nj) {\n const ai = ni / (ni + nj);\n const aj = nj / (ni + nj);\n const b = -(ni * nj) / (ni + nj) ** 2;\n return ai * dKI + aj * dKJ + b * dIJ;\n}\n\nfunction medianLink(dKI, dKJ, dIJ) {\n return dKI / 2 + dKJ / 2 - dIJ / 4;\n}\n\nfunction wardLink(dKI, dKJ, dIJ, ni, nj, nk) {\n const ai = (ni + nk) / (ni + nj + nk);\n const aj = (nj + nk) / (ni + nj + nk);\n const b = -nk / (ni + nj + nk);\n return ai * dKI + aj * dKJ + b * dIJ;\n}\n\nfunction wardLink2(dKI, dKJ, dIJ, ni, nj, nk) {\n const ai = (ni + nk) / (ni + nj + nk);\n const aj = (nj + nk) / (ni + nj + nk);\n const b = -nk / (ni + nj + nk);\n return Math.sqrt(ai * dKI * dKI + aj * dKJ * dKJ + b * dIJ * dIJ);\n}\n\n/**\n * Continuously merge nodes that have the least dissimilarity\n * @param {Array>} data - Array of points to be clustered\n * @param {object} [options]\n * @param {Function} [options.distanceFunction]\n * @param {string} [options.method] - Default: `'complete'`\n * @param {boolean} [options.isDistanceMatrix] - Is the input already a distance matrix?\n * @constructor\n */\nexport function agnes(data, options = {}) {\n const {\n distanceFunction = euclidean,\n method = 'complete',\n isDistanceMatrix = false,\n } = options;\n\n let updateFunc;\n if (!isDistanceMatrix) {\n data = getDistanceMatrix(data, distanceFunction);\n }\n let distanceMatrix = new Matrix(data);\n const numLeaves = distanceMatrix.rows;\n\n // allows to use a string or a given function\n if (typeof method === 'string') {\n switch (method.toLowerCase()) {\n case 'single':\n updateFunc = singleLink;\n break;\n case 'complete':\n updateFunc = completeLink;\n break;\n case 'average':\n case 'upgma':\n updateFunc = averageLink;\n break;\n case 'wpgma':\n updateFunc = weightedAverageLink;\n break;\n case 'centroid':\n case 'upgmc':\n updateFunc = centroidLink;\n break;\n case 'median':\n case 'wpgmc':\n updateFunc = medianLink;\n break;\n case 'ward':\n updateFunc = wardLink;\n break;\n case 'ward2':\n updateFunc = wardLink2;\n break;\n default:\n throw new RangeError(`unknown clustering method: ${method}`);\n }\n } else if (typeof method !== 'function') {\n throw new TypeError('method must be a string or function');\n }\n\n let clusters = [];\n for (let i = 0; i < numLeaves; i++) {\n const cluster = new Cluster();\n cluster.isLeaf = true;\n cluster.index = i;\n clusters.push(cluster);\n }\n\n for (let n = 0; n < numLeaves - 1; n++) {\n const [row, column, distance] = getSmallestDistance(distanceMatrix);\n const cluster1 = clusters[row];\n const cluster2 = clusters[column];\n const newCluster = new Cluster();\n newCluster.size = cluster1.size + cluster2.size;\n newCluster.children.push(cluster1, cluster2);\n newCluster.height = distance;\n\n const newClusters = [newCluster];\n const newDistanceMatrix = new Matrix(\n distanceMatrix.rows - 1,\n distanceMatrix.rows - 1,\n );\n const previous = (newIndex) =>\n getPreviousIndex(newIndex, Math.min(row, column), Math.max(row, column));\n\n for (let i = 1; i < newDistanceMatrix.rows; i++) {\n const prevI = previous(i);\n const prevICluster = clusters[prevI];\n newClusters.push(prevICluster);\n for (let j = 0; j < i; j++) {\n if (j === 0) {\n const dKI = distanceMatrix.get(row, prevI);\n const dKJ = distanceMatrix.get(prevI, column);\n const val = updateFunc(\n dKI,\n dKJ,\n distance,\n cluster1.size,\n cluster2.size,\n prevICluster.size,\n );\n newDistanceMatrix.set(i, j, val);\n newDistanceMatrix.set(j, i, val);\n } else {\n // Just copy distance from previous matrix\n const val = distanceMatrix.get(prevI, previous(j));\n newDistanceMatrix.set(i, j, val);\n newDistanceMatrix.set(j, i, val);\n }\n }\n }\n\n clusters = newClusters;\n distanceMatrix = newDistanceMatrix;\n }\n\n return clusters[0];\n}\n\nfunction getSmallestDistance(distance) {\n let smallest = Infinity;\n let smallestI = 0;\n let smallestJ = 0;\n for (let i = 1; i < distance.rows; i++) {\n for (let j = 0; j < i; j++) {\n if (distance.get(i, j) < smallest) {\n smallest = distance.get(i, j);\n smallestI = i;\n smallestJ = j;\n }\n }\n }\n return [smallestI, smallestJ, smallest];\n}\n\nfunction getPreviousIndex(newIndex, prev1, prev2) {\n newIndex -= 1;\n if (newIndex >= prev1) newIndex++;\n if (newIndex >= prev2) newIndex++;\n return newIndex;\n}\n","'use strict';\nimport { squaredEuclidean } from 'ml-distance-euclidean';\nconst defaultOptions = {\n distanceFunction: squaredEuclidean\n};\nexport default function nearestVector(listVectors, vector, options = defaultOptions) {\n const distanceFunction = options.distanceFunction || defaultOptions.distanceFunction;\n const similarityFunction = options.similarityFunction || defaultOptions.similarityFunction;\n let vectorIndex = -1;\n if (typeof similarityFunction === 'function') {\n // maximum similarity\n let maxSim = Number.MIN_VALUE;\n for (let j = 0; j < listVectors.length; j++) {\n const sim = similarityFunction(vector, listVectors[j]);\n if (sim > maxSim) {\n maxSim = sim;\n vectorIndex = j;\n }\n }\n }\n else if (typeof distanceFunction === 'function') {\n // minimum distance\n let minDist = Number.MAX_VALUE;\n for (let i = 0; i < listVectors.length; i++) {\n const dist = distanceFunction(vector, listVectors[i]);\n if (dist < minDist) {\n minDist = dist;\n vectorIndex = i;\n }\n }\n }\n else {\n throw new Error(\"A similarity or distance function it's required\");\n }\n return vectorIndex;\n}\nexport function findNearestVector(vectorList, vector, options = defaultOptions) {\n const index = nearestVector(vectorList, vector, options);\n return vectorList[index];\n}\n","import nearestVector from 'ml-nearest-vector';\n\n/**\n * Calculates the distance matrix for a given array of points\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @param {function} distance - Distance function to use between the points\n * @return {Array>} - matrix with the distance values\n */\nexport function calculateDistanceMatrix(data, distance) {\n var distanceMatrix = new Array(data.length);\n for (var i = 0; i < data.length; ++i) {\n for (var j = i; j < data.length; ++j) {\n if (!distanceMatrix[i]) {\n distanceMatrix[i] = new Array(data.length);\n }\n if (!distanceMatrix[j]) {\n distanceMatrix[j] = new Array(data.length);\n }\n const dist = distance(data[i], data[j]);\n distanceMatrix[i][j] = dist;\n distanceMatrix[j][i] = dist;\n }\n }\n return distanceMatrix;\n}\n\n/**\n * Updates the cluster identifier based in the new data\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @param {Array>} centers - the K centers in format [x,y,z,...]\n * @param {Array } clusterID - the cluster identifier for each data dot\n * @param {function} distance - Distance function to use between the points\n * @return {Array} the cluster identifier for each data dot\n */\nexport function updateClusterID(data, centers, clusterID, distance) {\n for (var i = 0; i < data.length; i++) {\n clusterID[i] = nearestVector(centers, data[i], {\n distanceFunction: distance\n });\n }\n return clusterID;\n}\n\n/**\n * Update the center values based in the new configurations of the clusters\n * @ignore\n * @param {Array>} prevCenters - Centroids from the previous iteration\n * @param {Array >} data - the [x,y,z,...] points to cluster\n * @param {Array } clusterID - the cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @return {Array} he K centers in format [x,y,z,...]\n */\nexport function updateCenters(prevCenters, data, clusterID, K) {\n const nDim = data[0].length;\n\n // copy previous centers\n var centers = new Array(K);\n var centersLen = new Array(K);\n for (var i = 0; i < K; i++) {\n centers[i] = new Array(nDim);\n centersLen[i] = 0;\n for (var j = 0; j < nDim; j++) {\n centers[i][j] = 0;\n }\n }\n\n // add the value for all dimensions of the point\n for (var l = 0; l < data.length; l++) {\n centersLen[clusterID[l]]++;\n for (var dim = 0; dim < nDim; dim++) {\n centers[clusterID[l]][dim] += data[l][dim];\n }\n }\n\n // divides by length\n for (var id = 0; id < K; id++) {\n for (var d = 0; d < nDim; d++) {\n if (centersLen[id]) {\n centers[id][d] /= centersLen[id];\n } else {\n centers[id][d] = prevCenters[id][d];\n }\n }\n }\n return centers;\n}\n\n/**\n * The centers have moved more than the tolerance value?\n * @ignore\n * @param {Array>} centers - the K centers in format [x,y,z,...]\n * @param {Array>} oldCenters - the K old centers in format [x,y,z,...]\n * @param {function} distanceFunction - Distance function to use between the points\n * @param {number} tolerance - Allowed distance for the centroids to move\n * @return {boolean}\n */\nexport function hasConverged(centers, oldCenters, distanceFunction, tolerance) {\n for (var i = 0; i < centers.length; i++) {\n if (distanceFunction(centers[i], oldCenters[i]) > tolerance) {\n return false;\n }\n }\n return true;\n}\n","const LOOP = 8;\nconst FLOAT_MUL = 1 / 16777216;\nconst sh1 = 15;\nconst sh2 = 18;\nconst sh3 = 11;\nfunction multiply_uint32(n, m) {\n n >>>= 0;\n m >>>= 0;\n const nlo = n & 0xffff;\n const nhi = n - nlo;\n return (((nhi * m) >>> 0) + nlo * m) >>> 0;\n}\nexport default class XSadd {\n constructor(seed = Date.now()) {\n this.state = new Uint32Array(4);\n this.init(seed);\n this.random = this.getFloat.bind(this);\n }\n /**\n * Returns a 32-bit integer r (0 <= r < 2^32)\n */\n getUint32() {\n this.nextState();\n return (this.state[3] + this.state[2]) >>> 0;\n }\n /**\n * Returns a floating point number r (0.0 <= r < 1.0)\n */\n getFloat() {\n return (this.getUint32() >>> 8) * FLOAT_MUL;\n }\n init(seed) {\n if (!Number.isInteger(seed)) {\n throw new TypeError('seed must be an integer');\n }\n this.state[0] = seed;\n this.state[1] = 0;\n this.state[2] = 0;\n this.state[3] = 0;\n for (let i = 1; i < LOOP; i++) {\n this.state[i & 3] ^=\n (i +\n multiply_uint32(1812433253, this.state[(i - 1) & 3] ^ ((this.state[(i - 1) & 3] >>> 30) >>> 0))) >>>\n 0;\n }\n this.periodCertification();\n for (let i = 0; i < LOOP; i++) {\n this.nextState();\n }\n }\n periodCertification() {\n if (this.state[0] === 0 &&\n this.state[1] === 0 &&\n this.state[2] === 0 &&\n this.state[3] === 0) {\n this.state[0] = 88; // X\n this.state[1] = 83; // S\n this.state[2] = 65; // A\n this.state[3] = 68; // D\n }\n }\n nextState() {\n let t = this.state[0];\n t ^= t << sh1;\n t ^= t >>> sh2;\n t ^= this.state[3] << sh3;\n this.state[0] = this.state[1];\n this.state[1] = this.state[2];\n this.state[2] = this.state[3];\n this.state[3] = t;\n }\n}\n","const PROB_TOLERANCE = 0.00000001;\nfunction randomChoice(values, options = {}, random = Math.random) {\n const { size = 1, replace = false, probabilities } = options;\n let valuesArr;\n let cumSum;\n if (typeof values === 'number') {\n valuesArr = getArray(values);\n }\n else {\n valuesArr = values.slice();\n }\n if (probabilities) {\n if (!replace) {\n throw new Error('choice with probabilities and no replacement is not implemented');\n }\n // check input is sane\n if (probabilities.length !== valuesArr.length) {\n throw new Error('the length of probabilities option should be equal to the number of choices');\n }\n cumSum = [probabilities[0]];\n for (let i = 1; i < probabilities.length; i++) {\n cumSum[i] = cumSum[i - 1] + probabilities[i];\n }\n if (Math.abs(1 - cumSum[cumSum.length - 1]) > PROB_TOLERANCE) {\n throw new Error(`probabilities should sum to 1, but instead sums to ${cumSum[cumSum.length - 1]}`);\n }\n }\n if (replace === false && size > valuesArr.length) {\n throw new Error('size option is too large');\n }\n const result = [];\n for (let i = 0; i < size; i++) {\n const index = randomIndex(valuesArr.length, random, cumSum);\n result.push(valuesArr[index]);\n if (!replace) {\n valuesArr.splice(index, 1);\n }\n }\n return result;\n}\nfunction getArray(n) {\n const arr = [];\n for (let i = 0; i < n; i++) {\n arr.push(i);\n }\n return arr;\n}\nfunction randomIndex(n, random, cumSum) {\n const rand = random();\n if (!cumSum) {\n return Math.floor(rand * n);\n }\n else {\n let idx = 0;\n while (rand > cumSum[idx]) {\n idx++;\n }\n return idx;\n }\n}\nexport default randomChoice;\n","// tslint:disable-next-line\nimport XSAdd from 'ml-xsadd';\nimport choice from './choice';\n/**\n * @classdesc Random class\n */\nexport default class Random {\n /**\n * @param [seedOrRandom=Math.random] - Control the random number generator used by the Random class instance. Pass a random number generator function with a uniform distribution over the half-open interval [0, 1[. If seed will pass it to ml-xsadd to create a seeded random number generator. If undefined will use Math.random.\n */\n constructor(seedOrRandom = Math.random) {\n if (typeof seedOrRandom === 'number') {\n const xsadd = new XSAdd(seedOrRandom);\n this.randomGenerator = xsadd.random;\n }\n else {\n this.randomGenerator = seedOrRandom;\n }\n }\n choice(values, options) {\n if (typeof values === 'number') {\n return choice(values, options, this.randomGenerator);\n }\n return choice(values, options, this.randomGenerator);\n }\n /**\n * Draw a random number from a uniform distribution on [0,1)\n * @return The random number\n */\n random() {\n return this.randomGenerator();\n }\n /**\n * Draw a random integer from a uniform distribution on [low, high). If only low is specified, the number is drawn on [0, low)\n * @param low - The lower bound of the uniform distribution interval.\n * @param high - The higher bound of the uniform distribution interval.\n */\n randInt(low, high) {\n if (high === undefined) {\n high = low;\n low = 0;\n }\n return low + Math.floor(this.randomGenerator() * (high - low));\n }\n /**\n * Draw several random number from a uniform distribution on [0, 1)\n * @param size - The number of number to draw\n * @return - The list of drawn numbers.\n */\n randomSample(size) {\n const result = [];\n for (let i = 0; i < size; i++) {\n result.push(this.random());\n }\n return result;\n }\n}\n","import Random from 'ml-random';\nimport { squaredEuclidean } from 'ml-distance-euclidean';\nimport { Matrix } from 'ml-matrix';\n\n/**\n * Choose K different random points from the original data\n * @ignore\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - number of clusters\n * @param {number} seed - seed for random number generation\n * @return {Array>} - Initial random points\n */\nexport function random(data, K, seed) {\n const random = new Random(seed);\n return random.choice(data, { size: K });\n}\n\n/**\n * Chooses the most distant points to a first random pick\n * @ignore\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - number of clusters\n * @param {Array>} distanceMatrix - matrix with the distance values\n * @param {number} seed - seed for random number generation\n * @return {Array>} - Initial random points\n */\nexport function mostDistant(data, K, distanceMatrix, seed) {\n const random = new Random(seed);\n var ans = new Array(K);\n // chooses a random point as initial cluster\n ans[0] = Math.floor(random.random() * data.length);\n\n if (K > 1) {\n // chooses the more distant point\n var maxDist = { dist: -1, index: -1 };\n for (var l = 0; l < data.length; ++l) {\n if (distanceMatrix[ans[0]][l] > maxDist.dist) {\n maxDist.dist = distanceMatrix[ans[0]][l];\n maxDist.index = l;\n }\n }\n ans[1] = maxDist.index;\n\n if (K > 2) {\n // chooses the set of points that maximises the min distance\n for (var k = 2; k < K; ++k) {\n var center = { dist: -1, index: -1 };\n for (var m = 0; m < data.length; ++m) {\n // minimum distance to centers\n var minDistCent = { dist: Number.MAX_VALUE, index: -1 };\n for (var n = 0; n < k; ++n) {\n if (\n distanceMatrix[n][m] < minDistCent.dist &&\n ans.indexOf(m) === -1\n ) {\n minDistCent = {\n dist: distanceMatrix[n][m],\n index: m\n };\n }\n }\n\n if (\n minDistCent.dist !== Number.MAX_VALUE &&\n minDistCent.dist > center.dist\n ) {\n center = Object.assign({}, minDistCent);\n }\n }\n\n ans[k] = center.index;\n }\n }\n }\n\n return ans.map((index) => data[index]);\n}\n\n// Implementation inspired from scikit\nexport function kmeanspp(X, K, options = {}) {\n X = new Matrix(X);\n const nSamples = X.rows;\n const random = new Random(options.seed);\n // Set the number of trials\n const centers = [];\n const localTrials = options.localTrials || 2 + Math.floor(Math.log(K));\n\n // Pick the first center at random from the dataset\n const firstCenterIdx = random.randInt(nSamples);\n centers.push(X.getRow(firstCenterIdx));\n\n // Init closest distances\n let closestDistSquared = new Matrix(1, X.rows);\n for (let i = 0; i < X.rows; i++) {\n closestDistSquared.set(0, i, squaredEuclidean(X.getRow(i), centers[0]));\n }\n let cumSumClosestDistSquared = [cumSum(closestDistSquared.getRow(0))];\n const factor = 1 / cumSumClosestDistSquared[0][nSamples - 1];\n let probabilities = Matrix.mul(closestDistSquared, factor);\n\n // Iterate over the remaining centers\n for (let i = 1; i < K; i++) {\n const candidateIdx = random.choice(nSamples, {\n replace: true,\n size: localTrials,\n probabilities: probabilities[0]\n });\n\n const candidates = X.selection(candidateIdx, range(X.columns));\n const distanceToCandidates = euclideanDistances(candidates, X);\n\n let bestCandidate;\n let bestPot;\n let bestDistSquared;\n\n for (let j = 0; j < localTrials; j++) {\n const newDistSquared = Matrix.min(closestDistSquared, [distanceToCandidates.getRow(j)]);\n const newPot = newDistSquared.sum();\n if (bestCandidate === undefined || newPot < bestPot) {\n bestCandidate = candidateIdx[j];\n bestPot = newPot;\n bestDistSquared = newDistSquared;\n }\n }\n centers[i] = X.getRow(bestCandidate);\n closestDistSquared = bestDistSquared;\n cumSumClosestDistSquared = [cumSum(closestDistSquared.getRow(0))];\n probabilities = Matrix.mul(\n closestDistSquared,\n 1 / cumSumClosestDistSquared[0][nSamples - 1]\n );\n }\n return centers;\n}\n\nfunction euclideanDistances(A, B) {\n const result = new Matrix(A.rows, B.rows);\n for (let i = 0; i < A.rows; i++) {\n for (let j = 0; j < B.rows; j++) {\n result.set(i, j, squaredEuclidean(A.getRow(i), B.getRow(j)));\n }\n }\n return result;\n}\n\nfunction range(l) {\n let r = [];\n for (let i = 0; i < l; i++) {\n r.push(i);\n }\n return r;\n}\n\nfunction cumSum(arr) {\n let cumSum = [arr[0]];\n for (let i = 1; i < arr.length; i++) {\n cumSum[i] = cumSum[i - 1] + arr[i];\n }\n return cumSum;\n}\n","import { updateClusterID } from './utils';\n\nconst distanceSymbol = Symbol('distance');\n\nexport default class KMeansResult {\n /**\n * Result of the kmeans algorithm\n * @param {Array} clusters - the cluster identifier for each data dot\n * @param {Array>} centroids - the K centers in format [x,y,z,...], the error and size of the cluster\n * @param {boolean} converged - Converge criteria satisfied\n * @param {number} iterations - Current number of iterations\n * @param {function} distance - (*Private*) Distance function to use between the points\n * @constructor\n */\n constructor(clusters, centroids, converged, iterations, distance) {\n this.clusters = clusters;\n this.centroids = centroids;\n this.converged = converged;\n this.iterations = iterations;\n this[distanceSymbol] = distance;\n }\n\n /**\n * Allows to compute for a new array of points their cluster id\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @return {Array} - cluster id for each point\n */\n nearest(data) {\n const clusterID = new Array(data.length);\n const centroids = this.centroids.map(function (centroid) {\n return centroid.centroid;\n });\n return updateClusterID(data, centroids, clusterID, this[distanceSymbol]);\n }\n\n /**\n * Returns a KMeansResult with the error and size of the cluster\n * @ignore\n * @param {Array>} data - the [x,y,z,...] points to cluster\n * @return {KMeansResult}\n */\n computeInformation(data) {\n var enrichedCentroids = this.centroids.map(function (centroid) {\n return {\n centroid: centroid,\n error: 0,\n size: 0\n };\n });\n\n for (var i = 0; i < data.length; i++) {\n enrichedCentroids[this.clusters[i]].error += this[distanceSymbol](\n data[i],\n this.centroids[this.clusters[i]]\n );\n enrichedCentroids[this.clusters[i]].size++;\n }\n\n for (var j = 0; j < this.centroids.length; j++) {\n if (enrichedCentroids[j].size) {\n enrichedCentroids[j].error /= enrichedCentroids[j].size;\n } else {\n enrichedCentroids[j].error = null;\n }\n }\n\n return new KMeansResult(\n this.clusters,\n enrichedCentroids,\n this.converged,\n this.iterations,\n this[distanceSymbol]\n );\n }\n}\n","import { squaredEuclidean } from 'ml-distance-euclidean';\n\nimport {\n updateClusterID,\n updateCenters,\n hasConverged,\n calculateDistanceMatrix\n} from './utils';\nimport { mostDistant, random, kmeanspp } from './initialization';\nimport KMeansResult from './KMeansResult';\n\nconst defaultOptions = {\n maxIterations: 100,\n tolerance: 1e-6,\n withIterations: false,\n initialization: 'kmeans++',\n distanceFunction: squaredEuclidean\n};\n\n/**\n * Each step operation for kmeans\n * @ignore\n * @param {Array>} centers - K centers in format [x,y,z,...]\n * @param {Array>} data - Points [x,y,z,...] to cluster\n * @param {Array} clusterID - Cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n * @param {number} iterations - Current number of iterations\n * @return {KMeansResult}\n */\nfunction step(centers, data, clusterID, K, options, iterations) {\n clusterID = updateClusterID(\n data,\n centers,\n clusterID,\n options.distanceFunction\n );\n var newCenters = updateCenters(centers, data, clusterID, K);\n var converged = hasConverged(\n newCenters,\n centers,\n options.distanceFunction,\n options.tolerance\n );\n return new KMeansResult(\n clusterID,\n newCenters,\n converged,\n iterations,\n options.distanceFunction\n );\n}\n\n/**\n * Generator version for the algorithm\n * @ignore\n * @param {Array>} centers - K centers in format [x,y,z,...]\n * @param {Array>} data - Points [x,y,z,...] to cluster\n * @param {Array} clusterID - Cluster identifier for each data dot\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n */\nfunction* kmeansGenerator(centers, data, clusterID, K, options) {\n var converged = false;\n var stepNumber = 0;\n var stepResult;\n while (!converged && stepNumber < options.maxIterations) {\n stepResult = step(centers, data, clusterID, K, options, ++stepNumber);\n yield stepResult.computeInformation(data);\n converged = stepResult.converged;\n centers = stepResult.centroids;\n }\n}\n\n/**\n * K-means algorithm\n * @param {Array>} data - Points in the format to cluster [x,y,z,...]\n * @param {number} K - Number of clusters\n * @param {object} [options] - Option object\n * @param {number} [options.maxIterations = 100] - Maximum of iterations allowed\n * @param {number} [options.tolerance = 1e-6] - Error tolerance\n * @param {boolean} [options.withIterations = false] - Store clusters and centroids for each iteration\n * @param {function} [options.distanceFunction = squaredDistance] - Distance function to use between the points\n * @param {number} [options.seed] - Seed for random initialization.\n * @param {string|Array>} [options.initialization = 'kmeans++'] - K centers in format [x,y,z,...] or a method for initialize the data:\n * * You can either specify your custom start centroids, or select one of the following initialization method:\n * * `'kmeans++'` will use the kmeans++ method as described by http://ilpubs.stanford.edu:8090/778/1/2006-13.pdf\n * * `'random'` will choose K random different values.\n * * `'mostDistant'` will choose the more distant points to a first random pick\n * @return {KMeansResult} - Cluster identifier for each data dot and centroids with the following fields:\n * * `'clusters'`: Array of indexes for the clusters.\n * * `'centroids'`: Array with the resulting centroids.\n * * `'iterations'`: Number of iterations that took to converge\n */\nexport default function kmeans(data, K, options) {\n options = Object.assign({}, defaultOptions, options);\n\n if (K <= 0 || K > data.length || !Number.isInteger(K)) {\n throw new Error(\n 'K should be a positive integer smaller than the number of points'\n );\n }\n\n var centers;\n if (Array.isArray(options.initialization)) {\n if (options.initialization.length !== K) {\n throw new Error('The initial centers should have the same length as K');\n } else {\n centers = options.initialization;\n }\n } else {\n switch (options.initialization) {\n case 'kmeans++':\n centers = kmeanspp(data, K, options);\n break;\n case 'random':\n centers = random(data, K, options.seed);\n break;\n case 'mostDistant':\n centers = mostDistant(\n data,\n K,\n calculateDistanceMatrix(data, options.distanceFunction),\n options.seed\n );\n break;\n default:\n throw new Error(\n `Unknown initialization method: \"${options.initialization}\"`\n );\n }\n }\n\n // infinite loop until convergence\n if (options.maxIterations === 0) {\n options.maxIterations = Number.MAX_VALUE;\n }\n\n var clusterID = new Array(data.length);\n if (options.withIterations) {\n return kmeansGenerator(centers, data, clusterID, K, options);\n } else {\n var converged = false;\n var stepNumber = 0;\n var stepResult;\n while (!converged && stepNumber < options.maxIterations) {\n stepResult = step(centers, data, clusterID, K, options, ++stepNumber);\n converged = stepResult.converged;\n centers = stepResult.centroids;\n }\n return stepResult.computeInformation(data);\n }\n}\n","import Matrix from 'ml-matrix';\n\n/**\n * @private\n * Function that retuns an array of matrices of the cases that belong to each class.\n * @param {Matrix} X - dataset\n * @param {Array} y - predictions\n * @return {Array}\n */\nexport function separateClasses(X, y) {\n var features = X.columns;\n\n var classes = 0;\n var totalPerClasses = new Array(10000); // max upperbound of classes\n for (var i = 0; i < y.length; i++) {\n if (totalPerClasses[y[i]] === undefined) {\n totalPerClasses[y[i]] = 0;\n classes++;\n }\n totalPerClasses[y[i]]++;\n }\n var separatedClasses = new Array(classes);\n var currentIndex = new Array(classes);\n for (i = 0; i < classes; ++i) {\n separatedClasses[i] = new Matrix(totalPerClasses[i], features);\n currentIndex[i] = 0;\n }\n for (i = 0; i < X.rows; ++i) {\n separatedClasses[y[i]].setRow(currentIndex[y[i]], X.getRow(i));\n currentIndex[y[i]]++;\n }\n return separatedClasses;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { separateClasses } from './utils';\n\nexport class GaussianNB {\n /**\n * Constructor for the Gaussian Naive Bayes classifier, the parameters here is just for loading purposes.\n * @constructor\n * @param {boolean} reload\n * @param {object} model\n */\n constructor(reload, model) {\n if (reload) {\n this.means = model.means;\n this.calculateProbabilities = model.calculateProbabilities;\n }\n }\n\n /**\n * Function that trains the classifier with a matrix that represents the training set and an array that\n * represents the label of each row in the training set. the labels must be numbers between 0 to n-1 where\n * n represents the number of classes.\n *\n * WARNING: in the case that one class, all the cases in one or more features have the same value, the\n * Naive Bayes classifier will not work well.\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n var C1 = Math.sqrt(2 * Math.PI); // constant to precalculate the squared root\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n if (trainingSet.rows !== trainingLabels.length) {\n throw new RangeError(\n 'the size of the training set and the training labels must be the same.'\n );\n }\n\n var separatedClasses = separateClasses(trainingSet, trainingLabels);\n var calculateProbabilities = new Array(separatedClasses.length);\n this.means = new Array(separatedClasses.length);\n for (var i = 0; i < separatedClasses.length; ++i) {\n var means = separatedClasses[i].mean('column');\n var std = separatedClasses[i].standardDeviation('column', {\n mean: means\n });\n\n var logPriorProbability = Math.log(\n separatedClasses[i].rows / trainingSet.rows\n );\n calculateProbabilities[i] = new Array(means.length + 1);\n\n calculateProbabilities[i][0] = logPriorProbability;\n for (var j = 1; j < means.length + 1; ++j) {\n var currentStd = std[j - 1];\n calculateProbabilities[i][j] = [\n 1 / (C1 * currentStd),\n -2 * currentStd * currentStd\n ];\n }\n\n this.means[i] = means;\n }\n\n this.calculateProbabilities = calculateProbabilities;\n }\n\n /**\n * function that predicts each row of the dataset (must be a matrix).\n *\n * @param {Matrix|Array} dataset\n * @return {Array}\n */\n predict(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n if (dataset.rows === this.calculateProbabilities[0].length) {\n throw new RangeError(\n 'the dataset must have the same features as the training set'\n );\n }\n\n var predictions = new Array(dataset.rows);\n\n for (var i = 0; i < predictions.length; ++i) {\n predictions[i] = getCurrentClass(\n dataset.getRow(i),\n this.means,\n this.calculateProbabilities\n );\n }\n\n return predictions;\n }\n\n /**\n * Function that export the NaiveBayes model.\n * @return {object}\n */\n toJSON() {\n return {\n modelName: 'NaiveBayes',\n means: this.means,\n calculateProbabilities: this.calculateProbabilities\n };\n }\n\n /**\n * Function that create a GaussianNB classifier with the given model.\n * @param {object} model\n * @return {GaussianNB}\n */\n static load(model) {\n if (model.modelName !== 'NaiveBayes') {\n throw new RangeError(\n 'The current model is not a Multinomial Naive Bayes, current model:',\n model.name\n );\n }\n\n return new GaussianNB(true, model);\n }\n}\n\n/**\n * @private\n * Function the retrieves a prediction with one case.\n *\n * @param {Array} currentCase\n * @param {Array} mean - Precalculated means of each class trained\n * @param {Array} classes - Precalculated value of each class (Prior probability and probability function of each feature)\n * @return {number}\n */\nfunction getCurrentClass(currentCase, mean, classes) {\n var maxProbability = 0;\n var predictedClass = -1;\n\n // going through all precalculated values for the classes\n for (var i = 0; i < classes.length; ++i) {\n var currentProbability = classes[i][0]; // initialize with the prior probability\n for (var j = 1; j < classes[0][1].length + 1; ++j) {\n currentProbability += calculateLogProbability(\n currentCase[j - 1],\n mean[i][j - 1],\n classes[i][j][0],\n classes[i][j][1]\n );\n }\n\n currentProbability = Math.exp(currentProbability);\n if (currentProbability > maxProbability) {\n maxProbability = currentProbability;\n predictedClass = i;\n }\n }\n\n return predictedClass;\n}\n\n/**\n * @private\n * function that retrieves the probability of the feature given the class.\n * @param {number} value - value of the feature.\n * @param {number} mean - mean of the feature for the given class.\n * @param {number} C1 - precalculated value of (1 / (sqrt(2*pi) * std)).\n * @param {number} C2 - precalculated value of (2 * std^2) for the denominator of the exponential.\n * @return {number}\n */\nfunction calculateLogProbability(value, mean, C1, C2) {\n value = value - mean;\n return Math.log(C1 * Math.exp((value * value) / C2));\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { separateClasses } from './utils';\n\nexport class MultinomialNB {\n /**\n * Constructor for Multinomial Naive Bayes, the model parameter is for load purposes.\n * @constructor\n * @param {object} model - for load purposes.\n */\n constructor(model) {\n if (model) {\n this.conditionalProbability = Matrix.checkMatrix(\n model.conditionalProbability\n );\n this.priorProbability = Matrix.checkMatrix(model.priorProbability);\n }\n }\n\n /**\n * Train the classifier with the current training set and labels, the labels must be numbers between 0 and n.\n * @param {Matrix|Array} trainingSet\n * @param {Array} trainingLabels\n */\n train(trainingSet, trainingLabels) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n\n if (trainingSet.rows !== trainingLabels.length) {\n throw new RangeError(\n 'the size of the training set and the training labels must be the same.'\n );\n }\n\n var separateClass = separateClasses(trainingSet, trainingLabels);\n\n this.priorProbability = new Matrix(separateClass.length, 1);\n\n for (var i = 0; i < separateClass.length; ++i) {\n this.priorProbability.set(i, 0, Math.log(\n separateClass[i].rows / trainingSet.rows\n ));\n }\n\n var features = trainingSet.columns;\n this.conditionalProbability = new Matrix(separateClass.length, features);\n for (i = 0; i < separateClass.length; ++i) {\n var classValues = Matrix.checkMatrix(separateClass[i]);\n var total = classValues.sum();\n var divisor = total + features;\n this.conditionalProbability.setRow(\n i,\n Matrix.rowVector(classValues\n .sum('column'))\n .add(1)\n .div(divisor)\n .apply(matrixLog)\n );\n }\n }\n\n /**\n * Retrieves the predictions for the dataset with the current model.\n * @param {Matrix|Array} dataset\n * @return {Array} - predictions from the dataset.\n */\n predict(dataset) {\n dataset = Matrix.checkMatrix(dataset);\n var predictions = new Array(dataset.rows);\n for (var i = 0; i < dataset.rows; ++i) {\n var currentElement = dataset.getRowVector(i);\n const v = Matrix.columnVector(this.conditionalProbability\n .clone()\n .mulRowVector(currentElement)\n .sum('row'));\n predictions[i] = v\n .add(this.priorProbability)\n .maxIndex()[0];\n }\n\n return predictions;\n }\n\n /**\n * Function that saves the current model.\n * @return {object} - model in JSON format.\n */\n toJSON() {\n return {\n name: 'MultinomialNB',\n priorProbability: this.priorProbability,\n conditionalProbability: this.conditionalProbability\n };\n }\n\n /**\n * Creates a new MultinomialNB from the given model\n * @param {object} model\n * @return {MultinomialNB}\n */\n static load(model) {\n if (model.name !== 'MultinomialNB') {\n throw new RangeError(`${model.name} is not a Multinomial Naive Bayes`);\n }\n\n return new MultinomialNB(model);\n }\n}\n\nfunction matrixLog(i, j) {\n this.set(i, j, Math.log(this.get(i, j)));\n}\n","/*\n * Original code from:\n *\n * k-d Tree JavaScript - V 1.01\n *\n * https://github.com/ubilabs/kd-tree-javascript\n *\n * @author Mircea Pricop , 2012\n * @author Martin Kleppe , 2012\n * @author Ubilabs http://ubilabs.net, 2012\n * @license MIT License \n */\n\nfunction Node(obj, dimension, parent) {\n this.obj = obj;\n this.left = null;\n this.right = null;\n this.parent = parent;\n this.dimension = dimension;\n}\n\nexport default class KDTree {\n constructor(points, metric) {\n // If points is not an array, assume we're loading a pre-built tree\n if (!Array.isArray(points)) {\n this.dimensions = points.dimensions;\n this.root = points;\n restoreParent(this.root);\n } else {\n this.dimensions = new Array(points[0].length);\n for (var i = 0; i < this.dimensions.length; i++) {\n this.dimensions[i] = i;\n }\n this.root = buildTree(points, 0, null, this.dimensions);\n }\n this.metric = metric;\n }\n\n // Convert to a JSON serializable structure; this just requires removing\n // the `parent` property\n toJSON() {\n const result = toJSONImpl(this.root, true);\n result.dimensions = this.dimensions;\n return result;\n }\n\n nearest(point, maxNodes, maxDistance) {\n const metric = this.metric;\n const dimensions = this.dimensions;\n var i;\n\n const bestNodes = new BinaryHeap(function (e) {\n return -e[1];\n });\n\n function nearestSearch(node) {\n const dimension = dimensions[node.dimension];\n const ownDistance = metric(point, node.obj);\n const linearPoint = {};\n var bestChild, linearDistance, otherChild, i;\n\n function saveNode(node, distance) {\n bestNodes.push([node, distance]);\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop();\n }\n }\n\n for (i = 0; i < dimensions.length; i += 1) {\n if (i === node.dimension) {\n linearPoint[dimensions[i]] = point[dimensions[i]];\n } else {\n linearPoint[dimensions[i]] = node.obj[dimensions[i]];\n }\n }\n\n linearDistance = metric(linearPoint, node.obj);\n\n if (node.right === null && node.left === null) {\n if (bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1]) {\n saveNode(node, ownDistance);\n }\n return;\n }\n\n if (node.right === null) {\n bestChild = node.left;\n } else if (node.left === null) {\n bestChild = node.right;\n } else {\n if (point[dimension] < node.obj[dimension]) {\n bestChild = node.left;\n } else {\n bestChild = node.right;\n }\n }\n\n nearestSearch(bestChild);\n\n if (bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[1]) {\n saveNode(node, ownDistance);\n }\n\n if (\n bestNodes.size() < maxNodes ||\n Math.abs(linearDistance) < bestNodes.peek()[1]\n ) {\n if (bestChild === node.left) {\n otherChild = node.right;\n } else {\n otherChild = node.left;\n }\n if (otherChild !== null) {\n nearestSearch(otherChild);\n }\n }\n }\n\n if (maxDistance) {\n for (i = 0; i < maxNodes; i += 1) {\n bestNodes.push([null, maxDistance]);\n }\n }\n\n if (this.root) {\n nearestSearch(this.root);\n }\n\n const result = [];\n for (i = 0; i < Math.min(maxNodes, bestNodes.content.length); i += 1) {\n if (bestNodes.content[i][0]) {\n result.push([bestNodes.content[i][0].obj, bestNodes.content[i][1]]);\n }\n }\n return result;\n }\n}\n\nfunction toJSONImpl(src) {\n const dest = new Node(src.obj, src.dimension, null);\n if (src.left) dest.left = toJSONImpl(src.left);\n if (src.right) dest.right = toJSONImpl(src.right);\n return dest;\n}\n\nfunction buildTree(points, depth, parent, dimensions) {\n const dim = depth % dimensions.length;\n\n if (points.length === 0) {\n return null;\n }\n if (points.length === 1) {\n return new Node(points[0], dim, parent);\n }\n\n points.sort((a, b) => a[dimensions[dim]] - b[dimensions[dim]]);\n\n const median = Math.floor(points.length / 2);\n const node = new Node(points[median], dim, parent);\n node.left = buildTree(points.slice(0, median), depth + 1, node, dimensions);\n node.right = buildTree(points.slice(median + 1), depth + 1, node, dimensions);\n\n return node;\n}\n\nfunction restoreParent(root) {\n if (root.left) {\n root.left.parent = root;\n restoreParent(root.left);\n }\n\n if (root.right) {\n root.right.parent = root;\n restoreParent(root.right);\n }\n}\n\n// Binary heap implementation from:\n// http://eloquentjavascript.net/appendix2.html\nclass BinaryHeap {\n constructor(scoreFunction) {\n this.content = [];\n this.scoreFunction = scoreFunction;\n }\n\n push(element) {\n // Add the new element to the end of the array.\n this.content.push(element);\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1);\n }\n\n pop() {\n // Store the first element so we can return it later.\n var result = this.content[0];\n // Get the element at the end of the array.\n var end = this.content.pop();\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (this.content.length > 0) {\n this.content[0] = end;\n this.sinkDown(0);\n }\n return result;\n }\n\n peek() {\n return this.content[0];\n }\n\n size() {\n return this.content.length;\n }\n\n bubbleUp(n) {\n // Fetch the element that has to be moved.\n var element = this.content[n];\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1;\n const parent = this.content[parentN];\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[parentN] = element;\n this.content[n] = parent;\n // Update 'n' to continue at the new position.\n n = parentN;\n } else {\n // Found a parent that is less, no need to move it further.\n break;\n }\n }\n }\n\n sinkDown(n) {\n // Look up the target element and its score.\n var length = this.content.length;\n var element = this.content[n];\n var elemScore = this.scoreFunction(element);\n\n while (true) {\n // Compute the indices of the child elements.\n var child2N = (n + 1) * 2;\n var child1N = child2N - 1;\n // This is used to store the new position of the element,\n // if any.\n var swap = null;\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n var child1 = this.content[child1N];\n var child1Score = this.scoreFunction(child1);\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) {\n swap = child1N;\n }\n }\n // Do the same checks for the other child.\n if (child2N < length) {\n var child2 = this.content[child2N];\n var child2Score = this.scoreFunction(child2);\n if (child2Score < (swap === null ? elemScore : child1Score)) {\n swap = child2N;\n }\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[n] = this.content[swap];\n this.content[swap] = element;\n n = swap;\n } else {\n // Otherwise, we are done.\n break;\n }\n }\n }\n}\n","import { euclidean as euclideanDistance } from 'ml-distance-euclidean';\n\nimport KDTree from './KDTree';\n\nexport default class KNN {\n /**\n * @param {Array} dataset\n * @param {Array} labels\n * @param {object} options\n * @param {number} [options.k=numberOfClasses + 1] - Number of neighbors to classify.\n * @param {function} [options.distance=euclideanDistance] - Distance function that takes two parameters.\n */\n constructor(dataset, labels, options = {}) {\n if (dataset === true) {\n const model = labels;\n this.kdTree = new KDTree(model.kdTree, options);\n this.k = model.k;\n this.classes = new Set(model.classes);\n this.isEuclidean = model.isEuclidean;\n return;\n }\n\n const classes = new Set(labels);\n\n const { distance = euclideanDistance, k = classes.size + 1 } = options;\n\n const points = new Array(dataset.length);\n for (var i = 0; i < points.length; ++i) {\n points[i] = dataset[i].slice();\n }\n\n for (i = 0; i < labels.length; ++i) {\n points[i].push(labels[i]);\n }\n\n this.kdTree = new KDTree(points, distance);\n this.k = k;\n this.classes = classes;\n this.isEuclidean = distance === euclideanDistance;\n }\n\n /**\n * Create a new KNN instance with the given model.\n * @param {object} model\n * @param {function} distance=euclideanDistance - distance function must be provided if the model wasn't trained with euclidean distance.\n * @return {KNN}\n */\n static load(model, distance = euclideanDistance) {\n if (model.name !== 'KNN') {\n throw new Error(`invalid model: ${model.name}`);\n }\n if (!model.isEuclidean && distance === euclideanDistance) {\n throw new Error(\n 'a custom distance function was used to create the model. Please provide it again'\n );\n }\n if (model.isEuclidean && distance !== euclideanDistance) {\n throw new Error(\n 'the model was created with the default distance function. Do not load it with another one'\n );\n }\n return new KNN(true, model, distance);\n }\n\n /**\n * Return a JSON containing the kd-tree model.\n * @return {object} JSON KNN model.\n */\n toJSON() {\n return {\n name: 'KNN',\n kdTree: this.kdTree,\n k: this.k,\n classes: Array.from(this.classes),\n isEuclidean: this.isEuclidean\n };\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Array} dataset\n * @return {Array} predictions\n */\n predict(dataset) {\n if (Array.isArray(dataset)) {\n if (typeof dataset[0] === 'number') {\n return getSinglePrediction(this, dataset);\n } else if (\n Array.isArray(dataset[0]) &&\n typeof dataset[0][0] === 'number'\n ) {\n const predictions = new Array(dataset.length);\n for (var i = 0; i < dataset.length; i++) {\n predictions[i] = getSinglePrediction(this, dataset[i]);\n }\n return predictions;\n }\n }\n throw new TypeError('dataset to predict must be an array or a matrix');\n }\n}\n\nfunction getSinglePrediction(knn, currentCase) {\n var nearestPoints = knn.kdTree.nearest(currentCase, knn.k);\n var pointsPerClass = {};\n var predictedClass = -1;\n var maxPoints = -1;\n var lastElement = nearestPoints[0][0].length - 1;\n\n for (var element of knn.classes) {\n pointsPerClass[element] = 0;\n }\n\n for (var i = 0; i < nearestPoints.length; ++i) {\n var currentClass = nearestPoints[i][0][lastElement];\n var currentPoints = ++pointsPerClass[currentClass];\n if (currentPoints > maxPoints) {\n predictedClass = currentClass;\n maxPoints = currentPoints;\n }\n }\n\n return predictedClass;\n}\n","import Matrix from 'ml-matrix';\n\n/**\n * @private\n * Function that given vector, returns its norm\n * @param {Vector} X\n * @return {number} Norm of the vector\n */\nexport function norm(X) {\n return Math.sqrt(\n X.clone()\n .apply(pow2array)\n .sum(),\n );\n}\n\n/**\n * @private\n * Function that pow 2 each element of a Matrix or a Vector,\n * used in the apply method of the Matrix object\n * @param {number} i - index i.\n * @param {number} j - index j.\n * @return {Matrix} The Matrix object modified at the index i, j.\n * */\nexport function pow2array(i, j) {\n this.set(i, j, this.get(i, j) ** 2);\n}\n\n/**\n * @private\n * Function that normalize the dataset and return the means and\n * standard deviation of each feature.\n * @param {Matrix} dataset\n * @return {object} dataset normalized, means and standard deviations\n */\nexport function featureNormalize(dataset) {\n let means = dataset.mean('column');\n let std = dataset.standardDeviation('column', {\n mean: means,\n unbiased: true,\n });\n let result = Matrix.checkMatrix(dataset).subRowVector(means);\n return { result: result.divRowVector(std), means: means, std: std };\n}\n\n/**\n * @private\n * Function that initialize an array of matrices.\n * @param {Array} array\n * @param {boolean} isMatrix\n * @return {Array} array with the matrices initialized.\n */\nexport function initializeMatrices(array, isMatrix) {\n if (isMatrix) {\n for (let i = 0; i < array.length; ++i) {\n for (let j = 0; j < array[i].length; ++j) {\n let elem = array[i][j];\n array[i][j] = elem !== null ? new Matrix(array[i][j]) : undefined;\n }\n }\n } else {\n for (let i = 0; i < array.length; ++i) {\n array[i] = new Matrix(array[i]);\n }\n }\n\n return array;\n}\n","import Matrix from 'ml-matrix';\n\nimport * as Utils from './util/utils';\n\n/**\n * @class PLS\n */\nexport class PLS {\n /**\n * Constructor for Partial Least Squares (PLS)\n * @param {object} options\n * @param {number} [options.latentVectors] - Number of latent vector to get (if the algorithm doesn't find a good model below the tolerance)\n * @param {number} [options.tolerance=1e-5]\n * @param {boolean} [options.scale=true] - rescale dataset using mean.\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.meanX = model.meanX;\n this.stdDevX = model.stdDevX;\n this.meanY = model.meanY;\n this.stdDevY = model.stdDevY;\n this.PBQ = Matrix.checkMatrix(model.PBQ);\n this.R2X = model.R2X;\n this.scale = model.scale;\n this.scaleMethod = model.scaleMethod;\n this.tolerance = model.tolerance;\n } else {\n let { tolerance = 1e-5, scale = true } = options;\n this.tolerance = tolerance;\n this.scale = scale;\n this.latentVectors = options.latentVectors;\n }\n }\n\n /**\n * Fits the model with the given data and predictions, in this function is calculated the\n * following outputs:\n *\n * T - Score matrix of X\n * P - Loading matrix of X\n * U - Score matrix of Y\n * Q - Loading matrix of Y\n * B - Matrix of regression coefficient\n * W - Weight matrix of X\n *\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n trainingValues = Matrix.checkMatrix(trainingValues);\n\n if (trainingSet.length !== trainingValues.length) {\n throw new RangeError(\n 'The number of X rows must be equal to the number of Y rows',\n );\n }\n\n this.meanX = trainingSet.mean('column');\n this.stdDevX = trainingSet.standardDeviation('column', {\n mean: this.meanX,\n unbiased: true,\n });\n this.meanY = trainingValues.mean('column');\n this.stdDevY = trainingValues.standardDeviation('column', {\n mean: this.meanY,\n unbiased: true,\n });\n\n if (this.scale) {\n trainingSet = trainingSet\n .clone()\n .subRowVector(this.meanX)\n .divRowVector(this.stdDevX);\n trainingValues = trainingValues\n .clone()\n .subRowVector(this.meanY)\n .divRowVector(this.stdDevY);\n }\n\n if (this.latentVectors === undefined) {\n this.latentVectors = Math.min(trainingSet.rows - 1, trainingSet.columns);\n }\n\n let rx = trainingSet.rows;\n let cx = trainingSet.columns;\n let ry = trainingValues.rows;\n let cy = trainingValues.columns;\n\n let ssqXcal = trainingSet\n .clone()\n .mul(trainingSet)\n .sum(); // for the r²\n let sumOfSquaresY = trainingValues\n .clone()\n .mul(trainingValues)\n .sum();\n\n let tolerance = this.tolerance;\n let n = this.latentVectors;\n let T = Matrix.zeros(rx, n);\n let P = Matrix.zeros(cx, n);\n let U = Matrix.zeros(ry, n);\n let Q = Matrix.zeros(cy, n);\n let B = Matrix.zeros(n, n);\n let W = P.clone();\n let k = 0;\n let t;\n let w;\n let q;\n let p;\n\n while (Utils.norm(trainingValues) > tolerance && k < n) {\n let transposeX = trainingSet.transpose();\n let transposeY = trainingValues.transpose();\n\n let tIndex = maxSumColIndex(trainingSet.clone().mul(trainingSet));\n let uIndex = maxSumColIndex(trainingValues.clone().mul(trainingValues));\n\n let t1 = trainingSet.getColumnVector(tIndex);\n let u = trainingValues.getColumnVector(uIndex);\n t = Matrix.zeros(rx, 1);\n\n while (Utils.norm(t1.clone().sub(t)) > tolerance) {\n w = transposeX.mmul(u);\n w.div(Utils.norm(w));\n t = t1;\n t1 = trainingSet.mmul(w);\n q = transposeY.mmul(t1);\n q.div(Utils.norm(q));\n u = trainingValues.mmul(q);\n }\n\n t = t1;\n let num = transposeX.mmul(t);\n let den = t\n .transpose()\n .mmul(t)\n .get(0, 0);\n p = num.div(den);\n let pnorm = Utils.norm(p);\n p.div(pnorm);\n t.mul(pnorm);\n w.mul(pnorm);\n\n num = u.transpose().mmul(t);\n den = t\n .transpose()\n .mmul(t)\n .get(0, 0);\n let b = num.div(den).get(0, 0);\n trainingSet.sub(t.mmul(p.transpose()));\n trainingValues.sub(\n t\n .clone()\n .mul(b)\n .mmul(q.transpose()),\n );\n\n T.setColumn(k, t);\n P.setColumn(k, p);\n U.setColumn(k, u);\n Q.setColumn(k, q);\n W.setColumn(k, w);\n\n B.set(k, k, b);\n k++;\n }\n\n k--;\n T = T.subMatrix(0, T.rows - 1, 0, k);\n P = P.subMatrix(0, P.rows - 1, 0, k);\n U = U.subMatrix(0, U.rows - 1, 0, k);\n Q = Q.subMatrix(0, Q.rows - 1, 0, k);\n W = W.subMatrix(0, W.rows - 1, 0, k);\n B = B.subMatrix(0, k, 0, k);\n\n this.ssqYcal = sumOfSquaresY;\n this.E = trainingSet;\n this.F = trainingValues;\n this.T = T;\n this.P = P;\n this.U = U;\n this.Q = Q;\n this.W = W;\n this.B = B;\n this.PBQ = P.mmul(B).mmul(Q.transpose());\n this.R2X = t\n .transpose()\n .mmul(t)\n .mmul(p.transpose().mmul(p))\n .div(ssqXcal)\n .get(0, 0);\n }\n\n /**\n * Predicts the behavior of the given dataset.\n * @param {Matrix|Array} dataset - data to be predicted.\n * @return {Matrix} - predictions of each element of the dataset.\n */\n predict(dataset) {\n let X = Matrix.checkMatrix(dataset);\n if (this.scale) {\n X = X.subRowVector(this.meanX).divRowVector(this.stdDevX);\n }\n let Y = X.mmul(this.PBQ);\n Y = Y.mulRowVector(this.stdDevY).addRowVector(this.meanY);\n return Y;\n }\n\n /**\n * Returns the explained variance on training of the PLS model\n * @return {number}\n */\n getExplainedVariance() {\n return this.R2X;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n name: 'PLS',\n R2X: this.R2X,\n meanX: this.meanX,\n stdDevX: this.stdDevX,\n meanY: this.meanY,\n stdDevY: this.stdDevY,\n PBQ: this.PBQ,\n tolerance: this.tolerance,\n scale: this.scale,\n };\n }\n\n /**\n * Load a PLS model from a JSON Object\n * @param {object} model\n * @return {PLS} - PLS object from the given model\n */\n static load(model) {\n if (model.name !== 'PLS') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n return new PLS(true, model);\n }\n}\n\n/**\n * @private\n * Function that returns the index where the sum of each\n * column vector is maximum.\n * @param {Matrix} data\n * @return {number} index of the maximum\n */\nfunction maxSumColIndex(data) {\n return Matrix.rowVector(data.sum('column')).maxIndex()[0];\n}\n","import { Matrix, SingularValueDecomposition, inverse } from 'ml-matrix';\n\nimport { initializeMatrices } from './util/utils';\n\n/**\n * @class KOPLS\n */\nexport class KOPLS {\n /**\n * Constructor for Kernel-based Orthogonal Projections to Latent Structures (K-OPLS)\n * @param {object} options\n * @param {number} [options.predictiveComponents] - Number of predictive components to use.\n * @param {number} [options.orthogonalComponents] - Number of Y-Orthogonal components.\n * @param {Kernel} [options.kernel] - Kernel object to apply, see [ml-kernel](https://github.com/mljs/kernel).\n * @param {object} model - for load purposes.\n */\n constructor(options, model) {\n if (options === true) {\n this.trainingSet = new Matrix(model.trainingSet);\n this.YLoadingMat = new Matrix(model.YLoadingMat);\n this.SigmaPow = new Matrix(model.SigmaPow);\n this.YScoreMat = new Matrix(model.YScoreMat);\n this.predScoreMat = initializeMatrices(model.predScoreMat, false);\n this.YOrthLoadingVec = initializeMatrices(model.YOrthLoadingVec, false);\n this.YOrthEigen = model.YOrthEigen;\n this.YOrthScoreMat = initializeMatrices(model.YOrthScoreMat, false);\n this.toNorm = initializeMatrices(model.toNorm, false);\n this.TURegressionCoeff = initializeMatrices(\n model.TURegressionCoeff,\n false,\n );\n this.kernelX = initializeMatrices(model.kernelX, true);\n this.kernel = model.kernel;\n this.orthogonalComp = model.orthogonalComp;\n this.predictiveComp = model.predictiveComp;\n } else {\n if (options.predictiveComponents === undefined) {\n throw new RangeError('no predictive components found!');\n }\n if (options.orthogonalComponents === undefined) {\n throw new RangeError('no orthogonal components found!');\n }\n if (options.kernel === undefined) {\n throw new RangeError('no kernel found!');\n }\n\n this.orthogonalComp = options.orthogonalComponents;\n this.predictiveComp = options.predictiveComponents;\n this.kernel = options.kernel;\n }\n }\n\n /**\n * Train the K-OPLS model with the given training set and labels.\n * @param {Matrix|Array} trainingSet\n * @param {Matrix|Array} trainingValues\n */\n train(trainingSet, trainingValues) {\n trainingSet = Matrix.checkMatrix(trainingSet);\n trainingValues = Matrix.checkMatrix(trainingValues);\n\n // to save and compute kernel with the prediction dataset.\n this.trainingSet = trainingSet.clone();\n\n let kernelX = this.kernel.compute(trainingSet);\n\n let Identity = Matrix.eye(kernelX.rows, kernelX.rows, 1);\n let temp = kernelX;\n kernelX = new Array(this.orthogonalComp + 1);\n for (let i = 0; i < this.orthogonalComp + 1; i++) {\n kernelX[i] = new Array(this.orthogonalComp + 1);\n }\n kernelX[0][0] = temp;\n\n let result = new SingularValueDecomposition(\n trainingValues\n .transpose()\n .mmul(kernelX[0][0])\n .mmul(trainingValues),\n {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false,\n },\n );\n let YLoadingMat = result.leftSingularVectors;\n let Sigma = result.diagonalMatrix;\n\n YLoadingMat = YLoadingMat.subMatrix(\n 0,\n YLoadingMat.rows - 1,\n 0,\n this.predictiveComp - 1,\n );\n Sigma = Sigma.subMatrix(\n 0,\n this.predictiveComp - 1,\n 0,\n this.predictiveComp - 1,\n );\n\n let YScoreMat = trainingValues.mmul(YLoadingMat);\n\n let predScoreMat = new Array(this.orthogonalComp + 1);\n let TURegressionCoeff = new Array(this.orthogonalComp + 1);\n let YOrthScoreMat = new Array(this.orthogonalComp);\n let YOrthLoadingVec = new Array(this.orthogonalComp);\n let YOrthEigen = new Array(this.orthogonalComp);\n let YOrthScoreNorm = new Array(this.orthogonalComp);\n\n let SigmaPow = Matrix.pow(Sigma, -0.5);\n // to avoid errors, check infinity\n SigmaPow.apply(function(i, j) {\n if (this.get(i, j) === Infinity) {\n this.set(i, j, 0);\n }\n });\n\n for (let i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = kernelX[0][i]\n .transpose()\n .mmul(YScoreMat)\n .mmul(SigmaPow);\n\n let TpiPrime = predScoreMat[i].transpose();\n TURegressionCoeff[i] = inverse(TpiPrime.mmul(predScoreMat[i]))\n .mmul(TpiPrime)\n .mmul(YScoreMat);\n\n result = new SingularValueDecomposition(\n TpiPrime.mmul(\n Matrix.sub(kernelX[i][i], predScoreMat[i].mmul(TpiPrime)),\n ).mmul(predScoreMat[i]),\n {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false,\n },\n );\n let CoTemp = result.leftSingularVectors;\n let SoTemp = result.diagonalMatrix;\n\n YOrthLoadingVec[i] = CoTemp.subMatrix(0, CoTemp.rows - 1, 0, 0);\n YOrthEigen[i] = SoTemp.get(0, 0);\n\n YOrthScoreMat[i] = Matrix.sub(\n kernelX[i][i],\n predScoreMat[i].mmul(TpiPrime),\n )\n .mmul(predScoreMat[i])\n .mmul(YOrthLoadingVec[i])\n .mul(Math.pow(YOrthEigen[i], -0.5));\n\n let toiPrime = YOrthScoreMat[i].transpose();\n YOrthScoreNorm[i] = Matrix.sqrt(toiPrime.mmul(YOrthScoreMat[i]));\n\n YOrthScoreMat[i] = YOrthScoreMat[i].divRowVector(YOrthScoreNorm[i]);\n\n let ITo = Matrix.sub(\n Identity,\n YOrthScoreMat[i].mmul(YOrthScoreMat[i].transpose()),\n );\n\n kernelX[0][i + 1] = kernelX[0][i].mmul(ITo);\n kernelX[i + 1][i + 1] = ITo.mmul(kernelX[i][i]).mmul(ITo);\n }\n\n let lastScoreMat = (predScoreMat[this.orthogonalComp] = kernelX[0][\n this.orthogonalComp\n ]\n .transpose()\n .mmul(YScoreMat)\n .mmul(SigmaPow));\n\n let lastTpPrime = lastScoreMat.transpose();\n TURegressionCoeff[this.orthogonalComp] = inverse(\n lastTpPrime.mmul(lastScoreMat),\n )\n .mmul(lastTpPrime)\n .mmul(YScoreMat);\n\n this.YLoadingMat = YLoadingMat;\n this.SigmaPow = SigmaPow;\n this.YScoreMat = YScoreMat;\n this.predScoreMat = predScoreMat;\n this.YOrthLoadingVec = YOrthLoadingVec;\n this.YOrthEigen = YOrthEigen;\n this.YOrthScoreMat = YOrthScoreMat;\n this.toNorm = YOrthScoreNorm;\n this.TURegressionCoeff = TURegressionCoeff;\n this.kernelX = kernelX;\n }\n\n /**\n * Predicts the output given the matrix to predict.\n * @param {Matrix|Array} toPredict\n * @return {{y: Matrix, predScoreMat: Array, predYOrthVectors: Array}} predictions\n */\n predict(toPredict) {\n let KTestTrain = this.kernel.compute(toPredict, this.trainingSet);\n\n let temp = KTestTrain;\n KTestTrain = new Array(this.orthogonalComp + 1);\n for (let i = 0; i < this.orthogonalComp + 1; i++) {\n KTestTrain[i] = new Array(this.orthogonalComp + 1);\n }\n KTestTrain[0][0] = temp;\n\n let YOrthScoreVector = new Array(this.orthogonalComp);\n let predScoreMat = new Array(this.orthogonalComp);\n\n let i;\n for (i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = KTestTrain[i][0]\n .mmul(this.YScoreMat)\n .mmul(this.SigmaPow);\n\n YOrthScoreVector[i] = Matrix.sub(\n KTestTrain[i][i],\n predScoreMat[i].mmul(this.predScoreMat[i].transpose()),\n )\n .mmul(this.predScoreMat[i])\n .mmul(this.YOrthLoadingVec[i])\n .mul(Math.pow(this.YOrthEigen[i], -0.5));\n\n YOrthScoreVector[i] = YOrthScoreVector[i].divRowVector(this.toNorm[i]);\n\n let scoreMatPrime = this.YOrthScoreMat[i].transpose();\n KTestTrain[i + 1][0] = Matrix.sub(\n KTestTrain[i][0],\n YOrthScoreVector[i]\n .mmul(scoreMatPrime)\n .mmul(this.kernelX[0][i].transpose()),\n );\n\n let p1 = Matrix.sub(\n KTestTrain[i][0],\n KTestTrain[i][i].mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime),\n );\n let p2 = YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[i][i]);\n let p3 = p2.mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime);\n\n KTestTrain[i + 1][i + 1] = p1.sub(p2).add(p3);\n }\n\n predScoreMat[i] = KTestTrain[i][0].mmul(this.YScoreMat).mmul(this.SigmaPow);\n let prediction = predScoreMat[i]\n .mmul(this.TURegressionCoeff[i])\n .mmul(this.YLoadingMat.transpose());\n\n return {\n prediction: prediction,\n predScoreMat: predScoreMat,\n predYOrthVectors: YOrthScoreVector,\n };\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} - Current model.\n */\n toJSON() {\n return {\n name: 'K-OPLS',\n YLoadingMat: this.YLoadingMat,\n SigmaPow: this.SigmaPow,\n YScoreMat: this.YScoreMat,\n predScoreMat: this.predScoreMat,\n YOrthLoadingVec: this.YOrthLoadingVec,\n YOrthEigen: this.YOrthEigen,\n YOrthScoreMat: this.YOrthScoreMat,\n toNorm: this.toNorm,\n TURegressionCoeff: this.TURegressionCoeff,\n kernelX: this.kernelX,\n trainingSet: this.trainingSet,\n orthogonalComp: this.orthogonalComp,\n predictiveComp: this.predictiveComp,\n };\n }\n\n /**\n * Load a K-OPLS with the given model.\n * @param {object} model\n * @param {Kernel} kernel - kernel used on the model, see [ml-kernel](https://github.com/mljs/kernel).\n * @return {KOPLS}\n */\n static load(model, kernel) {\n if (model.name !== 'K-OPLS') {\n throw new RangeError(`Invalid model: ${model.name}`);\n }\n\n if (!kernel) {\n throw new RangeError('You must provide a kernel for the model!');\n }\n\n model.kernel = kernel;\n return new KOPLS(true, model);\n }\n}\n","/**\n * Constructs a confusion matrix\n * @class ConfusionMatrix\n * @example\n * const CM = new ConfusionMatrix([[13, 2], [10, 5]], ['cat', 'dog'])\n * @param {Array>} matrix - The confusion matrix, a 2D Array. Rows represent the actual label and columns\n * the predicted label.\n * @param {Array} labels - Labels of the confusion matrix, a 1D Array\n */\nexport default class ConfusionMatrix {\n constructor(matrix, labels) {\n if (matrix.length !== matrix[0].length) {\n throw new Error('Confusion matrix must be square');\n }\n if (labels.length !== matrix.length) {\n throw new Error(\n 'Confusion matrix and labels should have the same length',\n );\n }\n this.labels = labels;\n this.matrix = matrix;\n }\n\n /**\n * Construct confusion matrix from the predicted and actual labels (classes). Be sure to provide the arguments in\n * the correct order!\n * @param {Array} actual - The predicted labels of the classification\n * @param {Array} predicted - The actual labels of the classification. Has to be of same length as\n * predicted.\n * @param {object} [options] - Additional options\n * @param {Array} [options.labels] - The list of labels that should be used. If not provided the distinct set\n * of labels present in predicted and actual is used. Labels are compared using the strict equality operator\n * '==='\n * @return {ConfusionMatrix} - Confusion matrix\n */\n static fromLabels(actual, predicted, options = {}) {\n if (predicted.length !== actual.length) {\n throw new Error('predicted and actual must have the same length');\n }\n let distinctLabels;\n if (options.labels) {\n distinctLabels = new Set(options.labels);\n } else {\n distinctLabels = new Set([...actual, ...predicted]);\n }\n distinctLabels = Array.from(distinctLabels);\n if (options.sort) {\n distinctLabels.sort(options.sort);\n }\n\n // Create confusion matrix and fill with 0's\n const matrix = Array.from({ length: distinctLabels.length });\n for (let i = 0; i < matrix.length; i++) {\n matrix[i] = new Array(matrix.length);\n matrix[i].fill(0);\n }\n\n for (let i = 0; i < predicted.length; i++) {\n const actualIdx = distinctLabels.indexOf(actual[i]);\n const predictedIdx = distinctLabels.indexOf(predicted[i]);\n if (actualIdx >= 0 && predictedIdx >= 0) {\n matrix[actualIdx][predictedIdx]++;\n }\n }\n\n return new ConfusionMatrix(matrix, distinctLabels);\n }\n\n /**\n * Get the confusion matrix\n * @return {Array >}\n */\n getMatrix() {\n return this.matrix;\n }\n\n getLabels() {\n return this.labels;\n }\n\n /**\n * Get the total number of samples\n * @return {number}\n */\n getTotalCount() {\n let predicted = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n predicted += this.matrix[i][j];\n }\n }\n return predicted;\n }\n\n /**\n * Get the total number of true predictions\n * @return {number}\n */\n getTrueCount() {\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n count += this.matrix[i][i];\n }\n return count;\n }\n\n /**\n * Get the total number of false predictions.\n * @return {number}\n */\n getFalseCount() {\n return this.getTotalCount() - this.getTrueCount();\n }\n\n /**\n * Get the number of true positive predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTruePositiveCount(label) {\n const index = this.getIndex(label);\n return this.matrix[index][index];\n }\n\n /**\n * Get the number of true negative predictions\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTrueNegativeCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n if (i !== index && j !== index) {\n count += this.matrix[i][j];\n }\n }\n }\n return count;\n }\n\n /**\n * Get the number of false positive predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalsePositiveCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n if (i !== index) {\n count += this.matrix[i][index];\n }\n }\n return count;\n }\n\n /**\n * Get the number of false negative predictions.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseNegativeCount(label) {\n const index = this.getIndex(label);\n let count = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n if (i !== index) {\n count += this.matrix[index][i];\n }\n }\n return count;\n }\n\n /**\n * Get the number of real positive samples.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getPositiveCount(label) {\n return this.getTruePositiveCount(label) + this.getFalseNegativeCount(label);\n }\n\n /**\n * Get the number of real negative samples.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getNegativeCount(label) {\n return this.getTrueNegativeCount(label) + this.getFalsePositiveCount(label);\n }\n\n /**\n * Get the index in the confusion matrix that corresponds to the given label\n * @param {any} label - The label to search for\n * @throws if the label is not found\n * @return {number}\n */\n getIndex(label) {\n const index = this.labels.indexOf(label);\n if (index === -1) throw new Error('The label does not exist');\n return index;\n }\n\n /**\n * Get the true positive rate a.k.a. sensitivity. Computes the ratio between the number of true positive predictions and the total number of positive samples.\n * {@link https://en.wikipedia.org/wiki/Sensitivity_and_specificity}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number} - The true positive rate [0-1]\n */\n getTruePositiveRate(label) {\n return this.getTruePositiveCount(label) / this.getPositiveCount(label);\n }\n\n /**\n * Get the true negative rate a.k.a. specificity. Computes the ration between the number of true negative predictions and the total number of negative samples.\n * {@link https://en.wikipedia.org/wiki/Sensitivity_and_specificity}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getTrueNegativeRate(label) {\n return this.getTrueNegativeCount(label) / this.getNegativeCount(label);\n }\n\n /**\n * Get the positive predictive value a.k.a. precision. Computes TP / (TP + FP)\n * {@link https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getPositivePredictiveValue(label) {\n const TP = this.getTruePositiveCount(label);\n return TP / (TP + this.getFalsePositiveCount(label));\n }\n\n /**\n * Negative predictive value\n * {@link https://en.wikipedia.org/wiki/Positive_and_negative_predictive_values}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getNegativePredictiveValue(label) {\n const TN = this.getTrueNegativeCount(label);\n return TN / (TN + this.getFalseNegativeCount(label));\n }\n\n /**\n * False negative rate a.k.a. miss rate.\n * {@link https://en.wikipedia.org/wiki/Type_I_and_type_II_errors#False_positive_and_false_negative_rates}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseNegativeRate(label) {\n return 1 - this.getTruePositiveRate(label);\n }\n\n /**\n * False positive rate a.k.a. fall-out rate.\n * {@link https://en.wikipedia.org/wiki/Type_I_and_type_II_errors#False_positive_and_false_negative_rates}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalsePositiveRate(label) {\n return 1 - this.getTrueNegativeRate(label);\n }\n\n /**\n * False discovery rate (FDR)\n * {@link https://en.wikipedia.org/wiki/False_discovery_rate}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseDiscoveryRate(label) {\n const FP = this.getFalsePositiveCount(label);\n return FP / (FP + this.getTruePositiveCount(label));\n }\n\n /**\n * False omission rate (FOR)\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getFalseOmissionRate(label) {\n const FN = this.getFalseNegativeCount(label);\n return FN / (FN + this.getTruePositiveCount(label));\n }\n\n /**\n * F1 score\n * {@link https://en.wikipedia.org/wiki/F1_score}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getF1Score(label) {\n const TP = this.getTruePositiveCount(label);\n return (\n (2 * TP) /\n (2 * TP +\n this.getFalsePositiveCount(label) +\n this.getFalseNegativeCount(label))\n );\n }\n\n /**\n * Matthews correlation coefficient (MCC)\n * {@link https://en.wikipedia.org/wiki/Matthews_correlation_coefficient}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getMatthewsCorrelationCoefficient(label) {\n const TP = this.getTruePositiveCount(label);\n const TN = this.getTrueNegativeCount(label);\n const FP = this.getFalsePositiveCount(label);\n const FN = this.getFalseNegativeCount(label);\n return (\n (TP * TN - FP * FN) /\n Math.sqrt((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN))\n );\n }\n\n /**\n * Informedness\n * {@link https://en.wikipedia.org/wiki/Youden%27s_J_statistic}\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getInformedness(label) {\n return (\n this.getTruePositiveRate(label) + this.getTrueNegativeRate(label) - 1\n );\n }\n\n /**\n * Markedness\n * @param {any} label - The label that should be considered \"positive\"\n * @return {number}\n */\n getMarkedness(label) {\n return (\n this.getPositivePredictiveValue(label) +\n this.getNegativePredictiveValue(label) -\n 1\n );\n }\n\n /**\n * Get the confusion table.\n * @param {any} label - The label that should be considered \"positive\"\n * @return {Array >} - The 2x2 confusion table. [[TP, FN], [FP, TN]]\n */\n getConfusionTable(label) {\n return [\n [this.getTruePositiveCount(label), this.getFalseNegativeCount(label)],\n [this.getFalsePositiveCount(label), this.getTrueNegativeCount(label)],\n ];\n }\n\n /**\n * Get total accuracy.\n * @return {number} - The ratio between the number of true predictions and total number of classifications ([0-1])\n */\n getAccuracy() {\n let correct = 0;\n let incorrect = 0;\n for (let i = 0; i < this.matrix.length; i++) {\n for (let j = 0; j < this.matrix.length; j++) {\n if (i === j) correct += this.matrix[i][j];\n else incorrect += this.matrix[i][j];\n }\n }\n return correct / (correct + incorrect);\n }\n\n /**\n * Returns the element in the confusion matrix that corresponds to the given actual and predicted labels.\n * @param {any} actual - The true label\n * @param {any} predicted - The predicted label\n * @return {number} - The element in the confusion matrix\n */\n getCount(actual, predicted) {\n const actualIndex = this.getIndex(actual);\n const predictedIndex = this.getIndex(predicted);\n return this.matrix[actualIndex][predictedIndex];\n }\n\n /**\n * Compute the general prediction accuracy\n * @deprecated Use getAccuracy\n * @return {number} - The prediction accuracy ([0-1]\n */\n get accuracy() {\n return this.getAccuracy();\n }\n\n /**\n * Compute the number of predicted observations\n * @deprecated Use getTotalCount\n * @return {number}\n */\n get total() {\n return this.getTotalCount();\n }\n}\n","(function (global, factory) {\n\ttypeof exports === 'object' && typeof module !== 'undefined' ? factory() :\n\ttypeof define === 'function' && define.amd ? define(factory) :\n\t(factory());\n}(this, (function () { 'use strict';\n\n\tfunction createCommonjsModule(fn, module) {\n\t\treturn module = { exports: {} }, fn(module, module.exports), module.exports;\n\t}\n\n\tvar runtime = createCommonjsModule(function (module) {\n\t/**\n\t * Copyright (c) 2014-present, Facebook, Inc.\n\t *\n\t * This source code is licensed under the MIT license found in the\n\t * LICENSE file in the root directory of this source tree.\n\t */\n\n\t!(function(global) {\n\n\t var Op = Object.prototype;\n\t var hasOwn = Op.hasOwnProperty;\n\t var undefined; // More compressible than void 0.\n\t var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n\t var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n\t var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n\t var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\t var runtime = global.regeneratorRuntime;\n\t if (runtime) {\n\t {\n\t // If regeneratorRuntime is defined globally and we're in a module,\n\t // make the exports object identical to regeneratorRuntime.\n\t module.exports = runtime;\n\t }\n\t // Don't bother evaluating the rest of this file if the runtime was\n\t // already defined globally.\n\t return;\n\t }\n\n\t // Define the runtime globally (as expected by generated code) as either\n\t // module.exports (if we're in a module) or a new, empty object.\n\t runtime = global.regeneratorRuntime = module.exports;\n\n\t function wrap(innerFn, outerFn, self, tryLocsList) {\n\t // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n\t var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n\t var generator = Object.create(protoGenerator.prototype);\n\t var context = new Context(tryLocsList || []);\n\n\t // The ._invoke method unifies the implementations of the .next,\n\t // .throw, and .return methods.\n\t generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n\t return generator;\n\t }\n\t runtime.wrap = wrap;\n\n\t // Try/catch helper to minimize deoptimizations. Returns a completion\n\t // record like context.tryEntries[i].completion. This interface could\n\t // have been (and was previously) designed to take a closure to be\n\t // invoked without arguments, but in all the cases we care about we\n\t // already have an existing method we want to call, so there's no need\n\t // to create a new function object. We can even get away with assuming\n\t // the method takes exactly one argument, since that happens to be true\n\t // in every case, so we don't have to touch the arguments object. The\n\t // only additional allocation required is the completion record, which\n\t // has a stable shape and so hopefully should be cheap to allocate.\n\t function tryCatch(fn, obj, arg) {\n\t try {\n\t return { type: \"normal\", arg: fn.call(obj, arg) };\n\t } catch (err) {\n\t return { type: \"throw\", arg: err };\n\t }\n\t }\n\n\t var GenStateSuspendedStart = \"suspendedStart\";\n\t var GenStateSuspendedYield = \"suspendedYield\";\n\t var GenStateExecuting = \"executing\";\n\t var GenStateCompleted = \"completed\";\n\n\t // Returning this object from the innerFn has the same effect as\n\t // breaking out of the dispatch switch statement.\n\t var ContinueSentinel = {};\n\n\t // Dummy constructor functions that we use as the .constructor and\n\t // .constructor.prototype properties for functions that return Generator\n\t // objects. For full spec compliance, you may wish to configure your\n\t // minifier not to mangle the names of these two functions.\n\t function Generator() {}\n\t function GeneratorFunction() {}\n\t function GeneratorFunctionPrototype() {}\n\n\t // This is a polyfill for %IteratorPrototype% for environments that\n\t // don't natively support it.\n\t var IteratorPrototype = {};\n\t IteratorPrototype[iteratorSymbol] = function () {\n\t return this;\n\t };\n\n\t var getProto = Object.getPrototypeOf;\n\t var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n\t if (NativeIteratorPrototype &&\n\t NativeIteratorPrototype !== Op &&\n\t hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n\t // This environment has a native %IteratorPrototype%; use it instead\n\t // of the polyfill.\n\t IteratorPrototype = NativeIteratorPrototype;\n\t }\n\n\t var Gp = GeneratorFunctionPrototype.prototype =\n\t Generator.prototype = Object.create(IteratorPrototype);\n\t GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n\t GeneratorFunctionPrototype.constructor = GeneratorFunction;\n\t GeneratorFunctionPrototype[toStringTagSymbol] =\n\t GeneratorFunction.displayName = \"GeneratorFunction\";\n\n\t // Helper for defining the .next, .throw, and .return methods of the\n\t // Iterator interface in terms of a single ._invoke method.\n\t function defineIteratorMethods(prototype) {\n\t [\"next\", \"throw\", \"return\"].forEach(function(method) {\n\t prototype[method] = function(arg) {\n\t return this._invoke(method, arg);\n\t };\n\t });\n\t }\n\n\t runtime.isGeneratorFunction = function(genFun) {\n\t var ctor = typeof genFun === \"function\" && genFun.constructor;\n\t return ctor\n\t ? ctor === GeneratorFunction ||\n\t // For the native GeneratorFunction constructor, the best we can\n\t // do is to check its .name property.\n\t (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n\t : false;\n\t };\n\n\t runtime.mark = function(genFun) {\n\t if (Object.setPrototypeOf) {\n\t Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n\t } else {\n\t genFun.__proto__ = GeneratorFunctionPrototype;\n\t if (!(toStringTagSymbol in genFun)) {\n\t genFun[toStringTagSymbol] = \"GeneratorFunction\";\n\t }\n\t }\n\t genFun.prototype = Object.create(Gp);\n\t return genFun;\n\t };\n\n\t // Within the body of any async function, `await x` is transformed to\n\t // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n\t // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n\t // meant to be awaited.\n\t runtime.awrap = function(arg) {\n\t return { __await: arg };\n\t };\n\n\t function AsyncIterator(generator) {\n\t function invoke(method, arg, resolve, reject) {\n\t var record = tryCatch(generator[method], generator, arg);\n\t if (record.type === \"throw\") {\n\t reject(record.arg);\n\t } else {\n\t var result = record.arg;\n\t var value = result.value;\n\t if (value &&\n\t typeof value === \"object\" &&\n\t hasOwn.call(value, \"__await\")) {\n\t return Promise.resolve(value.__await).then(function(value) {\n\t invoke(\"next\", value, resolve, reject);\n\t }, function(err) {\n\t invoke(\"throw\", err, resolve, reject);\n\t });\n\t }\n\n\t return Promise.resolve(value).then(function(unwrapped) {\n\t // When a yielded Promise is resolved, its final value becomes\n\t // the .value of the Promise<{value,done}> result for the\n\t // current iteration. If the Promise is rejected, however, the\n\t // result for this iteration will be rejected with the same\n\t // reason. Note that rejections of yielded Promises are not\n\t // thrown back into the generator function, as is the case\n\t // when an awaited Promise is rejected. This difference in\n\t // behavior between yield and await is important, because it\n\t // allows the consumer to decide what to do with the yielded\n\t // rejection (swallow it and continue, manually .throw it back\n\t // into the generator, abandon iteration, whatever). With\n\t // await, by contrast, there is no opportunity to examine the\n\t // rejection reason outside the generator function, so the\n\t // only option is to throw it from the await expression, and\n\t // let the generator function handle the exception.\n\t result.value = unwrapped;\n\t resolve(result);\n\t }, reject);\n\t }\n\t }\n\n\t var previousPromise;\n\n\t function enqueue(method, arg) {\n\t function callInvokeWithMethodAndArg() {\n\t return new Promise(function(resolve, reject) {\n\t invoke(method, arg, resolve, reject);\n\t });\n\t }\n\n\t return previousPromise =\n\t // If enqueue has been called before, then we want to wait until\n\t // all previous Promises have been resolved before calling invoke,\n\t // so that results are always delivered in the correct order. If\n\t // enqueue has not been called before, then it is important to\n\t // call invoke immediately, without waiting on a callback to fire,\n\t // so that the async generator function has the opportunity to do\n\t // any necessary setup in a predictable way. This predictability\n\t // is why the Promise constructor synchronously invokes its\n\t // executor callback, and why async functions synchronously\n\t // execute code before the first await. Since we implement simple\n\t // async functions in terms of async generators, it is especially\n\t // important to get this right, even though it requires care.\n\t previousPromise ? previousPromise.then(\n\t callInvokeWithMethodAndArg,\n\t // Avoid propagating failures to Promises returned by later\n\t // invocations of the iterator.\n\t callInvokeWithMethodAndArg\n\t ) : callInvokeWithMethodAndArg();\n\t }\n\n\t // Define the unified helper method that is used to implement .next,\n\t // .throw, and .return (see defineIteratorMethods).\n\t this._invoke = enqueue;\n\t }\n\n\t defineIteratorMethods(AsyncIterator.prototype);\n\t AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n\t return this;\n\t };\n\t runtime.AsyncIterator = AsyncIterator;\n\n\t // Note that simple async functions are implemented on top of\n\t // AsyncIterator objects; they just return a Promise for the value of\n\t // the final result produced by the iterator.\n\t runtime.async = function(innerFn, outerFn, self, tryLocsList) {\n\t var iter = new AsyncIterator(\n\t wrap(innerFn, outerFn, self, tryLocsList)\n\t );\n\n\t return runtime.isGeneratorFunction(outerFn)\n\t ? iter // If outerFn is a generator, return the full iterator.\n\t : iter.next().then(function(result) {\n\t return result.done ? result.value : iter.next();\n\t });\n\t };\n\n\t function makeInvokeMethod(innerFn, self, context) {\n\t var state = GenStateSuspendedStart;\n\n\t return function invoke(method, arg) {\n\t if (state === GenStateExecuting) {\n\t throw new Error(\"Generator is already running\");\n\t }\n\n\t if (state === GenStateCompleted) {\n\t if (method === \"throw\") {\n\t throw arg;\n\t }\n\n\t // Be forgiving, per 25.3.3.3.3 of the spec:\n\t // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n\t return doneResult();\n\t }\n\n\t context.method = method;\n\t context.arg = arg;\n\n\t while (true) {\n\t var delegate = context.delegate;\n\t if (delegate) {\n\t var delegateResult = maybeInvokeDelegate(delegate, context);\n\t if (delegateResult) {\n\t if (delegateResult === ContinueSentinel) continue;\n\t return delegateResult;\n\t }\n\t }\n\n\t if (context.method === \"next\") {\n\t // Setting context._sent for legacy support of Babel's\n\t // function.sent implementation.\n\t context.sent = context._sent = context.arg;\n\n\t } else if (context.method === \"throw\") {\n\t if (state === GenStateSuspendedStart) {\n\t state = GenStateCompleted;\n\t throw context.arg;\n\t }\n\n\t context.dispatchException(context.arg);\n\n\t } else if (context.method === \"return\") {\n\t context.abrupt(\"return\", context.arg);\n\t }\n\n\t state = GenStateExecuting;\n\n\t var record = tryCatch(innerFn, self, context);\n\t if (record.type === \"normal\") {\n\t // If an exception is thrown from innerFn, we leave state ===\n\t // GenStateExecuting and loop back for another invocation.\n\t state = context.done\n\t ? GenStateCompleted\n\t : GenStateSuspendedYield;\n\n\t if (record.arg === ContinueSentinel) {\n\t continue;\n\t }\n\n\t return {\n\t value: record.arg,\n\t done: context.done\n\t };\n\n\t } else if (record.type === \"throw\") {\n\t state = GenStateCompleted;\n\t // Dispatch the exception by looping back around to the\n\t // context.dispatchException(context.arg) call above.\n\t context.method = \"throw\";\n\t context.arg = record.arg;\n\t }\n\t }\n\t };\n\t }\n\n\t // Call delegate.iterator[context.method](context.arg) and handle the\n\t // result, either by returning a { value, done } result from the\n\t // delegate iterator, or by modifying context.method and context.arg,\n\t // setting context.delegate to null, and returning the ContinueSentinel.\n\t function maybeInvokeDelegate(delegate, context) {\n\t var method = delegate.iterator[context.method];\n\t if (method === undefined) {\n\t // A .throw or .return when the delegate iterator has no .throw\n\t // method always terminates the yield* loop.\n\t context.delegate = null;\n\n\t if (context.method === \"throw\") {\n\t if (delegate.iterator.return) {\n\t // If the delegate iterator has a return method, give it a\n\t // chance to clean up.\n\t context.method = \"return\";\n\t context.arg = undefined;\n\t maybeInvokeDelegate(delegate, context);\n\n\t if (context.method === \"throw\") {\n\t // If maybeInvokeDelegate(context) changed context.method from\n\t // \"return\" to \"throw\", let that override the TypeError below.\n\t return ContinueSentinel;\n\t }\n\t }\n\n\t context.method = \"throw\";\n\t context.arg = new TypeError(\n\t \"The iterator does not provide a 'throw' method\");\n\t }\n\n\t return ContinueSentinel;\n\t }\n\n\t var record = tryCatch(method, delegate.iterator, context.arg);\n\n\t if (record.type === \"throw\") {\n\t context.method = \"throw\";\n\t context.arg = record.arg;\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t var info = record.arg;\n\n\t if (! info) {\n\t context.method = \"throw\";\n\t context.arg = new TypeError(\"iterator result is not an object\");\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t if (info.done) {\n\t // Assign the result of the finished delegate to the temporary\n\t // variable specified by delegate.resultName (see delegateYield).\n\t context[delegate.resultName] = info.value;\n\n\t // Resume execution at the desired location (see delegateYield).\n\t context.next = delegate.nextLoc;\n\n\t // If context.method was \"throw\" but the delegate handled the\n\t // exception, let the outer generator proceed normally. If\n\t // context.method was \"next\", forget context.arg since it has been\n\t // \"consumed\" by the delegate iterator. If context.method was\n\t // \"return\", allow the original .return call to continue in the\n\t // outer generator.\n\t if (context.method !== \"return\") {\n\t context.method = \"next\";\n\t context.arg = undefined;\n\t }\n\n\t } else {\n\t // Re-yield the result returned by the delegate method.\n\t return info;\n\t }\n\n\t // The delegate iterator is finished, so forget it and continue with\n\t // the outer generator.\n\t context.delegate = null;\n\t return ContinueSentinel;\n\t }\n\n\t // Define Generator.prototype.{next,throw,return} in terms of the\n\t // unified ._invoke helper method.\n\t defineIteratorMethods(Gp);\n\n\t Gp[toStringTagSymbol] = \"Generator\";\n\n\t // A Generator should always return itself as the iterator object when the\n\t // @@iterator function is called on it. Some browsers' implementations of the\n\t // iterator prototype chain incorrectly implement this, causing the Generator\n\t // object to not be returned from this call. This ensures that doesn't happen.\n\t // See https://github.com/facebook/regenerator/issues/274 for more details.\n\t Gp[iteratorSymbol] = function() {\n\t return this;\n\t };\n\n\t Gp.toString = function() {\n\t return \"[object Generator]\";\n\t };\n\n\t function pushTryEntry(locs) {\n\t var entry = { tryLoc: locs[0] };\n\n\t if (1 in locs) {\n\t entry.catchLoc = locs[1];\n\t }\n\n\t if (2 in locs) {\n\t entry.finallyLoc = locs[2];\n\t entry.afterLoc = locs[3];\n\t }\n\n\t this.tryEntries.push(entry);\n\t }\n\n\t function resetTryEntry(entry) {\n\t var record = entry.completion || {};\n\t record.type = \"normal\";\n\t delete record.arg;\n\t entry.completion = record;\n\t }\n\n\t function Context(tryLocsList) {\n\t // The root entry object (effectively a try statement without a catch\n\t // or a finally block) gives us a place to store values thrown from\n\t // locations where there is no enclosing try statement.\n\t this.tryEntries = [{ tryLoc: \"root\" }];\n\t tryLocsList.forEach(pushTryEntry, this);\n\t this.reset(true);\n\t }\n\n\t runtime.keys = function(object) {\n\t var keys = [];\n\t for (var key in object) {\n\t keys.push(key);\n\t }\n\t keys.reverse();\n\n\t // Rather than returning an object with a next method, we keep\n\t // things simple and return the next function itself.\n\t return function next() {\n\t while (keys.length) {\n\t var key = keys.pop();\n\t if (key in object) {\n\t next.value = key;\n\t next.done = false;\n\t return next;\n\t }\n\t }\n\n\t // To avoid creating an additional object, we just hang the .value\n\t // and .done properties off the next function object itself. This\n\t // also ensures that the minifier will not anonymize the function.\n\t next.done = true;\n\t return next;\n\t };\n\t };\n\n\t function values(iterable) {\n\t if (iterable) {\n\t var iteratorMethod = iterable[iteratorSymbol];\n\t if (iteratorMethod) {\n\t return iteratorMethod.call(iterable);\n\t }\n\n\t if (typeof iterable.next === \"function\") {\n\t return iterable;\n\t }\n\n\t if (!isNaN(iterable.length)) {\n\t var i = -1, next = function next() {\n\t while (++i < iterable.length) {\n\t if (hasOwn.call(iterable, i)) {\n\t next.value = iterable[i];\n\t next.done = false;\n\t return next;\n\t }\n\t }\n\n\t next.value = undefined;\n\t next.done = true;\n\n\t return next;\n\t };\n\n\t return next.next = next;\n\t }\n\t }\n\n\t // Return an iterator with no values.\n\t return { next: doneResult };\n\t }\n\t runtime.values = values;\n\n\t function doneResult() {\n\t return { value: undefined, done: true };\n\t }\n\n\t Context.prototype = {\n\t constructor: Context,\n\n\t reset: function(skipTempReset) {\n\t this.prev = 0;\n\t this.next = 0;\n\t // Resetting context._sent for legacy support of Babel's\n\t // function.sent implementation.\n\t this.sent = this._sent = undefined;\n\t this.done = false;\n\t this.delegate = null;\n\n\t this.method = \"next\";\n\t this.arg = undefined;\n\n\t this.tryEntries.forEach(resetTryEntry);\n\n\t if (!skipTempReset) {\n\t for (var name in this) {\n\t // Not sure about the optimal order of these conditions:\n\t if (name.charAt(0) === \"t\" &&\n\t hasOwn.call(this, name) &&\n\t !isNaN(+name.slice(1))) {\n\t this[name] = undefined;\n\t }\n\t }\n\t }\n\t },\n\n\t stop: function() {\n\t this.done = true;\n\n\t var rootEntry = this.tryEntries[0];\n\t var rootRecord = rootEntry.completion;\n\t if (rootRecord.type === \"throw\") {\n\t throw rootRecord.arg;\n\t }\n\n\t return this.rval;\n\t },\n\n\t dispatchException: function(exception) {\n\t if (this.done) {\n\t throw exception;\n\t }\n\n\t var context = this;\n\t function handle(loc, caught) {\n\t record.type = \"throw\";\n\t record.arg = exception;\n\t context.next = loc;\n\n\t if (caught) {\n\t // If the dispatched exception was caught by a catch block,\n\t // then let that catch block handle the exception normally.\n\t context.method = \"next\";\n\t context.arg = undefined;\n\t }\n\n\t return !! caught;\n\t }\n\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t var record = entry.completion;\n\n\t if (entry.tryLoc === \"root\") {\n\t // Exception thrown outside of any try block that could handle\n\t // it, so set the completion value of the entire function to\n\t // throw the exception.\n\t return handle(\"end\");\n\t }\n\n\t if (entry.tryLoc <= this.prev) {\n\t var hasCatch = hasOwn.call(entry, \"catchLoc\");\n\t var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n\t if (hasCatch && hasFinally) {\n\t if (this.prev < entry.catchLoc) {\n\t return handle(entry.catchLoc, true);\n\t } else if (this.prev < entry.finallyLoc) {\n\t return handle(entry.finallyLoc);\n\t }\n\n\t } else if (hasCatch) {\n\t if (this.prev < entry.catchLoc) {\n\t return handle(entry.catchLoc, true);\n\t }\n\n\t } else if (hasFinally) {\n\t if (this.prev < entry.finallyLoc) {\n\t return handle(entry.finallyLoc);\n\t }\n\n\t } else {\n\t throw new Error(\"try statement without catch or finally\");\n\t }\n\t }\n\t }\n\t },\n\n\t abrupt: function(type, arg) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.tryLoc <= this.prev &&\n\t hasOwn.call(entry, \"finallyLoc\") &&\n\t this.prev < entry.finallyLoc) {\n\t var finallyEntry = entry;\n\t break;\n\t }\n\t }\n\n\t if (finallyEntry &&\n\t (type === \"break\" ||\n\t type === \"continue\") &&\n\t finallyEntry.tryLoc <= arg &&\n\t arg <= finallyEntry.finallyLoc) {\n\t // Ignore the finally entry if control is not jumping to a\n\t // location outside the try/catch block.\n\t finallyEntry = null;\n\t }\n\n\t var record = finallyEntry ? finallyEntry.completion : {};\n\t record.type = type;\n\t record.arg = arg;\n\n\t if (finallyEntry) {\n\t this.method = \"next\";\n\t this.next = finallyEntry.finallyLoc;\n\t return ContinueSentinel;\n\t }\n\n\t return this.complete(record);\n\t },\n\n\t complete: function(record, afterLoc) {\n\t if (record.type === \"throw\") {\n\t throw record.arg;\n\t }\n\n\t if (record.type === \"break\" ||\n\t record.type === \"continue\") {\n\t this.next = record.arg;\n\t } else if (record.type === \"return\") {\n\t this.rval = this.arg = record.arg;\n\t this.method = \"return\";\n\t this.next = \"end\";\n\t } else if (record.type === \"normal\" && afterLoc) {\n\t this.next = afterLoc;\n\t }\n\n\t return ContinueSentinel;\n\t },\n\n\t finish: function(finallyLoc) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.finallyLoc === finallyLoc) {\n\t this.complete(entry.completion, entry.afterLoc);\n\t resetTryEntry(entry);\n\t return ContinueSentinel;\n\t }\n\t }\n\t },\n\n\t \"catch\": function(tryLoc) {\n\t for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n\t var entry = this.tryEntries[i];\n\t if (entry.tryLoc === tryLoc) {\n\t var record = entry.completion;\n\t if (record.type === \"throw\") {\n\t var thrown = record.arg;\n\t resetTryEntry(entry);\n\t }\n\t return thrown;\n\t }\n\t }\n\n\t // The context.catch method must only be called with a location\n\t // argument that corresponds to a known catch block.\n\t throw new Error(\"illegal catch attempt\");\n\t },\n\n\t delegateYield: function(iterable, resultName, nextLoc) {\n\t this.delegate = {\n\t iterator: values(iterable),\n\t resultName: resultName,\n\t nextLoc: nextLoc\n\t };\n\n\t if (this.method === \"next\") {\n\t // Deliberately forget the last sent value so that we don't\n\t // accidentally pass it on to the delegate.\n\t this.arg = undefined;\n\t }\n\n\t return ContinueSentinel;\n\t }\n\t };\n\t})(\n\t // In sloppy mode, unbound `this` refers to the global object, fallback to\n\t // Function constructor if we're in global strict mode. That is sadly a form\n\t // of indirect eval which violates Content Security Policy.\n\t (function() { return this })() || Function(\"return this\")()\n\t);\n\t});\n\n\t/**\n\t * Copyright (c) 2014-present, Facebook, Inc.\n\t *\n\t * This source code is licensed under the MIT license found in the\n\t * LICENSE file in the root directory of this source tree.\n\t */\n\n\t// This method of obtaining a reference to the global object needs to be\n\t// kept identical to the way it is obtained in runtime.js\n\tvar g = (function() { return this })() || Function(\"return this\")();\n\n\t// Use `getOwnPropertyNames` because not all browsers support calling\n\t// `hasOwnProperty` on the global `self` object in a worker. See #183.\n\tvar hadRuntime = g.regeneratorRuntime &&\n\t Object.getOwnPropertyNames(g).indexOf(\"regeneratorRuntime\") >= 0;\n\n\t// Save the old regeneratorRuntime in case it needs to be restored later.\n\tvar oldRuntime = hadRuntime && g.regeneratorRuntime;\n\n\t// Force reevalutation of runtime.js.\n\tg.regeneratorRuntime = undefined;\n\n\tvar runtimeModule = runtime;\n\n\tif (hadRuntime) {\n\t // Restore the original runtime.\n\t g.regeneratorRuntime = oldRuntime;\n\t} else {\n\t // Remove the global property added by runtime.js.\n\t try {\n\t delete g.regeneratorRuntime;\n\t } catch(e) {\n\t g.regeneratorRuntime = undefined;\n\t }\n\t}\n\n\tvar regenerator = runtimeModule;\n\n\tvar defaultOptions = {\n\t mode: 'index'\n\t};\n\n\tmodule.exports = /*#__PURE__*/regenerator.mark(function _callee(M, N, options) {\n\t var a, c, b, p, x, y, z, i, twiddle;\n\t return regenerator.wrap(function _callee$(_context) {\n\t while (1) {\n\t switch (_context.prev = _context.next) {\n\t case 0:\n\t twiddle = function twiddle() {\n\t var i, j, k;\n\t j = 1;\n\t while (p[j] <= 0) {\n\t j++;\n\t }\n\t if (p[j - 1] === 0) {\n\t for (i = j - 1; i !== 1; i--) {\n\t p[i] = -1;\n\t }\n\t p[j] = 0;\n\t x = z = 0;\n\t p[1] = 1;\n\t y = j - 1;\n\t } else {\n\t if (j > 1) {\n\t p[j - 1] = 0;\n\t }\n\t do {\n\t j++;\n\t } while (p[j] > 0);\n\t k = j - 1;\n\t i = j;\n\t while (p[i] === 0) {\n\t p[i++] = -1;\n\t }\n\t if (p[i] === -1) {\n\t p[i] = p[k];\n\t z = p[k] - 1;\n\t x = i - 1;\n\t y = k - 1;\n\t p[k] = -1;\n\t } else {\n\t if (i === p[0]) {\n\t return 0;\n\t } else {\n\t p[j] = p[i];\n\t z = p[i] - 1;\n\t p[i] = 0;\n\t x = j - 1;\n\t y = i - 1;\n\t }\n\t }\n\t }\n\t return 1;\n\t };\n\n\t options = Object.assign({}, defaultOptions, options);\n\t a = new Array(N);\n\t c = new Array(M);\n\t b = new Array(N);\n\t p = new Array(N + 2);\n\n\n\t // init a and b\n\t for (i = 0; i < N; i++) {\n\t a[i] = i;\n\t if (i < N - M) b[i] = 0;else b[i] = 1;\n\t }\n\n\t // init c\n\t for (i = 0; i < M; i++) {\n\t c[i] = N - M + i;\n\t }\n\n\t // init p\n\t for (i = 0; i < p.length; i++) {\n\t if (i === 0) p[i] = N + 1;else if (i <= N - M) p[i] = 0;else if (i <= N) p[i] = i - N + M;else p[i] = -2;\n\t }\n\n\t if (!(options.mode === 'index')) {\n\t _context.next = 20;\n\t break;\n\t }\n\n\t _context.next = 12;\n\t return c.slice();\n\n\t case 12:\n\t if (!twiddle()) {\n\t _context.next = 18;\n\t break;\n\t }\n\n\t c[z] = a[x];\n\t _context.next = 16;\n\t return c.slice();\n\n\t case 16:\n\t _context.next = 12;\n\t break;\n\n\t case 18:\n\t _context.next = 33;\n\t break;\n\n\t case 20:\n\t if (!(options.mode === 'mask')) {\n\t _context.next = 32;\n\t break;\n\t }\n\n\t _context.next = 23;\n\t return b.slice();\n\n\t case 23:\n\t if (!twiddle()) {\n\t _context.next = 30;\n\t break;\n\t }\n\n\t b[x] = 1;\n\t b[y] = 0;\n\t _context.next = 28;\n\t return b.slice();\n\n\t case 28:\n\t _context.next = 23;\n\t break;\n\n\t case 30:\n\t _context.next = 33;\n\t break;\n\n\t case 32:\n\t throw new Error('Invalid mode');\n\n\t case 33:\n\t case 'end':\n\t return _context.stop();\n\t }\n\t }\n\t }, _callee, this);\n\t});\n\n})));\n","/**\n * get folds indexes\n * @param {Array} features\n * @param {Number} k - number of folds, a\n */\nexport function getFolds(features, k = 5) {\n let N = features.length;\n let allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n\n let l = Math.floor(N / k);\n // create random k-folds\n let current = [];\n let folds = [];\n while (allIdx.length) {\n let randi = Math.floor(Math.random() * allIdx.length);\n current.push(allIdx[randi]);\n allIdx.splice(randi, 1);\n if (current.length === l) {\n folds.push(current);\n current = [];\n }\n }\n // we push the remaining to the last fold so that the total length is\n // preserved. Otherwise the Q2 will fail.\n if (current.length) current.forEach((e) => folds[k - 1].push(e));\n folds = folds.slice(0, k);\n\n let foldsIndex = folds.map((x, idx) => ({\n testIndex: x,\n trainIndex: [].concat(...folds.filter((el, idx2) => idx2 !== idx)),\n }));\n return foldsIndex;\n}\n","/**\n * A function to sample a dataset maintaining classes equilibrated\n * @param {Array} classVector - an array containing class or group information\n * @param {Number} fraction - a fraction of the class to sample\n * @return {Object} - an object with indexes\n */\n\nexport function sampleAClass(classVector, fraction) {\n // sort the vector\n let classVectorSorted = JSON.parse(JSON.stringify(classVector));\n let result = Array.from(Array(classVectorSorted.length).keys()).sort((a, b) =>\n classVectorSorted[a] < classVectorSorted[b]\n ? -1\n : (classVectorSorted[b] < classVectorSorted[a]) | 0,\n );\n classVectorSorted.sort((a, b) => (a < b ? -1 : (b < a) | 0));\n\n // counts the class elements\n let counts = {};\n classVectorSorted.forEach((x) => (counts[x] = (counts[x] || 0) + 1));\n\n // pick a few per class\n let indexOfSelected = [];\n\n Object.keys(counts).forEach((e, i) => {\n let shift = [];\n Object.values(counts).reduce((a, c, item) => (shift[item] = a + c), 0);\n\n let arr = [...Array(counts[e]).keys()];\n\n let r = [];\n for (let j = 0; j < Math.floor(counts[e] * fraction); j++) {\n let n = arr[Math.floor(Math.random() * arr.length)];\n r.push(n);\n let ind = arr.indexOf(n);\n arr.splice(ind, 1);\n }\n\n if (i === 0) {\n indexOfSelected = indexOfSelected.concat(r);\n } else {\n indexOfSelected = indexOfSelected.concat(r.map((x) => x + shift[i - 1]));\n }\n });\n\n // sort back the index\n let trainIndex = [];\n indexOfSelected.forEach((e) => trainIndex.push(result[e]));\n\n let testIndex = [];\n let mask = [];\n classVector.forEach((el, idx) => {\n if (trainIndex.includes(idx)) {\n mask.push(true);\n } else {\n mask.push(false);\n testIndex.push(idx);\n }\n });\n return { trainIndex, testIndex, mask };\n}\n","import ConfusionMatrix from 'ml-confusion-matrix';\nimport combinations from 'ml-combinations';\n\nimport { getFolds } from './getFolds.js';\n\nexport { sampleAClass } from './sampleAClass.js';\nexport { getFolds } from './getFolds.js';\n\n/**\n * Performs a leave-one-out cross-validation (LOO-CV) of the given samples. In LOO-CV, 1 observation is used as the\n * validation set while the rest is used as the training set. This is repeated once for each observation. LOO-CV is a\n * special case of LPO-CV. @see leavePout\n * @param {function} Classifier - The classifier's constructor to use for the cross validation. Expect ml-classifier\n * api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\n\nexport function leaveOneOut(Classifier, features, labels, classifierOptions) {\n if (typeof labels === 'function') {\n let callback = labels;\n labels = features;\n features = Classifier;\n return leavePOut(features, labels, 1, callback);\n }\n return leavePOut(Classifier, features, labels, classifierOptions, 1);\n}\n\n/**\n * Performs a leave-p-out cross-validation (LPO-CV) of the given samples. In LPO-CV, p observations are used as the\n * validation set while the rest is used as the training set. This is repeated as many times as there are possible\n * ways to combine p observations from the set (unordered without replacement). Be aware that for relatively small\n * data-set size this can require a very large number of training and testing to do!\n * @param {function} Classifier - The classifier's constructor to use for the cross validation. Expect ml-classifier\n * api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @param {number} p - The size of the validation sub-samples' set\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\nexport function leavePOut(Classifier, features, labels, classifierOptions, p) {\n let callback;\n if (typeof classifierOptions === 'function') {\n callback = classifierOptions;\n p = labels;\n labels = features;\n features = Classifier;\n }\n check(features, labels);\n const distinct = getDistinct(labels);\n const confusionMatrix = initMatrix(distinct.length, distinct.length);\n\n let N = features.length;\n let gen = combinations(p, N);\n let allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n for (const testIdx of gen) {\n let trainIdx = allIdx.slice();\n\n for (let i = testIdx.length - 1; i >= 0; i--) {\n trainIdx.splice(testIdx[i], 1);\n }\n\n if (callback) {\n validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n );\n } else {\n validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n );\n }\n }\n\n return new ConfusionMatrix(confusionMatrix, distinct);\n}\n\n/**\n * Performs k-fold cross-validation (KF-CV). KF-CV separates the data-set into k random equally sized partitions, and\n * uses each as a validation set, with all other partitions used in the training set. Observations left over from if k\n * does not divide the number of observations are left out of the cross-validation process.\n * @param {function} Classifier - The classifier's to use for the cross validation. Expect ml-classifier api.\n * @param {Array} features - The features for all samples of the data-set\n * @param {Array} labels - The classification class of all samples of the data-set\n * @param {object} classifierOptions - The classifier options with which the classifier should be instantiated.\n * @param {number} k - The number of partitions to create\n * @return {ConfusionMatrix} - The cross-validation confusion matrix\n */\nexport function kFold(Classifier, features, labels, classifierOptions, k) {\n let callback;\n if (typeof classifierOptions === 'function') {\n callback = classifierOptions;\n k = labels;\n labels = features;\n features = Classifier;\n }\n check(features, labels);\n const distinct = getDistinct(labels);\n const confusionMatrix = initMatrix(distinct.length, distinct.length);\n\n let folds = getFolds(features, k);\n\n for (let i = 0; i < folds.length; i++) {\n let testIdx = folds[i].testIndex;\n let trainIdx = folds[i].trainIndex;\n\n if (callback) {\n validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n );\n } else {\n validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n );\n }\n }\n\n return new ConfusionMatrix(confusionMatrix, distinct);\n}\n\nfunction check(features, labels) {\n if (features.length !== labels.length) {\n throw new Error('features and labels should have the same length');\n }\n}\n\nfunction initMatrix(rows, columns) {\n return new Array(rows).fill(0).map(() => new Array(columns).fill(0));\n}\n\nfunction getDistinct(arr) {\n let s = new Set();\n for (let i = 0; i < arr.length; i++) {\n s.add(arr[i]);\n }\n return Array.from(s);\n}\n\nfunction validate(\n Classifier,\n features,\n labels,\n classifierOptions,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n) {\n const { testFeatures, trainFeatures, testLabels, trainLabels } = getTrainTest(\n features,\n labels,\n testIdx,\n trainIdx,\n );\n\n let classifier;\n if (Classifier.prototype.train) {\n classifier = new Classifier(classifierOptions);\n classifier.train(trainFeatures, trainLabels);\n } else {\n classifier = new Classifier(trainFeatures, trainLabels, classifierOptions);\n }\n\n let predictedLabels = classifier.predict(testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction validateWithCallback(\n features,\n labels,\n testIdx,\n trainIdx,\n confusionMatrix,\n distinct,\n callback,\n) {\n const { testFeatures, trainFeatures, testLabels, trainLabels } = getTrainTest(\n features,\n labels,\n testIdx,\n trainIdx,\n );\n const predictedLabels = callback(trainFeatures, trainLabels, testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction updateConfusionMatrix(\n confusionMatrix,\n testLabels,\n predictedLabels,\n distinct,\n) {\n for (let i = 0; i < predictedLabels.length; i++) {\n const actualIdx = distinct.indexOf(testLabels[i]);\n const predictedIdx = distinct.indexOf(predictedLabels[i]);\n if (actualIdx < 0 || predictedIdx < 0) {\n // eslint-disable-next-line no-console\n console.warn(`ignore unknown predicted label ${predictedLabels[i]}`);\n }\n confusionMatrix[actualIdx][predictedIdx]++;\n }\n}\n\nexport function getTrainTest(features, labels, testIdx, trainIdx) {\n return {\n testFeatures: testIdx.map(function(index) {\n return features[index];\n }),\n trainFeatures: trainIdx.map(function(index) {\n return features[index];\n }),\n testLabels: testIdx.map(function(index) {\n return labels[index];\n }),\n trainLabels: trainIdx.map(function(index) {\n return labels[index];\n }),\n };\n}\n","import Matrix from 'ml-matrix';\n\nimport { norm } from './util/utils.js';\n\n/**\n * OPLS loop\n * @param {Array} x a matrix with features\n * @param {Array} y an array of labels (dependent variable)\n * @param {Object} options an object with options\n * @return {Object} an object with model (filteredX: err,\n loadingsXOrtho: pOrtho,\n scoresXOrtho: tOrtho,\n weightsXOrtho: wOrtho,\n weightsPred: w,\n loadingsXpred: p,\n scoresXpred: t,\n loadingsY:)\n */\nexport function OPLSNipals(x, y, options = {}) {\n const { numberOSC = 100 } = options;\n\n let X = Matrix.checkMatrix(x);\n let Y = Matrix.checkMatrix(y);\n\n let u = Y.getColumnVector(0);\n\n let diff = 1;\n let t, c, w, uNew;\n for (let i = 0; i < numberOSC && diff > 1e-10; i++) {\n w = u\n .transpose()\n .mmul(X)\n .div(\n u\n .transpose()\n .mmul(u)\n .get(0, 0),\n );\n w = w.transpose().div(norm(w));\n\n t = X.mmul(w).div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n ); // t_h paso 3\n\n // calc loading\n c = t\n .transpose()\n .mmul(Y)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n\n // calc new u and compare with one in previus iteration (stop criterion)\n uNew = Y.mmul(c.transpose());\n uNew = uNew.div(\n c\n .transpose()\n .mmul(c)\n .get(0, 0),\n );\n\n if (i > 0) {\n diff =\n uNew\n .clone()\n .sub(u)\n .pow(2)\n .sum() /\n uNew\n .clone()\n .pow(2)\n .sum();\n }\n\n u = uNew.clone();\n }\n\n // calc loadings\n let p = t\n .transpose()\n .mmul(X)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n\n let wOrtho = p.clone().sub(\n w\n .transpose()\n .mmul(p.transpose())\n .div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n )\n .mmul(w.transpose()),\n );\n wOrtho.div(norm(wOrtho));\n\n // orthogonal scores\n let tOrtho = X.mmul(wOrtho.transpose()).div(\n wOrtho.mmul(wOrtho.transpose()).get(0, 0),\n );\n\n // orthogonal loadings\n let pOrtho = tOrtho\n .transpose()\n .mmul(X)\n .div(\n tOrtho\n .transpose()\n .mmul(tOrtho)\n .get(0, 0),\n );\n\n // filtered data\n let err = X.clone().sub(tOrtho.mmul(pOrtho));\n return {\n filteredX: err,\n weightsXOrtho: wOrtho,\n loadingsXOrtho: pOrtho,\n scoresXOrtho: tOrtho,\n weightsXPred: w,\n loadingsXpred: p,\n scoresXpred: t,\n loadingsY: c,\n };\n}\n","import { Matrix } from 'ml-matrix';\n\n/**\n * Get total sum of square\n * @param {Array} x an array\n * @return {Number} - the sum of the squares\n */\nexport function tss(x) {\n return Matrix.mul(x, x).sum();\n}\n","import { Matrix, NIPALS } from 'ml-matrix';\nimport ConfusionMatrix from 'ml-confusion-matrix';\nimport { getFolds } from 'ml-cross-validation';\n\nimport { OPLSNipals } from './OPLSNipals.js';\nimport { tss } from './util/tss.js';\n\n/**\n * Creates new OPLS (orthogonal partial latent structures) from features and labels.\n * @param {Matrix} data - matrix containing data (X).\n * @param {Array} labels - 1D Array containing metadata (Y).\n * @param {Object} [options]\n * @param {number} [options.nComp = 3] - number of latent structures computed.\n * @param {boolean} [options.center = true] - should the data be centered (subtract the mean).\n * @param {boolean} [options.scale = false] - should the data be scaled (divide by the standard deviation).\n * @param {Array} [options.cvFolds = []] - allows to provide folds as 2D array for testing purpose.\n * */\n\nexport class OPLS {\n constructor(data, labels, options = {}) {\n if (data === true) {\n const opls = options;\n this.center = opls.center;\n this.scale = opls.scale;\n this.means = opls.means;\n this.meansY = opls.meansY;\n this.stdevs = opls.stdevs;\n this.stdevs = opls.stdevsY;\n this.model = opls.model;\n this.tCV = opls.tCV;\n this.tOrthCV = opls.tOrthCV;\n this.yHatCV = opls.yHatCV;\n this.mode = opls.mode;\n return;\n }\n\n let features = data.clone();\n // set default values\n // cvFolds allows to define folds for testing purpose\n const { nComp = 3, center = true, scale = true, cvFolds = [] } = options;\n\n let group;\n if (typeof labels[0] === 'number') {\n // numeric labels: OPLS regression is used\n this.mode = 'regression';\n group = Matrix.from1DArray(labels.length, 1, labels);\n } else if (typeof labels[0] === 'string') {\n // non-numeric labels: OPLS-DA is used\n this.mode = 'discriminantAnalysis';\n group = labels;\n throw new Error('discriminant analysis is not yet supported');\n }\n\n // check types of features and labels\n if (features.constructor.name !== 'Matrix') {\n throw new TypeError('features must be of class Matrix');\n }\n // getting center and scale the features (all)\n this.center = center;\n if (this.center) {\n this.means = features.mean('column');\n this.meansY = group.mean('column');\n } else {\n this.stdevs = null;\n }\n this.scale = scale;\n if (this.scale) {\n this.stdevs = features.standardDeviation('column');\n this.stdevsY = group.standardDeviation('column');\n } else {\n this.means = null;\n }\n\n // check and remove for features with sd = 0 TODO here\n // check opls.R line 70\n\n let folds;\n if (cvFolds.length > 0) {\n folds = cvFolds;\n } else {\n folds = getFolds(labels, 5);\n }\n\n let Q2 = [];\n this.model = [];\n\n this.tCV = [];\n this.tOrthCV = [];\n this.yHatCV = [];\n let oplsCV = [];\n\n let modelNC = [];\n\n // this code could be made more efficient by reverting the order of the loops\n // this is a legacy loop to be consistent with R code from MetaboMate package\n // this allows for having statistic (R2) from CV to decide wether to continue\n // with more latent structures\n let nc;\n for (nc = 0; nc < nComp; nc++) {\n let yHatk = new Matrix(group.rows, 1);\n let tPredk = new Matrix(group.rows, 1);\n let tOrthk = new Matrix(group.rows, 1);\n let oplsk = [];\n\n let f = 0;\n for (let fold of folds) {\n let trainTest = this._getTrainTest(features, group, fold);\n let testXk = trainTest.testFeatures;\n let Xk = trainTest.trainFeatures;\n let Yk = trainTest.trainLabels;\n\n // determine center and scale of training set\n let dataCenter = Xk.mean('column');\n let dataSD = Xk.standardDeviation('column');\n\n // center and scale training set\n if (center) {\n Xk.center('column');\n Yk.center('column');\n }\n\n if (scale) {\n Xk.scale('column');\n Yk.scale('column');\n }\n\n // perform opls\n if (nc === 0) {\n oplsk[f] = OPLSNipals(Xk, Yk);\n } else {\n oplsk[f] = OPLSNipals(oplsCV[nc - 1][f].filteredX, Yk);\n }\n // store model for next component\n oplsCV[nc] = oplsk;\n\n let plsCV = new NIPALS(oplsk[f].filteredX, { Y: Yk });\n\n // scaling the test dataset with respect to the train\n testXk.center('column', { center: dataCenter });\n testXk.scale('column', { scale: dataSD });\n\n let Eh = testXk;\n // removing the orthogonal components from PLS\n let scores;\n for (let idx = 0; idx < nc + 1; idx++) {\n scores = Eh.mmul(oplsCV[idx][f].weightsXOrtho.transpose()); // ok\n Eh.sub(scores.mmul(oplsCV[idx][f].loadingsXOrtho));\n }\n\n // prediction\n let tPred = Eh.mmul(plsCV.w.transpose());\n // this should be summed over ncomp (pls_prediction.R line 23)\n let yHat = tPred.mmul(plsCV.betas); // ok\n\n // adding all prediction from all folds\n for (let i = 0; i < fold.testIndex.length; i++) {\n yHatk.setRow(fold.testIndex[i], [yHat.get(i, 0)]);\n tPredk.setRow(fold.testIndex[i], [tPred.get(i, 0)]);\n tOrthk.setRow(fold.testIndex[i], [scores.get(i, 0)]);\n }\n f++;\n } // end of loop over folds\n\n this.tCV.push(tPredk);\n this.tOrthCV.push(tOrthk);\n this.yHatCV.push(yHatk);\n\n // calculate Q2y for all the prediction (all folds)\n // ROC for DA is not implemented (check opls.R line 183) TODO\n if (this.mode === 'regression') {\n let tssy = tss(group.center('column').scale('column'));\n let press = tss(group.clone().sub(yHatk));\n let Q2y = 1 - press / tssy;\n Q2.push(Q2y);\n } else if (this.mode === 'discriminantAnalysis') {\n throw new Error('discriminant analysis is not yet supported');\n }\n\n // calculate the R2y for the complete data\n if (nc === 0) {\n modelNC = this._predictAll(features, group);\n } else {\n modelNC = this._predictAll(\n modelNC.xRes,\n group,\n (options = { scale: false, center: false }),\n );\n }\n\n // adding the predictive statistics from CV\n modelNC.Q2y = Q2;\n // store the model for each component\n this.model.push(modelNC);\n // console.warn(`OPLS iteration over # of Components: ${nc + 1}`);\n } // end of loop over nc\n\n // store scores from CV\n let tCV = this.tCV;\n let tOrthCV = this.tOrthCV;\n\n let m = this.model[nc - 1];\n let XOrth = m.XOrth;\n let FeaturesCS = features.center('column').scale('column');\n let labelsCS = group.center('column').scale('column');\n let Xres = FeaturesCS.clone().sub(XOrth);\n let plsCall = new NIPALS(Xres, { Y: labelsCS });\n let E = Xres.clone().sub(plsCall.t.mmul(plsCall.p));\n\n let R2x = this.model.map((x) => x.R2x);\n let R2y = this.model.map((x) => x.R2y);\n\n this.output = {\n Q2y: Q2,\n R2x,\n R2y,\n tPred: m.plsC.t,\n pPred: m.plsC.p,\n wPred: m.plsC.w,\n betasPred: m.plsC.betas,\n Qpc: m.plsC.q,\n tCV,\n tOrthCV,\n tOrth: m.tOrth,\n pOrth: m.pOrth,\n wOrth: m.wOrth,\n XOrth,\n yHat: m.totalPred,\n Yres: m.plsC.yResidual,\n E,\n };\n }\n\n /**\n * get access to all the computed elements\n * Mainly for debug and testing\n * @return {Object} output object\n */\n getLogs() {\n return this.output;\n }\n\n getScores() {\n let scoresX = this.tCV.map((x) => x.to1DArray());\n let scoresY = this.tOrthCV.map((x) => x.to1DArray());\n return { scoresX, scoresY };\n }\n\n /**\n * Load an OPLS model from JSON\n * @param {Object} model\n * @return {OPLS}\n */\n static load(model) {\n if (typeof model.name !== 'string') {\n throw new TypeError('model must have a name property');\n }\n if (model.name !== 'OPLS') {\n throw new RangeError(`invalid model: ${model.name}`);\n }\n return new OPLS(true, [], model);\n }\n\n /**\n * Export the current model to a JSON object\n * @return {Object} model\n */\n toJSON() {\n return {\n name: 'OPLS',\n center: this.center,\n scale: this.scale,\n means: this.means,\n stdevs: this.stdevs,\n model: this.model,\n tCV: this.tCV,\n tOrthCV: this.tOrthCV,\n yHatCV: this.yHatCV,\n };\n }\n\n /**\n * Predict scores for new data\n * @param {Matrix} features - a matrix containing new data\n * @param {Object} [options]\n * @param {Array} [options.trueLabel] - an array with true values to compute confusion matrix\n * @param {Number} [options.nc] - the number of components to be used\n * @return {Object} - predictions\n */\n predict(newData, options = {}) {\n let { trueLabels = [], nc = 1 } = options;\n let labels = [];\n if (trueLabels.length > 0) {\n trueLabels = Matrix.from1DArray(trueLabels.length, 1, trueLabels);\n labels = trueLabels.clone();\n }\n\n let features = newData.clone();\n\n // scaling the test dataset with respect to the train\n if (this.center) {\n features.center('column', { center: this.means });\n if (labels.rows > 0 && this.mode === 'regression') {\n labels.center('column', { center: this.meansY });\n }\n }\n if (this.scale) {\n features.scale('column', { scale: this.stdevs });\n if (labels.rows > 0 && this.mode === 'regression') {\n labels.scale('column', { scale: this.stdevsY });\n }\n }\n\n let Eh = features.clone();\n // removing the orthogonal components from PLS\n let tOrth;\n let wOrth;\n let pOrth;\n let yHat;\n let tPred;\n\n for (let idx = 0; idx < nc; idx++) {\n wOrth = this.model[idx].wOrth.transpose();\n pOrth = this.model[idx].pOrth;\n tOrth = Eh.mmul(wOrth);\n Eh.sub(tOrth.mmul(pOrth));\n // prediction\n tPred = Eh.mmul(this.model[idx].plsC.w.transpose());\n // this should be summed over ncomp (pls_prediction.R line 23)\n yHat = tPred.mmul(this.model[idx].plsC.betas);\n }\n\n if (labels.rows > 0) {\n if (this.mode === 'regression') {\n let tssy = tss(labels);\n let press = tss(labels.clone().sub(yHat));\n let Q2y = 1 - press / tssy;\n\n return { tPred, tOrth, yHat, Q2y };\n } else if (this.mode === 'discriminantAnalysis') {\n let confusionMatrix = [];\n confusionMatrix = ConfusionMatrix.fromLabels(\n trueLabels.to1DArray(),\n yHat.to1DArray(),\n );\n\n return { tPred, tOrth, yHat, confusionMatrix };\n }\n } else {\n return { tPred, tOrth, yHat };\n }\n }\n\n _predictAll(features, labels, options = {}) {\n // cannot use the global this.center here\n // since it is used in the NC loop and\n // centering and scaling should only be\n // performed once\n const { center = true, scale = true } = options;\n\n if (center) {\n features.center('column');\n labels.center('column');\n }\n\n if (scale) {\n features.scale('column');\n labels.scale('column');\n // reevaluate tssy and tssx after scaling\n // must be global because re-used for next nc iteration\n // tssx is only evaluate the first time\n this.tssy = tss(labels);\n this.tssx = tss(features);\n }\n\n let oplsC = OPLSNipals(features, labels);\n let plsC = new NIPALS(oplsC.filteredX, { Y: labels });\n\n let tPred = oplsC.filteredX.mmul(plsC.w.transpose());\n let yHat = tPred.mmul(plsC.betas);\n\n let rss = tss(labels.clone().sub(yHat));\n let R2y = 1 - rss / this.tssy;\n\n let xEx = plsC.t.mmul(plsC.p);\n let rssx = tss(xEx);\n let R2x = rssx / this.tssx;\n\n return {\n R2y,\n R2x,\n xRes: oplsC.filteredX,\n tOrth: oplsC.scoresXOrtho,\n pOrth: oplsC.loadingsXOrtho,\n wOrth: oplsC.weightsXOrtho,\n tPred: tPred,\n totalPred: yHat,\n XOrth: oplsC.scoresXOrtho.mmul(oplsC.loadingsXOrtho),\n oplsC,\n plsC,\n };\n }\n /**\n *\n * @param {*} X - dataset matrix object\n * @param {*} group - labels matrix object\n * @param {*} index - train and test index (output from getFold())\n */\n _getTrainTest(X, group, index) {\n let testFeatures = new Matrix(index.testIndex.length, X.columns);\n let testLabels = new Matrix(index.testIndex.length, 1);\n index.testIndex.forEach((el, idx) => {\n testFeatures.setRow(idx, X.getRow(el));\n testLabels.setRow(idx, group.getRow(el));\n });\n\n let trainFeatures = new Matrix(index.trainIndex.length, X.columns);\n let trainLabels = new Matrix(index.trainIndex.length, 1);\n index.trainIndex.forEach((el, idx) => {\n trainFeatures.setRow(idx, X.getRow(el));\n trainLabels.setRow(idx, group.getRow(el));\n });\n\n return {\n trainFeatures,\n testFeatures,\n trainLabels,\n testLabels,\n };\n }\n}\n","'use strict';\n\nvar mlMatrix = require('ml-matrix');\n\nfunction logistic(val) {\n return 1 / (1 + Math.exp(-val));\n}\n\nfunction expELU(val, param) {\n return val < 0 ? param * (Math.exp(val) - 1) : val;\n}\n\nfunction softExponential(val, param) {\n if (param < 0) {\n return -Math.log(1 - param * (val + param)) / param;\n }\n if (param > 0) {\n return ((Math.exp(param * val) - 1) / param) + param;\n }\n return val;\n}\n\nfunction softExponentialPrime(val, param) {\n if (param < 0) {\n return 1 / (1 - param * (param + val));\n } else {\n return Math.exp(param * val);\n }\n}\n\nconst ACTIVATION_FUNCTIONS = {\n tanh: {\n activation: Math.tanh,\n derivate: (val) => 1 - (val * val)\n },\n identity: {\n activation: (val) => val,\n derivate: () => 1\n },\n logistic: {\n activation: logistic,\n derivate: (val) => logistic(val) * (1 - logistic(val))\n },\n arctan: {\n activation: Math.atan,\n derivate: (val) => 1 / (val * val + 1)\n },\n softsign: {\n activation: (val) => val / (1 + Math.abs(val)),\n derivate: (val) => 1 / ((1 + Math.abs(val)) * (1 + Math.abs(val)))\n },\n relu: {\n activation: (val) => (val < 0 ? 0 : val),\n derivate: (val) => (val < 0 ? 0 : 1)\n },\n softplus: {\n activation: (val) => Math.log(1 + Math.exp(val)),\n derivate: (val) => 1 / (1 + Math.exp(-val))\n },\n bent: {\n activation: (val) => ((Math.sqrt(val * val + 1) - 1) / 2) + val,\n derivate: (val) => (val / (2 * Math.sqrt(val * val + 1))) + 1\n },\n sinusoid: {\n activation: Math.sin,\n derivate: Math.cos\n },\n sinc: {\n activation: (val) => (val === 0 ? 1 : Math.sin(val) / val),\n derivate: (val) => (val === 0 ? 0 : (Math.cos(val) / val) - (Math.sin(val) / (val * val)))\n },\n gaussian: {\n activation: (val) => Math.exp(-(val * val)),\n derivate: (val) => -2 * val * Math.exp(-(val * val))\n },\n 'parametric-relu': {\n activation: (val, param) => (val < 0 ? param * val : val),\n derivate: (val, param) => (val < 0 ? param : 1)\n },\n 'exponential-elu': {\n activation: expELU,\n derivate: (val, param) => (val < 0 ? expELU(val, param) + param : 1)\n },\n 'soft-exponential': {\n activation: softExponential,\n derivate: softExponentialPrime\n }\n};\n\nclass Layer {\n /**\n * @private\n * Create a new layer with the given options\n * @param {object} options\n * @param {number} [options.inputSize] - Number of conections that enter the neurons.\n * @param {number} [options.outputSize] - Number of conections that leave the neurons.\n * @param {number} [options.regularization] - Regularization parameter.\n * @param {number} [options.epsilon] - Learning rate parameter.\n * @param {string} [options.activation] - Activation function parameter from the FeedForwardNeuralNetwork class.\n * @param {number} [options.activationParam] - Activation parameter if needed.\n */\n constructor(options) {\n this.inputSize = options.inputSize;\n this.outputSize = options.outputSize;\n this.regularization = options.regularization;\n this.epsilon = options.epsilon;\n this.activation = options.activation;\n this.activationParam = options.activationParam;\n\n var selectedFunction = ACTIVATION_FUNCTIONS[options.activation];\n var params = selectedFunction.activation.length;\n\n var actFunction = params > 1 ? (val) => selectedFunction.activation(val, options.activationParam) : selectedFunction.activation;\n var derFunction = params > 1 ? (val) => selectedFunction.derivate(val, options.activationParam) : selectedFunction.derivate;\n\n this.activationFunction = function (i, j) {\n this.set(i, j, actFunction(this.get(i, j)));\n };\n this.derivate = function (i, j) {\n this.set(i, j, derFunction(this.get(i, j)));\n };\n\n if (options.model) {\n // load model\n this.W = mlMatrix.Matrix.checkMatrix(options.W);\n this.b = mlMatrix.Matrix.checkMatrix(options.b);\n } else {\n // default constructor\n this.W = mlMatrix.Matrix.rand(this.inputSize, this.outputSize);\n this.b = mlMatrix.Matrix.zeros(1, this.outputSize);\n\n this.W.apply(function (i, j) {\n this.set(i, j, this.get(i, j) / Math.sqrt(options.inputSize));\n });\n }\n }\n\n /**\n * @private\n * propagate the given input through the current layer.\n * @param {Matrix} X - input.\n * @return {Matrix} output at the current layer.\n */\n forward(X) {\n var z = X.mmul(this.W).addRowVector(this.b);\n z.apply(this.activationFunction);\n this.a = z.clone();\n return z;\n }\n\n /**\n * @private\n * apply backpropagation algorithm at the current layer\n * @param {Matrix} delta - delta values estimated at the following layer.\n * @param {Matrix} a - 'a' values from the following layer.\n * @return {Matrix} the new delta values for the next layer.\n */\n backpropagation(delta, a) {\n this.dW = a.transpose().mmul(delta);\n this.db = mlMatrix.Matrix.rowVector(delta.sum('column'));\n\n var aCopy = a.clone();\n return delta.mmul(this.W.transpose()).mul(aCopy.apply(this.derivate));\n }\n\n /**\n * @private\n * Function that updates the weights at the current layer with the derivatives.\n */\n update() {\n this.dW.add(this.W.clone().mul(this.regularization));\n this.W.add(this.dW.mul(-this.epsilon));\n this.b.add(this.db.mul(-this.epsilon));\n }\n\n /**\n * @private\n * Export the current layer to JSON.\n * @return {object} model\n */\n toJSON() {\n return {\n model: 'Layer',\n inputSize: this.inputSize,\n outputSize: this.outputSize,\n regularization: this.regularization,\n epsilon: this.epsilon,\n activation: this.activation,\n W: this.W,\n b: this.b\n };\n }\n\n /**\n * @private\n * Creates a new Layer with the given model.\n * @param {object} model\n * @return {Layer}\n */\n static load(model) {\n if (model.model !== 'Layer') {\n throw new RangeError('the current model is not a Layer model');\n }\n return new Layer(model);\n }\n}\n\nclass OutputLayer extends Layer {\n constructor(options) {\n super(options);\n\n this.activationFunction = function (i, j) {\n this.set(i, j, Math.exp(this.get(i, j)));\n };\n }\n\n static load(model) {\n if (model.model !== 'Layer') {\n throw new RangeError('the current model is not a Layer model');\n }\n\n return new OutputLayer(model);\n }\n}\n\nclass FeedForwardNeuralNetworks {\n /**\n * Create a new Feedforward neural network model.\n * @class FeedForwardNeuralNetworks\n * @param {object} [options]\n * @param {Array} [options.hiddenLayers=[10]] - Array that contains the sizes of the hidden layers.\n * @param {number} [options.iterations=50] - Number of iterations at the training step.\n * @param {number} [options.learningRate=0.01] - Learning rate of the neural net (also known as epsilon).\n * @param {number} [options.regularization=0.01] - Regularization parameter af the neural net.\n * @param {string} [options.activation='tanh'] - activation function to be used. (options: 'tanh'(default),\n * 'identity', 'logistic', 'arctan', 'softsign', 'relu', 'softplus', 'bent', 'sinusoid', 'sinc', 'gaussian').\n * (single-parametric options: 'parametric-relu', 'exponential-relu', 'soft-exponential').\n * @param {number} [options.activationParam=1] - if the selected activation function needs a parameter.\n */\n constructor(options) {\n options = options || {};\n if (options.model) {\n // load network\n this.hiddenLayers = options.hiddenLayers;\n this.iterations = options.iterations;\n this.learningRate = options.learningRate;\n this.regularization = options.regularization;\n this.dicts = options.dicts;\n this.activation = options.activation;\n this.activationParam = options.activationParam;\n this.model = new Array(options.layers.length);\n\n for (var i = 0; i < this.model.length - 1; ++i) {\n this.model[i] = Layer.load(options.layers[i]);\n }\n this.model[this.model.length - 1] = OutputLayer.load(options.layers[this.model.length - 1]);\n } else {\n // default constructor\n this.hiddenLayers = options.hiddenLayers || [10];\n this.iterations = options.iterations || 50;\n\n this.learningRate = options.learningRate || 0.01;\n this.regularization = options.regularization || 0.01;\n\n this.activation = options.activation || 'tanh';\n this.activationParam = options.activationParam || 1;\n if (!(this.activation in Object.keys(ACTIVATION_FUNCTIONS))) {\n this.activation = 'tanh';\n }\n }\n }\n\n /**\n * @private\n * Function that build and initialize the neural net.\n * @param {number} inputSize - total of features to fit.\n * @param {number} outputSize - total of labels of the prediction set.\n */\n buildNetwork(inputSize, outputSize) {\n var size = 2 + (this.hiddenLayers.length - 1);\n this.model = new Array(size);\n\n // input layer\n this.model[0] = new Layer({\n inputSize: inputSize,\n outputSize: this.hiddenLayers[0],\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n\n // hidden layers\n for (var i = 1; i < this.hiddenLayers.length; ++i) {\n this.model[i] = new Layer({\n inputSize: this.hiddenLayers[i - 1],\n outputSize: this.hiddenLayers[i],\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n }\n\n // output layer\n this.model[size - 1] = new OutputLayer({\n inputSize: this.hiddenLayers[this.hiddenLayers.length - 1],\n outputSize: outputSize,\n activation: this.activation,\n activationParam: this.activationParam,\n regularization: this.regularization,\n epsilon: this.learningRate\n });\n }\n\n /**\n * Train the neural net with the given features and labels.\n * @param {Matrix|Array} features\n * @param {Matrix|Array} labels\n */\n train(features, labels) {\n features = mlMatrix.Matrix.checkMatrix(features);\n this.dicts = dictOutputs(labels);\n\n var inputSize = features.columns;\n var outputSize = Object.keys(this.dicts.inputs).length;\n\n if (!this.model) {\n this.buildNetwork(inputSize, outputSize);\n }\n\n for (var i = 0; i < this.iterations; ++i) {\n var probabilities = this.propagate(features);\n this.backpropagation(features, labels, probabilities);\n }\n }\n\n /**\n * @private\n * Propagate the input(training set) and retrives the probabilities of each class.\n * @param {Matrix} X\n * @return {Matrix} probabilities of each class.\n */\n propagate(X) {\n var input = X;\n for (var i = 0; i < this.model.length; ++i) {\n input = this.model[i].forward(input);\n }\n\n // get probabilities\n return input.divColumnVector(input.sum('row'));\n }\n\n /**\n * @private\n * Function that applies the backpropagation algorithm on each layer of the network\n * in order to fit the features and labels.\n * @param {Matrix} features\n * @param {Array} labels\n * @param {Matrix} probabilities - probabilities of each class of the feature set.\n */\n backpropagation(features, labels, probabilities) {\n for (var i = 0; i < probabilities.rows; ++i) {\n probabilities.set(i, this.dicts.inputs[labels[i]], probabilities.get(i, this.dicts.inputs[labels[i]]) - 1);\n }\n\n // remember, the last delta doesn't matter\n var delta = probabilities;\n for (i = this.model.length - 1; i >= 0; --i) {\n var a = i > 0 ? this.model[i - 1].a : features;\n delta = this.model[i].backpropagation(delta, a);\n }\n\n for (i = 0; i < this.model.length; ++i) {\n this.model[i].update();\n }\n }\n\n /**\n * Predict the output given the feature set.\n * @param {Array|Matrix} features\n * @return {Array}\n */\n predict(features) {\n features = mlMatrix.Matrix.checkMatrix(features);\n var outputs = new Array(features.rows);\n var probabilities = this.propagate(features);\n for (var i = 0; i < features.rows; ++i) {\n outputs[i] = this.dicts.outputs[probabilities.maxRowIndex(i)[1]];\n }\n\n return outputs;\n }\n\n /**\n * Export the current model to JSON.\n * @return {object} model\n */\n toJSON() {\n var model = {\n model: 'FNN',\n hiddenLayers: this.hiddenLayers,\n iterations: this.iterations,\n learningRate: this.learningRate,\n regularization: this.regularization,\n activation: this.activation,\n activationParam: this.activationParam,\n dicts: this.dicts,\n layers: new Array(this.model.length)\n };\n\n for (var i = 0; i < this.model.length; ++i) {\n model.layers[i] = this.model[i].toJSON();\n }\n\n return model;\n }\n\n /**\n * Load a Feedforward Neural Network with the current model.\n * @param {object} model\n * @return {FeedForwardNeuralNetworks}\n */\n static load(model) {\n if (model.model !== 'FNN') {\n throw new RangeError('the current model is not a feed forward network');\n }\n\n return new FeedForwardNeuralNetworks(model);\n }\n}\n\n/**\n * @private\n * Method that given an array of labels(predictions), returns two dictionaries, one to transform from labels to\n * numbers and other in the reverse way\n * @param {Array} array\n * @return {object}\n */\nfunction dictOutputs(array) {\n var inputs = {};\n var outputs = {};\n var index = 0;\n for (var i = 0; i < array.length; i += 1) {\n if (inputs[array[i]] === undefined) {\n inputs[array[i]] = index;\n outputs[index] = array[i];\n index++;\n }\n }\n\n return {\n inputs: inputs,\n outputs: outputs\n };\n}\n\nmodule.exports = FeedForwardNeuralNetworks;\n","function NodeSquare(x, y, weights, som) {\n this.x = x;\n this.y = y;\n this.weights = weights;\n this.som = som;\n this.neighbors = {};\n}\n\nNodeSquare.prototype.adjustWeights = function adjustWeights(target, learningRate, influence) {\n for (var i = 0, ii = this.weights.length; i < ii; i++) {\n this.weights[i] += learningRate * influence * (target[i] - this.weights[i]);\n }\n};\n\nNodeSquare.prototype.getDistance = function getDistance(otherNode) {\n return Math.max(Math.abs(this.x - otherNode.x), Math.abs(this.y - otherNode.y));\n};\n\nNodeSquare.prototype.getDistanceTorus = function getDistanceTorus(otherNode) {\n var distX = Math.abs(this.x - otherNode.x),\n distY = Math.abs(this.y - otherNode.y);\n return Math.max(Math.min(distX, this.som.gridDim.x - distX), Math.min(distY, this.som.gridDim.y - distY));\n};\n\nNodeSquare.prototype.getNeighbors = function getNeighbors(xy) {\n if (!this.neighbors[xy]) {\n this.neighbors[xy] = new Array(2);\n\n // left or bottom neighbor\n var v;\n if (this[xy] > 0) {\n v = this[xy] - 1;\n } else if (this.som.torus) {\n v = this.som.gridDim[xy] - 1\n }\n if (typeof v !== 'undefined') {\n var x, y;\n if (xy === 'x') {\n x = v;\n y = this.y;\n } else {\n x = this.x;\n y = v;\n }\n this.neighbors[xy][0] = this.som.nodes[x][y];\n }\n\n // top or right neighbor\n var w;\n if (this[xy] < (this.som.gridDim[xy] - 1)) {\n w = this[xy] + 1;\n } else if (this.som.torus) {\n w = 0;\n }\n if (typeof w !== 'undefined') {\n if (xy === 'x') {\n x = w;\n y = this.y;\n } else {\n x = this.x;\n y = w;\n }\n this.neighbors[xy][1] = this.som.nodes[x][y];\n }\n }\n return this.neighbors[xy];\n};\n\nNodeSquare.prototype.getPos = function getPos(xy, element) {\n var neighbors = this.getNeighbors(xy),\n distance = this.som.distance,\n bestNeighbor,\n direction;\n if(neighbors[0]) {\n if (neighbors[1]) {\n var dist1 = distance(element, neighbors[0].weights),\n dist2 = distance(element, neighbors[1].weights);\n if(dist1 < dist2) {\n bestNeighbor = neighbors[0];\n direction = -1;\n } else {\n bestNeighbor = neighbors[1];\n direction = 1;\n }\n } else {\n bestNeighbor = neighbors[0];\n direction = -1;\n }\n } else {\n bestNeighbor = neighbors[1];\n direction = 1;\n }\n var simA = 1 - distance(element, this.weights),\n simB = 1 - distance(element, bestNeighbor.weights);\n var factor = ((simA - simB) / (2 - simA - simB));\n return 0.5 + 0.5 * factor * direction;\n};\n\nNodeSquare.prototype.getPosition = function getPosition(element) {\n return [\n this.getPos('x', element),\n this.getPos('y', element)\n ];\n};\n\nmodule.exports = NodeSquare;","var NodeSquare = require('./node-square');\n\nfunction NodeHexagonal(x, y, weights, som) {\n\n NodeSquare.call(this, x, y, weights, som);\n\n this.hX = x - Math.floor(y / 2);\n this.z = 0 - this.hX - y;\n\n}\n\nNodeHexagonal.prototype = new NodeSquare;\nNodeHexagonal.prototype.constructor = NodeHexagonal;\n\nNodeHexagonal.prototype.getDistance = function getDistanceHexagonal(otherNode) {\n return Math.max(Math.abs(this.hX - otherNode.hX), Math.abs(this.y - otherNode.y), Math.abs(this.z - otherNode.z));\n};\n\nNodeHexagonal.prototype.getDistanceTorus = function getDistanceTorus(otherNode) {\n var distX = Math.abs(this.hX - otherNode.hX),\n distY = Math.abs(this.y - otherNode.y),\n distZ = Math.abs(this.z - otherNode.z);\n return Math.max(Math.min(distX, this.som.gridDim.x - distX), Math.min(distY, this.som.gridDim.y - distY), Math.min(distZ, this.som.gridDim.z - distZ));\n};\n\nNodeHexagonal.prototype.getPosition = function getPosition() {\n throw new Error('Unimplemented : cannot get position of the points for hexagonal grid');\n};\n\nmodule.exports = NodeHexagonal;","'use strict';\n\nvar NodeSquare = require('./node-square'),\n NodeHexagonal = require('./node-hexagonal');\n\nvar defaultOptions = {\n fields: 3,\n randomizer: Math.random,\n distance: squareEuclidean,\n iterations: 10,\n learningRate: 0.1,\n gridType: 'rect',\n torus: true,\n method: 'random'\n};\n\nfunction SOM(x, y, options, reload) {\n\n this.x = x;\n this.y = y;\n\n options = options || {};\n this.options = {};\n for (var i in defaultOptions) {\n if (options.hasOwnProperty(i)) {\n this.options[i] = options[i];\n } else {\n this.options[i] = defaultOptions[i];\n }\n }\n\n if (typeof this.options.fields === 'number') {\n this.numWeights = this.options.fields;\n } else if (Array.isArray(this.options.fields)) {\n this.numWeights = this.options.fields.length;\n var converters = getConverters(this.options.fields);\n this.extractor = converters.extractor;\n this.creator = converters.creator;\n } else {\n throw new Error('Invalid fields definition');\n }\n\n if (this.options.gridType === 'rect') {\n this.nodeType = NodeSquare;\n this.gridDim = {\n x: x,\n y: y\n };\n } else {\n this.nodeType = NodeHexagonal;\n var hx = this.x - Math.floor(this.y / 2);\n this.gridDim = {\n x: hx,\n y: this.y,\n z: -(0 - hx - this.y)\n };\n }\n\n this.torus = this.options.torus;\n this.distanceMethod = this.torus ? 'getDistanceTorus' : 'getDistance';\n\n this.distance = this.options.distance;\n\n this.maxDistance = getMaxDistance(this.distance, this.numWeights);\n\n if (reload === true) { // For model loading\n this.done = true;\n return;\n }\n if (!(x > 0 && y > 0)) {\n throw new Error('x and y must be positive');\n }\n\n this.times = {\n findBMU: 0,\n adjust: 0\n };\n\n this.randomizer = this.options.randomizer;\n\n this.iterationCount = 0;\n this.iterations = this.options.iterations;\n\n this.startLearningRate = this.learningRate = this.options.learningRate;\n\n this.mapRadius = Math.floor(Math.max(x, y) / 2);\n\n this.algorithmMethod = this.options.method;\n\n this._initNodes();\n\n this.done = false;\n}\n\nSOM.load = function loadModel(model, distance) {\n if (model.name === 'SOM') {\n var x = model.data.length,\n y = model.data[0].length;\n if (distance) {\n model.options.distance = distance;\n } else if (model.options.distance) {\n model.options.distance = eval('(' + model.options.distance + ')');\n }\n var som = new SOM(x, y, model.options, true);\n som.nodes = new Array(x);\n for (var i = 0; i < x; i++) {\n som.nodes[i] = new Array(y);\n for (var j = 0; j < y; j++) {\n som.nodes[i][j] = new som.nodeType(i, j, model.data[i][j], som);\n }\n }\n return som;\n } else {\n throw new Error('expecting a SOM model');\n }\n};\n\nSOM.prototype.export = function exportModel(includeDistance) {\n if (!this.done) {\n throw new Error('model is not ready yet');\n }\n var model = {\n name: 'SOM'\n };\n model.options = {\n fields: this.options.fields,\n gridType: this.options.gridType,\n torus: this.options.torus\n };\n model.data = new Array(this.x);\n for (var i = 0; i < this.x; i++) {\n model.data[i] = new Array(this.y);\n for (var j = 0; j < this.y; j++) {\n model.data[i][j] = this.nodes[i][j].weights;\n }\n }\n if (includeDistance) {\n model.options.distance = this.distance.toString();\n }\n return model;\n};\n\nSOM.prototype._initNodes = function initNodes() {\n var now = Date.now(),\n i, j, k;\n this.nodes = new Array(this.x);\n for (i = 0; i < this.x; i++) {\n this.nodes[i] = new Array(this.y);\n for (j = 0; j < this.y; j++) {\n var weights = new Array(this.numWeights);\n for (k = 0; k < this.numWeights; k++) {\n weights[k] = this.randomizer();\n }\n this.nodes[i][j] = new this.nodeType(i, j, weights, this);\n }\n }\n this.times.initNodes = Date.now() - now;\n};\n\nSOM.prototype.setTraining = function setTraining(trainingSet) {\n if (this.trainingSet) {\n throw new Error('training set has already been set');\n }\n var now = Date.now();\n var convertedSet = trainingSet;\n var i, l = trainingSet.length;\n if (this.extractor) {\n convertedSet = new Array(l);\n for (i = 0; i < l; i++) {\n convertedSet[i] = this.extractor(trainingSet[i]);\n }\n }\n this.numIterations = this.iterations * l;\n\n if (this.algorithmMethod === 'random') {\n this.timeConstant = this.numIterations / Math.log(this.mapRadius);\n } else {\n this.timeConstant = l / Math.log(this.mapRadius);\n }\n this.trainingSet = convertedSet;\n this.times.setTraining = Date.now() - now;\n};\n\nSOM.prototype.trainOne = function trainOne() {\n if (this.done) {\n\n return false;\n\n } else if (this.numIterations-- > 0) {\n\n var neighbourhoodRadius,\n trainingValue,\n trainingSetFactor;\n\n if (this.algorithmMethod === 'random') { // Pick a random value of the training set at each step\n neighbourhoodRadius = this.mapRadius * Math.exp(-this.iterationCount / this.timeConstant);\n trainingValue = getRandomValue(this.trainingSet, this.randomizer);\n this._adjust(trainingValue, neighbourhoodRadius);\n this.learningRate = this.startLearningRate * Math.exp(-this.iterationCount / this.numIterations);\n } else { // Get next input vector\n trainingSetFactor = -Math.floor(this.iterationCount / this.trainingSet.length);\n neighbourhoodRadius = this.mapRadius * Math.exp(trainingSetFactor / this.timeConstant);\n trainingValue = this.trainingSet[this.iterationCount % this.trainingSet.length];\n this._adjust(trainingValue, neighbourhoodRadius);\n if (((this.iterationCount + 1) % this.trainingSet.length) === 0) {\n this.learningRate = this.startLearningRate * Math.exp(trainingSetFactor / Math.floor(this.numIterations / this.trainingSet.length));\n }\n }\n\n this.iterationCount++;\n\n return true;\n\n } else {\n\n this.done = true;\n return false;\n\n }\n};\n\nSOM.prototype._adjust = function adjust(trainingValue, neighbourhoodRadius) {\n var now = Date.now(),\n x, y, dist, influence;\n\n var bmu = this._findBestMatchingUnit(trainingValue);\n\n var now2 = Date.now();\n this.times.findBMU += now2 - now;\n\n var radiusLimit = Math.floor(neighbourhoodRadius);\n var xMin = bmu.x - radiusLimit,\n xMax = bmu.x + radiusLimit,\n yMin = bmu.y - radiusLimit,\n yMax = bmu.y + radiusLimit;\n\n for (x = xMin; x <= xMax; x++) {\n var theX = x;\n if (x < 0) {\n theX += this.x;\n } else if (x >= this.x) {\n theX -= this.x;\n }\n for (y = yMin; y <= yMax; y++) {\n var theY = y;\n if (y < 0) {\n theY += this.y;\n } else if (y >= this.y) {\n theY -= this.y;\n }\n\n dist = bmu[this.distanceMethod](this.nodes[theX][theY]);\n\n if (dist < neighbourhoodRadius) {\n influence = Math.exp(-dist / (2 * neighbourhoodRadius));\n this.nodes[theX][theY].adjustWeights(trainingValue, this.learningRate, influence);\n }\n\n }\n }\n\n this.times.adjust += (Date.now() - now2);\n\n};\n\nSOM.prototype.train = function train(trainingSet) {\n if (!this.done) {\n this.setTraining(trainingSet);\n while (this.trainOne()) {\n }\n }\n};\n\nSOM.prototype.getConvertedNodes = function getConvertedNodes() {\n var result = new Array(this.x);\n for (var i = 0; i < this.x; i++) {\n result[i] = new Array(this.y);\n for (var j = 0; j < this.y; j++) {\n var node = this.nodes[i][j];\n result[i][j] = this.creator ? this.creator(node.weights) : node.weights;\n }\n }\n return result;\n};\n\nSOM.prototype._findBestMatchingUnit = function findBestMatchingUnit(candidate) {\n\n var bmu,\n lowest = Infinity,\n dist;\n\n for (var i = 0; i < this.x; i++) {\n for (var j = 0; j < this.y; j++) {\n dist = this.distance(this.nodes[i][j].weights, candidate);\n if (dist < lowest) {\n lowest = dist;\n bmu = this.nodes[i][j];\n }\n }\n }\n\n return bmu;\n\n};\n\nSOM.prototype.predict = function predict(data, computePosition) {\n if (typeof data === 'boolean') {\n computePosition = data;\n data = null;\n }\n if (!data) {\n data = this.trainingSet;\n }\n if (Array.isArray(data) && (Array.isArray(data[0]) || (typeof data[0] === 'object'))) { // predict a dataset\n var self = this;\n return data.map(function (element) {\n return self._predict(element, computePosition);\n });\n } else { // predict a single element\n return this._predict(data, computePosition);\n }\n};\n\nSOM.prototype._predict = function _predict(element, computePosition) {\n if (!Array.isArray(element)) {\n element = this.extractor(element);\n }\n var bmu = this._findBestMatchingUnit(element);\n var result = [bmu.x, bmu.y];\n if (computePosition) {\n result[2] = bmu.getPosition(element);\n }\n return result;\n};\n\n// As seen in http://www.scholarpedia.org/article/Kohonen_network\nSOM.prototype.getQuantizationError = function getQuantizationError() {\n var fit = this.getFit(),\n l = fit.length,\n sum = 0;\n for (var i = 0; i < l; i++) {\n sum += fit[i];\n }\n return sum / l;\n};\n\nSOM.prototype.getFit = function getFit(dataset) {\n if (!dataset) {\n dataset = this.trainingSet;\n }\n var l = dataset.length,\n bmu,\n result = new Array(l);\n for (var i = 0; i < l; i++) {\n bmu = this._findBestMatchingUnit(dataset[i]);\n result[i] = Math.sqrt(this.distance(dataset[i], bmu.weights));\n }\n return result;\n};\n\nfunction getConverters(fields) {\n var l = fields.length,\n normalizers = new Array(l),\n denormalizers = new Array(l);\n for (var i = 0; i < l; i++) {\n normalizers[i] = getNormalizer(fields[i].range);\n denormalizers[i] = getDenormalizer(fields[i].range);\n }\n return {\n extractor: function extractor(value) {\n var result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = normalizers[i](value[fields[i].name]);\n }\n return result;\n },\n creator: function creator(value) {\n var result = {};\n for (var i = 0; i < l; i++) {\n result[fields[i].name] = denormalizers[i](value[i]);\n }\n return result;\n }\n };\n}\n\nfunction getNormalizer(minMax) {\n return function normalizer(value) {\n return (value - minMax[0]) / (minMax[1] - minMax[0]);\n };\n}\n\nfunction getDenormalizer(minMax) {\n return function denormalizer(value) {\n return (minMax[0] + value * (minMax[1] - minMax[0]));\n };\n}\n\nfunction squareEuclidean(a, b) {\n var d = 0;\n for (var i = 0, ii = a.length; i < ii; i++) {\n d += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return d;\n}\n\nfunction getRandomValue(arr, randomizer) {\n return arr[Math.floor(randomizer() * arr.length)];\n}\n\nfunction getMaxDistance(distance, numWeights) {\n var zero = new Array(numWeights),\n one = new Array(numWeights);\n for (var i = 0; i < numWeights; i++) {\n zero[i] = 0;\n one[i] = 1;\n }\n return distance(zero, one);\n}\n\nmodule.exports = SOM;","export default function maybeToPrecision(value, digits) {\n if (value < 0) {\n value = 0 - value;\n if (typeof digits === 'number') {\n return `- ${value.toPrecision(digits)}`;\n } else {\n return `- ${value.toString()}`;\n }\n } else {\n if (typeof digits === 'number') {\n return value.toPrecision(digits);\n } else {\n return value.toString();\n }\n }\n}\n","export default function checkArraySize(x, y) {\n if (!Array.isArray(x) || !Array.isArray(y)) {\n throw new TypeError('x and y must be arrays');\n }\n if (x.length !== y.length) {\n throw new RangeError('x and y arrays must have the same length');\n }\n}\n","export { default as maybeToPrecision } from './maybeToPrecision';\nexport { default as checkArrayLength } from './checkArrayLength';\n\nexport default class BaseRegression {\n constructor() {\n if (new.target === BaseRegression) {\n throw new Error('BaseRegression must be subclassed');\n }\n }\n\n predict(x) {\n if (typeof x === 'number') {\n return this._predict(x);\n } else if (Array.isArray(x)) {\n const y = [];\n for (let i = 0; i < x.length; i++) {\n y.push(this._predict(x[i]));\n }\n return y;\n } else {\n throw new TypeError('x must be a number or array');\n }\n }\n\n _predict() {\n throw new Error('_predict must be implemented');\n }\n\n train() {\n // Do nothing for this package\n }\n\n toString() {\n return '';\n }\n\n toLaTeX() {\n return '';\n }\n\n /**\n * Return the correlation coefficient of determination (r) and chi-square.\n * @param {Array} x\n * @param {Array} y\n * @return {object}\n */\n score(x, y) {\n if (!Array.isArray(x) || !Array.isArray(y) || x.length !== y.length) {\n throw new Error('x and y must be arrays of the same length');\n }\n\n const n = x.length;\n const y2 = new Array(n);\n for (let i = 0; i < n; i++) {\n y2[i] = this._predict(x[i]);\n }\n\n let xSum = 0;\n let ySum = 0;\n let chi2 = 0;\n let rmsd = 0;\n let xSquared = 0;\n let ySquared = 0;\n let xY = 0;\n for (let i = 0; i < n; i++) {\n xSum += y2[i];\n ySum += y[i];\n xSquared += y2[i] * y2[i];\n ySquared += y[i] * y[i];\n xY += y2[i] * y[i];\n if (y[i] !== 0) {\n chi2 += ((y[i] - y2[i]) * (y[i] - y2[i])) / y[i];\n }\n rmsd += (y[i] - y2[i]) * (y[i] - y2[i]);\n }\n\n const r =\n (n * xY - xSum * ySum) /\n Math.sqrt((n * xSquared - xSum * xSum) * (n * ySquared - ySum * ySum));\n\n return {\n r: r,\n r2: r * r,\n chi2: chi2,\n rmsd: Math.sqrt(rmsd / n)\n };\n }\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport { Matrix, MatrixTransposeView, solve } from 'ml-matrix';\n\nexport default class PolynomialRegression extends BaseRegression {\n constructor(x, y, degree) {\n super();\n if (x === true) {\n this.degree = y.degree;\n this.powers = y.powers;\n this.coefficients = y.coefficients;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y, degree);\n }\n }\n\n _predict(x) {\n let y = 0;\n for (let k = 0; k < this.powers.length; k++) {\n y += this.coefficients[k] * Math.pow(x, this.powers[k]);\n }\n return y;\n }\n\n toJSON() {\n return {\n name: 'polynomialRegression',\n degree: this.degree,\n powers: this.powers,\n coefficients: this.coefficients\n };\n }\n\n toString(precision) {\n return this._toFormula(precision, false);\n }\n\n toLaTeX(precision) {\n return this._toFormula(precision, true);\n }\n\n _toFormula(precision, isLaTeX) {\n let sup = '^';\n let closeSup = '';\n let times = ' * ';\n if (isLaTeX) {\n sup = '^{';\n closeSup = '}';\n times = '';\n }\n\n let fn = '';\n let str = '';\n for (let k = 0; k < this.coefficients.length; k++) {\n str = '';\n if (this.coefficients[k] !== 0) {\n if (this.powers[k] === 0) {\n str = maybeToPrecision(this.coefficients[k], precision);\n } else {\n if (this.powers[k] === 1) {\n str =\n `${maybeToPrecision(this.coefficients[k], precision) + times}x`;\n } else {\n str =\n `${maybeToPrecision(this.coefficients[k], precision) +\n times\n }x${\n sup\n }${this.powers[k]\n }${closeSup}`;\n }\n }\n\n if (this.coefficients[k] > 0 && k !== this.coefficients.length - 1) {\n str = ` + ${str}`;\n } else if (k !== this.coefficients.length - 1) {\n str = ` ${str}`;\n }\n }\n fn = str + fn;\n }\n if (fn.charAt(0) === '+') {\n fn = fn.slice(1);\n }\n\n return `f(x) = ${fn}`;\n }\n\n static load(json) {\n if (json.name !== 'polynomialRegression') {\n throw new TypeError('not a polynomial regression model');\n }\n return new PolynomialRegression(true, json);\n }\n}\n\nfunction regress(pr, x, y, degree) {\n const n = x.length;\n let powers;\n if (Array.isArray(degree)) {\n powers = degree;\n degree = powers.length;\n } else {\n degree++;\n powers = new Array(degree);\n for (let k = 0; k < degree; k++) {\n powers[k] = k;\n }\n }\n const F = new Matrix(n, degree);\n const Y = new Matrix([y]);\n for (let k = 0; k < degree; k++) {\n for (let i = 0; i < n; i++) {\n if (powers[k] === 0) {\n F.set(i, k, 1);\n } else {\n F.set(i, k, Math.pow(x[i], powers[k]));\n }\n }\n }\n\n const FT = new MatrixTransposeView(F);\n const A = FT.mmul(F);\n const B = FT.mmul(new MatrixTransposeView(Y));\n\n pr.degree = degree - 1;\n pr.powers = powers;\n pr.coefficients = solve(A, B).to1DArray();\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\n\nexport default class SimpleLinearRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n this.slope = y.slope;\n this.intercept = y.intercept;\n this.coefficients = [y.intercept, y.slope];\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n toJSON() {\n return {\n name: 'simpleLinearRegression',\n slope: this.slope,\n intercept: this.intercept\n };\n }\n\n _predict(x) {\n return this.slope * x + this.intercept;\n }\n\n computeX(y) {\n return (y - this.intercept) / this.slope;\n }\n\n toString(precision) {\n let result = 'f(x) = ';\n if (this.slope !== 0) {\n const xFactor = maybeToPrecision(this.slope, precision);\n result += `${xFactor === '1' ? '' : `${xFactor} * `}x`;\n if (this.intercept !== 0) {\n const absIntercept = Math.abs(this.intercept);\n const operator = absIntercept === this.intercept ? '+' : '-';\n result += ` ${operator} ${maybeToPrecision(absIntercept, precision)}`;\n }\n } else {\n result += maybeToPrecision(this.intercept, precision);\n }\n return result;\n }\n\n toLaTeX(precision) {\n return this.toString(precision);\n }\n\n static load(json) {\n if (json.name !== 'simpleLinearRegression') {\n throw new TypeError('not a SLR model');\n }\n return new SimpleLinearRegression(true, json);\n }\n}\n\nfunction regress(slr, x, y) {\n const n = x.length;\n let xSum = 0;\n let ySum = 0;\n\n let xSquared = 0;\n let xY = 0;\n\n for (let i = 0; i < n; i++) {\n xSum += x[i];\n ySum += y[i];\n xSquared += x[i] * x[i];\n xY += x[i] * y[i];\n }\n\n const numerator = n * xY - xSum * ySum;\n slr.slope = numerator / (n * xSquared - xSum * xSum);\n slr.intercept = (1 / n) * ySum - slr.slope * (1 / n) * xSum;\n slr.coefficients = [slr.intercept, slr.slope];\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport SimpleLinearRegression from 'ml-regression-simple-linear';\n\nexport default class ExponentialRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n this.A = y.A;\n this.B = y.B;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n _predict(input) {\n return this.B * Math.exp(input * this.A);\n }\n\n toJSON() {\n return {\n name: 'exponentialRegression',\n A: this.A,\n B: this.B\n };\n }\n\n toString(precision) {\n return (\n `f(x) = ${\n maybeToPrecision(this.B, precision)\n } * e^(${\n maybeToPrecision(this.A, precision)\n } * x)`\n );\n }\n\n toLaTeX(precision) {\n if (this.A >= 0) {\n return (\n `f(x) = ${\n maybeToPrecision(this.B, precision)\n }e^{${\n maybeToPrecision(this.A, precision)\n }x}`\n );\n } else {\n return (\n `f(x) = \\\\frac{${\n maybeToPrecision(this.B, precision)\n }}{e^{${\n maybeToPrecision(-this.A, precision)\n }x}}`\n );\n }\n }\n\n static load(json) {\n if (json.name !== 'exponentialRegression') {\n throw new TypeError('not a exponential regression model');\n }\n return new ExponentialRegression(true, json);\n }\n}\n\nfunction regress(er, x, y) {\n const n = x.length;\n const yl = new Array(n);\n for (let i = 0; i < n; i++) {\n yl[i] = Math.log(y[i]);\n }\n\n const linear = new SimpleLinearRegression(x, yl);\n er.A = linear.slope;\n er.B = Math.exp(linear.intercept);\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport SimpleLinearRegression from 'ml-regression-simple-linear';\n\nexport default class PowerRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n // reloading model\n this.A = y.A;\n this.B = y.B;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n _predict(newInputs) {\n return this.A * Math.pow(newInputs, this.B);\n }\n\n toJSON() {\n return {\n name: 'powerRegression',\n A: this.A,\n B: this.B\n };\n }\n\n toString(precision) {\n return `f(x) = ${maybeToPrecision(\n this.A,\n precision\n )} * x^${maybeToPrecision(this.B, precision)}`;\n }\n\n toLaTeX(precision) {\n let latex = '';\n if (this.B >= 0) {\n latex = `f(x) = ${maybeToPrecision(\n this.A,\n precision\n )}x^{${maybeToPrecision(this.B, precision)}}`;\n } else {\n latex = `f(x) = \\\\frac{${maybeToPrecision(\n this.A,\n precision\n )}}{x^{${maybeToPrecision(-this.B, precision)}}}`;\n }\n latex = latex.replace(/e([+-]?[0-9]+)/g, 'e^{$1}');\n return latex;\n }\n\n static load(json) {\n if (json.name !== 'powerRegression') {\n throw new TypeError('not a power regression model');\n }\n return new PowerRegression(true, json);\n }\n}\n\nfunction regress(pr, x, y) {\n const n = x.length;\n const xl = new Array(n);\n const yl = new Array(n);\n for (let i = 0; i < n; i++) {\n xl[i] = Math.log(x[i]);\n yl[i] = Math.log(y[i]);\n }\n\n const linear = new SimpleLinearRegression(xl, yl);\n pr.A = Math.exp(linear.intercept);\n pr.B = linear.slope;\n}\n","import Matrix, { SVD, pseudoInverse } from 'ml-matrix';\n\nexport default class MultivariateLinearRegression {\n constructor(x, y, options = {}) {\n const { intercept = true, statistics = true } = options;\n this.statistics = statistics;\n if (x === true) {\n this.weights = y.weights;\n this.inputs = y.inputs;\n this.outputs = y.outputs;\n this.intercept = y.intercept;\n } else {\n x = new Matrix(x);\n y = new Matrix(y);\n if (intercept) {\n x.addColumn(new Array(x.rows).fill(1));\n }\n let xt = x.transpose();\n const xx = xt\n .mmul(x);\n const xy = xt\n .mmul(y);\n const invxx = new SVD(xx)\n .inverse();\n const beta = xy\n .transpose()\n .mmul(invxx)\n .transpose();\n this.weights = beta.to2DArray();\n this.inputs = x.columns;\n this.outputs = y.columns;\n if (intercept) this.inputs--;\n this.intercept = intercept;\n if (statistics) {\n /*\n * Let's add some basic statistics about the beta's to be able to interpret them.\n * source: http://dept.stat.lsa.umich.edu/~kshedden/Courses/Stat401/Notes/401-multreg.pdf\n * validated against Excel Regression AddIn\n * test: \"datamining statistics test\"\n */\n const fittedValues = x.mmul(beta);\n const residuals = y.clone().addM(fittedValues.neg());\n const variance =\n residuals\n .to2DArray()\n .map((ri) => Math.pow(ri[0], 2))\n .reduce((a, b) => a + b) /\n (y.rows - x.columns);\n this.stdError = Math.sqrt(variance);\n this.stdErrorMatrix = pseudoInverse(xx).mul(variance);\n this.stdErrors = this.stdErrorMatrix\n .diagonal()\n .map((d) => Math.sqrt(d));\n this.tStats = this.weights.map((d, i) =>\n (this.stdErrors[i] === 0 ? 0 : d[0] / this.stdErrors[i])\n );\n }\n }\n }\n\n predict(x) {\n if (Array.isArray(x)) {\n if (typeof x[0] === 'number') {\n return this._predict(x);\n } else if (Array.isArray(x[0])) {\n const y = new Array(x.length);\n for (let i = 0; i < x.length; i++) {\n y[i] = this._predict(x[i]);\n }\n return y;\n }\n } else if (Matrix.isMatrix(x)) {\n const y = new Matrix(x.rows, this.outputs);\n for (let i = 0; i < x.rows; i++) {\n y.setRow(i, this._predict(x.getRow(i)));\n }\n return y;\n }\n throw new TypeError('x must be a matrix or array of numbers');\n }\n\n _predict(x) {\n const result = new Array(this.outputs);\n if (this.intercept) {\n for (let i = 0; i < this.outputs; i++) {\n result[i] = this.weights[this.inputs][i];\n }\n } else {\n result.fill(0);\n }\n for (let i = 0; i < this.inputs; i++) {\n for (let j = 0; j < this.outputs; j++) {\n result[j] += this.weights[i][j] * x[i];\n }\n }\n return result;\n }\n\n score() {\n throw new Error('score method is not implemented yet');\n }\n\n toJSON() {\n return {\n name: 'multivariateLinearRegression',\n weights: this.weights,\n inputs: this.inputs,\n outputs: this.outputs,\n intercept: this.intercept,\n summary: this.statistics\n ? {\n regressionStatistics: {\n standardError: this.stdError,\n observations: this.outputs\n },\n variables: this.weights.map((d, i) => {\n return {\n label:\n i === this.weights.length - 1\n ? 'Intercept'\n : `X Variable ${i + 1}`,\n coefficients: d,\n standardError: this.stdErrors[i],\n tStat: this.tStats[i]\n };\n })\n }\n : undefined\n };\n }\n\n static load(model) {\n if (model.name !== 'multivariateLinearRegression') {\n throw new Error('not a MLR model');\n }\n return new MultivariateLinearRegression(true, model);\n }\n}\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass GaussianKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.divisor = 2 * options.sigma * options.sigma;\n }\n compute(x, y) {\n const distance = squaredEuclidean(x, y);\n return Math.exp(-distance / this.divisor);\n }\n}\n\nmodule.exports = GaussianKernel;\n","'use strict';\n\nconst defaultOptions = {\n degree: 1,\n constant: 1,\n scale: 1\n};\n\nclass PolynomialKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n\n this.degree = options.degree;\n this.constant = options.constant;\n this.scale = options.scale;\n }\n\n compute(x, y) {\n var sum = 0;\n for (var i = 0; i < x.length; i++) {\n sum += x[i] * y[i];\n }\n return Math.pow(this.scale * sum + this.constant, this.degree);\n }\n}\n\nmodule.exports = PolynomialKernel;\n","'use strict';\n\nconst defaultOptions = {\n alpha: 0.01,\n constant: -Math.E\n};\n\nclass SigmoidKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.alpha = options.alpha;\n this.constant = options.constant;\n }\n\n compute(x, y) {\n var sum = 0;\n for (var i = 0; i < x.length; i++) {\n sum += x[i] * y[i];\n }\n return Math.tanh(this.alpha * sum + this.constant);\n }\n}\n\nmodule.exports = SigmoidKernel;\n","'use strict';\n\nconst defaultOptions = {\n sigma: 1,\n degree: 1\n};\n\nclass ANOVAKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.degree = options.degree;\n }\n\n compute(x, y) {\n var sum = 0;\n var len = Math.min(x.length, y.length);\n for (var i = 1; i <= len; ++i) {\n sum += Math.pow(\n Math.exp(\n -this.sigma *\n Math.pow(Math.pow(x[i - 1], i) - Math.pow(y[i - 1], i), 2)\n ),\n this.degree\n );\n }\n return sum;\n }\n}\n\nmodule.exports = ANOVAKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass CauchyKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n }\n\n compute(x, y) {\n return 1 / (1 + squaredEuclidean(x, y) / (this.sigma * this.sigma));\n }\n}\n\nmodule.exports = CauchyKernel;\n","'use strict';\n\nconst { euclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass ExponentialKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n this.divisor = 2 * options.sigma * options.sigma;\n }\n\n compute(x, y) {\n const distance = euclidean(x, y);\n return Math.exp(-distance / this.divisor);\n }\n}\n\nmodule.exports = ExponentialKernel;\n","'use strict';\n\nclass HistogramIntersectionKernel {\n compute(x, y) {\n var min = Math.min(x.length, y.length);\n var sum = 0;\n for (var i = 0; i < min; ++i) {\n sum += Math.min(x[i], y[i]);\n }\n\n return sum;\n }\n}\n\nmodule.exports = HistogramIntersectionKernel;\n","'use strict';\n\nconst { euclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n sigma: 1\n};\n\nclass LaplacianKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.sigma = options.sigma;\n }\n\n compute(x, y) {\n const distance = euclidean(x, y);\n return Math.exp(-distance / this.sigma);\n }\n}\n\nmodule.exports = LaplacianKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n constant: 1\n};\n\nclass MultiquadraticKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.constant = options.constant;\n }\n\n compute(x, y) {\n return Math.sqrt(squaredEuclidean(x, y) + this.constant * this.constant);\n }\n}\n\nmodule.exports = MultiquadraticKernel;\n","'use strict';\n\nconst { squaredEuclidean } = require('ml-distance-euclidean');\n\nconst defaultOptions = {\n constant: 1\n};\n\nclass RationalQuadraticKernel {\n constructor(options) {\n options = Object.assign({}, defaultOptions, options);\n this.constant = options.constant;\n }\n\n compute(x, y) {\n const distance = squaredEuclidean(x, y);\n return 1 - distance / (distance + this.constant);\n }\n}\n\nmodule.exports = RationalQuadraticKernel;\n","'use strict';\n\nconst { Matrix, MatrixTransposeView } = require('ml-matrix');\nconst GaussianKernel = require('ml-kernel-gaussian');\nconst PolynomialKernel = require('ml-kernel-polynomial');\nconst SigmoidKernel = require('ml-kernel-sigmoid');\n\nconst ANOVAKernel = require('./kernels/anova-kernel');\nconst CauchyKernel = require('./kernels/cauchy-kernel');\nconst ExponentialKernel = require('./kernels/exponential-kernel');\nconst HistogramKernel = require('./kernels/histogram-intersection-kernel');\nconst LaplacianKernel = require('./kernels/laplacian-kernel');\nconst MultiquadraticKernel = require('./kernels/multiquadratic-kernel');\nconst RationalKernel = require('./kernels/rational-quadratic-kernel');\n\nconst kernelType = {\n gaussian: GaussianKernel,\n rbf: GaussianKernel,\n polynomial: PolynomialKernel,\n poly: PolynomialKernel,\n anova: ANOVAKernel,\n cauchy: CauchyKernel,\n exponential: ExponentialKernel,\n histogram: HistogramKernel,\n min: HistogramKernel,\n laplacian: LaplacianKernel,\n multiquadratic: MultiquadraticKernel,\n rational: RationalKernel,\n sigmoid: SigmoidKernel,\n mlp: SigmoidKernel\n};\n\nclass Kernel {\n constructor(type, options) {\n this.kernelType = type;\n if (type === 'linear') return;\n\n if (typeof type === 'string') {\n type = type.toLowerCase();\n\n var KernelConstructor = kernelType[type];\n if (KernelConstructor) {\n this.kernelFunction = new KernelConstructor(options);\n } else {\n throw new Error(`unsupported kernel type: ${type}`);\n }\n } else if (typeof type === 'object' && typeof type.compute === 'function') {\n this.kernelFunction = type;\n } else {\n throw new TypeError(\n 'first argument must be a valid kernel type or instance'\n );\n }\n }\n\n compute(inputs, landmarks) {\n inputs = Matrix.checkMatrix(inputs);\n if (landmarks === undefined) {\n landmarks = inputs;\n } else {\n landmarks = Matrix.checkMatrix(landmarks);\n }\n if (this.kernelType === 'linear') {\n return inputs.mmul(new MatrixTransposeView(landmarks));\n }\n\n const kernelMatrix = new Matrix(inputs.rows, landmarks.rows);\n if (inputs === landmarks) {\n // fast path, matrix is symmetric\n for (let i = 0; i < inputs.rows; i++) {\n for (let j = i; j < inputs.rows; j++) {\n const value = this.kernelFunction.compute(\n inputs.getRow(i),\n inputs.getRow(j)\n );\n kernelMatrix.set(i, j, value);\n kernelMatrix.set(j, i, value);\n }\n }\n } else {\n for (let i = 0; i < inputs.rows; i++) {\n for (let j = 0; j < landmarks.rows; j++) {\n kernelMatrix.set(\n i,\n j,\n this.kernelFunction.compute(inputs.getRow(i), landmarks.getRow(j))\n );\n }\n }\n }\n return kernelMatrix;\n }\n}\n\nmodule.exports = Kernel;\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport median from 'ml-array-median';\n\nexport default class TheilSenRegression extends BaseRegression {\n /**\n * Theil–Sen estimator\n * https://en.wikipedia.org/wiki/Theil%E2%80%93Sen_estimator\n * @param {Array|boolean} x\n * @param {Array|object} y\n * @constructor\n */\n constructor(x, y) {\n super();\n if (x === true) {\n // loads the model\n this.slope = y.slope;\n this.intercept = y.intercept;\n this.coefficients = y.coefficients;\n } else {\n // creates the model\n checkArrayLength(x, y);\n theilSen(this, x, y);\n }\n }\n\n toJSON() {\n return {\n name: 'TheilSenRegression',\n slope: this.slope,\n intercept: this.intercept\n };\n }\n\n _predict(input) {\n return this.slope * input + this.intercept;\n }\n\n computeX(input) {\n return (input - this.intercept) / this.slope;\n }\n\n toString(precision) {\n var result = 'f(x) = ';\n if (this.slope) {\n var xFactor = maybeToPrecision(this.slope, precision);\n result += `${Math.abs(xFactor - 1) < 1e-5 ? '' : `${xFactor} * `}x`;\n if (this.intercept) {\n var absIntercept = Math.abs(this.intercept);\n var operator = absIntercept === this.intercept ? '+' : '-';\n result +=\n ` ${operator} ${maybeToPrecision(absIntercept, precision)}`;\n }\n } else {\n result += maybeToPrecision(this.intercept, precision);\n }\n return result;\n }\n\n toLaTeX(precision) {\n return this.toString(precision);\n }\n\n static load(json) {\n if (json.name !== 'TheilSenRegression') {\n throw new TypeError('not a Theil-Sen model');\n }\n return new TheilSenRegression(true, json);\n }\n}\n\nfunction theilSen(regression, x, y) {\n let len = x.length;\n let slopes = new Array(len * len);\n let count = 0;\n for (let i = 0; i < len; ++i) {\n for (let j = i + 1; j < len; ++j) {\n if (x[i] !== x[j]) {\n slopes[count++] = (y[j] - y[i]) / (x[j] - x[i]);\n }\n }\n }\n slopes.length = count;\n let medianSlope = median(slopes);\n\n let cuts = new Array(len);\n for (let i = 0; i < len; ++i) {\n cuts[i] = y[i] - medianSlope * x[i];\n }\n\n regression.slope = medianSlope;\n regression.intercept = median(cuts);\n regression.coefficients = [regression.intercept, regression.slope];\n}\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport { solve } from 'ml-matrix';\n\n/**\n * @class RobustPolynomialRegression\n * @param {Array} x\n * @param {Array} y\n * @param {number} degree - polynomial degree\n */\nexport default class RobustPolynomialRegression extends BaseRegression {\n constructor(x, y, degree) {\n super();\n if (x === true) {\n this.degree = y.degree;\n this.powers = y.powers;\n this.coefficients = y.coefficients;\n } else {\n checkArrayLength(x, y);\n robustPolynomial(this, x, y, degree);\n }\n }\n\n toJSON() {\n return {\n name: 'robustPolynomialRegression',\n degree: this.degree,\n powers: this.powers,\n coefficients: this.coefficients\n };\n }\n\n _predict(x) {\n return predict(x, this.powers, this.coefficients);\n }\n\n /**\n * Display the formula\n * @param {number} precision - precision for the numbers\n * @return {string}\n */\n toString(precision) {\n return this._toFormula(precision, false);\n }\n\n /**\n * Display the formula in LaTeX format\n * @param {number} precision - precision for the numbers\n * @return {string}\n */\n toLaTeX(precision) {\n return this._toFormula(precision, true);\n }\n\n _toFormula(precision, isLaTeX) {\n let sup = '^';\n let closeSup = '';\n let times = ' * ';\n if (isLaTeX) {\n sup = '^{';\n closeSup = '}';\n times = '';\n }\n\n let fn = '';\n let str = '';\n for (let k = 0; k < this.coefficients.length; k++) {\n str = '';\n if (this.coefficients[k] !== 0) {\n if (this.powers[k] === 0) {\n str = maybeToPrecision(this.coefficients[k], precision);\n } else {\n if (this.powers[k] === 1) {\n str = `${maybeToPrecision(this.coefficients[k], precision) +\n times}x`;\n } else {\n str = `${maybeToPrecision(this.coefficients[k], precision) +\n times}x${sup}${this.powers[k]}${closeSup}`;\n }\n }\n\n if (this.coefficients[k] > 0 && k !== this.coefficients.length - 1) {\n str = ` + ${str}`;\n } else if (k !== this.coefficients.length - 1) {\n str = ` ${str}`;\n }\n }\n fn = str + fn;\n }\n if (fn.charAt(0) === '+') {\n fn = fn.slice(1);\n }\n\n return `f(x) = ${fn}`;\n }\n\n static load(json) {\n if (json.name !== 'robustPolynomialRegression') {\n throw new TypeError('not a RobustPolynomialRegression model');\n }\n return new RobustPolynomialRegression(true, json);\n }\n}\n\nfunction robustPolynomial(regression, x, y, degree) {\n let powers = Array(degree)\n .fill(0)\n .map((_, index) => index);\n\n const tuples = getRandomTuples(x, y, degree);\n\n var min;\n for (var i = 0; i < tuples.length; i++) {\n var tuple = tuples[i];\n var coefficients = calcCoefficients(tuple, powers);\n\n var residuals = x.slice();\n for (var j = 0; j < x.length; j++) {\n residuals[j] = y[j] - predict(x[j], powers, coefficients);\n residuals[j] = {\n residual: residuals[j] * residuals[j],\n coefficients\n };\n }\n\n var median = residualsMedian(residuals);\n if (!min || median.residual < min.residual) {\n min = median;\n }\n }\n\n regression.degree = degree;\n regression.powers = powers;\n regression.coefficients = min.coefficients;\n}\n\n/**\n * @ignore\n * @param {Array} x\n * @param {Array} y\n * @param {number} degree\n * @return {Array<{x:number,y:number}>}\n */\nfunction getRandomTuples(x, y, degree) {\n var len = Math.floor(x.length / degree);\n var tuples = new Array(len);\n\n for (var i = 0; i < x.length; i++) {\n var pos = Math.floor(Math.random() * len);\n\n var counter = 0;\n while (counter < x.length) {\n if (!tuples[pos]) {\n tuples[pos] = [\n {\n x: x[i],\n y: y[i]\n }\n ];\n break;\n } else if (tuples[pos].length < degree) {\n tuples[pos].push({\n x: x[i],\n y: y[i]\n });\n break;\n } else {\n counter++;\n pos = (pos + 1) % len;\n }\n }\n\n if (counter === x.length) {\n return tuples;\n }\n }\n return tuples;\n}\n\n/**\n * @ignore\n * @param {{x:number,y:number}} tuple\n * @param {Array} powers\n * @return {Array}\n */\nfunction calcCoefficients(tuple, powers) {\n var X = tuple.slice();\n var Y = tuple.slice();\n for (var i = 0; i < X.length; i++) {\n Y[i] = [tuple[i].y];\n X[i] = new Array(powers.length);\n for (var j = 0; j < powers.length; j++) {\n X[i][j] = Math.pow(tuple[i].x, powers[j]);\n }\n }\n\n return solve(X, Y).to1DArray();\n}\n\nfunction predict(x, powers, coefficients) {\n let y = 0;\n for (let k = 0; k < powers.length; k++) {\n y += coefficients[k] * Math.pow(x, powers[k]);\n }\n return y;\n}\n\nfunction residualsMedian(residuals) {\n residuals.sort((a, b) => a.residual - b.residual);\n\n var l = residuals.length;\n var half = Math.floor(l / 2);\n return l % 2 === 0 ? residuals[half - 1] : residuals[half];\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","/**\n * Calculate current error\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} parameters - Array of current parameter values\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {number}\n */\nexport default function errorCalculation(\n data,\n parameters,\n parameterizedFunction,\n) {\n let error = 0;\n const func = parameterizedFunction(parameters);\n\n for (let i = 0; i < data.x.length; i++) {\n error += Math.abs(data.y[i] - func(data.x[i]));\n }\n\n return error;\n}\n","import { inverse, Matrix } from 'ml-matrix';\n\n/**\n * Difference of the matrix function over the parameters\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} evaluatedData - Array of previous evaluated function values\n * @param {Array} params - Array of previous parameter values\n * @param {number} gradientDifference - Adjustment for decrease the damping parameter\n * @param {function} paramFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {Matrix}\n */\nfunction gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n paramFunction,\n) {\n const n = params.length;\n const m = data.x.length;\n\n let ans = new Array(n);\n\n for (let param = 0; param < n; param++) {\n ans[param] = new Array(m);\n let auxParams = params.slice();\n auxParams[param] += gradientDifference;\n let funcParam = paramFunction(auxParams);\n\n for (let point = 0; point < m; point++) {\n ans[param][point] = evaluatedData[point] - funcParam(data.x[point]);\n }\n }\n return new Matrix(ans);\n}\n\n/**\n * Matrix function over the samples\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} evaluatedData - Array of previous evaluated function values\n * @return {Matrix}\n */\nfunction matrixFunction(data, evaluatedData) {\n const m = data.x.length;\n\n let ans = new Array(m);\n\n for (let point = 0; point < m; point++) {\n ans[point] = [data.y[point] - evaluatedData[point]];\n }\n\n return new Matrix(ans);\n}\n\n/**\n * Iteration for Levenberg-Marquardt\n * @ignore\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {Array} params - Array of previous parameter values\n * @param {number} damping - Levenberg-Marquardt parameter\n * @param {number} gradientDifference - Adjustment for decrease the damping parameter\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @return {Array}\n */\nexport default function step(\n data,\n params,\n damping,\n gradientDifference,\n parameterizedFunction,\n) {\n let value = damping * gradientDifference * gradientDifference;\n let identity = Matrix.eye(params.length, params.length, value);\n\n const func = parameterizedFunction(params);\n\n let evaluatedData = new Float64Array(data.x.length);\n for (let i = 0; i < data.x.length; i++) {\n evaluatedData[i] = func(data.x[i]);\n }\n\n let gradientFunc = gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n parameterizedFunction,\n );\n let matrixFunc = matrixFunction(data, evaluatedData);\n let inverseMatrix = inverse(\n identity.add(gradientFunc.mmul(gradientFunc.transpose())),\n );\n\n params = new Matrix([params]);\n params = params.sub(\n inverseMatrix\n .mmul(gradientFunc)\n .mmul(matrixFunc)\n .mul(gradientDifference)\n .transpose(),\n );\n\n return params.to1DArray();\n}\n","import isArray from 'is-any-array';\n\nimport errorCalculation from './errorCalculation';\nimport step from './step';\n\n/**\n * Curve fitting algorithm\n * @param {{x:Array, y:Array}} data - Array of points to fit in the format [x1, x2, ... ], [y1, y2, ... ]\n * @param {function} parameterizedFunction - The parameters and returns a function with the independent variable as a parameter\n * @param {object} [options] - Options object\n * @param {number} [options.damping] - Levenberg-Marquardt parameter\n * @param {number} [options.gradientDifference = 10e-2] - Adjustment for decrease the damping parameter\n * @param {Array} [options.minValues] - Minimum allowed values for parameters\n * @param {Array} [options.maxValues] - Maximum allowed values for parameters\n * @param {Array} [options.initialValues] - Array of initial parameter values\n * @param {number} [options.maxIterations = 100] - Maximum of allowed iterations\n * @param {number} [options.errorTolerance = 10e-3] - Minimum uncertainty allowed for each point\n * @return {{parameterValues: Array, parameterError: number, iterations: number}}\n */\nexport default function levenbergMarquardt(\n data,\n parameterizedFunction,\n options = {},\n) {\n let {\n maxIterations = 100,\n gradientDifference = 10e-2,\n damping = 0,\n errorTolerance = 10e-3,\n minValues,\n maxValues,\n initialValues,\n } = options;\n\n if (damping <= 0) {\n throw new Error('The damping option must be a positive number');\n } else if (!data.x || !data.y) {\n throw new Error('The data parameter must have x and y elements');\n } else if (\n !isArray(data.x) ||\n data.x.length < 2 ||\n !isArray(data.y) ||\n data.y.length < 2\n ) {\n throw new Error(\n 'The data parameter elements must be an array with more than 2 points',\n );\n } else if (data.x.length !== data.y.length) {\n throw new Error('The data parameter elements must have the same size');\n }\n\n let parameters =\n initialValues || new Array(parameterizedFunction.length).fill(1);\n let parLen = parameters.length;\n maxValues = maxValues || new Array(parLen).fill(Number.MAX_SAFE_INTEGER);\n minValues = minValues || new Array(parLen).fill(Number.MIN_SAFE_INTEGER);\n\n if (maxValues.length !== minValues.length) {\n throw new Error('minValues and maxValues must be the same size');\n }\n\n if (!isArray(parameters)) {\n throw new Error('initialValues must be an array');\n }\n\n let error = errorCalculation(data, parameters, parameterizedFunction);\n\n let converged = error <= errorTolerance;\n\n let iteration;\n for (iteration = 0; iteration < maxIterations && !converged; iteration++) {\n parameters = step(\n data,\n parameters,\n damping,\n gradientDifference,\n parameterizedFunction,\n );\n\n for (let k = 0; k < parLen; k++) {\n parameters[k] = Math.min(\n Math.max(minValues[k], parameters[k]),\n maxValues[k],\n );\n }\n\n error = errorCalculation(data, parameters, parameterizedFunction);\n if (isNaN(error)) break;\n converged = error <= errorTolerance;\n }\n\n return {\n parameterValues: parameters,\n parameterError: error,\n iterations: iteration,\n };\n}\n","/**\n * Returns a new array based on extraction of specific indices of an array\n * @private\n * @param {Array} vector\n * @param {Array} indices\n */\nexport default function selection(vector, indices) {\n let u = []; //new Float64Array(indices.length);\n for (let i = 0; i < indices.length; i++) {\n u[i] = vector[indices[i]];\n }\n return u;\n}\n","/**\n *\n * @private\n * @param {Array of arrays} collection\n */\nexport default function sortCollectionSet(collection) {\n let objectCollection = collection\n .map((value, index) => {\n let key = BigInt(0);\n value.forEach((item) => (key |= BigInt(1) << BigInt(item)));\n return { value, index, key };\n })\n .sort((a, b) => {\n if (a.key - b.key < 0) return -1;\n return 1;\n });\n\n let sorted = [];\n let indices = [];\n\n let key;\n for (let set of objectCollection) {\n if (set.key !== key) {\n key = set.key;\n indices.push([]);\n sorted.push(set.value);\n }\n indices[indices.length - 1].push(set.index);\n }\n\n let result = {\n values: sorted,\n indices: indices,\n };\n return result;\n}\n","import {\n Matrix,\n LuDecomposition,\n solve,\n CholeskyDecomposition,\n} from 'ml-matrix';\n\nimport sortCollectionSet from './util/sortCollectionSet';\n\n/**\n * (Combinatorial Subspace Least Squares) - subfunction for the FC-NNLS\n * @private\n * @param {Matrix} XtX\n * @param {Matrix} XtY\n * @param {Array} Pset\n * @param {Numbers} l\n * @param {Numbers} p\n */\nexport default function cssls(XtX, XtY, Pset, l, p) {\n // Solves the set of equation XtX*K = XtY for the variables in Pset\n // if XtX (or XtX(vars,vars)) is singular, performs the svd and find pseudoinverse, otherwise (even if ill-conditioned) finds inverse with LU decomposition and solves the set of equation\n // it is consistent with matlab results for ill-conditioned matrices (at least consistent with test 'ill-conditionned square X rank 2, Y 3x1' in cssls.test)\n\n let K = Matrix.zeros(l, p);\n if (Pset === null) {\n let choXtX = new CholeskyDecomposition(XtX);\n if (choXtX.isPositiveDefinite() === true) {\n K = choXtX.solve(XtY);\n } else {\n let luXtX = new LuDecomposition(XtX);\n if (luXtX.isSingular() === false) {\n K = luXtX.solve(Matrix.eye(l)).mmul(XtY);\n } else {\n K = solve(XtX, XtY, { useSVD: true });\n }\n }\n } else {\n let sortedPset = sortCollectionSet(Pset).values;\n let sortedEset = sortCollectionSet(Pset).indices;\n if (\n sortedPset.length === 1 &&\n sortedPset[0].length === 0 &&\n sortedEset[0].length === p\n ) {\n return K;\n } else if (\n sortedPset.length === 1 &&\n sortedPset[0].length === l &&\n sortedEset[0].length === p\n ) {\n let choXtX = new CholeskyDecomposition(XtX);\n if (choXtX.isPositiveDefinite() === true) {\n K = choXtX.solve(XtY);\n } else {\n let luXtX = new LuDecomposition(XtX);\n if (luXtX.isSingular() === false) {\n K = luXtX.solve(Matrix.eye(l)).mmul(XtY);\n } else {\n K = solve(XtX, XtY, { useSVD: true });\n }\n }\n } else {\n for (let k = 0; k < sortedPset.length; k++) {\n let cols2Solve = sortedEset[k];\n let vars = sortedPset[k];\n let L;\n let choXtX = new CholeskyDecomposition(XtX.selection(vars, vars));\n if (choXtX.isPositiveDefinite() === true) {\n L = choXtX.solve(XtY.selection(vars, cols2Solve));\n } else {\n let luXtX = new LuDecomposition(XtX.selection(vars, vars));\n if (luXtX.isSingular() === false) {\n L = luXtX\n .solve(Matrix.eye(vars.length))\n .mmul(XtY.selection(vars, cols2Solve));\n } else {\n L = solve(\n XtX.selection(vars, vars),\n XtY.selection(vars, cols2Solve),\n { useSVD: true },\n );\n }\n }\n for (let i = 0; i < L.rows; i++) {\n for (let j = 0; j < L.columns; j++) {\n K.set(vars[i], cols2Solve[j], L.get(i, j));\n }\n }\n }\n }\n }\n return K;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport cssls from './cssls';\n\nexport default function initialisation(X, Y) {\n let n = X.rows;\n let l = X.columns;\n let p = Y.columns;\n let iter = 0;\n\n if (Y.rows !== n) throw new Error('ERROR: matrix size not compatible');\n\n let W = Matrix.zeros(l, p);\n\n // precomputes part of pseudoinverse\n let XtX = X.transpose().mmul(X);\n let XtY = X.transpose().mmul(Y);\n\n let K = cssls(XtX, XtY, null, l, p); // K is lxp\n let Pset = [];\n for (let j = 0; j < p; j++) {\n Pset[j] = [];\n for (let i = 0; i < l; i++) {\n if (K.get(i, j) > 0) {\n Pset[j].push(i);\n } else {\n K.set(i, j, 0);\n } //This is our initial solution, it's the solution found by overwriting the unconstrained least square solution\n }\n }\n let Fset = [];\n for (let j = 0; j < p; j++) {\n if (Pset[j].length !== l) {\n Fset.push(j);\n }\n }\n\n let D = K.clone();\n\n return { n, l, p, iter, W, XtX, XtY, K, Pset, Fset, D };\n}\n","/**\n * Computes the set difference A\\B\n * @private\n * @param {A} set A as an array\n * @param {B} set B as an array\n */\nexport default function setDifference(A, B) {\n let C = [];\n for (let i of A) {\n if (!B.includes(i)) C.push(i);\n }\n return C;\n}\n","import setDifference from './util/setDifference';\n\n// Makes sure the solution has converged\nexport default function optimality(\n iter,\n maxIter,\n XtX,\n XtY,\n Fset,\n Pset,\n W,\n K,\n l,\n p,\n D,\n) {\n if (iter === maxIter) {\n throw new Error('Maximum number of iterations exceeded');\n }\n\n // Check solution for optimality\n let V = XtY.subMatrixColumn(Fset).subtract(XtX.mmul(K.subMatrixColumn(Fset)));\n for (let j = 0; j < Fset.length; j++) {\n W.setColumn(Fset[j], V.subMatrixColumn([j]));\n }\n let Jset = [];\n let fullSet = [];\n for (let i = 0; i < l; i++) {\n fullSet.push(i);\n }\n for (let j = 0; j < Fset.length; j++) {\n let notPset = setDifference(fullSet, Pset[Fset[j]]);\n if (notPset.length === 0) {\n Jset.push(Fset[j]);\n } else if (W.selection(notPset, [Fset[j]]).max() <= 0) {\n Jset.push(Fset[j]);\n }\n }\n Fset = setDifference(Fset, Jset);\n\n // For non-optimal solutions, add the appropriate variables to Pset\n if (Fset.length !== 0) {\n for (let j = 0; j < Fset.length; j++) {\n for (let i = 0; i < l; i++) {\n if (Pset[Fset[j]].includes(i)) W.set(i, Fset[j], -Infinity);\n }\n Pset[Fset[j]].push(W.subMatrixColumn(Fset).maxColumnIndex(j)[0]);\n }\n for (let j = 0; j < Fset.length; j++) {\n D.setColumn(Fset[j], K.getColumn(Fset[j]));\n }\n }\n for (let j = 0; j < p; j++) {\n Pset[j].sort((a, b) => a - b);\n }\n return { Pset, Fset, W };\n}\n","import { Matrix } from 'ml-matrix';\n\nimport selection from './util/selection';\nimport cssls from './cssls';\nimport initialisation from './initialisation';\nimport optimality from './optimality';\n\n/**\n * Fast Combinatorial Non-negative Least Squares with multiple Right Hand Side\n * @param {Matrix|number[][]} X\n * @param {Matrix|number[][]} Y\n * @param {object} [options={}]\n * @param {number} [options.maxIterations] if empty maxIterations is set at 3 times the number of columns of X\n * @returns {Matrix} K\n */\nexport default function fcnnls(X, Y, options = {}) {\n X = Matrix.checkMatrix(X);\n Y = Matrix.checkMatrix(Y);\n let { l, p, iter, W, XtX, XtY, K, Pset, Fset, D } = initialisation(X, Y);\n const { maxIterations = X.columns * 3 } = options;\n\n // Active set algorithm for NNLS main loop\n while (Fset.length > 0) {\n // Solves for the passive variables (uses subroutine below)\n let L = cssls(\n XtX,\n XtY.subMatrixColumn(Fset),\n selection(Pset, Fset),\n l,\n Fset.length,\n );\n for (let i = 0; i < l; i++) {\n for (let j = 0; j < Fset.length; j++) {\n K.set(i, Fset[j], L.get(i, j));\n }\n }\n\n // Finds any infeasible solutions\n let infeasIndex = [];\n for (let j = 0; j < Fset.length; j++) {\n for (let i = 0; i < l; i++) {\n if (L.get(i, j) < 0) {\n infeasIndex.push(j);\n break;\n }\n }\n }\n let Hset = selection(Fset, infeasIndex);\n\n // Makes infeasible solutions feasible (standard NNLS inner loop)\n if (Hset.length > 0) {\n let m = Hset.length;\n let alpha = Matrix.ones(l, m);\n\n while (m > 0 && iter < maxIterations) {\n iter++;\n\n alpha.mul(Infinity);\n\n // Finds indices of negative variables in passive set\n let hRowColIdx = [[], []]; // Indexes work in pairs, each pair reprensents a single element, first array is row index, second array is column index\n let negRowColIdx = [[], []]; // Same as before\n for (let j = 0; j < m; j++) {\n for (let i = 0; i < Pset[Hset[j]].length; i++) {\n if (K.get(Pset[Hset[j]][i], Hset[j]) < 0) {\n hRowColIdx[0].push(Pset[Hset[j]][i]); // i\n hRowColIdx[1].push(j);\n negRowColIdx[0].push(Pset[Hset[j]][i]); // i\n negRowColIdx[1].push(Hset[j]);\n } // Compared to matlab, here we keep the row/column indexing (we are not taking the linear indexing)\n }\n }\n\n for (let k = 0; k < hRowColIdx[0].length; k++) {\n // could be hRowColIdx[1].length as well\n alpha.set(\n hRowColIdx[0][k],\n hRowColIdx[1][k],\n D.get(negRowColIdx[0][k], negRowColIdx[1][k]) /\n (D.get(negRowColIdx[0][k], negRowColIdx[1][k]) -\n K.get(negRowColIdx[0][k], negRowColIdx[1][k])),\n );\n }\n\n let alphaMin = [];\n let minIdx = [];\n for (let j = 0; j < m; j++) {\n alphaMin[j] = alpha.minColumn(j);\n minIdx[j] = alpha.minColumnIndex(j)[0];\n }\n\n alphaMin = Matrix.rowVector(alphaMin);\n for (let i = 0; i < l; i++) {\n alpha.setSubMatrix(alphaMin, i, 0);\n }\n\n let E = new Matrix(l, m);\n E = D.subMatrixColumn(Hset).subtract(\n alpha\n .subMatrix(0, l - 1, 0, m - 1)\n .mul(D.subMatrixColumn(Hset).subtract(K.subMatrixColumn(Hset))),\n );\n for (let j = 0; j < m; j++) {\n D.setColumn(Hset[j], E.subMatrixColumn([j]));\n }\n\n let idx2zero = [minIdx, Hset];\n for (let k = 0; k < m; k++) {\n D.set(idx2zero[0][k], idx2zero[1][k], 0);\n }\n\n for (let j = 0; j < m; j++) {\n Pset[Hset[j]].splice(\n Pset[Hset[j]].findIndex((item) => item === minIdx[j]),\n 1,\n );\n }\n\n L = cssls(XtX, XtY.subMatrixColumn(Hset), selection(Pset, Hset), l, m);\n for (let j = 0; j < m; j++) {\n K.setColumn(Hset[j], L.subMatrixColumn([j]));\n }\n\n Hset = [];\n for (let j = 0; j < K.columns; j++) {\n for (let i = 0; i < l; i++) {\n if (K.get(i, j) < 0) {\n Hset.push(j);\n\n break;\n }\n }\n }\n m = Hset.length;\n }\n }\n\n let newParam = optimality(\n iter,\n maxIterations,\n XtX,\n XtY,\n Fset,\n Pset,\n W,\n K,\n l,\n p,\n D,\n );\n Pset = newParam.Pset;\n Fset = newParam.Fset;\n W = newParam.W;\n }\n\n return K;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport fcnnls from './fcnnls';\n\n/**\n * Fast Combinatorial Non-negative Least Squares with single Right Hand Side\n * @param {Matrix|number[][]} X\n * @param {number[]} y\n * @param {object} [options={}]\n * @param {boolean} [maxIterations] if true or empty maxIterations is set at 3 times the number of columns of X\n * @returns {Array} k\n */\nexport default function fcnnlsVector(X, y, options = {}) {\n if (Array.isArray(y) === false) {\n throw new TypeError('y must be a 1D Array');\n }\n let Y = Matrix.columnVector(y);\n let K = fcnnls(X, Y, options);\n let k = K.to1DArray();\n return k;\n}\n","module.exports = function(haystack, needle, comparator, low, high) {\n var mid, cmp;\n\n if(low === undefined)\n low = 0;\n\n else {\n low = low|0;\n if(low < 0 || low >= haystack.length)\n throw new RangeError(\"invalid lower bound\");\n }\n\n if(high === undefined)\n high = haystack.length - 1;\n\n else {\n high = high|0;\n if(high < low || high >= haystack.length)\n throw new RangeError(\"invalid upper bound\");\n }\n\n while(low <= high) {\n // The naive `low + high >>> 1` could fail for array lengths > 2**31\n // because `>>>` converts its operands to int32. `low + (high - low >>> 1)`\n // works for array lengths <= 2**32-1 which is also Javascript's max array\n // length.\n mid = low + ((high - low) >>> 1);\n cmp = +comparator(haystack[mid], needle, mid, haystack);\n\n // Too low.\n if(cmp < 0.0)\n low = mid + 1;\n\n // Too high.\n else if(cmp > 0.0)\n high = mid - 1;\n\n // Key found.\n else\n return mid;\n }\n\n // Key not found.\n return ~low;\n}\n","'use strict';\n\nfunction assertNumber(number) {\n\tif (typeof number !== 'number') {\n\t\tthrow new TypeError('Expected a number');\n\t}\n}\n\nexports.ascending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\n\tif (Number.isNaN(left)) {\n\t\treturn -1;\n\t}\n\n\tif (Number.isNaN(right)) {\n\t\treturn 1;\n\t}\n\n\treturn left - right;\n};\n\nexports.descending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\n\tif (Number.isNaN(left)) {\n\t\treturn 1;\n\t}\n\n\tif (Number.isNaN(right)) {\n\t\treturn -1;\n\t}\n\n\treturn right - left;\n};\n","import binarySearch from 'binary-search';\nimport { ascending } from 'num-sort';\n\nexport const largestPrime = 0x7fffffff;\n\nconst primeNumbers = [\n // chunk #0\n largestPrime, // 2^31-1\n\n // chunk #1\n 5,\n 11,\n 23,\n 47,\n 97,\n 197,\n 397,\n 797,\n 1597,\n 3203,\n 6421,\n 12853,\n 25717,\n 51437,\n 102877,\n 205759,\n 411527,\n 823117,\n 1646237,\n 3292489,\n 6584983,\n 13169977,\n 26339969,\n 52679969,\n 105359939,\n 210719881,\n 421439783,\n 842879579,\n 1685759167,\n\n // chunk #2\n 433,\n 877,\n 1759,\n 3527,\n 7057,\n 14143,\n 28289,\n 56591,\n 113189,\n 226379,\n 452759,\n 905551,\n 1811107,\n 3622219,\n 7244441,\n 14488931,\n 28977863,\n 57955739,\n 115911563,\n 231823147,\n 463646329,\n 927292699,\n 1854585413,\n\n // chunk #3\n 953,\n 1907,\n 3821,\n 7643,\n 15287,\n 30577,\n 61169,\n 122347,\n 244703,\n 489407,\n 978821,\n 1957651,\n 3915341,\n 7830701,\n 15661423,\n 31322867,\n 62645741,\n 125291483,\n 250582987,\n 501165979,\n 1002331963,\n 2004663929,\n\n // chunk #4\n 1039,\n 2081,\n 4177,\n 8363,\n 16729,\n 33461,\n 66923,\n 133853,\n 267713,\n 535481,\n 1070981,\n 2141977,\n 4283963,\n 8567929,\n 17135863,\n 34271747,\n 68543509,\n 137087021,\n 274174111,\n 548348231,\n 1096696463,\n\n // chunk #5\n 31,\n 67,\n 137,\n 277,\n 557,\n 1117,\n 2237,\n 4481,\n 8963,\n 17929,\n 35863,\n 71741,\n 143483,\n 286973,\n 573953,\n 1147921,\n 2295859,\n 4591721,\n 9183457,\n 18366923,\n 36733847,\n 73467739,\n 146935499,\n 293871013,\n 587742049,\n 1175484103,\n\n // chunk #6\n 599,\n 1201,\n 2411,\n 4831,\n 9677,\n 19373,\n 38747,\n 77509,\n 155027,\n 310081,\n 620171,\n 1240361,\n 2480729,\n 4961459,\n 9922933,\n 19845871,\n 39691759,\n 79383533,\n 158767069,\n 317534141,\n 635068283,\n 1270136683,\n\n // chunk #7\n 311,\n 631,\n 1277,\n 2557,\n 5119,\n 10243,\n 20507,\n 41017,\n 82037,\n 164089,\n 328213,\n 656429,\n 1312867,\n 2625761,\n 5251529,\n 10503061,\n 21006137,\n 42012281,\n 84024581,\n 168049163,\n 336098327,\n 672196673,\n 1344393353,\n\n // chunk #8\n 3,\n 7,\n 17,\n 37,\n 79,\n 163,\n 331,\n 673,\n 1361,\n 2729,\n 5471,\n 10949,\n 21911,\n 43853,\n 87719,\n 175447,\n 350899,\n 701819,\n 1403641,\n 2807303,\n 5614657,\n 11229331,\n 22458671,\n 44917381,\n 89834777,\n 179669557,\n 359339171,\n 718678369,\n 1437356741,\n\n // chunk #9\n 43,\n 89,\n 179,\n 359,\n 719,\n 1439,\n 2879,\n 5779,\n 11579,\n 23159,\n 46327,\n 92657,\n 185323,\n 370661,\n 741337,\n 1482707,\n 2965421,\n 5930887,\n 11861791,\n 23723597,\n 47447201,\n 94894427,\n 189788857,\n 379577741,\n 759155483,\n 1518310967,\n\n // chunk #10\n 379,\n 761,\n 1523,\n 3049,\n 6101,\n 12203,\n 24407,\n 48817,\n 97649,\n 195311,\n 390647,\n 781301,\n 1562611,\n 3125257,\n 6250537,\n 12501169,\n 25002389,\n 50004791,\n 100009607,\n 200019221,\n 400038451,\n 800076929,\n 1600153859,\n\n // chunk #11\n 13,\n 29,\n 59,\n 127,\n 257,\n 521,\n 1049,\n 2099,\n 4201,\n 8419,\n 16843,\n 33703,\n 67409,\n 134837,\n 269683,\n 539389,\n 1078787,\n 2157587,\n 4315183,\n 8630387,\n 17260781,\n 34521589,\n 69043189,\n 138086407,\n 276172823,\n 552345671,\n 1104691373,\n\n // chunk #12\n 19,\n 41,\n 83,\n 167,\n 337,\n 677,\n 1361,\n 2729,\n 5471,\n 10949,\n 21911,\n 43853,\n 87719,\n 175447,\n 350899,\n 701819,\n 1403641,\n 2807303,\n 5614657,\n 11229331,\n 22458671,\n 44917381,\n 89834777,\n 179669557,\n 359339171,\n 718678369,\n 1437356741,\n\n // chunk #13\n 53,\n 107,\n 223,\n 449,\n 907,\n 1823,\n 3659,\n 7321,\n 14653,\n 29311,\n 58631,\n 117269,\n 234539,\n 469099,\n 938207,\n 1876417,\n 3752839,\n 7505681,\n 15011389,\n 30022781,\n 60045577,\n 120091177,\n 240182359,\n 480364727,\n 960729461,\n 1921458943\n];\n\nprimeNumbers.sort(ascending);\n\nexport function nextPrime(value) {\n let index = binarySearch(primeNumbers, value, ascending);\n if (index < 0) {\n index = ~index;\n }\n return primeNumbers[index];\n}\n","import { largestPrime, nextPrime } from './primeFinder';\n\nconst FREE = 0;\nconst FULL = 1;\nconst REMOVED = 2;\n\nconst defaultInitialCapacity = 150;\nconst defaultMinLoadFactor = 1 / 6;\nconst defaultMaxLoadFactor = 2 / 3;\n\nexport default class HashTable {\n constructor(options = {}) {\n if (options instanceof HashTable) {\n this.table = options.table.slice();\n this.values = options.values.slice();\n this.state = options.state.slice();\n this.minLoadFactor = options.minLoadFactor;\n this.maxLoadFactor = options.maxLoadFactor;\n this.distinct = options.distinct;\n this.freeEntries = options.freeEntries;\n this.lowWaterMark = options.lowWaterMark;\n this.highWaterMark = options.maxLoadFactor;\n return;\n }\n\n const initialCapacity =\n options.initialCapacity === undefined\n ? defaultInitialCapacity\n : options.initialCapacity;\n if (initialCapacity < 0) {\n throw new RangeError(\n `initial capacity must not be less than zero: ${initialCapacity}`\n );\n }\n\n const minLoadFactor =\n options.minLoadFactor === undefined\n ? defaultMinLoadFactor\n : options.minLoadFactor;\n const maxLoadFactor =\n options.maxLoadFactor === undefined\n ? defaultMaxLoadFactor\n : options.maxLoadFactor;\n if (minLoadFactor < 0 || minLoadFactor >= 1) {\n throw new RangeError(`invalid minLoadFactor: ${minLoadFactor}`);\n }\n if (maxLoadFactor <= 0 || maxLoadFactor >= 1) {\n throw new RangeError(`invalid maxLoadFactor: ${maxLoadFactor}`);\n }\n if (minLoadFactor >= maxLoadFactor) {\n throw new RangeError(\n `minLoadFactor (${minLoadFactor}) must be smaller than maxLoadFactor (${maxLoadFactor})`\n );\n }\n\n let capacity = initialCapacity;\n // User wants to put at least capacity elements. We need to choose the size based on the maxLoadFactor to\n // avoid the need to rehash before this capacity is reached.\n // actualCapacity * maxLoadFactor >= capacity\n capacity = (capacity / maxLoadFactor) | 0;\n capacity = nextPrime(capacity);\n if (capacity === 0) capacity = 1;\n\n this.table = newArray(capacity);\n this.values = newArray(capacity);\n this.state = newArray(capacity);\n\n this.minLoadFactor = minLoadFactor;\n if (capacity === largestPrime) {\n this.maxLoadFactor = 1;\n } else {\n this.maxLoadFactor = maxLoadFactor;\n }\n\n this.distinct = 0;\n this.freeEntries = capacity;\n\n this.lowWaterMark = 0;\n this.highWaterMark = chooseHighWaterMark(capacity, this.maxLoadFactor);\n }\n\n clone() {\n return new HashTable(this);\n }\n\n get size() {\n return this.distinct;\n }\n\n get(key) {\n const i = this.indexOfKey(key);\n if (i < 0) return 0;\n return this.values[i];\n }\n\n set(key, value) {\n let i = this.indexOfInsertion(key);\n if (i < 0) {\n i = -i - 1;\n this.values[i] = value;\n return false;\n }\n\n if (this.distinct > this.highWaterMark) {\n const newCapacity = chooseGrowCapacity(\n this.distinct + 1,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n return this.set(key, value);\n }\n\n this.table[i] = key;\n this.values[i] = value;\n if (this.state[i] === FREE) this.freeEntries--;\n this.state[i] = FULL;\n this.distinct++;\n\n if (this.freeEntries < 1) {\n const newCapacity = chooseGrowCapacity(\n this.distinct + 1,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n }\n\n return true;\n }\n\n remove(key, noRehash) {\n const i = this.indexOfKey(key);\n if (i < 0) return false;\n\n this.state[i] = REMOVED;\n this.distinct--;\n\n if (!noRehash) this.maybeShrinkCapacity();\n\n return true;\n }\n\n delete(key, noRehash) {\n const i = this.indexOfKey(key);\n if (i < 0) return false;\n\n this.state[i] = FREE;\n this.distinct--;\n\n if (!noRehash) this.maybeShrinkCapacity();\n\n return true;\n }\n\n maybeShrinkCapacity() {\n if (this.distinct < this.lowWaterMark) {\n const newCapacity = chooseShrinkCapacity(\n this.distinct,\n this.minLoadFactor,\n this.maxLoadFactor\n );\n this.rehash(newCapacity);\n }\n }\n\n containsKey(key) {\n return this.indexOfKey(key) >= 0;\n }\n\n indexOfKey(key) {\n const table = this.table;\n const state = this.state;\n const length = this.table.length;\n\n const hash = key & 0x7fffffff;\n let i = hash % length;\n let decrement = hash % (length - 2);\n if (decrement === 0) decrement = 1;\n\n while (state[i] !== FREE && (state[i] === REMOVED || table[i] !== key)) {\n i -= decrement;\n if (i < 0) i += length;\n }\n\n if (state[i] === FREE) return -1;\n return i;\n }\n\n containsValue(value) {\n return this.indexOfValue(value) >= 0;\n }\n\n indexOfValue(value) {\n const values = this.values;\n const state = this.state;\n\n for (var i = 0; i < state.length; i++) {\n if (state[i] === FULL && values[i] === value) {\n return i;\n }\n }\n\n return -1;\n }\n\n indexOfInsertion(key) {\n const table = this.table;\n const state = this.state;\n const length = table.length;\n\n const hash = key & 0x7fffffff;\n let i = hash % length;\n let decrement = hash % (length - 2);\n if (decrement === 0) decrement = 1;\n\n while (state[i] === FULL && table[i] !== key) {\n i -= decrement;\n if (i < 0) i += length;\n }\n\n if (state[i] === REMOVED) {\n const j = i;\n while (state[i] !== FREE && (state[i] === REMOVED || table[i] !== key)) {\n i -= decrement;\n if (i < 0) i += length;\n }\n if (state[i] === FREE) i = j;\n }\n\n if (state[i] === FULL) {\n return -i - 1;\n }\n\n return i;\n }\n\n ensureCapacity(minCapacity) {\n if (this.table.length < minCapacity) {\n const newCapacity = nextPrime(minCapacity);\n this.rehash(newCapacity);\n }\n }\n\n rehash(newCapacity) {\n const oldCapacity = this.table.length;\n\n if (newCapacity <= this.distinct) throw new Error('Unexpected');\n\n const oldTable = this.table;\n const oldValues = this.values;\n const oldState = this.state;\n\n const newTable = newArray(newCapacity);\n const newValues = newArray(newCapacity);\n const newState = newArray(newCapacity);\n\n this.lowWaterMark = chooseLowWaterMark(newCapacity, this.minLoadFactor);\n this.highWaterMark = chooseHighWaterMark(newCapacity, this.maxLoadFactor);\n\n this.table = newTable;\n this.values = newValues;\n this.state = newState;\n this.freeEntries = newCapacity - this.distinct;\n\n for (var i = 0; i < oldCapacity; i++) {\n if (oldState[i] === FULL) {\n var element = oldTable[i];\n var index = this.indexOfInsertion(element);\n newTable[index] = element;\n newValues[index] = oldValues[i];\n newState[index] = FULL;\n }\n }\n }\n\n forEachKey(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.table[i])) return false;\n }\n }\n return true;\n }\n\n forEachValue(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.values[i])) return false;\n }\n }\n return true;\n }\n\n forEachPair(callback) {\n for (var i = 0; i < this.state.length; i++) {\n if (this.state[i] === FULL) {\n if (!callback(this.table[i], this.values[i])) return false;\n }\n }\n return true;\n }\n}\n\nfunction chooseLowWaterMark(capacity, minLoad) {\n return (capacity * minLoad) | 0;\n}\n\nfunction chooseHighWaterMark(capacity, maxLoad) {\n return Math.min(capacity - 2, (capacity * maxLoad) | 0);\n}\n\nfunction chooseGrowCapacity(size, minLoad, maxLoad) {\n return nextPrime(\n Math.max(size + 1, ((4 * size) / (3 * minLoad + maxLoad)) | 0)\n );\n}\n\nfunction chooseShrinkCapacity(size, minLoad, maxLoad) {\n return nextPrime(\n Math.max(size + 1, ((4 * size) / (minLoad + 3 * maxLoad)) | 0)\n );\n}\n\nfunction newArray(size) {\n return Array(size).fill(0);\n}\n","import HashTable from 'ml-hash-table';\n\nexport class SparseMatrix {\n constructor(rows, columns, options = {}) {\n if (rows instanceof SparseMatrix) {\n // clone\n const other = rows;\n this._init(\n other.rows,\n other.columns,\n other.elements.clone(),\n other.threshold\n );\n return;\n }\n\n if (Array.isArray(rows)) {\n const matrix = rows;\n rows = matrix.length;\n options = columns || {};\n columns = matrix[0].length;\n this._init(rows, columns, new HashTable(options), options.threshold);\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n var value = matrix[i][j];\n if (this.threshold && Math.abs(value) < this.threshold) value = 0;\n if (value !== 0) {\n this.elements.set(i * columns + j, matrix[i][j]);\n }\n }\n }\n } else {\n this._init(rows, columns, new HashTable(options), options.threshold);\n }\n }\n\n _init(rows, columns, elements, threshold) {\n this.rows = rows;\n this.columns = columns;\n this.elements = elements;\n this.threshold = threshold || 0;\n }\n\n static eye(rows = 1, columns = rows) {\n const min = Math.min(rows, columns);\n const matrix = new SparseMatrix(rows, columns, { initialCapacity: min });\n for (var i = 0; i < min; i++) {\n matrix.set(i, i, 1);\n }\n return matrix;\n }\n\n clone() {\n return new SparseMatrix(this);\n }\n\n to2DArray() {\n const copy = new Array(this.rows);\n for (var i = 0; i < this.rows; i++) {\n copy[i] = new Array(this.columns);\n for (var j = 0; j < this.columns; j++) {\n copy[i][j] = this.get(i, j);\n }\n }\n return copy;\n }\n\n isSquare() {\n return this.rows === this.columns;\n }\n\n isSymmetric() {\n if (!this.isSquare()) return false;\n\n var symmetric = true;\n this.forEachNonZero((i, j, v) => {\n if (this.get(j, i) !== v) {\n symmetric = false;\n return false;\n }\n return v;\n });\n return symmetric;\n }\n\n /**\n * Search for the wither band in the main diagonals\n * @return {number}\n */\n bandWidth() {\n let min = this.columns;\n let max = -1;\n this.forEachNonZero((i, j, v) => {\n let diff = i - j;\n min = Math.min(min, diff);\n max = Math.max(max, diff);\n return v;\n });\n return max - min;\n }\n\n /**\n * Test if a matrix is consider banded using a threshold\n * @param {number} width\n * @return {boolean}\n */\n isBanded(width) {\n let bandWidth = this.bandWidth();\n return bandWidth <= width;\n }\n\n get cardinality() {\n return this.elements.size;\n }\n\n get size() {\n return this.rows * this.columns;\n }\n\n get(row, column) {\n return this.elements.get(row * this.columns + column);\n }\n\n set(row, column, value) {\n if (this.threshold && Math.abs(value) < this.threshold) value = 0;\n if (value === 0) {\n this.elements.remove(row * this.columns + column);\n } else {\n this.elements.set(row * this.columns + column, value);\n }\n return this;\n }\n\n mmul(other) {\n if (this.columns !== other.rows) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Number of columns of left matrix are not equal to number of rows of right matrix.'\n );\n }\n\n const m = this.rows;\n const p = other.columns;\n\n const result = new SparseMatrix(m, p);\n this.forEachNonZero((i, j, v1) => {\n other.forEachNonZero((k, l, v2) => {\n if (j === k) {\n result.set(i, l, result.get(i, l) + v1 * v2);\n }\n return v2;\n });\n return v1;\n });\n return result;\n }\n\n kroneckerProduct(other) {\n const m = this.rows;\n const n = this.columns;\n const p = other.rows;\n const q = other.columns;\n\n const result = new SparseMatrix(m * p, n * q, {\n initialCapacity: this.cardinality * other.cardinality\n });\n this.forEachNonZero((i, j, v1) => {\n other.forEachNonZero((k, l, v2) => {\n result.set(p * i + k, q * j + l, v1 * v2);\n return v2;\n });\n return v1;\n });\n return result;\n }\n\n forEachNonZero(callback) {\n this.elements.forEachPair((key, value) => {\n const i = (key / this.columns) | 0;\n const j = key % this.columns;\n let r = callback(i, j, value);\n if (r === false) return false; // stop iteration\n if (this.threshold && Math.abs(r) < this.threshold) r = 0;\n if (r !== value) {\n if (r === 0) {\n this.elements.remove(key, true);\n } else {\n this.elements.set(key, r);\n }\n }\n return true;\n });\n this.elements.maybeShrinkCapacity();\n return this;\n }\n\n getNonZeros() {\n const cardinality = this.cardinality;\n const rows = new Array(cardinality);\n const columns = new Array(cardinality);\n const values = new Array(cardinality);\n var idx = 0;\n this.forEachNonZero((i, j, value) => {\n rows[idx] = i;\n columns[idx] = j;\n values[idx] = value;\n idx++;\n return value;\n });\n return { rows, columns, values };\n }\n\n setThreshold(newThreshold) {\n if (newThreshold !== 0 && newThreshold !== this.threshold) {\n this.threshold = newThreshold;\n this.forEachNonZero((i, j, v) => v);\n }\n return this;\n }\n\n /**\n * @return {SparseMatrix} - New transposed sparse matrix\n */\n transpose() {\n let trans = new SparseMatrix(this.columns, this.rows, {\n initialCapacity: this.cardinality\n });\n this.forEachNonZero((i, j, value) => {\n trans.set(j, i, value);\n return value;\n });\n return trans;\n }\n}\n\nSparseMatrix.prototype.klass = 'Matrix';\n\nSparseMatrix.identity = SparseMatrix.eye;\nSparseMatrix.prototype.tensorProduct = SparseMatrix.prototype.kroneckerProduct;\n\n/*\n Add dynamically instance and static methods for mathematical operations\n */\n\nvar inplaceOperator = `\n(function %name%(value) {\n if (typeof value === 'number') return this.%name%S(value);\n return this.%name%M(value);\n})\n`;\n\nvar inplaceOperatorScalar = `\n(function %name%S(value) {\n this.forEachNonZero((i, j, v) => v %op% value);\n return this;\n})\n`;\n\nvar inplaceOperatorMatrix = `\n(function %name%M(matrix) {\n matrix.forEachNonZero((i, j, v) => {\n this.set(i, j, this.get(i, j) %op% v);\n return v;\n });\n return this;\n})\n`;\n\nvar staticOperator = `\n(function %name%(matrix, value) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%(value);\n})\n`;\n\nvar inplaceMethod = `\n(function %name%() {\n this.forEachNonZero((i, j, v) => %method%(v));\n return this;\n})\n`;\n\nvar staticMethod = `\n(function %name%(matrix) {\n var newMatrix = new SparseMatrix(matrix);\n return newMatrix.%name%();\n})\n`;\n\nconst operators = [\n // Arithmetic operators\n ['+', 'add'],\n ['-', 'sub', 'subtract'],\n ['*', 'mul', 'multiply'],\n ['/', 'div', 'divide'],\n ['%', 'mod', 'modulus'],\n // Bitwise operators\n ['&', 'and'],\n ['|', 'or'],\n ['^', 'xor'],\n ['<<', 'leftShift'],\n ['>>', 'signPropagatingRightShift'],\n ['>>>', 'rightShift', 'zeroFillRightShift']\n];\n\nfor (const operator of operators) {\n for (let i = 1; i < operator.length; i++) {\n SparseMatrix.prototype[operator[i]] = eval(\n fillTemplateFunction(inplaceOperator, {\n name: operator[i],\n op: operator[0]\n })\n );\n SparseMatrix.prototype[`${operator[i]}S`] = eval(\n fillTemplateFunction(inplaceOperatorScalar, {\n name: `${operator[i]}S`,\n op: operator[0]\n })\n );\n SparseMatrix.prototype[`${operator[i]}M`] = eval(\n fillTemplateFunction(inplaceOperatorMatrix, {\n name: `${operator[i]}M`,\n op: operator[0]\n })\n );\n\n SparseMatrix[operator[i]] = eval(\n fillTemplateFunction(staticOperator, { name: operator[i] })\n );\n }\n}\n\nvar methods = [['~', 'not']];\n\n[\n 'abs',\n 'acos',\n 'acosh',\n 'asin',\n 'asinh',\n 'atan',\n 'atanh',\n 'cbrt',\n 'ceil',\n 'clz32',\n 'cos',\n 'cosh',\n 'exp',\n 'expm1',\n 'floor',\n 'fround',\n 'log',\n 'log1p',\n 'log10',\n 'log2',\n 'round',\n 'sign',\n 'sin',\n 'sinh',\n 'sqrt',\n 'tan',\n 'tanh',\n 'trunc'\n].forEach(function (mathMethod) {\n methods.push([`Math.${mathMethod}`, mathMethod]);\n});\n\nfor (const method of methods) {\n for (let i = 1; i < method.length; i++) {\n SparseMatrix.prototype[method[i]] = eval(\n fillTemplateFunction(inplaceMethod, {\n name: method[i],\n method: method[0]\n })\n );\n SparseMatrix[method[i]] = eval(\n fillTemplateFunction(staticMethod, { name: method[i] })\n );\n }\n}\n\nfunction fillTemplateFunction(template, values) {\n for (const i in values) {\n template = template.replace(new RegExp(`%${i}%`, 'g'), values[i]);\n }\n return template;\n}\n","export default function additiveSymmetric(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i]) * (a[i] + b[i])) / (a[i] * b[i]);\n }\n return 2 * d;\n}\n","export default function avg(a, b) {\n var ii = a.length;\n var max = 0;\n var ans = 0;\n var aux = 0;\n for (var i = 0; i < ii; i++) {\n aux = Math.abs(a[i] - b[i]);\n ans += aux;\n if (max < aux) {\n max = aux;\n }\n }\n return (max + ans) / 2;\n}\n","export default function bhattacharyya(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return -Math.log(ans);\n}\n","export default function canberra(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.abs(a[i] - b[i]) / (a[i] + b[i]);\n }\n return ans;\n}\n","export default function chebyshev(a, b) {\n var ii = a.length;\n var max = 0;\n var aux = 0;\n for (var i = 0; i < ii; i++) {\n aux = Math.abs(a[i] - b[i]);\n if (max < aux) {\n max = aux;\n }\n }\n return max;\n}\n","export default function clark(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.sqrt(\n ((a[i] - b[i]) * (a[i] - b[i])) / ((a[i] + b[i]) * (a[i] + b[i]))\n );\n }\n return 2 * d;\n}\n","export default function czekanowskiSimilarity(a, b) {\n var up = 0;\n var down = 0;\n for (var i = 0; i < a.length; i++) {\n up += Math.min(a[i], b[i]);\n down += a[i] + b[i];\n }\n return (2 * up) / down;\n}\n","import czekanowskiSimilarity from '../similarities/czekanowski';\n\nexport default function czekanowskiDistance(a, b) {\n return 1 - czekanowskiSimilarity(a, b);\n}\n","export default function dice(a, b) {\n var ii = a.length;\n var p = 0;\n var q1 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * a[i];\n q1 += b[i] * b[i];\n q2 += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return q2 / (p + q1);\n}\n","export default function divergence(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / ((a[i] + b[i]) * (a[i] + b[i]));\n }\n return 2 * d;\n}\n","export default function fidelity(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return ans;\n}\n","export default function gower(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.abs(a[i] - b[i]);\n }\n return ans / ii;\n}\n","export default function harmonicMean(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += (a[i] * b[i]) / (a[i] + b[i]);\n }\n return 2 * ans;\n}\n","export default function hellinger(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return 2 * Math.sqrt(1 - ans);\n}\n","export default function innerProduct(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * b[i];\n }\n return ans;\n}\n","export default function intersection(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.min(a[i], b[i]);\n }\n return 1 - ans;\n}\n","export default function jaccard(a, b) {\n var ii = a.length;\n var p1 = 0;\n var p2 = 0;\n var q1 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p1 += a[i] * b[i];\n p2 += a[i] * a[i];\n q1 += b[i] * b[i];\n q2 += (a[i] - b[i]) * (a[i] - b[i]);\n }\n return q2 / (p2 + q1 - p1);\n}\n","export default function jeffreys(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += (a[i] - b[i]) * Math.log(a[i] / b[i]);\n }\n return ans;\n}\n","export default function jensenDifference(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n (a[i] * Math.log(a[i]) + b[i] * Math.log(b[i])) / 2 -\n ((a[i] + b[i]) / 2) * Math.log((a[i] + b[i]) / 2);\n }\n return ans;\n}\n","export default function jensenShannon(a, b) {\n var ii = a.length;\n var p = 0;\n var q = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * Math.log((2 * a[i]) / (a[i] + b[i]));\n q += b[i] * Math.log((2 * b[i]) / (a[i] + b[i]));\n }\n return (p + q) / 2;\n}\n","export default function kdivergence(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * Math.log((2 * a[i]) / (a[i] + b[i]));\n }\n return ans;\n}\n","export default function kulczynski(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += Math.min(a[i], b[i]);\n }\n return up / down;\n}\n","export default function kullbackLeibler(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += a[i] * Math.log(a[i] / b[i]);\n }\n return ans;\n}\n","export default function kumarHassebrook(a, b) {\n var ii = a.length;\n var p = 0;\n var p2 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * b[i];\n p2 += a[i] * a[i];\n q2 += b[i] * b[i];\n }\n return p / (p2 + q2 - p);\n}\n","export default function kumarJohnson(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n Math.pow(a[i] * a[i] - b[i] * b[i], 2) / (2 * Math.pow(a[i] * b[i], 1.5));\n }\n return ans;\n}\n","export default function lorentzian(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.log(Math.abs(a[i] - b[i]) + 1);\n }\n return ans;\n}\n","export default function manhattan(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.abs(a[i] - b[i]);\n }\n return d;\n}\n","export default function matusita(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += Math.sqrt(a[i] * b[i]);\n }\n return Math.sqrt(2 - 2 * ans);\n}\n","export default function minkowski(a, b, p) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += Math.pow(Math.abs(a[i] - b[i]), p);\n }\n return Math.pow(d, 1 / p);\n}\n","export default function motyka(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.min(a[i], b[i]);\n down += a[i] + b[i];\n }\n return 1 - up / down;\n}\n","export default function neyman(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / a[i];\n }\n return d;\n}\n","export default function pearson(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / b[i];\n }\n return d;\n}\n","export default function probabilisticSymmetric(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / (a[i] + b[i]);\n }\n return 2 * d;\n}\n","export default function ruzicka(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.min(a[i], b[i]);\n down += Math.max(a[i], b[i]);\n }\n return up / down;\n}\n","export default function soergel(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += Math.max(a[i], b[i]);\n }\n return up / down;\n}\n","export default function sorensen(a, b) {\n var ii = a.length;\n var up = 0;\n var down = 0;\n for (var i = 0; i < ii; i++) {\n up += Math.abs(a[i] - b[i]);\n down += a[i] + b[i];\n }\n return up / down;\n}\n","export default function squared(a, b) {\n var i = 0;\n var ii = a.length;\n var d = 0;\n for (; i < ii; i++) {\n d += ((a[i] - b[i]) * (a[i] - b[i])) / (a[i] + b[i]);\n }\n return d;\n}\n","export default function squaredChord(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n (Math.sqrt(a[i]) - Math.sqrt(b[i])) * (Math.sqrt(a[i]) - Math.sqrt(b[i]));\n }\n return ans;\n}\n","export default function taneja(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n ((a[i] + b[i]) / 2) *\n Math.log((a[i] + b[i]) / (2 * Math.sqrt(a[i] * b[i])));\n }\n return ans;\n}\n","export default function tanimoto(a, b, bitvector) {\n if (bitvector) {\n var inter = 0;\n var union = 0;\n for (var j = 0; j < a.length; j++) {\n inter += a[j] && b[j];\n union += a[j] || b[j];\n }\n if (union === 0) {\n return 1;\n }\n return inter / union;\n } else {\n var ii = a.length;\n var p = 0;\n var q = 0;\n var m = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i];\n q += b[i];\n m += Math.min(a[i], b[i]);\n }\n return 1 - (p + q - 2 * m) / (p + q - m);\n }\n}\n","import tanimotoS from '../similarities/tanimoto';\n\nexport default function tanimoto(a, b, bitvector) {\n if (bitvector) {\n return 1 - tanimotoS(a, b, bitvector);\n } else {\n var ii = a.length;\n var p = 0;\n var q = 0;\n var m = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i];\n q += b[i];\n m += Math.min(a[i], b[i]);\n }\n return (p + q - 2 * m) / (p + q - m);\n }\n}\n","export default function topsoe(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans +=\n a[i] * Math.log((2 * a[i]) / (a[i] + b[i])) +\n b[i] * Math.log((2 * b[i]) / (a[i] + b[i]));\n }\n return ans;\n}\n","export default function waveHedges(a, b) {\n var ii = a.length;\n var ans = 0;\n for (var i = 0; i < ii; i++) {\n ans += 1 - Math.min(a[i], b[i]) / Math.max(a[i], b[i]);\n }\n return ans;\n}\n","import binarySearch from 'binary-search';\nimport { ascending } from 'num-sort';\n\n/**\n * Function that creates the tree\n * @param {Array>} spectrum\n * @param {object} [options]\n * @return {Tree|null}\n * left and right have the same structure than the parent,\n * or are null if they are leaves\n */\nexport function createTree(spectrum, options = {}) {\n var X = spectrum[0];\n const {\n minWindow = 0.16,\n threshold = 0.01,\n from = X[0],\n to = X[X.length - 1]\n } = options;\n\n return mainCreateTree(\n spectrum[0],\n spectrum[1],\n from,\n to,\n minWindow,\n threshold\n );\n}\n\nfunction mainCreateTree(X, Y, from, to, minWindow, threshold) {\n if (to - from < minWindow) {\n return null;\n }\n\n // search first point\n var start = binarySearch(X, from, ascending);\n if (start < 0) {\n start = ~start;\n }\n\n // stop at last point\n var sum = 0;\n var center = 0;\n for (var i = start; i < X.length; i++) {\n if (X[i] >= to) {\n break;\n }\n sum += Y[i];\n center += X[i] * Y[i];\n }\n\n if (sum < threshold) {\n return null;\n }\n\n center /= sum;\n if (center - from < 1e-6 || to - center < 1e-6) {\n return null;\n }\n if (center - from < minWindow / 4) {\n return mainCreateTree(X, Y, center, to, minWindow, threshold);\n } else {\n if (to - center < minWindow / 4) {\n return mainCreateTree(X, Y, from, center, minWindow, threshold);\n } else {\n return new Tree(\n sum,\n center,\n mainCreateTree(X, Y, from, center, minWindow, threshold),\n mainCreateTree(X, Y, center, to, minWindow, threshold)\n );\n }\n }\n}\n\nclass Tree {\n constructor(sum, center, left, right) {\n this.sum = sum;\n this.center = center;\n this.left = left;\n this.right = right;\n }\n}\n","import { createTree } from './createTree';\n\n/**\n * Similarity between two nodes\n * @param {Tree|Array>} a - tree A node\n * @param {Tree|Array>} b - tree B node\n * @param {object} [options]\n * @return {number} similarity measure between tree nodes\n */\nexport function getSimilarity(a, b, options = {}) {\n const { alpha = 0.1, beta = 0.33, gamma = 0.001 } = options;\n\n if (a === null || b === null) {\n return 0;\n }\n if (Array.isArray(a)) {\n a = createTree(a);\n }\n if (Array.isArray(b)) {\n b = createTree(b);\n }\n\n var C =\n (alpha * Math.min(a.sum, b.sum)) / Math.max(a.sum, b.sum) +\n (1 - alpha) * Math.exp(-gamma * Math.abs(a.center - b.center));\n\n return (\n beta * C +\n ((1 - beta) *\n (getSimilarity(a.left, b.left, options) +\n getSimilarity(a.right, b.right, options))) /\n 2\n );\n}\n","import { getSimilarity } from './getSimilarity';\n\nexport { createTree } from './createTree';\n\nexport function treeSimilarity(A, B, options = {}) {\n return getSimilarity(A, B, options);\n}\n\nexport function getFunction(options = {}) {\n return (A, B) => getSimilarity(A, B, options);\n}\n","export default function cosine(a, b) {\n var ii = a.length;\n var p = 0;\n var p2 = 0;\n var q2 = 0;\n for (var i = 0; i < ii; i++) {\n p += a[i] * b[i];\n p2 += a[i] * a[i];\n q2 += b[i] * b[i];\n }\n return p / (Math.sqrt(p2) * Math.sqrt(q2));\n}\n","import diceD from '../distances/dice';\n\nexport default function dice(a, b) {\n return 1 - diceD(a, b);\n}\n","import intersectionD from '../distances/intersection';\n\nexport default function intersection(a, b) {\n return 1 - intersectionD(a, b);\n}\n","import jaccardD from '../distances/jaccard';\n\nexport default function jaccard(a, b) {\n return 1 - jaccardD(a, b);\n}\n","import kulczynskiD from '../distances/kulczynski';\n\nexport default function kulczynski(a, b) {\n return 1 / kulczynskiD(a, b);\n}\n","import motykaD from '../distances/motyka';\n\nexport default function motyka(a, b) {\n return 1 - motykaD(a, b);\n}\n","import mean from 'ml-array-mean';\n\nimport cosine from './cosine';\n\nexport default function pearson(a, b) {\n var avgA = mean(a);\n var avgB = mean(b);\n\n var newA = new Array(a.length);\n var newB = new Array(b.length);\n for (var i = 0; i < newA.length; i++) {\n newA[i] = a[i] - avgA;\n newB[i] = b[i] - avgB;\n }\n\n return cosine(newA, newB);\n}\n","import squaredChordD from '../distances/squaredChord';\n\nexport default function squaredChord(a, b) {\n return 1 - squaredChordD(a, b);\n}\n","import { Matrix } from 'ml-matrix';\n\nexport function zeroInsteadOfNegative(X) {\n let rows = X.rows;\n let columns = X.columns;\n let newMatrix = new Matrix(X);\n for (let r = 0; r < rows; r++) {\n for (let c = 0; c < columns; c++) {\n if (newMatrix.get(r, c) < 0) {\n newMatrix.set(r, c, 0);\n }\n }\n }\n return newMatrix;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nexport function checkMatrixS(data, originalMatrix) {\n let { A, S } = data;\n //check if is there at least one element cero\n let indices = [];\n let sum = S.sum('row');\n\n for (let i = 0; i < sum.length; i++) {\n if (sum[i] === 0) {\n indices.push(i);\n continue;\n } else {\n for (let j = 0; j < S.columns; j++) {\n if (isNaN(S.get(i, j))) {\n indices.push(i);\n break;\n }\n }\n }\n }\n // if there than just one zero or NaN element\n // run a NMF with the residual matrix Y - A*B\n if (indices.length > 0) {\n let temp = fastExtractNMF(\n originalMatrix.clone().subM(A.mmul(S)),\n indices.length,\n );\n for (let i = 0; i < indices.length; i++) {\n for (let j = 0; j < S.columns; j++) {\n S.set(indices[i], j, temp.S.get(i, j));\n }\n for (let j = 0; j < A.rows; j++) {\n A.set(j, indices[i], temp.A.get(j, i));\n }\n }\n }\n\n return Object.assign({}, data, { A, S });\n}\n\nfunction fastExtractNMF(residual, r) {\n if (r <= 0) return { A: [], S: [] };\n\n const { columns, rows } = residual;\n\n let A = Matrix.zeros(rows, r);\n let S = Matrix.zeros(r, columns);\n for (let i = 0; i < r; i++) {\n residual = zeroInsteadOfNegative(residual);\n if (residual.sum() === 0) continue;\n let res2 = Matrix.pow(residual, 2).sum('column');\n //find the max of the first column\n\n let maxIndex = 0;\n for (let j = 1; j < res2.length; j++) {\n if (res2[maxIndex] < res2[j]) maxIndex = j;\n }\n\n if (res2[maxIndex] > 0) {\n let sqrtMaxValue = Math.sqrt(res2[maxIndex]);\n for (let j = 0; j < rows; j++) {\n let value = residual.get(j, maxIndex) / sqrtMaxValue;\n A.set(j, i, value);\n }\n let temp = A.getColumnVector(i).transpose().mmul(residual);\n for (let j = 0; j < columns; j++) {\n S.set(i, j, Math.max(temp.get(0, j), 0));\n }\n let subtracting = A.getColumnVector(i).mmul(S.getRowVector(i));\n residual = residual.sub(subtracting);\n }\n }\n return { A, S };\n}\n","import { Matrix } from 'ml-matrix';\n\nexport function normBy(x, by = 'column') {\n let norms = Matrix.mul(x, x).sum(by);\n let length = norms.length;\n for (let i = 0; i < length; i++) {\n norms[i] = Math.sqrt(norms[i]);\n }\n return by === 'row'\n ? Matrix.from1DArray(length, 1, norms)\n : Matrix.from1DArray(1, length, norms);\n}\n","import { normBy } from './normBy';\n\nexport function normProj(X, normLimits) {\n let norms;\n let r = X.rows;\n let c = X.columns;\n if (normLimits.rows === r) {\n norms = normBy(X, 'row');\n //select rows with norm > 0 then multiply twise by the min\n for (let i = 0; i < r; i++) {\n if (norms.get(i, 0) <= 0) continue;\n for (let j = 0; j < c; j++) {\n let value =\n X.get(i, j) *\n Math.min(norms.get(i, 0), normLimits.get(i, 0) / norms.get(i, 0));\n X.set(i, j, value);\n }\n }\n } else {\n norms = normBy(X, 'column');\n for (let i = 0; i < c; i++) {\n if (norms.get(0, i) <= 0) continue;\n for (let j = 0; j < r; j++) {\n let value =\n X.get(j, i) *\n Math.min(norms.get(0, i), normLimits.get(0, i) / norms.get(0, i));\n X.set(j, i, value);\n }\n }\n }\n return X;\n}\n","import { Matrix, EVD } from 'ml-matrix';\n\nimport { normBy } from '../util/normBy';\nimport { normProj } from '../util/normProj';\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nexport function updateMatrixA(Ainit, S, originalMatrix, options) {\n let {\n maxFBIteration,\n toleranceFB,\n normConstrained = false,\n lambda,\n } = options;\n let St = S.transpose();\n let H = S.mmul(St);\n let YSt = originalMatrix.mmul(St);\n let evd = new EVD(H, { assumeSymmetric: true });\n let L = Math.max(...evd.realEigenvalues);\n let A = Ainit;\n let prevA = A.clone();\n let t = 1;\n\n let gradient = (a) => a.mmul(H).sub(YSt);\n let proximal;\n if (normConstrained) {\n let normLimits = normBy(Ainit, 'column');\n proximal = (x, threshold) =>\n normProj(zeroInsteadOfNegative(x.subS(threshold)), normLimits);\n } else {\n proximal = (x, threshold) => zeroInsteadOfNegative(x.subS(threshold));\n }\n\n for (let i = 0; i < maxFBIteration; i++) {\n let tNext = (1 + Math.sqrt(1 + 4 * t * t)) / 2;\n let w = (t - 1) / tNext;\n t = tNext;\n let B = Matrix.mul(A, w + 1).sub(Matrix.mul(prevA, w));\n prevA = A.clone();\n A = proximal(B.sub(gradient(B).divS(L)), lambda / L);\n if (Matrix.sub(prevA, A).norm() / A.norm() < toleranceFB) {\n break;\n }\n }\n return A;\n}\n","export function getMax(array = []) {\n let max = Number.MIN_SAFE_INTEGER;\n for (let i = 0; i < array.length; i++) {\n if (max < array[i]) max = array[i];\n }\n return max;\n}\n","import { Matrix, EVD } from 'ml-matrix';\n\nimport { getMax } from '../util/getMax';\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nexport function updateMatrixS(A, Sinit, originalMatrix, lambda, options) {\n let { maxFBIteration, toleranceFB } = options;\n let At = A.transpose();\n let H = At.mmul(A);\n let AtY = At.mmul(originalMatrix);\n let evd = new EVD(H, { assumeSymmetric: true });\n let L = getMax(evd.realEigenvalues);\n let t = 1;\n let S = Sinit.clone();\n let prevS = S.clone();\n let gradient = (s) => H.mmul(s).sub(AtY);\n let proximal = (x, threshold) => zeroInsteadOfNegative(x.subS(threshold));\n\n for (let i = 0; i < maxFBIteration; i++) {\n let tNext = (1 + Math.sqrt(1 + 4 * t * t)) / 2;\n let w = (t - 1) / tNext;\n t = tNext;\n // R = S_k + w [S_k - S_(k-1)] = (1 + w) .* S_k - w .* S_(k-1)\n let R = Matrix.mul(S, 1 + w).sub(Matrix.mul(prevS, w));\n prevS = S.clone();\n S = proximal(R.sub(gradient(R).divS(L)), lambda / L);\n if (Matrix.sub(prevS, S).norm() / S.norm() < toleranceFB) {\n break;\n }\n }\n return S;\n}\n","import { Matrix, solve } from 'ml-matrix';\n\nimport { zeroInsteadOfNegative } from '../util/zeroInsteadOfNegative';\n\nimport { checkMatrixS } from './checkMatrixS';\nimport { updateMatrixA } from './updateMatrixA';\nimport { updateMatrixS } from './updateMatrixS';\n\nexport function initialize(originalMatrix, options = {}) {\n const {\n rank,\n randGenerator,\n maxInitFBIteration,\n toleranceFBInit,\n maxFBIteration,\n toleranceFB,\n normConstrained,\n } = options;\n\n let result = {};\n let rows = originalMatrix.rows;\n\n result.A = Matrix.rand(rows, rank, { random: randGenerator });\n\n for (let iter = 0; iter < maxInitFBIteration; iter++) {\n //select columns with sum positive from A\n let sumC = result.A.sum('column');\n for (let i = 0; i < sumC.length; i++) {\n while (sumC[i] === 0) {\n sumC[i] = 0;\n for (let j = 0; j < rows; j++) {\n result.A.set(j, i, randGenerator());\n sumC[i] += result.A.get(j, i);\n }\n }\n }\n\n //resolve the system of equation Lx = D for x, then select just non negative values;\n result.S = zeroInsteadOfNegative(solve(result.A, originalMatrix));\n\n //select rows with positive sum by row\n let sumR = result.S.sum('row');\n let positiveSumRowIndexS = [];\n let positiveSumRowS = [];\n for (let i = 0; i < sumR.length; i++) {\n if (sumR[i] > 0) {\n positiveSumRowIndexS.push(i);\n positiveSumRowS.push(result.S.getRow(i));\n }\n }\n\n positiveSumRowS = Matrix.checkMatrix(positiveSumRowS);\n\n // solve the system of linear equation xL = D for x. knowing that D/L = (L'\\D')'.\n let candidateA = zeroInsteadOfNegative(\n solve(positiveSumRowS.transpose(), originalMatrix.transpose()),\n );\n\n //then, set the columns of A with an index equal to the row index with sum > 0 into S\n //this step complete the last transpose of D/L = (L'\\D')'.\n for (let i = 0; i < positiveSumRowIndexS.length; i++) {\n let colCandidate = candidateA.getRow(i);\n for (let j = 0; j < rows; j++) {\n result.A.set(j, positiveSumRowIndexS[i], colCandidate[j]);\n }\n }\n\n let prevS = result.S.clone();\n result.S = updateMatrixS(result.A, result.S, originalMatrix, 0, {\n maxFBIteration,\n toleranceFB,\n });\n\n result = checkMatrixS(result, originalMatrix);\n\n result.A = updateMatrixA(result.A, result.S, originalMatrix, 0, {\n maxFBIteration,\n toleranceFB,\n normConstrained,\n });\n\n if (\n Matrix.sub(prevS, result.S).norm() / result.S.norm() <\n toleranceFBInit\n ) {\n break;\n }\n }\n return result;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { normBy } from '../util/normBy';\n\nexport function normalize(data, options) {\n const { normOnA } = options;\n let DS = normBy(data.S.transpose(), 'column');\n let DA = normBy(data.A, 'column');\n let D = Matrix.mul(DS, DA);\n let onS, onA;\n if (normOnA) {\n onS = (index, c) =>\n (data.S.get(index, c) * D.get(0, index)) / DS.get(0, index);\n onA = (index, r) => data.A.get(r, index) / DA.get(0, index);\n } else {\n onS = (index, c) => data.S.get(index, c) / DS.get(0, index);\n onA = (index, r) =>\n (data.A.get(r, index) * D.get(0, index)) / DA.get(0, index);\n }\n const sColumns = data.S.columns;\n const aRows = data.A.rows;\n for (let index = 0; index < D.columns; index++) {\n let valueForS, valueForA;\n if (D.get(0, index) > 0) {\n valueForS = onS;\n valueForA = onA;\n } else {\n valueForA = () => 0;\n valueForS = () => 0;\n }\n for (let c = 0; c < sColumns; c++) {\n data.S.set(index, c, valueForS(index, c));\n }\n for (let r = 0; r < aRows; r++) {\n data.A.set(r, index, valueForA(index, r));\n }\n }\n return data;\n}\n","import median from 'median-quickselect';\nimport { Matrix } from 'ml-matrix';\n\nexport function getMedians(X, by) {\n let medians = [];\n let rows = X.rows;\n let columns = X.columns;\n switch (by) {\n case 'column':\n for (let i = 0; i < columns; i++) {\n medians.push(median(X.getColumn(i)));\n }\n medians = Matrix.from1DArray(1, columns, medians);\n break;\n default:\n for (let i = 0; i < rows; i++) {\n medians.push(median(X.getRow(i)));\n }\n medians = Matrix.from1DArray(rows, 1, medians);\n }\n return medians;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { getMedians } from './getMedians';\n\nexport function dimMADstd(X, by) {\n let medians = getMedians(X, by);\n let matrix = X.clone();\n matrix =\n by === 'column'\n ? matrix.subRowVector(medians.to1DArray())\n : matrix.subColumnVector(medians.to1DArray());\n return Matrix.mul(getMedians(matrix.abs(), by), 1.4826);\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { dimMADstd } from '../util/dimMADstd';\n\nexport function updateLambda(data, originalMatrix, options = {}) {\n let { refinementBeginning, tauMAD } = options;\n let { iteration, lambda, A, S } = data;\n\n if (refinementBeginning <= iteration) return lambda;\n\n let sigmaResidue;\n if (options.lambdaInf !== undefined) {\n sigmaResidue = options.lambdaInf / options.tauMAD;\n } else if (options.addStd !== undefined) {\n sigmaResidue = options.addStd;\n } else {\n let alY = Matrix.sub(originalMatrix, A.mmul(S)).to1DArray();\n let result = dimMADstd(Matrix.from1DArray(1, alY.length, alY), 'row');\n sigmaResidue = result.get(0, 0);\n }\n let nextLambda = Math.max(\n tauMAD * sigmaResidue,\n lambda - 1 / (refinementBeginning - iteration),\n );\n return nextLambda;\n}\n","import { Matrix } from 'ml-matrix';\n\nimport { checkMatrixS } from './stages/checkMatrixS';\nimport { initialize } from './stages/initialize';\nimport { normalize } from './stages/normalize';\nimport { updateLambda } from './stages/updateLambda';\nimport { updateMatrixA } from './stages/updateMatrixA';\nimport { updateMatrixS } from './stages/updateMatrixS';\n\n/**\n * Performing non-negative matrix factorization solving argmin_(A >= 0, S >= 0) 1 / 2 * ||Y - AS||_2^2 + lambda * ||S||_1\n * @param {Matrix||Array} originalMatrix - Matrix to be separated.\n * @param {Number} rank - The maximum number of linearly independent column/row vectors in the matrix.\n * @param {Object} [options = {}] - Options of ngmca factorization method.\n * @param {Number} [options.maximumIteration = 500] - Maximum number of iterations.\n * @param {Number} [options.maxFBIteration = 80] - Maximum number of iterations of the Forward-Backward subroutine.\n * @param {Object} [options.randGenerator = Math.random] - Random number generator for the subroutine of initialization.\n * @param {Number} [options.maxInitFBIteration = 50] - Maximum number of iterations of the Forward-Backward subroutine at the initialization.\n * @param {Number} [options.toleranceFB = 1e-5] - relative difference tolerance for convergence of the Forward-Backward sub-iterations.\n * @param {Number} [options.toleranceFBInit = 0] - relative difference tolerance for convergence of the Forward-Backward sub-iterations at the initialization.\n * @param {Number} [options.phaseRatio = 0.8] - transition between decreasing thresholding phase and refinement phase in percent of the iterations.\n * @param {Number} [options.tauMAD = 1] - constant coefficient for the final threshold computation.\n * @param {Boolean} [options.useTranspose = false] - if true the originalMatrix is transposed.\n */\n\nexport function nGMCA(originalMatrix, rank, options = {}) {\n const {\n maximumIteration = 500,\n maxFBIteration = 80,\n maxInitFBIteration = 50,\n toleranceFBInit = 0,\n toleranceFB = 0.00001,\n phaseRatio = 0.8,\n randGenerator = Math.random,\n tauMAD = 1,\n useTranspose = false,\n } = options;\n\n let { normConstrained = false } = options;\n originalMatrix = Matrix.checkMatrix(originalMatrix);\n if (useTranspose) originalMatrix = originalMatrix.transpose();\n let refinementBeginning = Math.floor(phaseRatio * maximumIteration);\n\n let data = initialize(originalMatrix, {\n rank,\n randGenerator,\n maxInitFBIteration,\n toleranceFBInit,\n maxFBIteration,\n toleranceFB,\n });\n\n data = normalize(data, { normOnA: true });\n data.lambda = data.A.transpose()\n .mmul(data.A.mmul(data.S).sub(originalMatrix))\n .abs()\n .max();\n\n for (let iter = 0; iter < maximumIteration; iter++) {\n data.iteration = iter;\n data.S = updateMatrixS(\n data.A,\n data.S,\n originalMatrix,\n data.lambda,\n options,\n );\n data = checkMatrixS(data, originalMatrix);\n data = normalize(data, { normOnA: false });\n\n if (iter > refinementBeginning) normConstrained = true;\n\n data.A = updateMatrixA(data.A, data.S, originalMatrix, {\n maxFBIteration,\n toleranceFB,\n normConstrained,\n lambda: 0,\n });\n\n data = normalize(data, { normOnA: true });\n\n data.lambda = updateLambda(data, originalMatrix, {\n refinementBeginning,\n tauMAD,\n });\n }\n\n if (useTranspose) {\n let temp = data.A.transpose();\n data.A = data.S.transpose();\n data.S = temp;\n }\n return data;\n}\n","'use strict';\n\n// Accuracy\nexports.acc = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.tn[i] + pred.tp[i]) / (l - 1);\n }\n return result;\n};\n\n// Error rate\nexports.err = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.fp[i] / (l - 1));\n }\n return result;\n};\n\n// False positive rate\nexports.fpr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.fp[i] / pred.nNeg;\n }\n return result;\n};\n\n// True positive rate\nexports.tpr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.tp[i] / pred.nPos;\n }\n return result;\n};\n\n// False negative rate\nexports.fnr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.fn[i] / pred.nPos;\n }\n return result;\n};\n\n// True negative rate\nexports.tnr = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.tn[i] / pred.nNeg;\n }\n return result;\n};\n\n// Positive predictive value\nexports.ppv = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fp[i] + pred.tp[i] !== 0) ? (pred.tp[i] / (pred.fp[i] + pred.tp[i])) : 0;\n }\n return result;\n};\n\n// Negative predictive value\nexports.npv = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.tn[i] !== 0) ? (pred.tn[i] / (pred.fn[i] + pred.tn[i])) : 0;\n }\n return result;\n};\n\n// Prediction conditioned fallout\nexports.pcfall = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fp[i] + pred.tp[i] !== 0) ? 1 - (pred.tp[i] / (pred.fp[i] + pred.tp[i])) : 1;\n }\n return result;\n};\n\n// Prediction conditioned miss\nexports.pcmiss = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.fn[i] + pred.tn[i] !== 0) ? 1 - (pred.tn[i] / (pred.fn[i] + pred.tn[i])) : 1;\n }\n return result;\n};\n\n// Lift value\nexports.lift = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = (pred.nPosPred[i] !== 0) ? ((pred.tp[i] / pred.nPos) / (pred.nPosPred[i] / pred.nSamples)) : 0;\n }\n return result;\n};\n\n// Rate of positive predictions\nexports.rpp = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.nPosPred[i] / pred.nSamples;\n }\n return result;\n};\n\n// Rate of negative predictions\nexports.rnp = pred => {\n const l = pred.cutoffs.length;\n const result = new Array(l);\n for (var i = 0; i < l; i++) {\n result[i] = pred.nNegPred[i] / pred.nSamples;\n }\n return result;\n};\n\n// Threshold\nexports.threshold = pred => {\n const clone = pred.cutoffs.slice();\n clone[0] = clone[1]; // Remove the infinite value\n return clone;\n};\n","'use strict';\n\nconst measures = require('./measures');\n\nclass Performance {\n /**\n *\n * @param prediction - The prediction matrix\n * @param target - The target matrix (values: truthy for same class, falsy for different class)\n * @param options\n *\n * @option all True if the entire matrix must be used. False to ignore the diagonal and lower part (default is false, for similarity/distance matrices)\n * @option max True if the max value corresponds to a perfect match (like in similarity matrices), false if it is the min value (default is false, like in distance matrices. All values will be multiplied by -1)\n */\n constructor(prediction, target, options) {\n options = options || {};\n if (prediction.length !== target.length || prediction[0].length !== target[0].length) {\n throw new Error('dimensions of prediction and target do not match');\n }\n const rows = prediction.length;\n const columns = prediction[0].length;\n const isDistance = !options.max;\n\n const predP = [];\n\n if (options.all) {\n for (var i = 0; i < rows; i++) {\n for (var j = 0; j < columns; j++) {\n predP.push({\n pred: prediction[i][j],\n targ: target[i][j]\n });\n }\n }\n } else {\n if (rows < 3 || rows !== columns) {\n throw new Error('When \"all\" option is false, the prediction matrix must be square and have at least 3 columns');\n }\n for (var i = 0; i < rows - 1; i++) {\n for (var j = i + 1; j < columns; j++) {\n predP.push({\n pred: prediction[i][j],\n targ: target[i][j]\n });\n }\n }\n }\n\n if (isDistance) {\n predP.sort((a, b) => a.pred - b.pred);\n } else {\n predP.sort((a, b) => b.pred - a.pred);\n }\n \n const cutoffs = this.cutoffs = [isDistance ? Number.MIN_VALUE : Number.MAX_VALUE];\n const fp = this.fp = [0];\n const tp = this.tp = [0];\n\n var nPos = 0;\n var nNeg = 0;\n\n var currentPred = predP[0].pred;\n var nTp = 0;\n var nFp = 0;\n for (var i = 0; i < predP.length; i++) {\n if (predP[i].pred !== currentPred) {\n cutoffs.push(currentPred);\n fp.push(nFp);\n tp.push(nTp);\n currentPred = predP[i].pred;\n }\n if (predP[i].targ) {\n nPos++;\n nTp++;\n } else {\n nNeg++;\n nFp++;\n }\n }\n cutoffs.push(currentPred);\n fp.push(nFp);\n tp.push(nTp);\n\n const l = cutoffs.length;\n const fn = this.fn = new Array(l);\n const tn = this.tn = new Array(l);\n const nPosPred = this.nPosPred = new Array(l);\n const nNegPred = this.nNegPred = new Array(l);\n\n for (var i = 0; i < l; i++) {\n fn[i] = nPos - tp[i];\n tn[i] = nNeg - fp[i];\n\n nPosPred[i] = tp[i] + fp[i];\n nNegPred[i] = tn[i] + fn[i];\n }\n\n this.nPos = nPos;\n this.nNeg = nNeg;\n this.nSamples = nPos + nNeg;\n }\n\n /**\n * Computes a measure from the prediction object.\n *\n * Many measures are available and can be combined :\n * To create a ROC curve, you need fpr and tpr\n * To create a DET curve, you need fnr and fpr\n * To create a Lift chart, you need rpp and lift\n *\n * Possible measures are : threshold (Threshold), acc (Accuracy), err (Error rate),\n * fpr (False positive rate), tpr (True positive rate), fnr (False negative rate), tnr (True negative rate), ppv (Positive predictive value),\n * npv (Negative predictive value), pcfall (Prediction-conditioned fallout), pcmiss (Prediction-conditioned miss), lift (Lift value), rpp (Rate of positive predictions), rnp (Rate of negative predictions)\n *\n * @param measure - The short name of the measure\n *\n * @return [number]\n */\n getMeasure(measure) {\n if (typeof measure !== 'string') {\n throw new Error('No measure specified');\n }\n if (!measures[measure]) {\n throw new Error(`The specified measure (${measure}) does not exist`);\n }\n return measures[measure](this);\n }\n\n /**\n * Returns the area under the ROC curve\n */\n getAURC() {\n const l = this.cutoffs.length;\n const x = new Array(l);\n const y = new Array(l);\n for (var i = 0; i < l; i++) {\n x[i] = this.fp[i] / this.nNeg;\n y[i] = this.tp[i] / this.nPos;\n }\n var auc = 0;\n for (i = 1; i < l; i++) {\n auc += 0.5 * (x[i] - x[i - 1]) * (y[i] + y[i - 1]);\n }\n return auc;\n }\n\n /**\n * Returns the area under the DET curve\n */\n getAUDC() {\n const l = this.cutoffs.length;\n const x = new Array(l);\n const y = new Array(l);\n for (var i = 0; i < l; i++) {\n x[i] = this.fn[i] / this.nPos;\n y[i] = this.fp[i] / this.nNeg;\n }\n var auc = 0;\n for (i = 1; i < l; i++) {\n auc += 0.5 * (x[i] + x[i - 1]) * (y[i] - y[i - 1]);\n }\n return auc;\n }\n\n getDistribution(options) {\n options = options || {};\n var cutLength = this.cutoffs.length;\n var cutLow = options.xMin || Math.floor(this.cutoffs[cutLength - 1] * 100) / 100;\n var cutHigh = options.xMax || Math.ceil(this.cutoffs[1] * 100) / 100;\n var interval = options.interval || Math.floor(((cutHigh - cutLow) / 20 * 10000000) - 1) / 10000000; // Trick to avoid the precision problem of float numbers\n\n var xLabels = [];\n var interValues = [];\n var intraValues = [];\n var interCumPercent = [];\n var intraCumPercent = [];\n\n var nTP = this.tp[cutLength - 1], currentTP = 0;\n var nFP = this.fp[cutLength - 1], currentFP = 0;\n\n for (var i = cutLow, j = (cutLength - 1); i <= cutHigh; i += interval) {\n while (this.cutoffs[j] < i)\n j--;\n\n xLabels.push(i);\n\n var thisTP = nTP - currentTP - this.tp[j];\n var thisFP = nFP - currentFP - this.fp[j];\n\n currentTP += thisTP;\n currentFP += thisFP;\n\n interValues.push(thisFP);\n intraValues.push(thisTP);\n\n interCumPercent.push(100 - (nFP - this.fp[j]) / nFP * 100);\n intraCumPercent.push(100 - (nTP - this.tp[j]) / nTP * 100);\n }\n\n return {\n xLabels: xLabels,\n interValues: interValues,\n intraValues: intraValues,\n interCumPercent: interCumPercent,\n intraCumPercent: intraCumPercent\n };\n }\n}\n\nPerformance.names = {\n acc: 'Accuracy',\n err: 'Error rate',\n fpr: 'False positive rate',\n tpr: 'True positive rate',\n fnr: 'False negative rate',\n tnr: 'True negative rate',\n ppv: 'Positive predictive value',\n npv: 'Negative predictive value',\n pcfall: 'Prediction-conditioned fallout',\n pcmiss: 'Prediction-conditioned miss',\n lift: 'Lift value',\n rpp: 'Rate of positive predictions',\n rnp: 'Rate of negative predictions',\n threshold: 'Threshold'\n};\n\nmodule.exports = Performance;\n","'use strict';\n\nvar defaultOptions = {\n size: 1,\n value: 0\n};\n\n/**\n * Case when the entry is an array\n * @param data\n * @param options\n * @returns {Array}\n */\nfunction arrayCase(data, options) {\n var len = data.length;\n if (typeof options.size === 'number') {\n options.size = [options.size, options.size];\n }\n\n var cond = len + options.size[0] + options.size[1];\n\n var output;\n if (options.output) {\n if (options.output.length !== cond) {\n throw new RangeError('Wrong output size');\n }\n output = options.output;\n } else {\n output = new Array(cond);\n }\n\n var i;\n if (options.value === 'circular') {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) {\n output[i] = data[(len - (options.size[0] % len) + i) % len];\n } else if (i < options.size[0] + len) {\n output[i] = data[i - options.size[0]];\n } else {\n output[i] = data[(i - options.size[0]) % len];\n }\n }\n } else if (options.value === 'replicate') {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = data[0];\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = data[len - 1];\n }\n } else if (options.value === 'symmetric') {\n if (options.size[0] > len || options.size[1] > len) {\n throw new RangeError(\n 'expanded value should not be bigger than the data length'\n );\n }\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = data[options.size[0] - 1 - i];\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = data[2 * len + options.size[0] - i - 1];\n }\n } else {\n for (i = 0; i < cond; i++) {\n if (i < options.size[0]) output[i] = options.value;\n else if (i < options.size[0] + len) output[i] = data[i - options.size[0]];\n else output[i] = options.value;\n }\n }\n\n return output;\n}\n\n/**\n * Case when the entry is a matrix\n * @param data\n * @param options\n * @returns {Array}\n */\nfunction matrixCase(data, options) {\n // var row = data.length;\n // var col = data[0].length;\n if (options.size[0] === undefined) {\n options.size = [options.size, options.size, options.size, options.size];\n }\n throw new Error('matrix not supported yet, sorry');\n}\n\n/**\n * Pads and array\n * @param {Array } data\n * @param {object} options\n */\nfunction padArray(data, options) {\n options = Object.assign({}, defaultOptions, options);\n if (Array.isArray(data)) {\n if (Array.isArray(data[0])) return matrixCase(data, options);\n else return arrayCase(data, options);\n } else {\n throw new TypeError('data should be an array');\n }\n}\n\nmodule.exports = padArray;\n","import { Matrix, MatrixTransposeView, inverse } from 'ml-matrix';\nimport padArray from 'ml-pad-array';\n\n/**\n * Factorial of a number\n * @ignore\n * @param n\n * @return {number}\n */\nfunction factorial(n) {\n let r = 1;\n while (n > 0) r *= n--;\n return r;\n}\n\nconst defaultOptions = {\n windowSize: 5,\n derivative: 1,\n polynomial: 2,\n pad: 'none',\n padValue: 'replicate',\n};\n\n/**\n * Savitzky-Golay filter\n * @param {Array } data\n * @param {number} h\n * @param {Object} options\n * @returns {Array}\n */\nexport default function savitzkyGolay(data, h, options) {\n options = Object.assign({}, defaultOptions, options);\n if (\n options.windowSize % 2 === 0 ||\n options.windowSize < 5 ||\n !Number.isInteger(options.windowSize)\n ) {\n throw new RangeError(\n 'Invalid window size (should be odd and at least 5 integer number)',\n );\n }\n if (options.derivative < 0 || !Number.isInteger(options.derivative)) {\n throw new RangeError('Derivative should be a positive integer');\n }\n if (options.polynomial < 1 || !Number.isInteger(options.polynomial)) {\n throw new RangeError('Polynomial should be a positive integer');\n }\n\n let C, norm;\n let step = Math.floor(options.windowSize / 2);\n\n if (options.pad === 'pre') {\n data = padArray(data, { size: step, value: options.padValue });\n }\n\n let ans = new Array(data.length - 2 * step);\n\n if (\n options.windowSize === 5 &&\n options.polynomial === 2 &&\n (options.derivative === 1 || options.derivative === 2)\n ) {\n if (options.derivative === 1) {\n C = [-2, -1, 0, 1, 2];\n norm = 10;\n } else {\n C = [2, -1, -2, -1, 2];\n norm = 7;\n }\n } else {\n let J = Matrix.ones(options.windowSize, options.polynomial + 1);\n let inic = -(options.windowSize - 1) / 2;\n for (let i = 0; i < J.rows; i++) {\n for (let j = 0; j < J.columns; j++) {\n if (inic + 1 !== 0 || j !== 0) J.set(i, j, Math.pow(inic + i, j));\n }\n }\n let Jtranspose = new MatrixTransposeView(J);\n let Jinv = inverse(Jtranspose.mmul(J));\n C = Jinv.mmul(Jtranspose);\n C = C.getRow(options.derivative);\n norm = 1 / factorial(options.derivative);\n }\n let det = norm * Math.pow(h, options.derivative);\n for (let k = step; k < data.length - step; k++) {\n let d = 0;\n for (let l = 0; l < C.length; l++) d += (C[l] * data[l + k - step]) / det;\n ans[k - step] = d;\n }\n\n if (options.pad === 'post') {\n ans = padArray(ans, { size: step, value: options.padValue });\n }\n\n return ans;\n}\n","// auxiliary file to create the 256 look at table elements\n\nvar ans = new Array(256);\nfor (var i = 0; i < 256; i++) {\n var num = i;\n var c = 0;\n while (num) {\n num = num & (num - 1);\n c++;\n }\n ans[i] = c;\n}\n\nmodule.exports = ans;","'use strict';\n\nvar eightBits = require('./creator');\n\n/**\n * Count the number of true values in an array\n * @param {Array} arr\n * @return {number}\n */\nfunction count(arr) {\n var c = 0;\n for (var i = 0; i < arr.length; i++) {\n c += eightBits[arr[i] & 0xff] + eightBits[(arr[i] >> 8) & 0xff] + eightBits[(arr[i] >> 16) & 0xff] + eightBits[(arr[i] >> 24) & 0xff];\n }\n return c;\n}\n\n/**\n * Logical AND operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction and(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] & arr2[i];\n return ans;\n}\n\n/**\n * Logical OR operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction or(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] | arr2[i];\n return ans;\n}\n\n/**\n * Logical XOR operation\n * @param {Array} arr1\n * @param {Array} arr2\n * @return {Array}\n */\nfunction xor(arr1, arr2) {\n var ans = new Array(arr1.length);\n for (var i = 0; i < arr1.length; i++)\n ans[i] = arr1[i] ^ arr2[i];\n return ans;\n}\n\n/**\n * Logical NOT operation\n * @param {Array} arr\n * @return {Array}\n */\nfunction not(arr) {\n var ans = new Array(arr.length);\n for (var i = 0; i < ans.length; i++)\n ans[i] = ~arr[i];\n return ans;\n}\n\n/**\n * Gets the n value of array arr\n * @param {Array} arr\n * @param {number} n\n * @return {boolean}\n */\nfunction getBit(arr, n) {\n var index = n >> 5; // Same as Math.floor(n/32)\n var mask = 1 << (31 - n % 32);\n return Boolean(arr[index] & mask);\n}\n\n/**\n * Sets the n value of array arr to the value val\n * @param {Array} arr\n * @param {number} n\n * @param {boolean} val\n * @return {Array}\n */\nfunction setBit(arr, n, val) {\n var index = n >> 5; // Same as Math.floor(n/32)\n var mask = 1 << (31 - n % 32);\n if (val)\n arr[index] = mask | arr[index];\n else\n arr[index] = ~mask & arr[index];\n return arr;\n}\n\n/**\n * Translates an array of numbers to a string of bits\n * @param {Array} arr\n * @returns {string}\n */\nfunction toBinaryString(arr) {\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n var obj = (arr[i] >>> 0).toString(2);\n str += '00000000000000000000000000000000'.substr(obj.length) + obj;\n }\n return str;\n}\n\n/**\n * Creates an array of numbers based on a string of bits\n * @param {string} str\n * @returns {Array}\n */\nfunction parseBinaryString(str) {\n var len = str.length / 32;\n var ans = new Array(len);\n for (var i = 0; i < len; i++) {\n ans[i] = parseInt(str.substr(i*32, 32), 2) | 0;\n }\n return ans;\n}\n\n/**\n * Translates an array of numbers to a hex string\n * @param {Array} arr\n * @returns {string}\n */\nfunction toHexString(arr) {\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n var obj = (arr[i] >>> 0).toString(16);\n str += '00000000'.substr(obj.length) + obj;\n }\n return str;\n}\n\n/**\n * Creates an array of numbers based on a hex string\n * @param {string} str\n * @returns {Array}\n */\nfunction parseHexString(str) {\n var len = str.length / 8;\n var ans = new Array(len);\n for (var i = 0; i < len; i++) {\n ans[i] = parseInt(str.substr(i*8, 8), 16) | 0;\n }\n return ans;\n}\n\n/**\n * Creates a human readable string of the array\n * @param {Array} arr\n * @returns {string}\n */\nfunction toDebug(arr) {\n var binary = toBinaryString(arr);\n var str = '';\n for (var i = 0; i < arr.length; i++) {\n str += '0000'.substr((i * 32).toString(16).length) + (i * 32).toString(16) + ':';\n for (var j = 0; j < 32; j += 4) {\n str += ' ' + binary.substr(i * 32 + j, 4);\n }\n if (i < arr.length - 1) str += '\\n';\n }\n return str\n}\n\nmodule.exports = {\n count: count,\n and: and,\n or: or,\n xor: xor,\n not: not,\n getBit: getBit,\n setBit: setBit,\n toBinaryString: toBinaryString,\n parseBinaryString: parseBinaryString,\n toHexString: toHexString,\n parseHexString: parseHexString,\n toDebug: toDebug\n};\n","export default function SavitzkyGolay(data, h, options = {}) {\n let { windowSize = 9, derivative = 0, polynomial = 3 } = options;\n\n if (windowSize % 2 === 0 || windowSize < 5 || !Number.isInteger(windowSize)) {\n throw new RangeError(\n 'Invalid window size (should be odd and at least 5 integer number)',\n );\n }\n if (windowSize > data.length) {\n throw new RangeError(\n `Window size is higher than the data length ${windowSize}>${data.length}`,\n );\n }\n if (derivative < 0 || !Number.isInteger(derivative)) {\n throw new RangeError('Derivative should be a positive integer');\n }\n if (polynomial < 1 || !Number.isInteger(polynomial)) {\n throw new RangeError('Polynomial should be a positive integer');\n }\n if (polynomial >= 6) {\n // eslint-disable-next-line no-console\n console.warn(\n 'You should not use polynomial grade higher than 5 if you are' +\n ' not sure that your data arises from such a model. Possible polynomial oscillation problems',\n );\n }\n\n let half = Math.floor(windowSize / 2);\n let np = data.length;\n let ans = new Array(np);\n let weights = fullWeights(windowSize, polynomial, derivative);\n let hs = 0;\n let constantH = true;\n if (Array.isArray(h)) {\n constantH = false;\n } else {\n hs = Math.pow(h, derivative);\n }\n\n //For the borders\n for (let i = 0; i < half; i++) {\n let wg1 = weights[half - i - 1];\n let wg2 = weights[half + i + 1];\n let d1 = 0;\n let d2 = 0;\n for (let l = 0; l < windowSize; l++) {\n d1 += wg1[l] * data[l];\n d2 += wg2[l] * data[np - windowSize + l];\n }\n if (constantH) {\n ans[half - i - 1] = d1 / hs;\n ans[np - half + i] = d2 / hs;\n } else {\n hs = getHs(h, half - i - 1, half, derivative);\n ans[half - i - 1] = d1 / hs;\n hs = getHs(h, np - half + i, half, derivative);\n ans[np - half + i] = d2 / hs;\n }\n }\n\n //For the internal points\n let wg = weights[half];\n for (let i = windowSize; i <= np; i++) {\n let d = 0;\n for (let l = 0; l < windowSize; l++) d += wg[l] * data[l + i - windowSize];\n if (!constantH) hs = getHs(h, i - half - 1, half, derivative);\n ans[i - half - 1] = d / hs;\n }\n return ans;\n}\n\nfunction getHs(h, center, half, derivative) {\n let hs = 0;\n let count = 0;\n for (let i = center - half; i < center + half; i++) {\n if (i >= 0 && i < h.length - 1) {\n hs += h[i + 1] - h[i];\n count++;\n }\n }\n return Math.pow(hs / count, derivative);\n}\n\nfunction GramPoly(i, m, k, s) {\n let Grampoly = 0;\n if (k > 0) {\n Grampoly =\n ((4 * k - 2) / (k * (2 * m - k + 1))) *\n (i * GramPoly(i, m, k - 1, s) + s * GramPoly(i, m, k - 1, s - 1)) -\n (((k - 1) * (2 * m + k)) / (k * (2 * m - k + 1))) *\n GramPoly(i, m, k - 2, s);\n } else {\n if (k === 0 && s === 0) {\n Grampoly = 1;\n } else {\n Grampoly = 0;\n }\n }\n return Grampoly;\n}\n\nfunction GenFact(a, b) {\n let gf = 1;\n if (a >= b) {\n for (let j = a - b + 1; j <= a; j++) {\n gf *= j;\n }\n }\n return gf;\n}\n\nfunction Weight(i, t, m, n, s) {\n let sum = 0;\n for (let k = 0; k <= n; k++) {\n //console.log(k);\n sum +=\n (2 * k + 1) *\n (GenFact(2 * m, k) / GenFact(2 * m + k + 1, k + 1)) *\n GramPoly(i, m, k, 0) *\n GramPoly(t, m, k, s);\n }\n return sum;\n}\n\n/**\n *\n * @param m Number of points\n * @param n Polynomial grade\n * @param s Derivative\n */\nfunction fullWeights(m, n, s) {\n let weights = new Array(m);\n let np = Math.floor(m / 2);\n for (let t = -np; t <= np; t++) {\n weights[t + np] = new Array(m);\n for (let j = -np; j <= np; j++) {\n weights[t + np][j + np] = Weight(j, t, np, n, s);\n }\n }\n return weights;\n}\n\n/*function entropy(data,h,options){\n var trend = SavitzkyGolay(data,h,trendOptions);\n var copy = new Array(data.length);\n var sum = 0;\n var max = 0;\n for(var i=0;i} x - Independent variable\n * @param {Array} yIn - Dependent variable\n * @param {object} [options] - Options object\n * @param {object} [options.sgOptions] - Options object for Savitzky-Golay filter. See https://github.com/mljs/savitzky-golay-generalized#options\n * @param {number} [options.sgOptions.windowSize = 9] - points to use in the approximations\n * @param {number} [options.sgOptions.polynomial = 3] - degree of the polynomial to use in the approximations\n * @param {number} [options.minMaxRatio = 0.00025] - Threshold to determine if a given peak should be considered as a noise\n * @param {number} [options.broadRatio = 0.00] - If `broadRatio` is higher than 0, then all the peaks which second derivative\n * smaller than `broadRatio * maxAbsSecondDerivative` will be marked with the soft mask equal to true.\n * @param {number} [options.noiseLevel = 0] - Noise threshold in spectrum units\n * @param {boolean} [options.maxCriteria = true] - Peaks are local maximum(true) or minimum(false)\n * @param {boolean} [options.smoothY = true] - Select the peak intensities from a smoothed version of the independent variables\n * @param {boolean} [options.realTopDetection = false] - Use a quadratic optimizations with the peak and its 3 closest neighbors\n * to determine the true x,y values of the peak?\n * @param {number} [options.heightFactor = 0] - Factor to multiply the calculated height (usually 2)\n * @param {number} [options.derivativeThreshold = -1] - Filters based on the amplitude of the first derivative\n * @return {Array}\n */\nexport function gsd(x, yIn, options = {}) {\n let {\n noiseLevel,\n sgOptions = {\n windowSize: 9,\n polynomial: 3,\n },\n smoothY = true,\n heightFactor = 0,\n broadRatio = 0.0,\n maxCriteria = true,\n minMaxRatio = 0.00025,\n derivativeThreshold = -1,\n realTopDetection = false,\n } = options;\n\n const y = yIn.slice();\n let equalSpaced = isEqualSpaced(x);\n\n if (noiseLevel === undefined) {\n noiseLevel = equalSpaced ? getNoiseLevel(y) : 0;\n }\n\n const yCorrection = { m: 1, b: noiseLevel };\n\n if (!maxCriteria) {\n yCorrection.m = -1;\n yCorrection.b *= -1;\n }\n\n for (let i = 0; i < y.length; i++) {\n y[i] = yCorrection.m * y[i] - yCorrection.b;\n }\n\n for (let i = 0; i < y.length; i++) {\n if (y[i] < 0) {\n y[i] = 0;\n }\n }\n // If the max difference between delta x is less than 5%, then,\n // we can assume it to be equally spaced variable\n let yData = y;\n let dY, ddY;\n const { windowSize, polynomial } = sgOptions;\n\n if (equalSpaced) {\n if (smoothY) {\n yData = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 0,\n });\n }\n dY = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 1,\n });\n ddY = SG(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 2,\n });\n } else {\n if (smoothY) {\n yData = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 0,\n });\n }\n dY = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 1,\n });\n ddY = SG(y, x, {\n windowSize,\n polynomial,\n derivative: 2,\n });\n }\n\n const xData = x;\n const dX = x[1] - x[0];\n let maxDdy = 0;\n let maxY = 0;\n for (let i = 0; i < yData.length; i++) {\n if (Math.abs(ddY[i]) > maxDdy) {\n maxDdy = Math.abs(ddY[i]);\n }\n if (Math.abs(yData[i]) > maxY) {\n maxY = Math.abs(yData[i]);\n }\n }\n\n let lastMax = null;\n let lastMin = null;\n let minddY = new Array(yData.length - 2);\n let intervalL = new Array(yData.length);\n let intervalR = new Array(yData.length);\n let broadMask = new Array(yData.length - 2);\n let minddYLen = 0;\n let intervalLLen = 0;\n let intervalRLen = 0;\n let broadMaskLen = 0;\n // By the intermediate value theorem We cannot find 2 consecutive maximum or minimum\n for (let i = 1; i < yData.length - 1; ++i) {\n // filter based on derivativeThreshold\n // console.log('pasa', y[i], dY[i], ddY[i]);\n if (Math.abs(dY[i]) > derivativeThreshold) {\n // Minimum in first derivative\n if (\n (dY[i] < dY[i - 1] && dY[i] <= dY[i + 1]) ||\n (dY[i] <= dY[i - 1] && dY[i] < dY[i + 1])\n ) {\n lastMin = {\n x: xData[i],\n index: i,\n };\n if (dX > 0 && lastMax !== null) {\n intervalL[intervalLLen++] = lastMax;\n intervalR[intervalRLen++] = lastMin;\n }\n }\n\n // Maximum in first derivative\n if (\n (dY[i] >= dY[i - 1] && dY[i] > dY[i + 1]) ||\n (dY[i] > dY[i - 1] && dY[i] >= dY[i + 1])\n ) {\n lastMax = {\n x: xData[i],\n index: i,\n };\n if (dX < 0 && lastMin !== null) {\n intervalL[intervalLLen++] = lastMax;\n intervalR[intervalRLen++] = lastMin;\n }\n }\n }\n\n // Minimum in second derivative\n if (ddY[i] < ddY[i - 1] && ddY[i] < ddY[i + 1]) {\n // TODO should we change this to have 3 arrays ? Huge overhead creating arrays\n minddY[minddYLen++] = i; // ( [xData[i], yData[i], i] );\n broadMask[broadMaskLen++] = Math.abs(ddY[i]) <= broadRatio * maxDdy;\n }\n }\n minddY.length = minddYLen;\n intervalL.length = intervalLLen;\n intervalR.length = intervalRLen;\n broadMask.length = broadMaskLen;\n\n let signals = new Array(minddY.length);\n let signalsLen = 0;\n let lastK = -1;\n let possible, frequency, distanceJ, minDistance, gettingCloser;\n for (let j = 0; j < minddY.length; ++j) {\n frequency = xData[minddY[j]];\n possible = -1;\n let k = lastK + 1;\n minDistance = Number.MAX_VALUE;\n distanceJ = 0;\n gettingCloser = true;\n while (possible === -1 && k < intervalL.length && gettingCloser) {\n distanceJ = Math.abs(frequency - (intervalL[k].x + intervalR[k].x) / 2);\n\n // Still getting closer?\n if (distanceJ < minDistance) {\n minDistance = distanceJ;\n } else {\n gettingCloser = false;\n }\n if (distanceJ < Math.abs(intervalL[k].x - intervalR[k].x) / 2) {\n possible = k;\n lastK = k;\n }\n ++k;\n }\n\n if (possible !== -1) {\n if (Math.abs(yData[minddY[j]]) > minMaxRatio * maxY) {\n signals[signalsLen++] = {\n index: minddY[j],\n x: frequency,\n y: (yData[minddY[j]] + yCorrection.b) / yCorrection.m,\n width: Math.abs(intervalR[possible].x - intervalL[possible].x), // widthCorrection\n soft: broadMask[j],\n };\n\n signals[signalsLen - 1].left = intervalL[possible];\n signals[signalsLen - 1].right = intervalR[possible];\n\n if (heightFactor) {\n let yLeft = yData[intervalL[possible].index];\n let yRight = yData[intervalR[possible].index];\n signals[signalsLen - 1].height =\n heightFactor * (signals[signalsLen - 1].y - (yLeft + yRight) / 2);\n }\n }\n }\n }\n signals.length = signalsLen;\n\n if (realTopDetection) {\n determineRealTop(signals, xData, yData);\n }\n\n // Correct the values to fit the original spectra data\n for (let j = 0; j < signals.length; j++) {\n signals[j].base = noiseLevel;\n }\n\n signals.sort(function (a, b) {\n return a.x - b.x;\n });\n\n return signals;\n}\n\nconst isEqualSpaced = (x) => {\n let tmp;\n let maxDx = 0;\n let minDx = Number.MAX_SAFE_INTEGER;\n for (let i = 0; i < x.length - 1; ++i) {\n tmp = Math.abs(x[i + 1] - x[i]);\n if (tmp < minDx) {\n minDx = tmp;\n }\n if (tmp > maxDx) {\n maxDx = tmp;\n }\n }\n return (maxDx - minDx) / maxDx < 0.05;\n};\n\nconst getNoiseLevel = (y) => {\n let mean = 0;\n\n let stddev = 0;\n let length = y.length;\n for (let i = 0; i < length; ++i) {\n mean += y[i];\n }\n mean /= length;\n let averageDeviations = new Array(length);\n for (let i = 0; i < length; ++i) {\n averageDeviations[i] = Math.abs(y[i] - mean);\n }\n averageDeviations.sort((a, b) => a - b);\n if (length % 2 === 1) {\n stddev = averageDeviations[(length - 1) / 2] / 0.6745;\n } else {\n stddev =\n (0.5 *\n (averageDeviations[length / 2] + averageDeviations[length / 2 - 1])) /\n 0.6745;\n }\n\n return stddev;\n};\n\nconst determineRealTop = (peakList, x, y) => {\n let alpha, beta, gamma, p, currentPoint;\n for (let j = 0; j < peakList.length; j++) {\n currentPoint = peakList[j].index; // peakList[j][2];\n // The detected peak could be moved 1 or 2 units to left or right.\n if (\n y[currentPoint - 1] >= y[currentPoint - 2] &&\n y[currentPoint - 1] >= y[currentPoint]\n ) {\n currentPoint--;\n } else {\n if (\n y[currentPoint + 1] >= y[currentPoint] &&\n y[currentPoint + 1] >= y[currentPoint + 2]\n ) {\n currentPoint++;\n } else {\n if (\n y[currentPoint - 2] >= y[currentPoint - 3] &&\n y[currentPoint - 2] >= y[currentPoint - 1]\n ) {\n currentPoint -= 2;\n } else {\n if (\n y[currentPoint + 2] >= y[currentPoint + 1] &&\n y[currentPoint + 2] >= y[currentPoint + 3]\n ) {\n currentPoint += 2;\n }\n }\n }\n }\n // interpolation to a sin() function\n if (\n y[currentPoint - 1] > 0 &&\n y[currentPoint + 1] > 0 &&\n y[currentPoint] >= y[currentPoint - 1] &&\n y[currentPoint] >= y[currentPoint + 1] &&\n (y[currentPoint] !== y[currentPoint - 1] ||\n y[currentPoint] !== y[currentPoint + 1])\n ) {\n alpha = 20 * Math.log10(y[currentPoint - 1]);\n beta = 20 * Math.log10(y[currentPoint]);\n gamma = 20 * Math.log10(y[currentPoint + 1]);\n p = (0.5 * (alpha - gamma)) / (alpha - 2 * beta + gamma);\n // console.log(alpha, beta, gamma, `p: ${p}`);\n // console.log(x[currentPoint]+\" \"+tmp+\" \"+currentPoint);\n peakList[j].x =\n x[currentPoint] + (x[currentPoint] - x[currentPoint - 1]) * p;\n peakList[j].y =\n y[currentPoint] -\n 0.25 * (y[currentPoint - 1] - y[currentPoint + 1]) * p;\n }\n }\n};\n","/**\n * This function calculates the spectrum as a sum of gaussian functions. The Gaussian\n * parameters are divided in 3 batches. 1st: centers; 2nd: height; 3th: std's;\n * @param t Ordinate values\n * @param p Gaussian parameters\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\nexport function sumOfGaussians(p) {\n return function (t) {\n let nL = p.length / 3;\n let factor;\n let rows = t.length;\n let result = rows === undefined ? 0 : new Float64Array(rows).fill(0);\n for (let i = 0; i < nL; i++) {\n factor = Math.pow(p[i + nL * 2], 2) * 2;\n if (rows === undefined) {\n result += p[i + nL] * Math.exp(-Math.pow(t - p[i], 2) / factor);\n } else {\n for (let j = 0; j < rows; j++) {\n result[j] += p[i + nL] * Math.exp(-Math.pow(t[j] - p[i], 2) / factor);\n }\n }\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { sumOfGaussians } from './sumOfGaussians';\n\n/**\n *\n * @param xy A two column matrix containing the x and y data to be fitted\n * @param group A set of initial lorentzian parameters to be optimized [center, heigth, half_width_at_half_height]\n * @returns {Array} A set of final lorentzian parameters [center, heigth, hwhh*2]\n */\nexport function optimizeGaussianSum(xy, group, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let nL = group.length;\n let pInit = new Float64Array(nL * 3);\n let pMin = new Float64Array(nL * 3);\n let pMax = new Float64Array(nL * 3);\n let dt = Math.abs(t[0] - t[1]);\n\n for (let i = 0; i < nL; i++) {\n pInit[i] = group[i].x;\n pInit[i + nL] = group[i].y / maxY;\n pInit[i + 2 * nL] = group[i].width;\n\n pMin[i] = group[i].x - dt;\n pMin[i + nL] = 0;\n pMin[i + 2 * nL] = group[i].width / 4;\n\n pMax[i] = group[i].x + dt;\n pMax[i + nL] = (group[i].y * 1.2) / maxY;\n pMax[i + 2 * nL] = group[i].width * 4;\n }\n\n let data = {\n x: t,\n y: yData,\n };\n let result = new Array(nL);\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n\n let pFit = LM(data, sumOfGaussians, opts);\n for (let i = 0; i < nL; i++) {\n result[i] = {\n parameters: [\n pFit.parameterValues[i],\n pFit.parameterValues[i + nL] * maxY,\n pFit.parameterValues[i + nL * 2],\n ],\n error: pFit.parameterError,\n };\n }\n return result;\n}\n","/**\n * Single 3 parameter gaussian function\n * @param t Ordinate values\n * @param p Gaussian parameters [mean, height, std]\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\n\nexport function singleGaussian(p) {\n return function (t) {\n let factor2 = (p[2] * p[2]) / 2;\n let rows = t.length;\n if (!rows) return p[1] * Math.exp((-(t - p[0]) * (t - p[0])) / factor2);\n let result = new Float64Array(t.length);\n for (let i = 0; i < t.length; i++) {\n result[i] = p[1] * Math.exp((-(t[i] - p[0]) * (t[i] - p[0])) / factor2);\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { singleGaussian } from './singleGaussian';\n\n/**\n * Fits a set of points to a gaussian bell. Returns the mean of the peak, the std and the height of the signal.\n * @param data,[y]\n * @returns {*[]}\n */\nexport function optimizeSingleGaussian(xy, peak, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let dt = Math.abs(t[0] - t[1]);\n let pInit = new Float64Array([peak.x, 1, peak.width]);\n let pMin = new Float64Array([peak.x - dt, 0, peak.width / 4]);\n let pMax = new Float64Array([peak.x + dt, 1.25, peak.width * 4]);\n\n let data = {\n x: t,\n y: yData,\n };\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n let pFit = LM(data, singleGaussian, opts);\n return {\n parameters: [\n pFit.parameterValues[0],\n pFit.parameterValues[1] * maxY,\n pFit.parameterValues[2],\n ],\n error: pFit.parameterError,\n };\n}\n","/**\n * This function calculates the spectrum as a sum of lorentzian functions. The Lorentzian\n * parameters are divided in 3 batches. 1st: centers; 2nd: heights; 3th: widths;\n * @param t Ordinate values\n * @param p Lorentzian parameters\n * @returns {*}\n */\n\nexport function sumOfLorentzians(p) {\n return function (t) {\n let nL = p.length / 3;\n let factor;\n let p2;\n let rows = t.length;\n let result = rows === undefined ? 0 : new Float64Array(rows).fill(0);\n for (let i = 0; i < nL; i++) {\n p2 = Math.pow(p[i + nL * 2] / 2, 2);\n factor = p[i + nL] * p2;\n if (rows === undefined) {\n result += factor / (Math.pow(t - p[i], 2) + p2);\n } else {\n for (let j = 0; j < rows; j++) {\n result[j] += factor / (Math.pow(t[j] - p[i], 2) + p2);\n }\n }\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { sumOfLorentzians } from './sumOfLorentzians';\n\n/**\n *\n * @param xy A two column matrix containing the x and y data to be fitted\n * @param group A set of initial lorentzian parameters to be optimized [center, heigth, half_width_at_half_height]\n * @returns {Array} A set of final lorentzian parameters [center, heigth, hwhh*2]\n */\nexport function optimizeLorentzianSum(xy, group, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n\n let nL = group.length;\n let pInit = new Float64Array(nL * 3);\n let pMin = new Float64Array(nL * 3);\n let pMax = new Float64Array(nL * 3);\n let dt = Math.abs(t[0] - t[1]);\n\n for (let i = 0; i < nL; i++) {\n pInit[i] = group[i].x;\n pInit[i + nL] = 1;\n pInit[i + 2 * nL] = group[i].width;\n\n pMin[i] = group[i].x - dt;\n pMin[i + nL] = 0;\n pMin[i + 2 * nL] = group[i].width / 4;\n\n pMax[i] = group[i].x + dt;\n pMax[i + nL] = 1.5;\n pMax[i + 2 * nL] = group[i].width * 4;\n }\n\n let data = {\n x: t,\n y: yData,\n };\n\n let result = new Array(nL);\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n\n opts = Object.assign({}, lmOptions, opts);\n\n let pFit = LM(data, sumOfLorentzians, opts);\n for (let i = 0; i < nL; i++) {\n result[i] = {\n parameters: [\n pFit.parameterValues[i],\n pFit.parameterValues[i + nL] * maxY,\n pFit.parameterValues[i + nL * 2],\n ],\n error: pFit.parameterError,\n };\n }\n return result;\n}\n","/**\n * Single 4 parameter lorentzian function\n * @param t Ordinate values\n * @param p Lorentzian parameters\n * @param c Constant parameters(Not used)\n * @returns {*}\n */\n\nexport function singleLorentzian(p) {\n return function (t) {\n let factor = p[1] * Math.pow(p[2] / 2, 2);\n let rows = t.length;\n if (!rows) return factor / (Math.pow(t - p[0], 2) + Math.pow(p[2] / 2, 2));\n let result = new Float64Array(rows);\n for (let i = 0; i < rows; i++) {\n result[i] = factor / (Math.pow(t[i] - p[0], 2) + Math.pow(p[2] / 2, 2));\n }\n return result;\n };\n}\n","import LM from 'ml-levenberg-marquardt';\n\nimport { singleLorentzian } from './singleLorentzian';\n\n/**\n * * Fits a set of points to a Lorentzian function. Returns the center of the peak, the width at half height, and the height of the signal.\n * @param data,[y]\n * @returns {*[]}\n */\nexport function optimizeSingleLorentzian(xy, peak, opts = {}) {\n let t = xy[0];\n let yData = xy[1];\n let maxY = Math.max(...yData);\n yData.forEach((x, i, arr) => (arr[i] /= maxY));\n let dt = Math.abs(t[0] - t[1]);\n let pInit = new Float64Array([peak.x, 1, peak.width]);\n let pMin = new Float64Array([peak.x - dt, 0.75, peak.width / 4]);\n let pMax = new Float64Array([peak.x + dt, 1.25, peak.width * 4]);\n\n let data = {\n x: t,\n y: yData,\n };\n\n let lmOptions = {\n damping: 1.5,\n initialValues: pInit,\n minValues: pMin,\n maxValues: pMax,\n gradientDifference: dt / 10000,\n maxIterations: 100,\n errorTolerance: 10e-5,\n };\n opts = Object.assign({}, lmOptions, opts);\n let pFit = LM(data, singleLorentzian, opts);\n return {\n parameters: [\n pFit.parameterValues[0],\n pFit.parameterValues[1] * maxY,\n pFit.parameterValues[2],\n ],\n error: pFit.parameterError,\n };\n}\n","import {\n optimizeGaussianSum,\n optimizeLorentzianSum,\n optimizeSingleGaussian,\n optimizeSingleLorentzian,\n} from 'ml-optimize-lorentzian';\n\nexport function optimizePeaks(peakList, x, y, options = {}) {\n const {\n functionName = 'gaussian',\n factorWidth = 4,\n optimizationOptions = {\n damping: 1.5,\n maxIterations: 100,\n errorTolerance: 10e-5,\n },\n } = options;\n\n let lastIndex = [0];\n let groups = groupPeaks(peakList, factorWidth);\n let result = [];\n let factor = 1;\n if (functionName === 'gaussian') {\n factor = 1.17741;\n } // From https://en.wikipedia.org/wiki/Gaussian_function#Properties\n let sampling;\n for (let i = 0; i < groups.length; i++) {\n let peaks = groups[i].group;\n if (peaks.length > 1) {\n // Multiple peaks\n sampling = sampleFunction(\n groups[i].limits[0] - groups[i].limits[1],\n groups[i].limits[0] + groups[i].limits[1],\n x,\n y,\n lastIndex,\n );\n if (sampling[0].length > 5) {\n let optPeaks = [];\n if (functionName === 'gaussian') {\n optPeaks = optimizeGaussianSum(sampling, peaks, optimizationOptions);\n } else {\n if (functionName === 'lorentzian') {\n optPeaks = optimizeLorentzianSum(\n sampling,\n peaks,\n optimizationOptions,\n );\n }\n }\n\n for (let j = 0; j < optPeaks.length; j++) {\n let { parameters } = optPeaks[j];\n result.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2] * factor,\n index: peaks[j].index,\n });\n }\n }\n } else {\n // Single peak\n peaks = peaks[0];\n sampling = sampleFunction(\n peaks.x - factorWidth * peaks.width,\n peaks.x + factorWidth * peaks.width,\n x,\n y,\n lastIndex,\n );\n\n if (sampling[0].length > 5) {\n let fitResult = [];\n if (functionName === 'gaussian') {\n fitResult = optimizeSingleGaussian(\n [sampling[0], sampling[1]],\n peaks,\n optimizationOptions,\n );\n } else {\n if (functionName === 'lorentzian') {\n fitResult = optimizeSingleLorentzian(\n [sampling[0], sampling[1]],\n peaks,\n optimizationOptions,\n );\n }\n }\n\n let { parameters } = fitResult;\n result.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2] * factor,\n index: peaks.index,\n }); // From https://en.wikipedia.org/wiki/Gaussian_function#Properties}\n }\n }\n }\n return result;\n}\n\nfunction sampleFunction(from, to, x, y, lastIndex) {\n let nbPoints = x.length;\n let sampleX = [];\n let sampleY = [];\n let direction = Math.sign(x[1] - x[0]); // Direction of the derivative\n if (direction === -1) {\n lastIndex[0] = x.length - 1;\n }\n\n let delta = Math.abs(to - from) / 2;\n let mid = (from + to) / 2;\n let stop = false;\n let index = lastIndex[0];\n while (!stop && index < nbPoints && index >= 0) {\n if (Math.abs(x[index] - mid) <= delta) {\n sampleX.push(x[index]);\n sampleY.push(y[index]);\n index += direction;\n } else {\n // It is outside the range.\n if (Math.sign(mid - x[index]) === 1) {\n // We'll reach the mid going in the current direction\n index += direction;\n } else {\n // There is not more peaks in the current range\n stop = true;\n }\n }\n }\n lastIndex[0] = index;\n return [sampleX, sampleY];\n}\n\nfunction groupPeaks(peakList, nL) {\n let group = [];\n let groups = [];\n let limits = [peakList[0].x, nL * peakList[0].width];\n let upperLimit, lowerLimit;\n // Merge forward\n for (let i = 0; i < peakList.length; i++) {\n // If the 2 things overlaps\n if (\n Math.abs(peakList[i].x - limits[0]) <\n nL * peakList[i].width + limits[1]\n ) {\n // Add the peak to the group\n group.push(peakList[i]);\n // Update the group limits\n upperLimit = limits[0] + limits[1];\n if (peakList[i].x + nL * peakList[i].width > upperLimit) {\n upperLimit = peakList[i].x + nL * peakList[i].width;\n }\n lowerLimit = limits[0] - limits[1];\n if (peakList[i].x - nL * peakList[i].width < lowerLimit) {\n lowerLimit = peakList[i].x - nL * peakList[i].width;\n }\n limits = [\n (upperLimit + lowerLimit) / 2,\n Math.abs(upperLimit - lowerLimit) / 2,\n ];\n } else {\n groups.push({ limits: limits, group: group });\n // var optmimalPeak = fitSpectrum(group,limits,spectrum);\n group = [peakList[i]];\n limits = [peakList[i].x, nL * peakList[i].width];\n }\n }\n groups.push({ limits: limits, group: group });\n // Merge backward\n for (let i = groups.length - 2; i >= 0; i--) {\n // The groups overlaps\n if (\n Math.abs(groups[i].limits[0] - groups[i + 1].limits[0]) <\n (groups[i].limits[1] + groups[i + 1].limits[1]) / 2\n ) {\n for (let j = 0; j < groups[i + 1].group.length; j++) {\n groups[i].group.push(groups[i + 1].group[j]);\n }\n upperLimit = groups[i].limits[0] + groups[i].limits[1];\n if (groups[i + 1].limits[0] + groups[i + 1].limits[1] > upperLimit) {\n upperLimit = groups[i + 1].limits[0] + groups[i + 1].limits[1];\n }\n lowerLimit = groups[i].limits[0] - groups[i].limits[1];\n if (groups[i + 1].limits[0] - groups[i + 1].limits[1] < lowerLimit) {\n lowerLimit = groups[i + 1].limits[0] - groups[i + 1].limits[1];\n }\n\n groups[i].limits = [\n (upperLimit + lowerLimit) / 2,\n Math.abs(upperLimit - lowerLimit) / 2,\n ];\n\n groups.splice(i + 1, 1);\n }\n }\n return groups;\n}\n","import { optimizeSingleLorentzian } from 'ml-optimize-lorentzian';\n\n/**\n * This function try to join the peaks that seems to belong to a broad signal in a single broad peak.\n * @param peakList\n * @param options\n */\nexport function joinBroadPeaks(peakList, options = {}) {\n let width = options.width;\n let broadLines = [];\n // Optimize the possible broad lines\n let max = 0;\n\n let maxI = 0;\n\n let count = 1;\n for (let i = peakList.length - 1; i >= 0; i--) {\n if (peakList[i].soft) {\n broadLines.push(peakList.splice(i, 1)[0]);\n }\n }\n // Push a feke peak\n broadLines.push({ x: Number.MAX_VALUE });\n\n let candidates = [[broadLines[0].x, broadLines[0].y]];\n let indexes = [broadLines[0].index];\n\n for (let i = 1; i < broadLines.length; i++) {\n // console.log(broadLines[i-1].x+\" \"+broadLines[i].x);\n if (Math.abs(broadLines[i - 1].x - broadLines[i].x) < width) {\n candidates.push([broadLines[i].x, broadLines[i].y]);\n if (broadLines[i].y > max) {\n max = broadLines[i].y;\n maxI = i;\n }\n indexes.push(broadLines[i].index);\n count++;\n } else {\n if (count > 2) {\n let fitted = optimizeSingleLorentzian(candidates, {\n x: broadLines[maxI].x,\n y: max,\n width: Math.abs(\n candidates[0][0] - candidates[candidates.length - 1][0],\n ),\n });\n let { parameters } = fitted;\n peakList.push({\n x: parameters[0],\n y: parameters[1],\n width: parameters[2],\n index: Math.floor(\n indexes.reduce((a, b) => a + b, 0) / indexes.length,\n ),\n soft: false,\n });\n } else {\n // Put back the candidates to the signals list\n indexes.forEach((index) => {\n peakList.push(broadLines[index]);\n });\n }\n candidates = [[broadLines[i].x, broadLines[i].y]];\n indexes = [i];\n max = broadLines[i].y;\n maxI = i;\n count = 1;\n }\n }\n\n peakList.sort(function (a, b) {\n return a.x - b.x;\n });\n\n return peakList;\n}\n","/**\n * This method will allow to enlarge peaks and prevent overlap between peaks\n * Because peaks may not be symmetric after we add 2 properties, from and to.\n * @param {Array} peakList\n * @param {object} [options={}]\n * @param {number} [factor=2]\n * @param {boolean} [overlap=false] by default we don't allow overlap\n * @return {Array} peakList\n */\nexport function broadenPeaks(peakList, options = {}) {\n const { factor = 2, overlap = false } = options;\n\n for (let peak of peakList) {\n if (!peak.right || !peak.left) {\n peak.from = peak.x - (peak.width / 2) * factor;\n peak.to = peak.x + (peak.width / 2) * factor;\n } else {\n peak.from = peak.x - (peak.x - peak.left.x) * factor;\n peak.to = peak.x + (peak.right.x - peak.x) * factor;\n }\n }\n\n if (!overlap) {\n for (let i = 0; i < peakList.length - 1; i++) {\n let peak = peakList[i];\n let nextPeak = peakList[i + 1];\n if (peak.to > nextPeak.from) {\n peak.to = nextPeak.from = (peak.to + nextPeak.from) / 2;\n }\n }\n }\n\n for (let peak of peakList) {\n peak.width = peak.to - peak.from;\n }\n\n return peakList;\n}\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction min(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var minValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\n\nfunction mode(input) {\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var maxValue = 0;\n var maxCount = 0;\n var count = 0;\n var counts = {};\n\n for (var i = 0; i < input.length; ++i) {\n var element = input[i];\n count = counts[element];\n\n if (count) {\n counts[element]++;\n count++;\n } else {\n counts[element] = count = 1;\n }\n\n if (count > maxCount) {\n maxCount = count;\n maxValue = input[i];\n }\n }\n\n return maxValue;\n}\n\nexport default mode;\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\n\nfunction max(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n if (input.length === 0) {\n throw new TypeError('input must not be empty');\n }\n\n var _options$fromIndex = options.fromIndex,\n fromIndex = _options$fromIndex === void 0 ? 0 : _options$fromIndex,\n _options$toIndex = options.toIndex,\n toIndex = _options$toIndex === void 0 ? input.length : _options$toIndex;\n\n if (fromIndex < 0 || fromIndex >= input.length || !Number.isInteger(fromIndex)) {\n throw new Error('fromIndex must be a positive integer smaller than length');\n }\n\n if (toIndex <= fromIndex || toIndex > input.length || !Number.isInteger(toIndex)) {\n throw new Error('toIndex must be an integer greater than fromIndex and at most equal to length');\n }\n\n var maxValue = input[fromIndex];\n\n for (var i = fromIndex + 1; i < toIndex; i++) {\n if (input[i] > maxValue) maxValue = input[i];\n }\n\n return maxValue;\n}\n\nexport default max;\n","import isArray from 'is-any-array';\nimport max from 'ml-array-max';\nimport sum from 'ml-array-sum';\n\nfunction norm(input) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var _options$algorithm = options.algorithm,\n algorithm = _options$algorithm === void 0 ? 'absolute' : _options$algorithm,\n _options$sumValue = options.sumValue,\n sumValue = _options$sumValue === void 0 ? 1 : _options$sumValue,\n _options$maxValue = options.maxValue,\n maxValue = _options$maxValue === void 0 ? 1 : _options$maxValue;\n\n if (!isArray(input)) {\n throw new Error('input must be an array');\n }\n\n var output;\n\n if (options.output !== undefined) {\n if (!isArray(options.output)) {\n throw new TypeError('output option must be an array if specified');\n }\n\n output = options.output;\n } else {\n output = new Array(input.length);\n }\n\n if (input.length === 0) {\n throw new Error('input must not be empty');\n }\n\n switch (algorithm.toLowerCase()) {\n case 'absolute':\n {\n var absoluteSumValue = absoluteSum(input) / sumValue;\n if (absoluteSumValue === 0) return input.slice(0);\n\n for (var i = 0; i < input.length; i++) {\n output[i] = input[i] / absoluteSumValue;\n }\n\n return output;\n }\n\n case 'max':\n {\n var currentMaxValue = max(input);\n if (currentMaxValue === 0) return input.slice(0);\n var factor = maxValue / currentMaxValue;\n\n for (var _i = 0; _i < input.length; _i++) {\n output[_i] = input[_i] * factor;\n }\n\n return output;\n }\n\n case 'sum':\n {\n var sumFactor = sum(input) / sumValue;\n if (sumFactor === 0) return input.slice(0);\n\n for (var _i2 = 0; _i2 < input.length; _i2++) {\n output[_i2] = input[_i2] / sumFactor;\n }\n\n return output;\n }\n\n default:\n throw new Error(\"norm: unknown algorithm: \".concat(algorithm));\n }\n}\n\nfunction absoluteSum(input) {\n var sumValue = 0;\n\n for (var i = 0; i < input.length; i++) {\n sumValue += Math.abs(input[i]);\n }\n\n return sumValue;\n}\n\nexport default norm;\n","import isArray from 'is-any-array';\n\nfunction _typeof(obj) {\n \"@babel/helpers - typeof\";\n\n if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") {\n _typeof = function (obj) {\n return typeof obj;\n };\n } else {\n _typeof = function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj;\n };\n }\n\n return _typeof(obj);\n}\n\n/**\r\n * Fill an array with sequential numbers\r\n * @param {Array} [input] - optional destination array (if not provided a new array will be created)\r\n * @param {object} [options={}]\r\n * @param {number} [options.from=0] - first value in the array\r\n * @param {number} [options.to=10] - last value in the array\r\n * @param {number} [options.size=input.length] - size of the array (if not provided calculated from step)\r\n * @param {number} [options.step] - if not provided calculated from size\r\n * @return {Array}\r\n */\n\nfunction sequentialFill() {\n var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (_typeof(input) === 'object' && !isArray(input)) {\n options = input;\n input = [];\n }\n\n if (!isArray(input)) {\n throw new TypeError('input must be an array');\n }\n\n var _options = options,\n _options$from = _options.from,\n from = _options$from === void 0 ? 0 : _options$from,\n _options$to = _options.to,\n to = _options$to === void 0 ? 10 : _options$to,\n _options$size = _options.size,\n size = _options$size === void 0 ? input.length : _options$size,\n step = _options.step;\n\n if (size !== 0 && step) {\n throw new Error('step is defined by the array size');\n }\n\n if (!size) {\n if (step) {\n size = Math.floor((to - from) / step) + 1;\n } else {\n size = to - from + 1;\n }\n }\n\n if (!step && size) {\n step = (to - from) / (size - 1);\n }\n\n if (Array.isArray(input)) {\n // only works with normal array\n input.length = 0;\n\n for (var i = 0; i < size; i++) {\n input.push(from);\n from += step;\n }\n } else {\n if (input.length !== size) {\n throw new Error('sequentialFill typed array must have the correct length');\n }\n\n for (var _i = 0; _i < size; _i++) {\n input[_i] = from;\n from += step;\n }\n }\n\n return input;\n}\n\nexport default sequentialFill;\n","const toString = Object.prototype.toString;\n\nexport default function isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n","import isArray from 'is-any-array';\nimport arrayMean from 'ml-array-mean';\n\nfunction variance(values) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n if (!isArray(values)) {\n throw new TypeError('input must be an array');\n }\n\n var _options$unbiased = options.unbiased,\n unbiased = _options$unbiased === void 0 ? true : _options$unbiased,\n _options$mean = options.mean,\n mean = _options$mean === void 0 ? arrayMean(values) : _options$mean;\n var sqrError = 0;\n\n for (var i = 0; i < values.length; i++) {\n var x = values[i] - mean;\n sqrError += x * x;\n }\n\n if (unbiased) {\n return sqrError / (values.length - 1);\n } else {\n return sqrError / values.length;\n }\n}\n\nexport default variance;\n","import variance from 'ml-array-variance';\n\nfunction standardDeviation(values) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n return Math.sqrt(variance(values, options));\n}\n\nexport default standardDeviation;\n","/**\n * Merge abscissa values if the ordinate value is in a list of centroids\n * @param {object} originalPoints\n * @param {Array} originalPoints.x\n * @param {Array} originalPoints.y\n * @param {Array} centroids\n * @param {object} [options]\n * @param {number} [options.window = 0.01] - has to be a positive number\n * @return {{x: Array, y: Array}}\n */\nexport default function mergeByCentroids(\n originalPoints,\n centroids,\n options = {}\n) {\n const { window = 0.01 } = options;\n\n var mergedPoints = {\n x: centroids.slice(),\n y: new Array(centroids.length).fill(0)\n };\n\n var originalIndex = 0;\n var mergedIndex = 0;\n while (\n originalIndex < originalPoints.x.length &&\n mergedIndex < centroids.length\n ) {\n var diff = originalPoints.x[originalIndex] - centroids[mergedIndex];\n if (Math.abs(diff) < window) {\n mergedPoints.y[mergedIndex] += originalPoints.y[originalIndex++];\n } else if (diff < 0) {\n originalIndex++;\n } else {\n mergedIndex++;\n }\n }\n\n return mergedPoints;\n}\n","import binarySearch from 'binary-search';\nimport { ascending, descending } from 'num-sort';\n\n/**\n *\n * @param {object} points\n * @param {Array} originalPoints.x\n * @param {Array} originalPoints.y\n * @param {*} options\n * @return {{x: Array, y: Array}}\n */\nexport default function closestX(points, options) {\n const { x, y } = points;\n const { target = x[0], reverse = false } = options;\n\n let index;\n if (reverse) {\n index = binarySearch(x, target, descending);\n } else {\n index = binarySearch(x, target, ascending);\n }\n\n if (index >= 0) {\n return {\n x: x[index],\n y: y[index]\n };\n } else {\n index = ~index;\n if (\n (index !== 0 && Math.abs(x[index] - target) > 0.5) ||\n index === x.length\n ) {\n return {\n x: x[index - 1],\n y: y[index - 1]\n };\n } else {\n return {\n x: x[index],\n y: y[index]\n };\n }\n }\n}\n","import mean from 'ml-array-mean';\n\n/**\n *\n * @param {object} points\n * @param {Array} points.x\n * @param {Array} points.y\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @return {number}\n */\nexport default function covariance(points, options = {}) {\n const { x, y } = points;\n const { unbiased = true } = options;\n\n const meanX = mean(x);\n const meanY = mean(y);\n\n var error = 0;\n\n for (let i = 0; i < x.length; i++) {\n error += (x[i] - meanX) * (y[i] - meanY);\n }\n\n if (unbiased) {\n return error / (x.length - 1);\n } else {\n return error / x.length;\n }\n}\n","/**\n * Merge abscissas values on similar ordinates and weight the group of abscissas\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {number} [options.groupWidth = 0.001] - window for abscissas to merge\n * @return {{x: Array, y: Array}}\n */\nexport default function maxMerge(points, options = {}) {\n const { x, y } = points;\n const { groupWidth = 0.001 } = options;\n\n var merged = { x: [], y: [] };\n var maxAbscissa = { x: [], y: [] };\n var size = 0;\n var index = 0;\n\n while (index < x.length) {\n if (size === 0 || x[index] - merged.x[size - 1] > groupWidth) {\n maxAbscissa.x.push(x[index]);\n maxAbscissa.y.push(y[index]);\n merged.x.push(x[index]);\n merged.y.push(y[index]);\n index++;\n size++;\n } else {\n if (y[index] > maxAbscissa.y[size - 1]) {\n maxAbscissa.x[size - 1] = x[index];\n maxAbscissa.y[size - 1] = y[index];\n }\n merged.x[size - 1] = x[index];\n merged.y[size - 1] += y[index];\n index++;\n }\n }\n\n merged.x = maxAbscissa.x.slice();\n\n return merged;\n}\n","import binarySearch from 'binary-search';\nimport { ascending, descending } from 'num-sort';\n\n/**\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {object} [options.from = {index: 0}]\n * @param {object} [options.to = {index: x.length-1}]\n * @param {boolean} [options.reverse = false]\n * @return {{index: number, value: number}}\n */\nexport default function maxY(points, options = {}) {\n const { x, y } = points;\n let {\n from = { index: 0 },\n to = { index: x.length },\n reverse = false\n } = options;\n\n if (from.value !== undefined && from.index === undefined) {\n from.index = calculateIndex(from.value, x, reverse);\n }\n\n if (to.value !== undefined && to.index === undefined) {\n to.index = calculateIndex(to.value, x, reverse);\n }\n\n var currentMax = Number.MIN_VALUE;\n var currentIndex;\n for (var i = from.index; i < to.index; i++) {\n if (currentMax < y[i]) {\n currentMax = y[i];\n currentIndex = i;\n }\n }\n\n return {\n index: currentIndex,\n value: currentMax\n };\n}\n\n/**\n * @param {number} value\n * @param {Array} x\n * @param {boolean} reverse\n * @return {number} index of the value in the array\n */\nfunction calculateIndex(value, x, reverse) {\n let index;\n if (reverse) {\n index = binarySearch(x, value, descending);\n } else {\n index = binarySearch(x, value, ascending);\n }\n\n if (index < 0) {\n throw new Error(`the value ${value} doesn't belongs to the abscissa value`);\n }\n\n return index;\n}\n","export default function sortX(points, options = {}) {\n const { x, y } = points;\n const { reverse = false } = options;\n\n var sortFunc;\n if (!reverse) {\n sortFunc = (a, b) => a.x - b.x;\n } else {\n sortFunc = (a, b) => b.x - a.x;\n }\n\n var grouped = x\n .map((val, index) => ({\n x: val,\n y: y[index]\n }))\n .sort(sortFunc);\n\n var response = { x: x.slice(), y: y.slice() };\n for (var i = 0; i < x.length; i++) {\n response.x[i] = grouped[i].x;\n response.y[i] = grouped[i].y;\n }\n\n return response;\n}\n","\n/**\n * In place modification of the 2 arrays to make X unique and sum the Y if X has the same value\n * @param {object} [points={}] : Object of points contains property x (an array) and y (an array)\n * @return points\n */\n\nexport default function uniqueX(points = {}) {\n const { x, y } = points;\n if (x.length < 2) return;\n if (x.length !== y.length) {\n throw new Error('The X and Y arrays mush have the same length');\n }\n\n let current = x[0];\n let counter = 0;\n\n for (let i = 1; i < x.length; i++) {\n if (current !== x[i]) {\n counter++;\n current = x[i];\n x[counter] = x[i];\n if (i !== counter) {\n y[counter] = 0;\n }\n }\n if (i !== counter) {\n y[counter] += y[i];\n }\n }\n\n x.length = counter + 1;\n y.length = counter + 1;\n}\n","/**\n * Merge abscissas values on similar ordinates and weight the group of abscissas\n * @param {object} points\n * @param {Array} points.x - sorted abscissas values\n * @param {Array} points.y - ordinates values\n * @param {object} [options]\n * @param {number} [options.groupWidth = 0.001] - window for abscissas to merge\n * @return {{x: Array, y: Array}}\n */\nexport default function weightedMerge(points, options = {}) {\n const { x, y } = points;\n const { groupWidth = 0.001 } = options;\n\n var merged = { x: [], y: [] };\n var weightedAbscissa = { x: [], y: [] };\n var size = 0;\n var index = 0;\n\n while (index < x.length) {\n if (size === 0 || x[index] - merged.x[size - 1] > groupWidth) {\n weightedAbscissa.x.push(x[index] * y[index]);\n weightedAbscissa.y.push(y[index]);\n merged.x.push(x[index]);\n merged.y.push(y[index]);\n index++;\n size++;\n } else {\n weightedAbscissa.x[size - 1] += x[index] * y[index];\n weightedAbscissa.y[size - 1] += y[index];\n merged.x[size - 1] = x[index];\n merged.y[size - 1] += y[index];\n index++;\n }\n }\n\n for (var i = 0; i < merged.x.length; i++) {\n merged.x[i] = weightedAbscissa.x[i] / weightedAbscissa.y[i];\n }\n\n return merged;\n}\n","/**\n * Normalize an array of zones:\n * - ensure than from < to\n * - merge overlapping zones\n *\n * The method will always check if from if lower than to and will swap if required.\n * @param {Array} [zones=[]]\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of a zone\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of a zone\n */\n\nexport function normalize(zones = [], options = {}) {\n if (zones.length === 0) return [];\n let {\n from = Number.NEGATIVE_INFINITY,\n to = Number.POSITIVE_INFINITY,\n } = options;\n if (from > to) [from, to] = [to, from];\n\n zones = JSON.parse(JSON.stringify(zones)).map((zone) =>\n zone.from > zone.to ? { from: zone.to, to: zone.from } : zone,\n );\n zones = zones.sort((a, b) => {\n if (a.from !== b.from) return a.from - b.from;\n return a.to - b.to;\n });\n\n zones.forEach((zone) => {\n if (from > zone.from) zone.from = from;\n if (to < zone.to) zone.to = to;\n });\n\n zones = zones.filter((zone) => zone.from <= zone.to);\n if (zones.length === 0) return [];\n\n let currentZone = zones[0];\n let result = [currentZone];\n for (let i = 1; i < zones.length; i++) {\n let zone = zones[i];\n if (zone.from <= currentZone.to) {\n currentZone.to = zone.to;\n } else {\n currentZone = zone;\n result.push(currentZone);\n }\n }\n return result;\n}\n","import { normalize } from './normalize';\n\n/**\n * Convert an array of exclusions and keep only from / to\n *\n * The method will always check if from if lower than to and will swap if required.\n * @param {Array} [exclusions=[]]\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of zones (after inversion)\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of zones (after inversion)\n */\n\nexport function invert(exclusions = [], options = {}) {\n let {\n from = Number.NEGATIVE_INFINITY,\n to = Number.POSITIVE_INFINITY,\n } = options;\n if (from > to) [from, to] = [to, from];\n\n exclusions = normalize(exclusions, { from, to });\n if (exclusions.length === 0) return [{ from, to }];\n\n let zones = [];\n for (let i = 0; i < exclusions.length; i++) {\n let exclusion = exclusions[i];\n let nextExclusion = exclusions[i + 1];\n if (i === 0) {\n if (exclusion.from > from) {\n zones.push({ from, to: exclusion.from });\n }\n }\n if (i === exclusions.length - 1) {\n if (exclusion.to < to) {\n zones.push({ from: exclusion.to, to });\n }\n } else {\n zones.push({ from: exclusion.to, to: nextExclusion.from });\n }\n }\n\n return zones;\n}\n","import { normalize } from './normalize';\n\n/**\n * Add the number of points per zone to reach a specified total\n * @param {Array} [zones=[]]\n * @param {number} [numberOfPoints] Total number of points to distribute between zones\n * @param {object} [options={}]\n * @param {number} [options.from=Number.NEGATIVE_INFINITY] Specify min value of a zone\n * @param {number} [options.to=Number.POSITIVE_INFINITY] Specify max value of a zone\n */\n\nexport function zonesWithPoints(zones, numberOfPoints, options = {}) {\n if (zones.length === 0) return zones;\n zones = normalize(zones, options);\n\n const totalSize = zones.reduce((previous, current) => {\n return previous + (current.to - current.from);\n }, 0);\n\n let unitsPerPoint = totalSize / numberOfPoints;\n let currentTotal = 0;\n for (let i = 0; i < zones.length - 1; i++) {\n let zone = zones[i];\n zone.numberOfPoints = Math.min(\n Math.round((zone.to - zone.from) / unitsPerPoint),\n numberOfPoints - currentTotal,\n );\n currentTotal += zone.numberOfPoints;\n }\n\n zones[zones.length - 1].numberOfPoints = numberOfPoints - currentTotal;\n\n return zones;\n}\n","/**\n * Function that calculates the integral of the line between two\n * x-coordinates, given the slope and intercept of the line.\n * @param {number} x0\n * @param {number} x1\n * @param {number} slope\n * @param {number} intercept\n * @return {number} integral value.\n */\nexport default function integral(x0, x1, slope, intercept) {\n return (\n 0.5 * slope * x1 * x1 +\n intercept * x1 -\n (0.5 * slope * x0 * x0 + intercept * x0)\n );\n}\n","import integral from './integral';\n\n/**\n * function that retrieves the getEquallySpacedData with the variant \"smooth\"\n *\n * @param {Array} x\n * @param {Array} y\n * @param {number} from - Initial point\n * @param {number} to - Final point\n * @param {number} numberOfPoints\n * @return {Array} - Array of y's equally spaced with the variant \"smooth\"\n */\nexport default function equallySpacedSmooth(x, y, from, to, numberOfPoints) {\n let xLength = x.length;\n\n let step = (to - from) / (numberOfPoints - 1);\n let halfStep = step / 2;\n\n let output = new Array(numberOfPoints);\n\n let initialOriginalStep = x[1] - x[0];\n let lastOriginalStep = x[xLength - 1] - x[xLength - 2];\n\n // Init main variables\n let min = from - halfStep;\n let max = from + halfStep;\n\n let previousX = Number.MIN_VALUE;\n let previousY = 0;\n let nextX = x[0] - initialOriginalStep;\n let nextY = 0;\n\n let currentValue = 0;\n let slope = 0;\n let intercept = 0;\n let sumAtMin = 0;\n let sumAtMax = 0;\n\n let i = 0; // index of input\n let j = 0; // index of output\n\n function getSlope(x0, y0, x1, y1) {\n return (y1 - y0) / (x1 - x0);\n }\n\n let add = 0;\n main: while (true) {\n if (previousX <= min && min <= nextX) {\n add = integral(0, min - previousX, slope, previousY);\n sumAtMin = currentValue + add;\n }\n\n while (nextX - max >= 0) {\n // no overlap with original point, just consume current value\n add = integral(0, max - previousX, slope, previousY);\n sumAtMax = currentValue + add;\n\n output[j++] = (sumAtMax - sumAtMin) / step;\n\n if (j === numberOfPoints) {\n break main;\n }\n\n min = max;\n max += step;\n sumAtMin = sumAtMax;\n }\n\n currentValue += integral(previousX, nextX, slope, intercept);\n\n previousX = nextX;\n previousY = nextY;\n\n if (i < xLength) {\n nextX = x[i];\n nextY = y[i];\n i++;\n } else if (i === xLength) {\n nextX += lastOriginalStep;\n nextY = 0;\n }\n\n slope = getSlope(previousX, previousY, nextX, nextY);\n intercept = -slope * previousX + previousY;\n }\n\n return output;\n}\n","/**\n * function that retrieves the getEquallySpacedData with the variant \"slot\"\n *\n * @param {Array} x\n * @param {Array} y\n * @param {number} from - Initial point\n * @param {number} to - Final point\n * @param {number} numberOfPoints\n * @return {Array} - Array of y's equally spaced with the variant \"slot\"\n */\nexport default function equallySpacedSlot(x, y, from, to, numberOfPoints) {\n let xLength = x.length;\n\n let step = (to - from) / (numberOfPoints - 1);\n let halfStep = step / 2;\n let lastStep = x[x.length - 1] - x[x.length - 2];\n\n let start = from - halfStep;\n let output = new Array(numberOfPoints);\n\n // Init main variables\n let min = start;\n let max = start + step;\n\n let previousX = -Number.MAX_VALUE;\n let previousY = 0;\n let nextX = x[0];\n let nextY = y[0];\n let frontOutsideSpectra = 0;\n let backOutsideSpectra = true;\n\n let currentValue = 0;\n\n // for slot algorithm\n let currentPoints = 0;\n\n let i = 1; // index of input\n let j = 0; // index of output\n\n main: while (true) {\n if (previousX >= nextX) throw new Error('x must be an increasing serie');\n while (previousX - max > 0) {\n // no overlap with original point, just consume current value\n if (backOutsideSpectra) {\n currentPoints++;\n backOutsideSpectra = false;\n }\n\n output[j] = currentPoints <= 0 ? 0 : currentValue / currentPoints;\n j++;\n\n if (j === numberOfPoints) {\n break main;\n }\n\n min = max;\n max += step;\n currentValue = 0;\n currentPoints = 0;\n }\n\n if (previousX > min) {\n currentValue += previousY;\n currentPoints++;\n }\n\n if (previousX === -Number.MAX_VALUE || frontOutsideSpectra > 1) {\n currentPoints--;\n }\n\n previousX = nextX;\n previousY = nextY;\n\n if (i < xLength) {\n nextX = x[i];\n nextY = y[i];\n i++;\n } else {\n nextX += lastStep;\n nextY = 0;\n frontOutsideSpectra++;\n }\n }\n\n return output;\n}\n","import sequentialFill from 'ml-array-sequential-fill';\nimport { zonesWithPoints, invert } from 'ml-zones';\n\nimport equallySpacedSmooth from './equallySpacedSmooth';\nimport equallySpacedSlot from './equallySpacedSlot';\n\n/**\n * Function that returns a Number array of equally spaced numberOfPoints\n * containing a representation of intensities of the spectra arguments x\n * and y.\n *\n * The options parameter contains an object in the following form:\n * from: starting point\n * to: last point\n * numberOfPoints: number of points between from and to\n * variant: \"slot\" or \"smooth\" - smooth is the default option\n *\n * The slot variant consist that each point in the new array is calculated\n * averaging the existing points between the slot that belongs to the current\n * value. The smooth variant is the same but takes the integral of the range\n * of the slot and divide by the step size between two points in the new array.\n *\n * If exclusions zone are present, zones are ignored !\n * @param {object} [arrayXY={}] - object containing 2 properties x and y (both an array)\n * @param {object} [options={}]\n * @param {number} [options.from=x[0]]\n * @param {number} [options.to=x[x.length-1]]\n * @param {string} [options.variant='smooth']\n * @param {number} [options.numberOfPoints=100]\n * @param {Array} [options.exclusions=[]] array of from / to that should be skipped for the generation of the points\n * @param {Array} [options.zones=[]] array of from / to that should be kept\n * @return {object} new object with x / y array with the equally spaced data.\n */\n\nexport default function equallySpaced(arrayXY = {}, options = {}) {\n let { x, y } = arrayXY;\n let xLength = x.length;\n let reverse = false;\n if (x.length > 1 && x[0] > x[1]) {\n x = x.slice().reverse();\n y = y.slice().reverse();\n reverse = true;\n }\n\n let {\n from = x[0],\n to = x[xLength - 1],\n variant = 'smooth',\n numberOfPoints = 100,\n exclusions = [],\n zones = [],\n } = options;\n\n if (xLength !== y.length) {\n throw new RangeError(\"the x and y vector doesn't have the same size.\");\n }\n\n if (typeof from !== 'number' || isNaN(from)) {\n throw new RangeError(\"'from' option must be a number\");\n }\n\n if (typeof to !== 'number' || isNaN(to)) {\n throw new RangeError(\"'to' option must be a number\");\n }\n\n if (typeof numberOfPoints !== 'number' || isNaN(numberOfPoints)) {\n throw new RangeError(\"'numberOfPoints' option must be a number\");\n }\n\n if (numberOfPoints < 2) {\n throw new RangeError(\"'numberOfPoints' option must be greater than 1\");\n }\n\n if (zones.length === 0) {\n zones = invert(exclusions, { from, to });\n }\n\n zones = zonesWithPoints(zones, numberOfPoints, { from, to });\n\n let xResult = [];\n let yResult = [];\n for (let zone of zones) {\n let zoneResult = processZone(\n x,\n y,\n zone.from,\n zone.to,\n zone.numberOfPoints,\n variant,\n reverse,\n );\n\n xResult = xResult.concat(zoneResult.x);\n yResult = yResult.concat(zoneResult.y);\n }\n if (reverse) {\n if (from < to) {\n return { x: xResult.reverse(), y: yResult.reverse() };\n } else {\n return { x: xResult, y: yResult };\n }\n } else {\n if (from < to) {\n return { x: xResult, y: yResult };\n } else {\n return { x: xResult.reverse(), y: yResult.reverse() };\n }\n }\n}\n\nfunction processZone(x, y, from, to, numberOfPoints, variant) {\n if (numberOfPoints < 1) {\n throw new RangeError('the number of points must be at least 1');\n }\n\n let output =\n variant === 'slot'\n ? equallySpacedSlot(x, y, from, to, numberOfPoints)\n : equallySpacedSmooth(x, y, from, to, numberOfPoints);\n\n return {\n x: sequentialFill({\n from,\n to,\n size: numberOfPoints,\n }),\n y: output,\n };\n}\n","export default function getZones(from, to, exclusions = []) {\n if (from > to) {\n [from, to] = [to, from];\n }\n\n // in exclusions from and to have to be defined\n exclusions = exclusions.filter(\n (exclusion) => exclusion.from !== undefined && exclusion.to !== undefined\n );\n\n exclusions = JSON.parse(JSON.stringify(exclusions));\n // we ensure that from before to\n exclusions.forEach((exclusion) => {\n if (exclusion.from > exclusion.to) {\n [exclusion.to, exclusion.from] = [exclusion.from, exclusion.to];\n }\n });\n\n exclusions.sort((a, b) => a.from - b.from);\n\n // we will rework the exclusions in order to remove overlap and outside range (from / to)\n exclusions.forEach((exclusion) => {\n if (exclusion.from < from) exclusion.from = from;\n if (exclusion.to > to) exclusion.to = to;\n });\n for (let i = 0; i < exclusions.length - 1; i++) {\n if (exclusions[i].to > exclusions[i + 1].from) {\n exclusions[i].to = exclusions[i + 1].from;\n }\n }\n exclusions = exclusions.filter((exclusion) => exclusion.from < exclusion.to);\n\n if (!exclusions || exclusions.length === 0) {\n return [{ from, to }];\n }\n\n let zones = [];\n let currentFrom = from;\n for (let exclusion of exclusions) {\n if (currentFrom < exclusion.from) {\n zones.push({\n from: currentFrom,\n to: exclusion.from\n });\n }\n\n currentFrom = exclusion.to;\n }\n if (currentFrom < to) {\n zones.push({\n from: currentFrom,\n to: to\n });\n }\n\n return zones;\n}\n","import getZones from './getZones';\n\n/**\n * Filter an array x/y based on various criteria\n * x points are expected to be sorted\n *\n * @param {object} points\n * @param {object} [options={}]\n * @param {array} [options.from]\n * @param {array} [options.to]\n * @param {array} [options.exclusions=[]]\n * @return {{x: Array, y: Array}}\n */\n\nexport default function filterX(points, options = {}) {\n const { x, y } = points;\n const { from = x[0], to = x[x.length - 1], exclusions = [] } = options;\n\n let zones = getZones(from, to, exclusions);\n\n\n let currentZoneIndex = 0;\n let newX = [];\n let newY = [];\n let position = 0;\n while (position < x.length) {\n if (\n x[position] <= zones[currentZoneIndex].to &&\n x[position] >= zones[currentZoneIndex].from\n ) {\n newX.push(x[position]);\n newY.push(y[position]);\n } else {\n if (x[position] > zones[currentZoneIndex].to) {\n currentZoneIndex++;\n if (!zones[currentZoneIndex]) break;\n }\n }\n position++;\n }\n\n return {\n x: newX,\n y: newY\n };\n}\n","import { DecisionTreeClassifier, DecisionTreeRegression } from \"ml-cart\";\nimport {\n RandomForestClassifier,\n RandomForestRegression,\n} from \"ml-random-forest\";\n\n// Try to keep this list in the same structure as the README.\n\n// Unsupervised learning\nexport { PCA } from \"ml-pca\";\nimport * as HClust from \"ml-hclust\";\nexport { HClust };\nexport { default as KMeans } from \"ml-kmeans\";\n\n// Supervised learning\nimport * as NaiveBayes from \"ml-naivebayes\";\nexport { NaiveBayes };\nexport { default as KNN } from \"ml-knn\";\nexport { PLS, KOPLS, OPLS, OPLSNipals } from \"ml-pls\";\nimport * as CrossValidation from \"ml-cross-validation\";\nexport { CrossValidation };\nexport { default as ConfusionMatrix } from \"ml-confusion-matrix\";\nexport { DecisionTreeClassifier };\nexport { RandomForestClassifier };\n\n// Artificial neural networks\nexport { default as FNN } from \"ml-fnn\";\nexport { default as SOM } from \"ml-som\";\n\n// Regression\nexport {\n SimpleLinearRegression,\n PolynomialRegression,\n MultivariateLinearRegression,\n PowerRegression,\n ExponentialRegression,\n TheilSenRegression,\n RobustPolynomialRegression,\n} from \"ml-regression\";\nexport { DecisionTreeRegression };\nexport { RandomForestRegression };\n\n// Optimization\nexport { default as levenbergMarquardt } from \"ml-levenberg-marquardt\";\nimport * as FCNNLS from \"ml-fcnnls\";\nexport { FCNNLS };\n\n// Math\nimport * as MatrixLib from \"ml-matrix\";\nconst {\n Matrix,\n SVD,\n EVD,\n CholeskyDecomposition,\n LuDecomposition,\n QrDecomposition,\n} = MatrixLib;\nexport {\n MatrixLib,\n Matrix,\n SVD,\n EVD,\n CholeskyDecomposition,\n LuDecomposition,\n QrDecomposition,\n};\n\nexport { SparseMatrix } from \"ml-sparse-matrix\";\nexport { default as Kernel } from \"ml-kernel\";\nimport { distance, similarity } from \"ml-distance\";\nexport { distance as Distance, similarity as Similarity };\nexport { default as distanceMatrix } from \"ml-distance-matrix\";\nexport { default as XSadd } from \"ml-xsadd\";\nexport { nGMCA } from \"ml-ngmca\";\n\n// Statistics\nexport { default as Performance } from \"ml-performance\";\n\n// Data preprocessing\nexport { default as savitzkyGolay } from \"ml-savitzky-golay\";\n\n// Utility\nexport { default as BitArray } from \"ml-bit-array\";\nexport { default as HashTable } from \"ml-hash-table\";\nexport { default as padArray } from \"ml-pad-array\";\nexport { default as binarySearch } from \"binary-search\";\nimport * as numSort from \"num-sort\";\nexport { numSort };\nexport { default as Random } from \"ml-random\";\nimport * as GSD from 'ml-gsd';\nexport { GSD };\n\nimport min from \"ml-array-min\";\nimport max from \"ml-array-max\";\nimport median from \"ml-array-median\";\nimport mean from \"ml-array-mean\";\nimport mode from \"ml-array-mode\";\nimport normed from \"ml-array-normed\";\nimport rescale from \"ml-array-rescale\";\nimport sequentialFill from \"ml-array-sequential-fill\";\nimport sum from \"ml-array-sum\";\nimport standardDeviation from \"ml-array-standard-deviation\";\nimport variance from \"ml-array-variance\";\nexport const Array = {\n min,\n max,\n median,\n mean,\n mode,\n normed,\n rescale,\n sequentialFill,\n standardDeviation,\n sum,\n variance,\n};\n\nimport centroidsMerge from \"ml-array-xy-centroids-merge\";\nimport closestX from \"ml-arrayxy-closestx\";\nimport covariance from \"ml-array-xy-covariance\";\nimport maxMerge from \"ml-array-xy-max-merge\";\nimport maxY from \"ml-array-xy-max-y\";\nimport sortX from \"ml-array-xy-sort-x\";\nimport uniqueX from \"ml-arrayxy-uniquex\";\nimport weightedMerge from \"ml-array-xy-weighted-merge\";\nimport equallySpaced from \"ml-array-xy-equally-spaced\";\nimport filterX from \"ml-array-xy-filter-x\";\nexport const ArrayXY = {\n centroidsMerge,\n closestX,\n covariance,\n maxMerge,\n maxY,\n sortX,\n uniqueX,\n weightedMerge,\n equallySpaced,\n filterX,\n};\n"],"names":["toString","Object","prototype","isAnyArray","object","call","endsWith","max","input","options","arguments","length","undefined","isArray","TypeError","_options$fromIndex","fromIndex","_options$toIndex","toIndex","Number","isInteger","Error","maxValue","i","min","minValue","rescale","output","Array","currentMin","currentMax","RangeError","_options$min","autoMinMax","_options$max","factor","indent","repeat","indentData","inspectMatrix","inspectMatrixWithOptions","this","matrix","maxRows","maxColumns","maxNumSize","constructor","name","inspectData","rows","columns","maxI","Math","maxJ","result","line","j","push","formatNumber","get","join","num","numStr","String","padEnd","precise","toPrecision","exponential","toExponential","eIndex","indexOf","e","slice","installMathOperations","AbstractMatrix","Matrix","add","value","addS","addM","set","checkMatrix","sub","subS","subM","subtract","subtractS","subtractM","mul","mulS","mulM","multiply","multiplyS","multiplyM","div","divS","divM","divide","divideS","divideM","mod","modS","modM","modulus","modulusS","modulusM","and","andS","andM","or","orS","orM","xor","xorS","xorM","leftShift","leftShiftS","leftShiftM","signPropagatingRightShift","signPropagatingRightShiftS","signPropagatingRightShiftM","rightShift","rightShiftS","rightShiftM","zeroFillRightShift","zeroFillRightShiftS","zeroFillRightShiftM","not","abs","acos","acosh","asin","asinh","atan","atanh","cbrt","ceil","clz32","cos","cosh","exp","expm1","floor","fround","log","log1p","log10","log2","round","sign","sin","sinh","sqrt","tan","tanh","trunc","pow","arg0","powS","powM","checkRowIndex","index","outer","checkColumnIndex","checkRowVector","vector","to1DArray","checkColumnVector","checkIndices","rowIndices","columnIndices","row","checkRowIndices","column","checkColumnIndices","some","r","from","c","checkRange","startRow","endRow","startColumn","endColumn","checkNumber","newArray","array","sumByRow","sum","sumByColumn","sumAll","v","productByRow","productByColumn","productAll","varianceByRow","unbiased","mean","cols","variance","sum1","sum2","x","varianceByColumn","varianceAll","size","centerByRow","centerByColumn","centerAll","getScaleByRow","scale","scaleByRow","getScaleByColumn","scaleByColumn","getScaleAll","divider","scaleAll","newRows","newColumns","newData","newMatrix","fill","random","interval","zeros","data","l","matrix1","matrix2","isMatrix","klass","apply","callback","to2DArray","copy","toJSON","isRowVector","isColumnVector","isVector","isSquare","isSymmetric","isEchelonForm","previousColumn","checked","isReducedEchelonForm","k","echelonForm","clone","h","iMax","swapRows","tmp","reducedEchelonForm","m","n","maxRow","p","pivot","setSubMatrix","neg","getRow","getRowVector","rowVector","setRow","row1","row2","temp","getColumn","getColumnVector","columnVector","setColumn","swapColumns","column1","column2","addRowVector","subRowVector","mulRowVector","divRowVector","addColumnVector","subColumnVector","mulColumnVector","divColumnVector","mulRow","mulColumn","maxIndex","idx","minIndex","maxRowIndex","minRow","minRowIndex","maxColumn","maxColumnIndex","minColumn","minColumnIndex","diag","norm","type","cumulativeSum","dot","vector2","vector1","mmul","other","Bcolj","Float64Array","s","strassen2x2","a11","b11","a12","b12","a21","b21","a22","b22","m1","m2","m3","m4","m5","c00","c01","c10","c11","strassen3x3","a00","a01","a02","a10","a20","b00","b01","b02","b10","b20","m6","m7","m8","m9","m12","m13","m14","m15","m16","m17","m18","c02","c12","c20","c21","c22","mmulStrassen","y","r1","c1","r2","c2","embed","mat","resultat","console","warn","blockMult","a","b","halfRows","parseInt","halfCols","subMatrix","scaleRows","isFinite","scaleColumns","flipRows","middle","first","last","flipColumns","kroneckerProduct","q","transpose","sortRows","compareFunction","compareNumbers","sort","sortColumns","subMatrixRow","indices","subMatrixColumn","selection","rowIndex","columnIndex","trace","by","product","standardDeviation","center","Symbol","for","rand","randomInt","randInt","diagonal","identity","eye","negate","tensorProduct","nRows","nColumns","arrayData","removeRow","splice","addRow","removeColumn","newRow","addColumn","BaseView","MatrixColumnView","MatrixColumnSelectionView","MatrixFlipColumnView","MatrixFlipRowView","MatrixRowView","MatrixRowSelectionView","MatrixSelectionView","MatrixSubView","MatrixTransposeView","WrapperMatrix1D","_calculateIndex","WrapperMatrix2D","wrap","LuDecomposition","t","LUcolj","kmax","lu","pivotVector","pivotSign","LU","isSingular","col","solve","count","X","determinant","hypotenuse","QrDecomposition","qr","rdiag","nrm","QR","Rdiag","isFullRank","SingularValueDecomposition","computeLeftSingularVectors","computeRightSingularVectors","autoTranspose","wantu","Boolean","wantv","swapped","aux","nu","ni","U","V","work","si","nct","nrt","mrc","pp","eps","EPSILON","kase","alpha","MIN_VALUE","isNaN","ks","f","cs","sn","sp","spm1","epm1","sk","ek","shift","g","Y","threshold","scols","Ls","rightSingularVectors","VL","vrows","urows","VLU","solveForDiagonal","inverse","vcols","ucols","tol","ii","useSVD","leftHandSide","rightHandSide","d","subMatrix0","subMatrix1","subMatrix2","xrange","exception","range","dependenciesOneRow","error","thresholdValue","thresholdError","returnArray","linearDependencies","results","Abis","pseudoInverse","svdSolution","SVD","leftSingularVectors","covariance","xMatrix","yMatrix","yIsSame","cov","correlation","sdx","sdy","corr","EigenvalueDecomposition","assumeSymmetric","tred2","tql2","H","ort","orthes","hqr2","hh","dl1","c3","el1","s2","tst1","high","low","nn","w","ra","sa","vr","vi","notlast","cdivres","exshift","z","iter","cdiv","xr","xi","yr","yi","CholeskyDecomposition","dimension","positiveDefinite","L","isPositiveDefinite","B","nipals","scaleScores","maxIterations","terminationCriteria","u","tOld","diff","counter","xResidual","residual","yResidual","betas","sumValue","toDiscreteDistribution","numberOfClasses","counts","giniImpurity","probabilities","getNumberOfClasses","filter","val","arr","map","reduce","giniGain","splitted","splitsImpurity","splits","currentSplit","squaredError","meanArray","currentElement","regressionError","matrixSplitter","lesserX","greaterX","lesserY","greaterY","zip","ret","gainFunctions","gini","Utils","regression","splitFunctions","TreeNode","kind","gainFunction","splitFunction","minNumSamples","maxDepth","bestSplit","XTranspose","bestGain","Infinity","check","currentFeature","splitValues","featureSplit","currentSplitVal","split","gain","maxGain","splitValue","lesser","greater","calculatePrediction","distribution","train","currentDepth","parentGain","splitColumn","splittedMatrix","left","right","classify","setNodeParameters","node","defaultOptions","DecisionTreeClassifier","model","root","Tree","assign","trainingSet","trainingLabels","predict","toPredict","predictions","DecisionTreeRegression","trainingValues","SMALLEST_UNSAFE_INTEGER","LARGEST_SAFE_INTEGER","UINT32_MAX","UINT32_SIZE","INT32_SIZE","INT32_MAX","UINT21_SIZE","UINT21_MAX","checkFloat","examplesBaggingWithReplacement","trainingValue","seed","engine","Random","autoSeed","Xr","featureBagging","replacement","usedIndex","toRet","Set","has","RandomForestBase","maxFeatures","nEstimators","treeOptions","isClassifier","indexes","useSampleBagging","Estimator","DTClassifier","DTRegression","estimators","est","load","res","values","predictionValues","RandomForestClassifier","baseModel","mode","super","pop","_ref","module","exports","window","median","quickSelectMedian","selectionMethods","arrayMean","arrayMedian","selectionMethod","RandomForestRegression","PCA","dataset","means","stdevs","S","R","excludedFeatures","isCovarianceMatrix","method","nCompNIPALS","ignoreZeroVariance","_computeFromCovarianceMatrix","_adjust","covarianceMatrix","_computeWithNIPALS","svd","singularValues","eigenvalues","singularValue","nComponents","invert","getExplainedVariance","getCumulativeVariance","explained","getEigenvectors","getEigenvalues","getStandardDeviations","getLoadings","evd","EVD","eigenvectorMatrix","realEigenvalues","reverse","dc","NIPALS","squaredEuclidean","euclidean","distanceMatrix","distanceFn","getMatrix","Heap","defaultCmp","heapify","heappop","heappush","heappushpop","heapreplace","insort","nlargest","nsmallest","updateItem","_siftdown","_siftup","lo","hi","cmp","mid","concat","item","lastelt","returnitem","_i","_len","_ref1","_results","_results1","_j","pos","elem","los","startpos","newitem","parent","parentpos","childpos","endpos","rightpos","nodes","replace","pushpop","peek","contains","clear","empty","heap","toArray","insert","top","front","require$$0","Cluster","children","height","isLeaf","cut","list","ans","group","groups","forEach","child","traverse","cb","visit","cluster","singleLink","dKI","dKJ","completeLink","averageLink","dIJ","nj","weightedAverageLink","centroidLink","medianLink","wardLink","nk","wardLink2","ai","aj","agnes","distanceFunction","isDistanceMatrix","updateFunc","getDistanceMatrix","numLeaves","toLowerCase","clusters","distance","getSmallestDistance","cluster1","cluster2","newCluster","newClusters","newDistanceMatrix","previous","newIndex","getPreviousIndex","prevI","prevICluster","smallest","smallestI","smallestJ","prev1","prev2","nearestVector","listVectors","similarityFunction","vectorIndex","maxSim","sim","minDist","MAX_VALUE","dist","calculateDistanceMatrix","updateClusterID","centers","clusterID","updateCenters","prevCenters","K","nDim","centersLen","dim","id","hasConverged","oldCenters","tolerance","LOOP","FLOAT_MUL","sh1","sh2","sh3","multiply_uint32","nlo","XSadd","Date","now","state","Uint32Array","init","getFloat","bind","getUint32","nextState","periodCertification","PROB_TOLERANCE","randomChoice","valuesArr","cumSum","getArray","randomIndex","seedOrRandom","xsadd","XSAdd","randomGenerator","choice","randomSample","mostDistant","maxDist","minDistCent","kmeanspp","nSamples","localTrials","firstCenterIdx","closestDistSquared","cumSumClosestDistSquared","candidateIdx","distanceToCandidates","euclideanDistances","bestCandidate","bestPot","bestDistSquared","newDistSquared","newPot","A","distanceSymbol","KMeansResult","centroids","converged","iterations","nearest","centroid","computeInformation","enrichedCentroids","withIterations","initialization","step","newCenters","kmeansGenerator","stepResult","stepNumber","kmeans","separateClasses","features","classes","totalPerClasses","separatedClasses","currentIndex","GaussianNB","reload","calculateProbabilities","C1","PI","std","logPriorProbability","currentStd","getCurrentClass","modelName","currentCase","maxProbability","predictedClass","currentProbability","calculateLogProbability","C2","MultinomialNB","conditionalProbability","priorProbability","separateClass","classValues","divisor","matrixLog","Node","obj","KDTree","points","metric","dimensions","buildTree","restoreParent","toJSONImpl","point","maxNodes","maxDistance","bestNodes","BinaryHeap","nearestSearch","ownDistance","linearPoint","bestChild","linearDistance","otherChild","saveNode","content","src","dest","depth","scoreFunction","element","bubbleUp","end","sinkDown","parentN","elemScore","child2N","child1N","swap","child1","child1Score","child2","KNN","labels","kdTree","isEuclidean","euclideanDistance","getSinglePrediction","knn","nearestPoints","pointsPerClass","maxPoints","lastElement","currentClass","currentPoints","pow2array","initializeMatrices","PLS","meanX","stdDevX","meanY","stdDevY","PBQ","R2X","scaleMethod","latentVectors","rx","cx","ry","cy","ssqXcal","sumOfSquaresY","T","P","Q","W","transposeX","transposeY","tIndex","maxSumColIndex","uIndex","t1","den","pnorm","ssqYcal","E","F","KOPLS","YLoadingMat","SigmaPow","YScoreMat","predScoreMat","YOrthLoadingVec","YOrthEigen","YOrthScoreMat","toNorm","TURegressionCoeff","kernelX","kernel","orthogonalComp","predictiveComp","predictiveComponents","orthogonalComponents","compute","Identity","Sigma","diagonalMatrix","YOrthScoreNorm","TpiPrime","CoTemp","SoTemp","toiPrime","ITo","lastScoreMat","lastTpPrime","KTestTrain","YOrthScoreVector","scoreMatPrime","p1","p2","p3","prediction","predYOrthVectors","ConfusionMatrix","actual","predicted","distinctLabels","actualIdx","predictedIdx","getLabels","getTotalCount","getTrueCount","getFalseCount","getTruePositiveCount","label","getIndex","getTrueNegativeCount","getFalsePositiveCount","getFalseNegativeCount","getPositiveCount","getNegativeCount","getTruePositiveRate","getTrueNegativeRate","getPositivePredictiveValue","TP","getNegativePredictiveValue","TN","getFalseNegativeRate","getFalsePositiveRate","getFalseDiscoveryRate","FP","getFalseOmissionRate","FN","getF1Score","getMatthewsCorrelationCoefficient","getInformedness","getMarkedness","getConfusionTable","getAccuracy","correct","incorrect","getCount","actualIndex","predictedIndex","createCommonjsModule","fn","runtime","global","Op","hasOwn","hasOwnProperty","$Symbol","iteratorSymbol","iterator","asyncIteratorSymbol","asyncIterator","toStringTagSymbol","toStringTag","regeneratorRuntime","GenStateSuspendedStart","GenStateSuspendedYield","GenStateExecuting","GenStateCompleted","ContinueSentinel","IteratorPrototype","getProto","getPrototypeOf","NativeIteratorPrototype","Gp","GeneratorFunctionPrototype","Generator","create","GeneratorFunction","displayName","isGeneratorFunction","genFun","ctor","mark","setPrototypeOf","__proto__","awrap","arg","__await","defineIteratorMethods","AsyncIterator","async","innerFn","outerFn","self","tryLocsList","next","then","done","keys","key","Context","reset","skipTempReset","prev","sent","_sent","delegate","tryEntries","resetTryEntry","charAt","stop","rootRecord","completion","rval","dispatchException","context","handle","loc","caught","record","entry","tryLoc","hasCatch","hasFinally","catchLoc","finallyLoc","abrupt","finallyEntry","complete","afterLoc","finish","thrown","delegateYield","iterable","resultName","nextLoc","protoGenerator","generator","_invoke","makeInvokeMethod","tryCatch","err","invoke","resolve","reject","Promise","unwrapped","previousPromise","enqueue","callInvokeWithMethodAndArg","doneResult","delegateResult","maybeInvokeDelegate","return","info","pushTryEntry","locs","iteratorMethod","Function","hadRuntime","getOwnPropertyNames","oldRuntime","runtimeModule","regenerator","_callee","M","N","twiddle","_context","factory","getFolds","allIdx","current","folds","randi","testIndex","trainIndex","el","idx2","sampleAClass","classVector","fraction","classVectorSorted","JSON","parse","stringify","indexOfSelected","ind","mask","includes","leaveOneOut","Classifier","classifierOptions","leavePOut","distinct","getDistinct","confusionMatrix","initMatrix","gen","combinations","testIdx","trainIdx","validateWithCallback","validate","kFold","testFeatures","trainFeatures","testLabels","trainLabels","getTrainTest","classifier","updateConfusionMatrix","predictedLabels","OPLSNipals","numberOSC","uNew","wOrtho","tOrtho","pOrtho","filteredX","weightsXOrtho","loadingsXOrtho","scoresXOrtho","weightsXPred","loadingsXpred","scoresXpred","loadingsY","tss","OPLS","opls","meansY","stdevsY","tCV","tOrthCV","yHatCV","nComp","cvFolds","from1DArray","Q2","nc","oplsCV","modelNC","yHatk","tPredk","tOrthk","oplsk","fold","trainTest","_getTrainTest","testXk","Xk","Yk","dataCenter","dataSD","plsCV","scores","Eh","tPred","yHat","tssy","Q2y","_predictAll","xRes","XOrth","FeaturesCS","labelsCS","Xres","plsCall","R2x","R2y","plsC","pPred","wPred","betasPred","Qpc","tOrth","pOrth","wOrth","totalPred","Yres","getLogs","getScores","scoresX","scoresY","trueLabels","fromLabels","tssx","oplsC","logistic","expELU","param","softExponential","softExponentialPrime","ACTIVATION_FUNCTIONS","activation","derivate","arctan","softsign","relu","softplus","bent","sinusoid","sinc","gaussian","Layer","inputSize","outputSize","regularization","epsilon","activationParam","selectedFunction","params","actFunction","derFunction","activationFunction","mlMatrix","forward","backpropagation","delta","dW","db","aCopy","update","OutputLayer","FeedForwardNeuralNetworks","hiddenLayers","learningRate","dicts","layers","buildNetwork","dictOutputs","inputs","propagate","outputs","NodeSquare","weights","som","neighbors","adjustWeights","target","influence","getDistance","otherNode","getDistanceTorus","distX","distY","gridDim","getNeighbors","xy","torus","getPos","bestNeighbor","direction","simA","simB","getPosition","NodeHexagonal","hX","distZ","fields","randomizer","squareEuclidean","gridType","SOM","numWeights","converters","getConverters","extractor","creator","nodeType","hx","distanceMethod","getMaxDistance","times","findBMU","adjust","iterationCount","startLearningRate","mapRadius","algorithmMethod","_initNodes","normalizers","denormalizers","getNormalizer","getDenormalizer","minMax","getRandomValue","zero","one","loadModel","eval","export","includeDistance","initNodes","setTraining","convertedSet","numIterations","timeConstant","trainOne","neighbourhoodRadius","trainingSetFactor","bmu","_findBestMatchingUnit","now2","radiusLimit","xMin","xMax","yMin","yMax","theX","theY","getConvertedNodes","candidate","lowest","computePosition","_predict","getQuantizationError","fit","getFit","maybeToPrecision","digits","checkArraySize","BaseRegression","toLaTeX","score","y2","xSum","ySum","chi2","rmsd","xSquared","ySquared","xY","PolynomialRegression","degree","powers","coefficients","checkArrayLength","regress","precision","_toFormula","isLaTeX","sup","closeSup","str","json","pr","FT","SimpleLinearRegression","slope","intercept","computeX","xFactor","absIntercept","slr","numerator","ExponentialRegression","er","yl","linear","PowerRegression","newInputs","latex","xl","MultivariateLinearRegression","statistics","xt","xx","invxx","beta","fittedValues","ri","stdError","stdErrorMatrix","stdErrors","tStats","summary","regressionStatistics","standardError","observations","variables","tStat","sigma","GaussianKernel","constant","PolynomialKernel","SigmoidKernel","ANOVAKernel","len","CauchyKernel","ExponentialKernel","HistogramIntersectionKernel","LaplacianKernel","MultiquadraticKernel","RationalQuadraticKernel","kernelType","rbf","polynomial","poly","anova","cauchy","histogram","HistogramKernel","laplacian","multiquadratic","rational","RationalKernel","sigmoid","mlp","Kernel","KernelConstructor","kernelFunction","landmarks","kernelMatrix","TheilSenRegression","theilSen","slopes","medianSlope","cuts","RobustPolynomialRegression","robustPolynomial","_","tuples","getRandomTuples","calcCoefficients","residuals","residualsMedian","tuple","half","errorCalculation","parameters","parameterizedFunction","func","gradientFunction","evaluatedData","gradientDifference","paramFunction","auxParams","funcParam","matrixFunction","damping","gradientFunc","matrixFunc","inverseMatrix","levenbergMarquardt","errorTolerance","minValues","maxValues","initialValues","parLen","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","iteration","parameterValues","parameterError","sortCollectionSet","collection","objectCollection","BigInt","sorted","cssls","XtX","XtY","Pset","choXtX","luXtX","sortedPset","sortedEset","cols2Solve","vars","initialisation","Fset","D","setDifference","C","optimality","maxIter","Jset","fullSet","notPset","fcnnls","infeasIndex","Hset","ones","hRowColIdx","negRowColIdx","alphaMin","minIdx","idx2zero","findIndex","newParam","fcnnlsVector","haystack","needle","comparator","assertNumber","number","largestPrime","primeNumbers","nextPrime","binarySearch","ascending","FREE","FULL","REMOVED","defaultInitialCapacity","defaultMinLoadFactor","defaultMaxLoadFactor","HashTable","table","minLoadFactor","maxLoadFactor","freeEntries","lowWaterMark","highWaterMark","initialCapacity","capacity","chooseHighWaterMark","indexOfKey","indexOfInsertion","newCapacity","chooseGrowCapacity","rehash","remove","noRehash","maybeShrinkCapacity","delete","chooseShrinkCapacity","containsKey","hash","decrement","containsValue","indexOfValue","ensureCapacity","minCapacity","oldCapacity","oldTable","oldValues","oldState","newTable","newValues","newState","chooseLowWaterMark","forEachKey","forEachValue","forEachPair","minLoad","maxLoad","SparseMatrix","_init","elements","symmetric","forEachNonZero","bandWidth","isBanded","width","v1","v2","cardinality","getNonZeros","setThreshold","newThreshold","trans","inplaceOperator","inplaceOperatorScalar","inplaceOperatorMatrix","staticOperator","inplaceMethod","staticMethod","operators","operator","fillTemplateFunction","op","methods","mathMethod","template","RegExp","additiveSymmetric","avg","bhattacharyya","canberra","chebyshev","clark","czekanowskiSimilarity","up","down","czekanowskiDistance","dice","q1","q2","divergence","fidelity","gower","harmonicMean","hellinger","innerProduct","intersection","jaccard","jeffreys","jensenDifference","jensenShannon","kdivergence","kulczynski","kullbackLeibler","kumarHassebrook","kumarJohnson","lorentzian","manhattan","matusita","minkowski","motyka","neyman","pearson","probabilisticSymmetric","ruzicka","soergel","sorensen","squared","squaredChord","taneja","tanimoto","bitvector","inter","union","tanimotoS","topsoe","waveHedges","createTree","spectrum","minWindow","to","mainCreateTree","start","getSimilarity","gamma","treeSimilarity","getFunction","cosine","diceD","intersectionD","jaccardD","kulczynskiD","motykaD","avgA","avgB","newA","newB","squaredChordD","zeroInsteadOfNegative","checkMatrixS","originalMatrix","fastExtractNMF","res2","sqrtMaxValue","subtracting","normBy","norms","normProj","normLimits","updateMatrixA","Ainit","proximal","maxFBIteration","toleranceFB","normConstrained","lambda","St","YSt","prevA","tNext","getMax","updateMatrixS","Sinit","At","AtY","prevS","initialize","rank","randGenerator","maxInitFBIteration","toleranceFBInit","sumC","sumR","positiveSumRowIndexS","positiveSumRowS","candidateA","colCandidate","normalize","normOnA","onS","onA","DS","DA","sColumns","aRows","valueForS","valueForA","getMedians","medians","dimMADstd","updateLambda","sigmaResidue","refinementBeginning","tauMAD","lambdaInf","addStd","alY","nGMCA","maximumIteration","phaseRatio","useTranspose","pred","cutoffs","tn","tp","fp","nNeg","nPos","nPosPred","nNegPred","Performance","isDistance","predP","all","targ","currentPred","nTp","nFp","getMeasure","measure","measures","getAURC","auc","getAUDC","getDistribution","cutLength","cutLow","cutHigh","xLabels","interValues","intraValues","interCumPercent","intraCumPercent","nTP","currentTP","nFP","currentFP","thisTP","thisFP","names","acc","fpr","tpr","fnr","tnr","ppv","npv","pcfall","pcmiss","lift","rpp","rnp","arrayCase","cond","matrixCase","padArray","factorial","windowSize","derivative","pad","padValue","savitzkyGolay","J","inic","Jtranspose","det","eightBits","arr1","arr2","getBit","setBit","toBinaryString","substr","parseBinaryString","toHexString","parseHexString","toDebug","binary","SavitzkyGolay","np","fullWeights","hs","constantH","wg1","wg2","d1","d2","getHs","wg","GramPoly","Grampoly","GenFact","gf","Weight","gsd","yIn","noiseLevel","sgOptions","smoothY","heightFactor","broadRatio","maxCriteria","minMaxRatio","derivativeThreshold","realTopDetection","equalSpaced","isEqualSpaced","getNoiseLevel","yCorrection","dY","ddY","yData","SG","xData","dX","maxDdy","maxY","lastMax","lastMin","minddY","intervalL","intervalR","broadMask","minddYLen","intervalLLen","intervalRLen","broadMaskLen","possible","frequency","distanceJ","minDistance","gettingCloser","signals","signalsLen","lastK","soft","yLeft","yRight","determineRealTop","base","maxDx","minDx","stddev","averageDeviations","peakList","currentPoint","sumOfGaussians","nL","optimizeGaussianSum","opts","pInit","pMin","pMax","dt","lmOptions","pFit","LM","singleGaussian","factor2","optimizeSingleGaussian","peak","sumOfLorentzians","optimizeLorentzianSum","singleLorentzian","optimizeSingleLorentzian","optimizePeaks","functionName","factorWidth","optimizationOptions","sampling","lastIndex","groupPeaks","peaks","sampleFunction","limits","optPeaks","fitResult","nbPoints","sampleX","sampleY","upperLimit","lowerLimit","joinBroadPeaks","broadLines","candidates","fitted","broadenPeaks","overlap","nextPeak","maxCount","_options$algorithm","algorithm","_options$sumValue","_options$maxValue","absoluteSumValue","absoluteSum","currentMaxValue","sumFactor","_i2","_typeof","sequentialFill","_options","_options$from","_options$to","_options$size","_options$unbiased","_options$mean","sqrError","mergeByCentroids","originalPoints","mergedPoints","originalIndex","mergedIndex","closestX","descending","maxMerge","groupWidth","merged","maxAbscissa","calculateIndex","sortX","sortFunc","grouped","response","uniqueX","weightedMerge","weightedAbscissa","zones","NEGATIVE_INFINITY","POSITIVE_INFINITY","zone","currentZone","exclusions","exclusion","nextExclusion","zonesWithPoints","numberOfPoints","unitsPerPoint","currentTotal","integral","x0","x1","equallySpacedSmooth","xLength","halfStep","initialOriginalStep","lastOriginalStep","previousX","previousY","nextX","nextY","currentValue","sumAtMin","sumAtMax","main","equallySpacedSlot","lastStep","frontOutsideSpectra","backOutsideSpectra","equallySpaced","arrayXY","variant","xResult","yResult","zoneResult","processZone","getZones","currentFrom","filterX","currentZoneIndex","newX","newY","position","MatrixLib","normed","ArrayXY","centroidsMerge"],"mappings":"gPAAA,MAAMA,SAAWC,OAAOC,UAAUF,SAEnB,SAASG,WAAWC,UAC1BJ,SAASK,KAAKD,GAAQE,SAAS,UCDxC,SAASC,IAAIC,OACPC,EAAUC,UAAUC,OAAS,QAAsBC,IAAjBF,UAAU,GAAmBA,UAAU,GAAK,OAE7EG,WAAQL,SACL,IAAIM,UAAU,6BAGD,IAAjBN,EAAMG,aACF,IAAIG,UAAU,+BAGlBC,EAAqBN,E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AM,IAAIoB,WAAW,4BAGnBqgB,GAAOD,OAMXgO,GAAOg5B,EAAWF,EADlB74B,EAAMhO,GAAQD,EAAOC,IAAS,IACG8mC,EAAQ94B,EAAK64B,IAGrC,EACP7mC,EAAOgO,EAAM,MAGV,CAAA,KAAGD,EAAM,GAKZ,OAAOC,EAJPjO,EAAOiO,EAAM,SAQThO,GCzCV,SAASgnC,aAAaC,MACC,iBAAXA,QACJ,IAAIvoD,UAAU,qBAItB,cAAoB,CAACsnB,EAAMC,KAC1B+gC,aAAahhC,GACbghC,aAAa/gC,GAETlnB,OAAOwc,MAAMyK,IACR,EAGLjnB,OAAOwc,MAAM0K,GACT,EAGDD,EAAOC,cAGM,CAACD,EAAMC,KAC3B+gC,aAAahhC,GACbghC,aAAa/gC,GAETlnB,OAAOwc,MAAMyK,GACT,EAGJjnB,OAAOwc,MAAM0K,IACR,EAGFA,EAAQD,qLChCT,MAAMkhC,aAAe,WAEtBC,aAAe,CAEnBD,aAGA,EACA,GACA,GACA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,WAGA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,WAGA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,WACA,WAGA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,IACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,EACA,EACA,GACA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,WAGA,GACA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,GACA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,WAGA,GACA,IACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,YAKK,SAASE,UAAU3kD,OACpBoF,EAAQw/C,aAAaF,aAAc1kD,EAAO6kD,kBAC1Cz/C,EAAQ,IACVA,GAASA,GAEJs/C,aAAat/C,GAPtBs/C,aAAaxxC,KAAK2xC,WCtWlB,MAAMC,KAAO,EACPC,KAAO,EACPC,QAAU,EAEVC,uBAAyB,IACzBC,qBAAuB,EAAI,EAC3BC,qBAAuB,EAAI,EAElB,MAAMC,UACnBnnD,YAAYrC,EA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AQ58B,EAAU,UAC1CiM,EAAEA,EAAFsJ,EAAKA,GAAMqnB,GACXpyB,KAAEA,EAAOyB,EAAE,GAAXilD,GAAeA,EAAKjlD,EAAEA,EAAE/L,OAAS,GAAjCwkE,WAAqCA,EAAa,IAAO1kE,MAE3DqkE,EAAQuC,SAASp8D,EAAM0mD,EAAIwT,GAG3BqC,EAAmB,EACnBC,EAAO,GACPC,EAAO,GACPC,EAAW,OACRA,EAAWj7D,EAAE/L,QAAQ,IAExB+L,EAAEi7D,IAAa7C,EAAM0C,GAAkB7V,IACvCjlD,EAAEi7D,IAAa7C,EAAM0C,GAAkBv8D,KAEvCw8D,EAAKhkE,KAAKiJ,EAAEi7D,IACZD,EAAKjkE,KAAKuS,EAAE2xD,YAERj7D,EAAEi7D,GAAY7C,EAAM0C,GAAkB7V,KACxC6V,KACK1C,EAAM0C,IAAmB,MAGlCG,UAGK,CACLj7D,EAAG+6D,EACHzxD,EAAG0xD,gBCOL/iE,SADI+b,IAEJA,IAFI+N,IAGJA,0BACApL,wCACAxI,kCACAe,mBACEgsD,UA+CShmE,QAAQ,KACnBJ,UACAjB,MACA8rB,OAAAA,OACAhgB,KAAAA,UACAyf,cACA+7C,OACAnmE,QAAAA,QACAyhE,eAAAA,eACAzqD,kBAAAA,kBACA9M,IAAAA,IACAW,SAAAA,UAaWu7D,QAAU,gBACrBC,iBACA/D,SAAAA,oBACApjD,aACAsjD,SAAAA,SACAnG,KAAAA,KACAwG,MAAAA,MACAI,QAAAA,QACAC,cAAAA,cACAkC,cAAAA,cACAS,QAAAA"} \ No newline at end of file diff --git a/package.json b/package.json index 4954e60..ecf10ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ml", - "version": "5.2.0", + "version": "5.3.0", "description": "Machine learning tools", "main": "src/index.js", "scripts": {