From 28220fcca3718ab1e4ef53242548f1b91144afc3 Mon Sep 17 00:00:00 2001 From: cheminfo bot Date: Sat, 19 Oct 2019 12:04:02 +0000 Subject: [PATCH] Release v5.1.1 --- bower.json | 2 +- dist/ml.js | 185 ++++++++++++++++++++++++--------------------- dist/ml.js.map | 2 +- dist/ml.min.js | 4 +- dist/ml.min.js.map | 2 +- package.json | 2 +- 6 files changed, 103 insertions(+), 94 deletions(-) diff --git a/bower.json b/bower.json index 0ed63d8..b604599 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "ml", - "version": "5.1.0", + "version": "5.1.1", "main": [ "dist/ml.js", "dist/ml.min.js" diff --git a/dist/ml.js b/dist/ml.js index 3ebe2c9..ccd022b 100644 --- a/dist/ml.js +++ b/dist/ml.js @@ -1,6 +1,6 @@ /** * ml - Machine learning tools - * @version v5.1.0 + * @version v5.1.1 * @link https://github.com/mljs/ml * @license MIT */ @@ -5663,9 +5663,9 @@ */ function toDiscreteDistribution(array, numberOfClasses) { - var counts = new Array(numberOfClasses).fill(0); + let counts = new Array(numberOfClasses).fill(0); - for (var i = 0; i < array.length; ++i) { + for (let i = 0; i < array.length; ++i) { counts[array[i]] += 1 / array.length; } @@ -5683,10 +5683,10 @@ return 0; } - var probabilities = toDiscreteDistribution(array, getNumberOfClasses(array)).getRow(0); - var sum = 0.0; + let probabilities = toDiscreteDistribution(array, getNumberOfClasses(array)).getRow(0); + let sum = 0.0; - for (var i = 0; i < probabilities.length; ++i) { + for (let i = 0; i < probabilities.length; ++i) { sum += probabilities[i] * probabilities[i]; } @@ -5702,22 +5702,22 @@ function getNumberOfClasses(array) { return array.filter(function (val, i, arr) { return arr.indexOf(val) === i; - }).length; + }).map(val => val + 1).reduce((a, b) => Math.max(a, b)); } /** * @private * Calculates the Gini Gain of an array of predictions and those predictions splitted by a feature. - * @para {Array} array - Predictions + * @param {Array} array - Predictions * @param {object} splitted - Object with elements "greater" and "lesser" that contains an array of predictions splitted. * @return {number} - Gini Gain. */ function giniGain(array, splitted) { - var splitsImpurity = 0.0; - var splits = ['greater', 'lesser']; + let splitsImpurity = 0.0; + let splits = ['greater', 'lesser']; - for (var i = 0; i < splits.length; ++i) { - var currentSplit = splitted[splits[i]]; + for (let i = 0; i < splits.length; ++i) { + let currentSplit = splitted[splits[i]]; splitsImpurity += giniImpurity(currentSplit) * currentSplit.length / array.length; } @@ -5731,16 +5731,16 @@ */ function squaredError(array) { - var l = array.length; - var m = mean(array); - var squaredError = 0.0; + let l = array.length; + let m = mean(array); + let error = 0.0; - for (var i = 0; i < l; ++i) { - var currentElement = array[i]; - squaredError += (currentElement - m) * (currentElement - m); + for (let i = 0; i < l; ++i) { + let currentElement = array[i]; + error += (currentElement - m) * (currentElement - m); } - return squaredError; + return error; } /** * @private @@ -5751,11 +5751,11 @@ */ function regressionError(array, splitted) { - var error = 0.0; - var splits = ['greater', 'lesser']; + let error = 0.0; + let splits = ['greater', 'lesser']; - for (var i = 0; i < splits.length; ++i) { - var currentSplit = splitted[splits[i]]; + for (let i = 0; i < splits.length; ++i) { + let currentSplit = splitted[splits[i]]; error += squaredError(currentSplit); } @@ -5772,12 +5772,12 @@ */ function matrixSplitter(X, y, column, value) { - var lesserX = []; - var greaterX = []; - var lesserY = []; - var greaterY = []; + let lesserX = []; + let greaterX = []; + let lesserY = []; + let greaterY = []; - for (var i = 0; i < X.rows; ++i) { + for (let i = 0; i < X.rows; ++i) { if (X.get(i, column) < value) { lesserX.push(X.getRow(i)); lesserY.push(y[i]); @@ -5818,9 +5818,9 @@ throw new TypeError("Error on zip: the size of a: ".concat(a.length, " is different from b: ").concat(b.length)); } - var ret = new Array(a.length); + let ret = new Array(a.length); - for (var i = 0; i < a.length; ++i) { + for (let i = 0; i < a.length; ++i) { ret[i] = [a[i], b[i]]; } @@ -5861,19 +5861,19 @@ bestSplit(XTranspose, y) { // Depending in the node tree class, we set the variables to check information gain (to classify) // or error (for regression) - var bestGain = this.kind === 'classifier' ? -Infinity : Infinity; - var check = this.kind === 'classifier' ? (a, b) => a > b : (a, b) => a < b; - var maxColumn; - var maxValue; + let bestGain = this.kind === 'classifier' ? -Infinity : Infinity; + let check = this.kind === 'classifier' ? (a, b) => a > b : (a, b) => a < b; + let maxColumn; + let maxValue; - for (var i = 0; i < XTranspose.rows; ++i) { - var currentFeature = XTranspose.getRow(i); - var splitValues = this.featureSplit(currentFeature, y); + for (let i = 0; i < XTranspose.rows; ++i) { + let currentFeature = XTranspose.getRow(i); + let splitValues = this.featureSplit(currentFeature, y); - for (var j = 0; j < splitValues.length; ++j) { - var currentSplitVal = splitValues[j]; - var splitted = this.split(currentFeature, y, currentSplitVal); - var gain = gainFunctions[this.gainFunction](y, splitted); + for (let j = 0; j < splitValues.length; ++j) { + let currentSplitVal = splitValues[j]; + let splitted = this.split(currentFeature, y, currentSplitVal); + let gain = gainFunctions[this.gainFunction](y, splitted); if (check(gain, bestGain)) { maxColumn = i; @@ -5900,10 +5900,10 @@ split(x, y, splitValue) { - var lesser = []; - var greater = []; + let lesser = []; + let greater = []; - for (var i = 0; i < x.length; ++i) { + for (let i = 0; i < x.length; ++i) { if (x[i] < splitValue) { lesser.push(y[i]); } else { @@ -5926,13 +5926,13 @@ featureSplit(x, y) { - var splitValues = []; - var arr = zip(x, y); + let splitValues = []; + let arr = zip(x, y); arr.sort(function (a, b) { return a[0] - b[0]; }); - for (var i = 1; i < arr.length; ++i) { + for (let i = 1; i < arr.length; ++i) { if (arr[i - 1][1] !== arr[i][1]) { splitValues.push(splitFunctions[this.splitFunction](arr[i - 1][0], arr[i][0])); } @@ -5977,18 +5977,18 @@ } if (parentGain === undefined) parentGain = 0.0; - var XTranspose = X.transpose(); - var split = this.bestSplit(XTranspose, y); + let XTranspose = X.transpose(); + let split = this.bestSplit(XTranspose, y); this.splitValue = split.maxValue; this.splitColumn = split.maxColumn; this.gain = split.maxGain; - var splittedMatrix = matrixSplitter(X, y, this.splitColumn, this.splitValue); + let splittedMatrix = matrixSplitter(X, y, this.splitColumn, this.splitValue); if (currentDepth < this.maxDepth && this.gain > 0.01 && this.gain !== parentGain && splittedMatrix.lesserX.length > 0 && splittedMatrix.greaterX.length > 0) { this.left = new TreeNode(this); this.right = new TreeNode(this); - var lesserX = new Matrix(splittedMatrix.lesserX); - var greaterX = new Matrix(splittedMatrix.greaterX); + let lesserX = new Matrix(splittedMatrix.lesserX); + let greaterX = new Matrix(splittedMatrix.greaterX); this.left.train(lesserX, splittedMatrix.lesserY, currentDepth + 1, this.gain); this.right.train(greaterX, splittedMatrix.greaterY, currentDepth + 1, this.gain); } else { @@ -6094,9 +6094,9 @@ predict(toPredict) { toPredict = Matrix.checkMatrix(toPredict); - var predictions = new Array(toPredict.rows); + let predictions = new Array(toPredict.rows); - for (var i = 0; i < toPredict.rows; ++i) { + for (let i = 0; i < toPredict.rows; ++i) { predictions[i] = this.root.classify(toPredict.getRow(i)).maxRowIndex(0)[1]; } @@ -6189,9 +6189,9 @@ } toPredict = Matrix.checkMatrix(toPredict); - var predictions = new Array(toPredict.rows); + let predictions = new Array(toPredict.rows); - for (var i = 0; i < toPredict.rows; ++i) { + for (let i = 0; i < toPredict.rows; ++i) { predictions[i] = this.root.classify(toPredict.getRow(i)); } @@ -6775,8 +6775,8 @@ */ function examplesBaggingWithReplacement(trainingSet, trainingValue, seed) { - var engine; - var distribution = integer(0, trainingSet.rows - 1); + let engine; + let distribution = integer(0, trainingSet.rows - 1); if (seed === undefined) { engine = MersenneTwister19937.autoSeed(); @@ -6786,11 +6786,11 @@ throw new RangeError("Expected seed must be undefined or integer not ".concat(seed)); } - var Xr = new Array(trainingSet.rows); - var yr = new Array(trainingSet.rows); + let Xr = new Array(trainingSet.rows); + let yr = new Array(trainingSet.rows); - for (var i = 0; i < trainingSet.rows; ++i) { - var index = distribution(engine); + for (let i = 0; i < trainingSet.rows; ++i) { + let index = distribution(engine); Xr[i] = trainingSet.getRow(index); yr[i] = trainingValue[index]; } @@ -6815,8 +6815,8 @@ throw new RangeError('N should be less or equal to the number of columns of X'); } - var distribution = integer(0, trainingSet.columns - 1); - var engine; + let distribution = integer(0, trainingSet.columns - 1); + let engine; if (seed === undefined) { engine = MersenneTwister19937.autoSeed(); @@ -6826,13 +6826,15 @@ throw new RangeError("Expected seed must be undefined or integer not ".concat(seed)); } - var toRet = new Matrix(trainingSet.rows, n); + let toRet = new Matrix(trainingSet.rows, n); + let usedIndex; + let index; if (replacement) { - var usedIndex = new Array(n); + usedIndex = new Array(n); - for (var i = 0; i < n; ++i) { - var index = distribution(engine); + for (let i = 0; i < n; ++i) { + index = distribution(engine); usedIndex[i] = index; toRet.setColumn(i, trainingSet.getColumn(index)); } @@ -6840,7 +6842,7 @@ usedIndex = new Set(); index = distribution(engine); - for (i = 0; i < n; ++i) { + for (let i = 0; i < n; ++i) { while (usedIndex.has(index)) { index = distribution(engine); } @@ -6889,7 +6891,7 @@ this.n = model.n; this.indexes = model.indexes; this.useSampleBagging = model.useSampleBagging; - var Estimator = this.isClassifier ? DecisionTreeClassifier : DecisionTreeRegression; + let Estimator = this.isClassifier ? DecisionTreeClassifier : DecisionTreeRegression; this.estimators = model.estimators.map(est => Estimator.load(est)); } else { this.replacement = options.replacement; @@ -6924,8 +6926,10 @@ throw new RangeError("Cannot process the maxFeatures parameter ".concat(this.maxFeatures)); } + let Estimator; + if (this.isClassifier) { - var Estimator = DecisionTreeClassifier; + Estimator = DecisionTreeClassifier; } else { Estimator = DecisionTreeRegression; } @@ -6933,13 +6937,13 @@ this.estimators = new Array(this.nEstimators); this.indexes = new Array(this.nEstimators); - for (var i = 0; i < this.nEstimators; ++i) { - var res = this.useSampleBagging ? examplesBaggingWithReplacement(trainingSet, trainingValues, this.seed) : { + for (let i = 0; i < this.nEstimators; ++i) { + let res = this.useSampleBagging ? examplesBaggingWithReplacement(trainingSet, trainingValues, this.seed) : { X: trainingSet, y: trainingValues }; - var X = res.X; - var y = res.y; + let X = res.X; + let y = res.y; res = featureBagging(X, this.n, this.replacement, this.seed); X = res.X; this.indexes[i] = res.usedIndex; @@ -6969,19 +6973,19 @@ predict(toPredict) { - var predictionValues = new Array(this.nEstimators); + let predictionValues = new Array(this.nEstimators); toPredict = Matrix.checkMatrix(toPredict); - for (var i = 0; i < this.nEstimators; ++i) { - var X = new MatrixColumnSelectionView(toPredict, this.indexes[i]); // get features for estimator + for (let i = 0; i < this.nEstimators; ++i) { + let X = new MatrixColumnSelectionView(toPredict, this.indexes[i]); // get features for estimator predictionValues[i] = this.estimators[i].predict(X); } predictionValues = new MatrixTransposeView(new WrapperMatrix2D(predictionValues)); - var predictions = new Array(predictionValues.rows); + let predictions = new Array(predictionValues.rows); - for (i = 0; i < predictionValues.rows; ++i) { + for (let i = 0; i < predictionValues.rows; ++i) { predictions[i] = this.selection(predictionValues.getRow(i)); } @@ -7063,7 +7067,7 @@ toJSON() { - var baseModel = super.toJSON(); + let baseModel = super.toJSON(); return { baseModel: baseModel, name: 'RFClassifier' @@ -7219,7 +7223,7 @@ toJSON() { - var baseModel = super.toJSON(); + let baseModel = super.toJSON(); return { baseModel: baseModel, selectionMethod: this.selectionMethod, @@ -7248,8 +7252,8 @@ * @param {Matrix} dataset - dataset or covariance matrix. * @param {Object} [options] * @param {boolean} [options.isCovarianceMatrix=false] - true if the dataset is a covariance matrix. - * @param {boolean} [options.method='SVD'] - select which method to use: SVD (default), covarianceMatrirx or NIPALS. - * @param {boolean} [options.nCompNIPALS=2] - number of components to be computed with NIPALS. + * @param {string} [options.method='SVD'] - select which method to use: SVD (default), covarianceMatrirx or NIPALS. + * @param {number} [options.nCompNIPALS=2] - number of components to be computed with NIPALS. * @param {boolean} [options.center=true] - should the data be centered (subtract the mean). * @param {boolean} [options.scale=false] - should the data be scaled (divide by the standard deviation). * @param {boolean} [options.ignoreZeroVariance=false] - ignore columns with zero variance if `scale` is `true`. @@ -7268,7 +7272,7 @@ this.U = Matrix.checkMatrix(model.U); this.S = model.S; this.R = model.R; - this.excludedFeatures = model.excludedFeatures; + this.excludedFeatures = model.excludedFeatures || []; return; } @@ -7488,7 +7492,8 @@ means: this.means, stdevs: this.stdevs, U: this.U, - S: this.S + S: this.S, + excludedFeatures: this.excludedFeatures }; } @@ -17196,14 +17201,18 @@ throw new RangeError("'numberOfPoints' option must be a number"); } + if (numberOfPoints < 2) { + throw new RangeError("'numberOfPoints' option must be greater than 1"); + } + let zones = getZones(from, to, numberOfPoints, exclusions); let xResult = []; let yResult = []; for (let zone of zones) { let zoneResult = processZone(x, y, zone.from, zone.to, zone.numberOfPoints, variant); - xResult.push(...zoneResult.x); - yResult.push(...zoneResult.y); + xResult = xResult.concat(zoneResult.x); + yResult = yResult.concat(zoneResult.y); } if (reverse) { diff --git a/dist/ml.js.map b/dist/ml.js.map index 9ace1b7..fab0bc2 100644 --- a/dist/ml.js.map +++ b/dist/ml.js.map @@ -1 +1 @@ -{"version":3,"file":"ml.js","sources":["../node_modules/is-any-array/src/index.js","../node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-rescale/lib-es6/index.js","../node_modules/ml-matrix/src/util.js","../node_modules/ml-matrix/src/stat.js","../node_modules/ml-matrix/src/inspect.js","../node_modules/ml-matrix/src/mathOperations.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/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/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/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/src/index.js","../node_modules/ml-cross-validation/src/index.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/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-array-mode/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/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-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/getZones.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":["'use strict';\n\nconst toString = Object.prototype.toString;\n\nfunction isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n\nmodule.exports = isAnyArray;\n","import isArray from 'is-any-array';\n\n/**\n * Computes the maximum of the given values\n * @param {Array} input\n * @return {number}\n */\n\nfunction max(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 = input[0];\n\n for (var i = 1; i < input.length; 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\n/**\n * Computes the minimum of the given values\n * @param {Array} input\n * @return {number}\n */\n\nfunction min(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 minValue = input[0];\n\n for (var i = 1; i < input.length; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import max from 'ml-array-max';\nimport min from 'ml-array-min';\nimport isArray from 'is-any-array';\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","/**\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","export function inspectMatrix() {\n const indent = ' '.repeat(2);\n const indentData = ' '.repeat(4);\n return `${this.constructor.name} {\n${indent}[\n${indentData}${inspectData(this, indentData)}\n${indent}]\n${indent}rows: ${this.rows}\n${indent}columns: ${this.columns}\n}`;\n}\n\nconst maxRows = 15;\nconst maxColumns = 10;\nconst maxNumSize = 8;\n\nfunction inspectData(matrix, indent) {\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)));\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${indent}`);\n}\n\nfunction formatNumber(num) {\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.substring(eIndex);\n return exponential.substring(0, maxNumSize - e.length) + e;\n}\n","export function installMathOperations(AbstractMatrix, Matrix) {\n AbstractMatrix.prototype.add = function add(value) {\n if (typeof value === 'number') return this.addS(value);\n return this.addM(value);\n };\n\n AbstractMatrix.prototype.addS = function addS(value) {\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) + value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.addM = function addM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) + matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.add = function add(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.add(value);\n };\n\n AbstractMatrix.prototype.sub = function sub(value) {\n if (typeof value === 'number') return this.subS(value);\n return this.subM(value);\n };\n\n AbstractMatrix.prototype.subS = function subS(value) {\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) - value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.subM = function subM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) - matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.sub = function sub(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sub(value);\n };\n AbstractMatrix.prototype.subtract = AbstractMatrix.prototype.sub;\n AbstractMatrix.prototype.subtractS = AbstractMatrix.prototype.subS;\n AbstractMatrix.prototype.subtractM = AbstractMatrix.prototype.subM;\n AbstractMatrix.subtract = AbstractMatrix.sub;\n\n AbstractMatrix.prototype.mul = function mul(value) {\n if (typeof value === 'number') return this.mulS(value);\n return this.mulM(value);\n };\n\n AbstractMatrix.prototype.mulS = function mulS(value) {\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) * value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.mulM = function mulM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) * matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.mul = function mul(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.mul(value);\n };\n AbstractMatrix.prototype.multiply = AbstractMatrix.prototype.mul;\n AbstractMatrix.prototype.multiplyS = AbstractMatrix.prototype.mulS;\n AbstractMatrix.prototype.multiplyM = AbstractMatrix.prototype.mulM;\n AbstractMatrix.multiply = AbstractMatrix.mul;\n\n AbstractMatrix.prototype.div = function div(value) {\n if (typeof value === 'number') return this.divS(value);\n return this.divM(value);\n };\n\n AbstractMatrix.prototype.divS = function divS(value) {\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) / value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.divM = function divM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) / matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.div = function div(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.div(value);\n };\n AbstractMatrix.prototype.divide = AbstractMatrix.prototype.div;\n AbstractMatrix.prototype.divideS = AbstractMatrix.prototype.divS;\n AbstractMatrix.prototype.divideM = AbstractMatrix.prototype.divM;\n AbstractMatrix.divide = AbstractMatrix.div;\n\n AbstractMatrix.prototype.mod = function mod(value) {\n if (typeof value === 'number') return this.modS(value);\n return this.modM(value);\n };\n\n AbstractMatrix.prototype.modS = function modS(value) {\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) % value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.modM = function modM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) % matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.mod = function mod(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.mod(value);\n };\n AbstractMatrix.prototype.modulus = AbstractMatrix.prototype.mod;\n AbstractMatrix.prototype.modulusS = AbstractMatrix.prototype.modS;\n AbstractMatrix.prototype.modulusM = AbstractMatrix.prototype.modM;\n AbstractMatrix.modulus = AbstractMatrix.mod;\n\n AbstractMatrix.prototype.and = function and(value) {\n if (typeof value === 'number') return this.andS(value);\n return this.andM(value);\n };\n\n AbstractMatrix.prototype.andS = function andS(value) {\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) & value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.andM = function andM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) & matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.and = function and(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.and(value);\n };\n\n AbstractMatrix.prototype.or = function or(value) {\n if (typeof value === 'number') return this.orS(value);\n return this.orM(value);\n };\n\n AbstractMatrix.prototype.orS = function orS(value) {\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) | value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.orM = function orM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) | matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.or = function or(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.or(value);\n };\n\n AbstractMatrix.prototype.xor = function xor(value) {\n if (typeof value === 'number') return this.xorS(value);\n return this.xorM(value);\n };\n\n AbstractMatrix.prototype.xorS = function xorS(value) {\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) ^ value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.xorM = function xorM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) ^ matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.xor = function xor(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.xor(value);\n };\n\n AbstractMatrix.prototype.leftShift = function leftShift(value) {\n if (typeof value === 'number') return this.leftShiftS(value);\n return this.leftShiftM(value);\n };\n\n AbstractMatrix.prototype.leftShiftS = function leftShiftS(value) {\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) << value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.leftShiftM = function leftShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) << matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.leftShift = function leftShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.leftShift(value);\n };\n\n AbstractMatrix.prototype.signPropagatingRightShift = function signPropagatingRightShift(value) {\n if (typeof value === 'number') return this.signPropagatingRightShiftS(value);\n return this.signPropagatingRightShiftM(value);\n };\n\n AbstractMatrix.prototype.signPropagatingRightShiftS = function signPropagatingRightShiftS(value) {\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) >> value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.signPropagatingRightShiftM = function signPropagatingRightShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) >> matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.signPropagatingRightShift = function signPropagatingRightShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.signPropagatingRightShift(value);\n };\n\n AbstractMatrix.prototype.rightShift = function rightShift(value) {\n if (typeof value === 'number') return this.rightShiftS(value);\n return this.rightShiftM(value);\n };\n\n AbstractMatrix.prototype.rightShiftS = function rightShiftS(value) {\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) >>> value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.rightShiftM = function rightShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) >>> matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.rightShift = function rightShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.rightShift(value);\n };\n AbstractMatrix.prototype.zeroFillRightShift = AbstractMatrix.prototype.rightShift;\n AbstractMatrix.prototype.zeroFillRightShiftS = AbstractMatrix.prototype.rightShiftS;\n AbstractMatrix.prototype.zeroFillRightShiftM = AbstractMatrix.prototype.rightShiftM;\n AbstractMatrix.zeroFillRightShift = AbstractMatrix.rightShift;\n\n AbstractMatrix.prototype.not = function not() {\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)));\n }\n }\n return this;\n };\n\n AbstractMatrix.not = function not(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.not();\n };\n\n AbstractMatrix.prototype.abs = function abs() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.abs(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.abs = function abs(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.abs();\n };\n\n AbstractMatrix.prototype.acos = function acos() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.acos(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.acos = function acos(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.acos();\n };\n\n AbstractMatrix.prototype.acosh = function acosh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.acosh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.acosh = function acosh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.acosh();\n };\n\n AbstractMatrix.prototype.asin = function asin() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.asin(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.asin = function asin(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.asin();\n };\n\n AbstractMatrix.prototype.asinh = function asinh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.asinh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.asinh = function asinh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.asinh();\n };\n\n AbstractMatrix.prototype.atan = function atan() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.atan(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.atan = function atan(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.atan();\n };\n\n AbstractMatrix.prototype.atanh = function atanh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.atanh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.atanh = function atanh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.atanh();\n };\n\n AbstractMatrix.prototype.cbrt = function cbrt() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cbrt(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cbrt = function cbrt(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cbrt();\n };\n\n AbstractMatrix.prototype.ceil = function ceil() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.ceil(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.ceil = function ceil(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.ceil();\n };\n\n AbstractMatrix.prototype.clz32 = function clz32() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.clz32(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.clz32 = function clz32(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.clz32();\n };\n\n AbstractMatrix.prototype.cos = function cos() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cos(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cos = function cos(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cos();\n };\n\n AbstractMatrix.prototype.cosh = function cosh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cosh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cosh = function cosh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cosh();\n };\n\n AbstractMatrix.prototype.exp = function exp() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.exp(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.exp = function exp(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.exp();\n };\n\n AbstractMatrix.prototype.expm1 = function expm1() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.expm1(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.expm1 = function expm1(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.expm1();\n };\n\n AbstractMatrix.prototype.floor = function floor() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.floor(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.floor = function floor(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.floor();\n };\n\n AbstractMatrix.prototype.fround = function fround() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.fround(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.fround = function fround(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.fround();\n };\n\n AbstractMatrix.prototype.log = function log() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log = function log(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log();\n };\n\n AbstractMatrix.prototype.log1p = function log1p() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log1p(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log1p = function log1p(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log1p();\n };\n\n AbstractMatrix.prototype.log10 = function log10() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log10(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log10 = function log10(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log10();\n };\n\n AbstractMatrix.prototype.log2 = function log2() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log2(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log2 = function log2(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log2();\n };\n\n AbstractMatrix.prototype.round = function round() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.round(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.round = function round(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.round();\n };\n\n AbstractMatrix.prototype.sign = function sign() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sign(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sign = function sign(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sign();\n };\n\n AbstractMatrix.prototype.sin = function sin() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sin(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sin = function sin(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sin();\n };\n\n AbstractMatrix.prototype.sinh = function sinh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sinh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sinh = function sinh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sinh();\n };\n\n AbstractMatrix.prototype.sqrt = function sqrt() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sqrt(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sqrt = function sqrt(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sqrt();\n };\n\n AbstractMatrix.prototype.tan = function tan() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.tan(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.tan = function tan(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.tan();\n };\n\n AbstractMatrix.prototype.tanh = function tanh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.tanh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.tanh = function tanh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.tanh();\n };\n\n AbstractMatrix.prototype.trunc = function trunc() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.trunc(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.trunc = function trunc(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.trunc();\n };\n\n AbstractMatrix.pow = function pow(matrix, arg0) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.pow(arg0);\n };\n\n AbstractMatrix.prototype.pow = function pow(value) {\n if (typeof value === 'number') return this.powS(value);\n return this.powM(value);\n };\n\n AbstractMatrix.prototype.powS = function powS(value) {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.pow(this.get(i, j), value));\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.powM = function powM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j)));\n }\n }\n return this;\n };\n}\n","import rescale from 'ml-array-rescale';\n\nimport {\n checkRowVector,\n checkRowIndex,\n checkColumnIndex,\n checkColumnVector,\n checkRange,\n checkIndices,\n} from './util';\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 { inspectMatrix } from './inspect';\nimport { installMathOperations } from './mathOperations';\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\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';\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';\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';\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';\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';\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';\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 Matrix from './matrix';\nimport LuDecomposition from './dc/lu';\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 Matrix from './matrix';\nimport SingularValueDecomposition from './dc/svd';\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))\n .abs()\n .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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 WrapperMatrix2D from '../wrap/WrapperMatrix2D';\nimport Matrix from '../matrix';\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()\n .mmul(u)\n .div(\n u\n .transpose()\n .mmul(u)\n .get(0, 0),\n );\n w = w.div(w.norm());\n\n t = X.mmul(w).div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n );\n\n if (counter > 0) {\n diff = t\n .clone()\n .sub(tOld)\n .pow(2)\n .sum();\n }\n tOld = t.clone();\n\n if (Y) {\n q = Y.transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n q = q.div(q.norm());\n\n u = Y.mmul(q).div(\n q\n .transpose()\n .mmul(q)\n .get(0, 0),\n );\n } else {\n u = t;\n }\n }\n\n if (Y) {\n let p = X.transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n p = p.div(p.norm());\n let xResidual = X.clone().sub(t.clone().mmul(p.transpose()));\n let residual = u\n .transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n let yResidual = Y.clone().sub(\n t\n .clone()\n .mulS(residual.get(0, 0))\n .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\n .transpose()\n .mmul(t)\n .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","import isArray from 'is-any-array';\n\n/**\n * Computes the mean of the given values\n * @param {Array} input\n * @return {number}\n */\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\n/**\n * Computes the mean of the given values\n * @param {Array} input\n * @return {number}\n */\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 var counts = new Array(numberOfClasses).fill(0);\n for (var 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 var probabilities = toDiscreteDistribution(\n array,\n getNumberOfClasses(array)\n ).getRow(0);\n\n var sum = 0.0;\n for (var 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.filter(function (val, i, arr) {\n return arr.indexOf(val) === i;\n }).length;\n}\n\n/**\n * @private\n * Calculates the Gini Gain of an array of predictions and those predictions splitted by a feature.\n * @para {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 var splitsImpurity = 0.0;\n var splits = ['greater', 'lesser'];\n\n for (var i = 0; i < splits.length; ++i) {\n var 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 var l = array.length;\n\n var m = meanArray(array);\n var squaredError = 0.0;\n\n for (var i = 0; i < l; ++i) {\n var currentElement = array[i];\n squaredError += (currentElement - m) * (currentElement - m);\n }\n\n return squaredError;\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 var error = 0.0;\n var splits = ['greater', 'lesser'];\n\n for (var i = 0; i < splits.length; ++i) {\n var 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 var lesserX = [];\n var greaterX = [];\n var lesserY = [];\n var greaterY = [];\n\n for (var 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: ${\n b.length\n }`\n );\n }\n\n var ret = new Array(a.length);\n for (var 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 var bestGain = this.kind === 'classifier' ? -Infinity : Infinity;\n var check = this.kind === 'classifier' ? (a, b) => a > b : (a, b) => a < b;\n\n var maxColumn;\n var maxValue;\n\n for (var i = 0; i < XTranspose.rows; ++i) {\n var currentFeature = XTranspose.getRow(i);\n var splitValues = this.featureSplit(currentFeature, y);\n for (var j = 0; j < splitValues.length; ++j) {\n var currentSplitVal = splitValues[j];\n var splitted = this.split(currentFeature, y, currentSplitVal);\n\n var 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 var lesser = [];\n var greater = [];\n\n for (var 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 var splitValues = [];\n var arr = Utils.zip(x, y);\n arr.sort(function (a, b) {\n return a[0] - b[0];\n });\n\n for (var 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 var XTranspose = X.transpose();\n var split = this.bestSplit(XTranspose, y);\n\n this.splitValue = split.maxValue;\n this.splitColumn = split.maxColumn;\n this.gain = split.maxGain;\n\n var 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 var lesserX = new Matrix(splittedMatrix.lesserX);\n var 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 var predictions = new Array(toPredict.rows);\n\n for (var 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 (typeof trainingSet[0] !== 'undefined' && trainingSet[0].length === undefined) {\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 (typeof toPredict[0] !== 'undefined' && toPredict[0].length === undefined) {\n toPredict = Matrix.columnVector(toPredict);\n }\n toPredict = Matrix.checkMatrix(toPredict);\n\n var predictions = new Array(toPredict.rows);\n for (var 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/**\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 var engine;\n var 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 var Xr = new Array(trainingSet.rows);\n var yr = new Array(trainingSet.rows);\n\n for (var i = 0; i < trainingSet.rows; ++i) {\n var 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 var distribution = Random.integer(0, trainingSet.columns - 1);\n var 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 var toRet = new Matrix(trainingSet.rows, n);\n\n if (replacement) {\n var usedIndex = new Array(n);\n for (var i = 0; i < n; ++i) {\n var 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 (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 { Matrix, WrapperMatrix2D, MatrixTransposeView, MatrixColumnSelectionView } 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 var 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 if (this.isClassifier) {\n var 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 (var i = 0; i < this.nEstimators; ++i) {\n var res = this.useSampleBagging\n ? Utils.examplesBaggingWithReplacement(\n trainingSet,\n trainingValues,\n this.seed\n )\n : { X: trainingSet, y: trainingValues };\n var X = res.X;\n var 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 var predictionValues = new Array(this.nEstimators);\n toPredict = Matrix.checkMatrix(toPredict);\n for (var i = 0; i < this.nEstimators; ++i) {\n var 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(new WrapperMatrix2D(predictionValues));\n var predictions = new Array(predictionValues.rows);\n for (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 var 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","(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 quickSelectMedian from 'median-quickselect';\nimport isArray from 'is-any-array';\n\n/**\n * Computes the median of the given values\n * @param {Array} input\n * @return {number}\n */\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 var 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 {boolean} [options.method='SVD'] - select which method to use: SVD (default), covarianceMatrirx or NIPALS.\n * @param {boolean} [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 };\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(X.clone().apply(pow2array).sum());\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 var means = dataset.mean('column');\n var std = dataset.standardDeviation('column', { mean: means, unbiased: true });\n var 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 (var i = 0; i < array.length; ++i) {\n for (var j = 0; j < array[i].length; ++j) {\n var elem = array[i][j];\n array[i][j] = elem !== null ? new Matrix(array[i][j]) : undefined;\n }\n }\n } else {\n for (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 './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 var {\n tolerance = 1e-5,\n scale = true,\n } = 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('The number of X rows must be equal to the number of Y rows');\n }\n\n this.meanX = trainingSet.mean('column');\n this.stdDevX = trainingSet.standardDeviation('column', { mean: this.meanX, unbiased: true });\n this.meanY = trainingValues.mean('column');\n this.stdDevY = trainingValues.standardDeviation('column', { mean: this.meanY, unbiased: true });\n\n if (this.scale) {\n trainingSet = trainingSet.clone().subRowVector(this.meanX).divRowVector(this.stdDevX);\n trainingValues = trainingValues.clone().subRowVector(this.meanY).divRowVector(this.stdDevY);\n }\n\n if (this.latentVectors === undefined) {\n this.latentVectors = Math.min(trainingSet.rows - 1, trainingSet.columns);\n }\n\n var rx = trainingSet.rows;\n var cx = trainingSet.columns;\n var ry = trainingValues.rows;\n var cy = trainingValues.columns;\n\n var ssqXcal = trainingSet.clone().mul(trainingSet).sum(); // for the r²\n var sumOfSquaresY = trainingValues.clone().mul(trainingValues).sum();\n\n var tolerance = this.tolerance;\n var n = this.latentVectors;\n var T = Matrix.zeros(rx, n);\n var P = Matrix.zeros(cx, n);\n var U = Matrix.zeros(ry, n);\n var Q = Matrix.zeros(cy, n);\n var B = Matrix.zeros(n, n);\n var W = P.clone();\n var k = 0;\n\n while (Utils.norm(trainingValues) > tolerance && k < n) {\n var transposeX = trainingSet.transpose();\n var transposeY = trainingValues.transpose();\n\n var tIndex = maxSumColIndex(trainingSet.clone().mul(trainingSet));\n var uIndex = maxSumColIndex(trainingValues.clone().mul(trainingValues));\n\n var t1 = trainingSet.getColumnVector(tIndex);\n var u = trainingValues.getColumnVector(uIndex);\n var t = Matrix.zeros(rx, 1);\n\n while (Utils.norm(t1.clone().sub(t)) > tolerance) {\n var w = transposeX.mmul(u);\n w.div(Utils.norm(w));\n t = t1;\n t1 = trainingSet.mmul(w);\n var q = transposeY.mmul(t1);\n q.div(Utils.norm(q));\n u = trainingValues.mmul(q);\n }\n\n t = t1;\n var num = transposeX.mmul(t);\n var den = t.transpose().mmul(t).get(0, 0);\n var p = num.div(den);\n var 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.transpose().mmul(t).get(0, 0);\n var b = num.div(den).get(0, 0);\n trainingSet.sub(t.mmul(p.transpose()));\n trainingValues.sub(t.clone().mul(b).mmul(q.transpose()));\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 // TODO: review of R2Y\n // this.R2Y = t.transpose().mmul(t).mul(q[k][0]*q[k][0]).divS(ssqYcal)[0][0];\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.transpose().mmul(t).mmul(p.transpose().mmul(p)).div(ssqXcal).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 var X = Matrix.checkMatrix(dataset);\n if (this.scale) {\n X = X.subRowVector(this.meanX).divRowVector(this.stdDevX);\n }\n var 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 './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(model.TURegressionCoeff, false);\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 var kernelX = this.kernel.compute(trainingSet);\n\n var Identity = Matrix.eye(kernelX.rows, kernelX.rows, 1);\n var 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 var result = new SingularValueDecomposition(trainingValues.transpose().mmul(kernelX[0][0]).mmul(trainingValues), {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false\n });\n var YLoadingMat = result.leftSingularVectors;\n var Sigma = result.diagonalMatrix;\n\n YLoadingMat = YLoadingMat.subMatrix(0, YLoadingMat.rows - 1, 0, this.predictiveComp - 1);\n Sigma = Sigma.subMatrix(0, this.predictiveComp - 1, 0, this.predictiveComp - 1);\n\n var YScoreMat = trainingValues.mmul(YLoadingMat);\n\n var predScoreMat = new Array(this.orthogonalComp + 1);\n var TURegressionCoeff = new Array(this.orthogonalComp + 1);\n var YOrthScoreMat = new Array(this.orthogonalComp);\n var YOrthLoadingVec = new Array(this.orthogonalComp);\n var YOrthEigen = new Array(this.orthogonalComp);\n var YOrthScoreNorm = new Array(this.orthogonalComp);\n\n var 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 (var i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = kernelX[0][i].transpose().mmul(YScoreMat).mmul(SigmaPow);\n\n var TpiPrime = predScoreMat[i].transpose();\n TURegressionCoeff[i] = inverse(TpiPrime.mmul(predScoreMat[i])).mmul(TpiPrime).mmul(YScoreMat);\n\n result = new SingularValueDecomposition(TpiPrime.mmul(Matrix.sub(kernelX[i][i], predScoreMat[i].mmul(TpiPrime))).mmul(predScoreMat[i]), {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false\n });\n var CoTemp = result.leftSingularVectors;\n var 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(kernelX[i][i], predScoreMat[i].mmul(TpiPrime)).mmul(predScoreMat[i]).mmul(YOrthLoadingVec[i]).mul(Math.pow(YOrthEigen[i], -0.5));\n\n var toiPrime = YOrthScoreMat[i].transpose();\n YOrthScoreNorm[i] = Matrix.sqrt(toiPrime.mmul(YOrthScoreMat[i]));\n\n YOrthScoreMat[i] = YOrthScoreMat[i].divRowVector(YOrthScoreNorm[i]);\n\n var ITo = Matrix.sub(Identity, YOrthScoreMat[i].mmul(YOrthScoreMat[i].transpose()));\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 var lastScoreMat = predScoreMat[this.orthogonalComp] = kernelX[0][this.orthogonalComp].transpose().mmul(YScoreMat).mmul(SigmaPow);\n\n var lastTpPrime = lastScoreMat.transpose();\n TURegressionCoeff[this.orthogonalComp] = inverse(lastTpPrime.mmul(lastScoreMat)).mmul(lastTpPrime).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 var KTestTrain = this.kernel.compute(toPredict, this.trainingSet);\n\n var 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 var YOrthScoreVector = new Array(this.orthogonalComp);\n var predScoreMat = new Array(this.orthogonalComp);\n\n var i;\n for (i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = KTestTrain[i][0].mmul(this.YScoreMat).mmul(this.SigmaPow);\n\n YOrthScoreVector[i] = Matrix.sub(KTestTrain[i][i], predScoreMat[i].mmul(this.predScoreMat[i].transpose())).mmul(this.predScoreMat[i]).mmul(this.YOrthLoadingVec[i]).mul(Math.pow(this.YOrthEigen[i], -0.5));\n\n YOrthScoreVector[i] = YOrthScoreVector[i].divRowVector(this.toNorm[i]);\n\n var scoreMatPrime = this.YOrthScoreMat[i].transpose();\n KTestTrain[i + 1][0] = Matrix.sub(KTestTrain[i][0], YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[0][i].transpose()));\n\n var p1 = Matrix.sub(KTestTrain[i][0], KTestTrain[i][i].mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime));\n var p2 = YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[i][i]);\n var 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 var prediction = predScoreMat[i].mmul(this.TURegressionCoeff[i]).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 */\nclass 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('Confusion matrix and labels should have the same length');\n }\n this.labels = labels;\n this.matrix = matrix;\n }\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 (var i = 0; i < this.matrix.length; i++) {\n for (var 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 var count = 0;\n for (var 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 var count = 0;\n for (var i = 0; i < this.matrix.length; i++) {\n for (var 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 var count = 0;\n for (var 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 var count = 0;\n for (var 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 2 * TP / (2 * TP + this.getFalsePositiveCount(label) + this.getFalseNegativeCount(label));\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 (TP * TN - FP * FN) / Math.sqrt((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN));\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 this.getTruePositiveRate(label) + this.getTrueNegativeRate(label) - 1;\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 this.getPositivePredictiveValue(label) + this.getNegativePredictiveValue(label) - 1;\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 [\n this.getTruePositiveCount(label),\n this.getFalseNegativeCount(label)\n ],\n [\n this.getFalsePositiveCount(label),\n this.getTrueNegativeCount(label)\n ]\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 (var i = 0; i < this.matrix.length; i++) {\n for (var 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 /**\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\nmodule.exports = ConfusionMatrix;\n","'use strict';\nconst defaultOptions = {\n mode: 'index'\n};\n\nmodule.exports = function *(M, N, options) {\n options = Object.assign({}, defaultOptions, options);\n var a = new Array(N);\n var c = new Array(M);\n var b = new Array(N);\n var p = new Array(N + 2);\n var x, y, z;\n\n // init a and b\n for (var i = 0; i < N; i++) {\n a[i] = i;\n if (i < N - M) b[i] = 0;\n else b[i] = 1;\n }\n\n // init c\n for (i = 0; i < M; i++) {\n c[i] = N - M + i;\n }\n\n // init p\n for (i = 0; i < p.length; i++) {\n if (i === 0) p[i] = N + 1;\n else if (i <= N - M) p[i] = 0;\n else if (i <= N) p[i] = i - N + M;\n else p[i] = -2;\n }\n\n function twiddle() {\n var i, j, k;\n j = 1;\n while (p[j] <= 0) {\n j++;\n }\n if (p[j - 1] === 0) {\n for (i = j - 1; i !== 1; i--) {\n p[i] = -1;\n }\n p[j] = 0;\n x = z = 0;\n p[1] = 1;\n y = j - 1;\n } else {\n if (j > 1) {\n p[j - 1] = 0;\n }\n do {\n j++;\n }\n while (p[j] > 0);\n k = j - 1;\n i = j;\n while (p[i] === 0) {\n p[i++] = -1;\n }\n if (p[i] === -1) {\n p[i] = p[k];\n z = p[k] - 1;\n x = i - 1;\n y = k - 1;\n p[k] = -1;\n } else {\n if (i === p[0]) {\n return 0;\n } else {\n p[j] = p[i];\n z = p[i] - 1;\n p[i] = 0;\n x = j - 1;\n y = i - 1;\n }\n }\n }\n return 1;\n }\n\n if (options.mode === 'index') {\n yield c.slice();\n while (twiddle()) {\n c[z] = a[x];\n yield c.slice();\n }\n } else if (options.mode === 'mask') {\n yield b.slice();\n while (twiddle()) {\n b[x] = 1;\n b[y] = 0;\n yield b.slice();\n }\n } else {\n throw new Error('Invalid mode');\n }\n};\n","'use strict';\n\nconst ConfusionMatrix = require('ml-confusion-matrix');\n\nconst CV = {};\nconst combinations = require('ml-combinations');\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 */\nCV.leaveOneOut = function (Classifier, features, labels, classifierOptions) {\n if (typeof labels === 'function') {\n var callback = labels;\n labels = features;\n features = Classifier;\n return CV.leavePOut(features, labels, 1, callback);\n }\n return CV.leavePOut(Classifier, features, labels, classifierOptions, 1);\n};\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 */\nCV.leavePOut = function (Classifier, features, labels, classifierOptions, p) {\n if (typeof classifierOptions === 'function') {\n var 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 var N = features.length;\n var gen = combinations(p, N);\n var allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n for (const testIdx of gen) {\n var 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(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback);\n } else {\n validate(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, 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 */\nCV.kFold = function (Classifier, features, labels, classifierOptions, k) {\n if (typeof classifierOptions === 'function') {\n var 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 var N = features.length;\n var allIdx = new Array(N);\n for (var i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n\n var l = Math.floor(N / k);\n // create random k-folds\n var current = [];\n var folds = [];\n while (allIdx.length) {\n var 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 if (current.length) folds.push(current);\n folds = folds.slice(0, k);\n\n\n for (i = 0; i < folds.length; i++) {\n var testIdx = folds[i];\n var trainIdx = [];\n for (var j = 0; j < folds.length; j++) {\n if (j !== i) trainIdx = trainIdx.concat(folds[j]);\n }\n\n if (callback) {\n validateWithCallback(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback);\n } else {\n validate(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, distinct);\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 var 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(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, distinct) {\n const {testFeatures, trainFeatures, testLabels, trainLabels} = getTrainTest(features, labels, testIdx, trainIdx);\n\n var 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 var predictedLabels = classifier.predict(testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction validateWithCallback(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback) {\n const {testFeatures, trainFeatures, testLabels, trainLabels} = getTrainTest(features, labels, testIdx, trainIdx);\n const predictedLabels = callback(trainFeatures, trainLabels, testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct) {\n\n for (var 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\n\nfunction 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\nmodule.exports = CV;\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","/**\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 var error = 0;\n const func = parameterizedFunction(parameters);\n\n for (var 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 var ans = new Array(n);\n\n for (var param = 0; param < n; param++) {\n ans[param] = new Array(m);\n var auxParams = params.concat();\n auxParams[param] += gradientDifference;\n var funcParam = paramFunction(auxParams);\n\n for (var 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 var ans = new Array(m);\n\n for (var 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 var value = damping * gradientDifference * gradientDifference;\n var identity = Matrix.eye(params.length, params.length, value);\n\n const func = parameterizedFunction(params);\n var evaluatedData = data.x.map((e) => func(e));\n\n var gradientFunc = gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n parameterizedFunction\n );\n var matrixFunc = matrixFunction(data, evaluatedData);\n var 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 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 !Array.isArray(data.x) ||\n data.x.length < 2 ||\n !Array.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 var 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 (!Array.isArray(parameters)) {\n throw new Error('initialValues must be an array');\n }\n\n var error = errorCalculation(data, parameters, parameterizedFunction);\n\n var converged = error <= errorTolerance;\n\n for (\n var iteration = 0;\n iteration < maxIterations && !converged;\n iteration++\n ) {\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' || Number.isNaN(number)) {\n\t\tthrow new TypeError('Expected a number');\n\t}\n}\n\nexports.ascending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\treturn left - right;\n};\n\nexports.descending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\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\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;\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","import isArray from 'is-any-array';\n\n/**\n * Computes the mode of the given values\n * @param {Array} input\n * @return {number}\n */\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","import max from 'ml-array-max';\nimport sum from 'ml-array-sum';\n\n/**\n * Computes the norm of the given values\n * @param {Array} input\n * @param {object} [options={}]\n * @param {string} [options.algorithm='absolute'] absolute, sum or max\n * @return {number}\n */\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\n if (!Array.isArray(input)) {\n throw new Error('input must be an array');\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);\n if (absoluteSumValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / absoluteSumValue;\n });\n }\n\n case 'max':\n {\n var maxValue = max(input);\n if (maxValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / maxValue;\n });\n }\n\n case 'sum':\n {\n var sumValue = sum(input);\n if (sumValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / sumValue;\n });\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 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/**\n * Fill an array with sequential numbers\n * @param {Array} [input] - optional destination array (if not provided a new array will be created)\n * @param {object} [options={}]\n * @param {number} [options.from=0] - first value in the array\n * @param {number} [options.to=10] - last value in the array\n * @param {number} [options.size=input.length] - size of the array (if not provided calculated from step)\n * @param {number} [options.step] - if not provided calculated from size\n * @return {Array}\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 && 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 input.length = 0; // only works with normal array\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","import arrayMean from 'ml-array-mean';\nimport isArray from 'is-any-array';\n\n/**\n * Computes the variance of the given values\n * @param {Array} values\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @param {number} [options.mean = arrayMean] - precalculated mean, if any.\n * @return {number}\n */\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\n/**\n * Computes the standard deviation of the given values\n * @param {Array} values\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @param {number} [options.mean = arrayMean] - precalculated mean, if any.\n * @return {number}\n */\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 * 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 var xLength = x.length;\n\n var step = (to - from) / (numberOfPoints - 1);\n var halfStep = step / 2;\n\n var output = new Array(numberOfPoints);\n\n var initialOriginalStep = x[1] - x[0];\n var lastOriginalStep = x[xLength - 1] - x[xLength - 2];\n\n // Init main variables\n var min = from - halfStep;\n var max = from + halfStep;\n\n var previousX = Number.MIN_VALUE;\n var previousY = 0;\n var nextX = x[0] - initialOriginalStep;\n var nextY = 0;\n\n var currentValue = 0;\n var slope = 0;\n var intercept = 0;\n var sumAtMin = 0;\n var sumAtMax = 0;\n\n var i = 0; // index of input\n var j = 0; // index of output\n\n function getSlope(x0, y0, x1, y1) {\n return (y1 - y0) / (x1 - x0);\n }\n\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 var 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 var xLength = x.length;\n\n var step = (to - from) / (numberOfPoints - 1);\n var halfStep = step / 2;\n var lastStep = x[x.length - 1] - x[x.length - 2];\n\n var start = from - halfStep;\n var output = new Array(numberOfPoints);\n\n // Init main variables\n var min = start;\n var max = start + step;\n\n var previousX = -Number.MAX_VALUE;\n var previousY = 0;\n var nextX = x[0];\n var nextY = y[0];\n var frontOutsideSpectra = 0;\n var backOutsideSpectra = true;\n\n var currentValue = 0;\n\n // for slot algorithm\n var currentPoints = 0;\n\n var i = 1; // index of input\n var 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","export default function getZones(from, to, numberOfPoints, 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, numberOfPoints }];\n }\n\n // need to deal with overlapping exclusions and out of bound exclusions\n\n let toRemove = exclusions.reduce(\n (previous, exclusion) => (previous += exclusion.to - exclusion.from),\n 0\n );\n let total = to - from;\n let unitsPerPoint = (total - toRemove) / numberOfPoints;\n let zones = [];\n let currentFrom = from;\n let totalPoints = 0;\n for (let exclusion of exclusions) {\n let currentNbPoints = Math.round(\n (exclusion.from - currentFrom) / unitsPerPoint\n );\n totalPoints += currentNbPoints;\n if (currentNbPoints > 0) {\n zones.push({\n from: currentFrom,\n to: exclusion.from,\n numberOfPoints: currentNbPoints\n });\n }\n\n currentFrom = exclusion.to;\n }\n if (numberOfPoints - totalPoints > 0) {\n zones.push({\n from: currentFrom,\n to: to,\n numberOfPoints: numberOfPoints - totalPoints\n });\n }\n\n return zones;\n}\n","import sequentialFill from 'ml-array-sequential-fill';\n\nimport equallySpacedSmooth from './equallySpacedSmooth';\nimport equallySpacedSlot from './equallySpacedSlot';\nimport getZones from './getZones';\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 * @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 * @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 } = 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 let zones = getZones(from, to, numberOfPoints, exclusions);\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 xResult.push(...zoneResult.x);\n yResult.push(...zoneResult.y);\n }\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 var 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 } from 'ml-pls';\nexport { default as CrossValidation } from 'ml-cross-validation';\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';\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","isArray","TypeError","length","maxValue","i","min","minValue","rescale","options","arguments","undefined","output","Array","currentMin","currentMax","RangeError","_options$min","autoMinMax","_options$max","factor","checkRowIndex","matrix","index","outer","rows","checkColumnIndex","columns","checkRowVector","vector","to1DArray","checkColumnVector","checkIndices","rowIndices","columnIndices","row","checkRowIndices","column","checkColumnIndices","rowOut","some","r","from","columnOut","c","checkRange","startRow","endRow","startColumn","endColumn","checkNumber","newArray","value","array","push","name","sumByRow","sum","j","get","sumByColumn","sumAll","v","productByRow","productByColumn","productAll","varianceByRow","unbiased","mean","cols","variance","sum1","sum2","x","varianceByColumn","varianceAll","size","centerByRow","set","centerByColumn","centerAll","getScaleByRow","scale","Math","pow","sqrt","scaleByRow","getScaleByColumn","scaleByColumn","getScaleAll","divider","scaleAll","inspectMatrix","indent","repeat","indentData","constructor","inspectData","maxRows","maxColumns","maxNumSize","maxI","maxJ","result","line","formatNumber","join","num","numStr","String","padEnd","precise","toPrecision","exponential","toExponential","eIndex","indexOf","e","substring","installMathOperations","AbstractMatrix","Matrix","add","addS","addM","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","tan","tanh","trunc","arg0","powS","powM","from1DArray","newRows","newColumns","newData","rowVector","columnVector","zeros","ones","fill","rand","random","randInt","Number","isInteger","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","Error","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","iter","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","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","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","SMALLEST_UNSAFE_INTEGER","LARGEST_SAFE_INTEGER","UINT32_MAX","UINT32_SIZE","INT32_SIZE","INT32_MAX","UINT21_SIZE","UINT21_MAX","int32","engine","next","addend","int53","int53Full","uint32","uint53","uint53Full","isPowerOfTwoMinusOne","bitmask","masking","downscaleToLoopCheckedRange","extendedRange","maximum","downscaleToRange","isEvenlyDivisibleByMaxInt32","upscaleWithHighMasking","upscaleToLoopCheckedRange","upscaleWithinU53","highRange","upscaleWithinI53AndLoopCheck","integer","DEFAULT_STRING_POOL","string","pool","poolLength","charAt","LOWER_HEX_POOL","lowerHex","upperHex","toUpperCase","stringRepeat","pattern","_","nativeMath","I32Array","buffer","ArrayBuffer","view","Int32Array","createEntropy","Date","getTime","imul","UINT16_MAX","ah","al","bh","bl","ARRAY_SIZE","ARRAY_MAX","M","ARRAY_SIZE_MINUS_M","A","MersenneTwister19937","uses","seed","initial","seedWithArray","source","autoSeed","refreshData","temper","getUseCount","discard","previous","sourceLength","checkFloat","examplesBaggingWithReplacement","trainingValue","Random","Xr","featureBagging","replacement","toRet","usedIndex","Set","has","RandomForestBase","maxFeatures","nEstimators","treeOptions","isClassifier","indexes","useSampleBagging","Estimator","DTClassifier","DTRegression","estimators","map","est","res","values","predictionValues","RandomForestClassifier","baseModel","mode","pop","_ref","module","exports","window","median","quickSelectMedian","slice","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","_j","_len","_ref1","_results","_results1","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","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","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","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","N","twiddle","CV","leaveOneOut","Classifier","classifierOptions","leavePOut","distinct","getDistinct","confusionMatrix","initMatrix","gen","combinations","allIdx","testIdx","trainIdx","validateWithCallback","validate","kFold","current","folds","randi","testFeatures","trainFeatures","testLabels","trainLabels","getTrainTest","classifier","predictedLabels","updateConfusionMatrix","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","keys","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","hasOwnProperty","numWeights","converters","getConverters","extractor","creator","nodeType","hx","distanceMethod","getMaxDistance","done","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","self","_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","fn","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","reduce","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","key","BigInt","sorted","cssls","XtX","XtY","Pset","choXtX","luXtX","sortedPset","sortedEset","cols2Solve","vars","initialisation","Fset","D","setDifference","C","includes","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","err","fpr","tpr","fnr","tnr","ppv","npv","pcfall","pcmiss","lift","rpp","rnp","arrayCase","cond","matrixCase","padArray","windowSize","derivative","pad","padValue","savitzkyGolay","J","inic","Jtranspose","Jinv","det","eightBits","arr1","arr2","getBit","mask","setBit","toBinaryString","substr","parseBinaryString","toHexString","parseHexString","toDebug","binary","maxCount","_options$algorithm","algorithm","absoluteSumValue","absoluteSum","_typeof","iterator","sequentialFill","_options","_options$from","_options$to","_options$size","_options$unbiased","_options$mean","sqrError","mergeByCentroids","originalPoints","mergedPoints","originalIndex","mergedIndex","closestX","descending","maxMerge","groupWidth","merged","maxAbscissa","maxY","calculateIndex","sortX","sortFunc","grouped","response","uniqueX","weightedMerge","weightedAbscissa","integral","x0","x1","equallySpacedSmooth","numberOfPoints","xLength","halfStep","initialOriginalStep","lastOriginalStep","previousX","previousY","nextX","nextY","currentValue","sumAtMin","sumAtMax","getSlope","y0","y1","main","equallySpacedSlot","lastStep","frontOutsideSpectra","backOutsideSpectra","getZones","exclusions","exclusion","JSON","parse","stringify","toRemove","unitsPerPoint","zones","currentFrom","totalPoints","currentNbPoints","equallySpaced","arrayXY","variant","xResult","yResult","zone","zoneResult","processZone","filterX","currentZoneIndex","newX","newY","position","MatrixLib","normed","ArrayXY","centroidsMerge"],"mappings":";;;;;;;;;;;;EAEA,MAAMA,QAAQ,GAAGC,MAAM,CAACC,SAAP,CAAiBF,QAAlC;;EAEA,SAASG,UAAT,CAAoBC,MAApB,EAA4B;EAC1B,SAAOJ,QAAQ,CAACK,IAAT,CAAcD,MAAd,EAAsBE,QAAtB,CAA+B,QAA/B,CAAP;EACD;;EAED,OAAc,GAAGH,UAAjB;;ECNA;;;;;;EAMA,SAASI,GAAT,CAAaC,KAAb,EAAoB;EAClB,MAAI,CAACC,GAAO,CAACD,KAAD,CAAZ,EAAqB;EACnB,UAAM,IAAIE,SAAJ,CAAc,wBAAd,CAAN;EACD;;EAED,MAAIF,KAAK,CAACG,MAAN,KAAiB,CAArB,EAAwB;EACtB,UAAM,IAAID,SAAJ,CAAc,yBAAd,CAAN;EACD;;EAED,MAAIE,QAAQ,GAAGJ,KAAK,CAAC,CAAD,CAApB;;EAEA,OAAK,IAAIK,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGL,KAAK,CAACG,MAA1B,EAAkCE,CAAC,EAAnC,EAAuC;EACrC,QAAIL,KAAK,CAACK,CAAD,CAAL,GAAWD,QAAf,EAAyBA,QAAQ,GAAGJ,KAAK,CAACK,CAAD,CAAhB;EAC1B;;EAED,SAAOD,QAAP;EACD;;ECtBD;;;;;;EAMA,SAASE,GAAT,CAAaN,KAAb,EAAoB;EAClB,MAAI,CAACC,GAAO,CAACD,KAAD,CAAZ,EAAqB;EACnB,UAAM,IAAIE,SAAJ,CAAc,wBAAd,CAAN;EACD;;EAED,MAAIF,KAAK,CAACG,MAAN,KAAiB,CAArB,EAAwB;EACtB,UAAM,IAAID,SAAJ,CAAc,yBAAd,CAAN;EACD;;EAED,MAAIK,QAAQ,GAAGP,KAAK,CAAC,CAAD,CAApB;;EAEA,OAAK,IAAIK,CAAC,GAAG,CAAb,EAAgBA,C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AK,GAAG;EACnBP,EAAAA,GADmB;EAEnBP,EAAAA,GAFmB;EAGnB8wB,EAAAA,MAHmB;EAInBzsB,EAAAA,IAJmB;EAKnBmsB,QAAAA,MALmB;EAMnBilC,UAAAA,MANmB;EAOnBh1D,EAAAA,OAPmB;EAQnBkwD,EAAAA,cARmB;EASnBh4C,EAAAA,iBATmB;EAUnBjV,EAAAA,GAVmB;EAWnBa,EAAAA;EAXmB,CAAd;AAcP,QAUamxD,OAAO,GAAG;EACrBC,kBAAAA,gBADqB;EAErBnE,EAAAA,QAFqB;EAGrBpwC,cAAAA,YAHqB;EAIrBswC,EAAAA,QAJqB;EAKrBI,EAAAA,IALqB;EAMrBE,EAAAA,KANqB;EAOrBI,EAAAA,OAPqB;EAQrBC,EAAAA,aARqB;EASrBsC,EAAAA,aATqB;EAUrBQ,EAAAA;EAVqB,CAAhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"ml.js","sources":["../node_modules/is-any-array/src/index.js","../node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-rescale/lib-es6/index.js","../node_modules/ml-matrix/src/util.js","../node_modules/ml-matrix/src/stat.js","../node_modules/ml-matrix/src/inspect.js","../node_modules/ml-matrix/src/mathOperations.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/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/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/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/src/index.js","../node_modules/ml-cross-validation/src/index.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/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-array-mode/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/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-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/getZones.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":["'use strict';\n\nconst toString = Object.prototype.toString;\n\nfunction isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n\nmodule.exports = isAnyArray;\n","import isArray from 'is-any-array';\n\n/**\n * Computes the maximum of the given values\n * @param {Array} input\n * @return {number}\n */\n\nfunction max(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 = input[0];\n\n for (var i = 1; i < input.length; 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\n/**\n * Computes the minimum of the given values\n * @param {Array} input\n * @return {number}\n */\n\nfunction min(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 minValue = input[0];\n\n for (var i = 1; i < input.length; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import max from 'ml-array-max';\nimport min from 'ml-array-min';\nimport isArray from 'is-any-array';\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","/**\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","export function inspectMatrix() {\n const indent = ' '.repeat(2);\n const indentData = ' '.repeat(4);\n return `${this.constructor.name} {\n${indent}[\n${indentData}${inspectData(this, indentData)}\n${indent}]\n${indent}rows: ${this.rows}\n${indent}columns: ${this.columns}\n}`;\n}\n\nconst maxRows = 15;\nconst maxColumns = 10;\nconst maxNumSize = 8;\n\nfunction inspectData(matrix, indent) {\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)));\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${indent}`);\n}\n\nfunction formatNumber(num) {\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.substring(eIndex);\n return exponential.substring(0, maxNumSize - e.length) + e;\n}\n","export function installMathOperations(AbstractMatrix, Matrix) {\n AbstractMatrix.prototype.add = function add(value) {\n if (typeof value === 'number') return this.addS(value);\n return this.addM(value);\n };\n\n AbstractMatrix.prototype.addS = function addS(value) {\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) + value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.addM = function addM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) + matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.add = function add(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.add(value);\n };\n\n AbstractMatrix.prototype.sub = function sub(value) {\n if (typeof value === 'number') return this.subS(value);\n return this.subM(value);\n };\n\n AbstractMatrix.prototype.subS = function subS(value) {\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) - value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.subM = function subM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) - matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.sub = function sub(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sub(value);\n };\n AbstractMatrix.prototype.subtract = AbstractMatrix.prototype.sub;\n AbstractMatrix.prototype.subtractS = AbstractMatrix.prototype.subS;\n AbstractMatrix.prototype.subtractM = AbstractMatrix.prototype.subM;\n AbstractMatrix.subtract = AbstractMatrix.sub;\n\n AbstractMatrix.prototype.mul = function mul(value) {\n if (typeof value === 'number') return this.mulS(value);\n return this.mulM(value);\n };\n\n AbstractMatrix.prototype.mulS = function mulS(value) {\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) * value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.mulM = function mulM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) * matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.mul = function mul(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.mul(value);\n };\n AbstractMatrix.prototype.multiply = AbstractMatrix.prototype.mul;\n AbstractMatrix.prototype.multiplyS = AbstractMatrix.prototype.mulS;\n AbstractMatrix.prototype.multiplyM = AbstractMatrix.prototype.mulM;\n AbstractMatrix.multiply = AbstractMatrix.mul;\n\n AbstractMatrix.prototype.div = function div(value) {\n if (typeof value === 'number') return this.divS(value);\n return this.divM(value);\n };\n\n AbstractMatrix.prototype.divS = function divS(value) {\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) / value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.divM = function divM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) / matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.div = function div(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.div(value);\n };\n AbstractMatrix.prototype.divide = AbstractMatrix.prototype.div;\n AbstractMatrix.prototype.divideS = AbstractMatrix.prototype.divS;\n AbstractMatrix.prototype.divideM = AbstractMatrix.prototype.divM;\n AbstractMatrix.divide = AbstractMatrix.div;\n\n AbstractMatrix.prototype.mod = function mod(value) {\n if (typeof value === 'number') return this.modS(value);\n return this.modM(value);\n };\n\n AbstractMatrix.prototype.modS = function modS(value) {\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) % value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.modM = function modM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) % matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.mod = function mod(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.mod(value);\n };\n AbstractMatrix.prototype.modulus = AbstractMatrix.prototype.mod;\n AbstractMatrix.prototype.modulusS = AbstractMatrix.prototype.modS;\n AbstractMatrix.prototype.modulusM = AbstractMatrix.prototype.modM;\n AbstractMatrix.modulus = AbstractMatrix.mod;\n\n AbstractMatrix.prototype.and = function and(value) {\n if (typeof value === 'number') return this.andS(value);\n return this.andM(value);\n };\n\n AbstractMatrix.prototype.andS = function andS(value) {\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) & value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.andM = function andM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) & matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.and = function and(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.and(value);\n };\n\n AbstractMatrix.prototype.or = function or(value) {\n if (typeof value === 'number') return this.orS(value);\n return this.orM(value);\n };\n\n AbstractMatrix.prototype.orS = function orS(value) {\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) | value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.orM = function orM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) | matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.or = function or(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.or(value);\n };\n\n AbstractMatrix.prototype.xor = function xor(value) {\n if (typeof value === 'number') return this.xorS(value);\n return this.xorM(value);\n };\n\n AbstractMatrix.prototype.xorS = function xorS(value) {\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) ^ value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.xorM = function xorM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) ^ matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.xor = function xor(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.xor(value);\n };\n\n AbstractMatrix.prototype.leftShift = function leftShift(value) {\n if (typeof value === 'number') return this.leftShiftS(value);\n return this.leftShiftM(value);\n };\n\n AbstractMatrix.prototype.leftShiftS = function leftShiftS(value) {\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) << value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.leftShiftM = function leftShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) << matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.leftShift = function leftShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.leftShift(value);\n };\n\n AbstractMatrix.prototype.signPropagatingRightShift = function signPropagatingRightShift(value) {\n if (typeof value === 'number') return this.signPropagatingRightShiftS(value);\n return this.signPropagatingRightShiftM(value);\n };\n\n AbstractMatrix.prototype.signPropagatingRightShiftS = function signPropagatingRightShiftS(value) {\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) >> value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.signPropagatingRightShiftM = function signPropagatingRightShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) >> matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.signPropagatingRightShift = function signPropagatingRightShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.signPropagatingRightShift(value);\n };\n\n AbstractMatrix.prototype.rightShift = function rightShift(value) {\n if (typeof value === 'number') return this.rightShiftS(value);\n return this.rightShiftM(value);\n };\n\n AbstractMatrix.prototype.rightShiftS = function rightShiftS(value) {\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) >>> value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.rightShiftM = function rightShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) >>> matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.rightShift = function rightShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.rightShift(value);\n };\n AbstractMatrix.prototype.zeroFillRightShift = AbstractMatrix.prototype.rightShift;\n AbstractMatrix.prototype.zeroFillRightShiftS = AbstractMatrix.prototype.rightShiftS;\n AbstractMatrix.prototype.zeroFillRightShiftM = AbstractMatrix.prototype.rightShiftM;\n AbstractMatrix.zeroFillRightShift = AbstractMatrix.rightShift;\n\n AbstractMatrix.prototype.not = function not() {\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)));\n }\n }\n return this;\n };\n\n AbstractMatrix.not = function not(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.not();\n };\n\n AbstractMatrix.prototype.abs = function abs() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.abs(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.abs = function abs(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.abs();\n };\n\n AbstractMatrix.prototype.acos = function acos() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.acos(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.acos = function acos(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.acos();\n };\n\n AbstractMatrix.prototype.acosh = function acosh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.acosh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.acosh = function acosh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.acosh();\n };\n\n AbstractMatrix.prototype.asin = function asin() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.asin(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.asin = function asin(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.asin();\n };\n\n AbstractMatrix.prototype.asinh = function asinh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.asinh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.asinh = function asinh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.asinh();\n };\n\n AbstractMatrix.prototype.atan = function atan() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.atan(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.atan = function atan(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.atan();\n };\n\n AbstractMatrix.prototype.atanh = function atanh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.atanh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.atanh = function atanh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.atanh();\n };\n\n AbstractMatrix.prototype.cbrt = function cbrt() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cbrt(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cbrt = function cbrt(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cbrt();\n };\n\n AbstractMatrix.prototype.ceil = function ceil() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.ceil(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.ceil = function ceil(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.ceil();\n };\n\n AbstractMatrix.prototype.clz32 = function clz32() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.clz32(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.clz32 = function clz32(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.clz32();\n };\n\n AbstractMatrix.prototype.cos = function cos() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cos(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cos = function cos(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cos();\n };\n\n AbstractMatrix.prototype.cosh = function cosh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cosh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cosh = function cosh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cosh();\n };\n\n AbstractMatrix.prototype.exp = function exp() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.exp(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.exp = function exp(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.exp();\n };\n\n AbstractMatrix.prototype.expm1 = function expm1() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.expm1(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.expm1 = function expm1(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.expm1();\n };\n\n AbstractMatrix.prototype.floor = function floor() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.floor(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.floor = function floor(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.floor();\n };\n\n AbstractMatrix.prototype.fround = function fround() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.fround(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.fround = function fround(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.fround();\n };\n\n AbstractMatrix.prototype.log = function log() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log = function log(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log();\n };\n\n AbstractMatrix.prototype.log1p = function log1p() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log1p(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log1p = function log1p(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log1p();\n };\n\n AbstractMatrix.prototype.log10 = function log10() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log10(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log10 = function log10(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log10();\n };\n\n AbstractMatrix.prototype.log2 = function log2() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log2(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log2 = function log2(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log2();\n };\n\n AbstractMatrix.prototype.round = function round() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.round(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.round = function round(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.round();\n };\n\n AbstractMatrix.prototype.sign = function sign() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sign(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sign = function sign(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sign();\n };\n\n AbstractMatrix.prototype.sin = function sin() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sin(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sin = function sin(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sin();\n };\n\n AbstractMatrix.prototype.sinh = function sinh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sinh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sinh = function sinh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sinh();\n };\n\n AbstractMatrix.prototype.sqrt = function sqrt() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sqrt(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sqrt = function sqrt(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sqrt();\n };\n\n AbstractMatrix.prototype.tan = function tan() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.tan(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.tan = function tan(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.tan();\n };\n\n AbstractMatrix.prototype.tanh = function tanh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.tanh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.tanh = function tanh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.tanh();\n };\n\n AbstractMatrix.prototype.trunc = function trunc() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.trunc(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.trunc = function trunc(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.trunc();\n };\n\n AbstractMatrix.pow = function pow(matrix, arg0) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.pow(arg0);\n };\n\n AbstractMatrix.prototype.pow = function pow(value) {\n if (typeof value === 'number') return this.powS(value);\n return this.powM(value);\n };\n\n AbstractMatrix.prototype.powS = function powS(value) {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.pow(this.get(i, j), value));\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.powM = function powM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j)));\n }\n }\n return this;\n };\n}\n","import rescale from 'ml-array-rescale';\n\nimport {\n checkRowVector,\n checkRowIndex,\n checkColumnIndex,\n checkColumnVector,\n checkRange,\n checkIndices,\n} from './util';\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 { inspectMatrix } from './inspect';\nimport { installMathOperations } from './mathOperations';\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\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';\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';\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';\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';\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';\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';\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 Matrix from './matrix';\nimport LuDecomposition from './dc/lu';\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 Matrix from './matrix';\nimport SingularValueDecomposition from './dc/svd';\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))\n .abs()\n .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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 WrapperMatrix2D from '../wrap/WrapperMatrix2D';\nimport Matrix from '../matrix';\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()\n .mmul(u)\n .div(\n u\n .transpose()\n .mmul(u)\n .get(0, 0),\n );\n w = w.div(w.norm());\n\n t = X.mmul(w).div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n );\n\n if (counter > 0) {\n diff = t\n .clone()\n .sub(tOld)\n .pow(2)\n .sum();\n }\n tOld = t.clone();\n\n if (Y) {\n q = Y.transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n q = q.div(q.norm());\n\n u = Y.mmul(q).div(\n q\n .transpose()\n .mmul(q)\n .get(0, 0),\n );\n } else {\n u = t;\n }\n }\n\n if (Y) {\n let p = X.transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n p = p.div(p.norm());\n let xResidual = X.clone().sub(t.clone().mmul(p.transpose()));\n let residual = u\n .transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n let yResidual = Y.clone().sub(\n t\n .clone()\n .mulS(residual.get(0, 0))\n .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\n .transpose()\n .mmul(t)\n .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","import isArray from 'is-any-array';\n\n/**\n * Computes the mean of the given values\n * @param {Array} input\n * @return {number}\n */\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\n/**\n * Computes the mean of the given values\n * @param {Array} input\n * @return {number}\n */\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","(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 quickSelectMedian from 'median-quickselect';\nimport isArray from 'is-any-array';\n\n/**\n * Computes the median of the given values\n * @param {Array} input\n * @return {number}\n */\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(X.clone().apply(pow2array).sum());\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 var means = dataset.mean('column');\n var std = dataset.standardDeviation('column', { mean: means, unbiased: true });\n var 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 (var i = 0; i < array.length; ++i) {\n for (var j = 0; j < array[i].length; ++j) {\n var elem = array[i][j];\n array[i][j] = elem !== null ? new Matrix(array[i][j]) : undefined;\n }\n }\n } else {\n for (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 './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 var {\n tolerance = 1e-5,\n scale = true,\n } = 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('The number of X rows must be equal to the number of Y rows');\n }\n\n this.meanX = trainingSet.mean('column');\n this.stdDevX = trainingSet.standardDeviation('column', { mean: this.meanX, unbiased: true });\n this.meanY = trainingValues.mean('column');\n this.stdDevY = trainingValues.standardDeviation('column', { mean: this.meanY, unbiased: true });\n\n if (this.scale) {\n trainingSet = trainingSet.clone().subRowVector(this.meanX).divRowVector(this.stdDevX);\n trainingValues = trainingValues.clone().subRowVector(this.meanY).divRowVector(this.stdDevY);\n }\n\n if (this.latentVectors === undefined) {\n this.latentVectors = Math.min(trainingSet.rows - 1, trainingSet.columns);\n }\n\n var rx = trainingSet.rows;\n var cx = trainingSet.columns;\n var ry = trainingValues.rows;\n var cy = trainingValues.columns;\n\n var ssqXcal = trainingSet.clone().mul(trainingSet).sum(); // for the r²\n var sumOfSquaresY = trainingValues.clone().mul(trainingValues).sum();\n\n var tolerance = this.tolerance;\n var n = this.latentVectors;\n var T = Matrix.zeros(rx, n);\n var P = Matrix.zeros(cx, n);\n var U = Matrix.zeros(ry, n);\n var Q = Matrix.zeros(cy, n);\n var B = Matrix.zeros(n, n);\n var W = P.clone();\n var k = 0;\n\n while (Utils.norm(trainingValues) > tolerance && k < n) {\n var transposeX = trainingSet.transpose();\n var transposeY = trainingValues.transpose();\n\n var tIndex = maxSumColIndex(trainingSet.clone().mul(trainingSet));\n var uIndex = maxSumColIndex(trainingValues.clone().mul(trainingValues));\n\n var t1 = trainingSet.getColumnVector(tIndex);\n var u = trainingValues.getColumnVector(uIndex);\n var t = Matrix.zeros(rx, 1);\n\n while (Utils.norm(t1.clone().sub(t)) > tolerance) {\n var w = transposeX.mmul(u);\n w.div(Utils.norm(w));\n t = t1;\n t1 = trainingSet.mmul(w);\n var q = transposeY.mmul(t1);\n q.div(Utils.norm(q));\n u = trainingValues.mmul(q);\n }\n\n t = t1;\n var num = transposeX.mmul(t);\n var den = t.transpose().mmul(t).get(0, 0);\n var p = num.div(den);\n var 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.transpose().mmul(t).get(0, 0);\n var b = num.div(den).get(0, 0);\n trainingSet.sub(t.mmul(p.transpose()));\n trainingValues.sub(t.clone().mul(b).mmul(q.transpose()));\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 // TODO: review of R2Y\n // this.R2Y = t.transpose().mmul(t).mul(q[k][0]*q[k][0]).divS(ssqYcal)[0][0];\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.transpose().mmul(t).mmul(p.transpose().mmul(p)).div(ssqXcal).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 var X = Matrix.checkMatrix(dataset);\n if (this.scale) {\n X = X.subRowVector(this.meanX).divRowVector(this.stdDevX);\n }\n var 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 './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(model.TURegressionCoeff, false);\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 var kernelX = this.kernel.compute(trainingSet);\n\n var Identity = Matrix.eye(kernelX.rows, kernelX.rows, 1);\n var 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 var result = new SingularValueDecomposition(trainingValues.transpose().mmul(kernelX[0][0]).mmul(trainingValues), {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false\n });\n var YLoadingMat = result.leftSingularVectors;\n var Sigma = result.diagonalMatrix;\n\n YLoadingMat = YLoadingMat.subMatrix(0, YLoadingMat.rows - 1, 0, this.predictiveComp - 1);\n Sigma = Sigma.subMatrix(0, this.predictiveComp - 1, 0, this.predictiveComp - 1);\n\n var YScoreMat = trainingValues.mmul(YLoadingMat);\n\n var predScoreMat = new Array(this.orthogonalComp + 1);\n var TURegressionCoeff = new Array(this.orthogonalComp + 1);\n var YOrthScoreMat = new Array(this.orthogonalComp);\n var YOrthLoadingVec = new Array(this.orthogonalComp);\n var YOrthEigen = new Array(this.orthogonalComp);\n var YOrthScoreNorm = new Array(this.orthogonalComp);\n\n var 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 (var i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = kernelX[0][i].transpose().mmul(YScoreMat).mmul(SigmaPow);\n\n var TpiPrime = predScoreMat[i].transpose();\n TURegressionCoeff[i] = inverse(TpiPrime.mmul(predScoreMat[i])).mmul(TpiPrime).mmul(YScoreMat);\n\n result = new SingularValueDecomposition(TpiPrime.mmul(Matrix.sub(kernelX[i][i], predScoreMat[i].mmul(TpiPrime))).mmul(predScoreMat[i]), {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false\n });\n var CoTemp = result.leftSingularVectors;\n var 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(kernelX[i][i], predScoreMat[i].mmul(TpiPrime)).mmul(predScoreMat[i]).mmul(YOrthLoadingVec[i]).mul(Math.pow(YOrthEigen[i], -0.5));\n\n var toiPrime = YOrthScoreMat[i].transpose();\n YOrthScoreNorm[i] = Matrix.sqrt(toiPrime.mmul(YOrthScoreMat[i]));\n\n YOrthScoreMat[i] = YOrthScoreMat[i].divRowVector(YOrthScoreNorm[i]);\n\n var ITo = Matrix.sub(Identity, YOrthScoreMat[i].mmul(YOrthScoreMat[i].transpose()));\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 var lastScoreMat = predScoreMat[this.orthogonalComp] = kernelX[0][this.orthogonalComp].transpose().mmul(YScoreMat).mmul(SigmaPow);\n\n var lastTpPrime = lastScoreMat.transpose();\n TURegressionCoeff[this.orthogonalComp] = inverse(lastTpPrime.mmul(lastScoreMat)).mmul(lastTpPrime).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 var KTestTrain = this.kernel.compute(toPredict, this.trainingSet);\n\n var 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 var YOrthScoreVector = new Array(this.orthogonalComp);\n var predScoreMat = new Array(this.orthogonalComp);\n\n var i;\n for (i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = KTestTrain[i][0].mmul(this.YScoreMat).mmul(this.SigmaPow);\n\n YOrthScoreVector[i] = Matrix.sub(KTestTrain[i][i], predScoreMat[i].mmul(this.predScoreMat[i].transpose())).mmul(this.predScoreMat[i]).mmul(this.YOrthLoadingVec[i]).mul(Math.pow(this.YOrthEigen[i], -0.5));\n\n YOrthScoreVector[i] = YOrthScoreVector[i].divRowVector(this.toNorm[i]);\n\n var scoreMatPrime = this.YOrthScoreMat[i].transpose();\n KTestTrain[i + 1][0] = Matrix.sub(KTestTrain[i][0], YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[0][i].transpose()));\n\n var p1 = Matrix.sub(KTestTrain[i][0], KTestTrain[i][i].mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime));\n var p2 = YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[i][i]);\n var 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 var prediction = predScoreMat[i].mmul(this.TURegressionCoeff[i]).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 */\nclass 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('Confusion matrix and labels should have the same length');\n }\n this.labels = labels;\n this.matrix = matrix;\n }\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 (var i = 0; i < this.matrix.length; i++) {\n for (var 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 var count = 0;\n for (var 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 var count = 0;\n for (var i = 0; i < this.matrix.length; i++) {\n for (var 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 var count = 0;\n for (var 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 var count = 0;\n for (var 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 2 * TP / (2 * TP + this.getFalsePositiveCount(label) + this.getFalseNegativeCount(label));\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 (TP * TN - FP * FN) / Math.sqrt((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN));\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 this.getTruePositiveRate(label) + this.getTrueNegativeRate(label) - 1;\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 this.getPositivePredictiveValue(label) + this.getNegativePredictiveValue(label) - 1;\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 [\n this.getTruePositiveCount(label),\n this.getFalseNegativeCount(label)\n ],\n [\n this.getFalsePositiveCount(label),\n this.getTrueNegativeCount(label)\n ]\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 (var i = 0; i < this.matrix.length; i++) {\n for (var 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 /**\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\nmodule.exports = ConfusionMatrix;\n","'use strict';\nconst defaultOptions = {\n mode: 'index'\n};\n\nmodule.exports = function *(M, N, options) {\n options = Object.assign({}, defaultOptions, options);\n var a = new Array(N);\n var c = new Array(M);\n var b = new Array(N);\n var p = new Array(N + 2);\n var x, y, z;\n\n // init a and b\n for (var i = 0; i < N; i++) {\n a[i] = i;\n if (i < N - M) b[i] = 0;\n else b[i] = 1;\n }\n\n // init c\n for (i = 0; i < M; i++) {\n c[i] = N - M + i;\n }\n\n // init p\n for (i = 0; i < p.length; i++) {\n if (i === 0) p[i] = N + 1;\n else if (i <= N - M) p[i] = 0;\n else if (i <= N) p[i] = i - N + M;\n else p[i] = -2;\n }\n\n function twiddle() {\n var i, j, k;\n j = 1;\n while (p[j] <= 0) {\n j++;\n }\n if (p[j - 1] === 0) {\n for (i = j - 1; i !== 1; i--) {\n p[i] = -1;\n }\n p[j] = 0;\n x = z = 0;\n p[1] = 1;\n y = j - 1;\n } else {\n if (j > 1) {\n p[j - 1] = 0;\n }\n do {\n j++;\n }\n while (p[j] > 0);\n k = j - 1;\n i = j;\n while (p[i] === 0) {\n p[i++] = -1;\n }\n if (p[i] === -1) {\n p[i] = p[k];\n z = p[k] - 1;\n x = i - 1;\n y = k - 1;\n p[k] = -1;\n } else {\n if (i === p[0]) {\n return 0;\n } else {\n p[j] = p[i];\n z = p[i] - 1;\n p[i] = 0;\n x = j - 1;\n y = i - 1;\n }\n }\n }\n return 1;\n }\n\n if (options.mode === 'index') {\n yield c.slice();\n while (twiddle()) {\n c[z] = a[x];\n yield c.slice();\n }\n } else if (options.mode === 'mask') {\n yield b.slice();\n while (twiddle()) {\n b[x] = 1;\n b[y] = 0;\n yield b.slice();\n }\n } else {\n throw new Error('Invalid mode');\n }\n};\n","'use strict';\n\nconst ConfusionMatrix = require('ml-confusion-matrix');\n\nconst CV = {};\nconst combinations = require('ml-combinations');\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 */\nCV.leaveOneOut = function (Classifier, features, labels, classifierOptions) {\n if (typeof labels === 'function') {\n var callback = labels;\n labels = features;\n features = Classifier;\n return CV.leavePOut(features, labels, 1, callback);\n }\n return CV.leavePOut(Classifier, features, labels, classifierOptions, 1);\n};\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 */\nCV.leavePOut = function (Classifier, features, labels, classifierOptions, p) {\n if (typeof classifierOptions === 'function') {\n var 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 var N = features.length;\n var gen = combinations(p, N);\n var allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n for (const testIdx of gen) {\n var 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(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback);\n } else {\n validate(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, 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 */\nCV.kFold = function (Classifier, features, labels, classifierOptions, k) {\n if (typeof classifierOptions === 'function') {\n var 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 var N = features.length;\n var allIdx = new Array(N);\n for (var i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n\n var l = Math.floor(N / k);\n // create random k-folds\n var current = [];\n var folds = [];\n while (allIdx.length) {\n var 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 if (current.length) folds.push(current);\n folds = folds.slice(0, k);\n\n\n for (i = 0; i < folds.length; i++) {\n var testIdx = folds[i];\n var trainIdx = [];\n for (var j = 0; j < folds.length; j++) {\n if (j !== i) trainIdx = trainIdx.concat(folds[j]);\n }\n\n if (callback) {\n validateWithCallback(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback);\n } else {\n validate(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, distinct);\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 var 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(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, distinct) {\n const {testFeatures, trainFeatures, testLabels, trainLabels} = getTrainTest(features, labels, testIdx, trainIdx);\n\n var 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 var predictedLabels = classifier.predict(testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction validateWithCallback(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback) {\n const {testFeatures, trainFeatures, testLabels, trainLabels} = getTrainTest(features, labels, testIdx, trainIdx);\n const predictedLabels = callback(trainFeatures, trainLabels, testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct) {\n\n for (var 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\n\nfunction 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\nmodule.exports = CV;\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","/**\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 var error = 0;\n const func = parameterizedFunction(parameters);\n\n for (var 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 var ans = new Array(n);\n\n for (var param = 0; param < n; param++) {\n ans[param] = new Array(m);\n var auxParams = params.concat();\n auxParams[param] += gradientDifference;\n var funcParam = paramFunction(auxParams);\n\n for (var 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 var ans = new Array(m);\n\n for (var 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 var value = damping * gradientDifference * gradientDifference;\n var identity = Matrix.eye(params.length, params.length, value);\n\n const func = parameterizedFunction(params);\n var evaluatedData = data.x.map((e) => func(e));\n\n var gradientFunc = gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n parameterizedFunction\n );\n var matrixFunc = matrixFunction(data, evaluatedData);\n var 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 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 !Array.isArray(data.x) ||\n data.x.length < 2 ||\n !Array.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 var 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 (!Array.isArray(parameters)) {\n throw new Error('initialValues must be an array');\n }\n\n var error = errorCalculation(data, parameters, parameterizedFunction);\n\n var converged = error <= errorTolerance;\n\n for (\n var iteration = 0;\n iteration < maxIterations && !converged;\n iteration++\n ) {\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' || Number.isNaN(number)) {\n\t\tthrow new TypeError('Expected a number');\n\t}\n}\n\nexports.ascending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\treturn left - right;\n};\n\nexports.descending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\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\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;\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","import isArray from 'is-any-array';\n\n/**\n * Computes the mode of the given values\n * @param {Array} input\n * @return {number}\n */\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","import max from 'ml-array-max';\nimport sum from 'ml-array-sum';\n\n/**\n * Computes the norm of the given values\n * @param {Array} input\n * @param {object} [options={}]\n * @param {string} [options.algorithm='absolute'] absolute, sum or max\n * @return {number}\n */\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\n if (!Array.isArray(input)) {\n throw new Error('input must be an array');\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);\n if (absoluteSumValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / absoluteSumValue;\n });\n }\n\n case 'max':\n {\n var maxValue = max(input);\n if (maxValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / maxValue;\n });\n }\n\n case 'sum':\n {\n var sumValue = sum(input);\n if (sumValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / sumValue;\n });\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 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/**\n * Fill an array with sequential numbers\n * @param {Array} [input] - optional destination array (if not provided a new array will be created)\n * @param {object} [options={}]\n * @param {number} [options.from=0] - first value in the array\n * @param {number} [options.to=10] - last value in the array\n * @param {number} [options.size=input.length] - size of the array (if not provided calculated from step)\n * @param {number} [options.step] - if not provided calculated from size\n * @return {Array}\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 && 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 input.length = 0; // only works with normal array\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","import arrayMean from 'ml-array-mean';\nimport isArray from 'is-any-array';\n\n/**\n * Computes the variance of the given values\n * @param {Array} values\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @param {number} [options.mean = arrayMean] - precalculated mean, if any.\n * @return {number}\n */\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\n/**\n * Computes the standard deviation of the given values\n * @param {Array} values\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @param {number} [options.mean = arrayMean] - precalculated mean, if any.\n * @return {number}\n */\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 * 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 var xLength = x.length;\n\n var step = (to - from) / (numberOfPoints - 1);\n var halfStep = step / 2;\n\n var output = new Array(numberOfPoints);\n\n var initialOriginalStep = x[1] - x[0];\n var lastOriginalStep = x[xLength - 1] - x[xLength - 2];\n\n // Init main variables\n var min = from - halfStep;\n var max = from + halfStep;\n\n var previousX = Number.MIN_VALUE;\n var previousY = 0;\n var nextX = x[0] - initialOriginalStep;\n var nextY = 0;\n\n var currentValue = 0;\n var slope = 0;\n var intercept = 0;\n var sumAtMin = 0;\n var sumAtMax = 0;\n\n var i = 0; // index of input\n var j = 0; // index of output\n\n function getSlope(x0, y0, x1, y1) {\n return (y1 - y0) / (x1 - x0);\n }\n\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 var 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 var xLength = x.length;\n\n var step = (to - from) / (numberOfPoints - 1);\n var halfStep = step / 2;\n var lastStep = x[x.length - 1] - x[x.length - 2];\n\n var start = from - halfStep;\n var output = new Array(numberOfPoints);\n\n // Init main variables\n var min = start;\n var max = start + step;\n\n var previousX = -Number.MAX_VALUE;\n var previousY = 0;\n var nextX = x[0];\n var nextY = y[0];\n var frontOutsideSpectra = 0;\n var backOutsideSpectra = true;\n\n var currentValue = 0;\n\n // for slot algorithm\n var currentPoints = 0;\n\n var i = 1; // index of input\n var 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","export default function getZones(from, to, numberOfPoints, 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, numberOfPoints }];\n }\n\n // need to deal with overlapping exclusions and out of bound exclusions\n\n let toRemove = exclusions.reduce(\n (previous, exclusion) => (previous += exclusion.to - exclusion.from),\n 0\n );\n let total = to - from;\n let unitsPerPoint = (total - toRemove) / numberOfPoints;\n let zones = [];\n let currentFrom = from;\n let totalPoints = 0;\n for (let exclusion of exclusions) {\n let currentNbPoints = Math.round(\n (exclusion.from - currentFrom) / unitsPerPoint\n );\n totalPoints += currentNbPoints;\n if (currentNbPoints > 0) {\n zones.push({\n from: currentFrom,\n to: exclusion.from,\n numberOfPoints: currentNbPoints\n });\n }\n\n currentFrom = exclusion.to;\n }\n if (numberOfPoints - totalPoints > 0) {\n zones.push({\n from: currentFrom,\n to: to,\n numberOfPoints: numberOfPoints - totalPoints\n });\n }\n\n return zones;\n}\n","import sequentialFill from 'ml-array-sequential-fill';\n\nimport equallySpacedSmooth from './equallySpacedSmooth';\nimport equallySpacedSlot from './equallySpacedSlot';\nimport getZones from './getZones';\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 * @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 * @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 } = 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 let zones = getZones(from, to, numberOfPoints, exclusions);\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 xResult = xResult.concat(zoneResult.x);\n yResult = yResult.concat(zoneResult.y);\n }\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 var 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 } from 'ml-pls';\nexport { default as CrossValidation } from 'ml-cross-validation';\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';\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","isArray","TypeError","length","maxValue","i","min","minValue","rescale","options","arguments","undefined","output","Array","currentMin","currentMax","RangeError","_options$min","autoMinMax","_options$max","factor","checkRowIndex","matrix","index","outer","rows","checkColumnIndex","columns","checkRowVector","vector","to1DArray","checkColumnVector","checkIndices","rowIndices","columnIndices","row","checkRowIndices","column","checkColumnIndices","rowOut","some","r","from","columnOut","c","checkRange","startRow","endRow","startColumn","endColumn","checkNumber","newArray","value","array","push","name","sumByRow","sum","j","get","sumByColumn","sumAll","v","productByRow","productByColumn","productAll","varianceByRow","unbiased","mean","cols","variance","sum1","sum2","x","varianceByColumn","varianceAll","size","centerByRow","set","centerByColumn","centerAll","getScaleByRow","scale","Math","pow","sqrt","scaleByRow","getScaleByColumn","scaleByColumn","getScaleAll","divider","scaleAll","inspectMatrix","indent","repeat","indentData","constructor","inspectData","maxRows","maxColumns","maxNumSize","maxI","maxJ","result","line","formatNumber","join","num","numStr","String","padEnd","precise","toPrecision","exponential","toExponential","eIndex","indexOf","e","substring","installMathOperations","AbstractMatrix","Matrix","add","addS","addM","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","tan","tanh","trunc","arg0","powS","powM","from1DArray","newRows","newColumns","newData","rowVector","columnVector","zeros","ones","fill","rand","random","randInt","Number","isInteger","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","Error","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","iter","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","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","SMALLEST_UNSAFE_INTEGER","LARGEST_SAFE_INTEGER","UINT32_MAX","UINT32_SIZE","INT32_SIZE","INT32_MAX","UINT21_SIZE","UINT21_MAX","int32","engine","next","addend","int53","int53Full","uint32","uint53","uint53Full","isPowerOfTwoMinusOne","bitmask","masking","downscaleToLoopCheckedRange","extendedRange","maximum","downscaleToRange","isEvenlyDivisibleByMaxInt32","upscaleWithHighMasking","upscaleToLoopCheckedRange","upscaleWithinU53","highRange","upscaleWithinI53AndLoopCheck","integer","DEFAULT_STRING_POOL","string","pool","poolLength","charAt","LOWER_HEX_POOL","lowerHex","upperHex","toUpperCase","stringRepeat","pattern","_","nativeMath","I32Array","buffer","ArrayBuffer","view","Int32Array","createEntropy","Date","getTime","imul","UINT16_MAX","ah","al","bh","bl","ARRAY_SIZE","ARRAY_MAX","M","ARRAY_SIZE_MINUS_M","A","MersenneTwister19937","uses","seed","initial","seedWithArray","source","autoSeed","refreshData","temper","getUseCount","discard","previous","sourceLength","checkFloat","examplesBaggingWithReplacement","trainingValue","Random","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","slice","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","_j","_len","_ref1","_results","_results1","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","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","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","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","N","twiddle","CV","leaveOneOut","Classifier","classifierOptions","leavePOut","distinct","getDistinct","confusionMatrix","initMatrix","gen","combinations","allIdx","testIdx","trainIdx","validateWithCallback","validate","kFold","current","folds","randi","testFeatures","trainFeatures","testLabels","trainLabels","getTrainTest","classifier","predictedLabels","updateConfusionMatrix","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","keys","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","hasOwnProperty","numWeights","converters","getConverters","extractor","creator","nodeType","hx","distanceMethod","getMaxDistance","done","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","self","_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","fn","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","key","BigInt","sorted","cssls","XtX","XtY","Pset","choXtX","luXtX","sortedPset","sortedEset","cols2Solve","vars","initialisation","Fset","D","setDifference","C","includes","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","err","fpr","tpr","fnr","tnr","ppv","npv","pcfall","pcmiss","lift","rpp","rnp","arrayCase","cond","matrixCase","padArray","windowSize","derivative","pad","padValue","savitzkyGolay","J","inic","Jtranspose","Jinv","det","eightBits","arr1","arr2","getBit","mask","setBit","toBinaryString","substr","parseBinaryString","toHexString","parseHexString","toDebug","binary","maxCount","_options$algorithm","algorithm","absoluteSumValue","absoluteSum","_typeof","iterator","sequentialFill","_options","_options$from","_options$to","_options$size","_options$unbiased","_options$mean","sqrError","mergeByCentroids","originalPoints","mergedPoints","originalIndex","mergedIndex","closestX","descending","maxMerge","groupWidth","merged","maxAbscissa","maxY","calculateIndex","sortX","sortFunc","grouped","response","uniqueX","weightedMerge","weightedAbscissa","integral","x0","x1","equallySpacedSmooth","numberOfPoints","xLength","halfStep","initialOriginalStep","lastOriginalStep","previousX","previousY","nextX","nextY","currentValue","sumAtMin","sumAtMax","getSlope","y0","y1","main","equallySpacedSlot","lastStep","frontOutsideSpectra","backOutsideSpectra","getZones","exclusions","exclusion","JSON","parse","stringify","toRemove","unitsPerPoint","zones","currentFrom","totalPoints","currentNbPoints","equallySpaced","arrayXY","variant","xResult","yResult","zone","zoneResult","processZone","filterX","currentZoneIndex","newX","newY","position","MatrixLib","normed","ArrayXY","centroidsMerge"],"mappings":";;;;;;;;;;;;EAEA,MAAMA,QAAQ,GAAGC,MAAM,CAACC,SAAP,CAAiBF,QAAlC;;EAEA,SAASG,UAAT,CAAoBC,MAApB,EAA4B;EAC1B,SAAOJ,QAAQ,CAACK,IAAT,CAAcD,MAAd,EAAsBE,QAAtB,CAA+B,QAA/B,CAAP;EACD;;EAED,OAAc,GAAGH,UAAjB;;ECNA;;;;;;EAMA,SAASI,GAAT,CAAaC,KAAb,EAAoB;EAClB,MAAI,CAACC,GAAO,CAACD,KAAD,CAAZ,EAAqB;EACnB,UAAM,IAAIE,SAAJ,CAAc,wBAAd,CAAN;EACD;;EAED,MAAIF,KAAK,CAACG,MAAN,KAAiB,CAArB,EAAwB;EACtB,UAAM,IAAID,SAAJ,CAAc,yBAAd,CAAN;EACD;;EAED,MAAIE,QAAQ,GAAGJ,KAAK,CAAC,CAAD,CAApB;;EAEA,OAAK,IAAIK,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGL,KAAK,CAACG,MAA1B,EAAkCE,CAAC,EAAnC,EAAuC;EACrC,QAAIL,KAAK,CAACK,CAAD,CAAL,GAAWD,QAAf,EAAyBA,QAAQ,GAAGJ,KAAK,CAACK,CAAD,CAAhB;EAC1B;;EAED,SAAOD,QAAP;EACD;;ECtBD;;;;;;EAMA,SAASE,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AA,KANqB;EAOrBI,EAAAA,OAPqB;EAQrBC,EAAAA,aARqB;EASrBsC,EAAAA,aATqB;EAUrBQ,EAAAA;EAVqB,CAAhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/ml.min.js b/dist/ml.min.js index 17c5d8e..875774c 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=t||self).ML={})}(this,(function(exports){"use strict";const toString=Object.prototype.toString;function isAnyArray(t){return toString.call(t).endsWith("Array]")}var src=isAnyArray;function max(t){if(!src(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");for(var e=t[0],r=1;re&&(e=t[r]);return e}function min(t){if(!src(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");for(var e=t[0],r=1;r1&&void 0!==arguments[1]?arguments[1]:{};if(!src(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(!src(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var i=min(t),n=max(t);if(i===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=r.min,o=void 0===s?r.autoMinMax?i:0:s,a=r.max,h=void 0===a?r.autoMinMax?n:1:a;if(o>=h)throw new RangeError("min option must be smaller than max option");for(var l=(h-o)/(n-i),u=0;ui)throw new RangeError("Row index out of range")}function checkColumnIndex(t,e,r){let i=r?t.columns:t.columns-1;if(e<0||e>i)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,i,n){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(checkNumber("startRow",e),checkNumber("endRow",r),checkNumber("startColumn",i),checkNumber("endColumn",n),e>r||i>n||e<0||e>=t.rows||r<0||r>=t.rows||i<0||i>=t.columns||n<0||n>=t.columns)throw new RangeError("Submatrix indices are out of range")}function newArray(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[];for(let i=0;i>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;t2&&void 0!==arguments[2]?arguments[2]:{};if("object"!=typeof r)throw new TypeError("options must be an object");const{random:i=Math.random}=r;let n=new Matrix(t,e);for(let r=0;r2&&void 0!==arguments[2]?arguments[2]:{};if("object"!=typeof r)throw new TypeError("options must be an object");const{min:i=0,max:n=1e3,random:s=Math.random}=r;if(!Number.isInteger(i))throw new TypeError("min must be an integer");if(!Number.isInteger(n))throw new TypeError("max must be an integer");if(i>=n)throw new RangeError("min must be smaller than max");let o=n-i,a=new Matrix(t,e);for(let r=0;rr?(n=!0,r=e):(i=!1,n=!0);t++}return i}isReducedEchelonForm(){let t=0,e=0,r=-1,i=!0,n=!1;for(;tr?(n=!0,r=e):(i=!1,n=!0);for(let r=e+1;rt.get(i,r)&&(i=n);if(0===t.get(i,r))r++;else{t.swapRows(e,i);let n=t.get(e,r);for(let i=r;i=0;)if(0===t.maxRow(i))i--;else{let n=0,s=!1;for(;n0&&void 0!==arguments[0]?arguments[0]:{};if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let i=new Matrix(this.rows*e,this.columns*r);for(let t=0;tt&&(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,i),e[0]=r,e[1]=i);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 i=1;ie&&(e=this.get(t,i),r[1]=i);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 i=1;ie&&(e=this.get(i,t),r[0]=i);return r}minColumn(t){checkColumnIndex(this,t);let e=this.get(0,t);for(let r=1;r0&&void 0!==arguments[0]?arguments[0]:"frobenius",e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:{};if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let i=new Matrix(this.rows,this.columns);for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:{};if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let i=new Matrix(this.rows,this.columns);for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:compareNumbers;for(let e=0;e0&&void 0!==arguments[0]?arguments[0]:compareNumbers;for(let e=0;er||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let i=new Matrix(t.length,r-e+1);for(let n=0;n=this.rows)throw new RangeError("Row index out of range: ".concat(t[n]));i.set(n,s-e,this.get(t[n],s))}return i}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 i=new Matrix(r-e+1,t.length);for(let n=0;n=this.columns)throw new RangeError("Column index out of range: ".concat(t[n]));i.set(s-e,n,this.get(s,t[n]))}return i}setSubMatrix(t,e,r){checkRange(this,e,e+(t=Matrix.checkMatrix(t)).rows-1,r,r+t.columns-1);for(let i=0;i1&&void 0!==arguments[1]?arguments[1]:{};if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:i=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!Array.isArray(i))throw new TypeError("mean must be an array");return varianceByRow(this,r,i);case"column":if(!Array.isArray(i))throw new TypeError("mean must be an array");return varianceByColumn(this,r,i);case void 0:if("number"!=typeof i)throw new TypeError("mean must be a number");return varianceAll(this,r,i);default:throw new Error("invalid option: ".concat(t))}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t1&&void 0!==arguments[1]?arguments[1]:{};if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!Array.isArray(r))throw new TypeError("center must be an array");return centerByRow(this,r),this;case"column":if(!Array.isArray(r))throw new TypeError("center must be an array");return centerByColumn(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return centerAll(this,r),this;default:throw new Error("invalid option: ".concat(t))}}scale(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=getScaleByRow(this);else if(!Array.isArray(r))throw new TypeError("scale must be an array");return scaleByRow(this,r),this;case"column":if(void 0===r)r=getScaleByColumn(this);else if(!Array.isArray(r))throw new TypeError("scale must be an array");return scaleByColumn(this,r),this;case void 0:if(void 0===r)r=getScaleAll(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return scaleAll(this,r),this;default:throw new Error("invalid option: ".concat(t))}}}function compareNumbers(t,e){return t-e}AbstractMatrix.prototype.klass="Matrix","undefined"!=typeof Symbol&&(AbstractMatrix.prototype[Symbol.for("nodejs.util.inspect.custom")]=inspectMatrix),AbstractMatrix.random=AbstractMatrix.rand,AbstractMatrix.randomInt=AbstractMatrix.randInt,AbstractMatrix.diagonal=AbstractMatrix.diag,AbstractMatrix.prototype.diagonal=AbstractMatrix.prototype.diag,AbstractMatrix.identity=AbstractMatrix.eye,AbstractMatrix.prototype.negate=AbstractMatrix.prototype.neg,AbstractMatrix.prototype.tensorProduct=AbstractMatrix.prototype.kroneckerProduct;class Matrix extends AbstractMatrix{constructor(t,e){if(super(),Matrix.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>0){if(this.data=[],!(Number.isInteger(e)&&e>0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r1&&void 0!==arguments[1]?arguments[1]:{};const{rows:r=1}=e;if(t.length%r!=0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let i=this._calculateIndex(t,e);return this.data[i]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class WrapperMatrix2D extends AbstractMatrix{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function wrap(t,e){if(Array.isArray(t))return t[0]&&Array.isArray(t[0])?new WrapperMatrix2D(t):new WrapperMatrix1D(t,e);throw new Error("the argument is not an array")}class LuDecomposition{constructor(t){let e,r,i,n,s,o,a,h,l,u=(t=WrapperMatrix2D.checkMatrix(t)).clone(),c=u.rows,f=u.columns,m=new Float64Array(c),g=1;for(e=0;eMath.abs(h[n])&&(n=e);if(n!==r){for(i=0;i=0;n--){for(i=0;ie?i.set(n,e,t.get(n,e)):n===e?i.set(n,e,1):i.set(n,e,0);return i}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,i=new Matrix(e,r);for(let n=0;nMath.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,i,n,s=(t=WrapperMatrix2D.checkMatrix(t)).clone(),o=t.rows,a=t.columns,h=new Float64Array(a);for(i=0;i=0;s--){for(n=0;n=0;r--){for(t=0;t1&&void 0!==arguments[1]?arguments[1]:{},r=(t=WrapperMatrix2D.checkMatrix(t)).rows,i=t.columns;const{computeLeftSingularVectors:n=!0,computeRightSingularVectors:s=!0,autoTranspose:o=!1}=e;let a,h=Boolean(n),l=Boolean(s),u=!1;if(r=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(p[t])<=e||Number.isNaN(p[t])){p[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(p[r]):0)+(r!==t+1?Math.abs(p[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=p[b-2];p[b-2]=0;for(let r=b-2;r>=t;r--){let n=hypotenuse(m[r],e),s=m[r]/n,o=e/n;if(m[r]=n,r!==t&&(e=-o*p[r-1],p[r-1]=s*p[r-1]),l)for(let t=0;t=m[t+1]);){let e=m[t];if(m[t]=m[t+1],m[t+1]=e,l&&te&&n.set(s,r,t.get(s,r)/this.s[r]);let s=this.U,o=s.rows,a=s.columns,h=new Matrix(r,o);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){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t=WrapperMatrix2D.checkMatrix(t),e?new SingularValueDecomposition(t).inverse():solve(t,Matrix.eye(t.rows))}function solve(t,e){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];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,i,n;if(2===t.columns)return e=t.get(0,0),r=t.get(0,1),i=t.get(1,0),e*(n=t.get(1,1))-r*i;if(3===t.columns){let n,s,o;return n=new MatrixSelectionView(t,[1,2],[1,2]),s=new MatrixSelectionView(t,[1,2],[0,2]),o=new MatrixSelectionView(t,[1,2],[0,1]),e=t.get(0,0),r=t.get(0,1),i=t.get(0,2),e*determinant(n)-r*determinant(s)+i*determinant(o)}return new LuDecomposition(t).determinant}throw Error("determinant can only be calculated for a square matrix")}function xrange(t,e){let r=[];for(let i=0;i3&&void 0!==arguments[3]?arguments[3]:1e-9;if(t>(arguments.length>4&&void 0!==arguments[4]?arguments[4]:1e-9))return new Array(e.rows+1).fill(0);{let t=e.addRow(r,[0]);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:{};const{thresholdValue:r=1e-9,thresholdError:i=1e-9}=e;let n=(t=Matrix.checkMatrix(t)).rows,s=new Matrix(n,n);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:Number.EPSILON;t=Matrix.checkMatrix(t);let r=new SingularValueDecomposition(t,{autoTranspose:!0}),i=r.leftSingularVectors,n=r.rightSingularVectors,s=r.diagonal;for(let t=0;te?s[t]=1/s[t]:s[t]=0;return n.mmul(Matrix.diag(s).mmul(i.transpose()))}function covariance(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=Matrix.checkMatrix(t);let i=!1;if("object"!=typeof e||Matrix.isMatrix(e)||Array.isArray(e)?e=Matrix.checkMatrix(e):(r=e,e=t,i=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=r;n&&(t=t.center("column"),i||(e=e.center("column")));const s=t.transpose().mmul(e);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=Matrix.checkMatrix(t);let i=!1;if("object"!=typeof e||Matrix.isMatrix(e)||Array.isArray(e)?e=Matrix.checkMatrix(e):(r=e,e=t,i=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:s=!0}=r;n&&(t.center("column"),i||e.center("column")),s&&(t.scale("column"),i||e.scale("column"));const o=t.standardDeviation("column",{unbiased:!0}),a=i?o:e.standardDeviation("column",{unbiased:!0}),h=t.transpose().mmul(e);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:{};const{assumeSymmetric:r=!1}=e;if(!(t=WrapperMatrix2D.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");let i,n,s=t.columns,o=new Matrix(s,s),a=new Float64Array(s),h=new Float64Array(s),l=t,u=!1;if(u=!!r||t.isSymmetric()){for(i=0;i0?s.set(t,t+1,i[t]):i[t]<0&&s.set(t,t-1,i[t])}return s}}function tred2(t,e,r,i){let n,s,o,a,h,l,u,c;for(h=0;h0;a--){for(c=0,o=0,l=0;l0&&(s=-s),e[a]=c*s,o-=n*s,r[a-1]=n-s,h=0;hl)do{for(n=r[l],f=hypotenuse(c=(r[l+1]-n)/(2*e[l]),1),c<0&&(f=-f),r[l]=e[l]/(c+f),r[l+1]=e[l]*(c+f),m=r[l+1],s=n-r[l],o=l+2;o=l;o--)for(p=d,d=g,y=x,n=g*e[o],s=g*c,f=hypotenuse(c,e[o]),e[o+1]=x*f,x=e[o]/f,c=(g=c/f)*r[o]-x*n,r[o+1]=s+x*(g*n+x*r[o]),h=0;hb*v);r[l]=r[l]+M,e[l]=0}for(o=0;o=l;a--)r[a]=e.get(a,l-1)/u,o+=r[a]*r[a];for(s=Math.sqrt(o),r[l]>0&&(s=-s),o-=r[l]*s,r[l]=r[l]-s,h=l;h=l;a--)n+=r[a]*e.get(a,h);for(n/=o,a=l;a<=c;a++)e.set(a,h,e.get(a,h)-n*r[a])}for(a=0;a<=c;a++){for(n=0,h=c;h>=l;h--)n+=r[h]*e.get(a,h);for(n/=o,h=l;h<=c;h++)e.set(a,h,e.get(a,h)-n*r[h])}r[l]=u*r[l],e.set(l,l-1,u*s)}}for(a=0;a=1;l--)if(0!==e.get(l,l-1)){for(a=l+1;a<=c;a++)r[a]=e.get(a,l-1);for(h=l;h<=c;h++){for(s=0,a=l;a<=c;a++)s+=r[a]*i.get(a,h);for(s=s/r[l]/e.get(l,l-1),a=l;a<=c;a++)i.set(a,h,i.get(a,h)+s*r[a])}}}function hqr2(t,e,r,i,n){let s,o,a,h,l,u,c,f,m,g,d,p,w,x,y,M=t-1,v=t-1,b=Number.EPSILON,S=0,A=0,E=0,R=0,k=0,C=0,T=0,N=0;for(s=0;sv)&&(r[s]=n.get(s,s),e[s]=0),o=Math.max(s-1,0);o=0;){for(h=M;h>0&&(0===(C=Math.abs(n.get(h-1,h-1))+Math.abs(n.get(h,h)))&&(C=A),!(Math.abs(n.get(h,h-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,E=(f=n.get(M,M-1))/(C=Math.abs(f)+Math.abs(T)),R=T/C,E/=k=Math.sqrt(E*E+R*R),R/=k,o=M-1;o0){for(C=Math.sqrt(C),m=h&&(E=((k=f-(T=n.get(l,l)))*(C=m-T)-c)/n.get(l+1,l)+n.get(l,l+1),R=n.get(l+1,l+1)-T-k-C,k=n.get(l+2,l+1),E/=C=Math.abs(E)+Math.abs(R)+Math.abs(k),R/=C,k/=C,l!==h)&&!(Math.abs(n.get(l,l-1))*(Math.abs(R)+Math.abs(k))l+2&&n.set(s,s-3,0);for(a=l;a<=M-1&&(x=a!==M-1,a!==l&&(E=n.get(a,a-1),R=n.get(a+1,a-1),k=x?n.get(a+2,a-1):0,0!==(f=Math.abs(E)+Math.abs(R)+Math.abs(k))&&(E/=f,R/=f,k/=f)),0!==f);a++)if(C=Math.sqrt(E*E+R*R+k*k),E<0&&(C=-C),0!==C){for(a!==l?n.set(a,a-1,-C*f):h!==l&&n.set(a,a-1,-n.get(a,a-1)),f=(E+=C)/C,m=R/C,T=k/C,R/=E,k/=E,o=a;o=0;M--)if(E=r[M],0===(R=e[M]))for(h=M,n.set(M,M,1),s=M-1;s>=0;s--){for(c=n.get(s,s)-E,k=0,o=h;o<=M;o++)k+=n.get(s,o)*n.get(o,M);if(e[s]<0)T=c,C=k;else if(h=s,0===e[s]?n.set(s,M,0!==c?-k/c:-k/(b*A)):(f=n.get(s,s+1),m=n.get(s+1,s),u=(f*C-T*k)/(R=(r[s]-E)*(r[s]-E)+e[s]*e[s]),n.set(s,M,u),n.set(s+1,M,Math.abs(f)>Math.abs(T)?(-k-c*u)/f:(-C-m*u)/T)),b*(u=Math.abs(n.get(s,M)))*u>1)for(o=s;o<=M;o++)n.set(o,M,n.get(o,M)/u)}else if(R<0)for(h=M-1,Math.abs(n.get(M,M-1))>Math.abs(n.get(M-1,M))?(n.set(M-1,M-1,R/n.get(M,M-1)),n.set(M-1,M,-(n.get(M,M)-E)/n.get(M,M-1))):(y=cdiv(0,-n.get(M-1,M),n.get(M-1,M-1)-E,R),n.set(M-1,M-1,y[0]),n.set(M-1,M,y[1])),n.set(M,M-1,0),n.set(M,M,1),s=M-2;s>=0;s--){for(g=0,d=0,o=h;o<=M;o++)g+=n.get(s,o)*n.get(o,M-1),d+=n.get(s,o)*n.get(o,M);if(c=n.get(s,s)-E,e[s]<0)T=c,k=g,C=d;else if(h=s,0===e[s]?(y=cdiv(-g,-d,c,R),n.set(s,M-1,y[0]),n.set(s,M,y[1])):(f=n.get(s,s+1),m=n.get(s+1,s),p=(r[s]-E)*(r[s]-E)+e[s]*e[s]-R*R,w=2*(r[s]-E)*R,0===p&&0===w&&(p=b*A*(Math.abs(c)+Math.abs(R)+Math.abs(f)+Math.abs(m)+Math.abs(T))),y=cdiv(f*k-T*g+R*d,f*C-T*d-R*g,p,w),n.set(s,M-1,y[0]),n.set(s,M,y[1]),Math.abs(f)>Math.abs(T)+Math.abs(R)?(n.set(s+1,M-1,(-g-c*n.get(s,M-1)+R*n.get(s,M))/f),n.set(s+1,M,(-d-c*n.get(s,M)-R*n.get(s,M-1))/f)):(y=cdiv(-k-m*n.get(s,M-1),-C-m*n.get(s,M),T,R),n.set(s+1,M-1,y[0]),n.set(s+1,M,y[1]))),b*(u=Math.max(Math.abs(n.get(s,M-1)),Math.abs(n.get(s,M))))*u>1)for(o=s;o<=M;o++)n.set(o,M-1,n.get(o,M-1)/u),n.set(o,M,n.get(o,M)/u)}for(s=0;sv)for(o=s;o=0;o--)for(s=0;s<=v;s++){for(T=0,a=0;a<=Math.min(o,v);a++)T+=i.get(s,a)*n.get(a,o);i.set(s,o,T)}}}function cdiv(t,e,r,i){let n,s;return Math.abs(r)>Math.abs(i)?[(t+(n=i/r)*e)/(s=r+n*i),(e-n*t)/s]:[((n=r/i)*t+e)/(s=i+n*r),(n*e-t)/s]}class CholeskyDecomposition{constructor(t){if(!(t=WrapperMatrix2D.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,r,i,n=t,s=n.rows,o=new Matrix(s,s),a=!0;for(r=0;r0,o.set(r,r,Math.sqrt(Math.max(t,0))),i=r+1;i=0;s--)for(n=0;n1&&void 0!==arguments[1]?arguments[1]:{};t=WrapperMatrix2D.checkMatrix(t);let{Y:r}=e;const{scaleScores:i=!1,maxIterations:n=1e3,terminationCriteria:s=1e-10}=e;let o;if(r){if(!(r=Array.isArray(r)&&"number"==typeof r[0]?Matrix.columnVector(r):WrapperMatrix2D.checkMatrix(r)).isColumnVector()||r.rows!==t.rows)throw new Error("Y must be a column vector of length X.rows");o=r}else o=t.getColumnVector(0);let a,h,l,u,c=1;for(let e=0;es;e++)l=(l=t.transpose().mmul(o).div(o.transpose().mmul(o).get(0,0))).div(l.norm()),a=t.mmul(l).div(l.transpose().mmul(l).get(0,0)),e>0&&(c=a.clone().sub(u).pow(2).sum()),u=a.clone(),r?(h=(h=r.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0))).div(h.norm()),o=r.mmul(h).div(h.transpose().mmul(h).get(0,0))):o=a;if(r){let e=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0));e=e.div(e.norm());let i=t.clone().sub(a.clone().mmul(e.transpose())),n=o.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),s=r.clone().sub(a.clone().mulS(n.get(0,0)).mmul(h.transpose()));this.t=a,this.p=e.transpose(),this.w=l.transpose(),this.q=h,this.u=o,this.s=a.transpose().mmul(a),this.xResidual=i,this.yResidual=s,this.betas=n}else this.w=l.transpose(),this.s=a.transpose().mmul(a).sqrt(),this.t=i?a.clone().div(this.s.get(0,0)):a,this.xResidual=t.sub(a.mmul(l.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});function sum(t){if(!src(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>e:(t,e)=>t.01&&this.gain!==i&&o.lesserX.length>0&&o.greaterX.length>0){this.left=new TreeNode(this),this.right=new TreeNode(this);var a=new Matrix(o.lesserX),h=new Matrix(o.greaterX);this.left.train(a,o.lesserY,r+1,this.gain),this.right.train(h,o.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 i=0;do{i=t.next()>>>0}while(i>=r);return i%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,i=e.next()>>>0;return r*UINT32_SIZE+i}}function upscaleToLoopCheckedRange(t){const e=t*Math.floor(SMALLEST_UNSAFE_INTEGER/t);return r=>{let i=0;do{const t=r.next()&UINT21_MAX,e=r.next()>>>0;i=t*UINT32_SIZE+e}while(i>=e);return i%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 i=0;do{const t=0|r.next(),e=r.next()>>>0;i=(t&UINT21_MAX)*UINT32_SIZE+e+(t&UINT21_SIZE?-SMALLEST_UNSAFE_INTEGER:0)}while(ie);return i}}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 ".concat(-SMALLEST_UNSAFE_INTEGER));if(e>SMALLEST_UNSAFE_INTEGER||!isFinite(e))throw new RangeError("Expected max to be at most ".concat(SMALLEST_UNSAFE_INTEGER));const r=e-t;return r<=0||!isFinite(r)?()=>t:r===UINT32_MAX?0===t?uint32:add(int32,t+INT32_SIZE):r0&&void 0!==arguments[0]?arguments[0]:DEFAULT_STRING_POOL;const e=t.length;if(!e)throw new Error("Expected pool not to be an empty string");const r=integer(0,e-1);return(e,i)=>{let n="";for(let s=0;s{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(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nativeMath,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16;const r=[];r.push(0|(new Date).getTime());for(let i=1;i{try{if(-5===Math.imul(UINT32_MAX,5))return Math.imul}catch(t){}return(t,e)=>{const r=65535&t,i=65535&e;return r*i+((t>>>16&65535)*i+r*(e>>>16&65535)<<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,i=0;const n=e.length;let s=0|Math.max(n,ARRAY_SIZE),o=0|t[0];for(;(0|s)>0;--s)t[r]=o=(t[r]^imul(o^o>>>30,1664525))+(0|e[i])+(0|i)|0,++i,(0|(r=r+1|0))>ARRAY_MAX&&(t[0]=t[ARRAY_MAX],r=1),i>=n&&(i=0);for(s=ARRAY_MAX;(0|s)>0;--s)t[r]=o=(t[r]^imul(o^o>>>30,1566083941))-r|0,(0|(r=r+1|0))>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){var i,n=integer(0,t.rows-1);if(void 0===r)i=MersenneTwister19937.autoSeed();else{if(!Number.isInteger(r))throw new RangeError("Expected seed must be undefined or integer not ".concat(r));i=MersenneTwister19937.seed(r)}for(var s=new Array(t.rows),o=new Array(t.rows),a=0;ar.load(t))}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 ".concat(this.maxFeatures));if(this.maxFeatures>t.columns)throw new RangeError("The maxFeatures parameter should be less than ".concat(t.columns));this.n=this.maxFeatures}if(this.isClassifier)var r=DecisionTreeClassifier;else r=DecisionTreeRegression;this.estimators=new Array(this.nEstimators),this.indexes=new Array(this.nEstimators);for(var i=0;it.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: ".concat(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()}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e){return t(e={exports:{}},e.exports),e.exports}var medianQuickselect_min=createCommonjsModule((function(t){!function(){function e(t){for(var e=0,n=t.length-1,s=void 0,o=void 0,a=void 0,h=i(e,n);;){if(n<=e)return t[h];if(n==e+1)return t[e]>t[n]&&r(t,e,n),t[h];for(t[s=i(e,n)]>t[n]&&r(t,s,n),t[e]>t[n]&&r(t,e,n),t[s]>t[e]&&r(t,s,e),r(t,s,e+1),o=e+1,a=n;;){do{o++}while(t[e]>t[o]);do{a--}while(t[a]>t[e]);if(a=h&&(n=a-1)}}var r=function(t,e,r){var i;return i=[t[r],t[e]],t[e]=i[0],t[r]=i[1],i},i=function(t,e){return~~((t+e)/2)};t.exports?t.exports=e:window.median=e}()}));function median(t){if(!src(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 ".concat(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: ".concat(t.name));return new RandomForestRegression(!0,t)}}class PCA{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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:i="SVD",nCompNIPALS:n=2,center:s=!0,scale:o=!1,ignoreZeroVariance:a=!1}=e;if(this.center=s,this.scale=o,this.means=null,this.stdevs=null,this.excludedFeatures=[],r)this._computeFromCovarianceMatrix(t);else switch(this._adjust(t,a),i){case"covarianceMatrix":{const e=new MatrixTransposeView(t).mmul(t).div(t.rows-1);this._computeFromCovarianceMatrix(e);break}case"NIPALS":this._computeWithNIPALS(t,n);break;case"SVD":{const e=new SingularValueDecomposition(t,{computeLeftSingularVectors:!1,computeRightSingularVectors:!0,autoTranspose:!0});this.U=e.rightSingularVectors;const r=e.diagonal,i=[];for(const e of r)i.push(e*e/(t.rows-1));this.S=i;break}default:throw new Error("unknown method: ".concat(i))}}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: ".concat(t.name));return new PCA(!0,t)}predict(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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 i=t.mmul(this.U);return i.subMatrix(0,i.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}}_adjust(t,e){if(this.center){const r=t.mean("column"),i=this.scale?t.standardDeviation("column",{mean:r}):null;if(this.means=r,t.subRowVector(r),this.scale){for(let r=0;re?1:0},l=function(t,e,n,s,o){var a;if(null==n&&(n=0),null==o&&(o=r),n<0)throw new Error("lo must be non-negative");for(null==s&&(s=t.length);nr;0<=r?e++:e--)l.push(e);return l}.apply(this).reverse()).length;sd;0<=d?++f:--f)p.push(s(t,i));return p},g=function(t,e,i,n){var s,o,a;for(null==n&&(n=r),s=t[i];i>e&&n(s,o=t[a=i-1>>1])<0;)t[i]=o,i=a;return t[i]=s},d=function(t,e,i){var n,s,o,a,h;for(null==i&&(i=r),s=t.length,h=e,o=t[e],n=2*e+1;n0;){const i=e.shift();t>=i.height?r.push(i):e=e.concat(i.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 i=new Cluster;return i.children=e.toArray(),i.height=this.height,i}traverse(t){!function t(e,r){if(r(e),e.children)for(const i of e.children)t(i,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,i,n){return i/(i+n)*t+n/(i+n)*e}function weightedAverageLink(t,e){return(t+e)/2}function centroidLink(t,e,r,i,n){return i/(i+n)*t+n/(i+n)*e+-i*n/(i+n)**2*r}function medianLink(t,e,r){return t/2+e/2-r/4}function wardLink(t,e,r,i,n,s){return(i+s)/(i+n+s)*t+(n+s)/(i+n+s)*e+-s/(i+n+s)*r}function wardLink2(t,e,r,i,n,s){const o=(i+s)/(i+n+s),a=(n+s)/(i+n+s),h=-s/(i+n+s);return Math.sqrt(o*t*t+a*e*e+h*r*r)}function agnes(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{distanceFunction:r=euclidean,method:i="complete",isDistanceMatrix:n=!1}=e;let s;n||(t=distanceMatrix(t,r));let o=new Matrix(t);const a=o.rows;if("string"==typeof i)switch(i.toLowerCase()){case"single":s=singleLink;break;case"complete":s=completeLink;break;case"average":case"upgma":s=averageLink;break;case"wpgma":s=weightedAverageLink;break;case"centroid":case"upgmc":s=centroidLink;break;case"median":case"wpgmc":s=medianLink;break;case"ward":s=wardLink;break;case"ward2":s=wardLink2;break;default:throw new RangeError("unknown clustering method: ".concat(i))}else if("function"!=typeof i)throw new TypeError("method must be a string or function");let h=[];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){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:defaultOptions$4;const i=r.distanceFunction||defaultOptions$4.distanceFunction,n=r.similarityFunction||defaultOptions$4.similarityFunction;let s=-1;if("function"==typeof n){let r=Number.MIN_VALUE;for(let i=0;ir&&(r=o,s=i)}}else{if("function"!=typeof i)throw new Error("A similarity or distance function it's required");{let r=Number.MAX_VALUE;for(let n=0;ni)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(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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]<1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Math.random;const{size:i=1,replace:n=!1,probabilities:s}=e;let o,a;if(o="number"==typeof t?getArray(t):t.slice(),s){if(!n)throw new Error("choice with probabilities and no replacement is not implemented");if(s.length!==o.length)throw new Error("the length of probabilities option should be equal to the number of choices");a=[s[0]];for(let t=1;tPROB_TOLERANCE)throw new Error("probabilities should sum to 1, but instead sums to ".concat(a[a.length-1]))}if(!1===n&&i>o.length)throw new Error("size option is too large");const h=[];for(let t=0;tr[t];)t++;return t}return Math.floor(i*t)}class Random{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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 o={dist:-1,index:-1},a=0;ao.dist&&(o.dist=r[s[0]][a],o.index=a);if(s[1]=o.index,e>2)for(var h=2;hl.dist&&(l=Object.assign({},c))}s[h]=l.index}}return s.map(e=>t[e])}function kmeanspp(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=(t=new Matrix(t)).rows,n=new Random(r.seed),s=[],o=r.localTrials||2+Math.floor(Math.log(e)),a=n.randInt(i);s.push(t.getRow(a));let h=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 i;if(Array.isArray(r.initialization)){if(r.initialization.length!==e)throw new Error("The initial centers should have the same length as K");i=r.initialization}else switch(r.initialization){case"kmeans++":i=kmeanspp(t,e,r);break;case"random":i=random(t,e,r.seed);break;case"mostDistant":i=mostDistant(t,e,calculateDistanceMatrix(t,r.distanceFunction),r.seed);break;default:throw new Error('Unknown initialization method: "'.concat(r.initialization,'"'))}0===r.maxIterations&&(r.maxIterations=Number.MAX_VALUE);var n=new Array(t.length);if(r.withIterations)return kmeansGenerator(i,t,n,e,r);for(var s,o=!1,a=0;!o&&ai&&(i=o,n=s)}return n}function calculateLogProbability(t,e,r,i){return t-=e,Math.log(r*Math.exp(t*t/i))}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 i=0;ie&&(e=t[r]);return e}function min(t){if(!src(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");for(var e=t[0],r=1;r1&&void 0!==arguments[1]?arguments[1]:{};if(!src(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(!src(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var i=min(t),n=max(t);if(i===n)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var s=r.min,o=void 0===s?r.autoMinMax?i:0:s,a=r.max,h=void 0===a?r.autoMinMax?n:1:a;if(o>=h)throw new RangeError("min option must be smaller than max option");for(var l=(h-o)/(n-i),u=0;ui)throw new RangeError("Row index out of range")}function checkColumnIndex(t,e,r){let i=r?t.columns:t.columns-1;if(e<0||e>i)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,i,n){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(checkNumber("startRow",e),checkNumber("endRow",r),checkNumber("startColumn",i),checkNumber("endColumn",n),e>r||i>n||e<0||e>=t.rows||r<0||r>=t.rows||i<0||i>=t.columns||n<0||n>=t.columns)throw new RangeError("Submatrix indices are out of range")}function newArray(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[];for(let i=0;i>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;t2&&void 0!==arguments[2]?arguments[2]:{};if("object"!=typeof r)throw new TypeError("options must be an object");const{random:i=Math.random}=r;let n=new Matrix(t,e);for(let r=0;r2&&void 0!==arguments[2]?arguments[2]:{};if("object"!=typeof r)throw new TypeError("options must be an object");const{min:i=0,max:n=1e3,random:s=Math.random}=r;if(!Number.isInteger(i))throw new TypeError("min must be an integer");if(!Number.isInteger(n))throw new TypeError("max must be an integer");if(i>=n)throw new RangeError("min must be smaller than max");let o=n-i,a=new Matrix(t,e);for(let r=0;rr?(n=!0,r=e):(i=!1,n=!0);t++}return i}isReducedEchelonForm(){let t=0,e=0,r=-1,i=!0,n=!1;for(;tr?(n=!0,r=e):(i=!1,n=!0);for(let r=e+1;rt.get(i,r)&&(i=n);if(0===t.get(i,r))r++;else{t.swapRows(e,i);let n=t.get(e,r);for(let i=r;i=0;)if(0===t.maxRow(i))i--;else{let n=0,s=!1;for(;n0&&void 0!==arguments[0]?arguments[0]:{};if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let i=new Matrix(this.rows*e,this.columns*r);for(let t=0;tt&&(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,i),e[0]=r,e[1]=i);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 i=1;ie&&(e=this.get(t,i),r[1]=i);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 i=1;ie&&(e=this.get(i,t),r[0]=i);return r}minColumn(t){checkColumnIndex(this,t);let e=this.get(0,t);for(let r=1;r0&&void 0!==arguments[0]?arguments[0]:"frobenius",e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:{};if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let i=new Matrix(this.rows,this.columns);for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:{};if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let i=new Matrix(this.rows,this.columns);for(let t=0;t0&&void 0!==arguments[0]?arguments[0]:compareNumbers;for(let e=0;e0&&void 0!==arguments[0]?arguments[0]:compareNumbers;for(let e=0;er||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let i=new Matrix(t.length,r-e+1);for(let n=0;n=this.rows)throw new RangeError("Row index out of range: ".concat(t[n]));i.set(n,s-e,this.get(t[n],s))}return i}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 i=new Matrix(r-e+1,t.length);for(let n=0;n=this.columns)throw new RangeError("Column index out of range: ".concat(t[n]));i.set(s-e,n,this.get(s,t[n]))}return i}setSubMatrix(t,e,r){checkRange(this,e,e+(t=Matrix.checkMatrix(t)).rows-1,r,r+t.columns-1);for(let i=0;i1&&void 0!==arguments[1]?arguments[1]:{};if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:i=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!Array.isArray(i))throw new TypeError("mean must be an array");return varianceByRow(this,r,i);case"column":if(!Array.isArray(i))throw new TypeError("mean must be an array");return varianceByColumn(this,r,i);case void 0:if("number"!=typeof i)throw new TypeError("mean must be a number");return varianceAll(this,r,i);default:throw new Error("invalid option: ".concat(t))}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t1&&void 0!==arguments[1]?arguments[1]:{};if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!Array.isArray(r))throw new TypeError("center must be an array");return centerByRow(this,r),this;case"column":if(!Array.isArray(r))throw new TypeError("center must be an array");return centerByColumn(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return centerAll(this,r),this;default:throw new Error("invalid option: ".concat(t))}}scale(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=getScaleByRow(this);else if(!Array.isArray(r))throw new TypeError("scale must be an array");return scaleByRow(this,r),this;case"column":if(void 0===r)r=getScaleByColumn(this);else if(!Array.isArray(r))throw new TypeError("scale must be an array");return scaleByColumn(this,r),this;case void 0:if(void 0===r)r=getScaleAll(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return scaleAll(this,r),this;default:throw new Error("invalid option: ".concat(t))}}}function compareNumbers(t,e){return t-e}AbstractMatrix.prototype.klass="Matrix","undefined"!=typeof Symbol&&(AbstractMatrix.prototype[Symbol.for("nodejs.util.inspect.custom")]=inspectMatrix),AbstractMatrix.random=AbstractMatrix.rand,AbstractMatrix.randomInt=AbstractMatrix.randInt,AbstractMatrix.diagonal=AbstractMatrix.diag,AbstractMatrix.prototype.diagonal=AbstractMatrix.prototype.diag,AbstractMatrix.identity=AbstractMatrix.eye,AbstractMatrix.prototype.negate=AbstractMatrix.prototype.neg,AbstractMatrix.prototype.tensorProduct=AbstractMatrix.prototype.kroneckerProduct;class Matrix extends AbstractMatrix{constructor(t,e){if(super(),Matrix.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>0){if(this.data=[],!(Number.isInteger(e)&&e>0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r1&&void 0!==arguments[1]?arguments[1]:{};const{rows:r=1}=e;if(t.length%r!=0)throw new Error("the data length is not divisible by the number of rows");super(),this.rows=r,this.columns=t.length/r,this.data=t}set(t,e,r){let i=this._calculateIndex(t,e);return this.data[i]=r,this}get(t,e){let r=this._calculateIndex(t,e);return this.data[r]}_calculateIndex(t,e){return t*this.columns+e}}class WrapperMatrix2D extends AbstractMatrix{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function wrap(t,e){if(Array.isArray(t))return t[0]&&Array.isArray(t[0])?new WrapperMatrix2D(t):new WrapperMatrix1D(t,e);throw new Error("the argument is not an array")}class LuDecomposition{constructor(t){let e,r,i,n,s,o,a,h,l,u=(t=WrapperMatrix2D.checkMatrix(t)).clone(),c=u.rows,f=u.columns,m=new Float64Array(c),g=1;for(e=0;eMath.abs(h[n])&&(n=e);if(n!==r){for(i=0;i=0;n--){for(i=0;ie?i.set(n,e,t.get(n,e)):n===e?i.set(n,e,1):i.set(n,e,0);return i}get upperTriangularMatrix(){let t=this.LU,e=t.rows,r=t.columns,i=new Matrix(e,r);for(let n=0;nMath.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,i,n,s=(t=WrapperMatrix2D.checkMatrix(t)).clone(),o=t.rows,a=t.columns,h=new Float64Array(a);for(i=0;i=0;s--){for(n=0;n=0;r--){for(t=0;t1&&void 0!==arguments[1]?arguments[1]:{},r=(t=WrapperMatrix2D.checkMatrix(t)).rows,i=t.columns;const{computeLeftSingularVectors:n=!0,computeRightSingularVectors:s=!0,autoTranspose:o=!1}=e;let a,h=Boolean(n),l=Boolean(s),u=!1;if(r=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(p[t])<=e||Number.isNaN(p[t])){p[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(p[r]):0)+(r!==t+1?Math.abs(p[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=p[b-2];p[b-2]=0;for(let r=b-2;r>=t;r--){let n=hypotenuse(m[r],e),s=m[r]/n,o=e/n;if(m[r]=n,r!==t&&(e=-o*p[r-1],p[r-1]=s*p[r-1]),l)for(let t=0;t=m[t+1]);){let e=m[t];if(m[t]=m[t+1],m[t+1]=e,l&&te&&n.set(s,r,t.get(s,r)/this.s[r]);let s=this.U,o=s.rows,a=s.columns,h=new Matrix(r,o);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){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return t=WrapperMatrix2D.checkMatrix(t),e?new SingularValueDecomposition(t).inverse():solve(t,Matrix.eye(t.rows))}function solve(t,e){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];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,i,n;if(2===t.columns)return e=t.get(0,0),r=t.get(0,1),i=t.get(1,0),e*(n=t.get(1,1))-r*i;if(3===t.columns){let n,s,o;return n=new MatrixSelectionView(t,[1,2],[1,2]),s=new MatrixSelectionView(t,[1,2],[0,2]),o=new MatrixSelectionView(t,[1,2],[0,1]),e=t.get(0,0),r=t.get(0,1),i=t.get(0,2),e*determinant(n)-r*determinant(s)+i*determinant(o)}return new LuDecomposition(t).determinant}throw Error("determinant can only be calculated for a square matrix")}function xrange(t,e){let r=[];for(let i=0;i3&&void 0!==arguments[3]?arguments[3]:1e-9;if(t>(arguments.length>4&&void 0!==arguments[4]?arguments[4]:1e-9))return new Array(e.rows+1).fill(0);{let t=e.addRow(r,[0]);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:{};const{thresholdValue:r=1e-9,thresholdError:i=1e-9}=e;let n=(t=Matrix.checkMatrix(t)).rows,s=new Matrix(n,n);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:Number.EPSILON;t=Matrix.checkMatrix(t);let r=new SingularValueDecomposition(t,{autoTranspose:!0}),i=r.leftSingularVectors,n=r.rightSingularVectors,s=r.diagonal;for(let t=0;te?s[t]=1/s[t]:s[t]=0;return n.mmul(Matrix.diag(s).mmul(i.transpose()))}function covariance(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=Matrix.checkMatrix(t);let i=!1;if("object"!=typeof e||Matrix.isMatrix(e)||Array.isArray(e)?e=Matrix.checkMatrix(e):(r=e,e=t,i=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0}=r;n&&(t=t.center("column"),i||(e=e.center("column")));const s=t.transpose().mmul(e);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=Matrix.checkMatrix(t);let i=!1;if("object"!=typeof e||Matrix.isMatrix(e)||Array.isArray(e)?e=Matrix.checkMatrix(e):(r=e,e=t,i=!0),t.rows!==e.rows)throw new TypeError("Both matrices must have the same number of rows");const{center:n=!0,scale:s=!0}=r;n&&(t.center("column"),i||e.center("column")),s&&(t.scale("column"),i||e.scale("column"));const o=t.standardDeviation("column",{unbiased:!0}),a=i?o:e.standardDeviation("column",{unbiased:!0}),h=t.transpose().mmul(e);for(let e=0;e1&&void 0!==arguments[1]?arguments[1]:{};const{assumeSymmetric:r=!1}=e;if(!(t=WrapperMatrix2D.checkMatrix(t)).isSquare())throw new Error("Matrix is not a square matrix");let i,n,s=t.columns,o=new Matrix(s,s),a=new Float64Array(s),h=new Float64Array(s),l=t,u=!1;if(u=!!r||t.isSymmetric()){for(i=0;i0?s.set(t,t+1,i[t]):i[t]<0&&s.set(t,t-1,i[t])}return s}}function tred2(t,e,r,i){let n,s,o,a,h,l,u,c;for(h=0;h0;a--){for(c=0,o=0,l=0;l0&&(s=-s),e[a]=c*s,o-=n*s,r[a-1]=n-s,h=0;hl)do{for(n=r[l],f=hypotenuse(c=(r[l+1]-n)/(2*e[l]),1),c<0&&(f=-f),r[l]=e[l]/(c+f),r[l+1]=e[l]*(c+f),m=r[l+1],s=n-r[l],o=l+2;o=l;o--)for(p=d,d=g,M=x,n=g*e[o],s=g*c,f=hypotenuse(c,e[o]),e[o+1]=x*f,x=e[o]/f,c=(g=c/f)*r[o]-x*n,r[o+1]=s+x*(g*n+x*r[o]),h=0;hb*v);r[l]=r[l]+y,e[l]=0}for(o=0;o=l;a--)r[a]=e.get(a,l-1)/u,o+=r[a]*r[a];for(s=Math.sqrt(o),r[l]>0&&(s=-s),o-=r[l]*s,r[l]=r[l]-s,h=l;h=l;a--)n+=r[a]*e.get(a,h);for(n/=o,a=l;a<=c;a++)e.set(a,h,e.get(a,h)-n*r[a])}for(a=0;a<=c;a++){for(n=0,h=c;h>=l;h--)n+=r[h]*e.get(a,h);for(n/=o,h=l;h<=c;h++)e.set(a,h,e.get(a,h)-n*r[h])}r[l]=u*r[l],e.set(l,l-1,u*s)}}for(a=0;a=1;l--)if(0!==e.get(l,l-1)){for(a=l+1;a<=c;a++)r[a]=e.get(a,l-1);for(h=l;h<=c;h++){for(s=0,a=l;a<=c;a++)s+=r[a]*i.get(a,h);for(s=s/r[l]/e.get(l,l-1),a=l;a<=c;a++)i.set(a,h,i.get(a,h)+s*r[a])}}}function hqr2(t,e,r,i,n){let s,o,a,h,l,u,c,f,m,g,d,p,w,x,M,y=t-1,v=t-1,b=Number.EPSILON,S=0,A=0,E=0,R=0,k=0,C=0,T=0,N=0;for(s=0;sv)&&(r[s]=n.get(s,s),e[s]=0),o=Math.max(s-1,0);o=0;){for(h=y;h>0&&(0===(C=Math.abs(n.get(h-1,h-1))+Math.abs(n.get(h,h)))&&(C=A),!(Math.abs(n.get(h,h-1))=0){for(T=E>=0?E+T:E-T,r[y-1]=f+T,r[y]=r[y-1],0!==T&&(r[y]=f-c/T),e[y-1]=0,e[y]=0,E=(f=n.get(y,y-1))/(C=Math.abs(f)+Math.abs(T)),R=T/C,E/=k=Math.sqrt(E*E+R*R),R/=k,o=y-1;o0){for(C=Math.sqrt(C),m=h&&(E=((k=f-(T=n.get(l,l)))*(C=m-T)-c)/n.get(l+1,l)+n.get(l,l+1),R=n.get(l+1,l+1)-T-k-C,k=n.get(l+2,l+1),E/=C=Math.abs(E)+Math.abs(R)+Math.abs(k),R/=C,k/=C,l!==h)&&!(Math.abs(n.get(l,l-1))*(Math.abs(R)+Math.abs(k))l+2&&n.set(s,s-3,0);for(a=l;a<=y-1&&(x=a!==y-1,a!==l&&(E=n.get(a,a-1),R=n.get(a+1,a-1),k=x?n.get(a+2,a-1):0,0!==(f=Math.abs(E)+Math.abs(R)+Math.abs(k))&&(E/=f,R/=f,k/=f)),0!==f);a++)if(C=Math.sqrt(E*E+R*R+k*k),E<0&&(C=-C),0!==C){for(a!==l?n.set(a,a-1,-C*f):h!==l&&n.set(a,a-1,-n.get(a,a-1)),f=(E+=C)/C,m=R/C,T=k/C,R/=E,k/=E,o=a;o=0;y--)if(E=r[y],0===(R=e[y]))for(h=y,n.set(y,y,1),s=y-1;s>=0;s--){for(c=n.get(s,s)-E,k=0,o=h;o<=y;o++)k+=n.get(s,o)*n.get(o,y);if(e[s]<0)T=c,C=k;else if(h=s,0===e[s]?n.set(s,y,0!==c?-k/c:-k/(b*A)):(f=n.get(s,s+1),m=n.get(s+1,s),u=(f*C-T*k)/(R=(r[s]-E)*(r[s]-E)+e[s]*e[s]),n.set(s,y,u),n.set(s+1,y,Math.abs(f)>Math.abs(T)?(-k-c*u)/f:(-C-m*u)/T)),b*(u=Math.abs(n.get(s,y)))*u>1)for(o=s;o<=y;o++)n.set(o,y,n.get(o,y)/u)}else if(R<0)for(h=y-1,Math.abs(n.get(y,y-1))>Math.abs(n.get(y-1,y))?(n.set(y-1,y-1,R/n.get(y,y-1)),n.set(y-1,y,-(n.get(y,y)-E)/n.get(y,y-1))):(M=cdiv(0,-n.get(y-1,y),n.get(y-1,y-1)-E,R),n.set(y-1,y-1,M[0]),n.set(y-1,y,M[1])),n.set(y,y-1,0),n.set(y,y,1),s=y-2;s>=0;s--){for(g=0,d=0,o=h;o<=y;o++)g+=n.get(s,o)*n.get(o,y-1),d+=n.get(s,o)*n.get(o,y);if(c=n.get(s,s)-E,e[s]<0)T=c,k=g,C=d;else if(h=s,0===e[s]?(M=cdiv(-g,-d,c,R),n.set(s,y-1,M[0]),n.set(s,y,M[1])):(f=n.get(s,s+1),m=n.get(s+1,s),p=(r[s]-E)*(r[s]-E)+e[s]*e[s]-R*R,w=2*(r[s]-E)*R,0===p&&0===w&&(p=b*A*(Math.abs(c)+Math.abs(R)+Math.abs(f)+Math.abs(m)+Math.abs(T))),M=cdiv(f*k-T*g+R*d,f*C-T*d-R*g,p,w),n.set(s,y-1,M[0]),n.set(s,y,M[1]),Math.abs(f)>Math.abs(T)+Math.abs(R)?(n.set(s+1,y-1,(-g-c*n.get(s,y-1)+R*n.get(s,y))/f),n.set(s+1,y,(-d-c*n.get(s,y)-R*n.get(s,y-1))/f)):(M=cdiv(-k-m*n.get(s,y-1),-C-m*n.get(s,y),T,R),n.set(s+1,y-1,M[0]),n.set(s+1,y,M[1]))),b*(u=Math.max(Math.abs(n.get(s,y-1)),Math.abs(n.get(s,y))))*u>1)for(o=s;o<=y;o++)n.set(o,y-1,n.get(o,y-1)/u),n.set(o,y,n.get(o,y)/u)}for(s=0;sv)for(o=s;o=0;o--)for(s=0;s<=v;s++){for(T=0,a=0;a<=Math.min(o,v);a++)T+=i.get(s,a)*n.get(a,o);i.set(s,o,T)}}}function cdiv(t,e,r,i){let n,s;return Math.abs(r)>Math.abs(i)?[(t+(n=i/r)*e)/(s=r+n*i),(e-n*t)/s]:[((n=r/i)*t+e)/(s=i+n*r),(n*e-t)/s]}class CholeskyDecomposition{constructor(t){if(!(t=WrapperMatrix2D.checkMatrix(t)).isSymmetric())throw new Error("Matrix is not symmetric");let e,r,i,n=t,s=n.rows,o=new Matrix(s,s),a=!0;for(r=0;r0,o.set(r,r,Math.sqrt(Math.max(t,0))),i=r+1;i=0;s--)for(n=0;n1&&void 0!==arguments[1]?arguments[1]:{};t=WrapperMatrix2D.checkMatrix(t);let{Y:r}=e;const{scaleScores:i=!1,maxIterations:n=1e3,terminationCriteria:s=1e-10}=e;let o;if(r){if(!(r=Array.isArray(r)&&"number"==typeof r[0]?Matrix.columnVector(r):WrapperMatrix2D.checkMatrix(r)).isColumnVector()||r.rows!==t.rows)throw new Error("Y must be a column vector of length X.rows");o=r}else o=t.getColumnVector(0);let a,h,l,u,c=1;for(let e=0;es;e++)l=(l=t.transpose().mmul(o).div(o.transpose().mmul(o).get(0,0))).div(l.norm()),a=t.mmul(l).div(l.transpose().mmul(l).get(0,0)),e>0&&(c=a.clone().sub(u).pow(2).sum()),u=a.clone(),r?(h=(h=r.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0))).div(h.norm()),o=r.mmul(h).div(h.transpose().mmul(h).get(0,0))):o=a;if(r){let e=t.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0));e=e.div(e.norm());let i=t.clone().sub(a.clone().mmul(e.transpose())),n=o.transpose().mmul(a).div(a.transpose().mmul(a).get(0,0)),s=r.clone().sub(a.clone().mulS(n.get(0,0)).mmul(h.transpose()));this.t=a,this.p=e.transpose(),this.w=l.transpose(),this.q=h,this.u=o,this.s=a.transpose().mmul(a),this.xResidual=i,this.yResidual=s,this.betas=n}else this.w=l.transpose(),this.s=a.transpose().mmul(a).sqrt(),this.t=i?a.clone().div(this.s.get(0,0)):a,this.xResidual=t.sub(a.mmul(l.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});function sum(t){if(!src(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,i=["greater","lesser"];for(let n=0;nt>e:(t,e)=>t.01&&this.gain!==i&&o.lesserX.length>0&&o.greaterX.length>0){this.left=new TreeNode(this),this.right=new TreeNode(this);let t=new Matrix(o.lesserX),e=new Matrix(o.greaterX);this.left.train(t,o.lesserY,r+1,this.gain),this.right.train(e,o.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 i=0;do{i=t.next()>>>0}while(i>=r);return i%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,i=e.next()>>>0;return r*UINT32_SIZE+i}}function upscaleToLoopCheckedRange(t){const e=t*Math.floor(SMALLEST_UNSAFE_INTEGER/t);return r=>{let i=0;do{const t=r.next()&UINT21_MAX,e=r.next()>>>0;i=t*UINT32_SIZE+e}while(i>=e);return i%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 i=0;do{const t=0|r.next(),e=r.next()>>>0;i=(t&UINT21_MAX)*UINT32_SIZE+e+(t&UINT21_SIZE?-SMALLEST_UNSAFE_INTEGER:0)}while(ie);return i}}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 ".concat(-SMALLEST_UNSAFE_INTEGER));if(e>SMALLEST_UNSAFE_INTEGER||!isFinite(e))throw new RangeError("Expected max to be at most ".concat(SMALLEST_UNSAFE_INTEGER));const r=e-t;return r<=0||!isFinite(r)?()=>t:r===UINT32_MAX?0===t?uint32:add(int32,t+INT32_SIZE):r0&&void 0!==arguments[0]?arguments[0]:DEFAULT_STRING_POOL;const e=t.length;if(!e)throw new Error("Expected pool not to be an empty string");const r=integer(0,e-1);return(e,i)=>{let n="";for(let s=0;s{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(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nativeMath,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:16;const r=[];r.push(0|(new Date).getTime());for(let i=1;i{try{if(-5===Math.imul(UINT32_MAX,5))return Math.imul}catch(t){}return(t,e)=>{const r=65535&t,i=65535&e;return r*i+((t>>>16&65535)*i+r*(e>>>16&65535)<<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,i=0;const n=e.length;let s=0|Math.max(n,ARRAY_SIZE),o=0|t[0];for(;(0|s)>0;--s)t[r]=o=(t[r]^imul(o^o>>>30,1664525))+(0|e[i])+(0|i)|0,++i,(0|(r=r+1|0))>ARRAY_MAX&&(t[0]=t[ARRAY_MAX],r=1),i>=n&&(i=0);for(s=ARRAY_MAX;(0|s)>0;--s)t[r]=o=(t[r]^imul(o^o>>>30,1566083941))-r|0,(0|(r=r+1|0))>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 i,n=integer(0,t.rows-1);if(void 0===r)i=MersenneTwister19937.autoSeed();else{if(!Number.isInteger(r))throw new RangeError("Expected seed must be undefined or integer not ".concat(r));i=MersenneTwister19937.seed(r)}let s=new Array(t.rows),o=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 ".concat(this.maxFeatures));if(this.maxFeatures>t.columns)throw new RangeError("The maxFeatures parameter should be less than ".concat(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 i=0;it.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: ".concat(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()}var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e){return t(e={exports:{}},e.exports),e.exports}var medianQuickselect_min=createCommonjsModule((function(t){!function(){function e(t){for(var e=0,n=t.length-1,s=void 0,o=void 0,a=void 0,h=i(e,n);;){if(n<=e)return t[h];if(n==e+1)return t[e]>t[n]&&r(t,e,n),t[h];for(t[s=i(e,n)]>t[n]&&r(t,s,n),t[e]>t[n]&&r(t,e,n),t[s]>t[e]&&r(t,s,e),r(t,s,e+1),o=e+1,a=n;;){do{o++}while(t[e]>t[o]);do{a--}while(t[a]>t[e]);if(a=h&&(n=a-1)}}var r=function(t,e,r){var i;return i=[t[r],t[e]],t[e]=i[0],t[r]=i[1],i},i=function(t,e){return~~((t+e)/2)};t.exports?t.exports=e:window.median=e}()}));function median(t){if(!src(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 ".concat(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: ".concat(t.name));return new RandomForestRegression(!0,t)}}class PCA{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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:i="SVD",nCompNIPALS:n=2,center:s=!0,scale:o=!1,ignoreZeroVariance:a=!1}=e;if(this.center=s,this.scale=o,this.means=null,this.stdevs=null,this.excludedFeatures=[],r)this._computeFromCovarianceMatrix(t);else switch(this._adjust(t,a),i){case"covarianceMatrix":{const e=new MatrixTransposeView(t).mmul(t).div(t.rows-1);this._computeFromCovarianceMatrix(e);break}case"NIPALS":this._computeWithNIPALS(t,n);break;case"SVD":{const e=new SingularValueDecomposition(t,{computeLeftSingularVectors:!1,computeRightSingularVectors:!0,autoTranspose:!0});this.U=e.rightSingularVectors;const r=e.diagonal,i=[];for(const e of r)i.push(e*e/(t.rows-1));this.S=i;break}default:throw new Error("unknown method: ".concat(i))}}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: ".concat(t.name));return new PCA(!0,t)}predict(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};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 i=t.mmul(this.U);return i.subMatrix(0,i.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"),i=this.scale?t.standardDeviation("column",{mean:r}):null;if(this.means=r,t.subRowVector(r),this.scale){for(let r=0;re?1:0},l=function(t,e,n,s,o){var a;if(null==n&&(n=0),null==o&&(o=r),n<0)throw new Error("lo must be non-negative");for(null==s&&(s=t.length);nr;0<=r?e++:e--)l.push(e);return l}.apply(this).reverse()).length;sd;0<=d?++f:--f)p.push(s(t,i));return p},g=function(t,e,i,n){var s,o,a;for(null==n&&(n=r),s=t[i];i>e&&n(s,o=t[a=i-1>>1])<0;)t[i]=o,i=a;return t[i]=s},d=function(t,e,i){var n,s,o,a,h;for(null==i&&(i=r),s=t.length,h=e,o=t[e],n=2*e+1;n0;){const i=e.shift();t>=i.height?r.push(i):e=e.concat(i.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 i=new Cluster;return i.children=e.toArray(),i.height=this.height,i}traverse(t){!function t(e,r){if(r(e),e.children)for(const i of e.children)t(i,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,i,n){return i/(i+n)*t+n/(i+n)*e}function weightedAverageLink(t,e){return(t+e)/2}function centroidLink(t,e,r,i,n){return i/(i+n)*t+n/(i+n)*e+-i*n/(i+n)**2*r}function medianLink(t,e,r){return t/2+e/2-r/4}function wardLink(t,e,r,i,n,s){return(i+s)/(i+n+s)*t+(n+s)/(i+n+s)*e+-s/(i+n+s)*r}function wardLink2(t,e,r,i,n,s){const o=(i+s)/(i+n+s),a=(n+s)/(i+n+s),h=-s/(i+n+s);return Math.sqrt(o*t*t+a*e*e+h*r*r)}function agnes(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{distanceFunction:r=euclidean,method:i="complete",isDistanceMatrix:n=!1}=e;let s;n||(t=distanceMatrix(t,r));let o=new Matrix(t);const a=o.rows;if("string"==typeof i)switch(i.toLowerCase()){case"single":s=singleLink;break;case"complete":s=completeLink;break;case"average":case"upgma":s=averageLink;break;case"wpgma":s=weightedAverageLink;break;case"centroid":case"upgmc":s=centroidLink;break;case"median":case"wpgmc":s=medianLink;break;case"ward":s=wardLink;break;case"ward2":s=wardLink2;break;default:throw new RangeError("unknown clustering method: ".concat(i))}else if("function"!=typeof i)throw new TypeError("method must be a string or function");let h=[];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){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:defaultOptions$4;const i=r.distanceFunction||defaultOptions$4.distanceFunction,n=r.similarityFunction||defaultOptions$4.similarityFunction;let s=-1;if("function"==typeof n){let r=Number.MIN_VALUE;for(let i=0;ir&&(r=o,s=i)}}else{if("function"!=typeof i)throw new Error("A similarity or distance function it's required");{let r=Number.MAX_VALUE;for(let n=0;ni)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(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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]<1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Math.random;const{size:i=1,replace:n=!1,probabilities:s}=e;let o,a;if(o="number"==typeof t?getArray(t):t.slice(),s){if(!n)throw new Error("choice with probabilities and no replacement is not implemented");if(s.length!==o.length)throw new Error("the length of probabilities option should be equal to the number of choices");a=[s[0]];for(let t=1;tPROB_TOLERANCE)throw new Error("probabilities should sum to 1, but instead sums to ".concat(a[a.length-1]))}if(!1===n&&i>o.length)throw new Error("size option is too large");const h=[];for(let t=0;tr[t];)t++;return t}return Math.floor(i*t)}class Random{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]: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 o={dist:-1,index:-1},a=0;ao.dist&&(o.dist=r[s[0]][a],o.index=a);if(s[1]=o.index,e>2)for(var h=2;hl.dist&&(l=Object.assign({},c))}s[h]=l.index}}return s.map(e=>t[e])}function kmeanspp(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i=(t=new Matrix(t)).rows,n=new Random(r.seed),s=[],o=r.localTrials||2+Math.floor(Math.log(e)),a=n.randInt(i);s.push(t.getRow(a));let h=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 i;if(Array.isArray(r.initialization)){if(r.initialization.length!==e)throw new Error("The initial centers should have the same length as K");i=r.initialization}else switch(r.initialization){case"kmeans++":i=kmeanspp(t,e,r);break;case"random":i=random(t,e,r.seed);break;case"mostDistant":i=mostDistant(t,e,calculateDistanceMatrix(t,r.distanceFunction),r.seed);break;default:throw new Error('Unknown initialization method: "'.concat(r.initialization,'"'))}0===r.maxIterations&&(r.maxIterations=Number.MAX_VALUE);var n=new Array(t.length);if(r.withIterations)return kmeansGenerator(i,t,n,e,r);for(var s,o=!1,a=0;!o&&ai&&(i=o,n=s)}return n}function calculateLogProbability(t,e,r,i){return t-=e,Math.log(r*Math.exp(t*t/i))}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 i=0;i, 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&&o.pop()}for(m=0;mt[i[n]]-e[i[n]]);const s=Math.floor(t.length/2),o=new Node(t[s],n,r);return o.left=buildTree(t.slice(0,s),e+1,o,i),o.right=buildTree(t.slice(s+1),e+1,o,i),o}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,i=this.content[r];if(!(this.scoreFunction(e)2&&void 0!==arguments[2]?arguments[2]:{};if(!0===t){const t=e;return this.kdTree=new KDTree(t.kdTree,r),this.k=t.k,this.classes=new Set(t.classes),void(this.isEuclidean=t.isEuclidean)}const i=new Set(e),{distance:n=euclidean,k:s=i.size+1}=r,o=new Array(t.length);for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:euclidean;if("KNN"!==t.name)throw new Error("invalid model: ".concat(t.name));if(!t.isEuclidean&&e===euclidean)throw new Error("a custom distance function was used to create the model. Please provide it again");if(t.isEuclidean&&e!==euclidean)throw new Error("the model was created with the default distance function. Do not load it with another one");return new KNN(!0,t,e)}toJSON(){return{name:"KNN",kdTree:this.kdTree,k:this.k,classes:Array.from(this.classes),isEuclidean:this.isEuclidean}}predict(t){if(Array.isArray(t)){if("number"==typeof t[0])return getSinglePrediction(this,t);if(Array.isArray(t[0])&&"number"==typeof t[0][0]){const r=new Array(t.length);for(var e=0;es&&(n=l,s=u)}return n}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(var r=0;rh&&ph;){var A=w.mmul(b);A.div(norm(A)),S=v,v=t.mmul(A);var E=x.mmul(v);E.div(norm(E)),b=e.mmul(E)}S=v;var R=w.mmul(S),k=S.transpose().mmul(S).get(0,0),C=R.div(k),T=norm(C);C.div(T),S.mul(T),A.mul(T),R=b.transpose().mmul(S),k=S.transpose().mmul(S).get(0,0);var N=R.div(k).get(0,0);t.sub(S.mmul(C.transpose())),e.sub(S.clone().mul(N).mmul(E.transpose())),u.setColumn(p,S),c.setColumn(p,C),f.setColumn(p,b),m.setColumn(p,E),d.setColumn(p,A),g.set(p,p,N),p++}p--,u=u.subMatrix(0,u.rows-1,0,p),c=c.subMatrix(0,c.rows-1,0,p),f=f.subMatrix(0,f.rows-1,0,p),m=m.subMatrix(0,m.rows-1,0,p),d=d.subMatrix(0,d.rows-1,0,p),g=g.subMatrix(0,p,0,p),this.ssqYcal=a,this.E=t,this.F=e,this.T=u,this.P=c,this.U=f,this.Q=m,this.W=d,this.B=g,this.PBQ=c.mmul(g).mmul(m.transpose()),this.R2X=S.transpose().mmul(S).mmul(C.transpose().mmul(C)).div(o).get(0,0)}predict(t){var e=Matrix.checkMatrix(t);this.scale&&(e=e.subRowVector(this.meanX).divRowVector(this.stdDevX));var r=e.mmul(this.PBQ);return r=r.mulRowVector(this.stdDevY).addRowVector(this.meanY)}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: ".concat(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();var r=this.kernel.compute(t),i=Matrix.eye(r.rows,r.rows,1),n=r;r=new Array(this.orthogonalComp+1);for(let t=0;t2&&void 0!==arguments[2]?arguments[2]:{};if(e.length!==t.length)throw new Error("predicted and actual must have the same length");r=i.labels?new Set(i.labels):new Set([...t,...e]),r=Array.from(r),i.sort&&r.sort(i.sort);const n=Array.from({length:r.length});for(let t=0;t=0&&o>=0&&n[s][o]++}return new ConfusionMatrix(n,r)}getMatrix(){return this.matrix}getLabels(){return this.labels}getTotalCount(){let t=0;for(var e=0;e1&&(l[e-1]=0);do{e++}while(l[e]>0);for(r=e-1,t=e;0===l[t];)l[t++]=-1;if(-1===l[t])l[t]=l[r],s=l[r]-1,i=t-1,n=r-1,l[r]=-1;else{if(t===l[0])return 0;l[e]=l[t],s=l[t]-1,l[t]=0,i=e-1,n=t-1}}return 1}if("index"===r.mode)for(yield a.slice();c();)a[s]=o[i],yield a.slice();else{if("mask"!==r.mode)throw new Error("Invalid mode");for(yield h.slice();c();)h[i]=1,h[n]=0,yield h.slice()}};const CV={};function check(t,e){if(t.length!==e.length)throw new Error("features and labels should have the same length")}function initMatrix(t,e){return new Array(t).fill(0).map(()=>new Array(e).fill(0))}function getDistinct(t){var e=new Set;for(let r=0;r=0;t--)c.splice(n[t],1);s?validateWithCallback(e,r,n,c,a,o,s):validate(t,e,r,i,n,c,a,o)}return new src$1(a,o)},CV.kFold=function(t,e,r,i,n){if("function"==typeof i){var s=i;n=r,r=e,e=t}check(e,r);const o=getDistinct(r),a=initMatrix(o.length,o.length);for(var h=e.length,l=new Array(h),u=0;u0?(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,i=r>1?r=>e.activation(r,t.activationParam):e.activation,n=r>1?r=>e.derivate(r,t.activationParam):e.derivate;this.activationFunction=function(t,e){this.set(t,e,i(this.get(t,e)))},this.derivate=function(t,e){this.set(t,e,n(this.get(t,e)))},t.model?(this.W=Matrix.Matrix.checkMatrix(t.W),this.b=Matrix.Matrix.checkMatrix(t.b)):(this.W=Matrix.Matrix.rand(this.inputSize,this.outputSize),this.b=Matrix.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=Matrix.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;--i){var s=i>0?this.model[i-1].a:t;n=this.model[i].backpropagation(n,s)}for(i=0;i0?e=this[t]-1:this.som.torus&&(e=this.som.gridDim[t]-1),void 0!==e)"x"===t?(r=e,i=this.y):(r=this.x,i=e),this.neighbors[t][0]=this.som.nodes[r][i];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),i=new Array(e),n=0;n0?("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,i,n,s,o=Date.now(),a=this._findBestMatchingUnit(t),h=Date.now();this.times.findBMU+=h-o;var l=Math.floor(e),u=a.x-l,c=a.x+l,f=a.y-l,m=a.y+l;for(r=u;r<=c;r++){var g=r;for(r<0?g+=this.x:r>=this.x&&(g-=this.x),i=f;i<=m;i++){var d=i;i<0?d+=this.y:i>=this.y&&(d-=this.y),(n=a[this.distanceMethod](this.nodes[g][d]))0&&e!==this.coefficients.length-1?o=" + ".concat(o):e!==this.coefficients.length-1&&(o=" ".concat(o))),s=o+s;return"+"===s.charAt(0)&&(s=s.slice(1)),"f(x) = ".concat(s)}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,i){const n=e.length;let s;if(Array.isArray(i))i=(s=i).length;else{i++,s=new Array(i);for(let t=0;t=0?"f(x) = ".concat(maybeToPrecision(this.B,t),"e^{").concat(maybeToPrecision(this.A,t),"x}"):"f(x) = \\frac{".concat(maybeToPrecision(this.B,t),"}{e^{").concat(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 i=e.length,n=new Array(i);for(let t=0;t=0?"f(x) = ".concat(maybeToPrecision(this.A,t),"x^{").concat(maybeToPrecision(this.B,t),"}"):"f(x) = \\frac{".concat(maybeToPrecision(this.A,t),"}{x^{").concat(maybeToPrecision(-this.B,t),"}}")).replace(/e([+-]?[0-9]+)/g,"e^{$1}")}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 i=e.length,n=new Array(i),s=new Array(i);for(let t=0;t2&&void 0!==arguments[2]?arguments[2]:{};const{intercept:i=!0,statistics:n=!0}=r;if(this.statistics=n,!0===t)this.weights=e.weights,this.inputs=e.inputs,this.outputs=e.outputs,this.intercept=e.intercept;else{t=new Matrix(t),e=new Matrix(e),i&&t.addColumn(new Array(t.rows).fill(1));let r=t.transpose();const s=r.mmul(t),o=r.mmul(e),a=new SingularValueDecomposition(s).inverse(),h=o.transpose().mmul(a).transpose();if(this.weights=h.to2DArray(),this.inputs=t.columns,this.outputs=e.columns,i&&this.inputs--,this.intercept=i,n){const r=t.mmul(h),i=e.clone().addM(r.neg()).to2DArray().map(t=>Math.pow(t[0],2)).reduce((t,e)=>t+e)/(e.rows-t.columns);this.stdError=Math.sqrt(i),this.stdErrorMatrix=pseudoInverse(s).mul(i),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 ".concat(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)}}const{squaredEuclidean:squaredEuclidean$1}=euclidean$1,defaultOptions$8={sigma:1};class GaussianKernel{constructor(t){t=Object.assign({},defaultOptions$8,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$9={degree:1,constant:1,scale:1};class PolynomialKernel{constructor(t){t=Object.assign({},defaultOptions$9,t),this.degree=t.degree,this.constant=t.constant,this.scale=t.scale}compute(t,e){for(var r=0,i=0;i0&&e!==this.coefficients.length-1?o=" + ".concat(o):e!==this.coefficients.length-1&&(o=" ".concat(o))),s=o+s;return"+"===s.charAt(0)&&(s=s.slice(1)),"f(x) = ".concat(s)}static load(t){if("robustPolynomialRegression"!==t.name)throw new TypeError("not a RobustPolynomialRegression model");return new RobustPolynomialRegression(!0,t)}}function robustPolynomial(t,e,r,i){let n=Array(i).fill(0).map((t,e)=>e);const s=getRandomTuples(e,r,i);for(var o,a=0;at.residual-e.residual);var e=t.length,r=Math.floor(e/2);return e%2==0?t[r-1]:t[r]}function errorCalculation(t,e,r){var i=0;const n=r(e);for(var s=0;sa(t)),l=gradientFunction(t,h,e,i,n),u=matrixFunction(t,h),c=inverse(o.add(l.mmul(l.transpose())));return(e=(e=new Matrix([e])).sub(c.mmul(l).mmul(u).mul(i).transpose())).to1DArray()}function levenbergMarquardt(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{maxIterations:i=100,gradientDifference:n=.1,damping:s=0,errorTolerance:o=.01,minValues:a,maxValues:h,initialValues:l}=r;if(s<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!Array.isArray(t.x)||t.x.length<2||!Array.isArray(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");var u=l||new Array(e.length).fill(1);let c=u.length;if(h=h||new Array(c).fill(Number.MAX_SAFE_INTEGER),a=a||new Array(c).fill(Number.MIN_SAFE_INTEGER),h.length!==a.length)throw new Error("minValues and maxValues must be the same size");if(!Array.isArray(u))throw new Error("initialValues must be an array");for(var f=errorCalculation(t,u,e),m=f<=o,g=0;g{let r=BigInt(0);return t.forEach(t=>r|=BigInt(1)<t.key-e.key<0?-1:1),i=[],n=[];for(let t of r)t.key!==e&&(e=t.key,n.push([]),i.push(t.value)),n[n.length-1].push(t.index);return{values:i,indices:n}}function cssls(t,e,r,i,n){let s=Matrix.zeros(i,n);if(null===r){let r=new CholeskyDecomposition(t);if(!0===r.isPositiveDefinite())s=r.solve(e);else{let r=new LuDecomposition(t);s=!1===r.isSingular()?r.solve(Matrix.eye(i)).mmul(e):solve(t,e,{useSVD:!0})}}else{let o=sortCollectionSet(r).values,a=sortCollectionSet(r).indices;if(1===o.length&&0===o[0].length&&a[0].length===n)return s;if(1===o.length&&o[0].length===i&&a[0].length===n){let r=new CholeskyDecomposition(t);if(!0===r.isPositiveDefinite())s=r.solve(e);else{let r=new LuDecomposition(t);s=!1===r.isSingular()?r.solve(Matrix.eye(i)).mmul(e):solve(t,e,{useSVD:!0})}}else for(let r=0;r0?l[t].push(e):h.set(e,t,0)}let u=[];for(let t=0;tt-e);return{Pset:s,Fset:n,W:o}}function fcnnls(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=Matrix.checkMatrix(t),e=Matrix.checkMatrix(e);let{l:i,p:n,iter:s,W:o,XtX:a,XtY:h,K:l,Pset:u,Fset:c,D:f}=initialisation(t,e);const{maxIterations:m=3*t.columns}=r;for(;c.length>0;){let t=cssls(a,h.subMatrixColumn(c),selection(u,c),i,c.length);for(let e=0;e0){let e=r.length,n=Matrix.ones(i,e);for(;e>0&&se===g[t]),1);t=cssls(a,h.subMatrixColumn(r),selection(u,r),i,e);for(let i=0;i2&&void 0!==arguments[2]?arguments[2]:{};if(!1===Array.isArray(e))throw new TypeError("y must be a 1D Array");return fcnnls(t,Matrix.columnVector(e),r).to1DArray()}var index$2=Object.freeze({__proto__:null,fcnnls:fcnnls,fcnnlsVector:fcnnlsVector}),binarySearch=function(t,e,r,i,n){var s,o;if(void 0===i)i=0;else if((i|=0)<0||i>=t.length)throw new RangeError("invalid lower bound");if(void 0===n)n=t.length-1;else if((n|=0)=t.length)throw new RangeError("invalid upper bound");for(;i<=n;)if((o=+r(t[s=i+(n-i>>>1)],e,s,t))<0)i=s+1;else{if(!(o>0))return s;n=s-1}return~i};function assertNumber(t){if("number"!=typeof t||Number.isNaN(t))throw new TypeError("Expected a number")}var ascending=(t,e)=>(assertNumber(t),assertNumber(e),t-e),descending=(t,e)=>(assertNumber(t),assertNumber(e),e-t),numSort={ascending:ascending,descending:descending},index$3=Object.freeze({__proto__:null,default:numSort,__moduleExports: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(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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: ".concat(e));const r=void 0===t.minLoadFactor?defaultMinLoadFactor:t.minLoadFactor,i=void 0===t.maxLoadFactor?defaultMaxLoadFactor:t.maxLoadFactor;if(r<0||r>=1)throw new RangeError("invalid minLoadFactor: ".concat(r));if(i<=0||i>=1)throw new RangeError("invalid maxLoadFactor: ".concat(i));if(r>=i)throw new RangeError("minLoadFactor (".concat(r,") must be smaller than maxLoadFactor (").concat(i,")"));let n=e;0===(n=nextPrime(n=n/i|0))&&(n=1),this.table=newArray$1(n),this.values=newArray$1(n),this.state=newArray$1(n),this.minLoadFactor=r,this.maxLoadFactor=n===largestPrime?1:i,this.distinct=0,this.freeEntries=n,this.lowWaterMark=0,this.highWaterMark=chooseHighWaterMark(n,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,i=this.table.length,n=2147483647&t;let s=n%i,o=n%(i-2);for(0===o&&(o=1);r[s]!==FREE&&(r[s]===REMOVED||e[s]!==t);)(s-=o)<0&&(s+=i);return r[s]===FREE?-1:s}containsValue(t){return this.indexOfValue(t)>=0}indexOfValue(t){const e=this.values,r=this.state;for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:{};if(t instanceof SparseMatrix){const e=t;this._init(e.rows,e.columns,e.elements.clone(),e.threshold)}else if(Array.isArray(t)){const o=t;t=o.length,r=e||{},e=o[0].length,this._init(t,e,new HashTable(r),r.threshold);for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;const r=Math.min(t,e),i=new SparseMatrix(t,e,{initialCapacity:r});for(var n=0;nthis.get(r,e)!==i?(t=!1,!1):i),t}bandWidth(){let t=this.columns,e=-1;return this.forEachNonZero((r,i,n)=>{let s=r-i;return t=Math.min(t,s),e=Math.max(e,s),n}),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,s,o)=>(r===t&&i.set(e,s,i.get(e,s)+n*o),o)),n)),i}kroneckerProduct(t){const e=this.rows,r=this.columns,i=t.rows,n=t.columns,s=new SparseMatrix(e*i,r*n,{initialCapacity:this.cardinality*t.cardinality});return this.forEachNonZero((e,r,o)=>(t.forEachNonZero((t,a,h)=>(s.set(i*e+t,n*r+a,o*h),h)),o)),s}forEachNonZero(t){return this.elements.forEachPair((e,r)=>{const i=e/this.columns|0,n=e%this.columns;let s=t(i,n,r);return!1!==s&&(this.threshold&&Math.abs(s)(e[n]=t,r[n]=s,i[n]=o,n++,o)),{rows:e,columns:r,values:i}}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,i)=>(t.set(r,e,i),i)),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;i1&&void 0!==arguments[1]?arguments[1]:{};var r=t[0];const{minWindow:i=.16,threshold:n=.01,from:s=r[0],to:o=r[r.length-1]}=e;return mainCreateTree(t[0],t[1],s,o,i,n)}function mainCreateTree(t,e,r,i,n,s){if(i-r=i);l++)a+=e[l],h+=t[l]*e[l];return a2&&void 0!==arguments[2]?arguments[2]:{};const{alpha:i=.1,beta:n=.33,gamma:s=.001}=r;return null===t||null===e?0:(Array.isArray(t)&&(t=createTree(t)),Array.isArray(e)&&(e=createTree(e)),n*(i*Math.min(t.sum,e.sum)/Math.max(t.sum,e.sum)+(1-i)*Math.exp(-s*Math.abs(t.center-e.center)))+(1-n)*(getSimilarity(t.left,e.left,r)+getSimilarity(t.right,e.right,r))/2)}function treeSimilarity(t,e){return getSimilarity(t,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function getFunction(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(e,r)=>getSimilarity(e,r,t)}var index$4=Object.freeze({__proto__:null,treeSimilarity:treeSimilarity,getFunction:getFunction,createTree:createTree});function cosine(t,e){for(var r=t.length,i=0,n=0,s=0,o=0;o{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{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 i=t.length,n=t[0].length,s=!r.max,o=[];if(r.all)for(var a=0;at.pred-e.pred):o.sort((t,e)=>e.pred-t.pred);const l=this.cutoffs=[s?Number.MIN_VALUE:Number.MAX_VALUE],u=this.fp=[0],c=this.tp=[0];var f=0,m=0,g=o[0].pred,d=0,p=0;for(a=0;ar||e.size[1]>r)throw new RangeError("expanded value should not be bigger than the data length");for(n=0;n>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),i=0;i>5]&r)}function setBit(t,e,r){var i=e>>5,n=1<<31-e%32;return t[i]=r?n|t[i]:~n&t[i],t}function toBinaryString(t){for(var e="",r=0;r>>0).toString(2);e+="00000000000000000000000000000000".substr(i.length)+i}return e}function parseBinaryString(t){for(var e=t.length/32,r=new Array(e),i=0;i>>0).toString(16);e+="00000000".substr(i.length)+i}return e}function parseHexString(t){for(var e=t.length/8,r=new Array(e),i=0;ir&&(r=i,e=t[s])}return e}function norm$1(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).algorithm,r=void 0===e?"absolute":e;if(!Array.isArray(t))throw new Error("input must be an array");if(0===t.length)throw new Error("input must not be empty");switch(r.toLowerCase()){case"absolute":var i=absoluteSum(t);return 0===i?t.slice(0):t.map((function(t){return t/i}));case"max":var n=max(t);return 0===n?t.slice(0):t.map((function(t){return t/n}));case"sum":var s=sum(t);return 0===s?t.slice(0):t.map((function(t){return t/s}));default:throw new Error("norm: unknown algorithm: ".concat(r))}}function absoluteSum(t){for(var e=0,r=0;r0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==_typeof(t)||src(t)||(e=t,t=[]),!src(t))throw new TypeError("input must be an array");var r=e,i=r.from,n=void 0===i?0:i,s=r.to,o=void 0===s?10:s,a=r.size,h=void 0===a?t.length:a,l=r.step;if(h&&l)throw new Error("step is defined by the array size");if(h||(h=l?Math.floor((o-n)/l)+1:o-n+1),!l&&h&&(l=(o-n)/(h-1)),Array.isArray(t)){t.length=0;for(var u=0;u1&&void 0!==arguments[1]?arguments[1]:{};if(!src(t))throw new TypeError("input must be an array");for(var r=e.unbiased,i=void 0===r||r,n=e.mean,s=void 0===n?mean(t):n,o=0,a=0;a1&&void 0!==arguments[1]?arguments[1]:{};return Math.sqrt(variance(t,e))}function mergeByCentroids(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{window:i=.01}=r;for(var n={x:e.slice(),y:new Array(e.length).fill(0)},s=0,o=0;s=0?{x:r[o],y:i[o]}:0!==(o=~o)&&Math.abs(r[o]-n)>.5||o===r.length?{x:r[o-1],y:i[o-1]}:{x:r[o],y:i[o]}}function covariance$1(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t,{unbiased:n=!0}=e,s=mean(r),o=mean(i);var a=0;for(let t=0;t1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t,{groupWidth:n=.001}=e;for(var s={x:[],y:[]},o={x:[],y:[]},a=0,h=0;hn?(o.x.push(r[h]),o.y.push(i[h]),s.x.push(r[h]),s.y.push(i[h]),h++,a++):(i[h]>o.y[a-1]&&(o.x[a-1]=r[h],o.y[a-1]=i[h]),s.x[a-1]=r[h],s.y[a-1]+=i[h],h++);return s.x=o.x.slice(),s}function maxY(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t;let{from:n={index:0},to:s={index:r.length},reverse:o=!1}=e;void 0!==n.value&&void 0===n.index&&(n.index=calculateIndex(n.value,r,o)),void 0!==s.value&&void 0===s.index&&(s.index=calculateIndex(s.value,r,o));for(var a,h=Number.MIN_VALUE,l=n.index;l1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t,{reverse:n=!1}=e;var s;s=n?(t,e)=>e.x-t.x:(t,e)=>t.x-e.x;for(var o=r.map((t,e)=>({x:t,y:i[e]})).sort(s),a={x:r.slice(),y:i.slice()},h=0;h0&&void 0!==arguments[0]?arguments[0]:{};const{x:e,y:r}=t;if(e.length<2)return;if(e.length!==r.length)throw new Error("The X and Y arrays mush have the same length");let i=e[0],n=0;for(let t=1;t1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t,{groupWidth:n=.001}=e;for(var s={x:[],y:[]},o={x:[],y:[]},a=0,h=0;hn?(o.x.push(r[h]*i[h]),o.y.push(i[h]),s.x.push(r[h]),s.y.push(i[h]),h++,a++):(o.x[a-1]+=r[h]*i[h],o.y[a-1]+=i[h],s.x[a-1]=r[h],s.y[a-1]+=i[h],h++);for(var l=0;l=0;){var A=integral(0,f-m,x,g);if(v=w+A,h[S++]=(v-M)/o,S===n)break t;c=f,f+=o,M=v}w+=integral(m,d,x,y),m=d,g=p,b=d)throw new Error("x must be an increasing serie");for(;m-f>0;){if(x&&(M++,x=!1),u[b]=M<=0?0:y/M,++b===n)break t;c=f,f+=o,y=0,M=0}m>c&&(y+=g,M++),(m===-Number.MAX_VALUE||w>1)&&M--,m=d,g=p,v3&&void 0!==arguments[3]?arguments[3]:[];t>e&&([t,e]=[e,t]),i=i.filter(t=>void 0!==t.from&&void 0!==t.to),(i=JSON.parse(JSON.stringify(i))).forEach(t=>{t.from>t.to&&([t.to,t.from]=[t.from,t.to])}),i.sort((t,e)=>t.from-e.from),i.forEach(r=>{r.frome&&(r.to=e)});for(let t=0;ti[t+1].from&&(i[t].to=i[t+1].from);if(!(i=i.filter(t=>t.fromt+=e.to-e.from,0),s=(e-t-n)/r,o=[],a=t,h=0;for(let t of i){let e=Math.round((t.from-a)/s);h+=e,e>0&&o.push({from:a,to:t.from,numberOfPoints:e}),a=t.to}return r-h>0&&o.push({from:a,to:e,numberOfPoints:r-h}),o}function equallySpaced(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{x:r,y:i}=t,n=r.length,s=!1;r.length>1&&r[0]>r[1]&&(r=r.slice().reverse(),i=i.slice().reverse(),s=!0);let{from:o=r[0],to:a=r[n-1],variant:h="smooth",numberOfPoints:l=100,exclusions:u=[]}=e;if(n!==i.length)throw new RangeError("the x and y vector doesn't have the same size.");if("number"!=typeof o||isNaN(o))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 l||isNaN(l))throw new RangeError("'numberOfPoints' option must be a number");let c=getZones(o,a,l,u),f=[],m=[];for(let t of c){let e=processZone(r,i,t.from,t.to,t.numberOfPoints,h);f.push(...e.x),m.push(...e.y)}return s?o2&&void 0!==arguments[2]?arguments[2]:[];t>e&&([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.from1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t,{from:n=r[0],to:s=r[r.length-1],exclusions:o=[]}=e;let a=getZones$1(n,s,o),h=0,l=[],u=[],c=0;for(;c=a[h].from)l.push(r[c]),u.push(i[c]);else if(r[c]>a[h].to&&!a[++h])break;c++}return{x:l,y:u}}const{Matrix:Matrix$2,SVD:SVD,EVD:EVD,CholeskyDecomposition:CholeskyDecomposition$1,LuDecomposition:LuDecomposition$1,QrDecomposition:QrDecomposition$1}=MatrixLib,Array$1={min:min,max:max,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$7,exports.CholeskyDecomposition=CholeskyDecomposition$1,exports.ConfusionMatrix=src$1,exports.CrossValidation=src$3,exports.DecisionTreeClassifier=DecisionTreeClassifier,exports.DecisionTreeRegression=DecisionTreeRegression,exports.Distance=distances,exports.EVD=EVD,exports.ExponentialRegression=ExponentialRegression,exports.FCNNLS=index$2,exports.FNN=FeedForwardNeuralNetwork,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.PCA=PCA,exports.PLS=PLS,exports.Performance=src$5,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$4,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$3,exports.padArray=src$6,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&&o.pop()}for(m=0;mt[i[n]]-e[i[n]]);const s=Math.floor(t.length/2),o=new Node(t[s],n,r);return o.left=buildTree(t.slice(0,s),e+1,o,i),o.right=buildTree(t.slice(s+1),e+1,o,i),o}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,i=this.content[r];if(!(this.scoreFunction(e)2&&void 0!==arguments[2]?arguments[2]:{};if(!0===t){const t=e;return this.kdTree=new KDTree(t.kdTree,r),this.k=t.k,this.classes=new Set(t.classes),void(this.isEuclidean=t.isEuclidean)}const i=new Set(e),{distance:n=euclidean,k:s=i.size+1}=r,o=new Array(t.length);for(var a=0;a1&&void 0!==arguments[1]?arguments[1]:euclidean;if("KNN"!==t.name)throw new Error("invalid model: ".concat(t.name));if(!t.isEuclidean&&e===euclidean)throw new Error("a custom distance function was used to create the model. Please provide it again");if(t.isEuclidean&&e!==euclidean)throw new Error("the model was created with the default distance function. Do not load it with another one");return new KNN(!0,t,e)}toJSON(){return{name:"KNN",kdTree:this.kdTree,k:this.k,classes:Array.from(this.classes),isEuclidean:this.isEuclidean}}predict(t){if(Array.isArray(t)){if("number"==typeof t[0])return getSinglePrediction(this,t);if(Array.isArray(t[0])&&"number"==typeof t[0][0]){const r=new Array(t.length);for(var e=0;es&&(n=l,s=u)}return n}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(var r=0;rh&&ph;){var A=w.mmul(b);A.div(norm(A)),S=v,v=t.mmul(A);var E=x.mmul(v);E.div(norm(E)),b=e.mmul(E)}S=v;var R=w.mmul(S),k=S.transpose().mmul(S).get(0,0),C=R.div(k),T=norm(C);C.div(T),S.mul(T),A.mul(T),R=b.transpose().mmul(S),k=S.transpose().mmul(S).get(0,0);var N=R.div(k).get(0,0);t.sub(S.mmul(C.transpose())),e.sub(S.clone().mul(N).mmul(E.transpose())),u.setColumn(p,S),c.setColumn(p,C),f.setColumn(p,b),m.setColumn(p,E),d.setColumn(p,A),g.set(p,p,N),p++}p--,u=u.subMatrix(0,u.rows-1,0,p),c=c.subMatrix(0,c.rows-1,0,p),f=f.subMatrix(0,f.rows-1,0,p),m=m.subMatrix(0,m.rows-1,0,p),d=d.subMatrix(0,d.rows-1,0,p),g=g.subMatrix(0,p,0,p),this.ssqYcal=a,this.E=t,this.F=e,this.T=u,this.P=c,this.U=f,this.Q=m,this.W=d,this.B=g,this.PBQ=c.mmul(g).mmul(m.transpose()),this.R2X=S.transpose().mmul(S).mmul(C.transpose().mmul(C)).div(o).get(0,0)}predict(t){var e=Matrix.checkMatrix(t);this.scale&&(e=e.subRowVector(this.meanX).divRowVector(this.stdDevX));var r=e.mmul(this.PBQ);return r=r.mulRowVector(this.stdDevY).addRowVector(this.meanY)}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: ".concat(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();var r=this.kernel.compute(t),i=Matrix.eye(r.rows,r.rows,1),n=r;r=new Array(this.orthogonalComp+1);for(let t=0;t2&&void 0!==arguments[2]?arguments[2]:{};if(e.length!==t.length)throw new Error("predicted and actual must have the same length");r=i.labels?new Set(i.labels):new Set([...t,...e]),r=Array.from(r),i.sort&&r.sort(i.sort);const n=Array.from({length:r.length});for(let t=0;t=0&&o>=0&&n[s][o]++}return new ConfusionMatrix(n,r)}getMatrix(){return this.matrix}getLabels(){return this.labels}getTotalCount(){let t=0;for(var e=0;e1&&(l[e-1]=0);do{e++}while(l[e]>0);for(r=e-1,t=e;0===l[t];)l[t++]=-1;if(-1===l[t])l[t]=l[r],s=l[r]-1,i=t-1,n=r-1,l[r]=-1;else{if(t===l[0])return 0;l[e]=l[t],s=l[t]-1,l[t]=0,i=e-1,n=t-1}}return 1}if("index"===r.mode)for(yield a.slice();c();)a[s]=o[i],yield a.slice();else{if("mask"!==r.mode)throw new Error("Invalid mode");for(yield h.slice();c();)h[i]=1,h[n]=0,yield h.slice()}};const CV={};function check(t,e){if(t.length!==e.length)throw new Error("features and labels should have the same length")}function initMatrix(t,e){return new Array(t).fill(0).map(()=>new Array(e).fill(0))}function getDistinct(t){var e=new Set;for(let r=0;r=0;t--)c.splice(n[t],1);s?validateWithCallback(e,r,n,c,a,o,s):validate(t,e,r,i,n,c,a,o)}return new src$1(a,o)},CV.kFold=function(t,e,r,i,n){if("function"==typeof i){var s=i;n=r,r=e,e=t}check(e,r);const o=getDistinct(r),a=initMatrix(o.length,o.length);for(var h=e.length,l=new Array(h),u=0;u0?(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,i=r>1?r=>e.activation(r,t.activationParam):e.activation,n=r>1?r=>e.derivate(r,t.activationParam):e.derivate;this.activationFunction=function(t,e){this.set(t,e,i(this.get(t,e)))},this.derivate=function(t,e){this.set(t,e,n(this.get(t,e)))},t.model?(this.W=Matrix.Matrix.checkMatrix(t.W),this.b=Matrix.Matrix.checkMatrix(t.b)):(this.W=Matrix.Matrix.rand(this.inputSize,this.outputSize),this.b=Matrix.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=Matrix.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;--i){var s=i>0?this.model[i-1].a:t;n=this.model[i].backpropagation(n,s)}for(i=0;i0?e=this[t]-1:this.som.torus&&(e=this.som.gridDim[t]-1),void 0!==e)"x"===t?(r=e,i=this.y):(r=this.x,i=e),this.neighbors[t][0]=this.som.nodes[r][i];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),i=new Array(e),n=0;n0?("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,i,n,s,o=Date.now(),a=this._findBestMatchingUnit(t),h=Date.now();this.times.findBMU+=h-o;var l=Math.floor(e),u=a.x-l,c=a.x+l,f=a.y-l,m=a.y+l;for(r=u;r<=c;r++){var g=r;for(r<0?g+=this.x:r>=this.x&&(g-=this.x),i=f;i<=m;i++){var d=i;i<0?d+=this.y:i>=this.y&&(d-=this.y),(n=a[this.distanceMethod](this.nodes[g][d]))0&&e!==this.coefficients.length-1?o=" + ".concat(o):e!==this.coefficients.length-1&&(o=" ".concat(o))),s=o+s;return"+"===s.charAt(0)&&(s=s.slice(1)),"f(x) = ".concat(s)}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,i){const n=e.length;let s;if(Array.isArray(i))i=(s=i).length;else{i++,s=new Array(i);for(let t=0;t=0?"f(x) = ".concat(maybeToPrecision(this.B,t),"e^{").concat(maybeToPrecision(this.A,t),"x}"):"f(x) = \\frac{".concat(maybeToPrecision(this.B,t),"}{e^{").concat(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 i=e.length,n=new Array(i);for(let t=0;t=0?"f(x) = ".concat(maybeToPrecision(this.A,t),"x^{").concat(maybeToPrecision(this.B,t),"}"):"f(x) = \\frac{".concat(maybeToPrecision(this.A,t),"}{x^{").concat(maybeToPrecision(-this.B,t),"}}")).replace(/e([+-]?[0-9]+)/g,"e^{$1}")}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 i=e.length,n=new Array(i),s=new Array(i);for(let t=0;t2&&void 0!==arguments[2]?arguments[2]:{};const{intercept:i=!0,statistics:n=!0}=r;if(this.statistics=n,!0===t)this.weights=e.weights,this.inputs=e.inputs,this.outputs=e.outputs,this.intercept=e.intercept;else{t=new Matrix(t),e=new Matrix(e),i&&t.addColumn(new Array(t.rows).fill(1));let r=t.transpose();const s=r.mmul(t),o=r.mmul(e),a=new SingularValueDecomposition(s).inverse(),h=o.transpose().mmul(a).transpose();if(this.weights=h.to2DArray(),this.inputs=t.columns,this.outputs=e.columns,i&&this.inputs--,this.intercept=i,n){const r=t.mmul(h),i=e.clone().addM(r.neg()).to2DArray().map(t=>Math.pow(t[0],2)).reduce((t,e)=>t+e)/(e.rows-t.columns);this.stdError=Math.sqrt(i),this.stdErrorMatrix=pseudoInverse(s).mul(i),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 ".concat(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)}}const{squaredEuclidean:squaredEuclidean$1}=euclidean$1,defaultOptions$8={sigma:1};class GaussianKernel{constructor(t){t=Object.assign({},defaultOptions$8,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$9={degree:1,constant:1,scale:1};class PolynomialKernel{constructor(t){t=Object.assign({},defaultOptions$9,t),this.degree=t.degree,this.constant=t.constant,this.scale=t.scale}compute(t,e){for(var r=0,i=0;i0&&e!==this.coefficients.length-1?o=" + ".concat(o):e!==this.coefficients.length-1&&(o=" ".concat(o))),s=o+s;return"+"===s.charAt(0)&&(s=s.slice(1)),"f(x) = ".concat(s)}static load(t){if("robustPolynomialRegression"!==t.name)throw new TypeError("not a RobustPolynomialRegression model");return new RobustPolynomialRegression(!0,t)}}function robustPolynomial(t,e,r,i){let n=Array(i).fill(0).map((t,e)=>e);const s=getRandomTuples(e,r,i);for(var o,a=0;at.residual-e.residual);var e=t.length,r=Math.floor(e/2);return e%2==0?t[r-1]:t[r]}function errorCalculation(t,e,r){var i=0;const n=r(e);for(var s=0;sa(t)),l=gradientFunction(t,h,e,i,n),u=matrixFunction(t,h),c=inverse(o.add(l.mmul(l.transpose())));return(e=(e=new Matrix([e])).sub(c.mmul(l).mmul(u).mul(i).transpose())).to1DArray()}function levenbergMarquardt(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{maxIterations:i=100,gradientDifference:n=.1,damping:s=0,errorTolerance:o=.01,minValues:a,maxValues:h,initialValues:l}=r;if(s<=0)throw new Error("The damping option must be a positive number");if(!t.x||!t.y)throw new Error("The data parameter must have x and y elements");if(!Array.isArray(t.x)||t.x.length<2||!Array.isArray(t.y)||t.y.length<2)throw new Error("The data parameter elements must be an array with more than 2 points");if(t.x.length!==t.y.length)throw new Error("The data parameter elements must have the same size");var u=l||new Array(e.length).fill(1);let c=u.length;if(h=h||new Array(c).fill(Number.MAX_SAFE_INTEGER),a=a||new Array(c).fill(Number.MIN_SAFE_INTEGER),h.length!==a.length)throw new Error("minValues and maxValues must be the same size");if(!Array.isArray(u))throw new Error("initialValues must be an array");for(var f=errorCalculation(t,u,e),m=f<=o,g=0;g{let r=BigInt(0);return t.forEach(t=>r|=BigInt(1)<t.key-e.key<0?-1:1),i=[],n=[];for(let t of r)t.key!==e&&(e=t.key,n.push([]),i.push(t.value)),n[n.length-1].push(t.index);return{values:i,indices:n}}function cssls(t,e,r,i,n){let s=Matrix.zeros(i,n);if(null===r){let r=new CholeskyDecomposition(t);if(!0===r.isPositiveDefinite())s=r.solve(e);else{let r=new LuDecomposition(t);s=!1===r.isSingular()?r.solve(Matrix.eye(i)).mmul(e):solve(t,e,{useSVD:!0})}}else{let o=sortCollectionSet(r).values,a=sortCollectionSet(r).indices;if(1===o.length&&0===o[0].length&&a[0].length===n)return s;if(1===o.length&&o[0].length===i&&a[0].length===n){let r=new CholeskyDecomposition(t);if(!0===r.isPositiveDefinite())s=r.solve(e);else{let r=new LuDecomposition(t);s=!1===r.isSingular()?r.solve(Matrix.eye(i)).mmul(e):solve(t,e,{useSVD:!0})}}else for(let r=0;r0?l[t].push(e):h.set(e,t,0)}let u=[];for(let t=0;tt-e);return{Pset:s,Fset:n,W:o}}function fcnnls(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};t=Matrix.checkMatrix(t),e=Matrix.checkMatrix(e);let{l:i,p:n,iter:s,W:o,XtX:a,XtY:h,K:l,Pset:u,Fset:c,D:f}=initialisation(t,e);const{maxIterations:m=3*t.columns}=r;for(;c.length>0;){let t=cssls(a,h.subMatrixColumn(c),selection(u,c),i,c.length);for(let e=0;e0){let e=r.length,n=Matrix.ones(i,e);for(;e>0&&se===g[t]),1);t=cssls(a,h.subMatrixColumn(r),selection(u,r),i,e);for(let i=0;i2&&void 0!==arguments[2]?arguments[2]:{};if(!1===Array.isArray(e))throw new TypeError("y must be a 1D Array");return fcnnls(t,Matrix.columnVector(e),r).to1DArray()}var index$2=Object.freeze({__proto__:null,fcnnls:fcnnls,fcnnlsVector:fcnnlsVector}),binarySearch=function(t,e,r,i,n){var s,o;if(void 0===i)i=0;else if((i|=0)<0||i>=t.length)throw new RangeError("invalid lower bound");if(void 0===n)n=t.length-1;else if((n|=0)=t.length)throw new RangeError("invalid upper bound");for(;i<=n;)if((o=+r(t[s=i+(n-i>>>1)],e,s,t))<0)i=s+1;else{if(!(o>0))return s;n=s-1}return~i};function assertNumber(t){if("number"!=typeof t||Number.isNaN(t))throw new TypeError("Expected a number")}var ascending=(t,e)=>(assertNumber(t),assertNumber(e),t-e),descending=(t,e)=>(assertNumber(t),assertNumber(e),e-t),numSort={ascending:ascending,descending:descending},index$3=Object.freeze({__proto__:null,default:numSort,__moduleExports: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(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};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: ".concat(e));const r=void 0===t.minLoadFactor?defaultMinLoadFactor:t.minLoadFactor,i=void 0===t.maxLoadFactor?defaultMaxLoadFactor:t.maxLoadFactor;if(r<0||r>=1)throw new RangeError("invalid minLoadFactor: ".concat(r));if(i<=0||i>=1)throw new RangeError("invalid maxLoadFactor: ".concat(i));if(r>=i)throw new RangeError("minLoadFactor (".concat(r,") must be smaller than maxLoadFactor (").concat(i,")"));let n=e;0===(n=nextPrime(n=n/i|0))&&(n=1),this.table=newArray$1(n),this.values=newArray$1(n),this.state=newArray$1(n),this.minLoadFactor=r,this.maxLoadFactor=n===largestPrime?1:i,this.distinct=0,this.freeEntries=n,this.lowWaterMark=0,this.highWaterMark=chooseHighWaterMark(n,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,i=this.table.length,n=2147483647&t;let s=n%i,o=n%(i-2);for(0===o&&(o=1);r[s]!==FREE&&(r[s]===REMOVED||e[s]!==t);)(s-=o)<0&&(s+=i);return r[s]===FREE?-1:s}containsValue(t){return this.indexOfValue(t)>=0}indexOfValue(t){const e=this.values,r=this.state;for(var i=0;i2&&void 0!==arguments[2]?arguments[2]:{};if(t instanceof SparseMatrix){const e=t;this._init(e.rows,e.columns,e.elements.clone(),e.threshold)}else if(Array.isArray(t)){const o=t;t=o.length,r=e||{},e=o[0].length,this._init(t,e,new HashTable(r),r.threshold);for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;const r=Math.min(t,e),i=new SparseMatrix(t,e,{initialCapacity:r});for(var n=0;nthis.get(r,e)!==i?(t=!1,!1):i),t}bandWidth(){let t=this.columns,e=-1;return this.forEachNonZero((r,i,n)=>{let s=r-i;return t=Math.min(t,s),e=Math.max(e,s),n}),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,s,o)=>(r===t&&i.set(e,s,i.get(e,s)+n*o),o)),n)),i}kroneckerProduct(t){const e=this.rows,r=this.columns,i=t.rows,n=t.columns,s=new SparseMatrix(e*i,r*n,{initialCapacity:this.cardinality*t.cardinality});return this.forEachNonZero((e,r,o)=>(t.forEachNonZero((t,a,h)=>(s.set(i*e+t,n*r+a,o*h),h)),o)),s}forEachNonZero(t){return this.elements.forEachPair((e,r)=>{const i=e/this.columns|0,n=e%this.columns;let s=t(i,n,r);return!1!==s&&(this.threshold&&Math.abs(s)(e[n]=t,r[n]=s,i[n]=o,n++,o)),{rows:e,columns:r,values:i}}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,i)=>(t.set(r,e,i),i)),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;i1&&void 0!==arguments[1]?arguments[1]:{};var r=t[0];const{minWindow:i=.16,threshold:n=.01,from:s=r[0],to:o=r[r.length-1]}=e;return mainCreateTree(t[0],t[1],s,o,i,n)}function mainCreateTree(t,e,r,i,n,s){if(i-r=i);l++)a+=e[l],h+=t[l]*e[l];return a2&&void 0!==arguments[2]?arguments[2]:{};const{alpha:i=.1,beta:n=.33,gamma:s=.001}=r;return null===t||null===e?0:(Array.isArray(t)&&(t=createTree(t)),Array.isArray(e)&&(e=createTree(e)),n*(i*Math.min(t.sum,e.sum)/Math.max(t.sum,e.sum)+(1-i)*Math.exp(-s*Math.abs(t.center-e.center)))+(1-n)*(getSimilarity(t.left,e.left,r)+getSimilarity(t.right,e.right,r))/2)}function treeSimilarity(t,e){return getSimilarity(t,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{})}function getFunction(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(e,r)=>getSimilarity(e,r,t)}var index$4=Object.freeze({__proto__:null,treeSimilarity:treeSimilarity,getFunction:getFunction,createTree:createTree});function cosine(t,e){for(var r=t.length,i=0,n=0,s=0,o=0;o{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{const e=t.cutoffs.length,r=new Array(e);for(var i=0;i{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 i=t.length,n=t[0].length,s=!r.max,o=[];if(r.all)for(var a=0;at.pred-e.pred):o.sort((t,e)=>e.pred-t.pred);const l=this.cutoffs=[s?Number.MIN_VALUE:Number.MAX_VALUE],u=this.fp=[0],c=this.tp=[0];var f=0,m=0,g=o[0].pred,d=0,p=0;for(a=0;ar||e.size[1]>r)throw new RangeError("expanded value should not be bigger than the data length");for(n=0;n>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),i=0;i>5]&r)}function setBit(t,e,r){var i=e>>5,n=1<<31-e%32;return t[i]=r?n|t[i]:~n&t[i],t}function toBinaryString(t){for(var e="",r=0;r>>0).toString(2);e+="00000000000000000000000000000000".substr(i.length)+i}return e}function parseBinaryString(t){for(var e=t.length/32,r=new Array(e),i=0;i>>0).toString(16);e+="00000000".substr(i.length)+i}return e}function parseHexString(t){for(var e=t.length/8,r=new Array(e),i=0;ir&&(r=i,e=t[s])}return e}function norm$1(t){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).algorithm,r=void 0===e?"absolute":e;if(!Array.isArray(t))throw new Error("input must be an array");if(0===t.length)throw new Error("input must not be empty");switch(r.toLowerCase()){case"absolute":var i=absoluteSum(t);return 0===i?t.slice(0):t.map((function(t){return t/i}));case"max":var n=max(t);return 0===n?t.slice(0):t.map((function(t){return t/n}));case"sum":var s=sum(t);return 0===s?t.slice(0):t.map((function(t){return t/s}));default:throw new Error("norm: unknown algorithm: ".concat(r))}}function absoluteSum(t){for(var e=0,r=0;r0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("object"!==_typeof(t)||src(t)||(e=t,t=[]),!src(t))throw new TypeError("input must be an array");var r=e,i=r.from,n=void 0===i?0:i,s=r.to,o=void 0===s?10:s,a=r.size,h=void 0===a?t.length:a,l=r.step;if(h&&l)throw new Error("step is defined by the array size");if(h||(h=l?Math.floor((o-n)/l)+1:o-n+1),!l&&h&&(l=(o-n)/(h-1)),Array.isArray(t)){t.length=0;for(var u=0;u1&&void 0!==arguments[1]?arguments[1]:{};if(!src(t))throw new TypeError("input must be an array");for(var r=e.unbiased,i=void 0===r||r,n=e.mean,s=void 0===n?mean(t):n,o=0,a=0;a1&&void 0!==arguments[1]?arguments[1]:{};return Math.sqrt(variance(t,e))}function mergeByCentroids(t,e){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{window:i=.01}=r;for(var n={x:e.slice(),y:new Array(e.length).fill(0)},s=0,o=0;s=0?{x:r[o],y:i[o]}:0!==(o=~o)&&Math.abs(r[o]-n)>.5||o===r.length?{x:r[o-1],y:i[o-1]}:{x:r[o],y:i[o]}}function covariance$1(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t,{unbiased:n=!0}=e,s=mean(r),o=mean(i);var a=0;for(let t=0;t1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t,{groupWidth:n=.001}=e;for(var s={x:[],y:[]},o={x:[],y:[]},a=0,h=0;hn?(o.x.push(r[h]),o.y.push(i[h]),s.x.push(r[h]),s.y.push(i[h]),h++,a++):(i[h]>o.y[a-1]&&(o.x[a-1]=r[h],o.y[a-1]=i[h]),s.x[a-1]=r[h],s.y[a-1]+=i[h],h++);return s.x=o.x.slice(),s}function maxY(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t;let{from:n={index:0},to:s={index:r.length},reverse:o=!1}=e;void 0!==n.value&&void 0===n.index&&(n.index=calculateIndex(n.value,r,o)),void 0!==s.value&&void 0===s.index&&(s.index=calculateIndex(s.value,r,o));for(var a,h=Number.MIN_VALUE,l=n.index;l1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t,{reverse:n=!1}=e;var s;s=n?(t,e)=>e.x-t.x:(t,e)=>t.x-e.x;for(var o=r.map((t,e)=>({x:t,y:i[e]})).sort(s),a={x:r.slice(),y:i.slice()},h=0;h0&&void 0!==arguments[0]?arguments[0]:{};const{x:e,y:r}=t;if(e.length<2)return;if(e.length!==r.length)throw new Error("The X and Y arrays mush have the same length");let i=e[0],n=0;for(let t=1;t1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t,{groupWidth:n=.001}=e;for(var s={x:[],y:[]},o={x:[],y:[]},a=0,h=0;hn?(o.x.push(r[h]*i[h]),o.y.push(i[h]),s.x.push(r[h]),s.y.push(i[h]),h++,a++):(o.x[a-1]+=r[h]*i[h],o.y[a-1]+=i[h],s.x[a-1]=r[h],s.y[a-1]+=i[h],h++);for(var l=0;l=0;){var A=integral(0,f-m,x,g);if(v=w+A,h[S++]=(v-y)/o,S===n)break t;c=f,f+=o,y=v}w+=integral(m,d,x,M),m=d,g=p,b=d)throw new Error("x must be an increasing serie");for(;m-f>0;){if(x&&(y++,x=!1),u[b]=y<=0?0:M/y,++b===n)break t;c=f,f+=o,M=0,y=0}m>c&&(M+=g,y++),(m===-Number.MAX_VALUE||w>1)&&y--,m=d,g=p,v3&&void 0!==arguments[3]?arguments[3]:[];t>e&&([t,e]=[e,t]),i=i.filter(t=>void 0!==t.from&&void 0!==t.to),(i=JSON.parse(JSON.stringify(i))).forEach(t=>{t.from>t.to&&([t.to,t.from]=[t.from,t.to])}),i.sort((t,e)=>t.from-e.from),i.forEach(r=>{r.frome&&(r.to=e)});for(let t=0;ti[t+1].from&&(i[t].to=i[t+1].from);if(!(i=i.filter(t=>t.fromt+=e.to-e.from,0),s=(e-t-n)/r,o=[],a=t,h=0;for(let t of i){let e=Math.round((t.from-a)/s);h+=e,e>0&&o.push({from:a,to:t.from,numberOfPoints:e}),a=t.to}return r-h>0&&o.push({from:a,to:e,numberOfPoints:r-h}),o}function equallySpaced(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{x:r,y:i}=t,n=r.length,s=!1;r.length>1&&r[0]>r[1]&&(r=r.slice().reverse(),i=i.slice().reverse(),s=!0);let{from:o=r[0],to:a=r[n-1],variant:h="smooth",numberOfPoints:l=100,exclusions:u=[]}=e;if(n!==i.length)throw new RangeError("the x and y vector doesn't have the same size.");if("number"!=typeof o||isNaN(o))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 l||isNaN(l))throw new RangeError("'numberOfPoints' option must be a number");if(l<2)throw new RangeError("'numberOfPoints' option must be greater than 1");let c=getZones(o,a,l,u),f=[],m=[];for(let t of c){let e=processZone(r,i,t.from,t.to,t.numberOfPoints,h);f=f.concat(e.x),m=m.concat(e.y)}return s?o2&&void 0!==arguments[2]?arguments[2]:[];t>e&&([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.from1&&void 0!==arguments[1]?arguments[1]:{};const{x:r,y:i}=t,{from:n=r[0],to:s=r[r.length-1],exclusions:o=[]}=e;let a=getZones$1(n,s,o),h=0,l=[],u=[],c=0;for(;c=a[h].from)l.push(r[c]),u.push(i[c]);else if(r[c]>a[h].to&&!a[++h])break;c++}return{x:l,y:u}}const{Matrix:Matrix$2,SVD:SVD,EVD:EVD,CholeskyDecomposition:CholeskyDecomposition$1,LuDecomposition:LuDecomposition$1,QrDecomposition:QrDecomposition$1}=MatrixLib,Array$1={min:min,max:max,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$7,exports.CholeskyDecomposition=CholeskyDecomposition$1,exports.ConfusionMatrix=src$1,exports.CrossValidation=src$3,exports.DecisionTreeClassifier=DecisionTreeClassifier,exports.DecisionTreeRegression=DecisionTreeRegression,exports.Distance=distances,exports.EVD=EVD,exports.ExponentialRegression=ExponentialRegression,exports.FCNNLS=index$2,exports.FNN=FeedForwardNeuralNetwork,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.PCA=PCA,exports.PLS=PLS,exports.Performance=src$5,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$4,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$3,exports.padArray=src$6,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 723c8a2..7d50fd8 100644 --- a/dist/ml.min.js.map +++ b/dist/ml.min.js.map @@ -1 +1 @@ -{"version":3,"file":"ml.min.js","sources":["../node_modules/is-any-array/src/index.js","../node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-rescale/lib-es6/index.js","../node_modules/ml-matrix/src/util.js","../node_modules/ml-matrix/src/stat.js","../node_modules/ml-matrix/src/inspect.js","../node_modules/ml-matrix/src/mathOperations.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/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/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/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/src/index.js","../node_modules/ml-cross-validation/src/index.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/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-array-mode/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/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-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/getZones.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":["'use strict';\n\nconst toString = Object.prototype.toString;\n\nfunction isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n\nmodule.exports = isAnyArray;\n","import isArray from 'is-any-array';\n\n/**\n * Computes the maximum of the given values\n * @param {Array} input\n * @return {number}\n */\n\nfunction max(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 = input[0];\n\n for (var i = 1; i < input.length; 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\n/**\n * Computes the minimum of the given values\n * @param {Array} input\n * @return {number}\n */\n\nfunction min(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 minValue = input[0];\n\n for (var i = 1; i < input.length; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import max from 'ml-array-max';\nimport min from 'ml-array-min';\nimport isArray from 'is-any-array';\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","/**\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","export function inspectMatrix() {\n const indent = ' '.repeat(2);\n const indentData = ' '.repeat(4);\n return `${this.constructor.name} {\n${indent}[\n${indentData}${inspectData(this, indentData)}\n${indent}]\n${indent}rows: ${this.rows}\n${indent}columns: ${this.columns}\n}`;\n}\n\nconst maxRows = 15;\nconst maxColumns = 10;\nconst maxNumSize = 8;\n\nfunction inspectData(matrix, indent) {\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)));\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${indent}`);\n}\n\nfunction formatNumber(num) {\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.substring(eIndex);\n return exponential.substring(0, maxNumSize - e.length) + e;\n}\n","export function installMathOperations(AbstractMatrix, Matrix) {\n AbstractMatrix.prototype.add = function add(value) {\n if (typeof value === 'number') return this.addS(value);\n return this.addM(value);\n };\n\n AbstractMatrix.prototype.addS = function addS(value) {\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) + value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.addM = function addM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) + matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.add = function add(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.add(value);\n };\n\n AbstractMatrix.prototype.sub = function sub(value) {\n if (typeof value === 'number') return this.subS(value);\n return this.subM(value);\n };\n\n AbstractMatrix.prototype.subS = function subS(value) {\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) - value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.subM = function subM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) - matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.sub = function sub(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sub(value);\n };\n AbstractMatrix.prototype.subtract = AbstractMatrix.prototype.sub;\n AbstractMatrix.prototype.subtractS = AbstractMatrix.prototype.subS;\n AbstractMatrix.prototype.subtractM = AbstractMatrix.prototype.subM;\n AbstractMatrix.subtract = AbstractMatrix.sub;\n\n AbstractMatrix.prototype.mul = function mul(value) {\n if (typeof value === 'number') return this.mulS(value);\n return this.mulM(value);\n };\n\n AbstractMatrix.prototype.mulS = function mulS(value) {\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) * value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.mulM = function mulM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) * matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.mul = function mul(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.mul(value);\n };\n AbstractMatrix.prototype.multiply = AbstractMatrix.prototype.mul;\n AbstractMatrix.prototype.multiplyS = AbstractMatrix.prototype.mulS;\n AbstractMatrix.prototype.multiplyM = AbstractMatrix.prototype.mulM;\n AbstractMatrix.multiply = AbstractMatrix.mul;\n\n AbstractMatrix.prototype.div = function div(value) {\n if (typeof value === 'number') return this.divS(value);\n return this.divM(value);\n };\n\n AbstractMatrix.prototype.divS = function divS(value) {\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) / value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.divM = function divM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) / matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.div = function div(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.div(value);\n };\n AbstractMatrix.prototype.divide = AbstractMatrix.prototype.div;\n AbstractMatrix.prototype.divideS = AbstractMatrix.prototype.divS;\n AbstractMatrix.prototype.divideM = AbstractMatrix.prototype.divM;\n AbstractMatrix.divide = AbstractMatrix.div;\n\n AbstractMatrix.prototype.mod = function mod(value) {\n if (typeof value === 'number') return this.modS(value);\n return this.modM(value);\n };\n\n AbstractMatrix.prototype.modS = function modS(value) {\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) % value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.modM = function modM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) % matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.mod = function mod(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.mod(value);\n };\n AbstractMatrix.prototype.modulus = AbstractMatrix.prototype.mod;\n AbstractMatrix.prototype.modulusS = AbstractMatrix.prototype.modS;\n AbstractMatrix.prototype.modulusM = AbstractMatrix.prototype.modM;\n AbstractMatrix.modulus = AbstractMatrix.mod;\n\n AbstractMatrix.prototype.and = function and(value) {\n if (typeof value === 'number') return this.andS(value);\n return this.andM(value);\n };\n\n AbstractMatrix.prototype.andS = function andS(value) {\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) & value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.andM = function andM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) & matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.and = function and(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.and(value);\n };\n\n AbstractMatrix.prototype.or = function or(value) {\n if (typeof value === 'number') return this.orS(value);\n return this.orM(value);\n };\n\n AbstractMatrix.prototype.orS = function orS(value) {\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) | value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.orM = function orM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) | matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.or = function or(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.or(value);\n };\n\n AbstractMatrix.prototype.xor = function xor(value) {\n if (typeof value === 'number') return this.xorS(value);\n return this.xorM(value);\n };\n\n AbstractMatrix.prototype.xorS = function xorS(value) {\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) ^ value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.xorM = function xorM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) ^ matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.xor = function xor(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.xor(value);\n };\n\n AbstractMatrix.prototype.leftShift = function leftShift(value) {\n if (typeof value === 'number') return this.leftShiftS(value);\n return this.leftShiftM(value);\n };\n\n AbstractMatrix.prototype.leftShiftS = function leftShiftS(value) {\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) << value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.leftShiftM = function leftShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) << matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.leftShift = function leftShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.leftShift(value);\n };\n\n AbstractMatrix.prototype.signPropagatingRightShift = function signPropagatingRightShift(value) {\n if (typeof value === 'number') return this.signPropagatingRightShiftS(value);\n return this.signPropagatingRightShiftM(value);\n };\n\n AbstractMatrix.prototype.signPropagatingRightShiftS = function signPropagatingRightShiftS(value) {\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) >> value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.signPropagatingRightShiftM = function signPropagatingRightShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) >> matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.signPropagatingRightShift = function signPropagatingRightShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.signPropagatingRightShift(value);\n };\n\n AbstractMatrix.prototype.rightShift = function rightShift(value) {\n if (typeof value === 'number') return this.rightShiftS(value);\n return this.rightShiftM(value);\n };\n\n AbstractMatrix.prototype.rightShiftS = function rightShiftS(value) {\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) >>> value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.rightShiftM = function rightShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) >>> matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.rightShift = function rightShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.rightShift(value);\n };\n AbstractMatrix.prototype.zeroFillRightShift = AbstractMatrix.prototype.rightShift;\n AbstractMatrix.prototype.zeroFillRightShiftS = AbstractMatrix.prototype.rightShiftS;\n AbstractMatrix.prototype.zeroFillRightShiftM = AbstractMatrix.prototype.rightShiftM;\n AbstractMatrix.zeroFillRightShift = AbstractMatrix.rightShift;\n\n AbstractMatrix.prototype.not = function not() {\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)));\n }\n }\n return this;\n };\n\n AbstractMatrix.not = function not(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.not();\n };\n\n AbstractMatrix.prototype.abs = function abs() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.abs(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.abs = function abs(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.abs();\n };\n\n AbstractMatrix.prototype.acos = function acos() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.acos(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.acos = function acos(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.acos();\n };\n\n AbstractMatrix.prototype.acosh = function acosh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.acosh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.acosh = function acosh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.acosh();\n };\n\n AbstractMatrix.prototype.asin = function asin() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.asin(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.asin = function asin(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.asin();\n };\n\n AbstractMatrix.prototype.asinh = function asinh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.asinh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.asinh = function asinh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.asinh();\n };\n\n AbstractMatrix.prototype.atan = function atan() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.atan(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.atan = function atan(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.atan();\n };\n\n AbstractMatrix.prototype.atanh = function atanh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.atanh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.atanh = function atanh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.atanh();\n };\n\n AbstractMatrix.prototype.cbrt = function cbrt() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cbrt(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cbrt = function cbrt(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cbrt();\n };\n\n AbstractMatrix.prototype.ceil = function ceil() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.ceil(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.ceil = function ceil(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.ceil();\n };\n\n AbstractMatrix.prototype.clz32 = function clz32() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.clz32(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.clz32 = function clz32(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.clz32();\n };\n\n AbstractMatrix.prototype.cos = function cos() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cos(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cos = function cos(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cos();\n };\n\n AbstractMatrix.prototype.cosh = function cosh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cosh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cosh = function cosh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cosh();\n };\n\n AbstractMatrix.prototype.exp = function exp() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.exp(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.exp = function exp(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.exp();\n };\n\n AbstractMatrix.prototype.expm1 = function expm1() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.expm1(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.expm1 = function expm1(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.expm1();\n };\n\n AbstractMatrix.prototype.floor = function floor() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.floor(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.floor = function floor(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.floor();\n };\n\n AbstractMatrix.prototype.fround = function fround() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.fround(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.fround = function fround(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.fround();\n };\n\n AbstractMatrix.prototype.log = function log() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log = function log(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log();\n };\n\n AbstractMatrix.prototype.log1p = function log1p() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log1p(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log1p = function log1p(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log1p();\n };\n\n AbstractMatrix.prototype.log10 = function log10() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log10(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log10 = function log10(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log10();\n };\n\n AbstractMatrix.prototype.log2 = function log2() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log2(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log2 = function log2(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log2();\n };\n\n AbstractMatrix.prototype.round = function round() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.round(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.round = function round(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.round();\n };\n\n AbstractMatrix.prototype.sign = function sign() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sign(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sign = function sign(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sign();\n };\n\n AbstractMatrix.prototype.sin = function sin() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sin(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sin = function sin(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sin();\n };\n\n AbstractMatrix.prototype.sinh = function sinh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sinh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sinh = function sinh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sinh();\n };\n\n AbstractMatrix.prototype.sqrt = function sqrt() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sqrt(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sqrt = function sqrt(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sqrt();\n };\n\n AbstractMatrix.prototype.tan = function tan() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.tan(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.tan = function tan(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.tan();\n };\n\n AbstractMatrix.prototype.tanh = function tanh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.tanh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.tanh = function tanh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.tanh();\n };\n\n AbstractMatrix.prototype.trunc = function trunc() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.trunc(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.trunc = function trunc(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.trunc();\n };\n\n AbstractMatrix.pow = function pow(matrix, arg0) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.pow(arg0);\n };\n\n AbstractMatrix.prototype.pow = function pow(value) {\n if (typeof value === 'number') return this.powS(value);\n return this.powM(value);\n };\n\n AbstractMatrix.prototype.powS = function powS(value) {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.pow(this.get(i, j), value));\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.powM = function powM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j)));\n }\n }\n return this;\n };\n}\n","import rescale from 'ml-array-rescale';\n\nimport {\n checkRowVector,\n checkRowIndex,\n checkColumnIndex,\n checkColumnVector,\n checkRange,\n checkIndices,\n} from './util';\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 { inspectMatrix } from './inspect';\nimport { installMathOperations } from './mathOperations';\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\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';\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';\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';\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';\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';\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';\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 Matrix from './matrix';\nimport LuDecomposition from './dc/lu';\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 Matrix from './matrix';\nimport SingularValueDecomposition from './dc/svd';\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))\n .abs()\n .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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 WrapperMatrix2D from '../wrap/WrapperMatrix2D';\nimport Matrix from '../matrix';\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()\n .mmul(u)\n .div(\n u\n .transpose()\n .mmul(u)\n .get(0, 0),\n );\n w = w.div(w.norm());\n\n t = X.mmul(w).div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n );\n\n if (counter > 0) {\n diff = t\n .clone()\n .sub(tOld)\n .pow(2)\n .sum();\n }\n tOld = t.clone();\n\n if (Y) {\n q = Y.transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n q = q.div(q.norm());\n\n u = Y.mmul(q).div(\n q\n .transpose()\n .mmul(q)\n .get(0, 0),\n );\n } else {\n u = t;\n }\n }\n\n if (Y) {\n let p = X.transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n p = p.div(p.norm());\n let xResidual = X.clone().sub(t.clone().mmul(p.transpose()));\n let residual = u\n .transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n let yResidual = Y.clone().sub(\n t\n .clone()\n .mulS(residual.get(0, 0))\n .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\n .transpose()\n .mmul(t)\n .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","import isArray from 'is-any-array';\n\n/**\n * Computes the mean of the given values\n * @param {Array} input\n * @return {number}\n */\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\n/**\n * Computes the mean of the given values\n * @param {Array} input\n * @return {number}\n */\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 var counts = new Array(numberOfClasses).fill(0);\n for (var 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 var probabilities = toDiscreteDistribution(\n array,\n getNumberOfClasses(array)\n ).getRow(0);\n\n var sum = 0.0;\n for (var 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.filter(function (val, i, arr) {\n return arr.indexOf(val) === i;\n }).length;\n}\n\n/**\n * @private\n * Calculates the Gini Gain of an array of predictions and those predictions splitted by a feature.\n * @para {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 var splitsImpurity = 0.0;\n var splits = ['greater', 'lesser'];\n\n for (var i = 0; i < splits.length; ++i) {\n var 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 var l = array.length;\n\n var m = meanArray(array);\n var squaredError = 0.0;\n\n for (var i = 0; i < l; ++i) {\n var currentElement = array[i];\n squaredError += (currentElement - m) * (currentElement - m);\n }\n\n return squaredError;\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 var error = 0.0;\n var splits = ['greater', 'lesser'];\n\n for (var i = 0; i < splits.length; ++i) {\n var 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 var lesserX = [];\n var greaterX = [];\n var lesserY = [];\n var greaterY = [];\n\n for (var 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: ${\n b.length\n }`\n );\n }\n\n var ret = new Array(a.length);\n for (var 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 var bestGain = this.kind === 'classifier' ? -Infinity : Infinity;\n var check = this.kind === 'classifier' ? (a, b) => a > b : (a, b) => a < b;\n\n var maxColumn;\n var maxValue;\n\n for (var i = 0; i < XTranspose.rows; ++i) {\n var currentFeature = XTranspose.getRow(i);\n var splitValues = this.featureSplit(currentFeature, y);\n for (var j = 0; j < splitValues.length; ++j) {\n var currentSplitVal = splitValues[j];\n var splitted = this.split(currentFeature, y, currentSplitVal);\n\n var 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 var lesser = [];\n var greater = [];\n\n for (var 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 var splitValues = [];\n var arr = Utils.zip(x, y);\n arr.sort(function (a, b) {\n return a[0] - b[0];\n });\n\n for (var 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 var XTranspose = X.transpose();\n var split = this.bestSplit(XTranspose, y);\n\n this.splitValue = split.maxValue;\n this.splitColumn = split.maxColumn;\n this.gain = split.maxGain;\n\n var 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 var lesserX = new Matrix(splittedMatrix.lesserX);\n var 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 var predictions = new Array(toPredict.rows);\n\n for (var 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 (typeof trainingSet[0] !== 'undefined' && trainingSet[0].length === undefined) {\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 (typeof toPredict[0] !== 'undefined' && toPredict[0].length === undefined) {\n toPredict = Matrix.columnVector(toPredict);\n }\n toPredict = Matrix.checkMatrix(toPredict);\n\n var predictions = new Array(toPredict.rows);\n for (var 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/**\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 var engine;\n var 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 var Xr = new Array(trainingSet.rows);\n var yr = new Array(trainingSet.rows);\n\n for (var i = 0; i < trainingSet.rows; ++i) {\n var 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 var distribution = Random.integer(0, trainingSet.columns - 1);\n var 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 var toRet = new Matrix(trainingSet.rows, n);\n\n if (replacement) {\n var usedIndex = new Array(n);\n for (var i = 0; i < n; ++i) {\n var 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 (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 { Matrix, WrapperMatrix2D, MatrixTransposeView, MatrixColumnSelectionView } 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 var 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 if (this.isClassifier) {\n var 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 (var i = 0; i < this.nEstimators; ++i) {\n var res = this.useSampleBagging\n ? Utils.examplesBaggingWithReplacement(\n trainingSet,\n trainingValues,\n this.seed\n )\n : { X: trainingSet, y: trainingValues };\n var X = res.X;\n var 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 var predictionValues = new Array(this.nEstimators);\n toPredict = Matrix.checkMatrix(toPredict);\n for (var i = 0; i < this.nEstimators; ++i) {\n var 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(new WrapperMatrix2D(predictionValues));\n var predictions = new Array(predictionValues.rows);\n for (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 var 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","(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 quickSelectMedian from 'median-quickselect';\nimport isArray from 'is-any-array';\n\n/**\n * Computes the median of the given values\n * @param {Array} input\n * @return {number}\n */\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 var 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 {boolean} [options.method='SVD'] - select which method to use: SVD (default), covarianceMatrirx or NIPALS.\n * @param {boolean} [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 };\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(X.clone().apply(pow2array).sum());\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 var means = dataset.mean('column');\n var std = dataset.standardDeviation('column', { mean: means, unbiased: true });\n var 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 (var i = 0; i < array.length; ++i) {\n for (var j = 0; j < array[i].length; ++j) {\n var elem = array[i][j];\n array[i][j] = elem !== null ? new Matrix(array[i][j]) : undefined;\n }\n }\n } else {\n for (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 './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 var {\n tolerance = 1e-5,\n scale = true,\n } = 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('The number of X rows must be equal to the number of Y rows');\n }\n\n this.meanX = trainingSet.mean('column');\n this.stdDevX = trainingSet.standardDeviation('column', { mean: this.meanX, unbiased: true });\n this.meanY = trainingValues.mean('column');\n this.stdDevY = trainingValues.standardDeviation('column', { mean: this.meanY, unbiased: true });\n\n if (this.scale) {\n trainingSet = trainingSet.clone().subRowVector(this.meanX).divRowVector(this.stdDevX);\n trainingValues = trainingValues.clone().subRowVector(this.meanY).divRowVector(this.stdDevY);\n }\n\n if (this.latentVectors === undefined) {\n this.latentVectors = Math.min(trainingSet.rows - 1, trainingSet.columns);\n }\n\n var rx = trainingSet.rows;\n var cx = trainingSet.columns;\n var ry = trainingValues.rows;\n var cy = trainingValues.columns;\n\n var ssqXcal = trainingSet.clone().mul(trainingSet).sum(); // for the r²\n var sumOfSquaresY = trainingValues.clone().mul(trainingValues).sum();\n\n var tolerance = this.tolerance;\n var n = this.latentVectors;\n var T = Matrix.zeros(rx, n);\n var P = Matrix.zeros(cx, n);\n var U = Matrix.zeros(ry, n);\n var Q = Matrix.zeros(cy, n);\n var B = Matrix.zeros(n, n);\n var W = P.clone();\n var k = 0;\n\n while (Utils.norm(trainingValues) > tolerance && k < n) {\n var transposeX = trainingSet.transpose();\n var transposeY = trainingValues.transpose();\n\n var tIndex = maxSumColIndex(trainingSet.clone().mul(trainingSet));\n var uIndex = maxSumColIndex(trainingValues.clone().mul(trainingValues));\n\n var t1 = trainingSet.getColumnVector(tIndex);\n var u = trainingValues.getColumnVector(uIndex);\n var t = Matrix.zeros(rx, 1);\n\n while (Utils.norm(t1.clone().sub(t)) > tolerance) {\n var w = transposeX.mmul(u);\n w.div(Utils.norm(w));\n t = t1;\n t1 = trainingSet.mmul(w);\n var q = transposeY.mmul(t1);\n q.div(Utils.norm(q));\n u = trainingValues.mmul(q);\n }\n\n t = t1;\n var num = transposeX.mmul(t);\n var den = t.transpose().mmul(t).get(0, 0);\n var p = num.div(den);\n var 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.transpose().mmul(t).get(0, 0);\n var b = num.div(den).get(0, 0);\n trainingSet.sub(t.mmul(p.transpose()));\n trainingValues.sub(t.clone().mul(b).mmul(q.transpose()));\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 // TODO: review of R2Y\n // this.R2Y = t.transpose().mmul(t).mul(q[k][0]*q[k][0]).divS(ssqYcal)[0][0];\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.transpose().mmul(t).mmul(p.transpose().mmul(p)).div(ssqXcal).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 var X = Matrix.checkMatrix(dataset);\n if (this.scale) {\n X = X.subRowVector(this.meanX).divRowVector(this.stdDevX);\n }\n var 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 './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(model.TURegressionCoeff, false);\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 var kernelX = this.kernel.compute(trainingSet);\n\n var Identity = Matrix.eye(kernelX.rows, kernelX.rows, 1);\n var 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 var result = new SingularValueDecomposition(trainingValues.transpose().mmul(kernelX[0][0]).mmul(trainingValues), {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false\n });\n var YLoadingMat = result.leftSingularVectors;\n var Sigma = result.diagonalMatrix;\n\n YLoadingMat = YLoadingMat.subMatrix(0, YLoadingMat.rows - 1, 0, this.predictiveComp - 1);\n Sigma = Sigma.subMatrix(0, this.predictiveComp - 1, 0, this.predictiveComp - 1);\n\n var YScoreMat = trainingValues.mmul(YLoadingMat);\n\n var predScoreMat = new Array(this.orthogonalComp + 1);\n var TURegressionCoeff = new Array(this.orthogonalComp + 1);\n var YOrthScoreMat = new Array(this.orthogonalComp);\n var YOrthLoadingVec = new Array(this.orthogonalComp);\n var YOrthEigen = new Array(this.orthogonalComp);\n var YOrthScoreNorm = new Array(this.orthogonalComp);\n\n var 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 (var i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = kernelX[0][i].transpose().mmul(YScoreMat).mmul(SigmaPow);\n\n var TpiPrime = predScoreMat[i].transpose();\n TURegressionCoeff[i] = inverse(TpiPrime.mmul(predScoreMat[i])).mmul(TpiPrime).mmul(YScoreMat);\n\n result = new SingularValueDecomposition(TpiPrime.mmul(Matrix.sub(kernelX[i][i], predScoreMat[i].mmul(TpiPrime))).mmul(predScoreMat[i]), {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false\n });\n var CoTemp = result.leftSingularVectors;\n var 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(kernelX[i][i], predScoreMat[i].mmul(TpiPrime)).mmul(predScoreMat[i]).mmul(YOrthLoadingVec[i]).mul(Math.pow(YOrthEigen[i], -0.5));\n\n var toiPrime = YOrthScoreMat[i].transpose();\n YOrthScoreNorm[i] = Matrix.sqrt(toiPrime.mmul(YOrthScoreMat[i]));\n\n YOrthScoreMat[i] = YOrthScoreMat[i].divRowVector(YOrthScoreNorm[i]);\n\n var ITo = Matrix.sub(Identity, YOrthScoreMat[i].mmul(YOrthScoreMat[i].transpose()));\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 var lastScoreMat = predScoreMat[this.orthogonalComp] = kernelX[0][this.orthogonalComp].transpose().mmul(YScoreMat).mmul(SigmaPow);\n\n var lastTpPrime = lastScoreMat.transpose();\n TURegressionCoeff[this.orthogonalComp] = inverse(lastTpPrime.mmul(lastScoreMat)).mmul(lastTpPrime).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 var KTestTrain = this.kernel.compute(toPredict, this.trainingSet);\n\n var 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 var YOrthScoreVector = new Array(this.orthogonalComp);\n var predScoreMat = new Array(this.orthogonalComp);\n\n var i;\n for (i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = KTestTrain[i][0].mmul(this.YScoreMat).mmul(this.SigmaPow);\n\n YOrthScoreVector[i] = Matrix.sub(KTestTrain[i][i], predScoreMat[i].mmul(this.predScoreMat[i].transpose())).mmul(this.predScoreMat[i]).mmul(this.YOrthLoadingVec[i]).mul(Math.pow(this.YOrthEigen[i], -0.5));\n\n YOrthScoreVector[i] = YOrthScoreVector[i].divRowVector(this.toNorm[i]);\n\n var scoreMatPrime = this.YOrthScoreMat[i].transpose();\n KTestTrain[i + 1][0] = Matrix.sub(KTestTrain[i][0], YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[0][i].transpose()));\n\n var p1 = Matrix.sub(KTestTrain[i][0], KTestTrain[i][i].mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime));\n var p2 = YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[i][i]);\n var 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 var prediction = predScoreMat[i].mmul(this.TURegressionCoeff[i]).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 */\nclass 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('Confusion matrix and labels should have the same length');\n }\n this.labels = labels;\n this.matrix = matrix;\n }\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 (var i = 0; i < this.matrix.length; i++) {\n for (var 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 var count = 0;\n for (var 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 var count = 0;\n for (var i = 0; i < this.matrix.length; i++) {\n for (var 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 var count = 0;\n for (var 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 var count = 0;\n for (var 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 2 * TP / (2 * TP + this.getFalsePositiveCount(label) + this.getFalseNegativeCount(label));\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 (TP * TN - FP * FN) / Math.sqrt((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN));\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 this.getTruePositiveRate(label) + this.getTrueNegativeRate(label) - 1;\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 this.getPositivePredictiveValue(label) + this.getNegativePredictiveValue(label) - 1;\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 [\n this.getTruePositiveCount(label),\n this.getFalseNegativeCount(label)\n ],\n [\n this.getFalsePositiveCount(label),\n this.getTrueNegativeCount(label)\n ]\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 (var i = 0; i < this.matrix.length; i++) {\n for (var 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 /**\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\nmodule.exports = ConfusionMatrix;\n","'use strict';\nconst defaultOptions = {\n mode: 'index'\n};\n\nmodule.exports = function *(M, N, options) {\n options = Object.assign({}, defaultOptions, options);\n var a = new Array(N);\n var c = new Array(M);\n var b = new Array(N);\n var p = new Array(N + 2);\n var x, y, z;\n\n // init a and b\n for (var i = 0; i < N; i++) {\n a[i] = i;\n if (i < N - M) b[i] = 0;\n else b[i] = 1;\n }\n\n // init c\n for (i = 0; i < M; i++) {\n c[i] = N - M + i;\n }\n\n // init p\n for (i = 0; i < p.length; i++) {\n if (i === 0) p[i] = N + 1;\n else if (i <= N - M) p[i] = 0;\n else if (i <= N) p[i] = i - N + M;\n else p[i] = -2;\n }\n\n function twiddle() {\n var i, j, k;\n j = 1;\n while (p[j] <= 0) {\n j++;\n }\n if (p[j - 1] === 0) {\n for (i = j - 1; i !== 1; i--) {\n p[i] = -1;\n }\n p[j] = 0;\n x = z = 0;\n p[1] = 1;\n y = j - 1;\n } else {\n if (j > 1) {\n p[j - 1] = 0;\n }\n do {\n j++;\n }\n while (p[j] > 0);\n k = j - 1;\n i = j;\n while (p[i] === 0) {\n p[i++] = -1;\n }\n if (p[i] === -1) {\n p[i] = p[k];\n z = p[k] - 1;\n x = i - 1;\n y = k - 1;\n p[k] = -1;\n } else {\n if (i === p[0]) {\n return 0;\n } else {\n p[j] = p[i];\n z = p[i] - 1;\n p[i] = 0;\n x = j - 1;\n y = i - 1;\n }\n }\n }\n return 1;\n }\n\n if (options.mode === 'index') {\n yield c.slice();\n while (twiddle()) {\n c[z] = a[x];\n yield c.slice();\n }\n } else if (options.mode === 'mask') {\n yield b.slice();\n while (twiddle()) {\n b[x] = 1;\n b[y] = 0;\n yield b.slice();\n }\n } else {\n throw new Error('Invalid mode');\n }\n};\n","'use strict';\n\nconst ConfusionMatrix = require('ml-confusion-matrix');\n\nconst CV = {};\nconst combinations = require('ml-combinations');\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 */\nCV.leaveOneOut = function (Classifier, features, labels, classifierOptions) {\n if (typeof labels === 'function') {\n var callback = labels;\n labels = features;\n features = Classifier;\n return CV.leavePOut(features, labels, 1, callback);\n }\n return CV.leavePOut(Classifier, features, labels, classifierOptions, 1);\n};\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 */\nCV.leavePOut = function (Classifier, features, labels, classifierOptions, p) {\n if (typeof classifierOptions === 'function') {\n var 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 var N = features.length;\n var gen = combinations(p, N);\n var allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n for (const testIdx of gen) {\n var 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(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback);\n } else {\n validate(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, 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 */\nCV.kFold = function (Classifier, features, labels, classifierOptions, k) {\n if (typeof classifierOptions === 'function') {\n var 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 var N = features.length;\n var allIdx = new Array(N);\n for (var i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n\n var l = Math.floor(N / k);\n // create random k-folds\n var current = [];\n var folds = [];\n while (allIdx.length) {\n var 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 if (current.length) folds.push(current);\n folds = folds.slice(0, k);\n\n\n for (i = 0; i < folds.length; i++) {\n var testIdx = folds[i];\n var trainIdx = [];\n for (var j = 0; j < folds.length; j++) {\n if (j !== i) trainIdx = trainIdx.concat(folds[j]);\n }\n\n if (callback) {\n validateWithCallback(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback);\n } else {\n validate(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, distinct);\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 var 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(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, distinct) {\n const {testFeatures, trainFeatures, testLabels, trainLabels} = getTrainTest(features, labels, testIdx, trainIdx);\n\n var 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 var predictedLabels = classifier.predict(testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction validateWithCallback(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback) {\n const {testFeatures, trainFeatures, testLabels, trainLabels} = getTrainTest(features, labels, testIdx, trainIdx);\n const predictedLabels = callback(trainFeatures, trainLabels, testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct) {\n\n for (var 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\n\nfunction 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\nmodule.exports = CV;\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","/**\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 var error = 0;\n const func = parameterizedFunction(parameters);\n\n for (var 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 var ans = new Array(n);\n\n for (var param = 0; param < n; param++) {\n ans[param] = new Array(m);\n var auxParams = params.concat();\n auxParams[param] += gradientDifference;\n var funcParam = paramFunction(auxParams);\n\n for (var 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 var ans = new Array(m);\n\n for (var 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 var value = damping * gradientDifference * gradientDifference;\n var identity = Matrix.eye(params.length, params.length, value);\n\n const func = parameterizedFunction(params);\n var evaluatedData = data.x.map((e) => func(e));\n\n var gradientFunc = gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n parameterizedFunction\n );\n var matrixFunc = matrixFunction(data, evaluatedData);\n var 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 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 !Array.isArray(data.x) ||\n data.x.length < 2 ||\n !Array.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 var 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 (!Array.isArray(parameters)) {\n throw new Error('initialValues must be an array');\n }\n\n var error = errorCalculation(data, parameters, parameterizedFunction);\n\n var converged = error <= errorTolerance;\n\n for (\n var iteration = 0;\n iteration < maxIterations && !converged;\n iteration++\n ) {\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' || Number.isNaN(number)) {\n\t\tthrow new TypeError('Expected a number');\n\t}\n}\n\nexports.ascending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\treturn left - right;\n};\n\nexports.descending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\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\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;\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","import isArray from 'is-any-array';\n\n/**\n * Computes the mode of the given values\n * @param {Array} input\n * @return {number}\n */\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","import max from 'ml-array-max';\nimport sum from 'ml-array-sum';\n\n/**\n * Computes the norm of the given values\n * @param {Array} input\n * @param {object} [options={}]\n * @param {string} [options.algorithm='absolute'] absolute, sum or max\n * @return {number}\n */\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\n if (!Array.isArray(input)) {\n throw new Error('input must be an array');\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);\n if (absoluteSumValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / absoluteSumValue;\n });\n }\n\n case 'max':\n {\n var maxValue = max(input);\n if (maxValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / maxValue;\n });\n }\n\n case 'sum':\n {\n var sumValue = sum(input);\n if (sumValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / sumValue;\n });\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 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/**\n * Fill an array with sequential numbers\n * @param {Array} [input] - optional destination array (if not provided a new array will be created)\n * @param {object} [options={}]\n * @param {number} [options.from=0] - first value in the array\n * @param {number} [options.to=10] - last value in the array\n * @param {number} [options.size=input.length] - size of the array (if not provided calculated from step)\n * @param {number} [options.step] - if not provided calculated from size\n * @return {Array}\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 && 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 input.length = 0; // only works with normal array\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","import arrayMean from 'ml-array-mean';\nimport isArray from 'is-any-array';\n\n/**\n * Computes the variance of the given values\n * @param {Array} values\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @param {number} [options.mean = arrayMean] - precalculated mean, if any.\n * @return {number}\n */\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\n/**\n * Computes the standard deviation of the given values\n * @param {Array} values\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @param {number} [options.mean = arrayMean] - precalculated mean, if any.\n * @return {number}\n */\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 * 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 var xLength = x.length;\n\n var step = (to - from) / (numberOfPoints - 1);\n var halfStep = step / 2;\n\n var output = new Array(numberOfPoints);\n\n var initialOriginalStep = x[1] - x[0];\n var lastOriginalStep = x[xLength - 1] - x[xLength - 2];\n\n // Init main variables\n var min = from - halfStep;\n var max = from + halfStep;\n\n var previousX = Number.MIN_VALUE;\n var previousY = 0;\n var nextX = x[0] - initialOriginalStep;\n var nextY = 0;\n\n var currentValue = 0;\n var slope = 0;\n var intercept = 0;\n var sumAtMin = 0;\n var sumAtMax = 0;\n\n var i = 0; // index of input\n var j = 0; // index of output\n\n function getSlope(x0, y0, x1, y1) {\n return (y1 - y0) / (x1 - x0);\n }\n\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 var 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 var xLength = x.length;\n\n var step = (to - from) / (numberOfPoints - 1);\n var halfStep = step / 2;\n var lastStep = x[x.length - 1] - x[x.length - 2];\n\n var start = from - halfStep;\n var output = new Array(numberOfPoints);\n\n // Init main variables\n var min = start;\n var max = start + step;\n\n var previousX = -Number.MAX_VALUE;\n var previousY = 0;\n var nextX = x[0];\n var nextY = y[0];\n var frontOutsideSpectra = 0;\n var backOutsideSpectra = true;\n\n var currentValue = 0;\n\n // for slot algorithm\n var currentPoints = 0;\n\n var i = 1; // index of input\n var 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","export default function getZones(from, to, numberOfPoints, 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, numberOfPoints }];\n }\n\n // need to deal with overlapping exclusions and out of bound exclusions\n\n let toRemove = exclusions.reduce(\n (previous, exclusion) => (previous += exclusion.to - exclusion.from),\n 0\n );\n let total = to - from;\n let unitsPerPoint = (total - toRemove) / numberOfPoints;\n let zones = [];\n let currentFrom = from;\n let totalPoints = 0;\n for (let exclusion of exclusions) {\n let currentNbPoints = Math.round(\n (exclusion.from - currentFrom) / unitsPerPoint\n );\n totalPoints += currentNbPoints;\n if (currentNbPoints > 0) {\n zones.push({\n from: currentFrom,\n to: exclusion.from,\n numberOfPoints: currentNbPoints\n });\n }\n\n currentFrom = exclusion.to;\n }\n if (numberOfPoints - totalPoints > 0) {\n zones.push({\n from: currentFrom,\n to: to,\n numberOfPoints: numberOfPoints - totalPoints\n });\n }\n\n return zones;\n}\n","import sequentialFill from 'ml-array-sequential-fill';\n\nimport equallySpacedSmooth from './equallySpacedSmooth';\nimport equallySpacedSlot from './equallySpacedSlot';\nimport getZones from './getZones';\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 * @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 * @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 } = 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 let zones = getZones(from, to, numberOfPoints, exclusions);\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 xResult.push(...zoneResult.x);\n yResult.push(...zoneResult.y);\n }\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 var 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 } from 'ml-pls';\nexport { default as CrossValidation } from 'ml-cross-validation';\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';\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","isArray","TypeError","length","maxValue","i","min","minValue","rescale","output","options","arguments","undefined","Array","currentMin","currentMax","RangeError","_options$min","autoMinMax","_options$max","factor","checkRowIndex","matrix","index","outer","rows","checkColumnIndex","columns","checkRowVector","vector","to1DArray","checkColumnVector","checkIndices","rowIndices","columnIndices","row","checkRowIndices","column","checkColumnIndices","some","r","from","c","checkRange","startRow","endRow","startColumn","endColumn","checkNumber","newArray","value","array","push","name","sumByRow","sum","j","get","sumByColumn","sumAll","v","productByRow","productByColumn","productAll","varianceByRow","unbiased","mean","cols","variance","sum1","sum2","x","varianceByColumn","varianceAll","size","centerByRow","set","centerByColumn","centerAll","getScaleByRow","scale","Math","pow","sqrt","scaleByRow","getScaleByColumn","scaleByColumn","getScaleAll","divider","scaleAll","inspectMatrix","indent","repeat","indentData","this","constructor","inspectData","maxRows","maxColumns","maxNumSize","maxI","maxJ","result","line","formatNumber","join","num","numStr","String","padEnd","precise","toPrecision","exponential","toExponential","eIndex","indexOf","e","substring","installMathOperations","AbstractMatrix","Matrix","add","addS","addM","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","tan","tanh","trunc","arg0","powS","powM","newRows","newColumns","newData","newMatrix","fill","random","Number","isInteger","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","Error","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","returnArray","linearDependencies","thresholdError","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","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","int32","engine","next","addend","int53","int53Full","uint32","uint53","uint53Full","isPowerOfTwoMinusOne","bitmask","masking","downscaleToLoopCheckedRange","extendedRange","maximum","downscaleToRange","isEvenlyDivisibleByMaxInt32","upscaleWithHighMasking","upscaleToLoopCheckedRange","upscaleWithinU53","highRange","upscaleWithinI53AndLoopCheck","integer","DEFAULT_STRING_POOL","string","pool","poolLength","charAt","LOWER_HEX_POOL","lowerHex","upperHex","toUpperCase","stringRepeat","pattern","_","nativeMath","I32Array","buffer","ArrayBuffer","view","Int32Array","createEntropy","Date","getTime","imul","al","bl","ARRAY_SIZE","ARRAY_MAX","M","ARRAY_SIZE_MINUS_M","A","MersenneTwister19937","uses","initial","seed","source","seedWithArray","refreshData","temper","getUseCount","discard","previous","sourceLength","checkFloat","examplesBaggingWithReplacement","trainingValue","Random","autoSeed","Xr","featureBagging","replacement","toRet","usedIndex","Set","has","RandomForestBase","maxFeatures","nEstimators","treeOptions","isClassifier","indexes","useSampleBagging","Estimator","DTClassifier","DTRegression","estimators","map","est","load","res","values","predictionValues","RandomForestClassifier","baseModel","mode","super","pop","_ref","module","exports","window","median","quickSelectMedian","slice","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","_j","_ref1","_results","_results1","_len","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","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","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","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","N","twiddle","CV","initMatrix","getDistinct","validate","Classifier","classifierOptions","testIdx","trainIdx","confusionMatrix","distinct","testFeatures","trainFeatures","testLabels","trainLabels","getTrainTest","classifier","updateConfusionMatrix","validateWithCallback","predictedLabels","leaveOneOut","leavePOut","gen","combinations","allIdx","kFold","current","folds","randi","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","keys","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","hasOwnProperty","numWeights","converters","getConverters","extractor","creator","nodeType","hx","distanceMethod","getMaxDistance","times","findBMU","adjust","iterationCount","startLearningRate","mapRadius","algorithmMethod","_initNodes","done","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","self","_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","fn","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","ri","reduce","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","key","objectCollection","BigInt","sorted","cssls","XtX","XtY","Pset","choXtX","luXtX","sortedPset","sortedEset","cols2Solve","vars","initialisation","Fset","D","setDifference","C","includes","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","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","err","fpr","tpr","fnr","tnr","ppv","npv","pcfall","pcmiss","lift","rpp","rnp","arrayCase","cond","matrixCase","padArray","windowSize","derivative","pad","padValue","savitzkyGolay","J","inic","Jtranspose","det","eightBits","arr1","arr2","getBit","mask","setBit","toBinaryString","substr","parseBinaryString","toHexString","parseHexString","toDebug","binary","maxCount","_options$algorithm","algorithm","absoluteSumValue","absoluteSum","_typeof","iterator","sequentialFill","_options","_options$from","_options$to","_options$size","_options$unbiased","_options$mean","sqrError","mergeByCentroids","originalPoints","mergedPoints","originalIndex","mergedIndex","closestX","descending","maxMerge","groupWidth","merged","maxAbscissa","maxY","calculateIndex","sortX","sortFunc","grouped","response","uniqueX","weightedMerge","weightedAbscissa","integral","x0","x1","equallySpacedSmooth","numberOfPoints","xLength","halfStep","initialOriginalStep","lastOriginalStep","previousX","previousY","nextX","nextY","currentValue","sumAtMin","sumAtMax","main","equallySpacedSlot","lastStep","frontOutsideSpectra","backOutsideSpectra","getZones","exclusions","exclusion","JSON","parse","stringify","toRemove","unitsPerPoint","zones","currentFrom","totalPoints","currentNbPoints","equallySpaced","arrayXY","variant","xResult","yResult","zone","zoneResult","processZone","filterX","currentZoneIndex","newX","newY","position","MatrixLib","normed","ArrayXY","centroidsMerge"],"mappings":"sMAEA,MAAMA,SAAWC,OAAOC,UAAUF,SAElC,SAASG,WAAWC,UACXJ,SAASK,KAAKD,GAAQE,SAAS,UAGxC,QAAiBH,WCAjB,SAASI,IAAIC,OACNC,IAAQD,SACL,IAAI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bo4B,aAAan4B,GACND,EAAOC,cAGM,CAACD,EAAMC,KAC3Bm4B,aAAap4B,GACbo4B,aAAan4B,GACNA,EAAQD,iLCdT,MAAMs4B,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,UAAU38C,OACpB3B,EAAQu+C,aAAaF,aAAc18C,EAAO68C,kBAC1Cx+C,EAAQ,IACVA,GAASA,GAEJq+C,aAAar+C,GAPtBq+C,aAAa1oC,KAAK6oC,WCtWlB,MAAMC,KAAO,EACPC,KAAO,EACPC,QAAU,EAEVC,uBAAyB,IACzBC,qBAAuB,EAAI,EAC3BC,qBAAuB,EAAI,EAElB,MAAMC,UACnBv6C,kBAAYrF,yDAAU,MAChBA,aAAmB4/C,sBAChBC,MAAQ7/C,EAAQ6/C,MAAMhxB,aACtBb,OAAShuB,EAAQguB,OAAOa,aACxBsL,MAAQn6B,EAAQm6B,MAAMtL,aACtBixB,cAAgB9/C,EAAQ8/C,mBACxBC,cAAgB//C,EAAQ+/C,mBACxB9V,SAAWjqC,EAAQiqC,cACnB+V,YAAchgD,EAAQggD,iBACtBC,aAAejgD,EAAQigD,uBACvBC,cAAgBlgD,EAAQ+/C,qBAIzBI,OACwBjgD,IAA5BF,EAAQmgD,gBACJV,uBACAz/C,EAAQmgD,mBACVA,EAAkB,QACd,IAAI7/C,kEACwC6/C,UAI9CL,OACsB5/C,IAA1BF,EAAQ8/C,cACJJ,qBACA1/C,EAAQ8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GAC8B,MAGlCG,UAGK,CACLxuD,EAAGsuD,EACH19C,EAAG29C,gBCMLtrD,SADIqY,IAEJA,IAFI6R,IAGJA,0BACAlP,wCACAxI,kCACAe,mBACEi4C,UA4CSnyD,QAAQ,CACnBP,IAAAA,IACAP,IAAAA,IACAsvB,OAAAA,OACAnrB,KAAAA,UACA4qB,cACAmkC,OACAzyD,QAAAA,QACA8tD,eAAAA,eACAz2C,kBAAAA,kBACAtU,IAAAA,IACAa,SAAAA,UAaW8uD,QAAU,gBACrBC,iBACAhE,SAAAA,oBACApvC,aACAsvC,SAAAA,SACAI,KAAAA,KACAE,MAAAA,MACAI,QAAAA,QACAC,cAAAA,cACAmC,cAAAA,cACAQ,QAAAA"} \ No newline at end of file +{"version":3,"file":"ml.min.js","sources":["../node_modules/is-any-array/src/index.js","../node_modules/ml-array-max/lib-es6/index.js","../node_modules/ml-array-min/lib-es6/index.js","../node_modules/ml-array-rescale/lib-es6/index.js","../node_modules/ml-matrix/src/util.js","../node_modules/ml-matrix/src/stat.js","../node_modules/ml-matrix/src/inspect.js","../node_modules/ml-matrix/src/mathOperations.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/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/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/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/src/index.js","../node_modules/ml-cross-validation/src/index.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/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-array-mode/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/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-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/getZones.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":["'use strict';\n\nconst toString = Object.prototype.toString;\n\nfunction isAnyArray(object) {\n return toString.call(object).endsWith('Array]');\n}\n\nmodule.exports = isAnyArray;\n","import isArray from 'is-any-array';\n\n/**\n * Computes the maximum of the given values\n * @param {Array} input\n * @return {number}\n */\n\nfunction max(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 = input[0];\n\n for (var i = 1; i < input.length; 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\n/**\n * Computes the minimum of the given values\n * @param {Array} input\n * @return {number}\n */\n\nfunction min(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 minValue = input[0];\n\n for (var i = 1; i < input.length; i++) {\n if (input[i] < minValue) minValue = input[i];\n }\n\n return minValue;\n}\n\nexport default min;\n","import max from 'ml-array-max';\nimport min from 'ml-array-min';\nimport isArray from 'is-any-array';\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","/**\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","export function inspectMatrix() {\n const indent = ' '.repeat(2);\n const indentData = ' '.repeat(4);\n return `${this.constructor.name} {\n${indent}[\n${indentData}${inspectData(this, indentData)}\n${indent}]\n${indent}rows: ${this.rows}\n${indent}columns: ${this.columns}\n}`;\n}\n\nconst maxRows = 15;\nconst maxColumns = 10;\nconst maxNumSize = 8;\n\nfunction inspectData(matrix, indent) {\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)));\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${indent}`);\n}\n\nfunction formatNumber(num) {\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.substring(eIndex);\n return exponential.substring(0, maxNumSize - e.length) + e;\n}\n","export function installMathOperations(AbstractMatrix, Matrix) {\n AbstractMatrix.prototype.add = function add(value) {\n if (typeof value === 'number') return this.addS(value);\n return this.addM(value);\n };\n\n AbstractMatrix.prototype.addS = function addS(value) {\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) + value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.addM = function addM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) + matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.add = function add(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.add(value);\n };\n\n AbstractMatrix.prototype.sub = function sub(value) {\n if (typeof value === 'number') return this.subS(value);\n return this.subM(value);\n };\n\n AbstractMatrix.prototype.subS = function subS(value) {\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) - value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.subM = function subM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) - matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.sub = function sub(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sub(value);\n };\n AbstractMatrix.prototype.subtract = AbstractMatrix.prototype.sub;\n AbstractMatrix.prototype.subtractS = AbstractMatrix.prototype.subS;\n AbstractMatrix.prototype.subtractM = AbstractMatrix.prototype.subM;\n AbstractMatrix.subtract = AbstractMatrix.sub;\n\n AbstractMatrix.prototype.mul = function mul(value) {\n if (typeof value === 'number') return this.mulS(value);\n return this.mulM(value);\n };\n\n AbstractMatrix.prototype.mulS = function mulS(value) {\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) * value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.mulM = function mulM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) * matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.mul = function mul(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.mul(value);\n };\n AbstractMatrix.prototype.multiply = AbstractMatrix.prototype.mul;\n AbstractMatrix.prototype.multiplyS = AbstractMatrix.prototype.mulS;\n AbstractMatrix.prototype.multiplyM = AbstractMatrix.prototype.mulM;\n AbstractMatrix.multiply = AbstractMatrix.mul;\n\n AbstractMatrix.prototype.div = function div(value) {\n if (typeof value === 'number') return this.divS(value);\n return this.divM(value);\n };\n\n AbstractMatrix.prototype.divS = function divS(value) {\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) / value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.divM = function divM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) / matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.div = function div(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.div(value);\n };\n AbstractMatrix.prototype.divide = AbstractMatrix.prototype.div;\n AbstractMatrix.prototype.divideS = AbstractMatrix.prototype.divS;\n AbstractMatrix.prototype.divideM = AbstractMatrix.prototype.divM;\n AbstractMatrix.divide = AbstractMatrix.div;\n\n AbstractMatrix.prototype.mod = function mod(value) {\n if (typeof value === 'number') return this.modS(value);\n return this.modM(value);\n };\n\n AbstractMatrix.prototype.modS = function modS(value) {\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) % value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.modM = function modM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) % matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.mod = function mod(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.mod(value);\n };\n AbstractMatrix.prototype.modulus = AbstractMatrix.prototype.mod;\n AbstractMatrix.prototype.modulusS = AbstractMatrix.prototype.modS;\n AbstractMatrix.prototype.modulusM = AbstractMatrix.prototype.modM;\n AbstractMatrix.modulus = AbstractMatrix.mod;\n\n AbstractMatrix.prototype.and = function and(value) {\n if (typeof value === 'number') return this.andS(value);\n return this.andM(value);\n };\n\n AbstractMatrix.prototype.andS = function andS(value) {\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) & value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.andM = function andM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) & matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.and = function and(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.and(value);\n };\n\n AbstractMatrix.prototype.or = function or(value) {\n if (typeof value === 'number') return this.orS(value);\n return this.orM(value);\n };\n\n AbstractMatrix.prototype.orS = function orS(value) {\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) | value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.orM = function orM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) | matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.or = function or(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.or(value);\n };\n\n AbstractMatrix.prototype.xor = function xor(value) {\n if (typeof value === 'number') return this.xorS(value);\n return this.xorM(value);\n };\n\n AbstractMatrix.prototype.xorS = function xorS(value) {\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) ^ value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.xorM = function xorM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) ^ matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.xor = function xor(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.xor(value);\n };\n\n AbstractMatrix.prototype.leftShift = function leftShift(value) {\n if (typeof value === 'number') return this.leftShiftS(value);\n return this.leftShiftM(value);\n };\n\n AbstractMatrix.prototype.leftShiftS = function leftShiftS(value) {\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) << value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.leftShiftM = function leftShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) << matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.leftShift = function leftShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.leftShift(value);\n };\n\n AbstractMatrix.prototype.signPropagatingRightShift = function signPropagatingRightShift(value) {\n if (typeof value === 'number') return this.signPropagatingRightShiftS(value);\n return this.signPropagatingRightShiftM(value);\n };\n\n AbstractMatrix.prototype.signPropagatingRightShiftS = function signPropagatingRightShiftS(value) {\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) >> value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.signPropagatingRightShiftM = function signPropagatingRightShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) >> matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.signPropagatingRightShift = function signPropagatingRightShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.signPropagatingRightShift(value);\n };\n\n AbstractMatrix.prototype.rightShift = function rightShift(value) {\n if (typeof value === 'number') return this.rightShiftS(value);\n return this.rightShiftM(value);\n };\n\n AbstractMatrix.prototype.rightShiftS = function rightShiftS(value) {\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) >>> value);\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.rightShiftM = function rightShiftM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\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) >>> matrix.get(i, j));\n }\n }\n return this;\n };\n\n AbstractMatrix.rightShift = function rightShift(matrix, value) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.rightShift(value);\n };\n AbstractMatrix.prototype.zeroFillRightShift = AbstractMatrix.prototype.rightShift;\n AbstractMatrix.prototype.zeroFillRightShiftS = AbstractMatrix.prototype.rightShiftS;\n AbstractMatrix.prototype.zeroFillRightShiftM = AbstractMatrix.prototype.rightShiftM;\n AbstractMatrix.zeroFillRightShift = AbstractMatrix.rightShift;\n\n AbstractMatrix.prototype.not = function not() {\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)));\n }\n }\n return this;\n };\n\n AbstractMatrix.not = function not(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.not();\n };\n\n AbstractMatrix.prototype.abs = function abs() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.abs(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.abs = function abs(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.abs();\n };\n\n AbstractMatrix.prototype.acos = function acos() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.acos(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.acos = function acos(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.acos();\n };\n\n AbstractMatrix.prototype.acosh = function acosh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.acosh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.acosh = function acosh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.acosh();\n };\n\n AbstractMatrix.prototype.asin = function asin() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.asin(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.asin = function asin(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.asin();\n };\n\n AbstractMatrix.prototype.asinh = function asinh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.asinh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.asinh = function asinh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.asinh();\n };\n\n AbstractMatrix.prototype.atan = function atan() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.atan(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.atan = function atan(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.atan();\n };\n\n AbstractMatrix.prototype.atanh = function atanh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.atanh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.atanh = function atanh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.atanh();\n };\n\n AbstractMatrix.prototype.cbrt = function cbrt() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cbrt(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cbrt = function cbrt(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cbrt();\n };\n\n AbstractMatrix.prototype.ceil = function ceil() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.ceil(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.ceil = function ceil(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.ceil();\n };\n\n AbstractMatrix.prototype.clz32 = function clz32() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.clz32(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.clz32 = function clz32(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.clz32();\n };\n\n AbstractMatrix.prototype.cos = function cos() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cos(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cos = function cos(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cos();\n };\n\n AbstractMatrix.prototype.cosh = function cosh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.cosh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.cosh = function cosh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.cosh();\n };\n\n AbstractMatrix.prototype.exp = function exp() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.exp(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.exp = function exp(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.exp();\n };\n\n AbstractMatrix.prototype.expm1 = function expm1() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.expm1(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.expm1 = function expm1(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.expm1();\n };\n\n AbstractMatrix.prototype.floor = function floor() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.floor(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.floor = function floor(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.floor();\n };\n\n AbstractMatrix.prototype.fround = function fround() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.fround(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.fround = function fround(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.fround();\n };\n\n AbstractMatrix.prototype.log = function log() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log = function log(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log();\n };\n\n AbstractMatrix.prototype.log1p = function log1p() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log1p(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log1p = function log1p(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log1p();\n };\n\n AbstractMatrix.prototype.log10 = function log10() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log10(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log10 = function log10(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log10();\n };\n\n AbstractMatrix.prototype.log2 = function log2() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.log2(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.log2 = function log2(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.log2();\n };\n\n AbstractMatrix.prototype.round = function round() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.round(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.round = function round(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.round();\n };\n\n AbstractMatrix.prototype.sign = function sign() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sign(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sign = function sign(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sign();\n };\n\n AbstractMatrix.prototype.sin = function sin() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sin(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sin = function sin(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sin();\n };\n\n AbstractMatrix.prototype.sinh = function sinh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sinh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sinh = function sinh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sinh();\n };\n\n AbstractMatrix.prototype.sqrt = function sqrt() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.sqrt(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.sqrt = function sqrt(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.sqrt();\n };\n\n AbstractMatrix.prototype.tan = function tan() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.tan(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.tan = function tan(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.tan();\n };\n\n AbstractMatrix.prototype.tanh = function tanh() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.tanh(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.tanh = function tanh(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.tanh();\n };\n\n AbstractMatrix.prototype.trunc = function trunc() {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.trunc(this.get(i, j)));\n }\n }\n return this;\n };\n\n AbstractMatrix.trunc = function trunc(matrix) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.trunc();\n };\n\n AbstractMatrix.pow = function pow(matrix, arg0) {\n const newMatrix = new Matrix(matrix);\n return newMatrix.pow(arg0);\n };\n\n AbstractMatrix.prototype.pow = function pow(value) {\n if (typeof value === 'number') return this.powS(value);\n return this.powM(value);\n };\n\n AbstractMatrix.prototype.powS = function powS(value) {\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.pow(this.get(i, j), value));\n }\n }\n return this;\n };\n\n AbstractMatrix.prototype.powM = function powM(matrix) {\n matrix = Matrix.checkMatrix(matrix);\n if (this.rows !== matrix.rows ||\n this.columns !== matrix.columns) {\n throw new RangeError('Matrices dimensions must be equal');\n }\n for (let i = 0; i < this.rows; i++) {\n for (let j = 0; j < this.columns; j++) {\n this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j)));\n }\n }\n return this;\n };\n}\n","import rescale from 'ml-array-rescale';\n\nimport {\n checkRowVector,\n checkRowIndex,\n checkColumnIndex,\n checkColumnVector,\n checkRange,\n checkIndices,\n} from './util';\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 { inspectMatrix } from './inspect';\nimport { installMathOperations } from './mathOperations';\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\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';\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';\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';\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';\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';\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';\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 Matrix from './matrix';\nimport LuDecomposition from './dc/lu';\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 Matrix from './matrix';\nimport SingularValueDecomposition from './dc/svd';\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))\n .abs()\n .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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 = Matrix.checkMatrix(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 WrapperMatrix2D from '../wrap/WrapperMatrix2D';\nimport Matrix from '../matrix';\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()\n .mmul(u)\n .div(\n u\n .transpose()\n .mmul(u)\n .get(0, 0),\n );\n w = w.div(w.norm());\n\n t = X.mmul(w).div(\n w\n .transpose()\n .mmul(w)\n .get(0, 0),\n );\n\n if (counter > 0) {\n diff = t\n .clone()\n .sub(tOld)\n .pow(2)\n .sum();\n }\n tOld = t.clone();\n\n if (Y) {\n q = Y.transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n q = q.div(q.norm());\n\n u = Y.mmul(q).div(\n q\n .transpose()\n .mmul(q)\n .get(0, 0),\n );\n } else {\n u = t;\n }\n }\n\n if (Y) {\n let p = X.transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n p = p.div(p.norm());\n let xResidual = X.clone().sub(t.clone().mmul(p.transpose()));\n let residual = u\n .transpose()\n .mmul(t)\n .div(\n t\n .transpose()\n .mmul(t)\n .get(0, 0),\n );\n let yResidual = Y.clone().sub(\n t\n .clone()\n .mulS(residual.get(0, 0))\n .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\n .transpose()\n .mmul(t)\n .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","import isArray from 'is-any-array';\n\n/**\n * Computes the mean of the given values\n * @param {Array} input\n * @return {number}\n */\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\n/**\n * Computes the mean of the given values\n * @param {Array} input\n * @return {number}\n */\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","(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 quickSelectMedian from 'median-quickselect';\nimport isArray from 'is-any-array';\n\n/**\n * Computes the median of the given values\n * @param {Array} input\n * @return {number}\n */\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(X.clone().apply(pow2array).sum());\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 var means = dataset.mean('column');\n var std = dataset.standardDeviation('column', { mean: means, unbiased: true });\n var 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 (var i = 0; i < array.length; ++i) {\n for (var j = 0; j < array[i].length; ++j) {\n var elem = array[i][j];\n array[i][j] = elem !== null ? new Matrix(array[i][j]) : undefined;\n }\n }\n } else {\n for (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 './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 var {\n tolerance = 1e-5,\n scale = true,\n } = 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('The number of X rows must be equal to the number of Y rows');\n }\n\n this.meanX = trainingSet.mean('column');\n this.stdDevX = trainingSet.standardDeviation('column', { mean: this.meanX, unbiased: true });\n this.meanY = trainingValues.mean('column');\n this.stdDevY = trainingValues.standardDeviation('column', { mean: this.meanY, unbiased: true });\n\n if (this.scale) {\n trainingSet = trainingSet.clone().subRowVector(this.meanX).divRowVector(this.stdDevX);\n trainingValues = trainingValues.clone().subRowVector(this.meanY).divRowVector(this.stdDevY);\n }\n\n if (this.latentVectors === undefined) {\n this.latentVectors = Math.min(trainingSet.rows - 1, trainingSet.columns);\n }\n\n var rx = trainingSet.rows;\n var cx = trainingSet.columns;\n var ry = trainingValues.rows;\n var cy = trainingValues.columns;\n\n var ssqXcal = trainingSet.clone().mul(trainingSet).sum(); // for the r²\n var sumOfSquaresY = trainingValues.clone().mul(trainingValues).sum();\n\n var tolerance = this.tolerance;\n var n = this.latentVectors;\n var T = Matrix.zeros(rx, n);\n var P = Matrix.zeros(cx, n);\n var U = Matrix.zeros(ry, n);\n var Q = Matrix.zeros(cy, n);\n var B = Matrix.zeros(n, n);\n var W = P.clone();\n var k = 0;\n\n while (Utils.norm(trainingValues) > tolerance && k < n) {\n var transposeX = trainingSet.transpose();\n var transposeY = trainingValues.transpose();\n\n var tIndex = maxSumColIndex(trainingSet.clone().mul(trainingSet));\n var uIndex = maxSumColIndex(trainingValues.clone().mul(trainingValues));\n\n var t1 = trainingSet.getColumnVector(tIndex);\n var u = trainingValues.getColumnVector(uIndex);\n var t = Matrix.zeros(rx, 1);\n\n while (Utils.norm(t1.clone().sub(t)) > tolerance) {\n var w = transposeX.mmul(u);\n w.div(Utils.norm(w));\n t = t1;\n t1 = trainingSet.mmul(w);\n var q = transposeY.mmul(t1);\n q.div(Utils.norm(q));\n u = trainingValues.mmul(q);\n }\n\n t = t1;\n var num = transposeX.mmul(t);\n var den = t.transpose().mmul(t).get(0, 0);\n var p = num.div(den);\n var 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.transpose().mmul(t).get(0, 0);\n var b = num.div(den).get(0, 0);\n trainingSet.sub(t.mmul(p.transpose()));\n trainingValues.sub(t.clone().mul(b).mmul(q.transpose()));\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 // TODO: review of R2Y\n // this.R2Y = t.transpose().mmul(t).mul(q[k][0]*q[k][0]).divS(ssqYcal)[0][0];\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.transpose().mmul(t).mmul(p.transpose().mmul(p)).div(ssqXcal).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 var X = Matrix.checkMatrix(dataset);\n if (this.scale) {\n X = X.subRowVector(this.meanX).divRowVector(this.stdDevX);\n }\n var 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 './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(model.TURegressionCoeff, false);\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 var kernelX = this.kernel.compute(trainingSet);\n\n var Identity = Matrix.eye(kernelX.rows, kernelX.rows, 1);\n var 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 var result = new SingularValueDecomposition(trainingValues.transpose().mmul(kernelX[0][0]).mmul(trainingValues), {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false\n });\n var YLoadingMat = result.leftSingularVectors;\n var Sigma = result.diagonalMatrix;\n\n YLoadingMat = YLoadingMat.subMatrix(0, YLoadingMat.rows - 1, 0, this.predictiveComp - 1);\n Sigma = Sigma.subMatrix(0, this.predictiveComp - 1, 0, this.predictiveComp - 1);\n\n var YScoreMat = trainingValues.mmul(YLoadingMat);\n\n var predScoreMat = new Array(this.orthogonalComp + 1);\n var TURegressionCoeff = new Array(this.orthogonalComp + 1);\n var YOrthScoreMat = new Array(this.orthogonalComp);\n var YOrthLoadingVec = new Array(this.orthogonalComp);\n var YOrthEigen = new Array(this.orthogonalComp);\n var YOrthScoreNorm = new Array(this.orthogonalComp);\n\n var 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 (var i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = kernelX[0][i].transpose().mmul(YScoreMat).mmul(SigmaPow);\n\n var TpiPrime = predScoreMat[i].transpose();\n TURegressionCoeff[i] = inverse(TpiPrime.mmul(predScoreMat[i])).mmul(TpiPrime).mmul(YScoreMat);\n\n result = new SingularValueDecomposition(TpiPrime.mmul(Matrix.sub(kernelX[i][i], predScoreMat[i].mmul(TpiPrime))).mmul(predScoreMat[i]), {\n computeLeftSingularVectors: true,\n computeRightSingularVectors: false\n });\n var CoTemp = result.leftSingularVectors;\n var 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(kernelX[i][i], predScoreMat[i].mmul(TpiPrime)).mmul(predScoreMat[i]).mmul(YOrthLoadingVec[i]).mul(Math.pow(YOrthEigen[i], -0.5));\n\n var toiPrime = YOrthScoreMat[i].transpose();\n YOrthScoreNorm[i] = Matrix.sqrt(toiPrime.mmul(YOrthScoreMat[i]));\n\n YOrthScoreMat[i] = YOrthScoreMat[i].divRowVector(YOrthScoreNorm[i]);\n\n var ITo = Matrix.sub(Identity, YOrthScoreMat[i].mmul(YOrthScoreMat[i].transpose()));\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 var lastScoreMat = predScoreMat[this.orthogonalComp] = kernelX[0][this.orthogonalComp].transpose().mmul(YScoreMat).mmul(SigmaPow);\n\n var lastTpPrime = lastScoreMat.transpose();\n TURegressionCoeff[this.orthogonalComp] = inverse(lastTpPrime.mmul(lastScoreMat)).mmul(lastTpPrime).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 var KTestTrain = this.kernel.compute(toPredict, this.trainingSet);\n\n var 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 var YOrthScoreVector = new Array(this.orthogonalComp);\n var predScoreMat = new Array(this.orthogonalComp);\n\n var i;\n for (i = 0; i < this.orthogonalComp; ++i) {\n predScoreMat[i] = KTestTrain[i][0].mmul(this.YScoreMat).mmul(this.SigmaPow);\n\n YOrthScoreVector[i] = Matrix.sub(KTestTrain[i][i], predScoreMat[i].mmul(this.predScoreMat[i].transpose())).mmul(this.predScoreMat[i]).mmul(this.YOrthLoadingVec[i]).mul(Math.pow(this.YOrthEigen[i], -0.5));\n\n YOrthScoreVector[i] = YOrthScoreVector[i].divRowVector(this.toNorm[i]);\n\n var scoreMatPrime = this.YOrthScoreMat[i].transpose();\n KTestTrain[i + 1][0] = Matrix.sub(KTestTrain[i][0], YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[0][i].transpose()));\n\n var p1 = Matrix.sub(KTestTrain[i][0], KTestTrain[i][i].mmul(this.YOrthScoreMat[i]).mmul(scoreMatPrime));\n var p2 = YOrthScoreVector[i].mmul(scoreMatPrime).mmul(this.kernelX[i][i]);\n var 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 var prediction = predScoreMat[i].mmul(this.TURegressionCoeff[i]).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 */\nclass 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('Confusion matrix and labels should have the same length');\n }\n this.labels = labels;\n this.matrix = matrix;\n }\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 (var i = 0; i < this.matrix.length; i++) {\n for (var 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 var count = 0;\n for (var 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 var count = 0;\n for (var i = 0; i < this.matrix.length; i++) {\n for (var 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 var count = 0;\n for (var 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 var count = 0;\n for (var 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 2 * TP / (2 * TP + this.getFalsePositiveCount(label) + this.getFalseNegativeCount(label));\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 (TP * TN - FP * FN) / Math.sqrt((TP + FP) * (TP + FN) * (TN + FP) * (TN + FN));\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 this.getTruePositiveRate(label) + this.getTrueNegativeRate(label) - 1;\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 this.getPositivePredictiveValue(label) + this.getNegativePredictiveValue(label) - 1;\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 [\n this.getTruePositiveCount(label),\n this.getFalseNegativeCount(label)\n ],\n [\n this.getFalsePositiveCount(label),\n this.getTrueNegativeCount(label)\n ]\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 (var i = 0; i < this.matrix.length; i++) {\n for (var 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 /**\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\nmodule.exports = ConfusionMatrix;\n","'use strict';\nconst defaultOptions = {\n mode: 'index'\n};\n\nmodule.exports = function *(M, N, options) {\n options = Object.assign({}, defaultOptions, options);\n var a = new Array(N);\n var c = new Array(M);\n var b = new Array(N);\n var p = new Array(N + 2);\n var x, y, z;\n\n // init a and b\n for (var i = 0; i < N; i++) {\n a[i] = i;\n if (i < N - M) b[i] = 0;\n else b[i] = 1;\n }\n\n // init c\n for (i = 0; i < M; i++) {\n c[i] = N - M + i;\n }\n\n // init p\n for (i = 0; i < p.length; i++) {\n if (i === 0) p[i] = N + 1;\n else if (i <= N - M) p[i] = 0;\n else if (i <= N) p[i] = i - N + M;\n else p[i] = -2;\n }\n\n function twiddle() {\n var i, j, k;\n j = 1;\n while (p[j] <= 0) {\n j++;\n }\n if (p[j - 1] === 0) {\n for (i = j - 1; i !== 1; i--) {\n p[i] = -1;\n }\n p[j] = 0;\n x = z = 0;\n p[1] = 1;\n y = j - 1;\n } else {\n if (j > 1) {\n p[j - 1] = 0;\n }\n do {\n j++;\n }\n while (p[j] > 0);\n k = j - 1;\n i = j;\n while (p[i] === 0) {\n p[i++] = -1;\n }\n if (p[i] === -1) {\n p[i] = p[k];\n z = p[k] - 1;\n x = i - 1;\n y = k - 1;\n p[k] = -1;\n } else {\n if (i === p[0]) {\n return 0;\n } else {\n p[j] = p[i];\n z = p[i] - 1;\n p[i] = 0;\n x = j - 1;\n y = i - 1;\n }\n }\n }\n return 1;\n }\n\n if (options.mode === 'index') {\n yield c.slice();\n while (twiddle()) {\n c[z] = a[x];\n yield c.slice();\n }\n } else if (options.mode === 'mask') {\n yield b.slice();\n while (twiddle()) {\n b[x] = 1;\n b[y] = 0;\n yield b.slice();\n }\n } else {\n throw new Error('Invalid mode');\n }\n};\n","'use strict';\n\nconst ConfusionMatrix = require('ml-confusion-matrix');\n\nconst CV = {};\nconst combinations = require('ml-combinations');\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 */\nCV.leaveOneOut = function (Classifier, features, labels, classifierOptions) {\n if (typeof labels === 'function') {\n var callback = labels;\n labels = features;\n features = Classifier;\n return CV.leavePOut(features, labels, 1, callback);\n }\n return CV.leavePOut(Classifier, features, labels, classifierOptions, 1);\n};\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 */\nCV.leavePOut = function (Classifier, features, labels, classifierOptions, p) {\n if (typeof classifierOptions === 'function') {\n var 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 var N = features.length;\n var gen = combinations(p, N);\n var allIdx = new Array(N);\n for (let i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n for (const testIdx of gen) {\n var 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(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback);\n } else {\n validate(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, 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 */\nCV.kFold = function (Classifier, features, labels, classifierOptions, k) {\n if (typeof classifierOptions === 'function') {\n var 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 var N = features.length;\n var allIdx = new Array(N);\n for (var i = 0; i < N; i++) {\n allIdx[i] = i;\n }\n\n var l = Math.floor(N / k);\n // create random k-folds\n var current = [];\n var folds = [];\n while (allIdx.length) {\n var 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 if (current.length) folds.push(current);\n folds = folds.slice(0, k);\n\n\n for (i = 0; i < folds.length; i++) {\n var testIdx = folds[i];\n var trainIdx = [];\n for (var j = 0; j < folds.length; j++) {\n if (j !== i) trainIdx = trainIdx.concat(folds[j]);\n }\n\n if (callback) {\n validateWithCallback(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback);\n } else {\n validate(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, distinct);\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 var 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(Classifier, features, labels, classifierOptions, testIdx, trainIdx, confusionMatrix, distinct) {\n const {testFeatures, trainFeatures, testLabels, trainLabels} = getTrainTest(features, labels, testIdx, trainIdx);\n\n var 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 var predictedLabels = classifier.predict(testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction validateWithCallback(features, labels, testIdx, trainIdx, confusionMatrix, distinct, callback) {\n const {testFeatures, trainFeatures, testLabels, trainLabels} = getTrainTest(features, labels, testIdx, trainIdx);\n const predictedLabels = callback(trainFeatures, trainLabels, testFeatures);\n updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct);\n}\n\nfunction updateConfusionMatrix(confusionMatrix, testLabels, predictedLabels, distinct) {\n\n for (var 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\n\nfunction 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\nmodule.exports = CV;\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","/**\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 var error = 0;\n const func = parameterizedFunction(parameters);\n\n for (var 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 var ans = new Array(n);\n\n for (var param = 0; param < n; param++) {\n ans[param] = new Array(m);\n var auxParams = params.concat();\n auxParams[param] += gradientDifference;\n var funcParam = paramFunction(auxParams);\n\n for (var 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 var ans = new Array(m);\n\n for (var 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 var value = damping * gradientDifference * gradientDifference;\n var identity = Matrix.eye(params.length, params.length, value);\n\n const func = parameterizedFunction(params);\n var evaluatedData = data.x.map((e) => func(e));\n\n var gradientFunc = gradientFunction(\n data,\n evaluatedData,\n params,\n gradientDifference,\n parameterizedFunction\n );\n var matrixFunc = matrixFunction(data, evaluatedData);\n var 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 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 !Array.isArray(data.x) ||\n data.x.length < 2 ||\n !Array.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 var 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 (!Array.isArray(parameters)) {\n throw new Error('initialValues must be an array');\n }\n\n var error = errorCalculation(data, parameters, parameterizedFunction);\n\n var converged = error <= errorTolerance;\n\n for (\n var iteration = 0;\n iteration < maxIterations && !converged;\n iteration++\n ) {\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' || Number.isNaN(number)) {\n\t\tthrow new TypeError('Expected a number');\n\t}\n}\n\nexports.ascending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\n\treturn left - right;\n};\n\nexports.descending = (left, right) => {\n\tassertNumber(left);\n\tassertNumber(right);\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\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;\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","import isArray from 'is-any-array';\n\n/**\n * Computes the mode of the given values\n * @param {Array} input\n * @return {number}\n */\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","import max from 'ml-array-max';\nimport sum from 'ml-array-sum';\n\n/**\n * Computes the norm of the given values\n * @param {Array} input\n * @param {object} [options={}]\n * @param {string} [options.algorithm='absolute'] absolute, sum or max\n * @return {number}\n */\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\n if (!Array.isArray(input)) {\n throw new Error('input must be an array');\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);\n if (absoluteSumValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / absoluteSumValue;\n });\n }\n\n case 'max':\n {\n var maxValue = max(input);\n if (maxValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / maxValue;\n });\n }\n\n case 'sum':\n {\n var sumValue = sum(input);\n if (sumValue === 0) return input.slice(0);\n return input.map(function (element) {\n return element / sumValue;\n });\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 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/**\n * Fill an array with sequential numbers\n * @param {Array} [input] - optional destination array (if not provided a new array will be created)\n * @param {object} [options={}]\n * @param {number} [options.from=0] - first value in the array\n * @param {number} [options.to=10] - last value in the array\n * @param {number} [options.size=input.length] - size of the array (if not provided calculated from step)\n * @param {number} [options.step] - if not provided calculated from size\n * @return {Array}\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 && 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 input.length = 0; // only works with normal array\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","import arrayMean from 'ml-array-mean';\nimport isArray from 'is-any-array';\n\n/**\n * Computes the variance of the given values\n * @param {Array} values\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @param {number} [options.mean = arrayMean] - precalculated mean, if any.\n * @return {number}\n */\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\n/**\n * Computes the standard deviation of the given values\n * @param {Array} values\n * @param {object} [options]\n * @param {boolean} [options.unbiased = true] - if true, divide by (n-1); if false, divide by n.\n * @param {number} [options.mean = arrayMean] - precalculated mean, if any.\n * @return {number}\n */\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 * 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 var xLength = x.length;\n\n var step = (to - from) / (numberOfPoints - 1);\n var halfStep = step / 2;\n\n var output = new Array(numberOfPoints);\n\n var initialOriginalStep = x[1] - x[0];\n var lastOriginalStep = x[xLength - 1] - x[xLength - 2];\n\n // Init main variables\n var min = from - halfStep;\n var max = from + halfStep;\n\n var previousX = Number.MIN_VALUE;\n var previousY = 0;\n var nextX = x[0] - initialOriginalStep;\n var nextY = 0;\n\n var currentValue = 0;\n var slope = 0;\n var intercept = 0;\n var sumAtMin = 0;\n var sumAtMax = 0;\n\n var i = 0; // index of input\n var j = 0; // index of output\n\n function getSlope(x0, y0, x1, y1) {\n return (y1 - y0) / (x1 - x0);\n }\n\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 var 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 var xLength = x.length;\n\n var step = (to - from) / (numberOfPoints - 1);\n var halfStep = step / 2;\n var lastStep = x[x.length - 1] - x[x.length - 2];\n\n var start = from - halfStep;\n var output = new Array(numberOfPoints);\n\n // Init main variables\n var min = start;\n var max = start + step;\n\n var previousX = -Number.MAX_VALUE;\n var previousY = 0;\n var nextX = x[0];\n var nextY = y[0];\n var frontOutsideSpectra = 0;\n var backOutsideSpectra = true;\n\n var currentValue = 0;\n\n // for slot algorithm\n var currentPoints = 0;\n\n var i = 1; // index of input\n var 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","export default function getZones(from, to, numberOfPoints, 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, numberOfPoints }];\n }\n\n // need to deal with overlapping exclusions and out of bound exclusions\n\n let toRemove = exclusions.reduce(\n (previous, exclusion) => (previous += exclusion.to - exclusion.from),\n 0\n );\n let total = to - from;\n let unitsPerPoint = (total - toRemove) / numberOfPoints;\n let zones = [];\n let currentFrom = from;\n let totalPoints = 0;\n for (let exclusion of exclusions) {\n let currentNbPoints = Math.round(\n (exclusion.from - currentFrom) / unitsPerPoint\n );\n totalPoints += currentNbPoints;\n if (currentNbPoints > 0) {\n zones.push({\n from: currentFrom,\n to: exclusion.from,\n numberOfPoints: currentNbPoints\n });\n }\n\n currentFrom = exclusion.to;\n }\n if (numberOfPoints - totalPoints > 0) {\n zones.push({\n from: currentFrom,\n to: to,\n numberOfPoints: numberOfPoints - totalPoints\n });\n }\n\n return zones;\n}\n","import sequentialFill from 'ml-array-sequential-fill';\n\nimport equallySpacedSmooth from './equallySpacedSmooth';\nimport equallySpacedSlot from './equallySpacedSlot';\nimport getZones from './getZones';\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 * @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 * @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 } = 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 let zones = getZones(from, to, numberOfPoints, exclusions);\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 xResult = xResult.concat(zoneResult.x);\n yResult = yResult.concat(zoneResult.y);\n }\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 var 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 } from 'ml-pls';\nexport { default as CrossValidation } from 'ml-cross-validation';\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';\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","isArray","TypeError","length","maxValue","i","min","minValue","rescale","output","options","arguments","undefined","Array","currentMin","currentMax","RangeError","_options$min","autoMinMax","_options$max","factor","checkRowIndex","matrix","index","outer","rows","checkColumnIndex","columns","checkRowVector","vector","to1DArray","checkColumnVector","checkIndices","rowIndices","columnIndices","row","checkRowIndices","column","checkColumnIndices","some","r","from","c","checkRange","startRow","endRow","startColumn","endColumn","checkNumber","newArray","value","array","push","name","sumByRow","sum","j","get","sumByColumn","sumAll","v","productByRow","productByColumn","productAll","varianceByRow","unbiased","mean","cols","variance","sum1","sum2","x","varianceByColumn","varianceAll","size","centerByRow","set","centerByColumn","centerAll","getScaleByRow","scale","Math","pow","sqrt","scaleByRow","getScaleByColumn","scaleByColumn","getScaleAll","divider","scaleAll","inspectMatrix","indent","repeat","indentData","this","constructor","inspectData","maxRows","maxColumns","maxNumSize","maxI","maxJ","result","line","formatNumber","join","num","numStr","String","padEnd","precise","toPrecision","exponential","toExponential","eIndex","indexOf","e","substring","installMathOperations","AbstractMatrix","Matrix","add","addS","addM","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","tan","tanh","trunc","arg0","powS","powM","newRows","newColumns","newData","newMatrix","fill","random","Number","isInteger","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","Error","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","returnArray","linearDependencies","thresholdError","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","int32","engine","next","addend","int53","int53Full","uint32","uint53","uint53Full","isPowerOfTwoMinusOne","bitmask","masking","downscaleToLoopCheckedRange","extendedRange","maximum","downscaleToRange","isEvenlyDivisibleByMaxInt32","upscaleWithHighMasking","upscaleToLoopCheckedRange","upscaleWithinU53","highRange","upscaleWithinI53AndLoopCheck","integer","DEFAULT_STRING_POOL","string","pool","poolLength","charAt","LOWER_HEX_POOL","lowerHex","upperHex","toUpperCase","stringRepeat","pattern","_","nativeMath","I32Array","buffer","ArrayBuffer","view","Int32Array","createEntropy","Date","getTime","imul","al","bl","ARRAY_SIZE","ARRAY_MAX","M","ARRAY_SIZE_MINUS_M","A","MersenneTwister19937","uses","initial","seed","source","seedWithArray","refreshData","temper","getUseCount","discard","previous","sourceLength","checkFloat","examplesBaggingWithReplacement","trainingValue","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","slice","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","_j","_ref1","_results","_results1","_len","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","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","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","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","N","twiddle","CV","initMatrix","getDistinct","validate","Classifier","classifierOptions","testIdx","trainIdx","confusionMatrix","distinct","testFeatures","trainFeatures","testLabels","trainLabels","getTrainTest","classifier","updateConfusionMatrix","validateWithCallback","predictedLabels","leaveOneOut","leavePOut","gen","combinations","allIdx","kFold","current","folds","randi","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","keys","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","hasOwnProperty","numWeights","converters","getConverters","extractor","creator","nodeType","hx","distanceMethod","getMaxDistance","times","findBMU","adjust","iterationCount","startLearningRate","mapRadius","algorithmMethod","_initNodes","done","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","self","_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","fn","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","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","key","objectCollection","BigInt","sorted","cssls","XtX","XtY","Pset","choXtX","luXtX","sortedPset","sortedEset","cols2Solve","vars","initialisation","Fset","D","setDifference","C","includes","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","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","err","fpr","tpr","fnr","tnr","ppv","npv","pcfall","pcmiss","lift","rpp","rnp","arrayCase","cond","matrixCase","padArray","windowSize","derivative","pad","padValue","savitzkyGolay","J","inic","Jtranspose","det","eightBits","arr1","arr2","getBit","mask","setBit","toBinaryString","substr","parseBinaryString","toHexString","parseHexString","toDebug","binary","maxCount","_options$algorithm","algorithm","absoluteSumValue","absoluteSum","_typeof","iterator","sequentialFill","_options","_options$from","_options$to","_options$size","_options$unbiased","_options$mean","sqrError","mergeByCentroids","originalPoints","mergedPoints","originalIndex","mergedIndex","closestX","descending","maxMerge","groupWidth","merged","maxAbscissa","maxY","calculateIndex","sortX","sortFunc","grouped","response","uniqueX","weightedMerge","weightedAbscissa","integral","x0","x1","equallySpacedSmooth","numberOfPoints","xLength","halfStep","initialOriginalStep","lastOriginalStep","previousX","previousY","nextX","nextY","currentValue","sumAtMin","sumAtMax","main","equallySpacedSlot","lastStep","frontOutsideSpectra","backOutsideSpectra","getZones","exclusions","exclusion","JSON","parse","stringify","toRemove","unitsPerPoint","zones","currentFrom","totalPoints","currentNbPoints","equallySpaced","arrayXY","variant","xResult","yResult","zone","zoneResult","processZone","filterX","currentZoneIndex","newX","newY","position","MatrixLib","normed","ArrayXY","centroidsMerge"],"mappings":"sMAEA,MAAMA,SAAWC,OAAOC,UAAUF,SAElC,SAASG,WAAWC,UACXJ,SAAS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,OAAS,WAGzBmhB,GAAY,GACFC,GAAOD,GAAQg+B,EAASn/C,OAChC,MAAM,IAAIa,WAAW,4BAGnBugB,GAAOD,OAMX+R,GAAOmsB,EAAWF,EADlBhsB,EAAM/R,GAAQD,EAAOC,IAAS,IACGg+B,EAAQjsB,EAAKgsB,IAGrC,EACP/9B,EAAO+R,EAAM,MAGV,CAAA,KAAGD,EAAM,GAKZ,OAAOC,EAJPhS,EAAOgS,EAAM,SAQT/R,GCzCV,SAASk+B,aAAaC,MACC,iBAAXA,GAAuB3yC,OAAO+P,MAAM4iC,SACxC,IAAIx/C,UAAU,qBAItB,cAAoB,CAACqnB,EAAMC,KAC1Bi4B,aAAal4B,GACbk4B,aAAaj4B,GACND,EAAOC,cAGM,CAACD,EAAMC,KAC3Bi4B,aAAal4B,GACbk4B,aAAaj4B,GACNA,EAAQD,iLCdT,MAAMo4B,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,UAAU38C,OACpB3B,EAAQu+C,aAAaF,aAAc18C,EAAO68C,kBAC1Cx+C,EAAQ,IACVA,GAASA,GAEJq+C,aAAar+C,GAPtBq+C,aAAa1oC,KAAK6oC,WCtWlB,MAAMC,KAAO,EACPC,KAAO,EACPC,QAAU,EAEVC,uBAAyB,IACzBC,qBAAuB,EAAI,EAC3BC,qBAAuB,EAAI,EAElB,MAAMC,UACnBv6C,kBAAYrF,yDAAU,MAChBA,aAAmB4/C,sBAChBC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ACX39B,KAAEA,EAAO8B,EAAE,GAAXwjD,GAAeA,EAAKxjD,EAAEA,EAAEpE,OAAS,GAAjCqxD,WAAqCA,EAAa,IAAO9wD,MAE3DqxD,EAAQR,WAAS9uD,EAAMslD,EAAIyJ,GAG3BoB,EAAmB,EACnBC,EAAO,GACPC,EAAO,GACPC,EAAW,OACRA,EAAWxuD,EAAEpE,QAAQ,IAExBoE,EAAEwuD,IAAahB,EAAMa,GAAkB7K,IACvCxjD,EAAEwuD,IAAahB,EAAMa,GAAkBnwD,KAEvCowD,EAAKzvD,KAAKmB,EAAEwuD,IACZD,EAAK1vD,KAAK+R,EAAE49C,YAERxuD,EAAEwuD,GAAYhB,EAAMa,GAAkB7K,KAEnCgK,IADLa,GAC8B,MAGlCG,UAGK,CACLxuD,EAAGsuD,EACH19C,EAAG29C,gBCMLtrD,SADIqY,IAEJA,IAFI8R,IAGJA,0BACAnP,wCACAxI,kCACAe,mBACEi4C,UA4CSnyD,QAAQ,CACnBP,IAAAA,IACAP,IAAAA,IACAuvB,OAAAA,OACAprB,KAAAA,UACA6qB,cACAkkC,OACAzyD,QAAAA,QACA8tD,eAAAA,eACAz2C,kBAAAA,kBACAtU,IAAAA,IACAa,SAAAA,UAaW8uD,QAAU,gBACrBC,iBACAhE,SAAAA,oBACApvC,aACAsvC,SAAAA,SACAI,KAAAA,KACAE,MAAAA,MACAI,QAAAA,QACAC,cAAAA,cACAmC,cAAAA,cACAQ,QAAAA"} \ No newline at end of file diff --git a/package.json b/package.json index 65efe4e..76507f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ml", - "version": "5.1.0", + "version": "5.1.1", "description": "Machine learning tools", "main": "src/index.js", "scripts": {