From 4026b99289c8bfe80a826ba8bdb3fc88ed545827 Mon Sep 17 00:00:00 2001 From: Rene Cutura Date: Tue, 1 Mar 2022 13:18:52 +0100 Subject: [PATCH] DR.parameters bugfix --- dimred/DR.js | 2 +- dist/druid.esm.js | 2 +- dist/druid.esm.js.map | 2 +- dist/druid.js | 2 +- dist/druid.js.map | 2 +- dist/druid.min.js | 2 +- dist/druid.min.js.map | 2 +- docs/BallTree.html | 2 +- docs/DR.html | 2 +- docs/DisjointSet.html | 2 +- docs/FASTMAP.html | 2 +- docs/HIPP.html | 2 +- docs/HNSW.html | 2 +- docs/Heap.html | 2 +- docs/Hierarchical_Clustering.html | 2 +- docs/ISOMAP.html | 2 +- docs/KMeans.html | 2 +- docs/KMedoids.html | 2 +- docs/KNN.html | 2 +- docs/LDA.html | 2 +- docs/LLE.html | 2 +- docs/LSP.html | 2 +- docs/LTSA.html | 2 +- docs/MDS.html | 2 +- docs/Matrix.html | 2 +- docs/NNDescent.html | 2 +- docs/OAP.html | 2 +- docs/OPTICS.html | 2 +- docs/PCA.html | 2 +- docs/Randomizer.html | 2 +- docs/SAMMON.html | 2 +- docs/TSNE.html | 2 +- docs/TopoMap.html | 2 +- docs/TriMap.html | 2 +- docs/UMAP.html | 2 +- docs/XMeans.html | 2 +- docs/clustering_Hierarchical_Clustering.js.html | 2 +- docs/clustering_KMeans.js.html | 2 +- docs/clustering_KMedoids.js.html | 2 +- docs/clustering_OPTICS.js.html | 2 +- docs/clustering_XMeans.js.html | 2 +- docs/clustering_index.js.html | 2 +- docs/datastructure_DisjointSet.js.html | 2 +- docs/datastructure_Heap.js.html | 2 +- docs/datastructure_index.js.html | 2 +- docs/dimred_DR.js.html | 4 ++-- docs/dimred_FASTMAP.js.html | 2 +- docs/dimred_HIPP.js.html | 2 +- docs/dimred_ISOMAP.js.html | 2 +- docs/dimred_LDA.js.html | 2 +- docs/dimred_LLE.js.html | 2 +- docs/dimred_LSP.js.html | 2 +- docs/dimred_LTSA.js.html | 2 +- docs/dimred_MDS.js.html | 2 +- docs/dimred_OAP.js.html | 2 +- docs/dimred_PCA.js.html | 2 +- docs/dimred_SAMMON.js.html | 2 +- docs/dimred_TSNE.js.html | 2 +- docs/dimred_TopoMap.js.html | 2 +- docs/dimred_TriMap.js.html | 2 +- docs/dimred_UMAP.js.html | 2 +- docs/dimred_index.js.html | 2 +- docs/global.html | 2 +- docs/index.html | 2 +- docs/knn_BallTree.js.html | 2 +- docs/knn_HNSW.js.html | 2 +- docs/knn_KNN.js.html | 2 +- docs/knn_NNDescent.js.html | 2 +- docs/knn_dijkstra.js.html | 2 +- docs/knn_index.js.html | 2 +- docs/linear_algebra_index.js.html | 2 +- docs/linear_algebra_inner_product.js.html | 2 +- docs/linear_algebra_poweriteration_m.js.html | 2 +- docs/linear_algebra_poweriteration_n.js.html | 2 +- docs/linear_algebra_qr.js.html | 2 +- docs/linear_algebra_qr_givens.js.html | 2 +- docs/linear_algebra_qr_householder.js.html | 2 +- docs/linear_algebra_sapi.js.html | 2 +- docs/linear_algebra_simultaneous_poweriteration.js.html | 2 +- docs/linear_algebra_svrg.js.html | 2 +- docs/matrix_Matrix.js.html | 2 +- docs/matrix_distance_matrix.js.html | 2 +- docs/matrix_index.js.html | 2 +- docs/matrix_k_nearest_neighbors.js.html | 2 +- docs/matrix_linspace.js.html | 2 +- docs/matrix_norm.js.html | 2 +- docs/matrix_normalize.js.html | 2 +- docs/metrics_canberra.js.html | 2 +- docs/metrics_chebyshev.js.html | 2 +- docs/metrics_cosine.js.html | 2 +- docs/metrics_euclidean.js.html | 2 +- docs/metrics_euclidean_squared.js.html | 2 +- docs/metrics_hamming.js.html | 2 +- docs/metrics_index.js.html | 2 +- docs/metrics_jaccard.js.html | 2 +- docs/metrics_manhattan.js.html | 2 +- docs/metrics_sokal_michener.js.html | 2 +- docs/metrics_yule.js.html | 2 +- docs/module-clustering.html | 2 +- docs/module-datastructure.html | 2 +- docs/module-dimensionality_reduction.html | 2 +- docs/module-knn.html | 2 +- docs/module-linear_algebra.html | 2 +- docs/module-matrix.html | 2 +- docs/module-metrics.html | 2 +- docs/module-numerical.html | 2 +- docs/module-optimization.html | 2 +- docs/module-utils.html | 2 +- docs/numerical_index.js.html | 2 +- docs/numerical_kahan_sum.js.html | 2 +- docs/numerical_neumair_sum.js.html | 2 +- docs/optimization_index.js.html | 2 +- docs/optimization_powell.js.html | 2 +- docs/util_index.js.html | 2 +- docs/util_max.js.html | 2 +- docs/util_min.js.html | 2 +- docs/util_randomizer.js.html | 2 +- 117 files changed, 118 insertions(+), 118 deletions(-) diff --git a/dimred/DR.js b/dimred/DR.js index 6ba8552..a5af1cf 100755 --- a/dimred/DR.js +++ b/dimred/DR.js @@ -52,7 +52,7 @@ export class DR { if (!this._parameters.hasOwnProperty(name)) { throw new Error(`${name} is not a valid parameter!`); } - if (value) { + if (value !== null) { this._parameters[name] = value; this._is_initialized = false; return this; diff --git a/dist/druid.esm.js b/dist/druid.esm.js index e1fb7b3..8e8669a 100644 --- a/dist/druid.esm.js +++ b/dist/druid.esm.js @@ -724,7 +724,7 @@ constructor(t,e,r){if(this._parameters=Object.assign(Object.seal(e),r),Array.isA * const DR = new druid.TSNE(X, {d: 3}); // creates a new DR object, with parameter for d = 3. * DR.parameter("d"); // returns 3, * DR.parameter("d", 2); // sets parameter d to 2 and returns DR. - */parameter(t,e=null){if(!this._parameters.hasOwnProperty(t))throw new Error(`${t} is not a valid parameter!`);return e?(this._parameters[t]=e,this._is_initialized=!1,this):this._parameters[t]}para(t,e=null){return this.parameter(t,e)}p(t,e=null){return this.parameter(t,e)} + */parameter(t,e=null){if(!this._parameters.hasOwnProperty(t))throw new Error(`${t} is not a valid parameter!`);return null!==e?(this._parameters[t]=e,this._is_initialized=!1,this):this._parameters[t]}para(t,e=null){return this.parameter(t,e)}p(t,e=null){return this.parameter(t,e)} /** * Computes the projection. * @returns {Matrix} - Returns the projection. diff --git a/dist/druid.esm.js.map b/dist/druid.esm.js.map index b6b07a0..edc161b 100644 --- a/dist/druid.esm.js.map +++ b/dist/druid.esm.js.map @@ -1 +1 @@ -{"version":3,"file":"druid.esm.js","sources":["../metrics/euclidean.js","../numerical/kahan_sum.js","../numerical/neumair_sum.js","../metrics/euclidean_squared.js","../metrics/cosine.js","../metrics/manhattan.js","../metrics/chebyshev.js","../metrics/canberra.js","../metrics/jaccard.js","../metrics/hamming.js","../metrics/sokal_michener.js","../metrics/yule.js","../matrix/k_nearest_neighbors.js","../matrix/distance_matrix.js","../matrix/linspace.js","../matrix/norm.js","../matrix/normalize.js","../linear_algebra/qr.js","../linear_algebra/qr_householder.js","../linear_algebra/simultaneous_poweriteration.js","../linear_algebra/inner_product.js","../matrix/Matrix.js","../util/randomizer.js","../util/max.js","../util/min.js","../datastructure/Heap.js","../datastructure/DisjointSet.js","../knn/BallTree.js","../knn/KNN.js","../dimred/DR.js","../dimred/PCA.js","../dimred/MDS.js","../dimred/ISOMAP.js","../dimred/FASTMAP.js","../dimred/LDA.js","../dimred/LLE.js","../dimred/LTSA.js","../dimred/TSNE.js","../optimization/powell.js","../dimred/UMAP.js","../dimred/TriMap.js","../clustering/Hierarchical_Clustering.js","../clustering/KMeans.js","../clustering/KMedoids.js","../clustering/OPTICS.js","../dimred/LSP.js","../dimred/TopoMap.js","../dimred/SAMMON.js"],"sourcesContent":["import { euclidean_squared } from \"../metrics/index.js\";\n/**\n * Computes the euclidean distance (l2) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n return Math.sqrt(euclidean_squared(a, b));\n}\n","/**\n * Numerical stable summation with the Kahan summation algorithm.\n * @memberof module:numerical\n * @alias kahan_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n let y, t;\n\n for (let i = 0; i < n; ++i) {\n y = summands[i] - compensation;\n t = sum + y;\n compensation = t - sum - y;\n sum = t;\n }\n return sum;\n}\n","/**\n * Numerical stable summation with the Neumair summation algorithm.\n * @memberof module:numerical\n * @alias neumair_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm#Further_enhancements}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n\n for (let i = 0; i < n; ++i) {\n let summand = summands[i];\n let t = sum + summand;\n if (Math.abs(sum) >= Math.abs(summand)) {\n compensation += sum - t + summand;\n } else {\n compensation += summand - t + sum;\n }\n sum = t;\n }\n return sum + compensation;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n/**\n * Computes the squared euclidean distance (l22) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean_squared\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the squared euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let s = new Array(n);\n for (let i = 0; i < n; ++i) {\n let x = a[i];\n let y = b[i];\n s[i] = (x - y) * (x - y);\n }\n return neumair_sum(s);\n}\n","/**\n * Computes the cosine distance (not similarity) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias cosine\n * @param {Array} a\n * @param {Array} b\n * @example\n * druid.cosine([1,0],[1,1]) == 0.7853981633974484 == π/4\n * @returns {Number} The cosine distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n let sum_a = 0;\n let sum_b = 0;\n for (let i = 0; i < n; ++i) {\n sum += a[i] * b[i];\n sum_a += a[i] * a[i];\n sum_b += b[i] * b[i];\n }\n return Math.acos(sum / (Math.sqrt(sum_a) * Math.sqrt(sum_b)));\n}\n","/**\n * Computes the manhattan distance (l1) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias manhattan\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the manhattan distance between {@link a} and {@link b}.\n */ \nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += Math.abs(a[i] - b[i]);\n }\n return sum;\n}\n","/**\n * Computes the chebyshev distance (L) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias chebyshev\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the chebyshev distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let res = [];\n for (let i = 0; i < n; ++i) {\n res.push(Math.abs(a[i] - b[i]));\n }\n return Math.max(...res);\n}\n","/**\n * Computes the canberra distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias canberra\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} The canberra distance between {@link a} and {@link b}.\n * @see {@link https://en.wikipedia.org/wiki/Canberra_distance}\n */\nexport default function(a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += (Math.abs(a[i] - b[i]) / (Math.abs(a[i]) + Math.abs(b[i])))\n }\n return sum;\n}","/**\n * Computes the jaccard distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias jaccard\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the jaccard distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_non_zero = 0;\n let num_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_non_zero += x || y;\n num_equal += x && y;\n }\n return (num_non_zero - num_equal) / num_non_zero;\n}\n","/**\n * Computes the hamming distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias hamming\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the hamming distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let disagree = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i];\n const y = b[i];\n disagree += x != y;\n }\n return disagree / n;\n}\n","/**\n * Computes the Sokal-Michener distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias sokal_michener\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} the Sokal-Michener distance between {@link a} and {@link b}. \n */\nexport default function(a, b) {\n if (a.length != b.length) return undefined\n const n = a.length;\n let num_not_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_not_equal += x != y;\n }\n return (2 * num_not_equal) / (n + num_not_equal);\n}","/**\n * Computes the yule distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias yule\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the yule distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_true_true = 0;\n let num_true_false = 0;\n let num_false_true = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_true_true += x && y;\n num_true_false += x && !y;\n num_false_true += !x && x;\n }\n const num_false_false = n - num_true_true - num_true_false - num_false_true;\n return num_true_false == 0 || num_false_true == 0 ? 0 : (2 * num_true_false * num_false_true) / (num_true_true * num_false_false + num_true_false * num_false_true);\n}\n","import { distance_matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Computes the k-nearest neighbors of each row of {@link A}.\n * @memberof module:matrix\n * @alias k_nearest_neigbhors\n * @param {Matrix} A - Either the data matrix, or a distance matrix.\n * @param {Number} k - The number of neighbors to compute.\n * @param {Function|\"precomputed\"} [metric=euclidean]\n * @returns {Array} -\n */\nexport default function (A, k, metric = euclidean) {\n const rows = A.shape[0];\n let D = metric == \"precomputed\" ? A : distance_matrix(A, metric);\n let nN = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n nN[row] = Array.from(D.row(row))\n .map((distance, col) => {\n return {\n i: row,\n j: col,\n distance: distance,\n };\n })\n .sort((a, b) => a.distance - b.distance)\n .slice(1, k + 1);\n }\n return nN;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"./index.js\";\n\n/**\n * Computes the distance matrix of datamatrix {@link A}.\n * @memberof module:matrix\n * @alias distance_matrix\n * @param {Matrix} A - Matrix.\n * @param {Function} [metric=euclidean] - The diistance metric.\n * @returns {Matrix} D - The distance matrix of {@link A}.\n */\nexport default function (A, metric = euclidean) {\n let n = A.shape[0];\n const D = new Matrix(n, n);\n for (let i = 0; i < n; ++i) {\n const A_i = A.row(i);\n for (let j = i + 1; j < n; ++j) {\n const dist = metric(A_i, A.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n }\n }\n return D;\n}\n","/**\n * Creates an Array containing {@link number} numbers from {@link start} to {@link end}.\n * If {@link number} = null.\n * @memberof module:matrix\n * @alias linspace\n * @param {Number} start - Start value.\n * @param {Number} end - End value.\n * @param {Number} [number = null] - Number of number between {@link start} and {@link end}.\n * @returns {Array} - An array with {@link number} entries, beginning at {@link start} ending at {@link end}.\n */\nexport default function (start, end, number = null) {\n if (!number) {\n number = Math.max(Math.round(end - start) + 1, 1);\n }\n if (number < 2) {\n return number === 1 ? [start] : [];\n }\n let result = new Array(number);\n number -= 1;\n for (let i = number; i >= 0; --i) {\n result[i] = (i * end + (number - i) * start) / number;\n }\n return result;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n//import { neumair_sum } from \"../numerical/index\";\n\n/**\n * Computes the norm of a vector, by computing its distance to **0**.\n * @memberof module:matrix\n * @alias norm\n * @param {Matrix|Array|Float64Array} v - Vector. \n * @param {Function} [metric = euclidean] - Which metric should be used to compute the norm.\n * @returns {Number} - The norm of {@link v}.\n */\nexport default function (v, metric = euclidean) {\n let vector = null;\n if (v instanceof Matrix) {\n let [rows, cols] = v.shape;\n if (rows === 1) vector = v.row(0);\n else if (cols === 1) vector = v.col(0);\n else throw new Error(\"Matrix must be 1d!\");\n } else {\n vector = v;\n }\n const n = vector.length;\n const zeros = Float64Array.from({ length: n }, () => 0);\n return metric(vector, zeros);\n}\n","import { norm } from \"./index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Normalizes Vector {@link v}.\n * @memberof module:matrix\n * @alias normalize\n * @param {Array|Float64Array} v - Vector\n * @param {Function} metric \n * @returns {Array|Float64Array} - The normalized vector with length 1.\n */\nexport default function(v, metric = euclidean) {\n const v_norm = norm(v, metric);\n return v.map(value => value / v_norm);\n}","import { Matrix, norm } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} using Gram-Schmidt process.\n * @memberof module:linear_algebra\n * @alias qr\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_the_Gram%E2%80%93Schmidt_process}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, cols, \"identity\");\n const R = new Matrix(cols, cols, 0);\n\n for (let j = 0; j < cols; ++j) {\n let v = A.col(j);\n for (let i = 0; i < j; ++i) {\n const q = Q.col(i);\n const q_dot_v = neumair_sum(q.map((q_, k) => q_ * v[k]));\n R.set_entry(i, j, q_dot_v);\n v = v.map((v_, k) => v_ - q_dot_v * q[k]);\n }\n const v_norm = norm(v, euclidean);\n for (let k = 0; k < rows; ++k) {\n Q.set_entry(k, j, v[k] / v_norm);\n }\n R.set_entry(j, j, v_norm);\n }\n return { R, Q };\n}\n","import { Matrix, norm } from \"../matrix/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} with householder transformations.\n * @memberof module:linear_algebra\n * @alias qr_householder\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections}\n * @see {@link http://mlwiki.org/index.php/Householder_Transformation}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, rows, \"I\");\n const R = A.clone();\n\n for (let j = 0; j < cols; ++j) {\n const x = Matrix.from(R.col(j).slice(j));\n const x_norm = norm(x);\n const x0 = x.entry(0, 0);\n const rho = -Math.sign(x0);\n const u1 = x0 - rho * x_norm;\n const u = x.divide(u1).set_entry(0, 0, 1);\n const beta = (-rho * u1) / x_norm;\n\n const u_outer_u = u.outer(u);\n const R_block = R.get_block(j, 0);\n const new_R = R_block.sub(u_outer_u.dot(R_block).mult(beta));\n const Q_block = Q.get_block(0, j);\n const new_Q = Q_block.sub(Q_block.dot(u_outer_u).mult(beta));\n R.set_block(j, 0, new_R);\n Q.set_block(0, j, new_Q);\n }\n return { R, Q };\n}\n","import { qr as qr_gramschmidt } from \"./index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { euclidean_squared } from \"../metrics/index.js\";\n\n/**\n * Computes the {@link k} biggest Eigenvectors and Eigenvalues from Matrix {@link A} with the QR-Algorithm.\n * @memberof module:linear_algebra\n * @alias simultaneous_poweriteration\n * @param {Matrix} A - The Matrix\n * @param {Number} k - The number of eigenvectors and eigenvalues to compute.\n * @param {Object} parameters - Object containing parameterization of the simultanious poweriteration method.\n * @param {Number} [parameters.max_iterations=100] - The number of maxiumum iterations the algorithm should run.\n * @param {Number|Randomizer} [parameters.seed=1212] - The seed value or a randomizer used in the algorithm.\n * @param {Function} [parameters.qr=qr_gramschmidt] - The QR technique to use.\n * @param {Number} [parameters.tol=1e-8] - Allowed error for stopping criteria\n * @returns {{eigenvalues: Array, eigenvectors: Array}} - The {@link k} biggest eigenvectors and eigenvalues of Matrix {@link A}.\n */\nexport default function (A, k = 2, {seed = 1212, max_iterations = 100, qr = qr_gramschmidt, tol = 1e-8} = {}) {\n const randomizer = seed instanceof Randomizer ? seed : new Randomizer(seed);\n if (!(A instanceof Matrix)) A = Matrix.from(A);\n const n = A.shape[0];\n let { Q, R } = qr(new Matrix(n, k, () => (randomizer.random - .5) * 2));\n while (max_iterations--) {\n const oldQ = Q.clone();\n const Z = A.dot(Q);\n const QR = qr(Z);\n Q = QR.Q;\n R = QR.R;\n const error = euclidean_squared(Q.values, oldQ.values);\n if (error < tol) {\n break;\n }\n }\n\n const eigenvalues = R.diag;\n const eigenvectors = Q.transpose().to2dArray;\n return { eigenvalues, eigenvectors };\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the inner product between two arrays of the same length.\n * @memberof module:linear_algebra\n * @alias inner_product\n * @param {Array|Float64Array} a - Array a\n * @param {Array|Float64Array} b - Array b\n * @returns The inner product between {@link a} and {@link b}\n */\nexport default function (a, b) {\n const N = a.length;\n if (N != b.length) {\n throw new Error(\"Array a and b must have the same length!\")\n }\n let sum = 0;\n for (let i = 0; i < N; ++i) {\n sum += a * b;\n }\n return sum;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n/**\n * @class\n * @alias Matrix\n * @requires module:numerical/neumair_sum\n */\nexport class Matrix {\n /**\n * creates a new Matrix. Entries are stored in a Float64Array.\n * @constructor\n * @memberof module:matrix\n * @alias Matrix\n * @param {number} rows - The amount of rows of the matrix.\n * @param {number} cols - The amount of columns of the matrix.\n * @param {(function|string|number)} value=0 - Can be a function with row and col as parameters, a number, or \"zeros\", \"identity\" or \"I\", or \"center\".\n * - **function**: for each entry the function gets called with the parameters for the actual row and column.\n * - **string**: allowed are\n * - \"zero\", creates a zero matrix.\n * - \"identity\" or \"I\", creates an identity matrix.\n * - \"center\", creates an center matrix.\n * - **number**: create a matrix filled with the given value.\n * @example\n *\n * let A = new Matrix(10, 10, () => Math.random()); //creates a 10 times 10 random matrix.\n * let B = new Matrix(3, 3, \"I\"); // creates a 3 times 3 identity matrix.\n * @returns {Matrix} returns a {@link rows} times {@link cols} Matrix filled with {@link value}.\n */\n constructor(rows = null, cols = null, value = null) {\n this._rows = rows;\n this._cols = cols;\n this._data = null;\n if (rows && cols) {\n if (!value) {\n this._data = new Float64Array(rows * cols);\n return this;\n }\n if (typeof value === \"function\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n if (typeof value === \"string\") {\n if (value === \"zeros\") {\n return new Matrix(rows, cols, 0);\n }\n if (value === \"identity\" || value === \"I\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n this._data[row * cols + row] = 1;\n }\n return this;\n }\n if (value === \"center\" && rows == cols) {\n this._data = new Float64Array(rows * cols);\n value = (i, j) => (i === j ? 1 : 0) - 1 / rows;\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n }\n if (typeof value === \"number\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value;\n }\n }\n return this;\n }\n }\n return this;\n }\n\n /**\n * Creates a Matrix out of {@link A}.\n * @param {(Matrix|Array|Float64Array|number)} A - The matrix, array, or number, which should converted to a Matrix.\n * @param {\"row\"|\"col\"|\"diag\"} [type = \"row\"] - If {@link A} is a Array or Float64Array, then type defines if it is a row- or a column vector.\n * @returns {Matrix}\n *\n * @example\n * let A = Matrix.from([[1, 0], [0, 1]]); //creates a two by two identity matrix.\n * let S = Matrix.from([1, 2, 3], \"diag\"); // creates a 3 by 3 matrix with 1, 2, 3 on its diagonal. [[1, 0, 0], [0, 2, 0], [0, 0, 3]]\n */\n static from(A, type = \"row\") {\n if (A instanceof Matrix) {\n return A.clone();\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let m = A.length;\n if (m === 0) throw new Error(\"Array is empty\");\n // 1d\n if (!Array.isArray(A[0]) && !(A[0] instanceof Float64Array)) {\n if (type === \"row\") {\n return new Matrix(1, m, (_, j) => A[j]);\n } else if (type === \"col\") {\n return new Matrix(m, 1, (i) => A[i]);\n } else if (type === \"diag\") {\n return new Matrix(m, m, (i, j) => (i == j ? A[i] : 0));\n } else {\n throw new Error(\"1d array has NaN entries\");\n }\n // 2d\n } else if (Array.isArray(A[0]) || A[0] instanceof Float64Array) {\n let n = A[0].length;\n for (let row = 0; row < m; ++row) {\n if (A[row].length !== n) {\n throw new Error(\"various array lengths\");\n }\n }\n return new Matrix(m, n, (i, j) => A[i][j]);\n }\n } else if (typeof A === \"number\") {\n return new Matrix(1, 1, A);\n } else {\n throw new Error(\"error\");\n }\n }\n\n /**\n * Returns the {@link row}th row from the Matrix.\n * @param {Number} row\n * @returns {Float64Array}\n */\n row(row) {\n const data = this.values;\n const cols = this._cols;\n return data.subarray(row * cols, (row + 1) * cols);\n }\n\n /**\n * Returns an generator yielding each row of the Matrix.\n * @yields {Float64Array}\n */\n *iterate_rows() {\n const cols = this._cols;\n const rows = this._rows;\n const data = this.values;\n for (let row = 0; row < rows; ++row) {\n yield data.subarray(row * cols, (row + 1) * cols);\n }\n }\n\n /**\n * Makes a {@link Matrix} object an iterable object.\n * @yields {Float64Array}\n */\n *[Symbol.iterator]() {\n for (const row of this.iterate_rows()) {\n yield row;\n }\n }\n\n /**\n * Sets the entries of {@link row}th row from the Matrix to the entries from {@link values}.\n * @param {int} row\n * @param {Array} values\n * @returns {Matrix}\n */\n set_row(row, values) {\n let cols = this._cols;\n if (Array.isArray(values) && values.length === cols) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values[col];\n }\n } else if (values instanceof Matrix && values.shape[1] === cols && values.shape[0] === 1) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values._data[col];\n }\n }\n return this;\n }\n\n /**\n * Returns the {@link col}th column from the Matrix.\n * @param {int} col\n * @returns {Array}\n */\n col(col) {\n let result_col = new Float64Array(this._rows);\n for (let row = 0; row < this._rows; ++row) {\n result_col[row] = this.values[row * this._cols + col];\n }\n return result_col;\n }\n\n /**\n * Returns the {@link col}th entry from the {@link row}th row of the Matrix.\n * @param {int} row\n * @param {int} col\n * @returns {float64}\n */\n entry(row, col) {\n return this.values[row * this._cols + col];\n }\n\n /**\n * Sets the {@link col}th entry from the {@link row}th row of the Matrix to the given {@link value}.\n * @param {int} row\n * @param {int} col\n * @param {float64} value\n * @returns {Matrix}\n */\n set_entry(row, col, value) {\n this.values[row * this._cols + col] = value;\n return this;\n }\n\n /**\n * Returns a new transposed Matrix.\n * @returns {Matrix}\n */\n transpose() {\n let B = new Matrix(this._cols, this._rows, (row, col) => this.entry(col, row));\n return B;\n }\n\n /**\n * Returns a new transposed Matrix. Short-form of {@function transpose}.\n * @returns {Matrix}\n */\n get T() {\n return this.transpose();\n }\n\n /**\n * Returns the inverse of the Matrix.\n * @returns {Matrix}\n */\n inverse() {\n const rows = this._rows;\n const cols = this._cols;\n let B = new Matrix(rows, 2 * cols, (i, j) => {\n if (j >= cols) {\n return i === j - cols ? 1 : 0;\n } else {\n return this.entry(i, j);\n }\n });\n let h = 0;\n let k = 0;\n while (h < rows && k < cols) {\n var i_max = 0;\n let max_val = -Infinity;\n for (let i = h; i < rows; ++i) {\n let val = Math.abs(B.entry(i, k));\n if (max_val < val) {\n i_max = i;\n max_val = val;\n }\n }\n if (B.entry(i_max, k) == 0) {\n k++;\n } else {\n // swap rows\n for (let j = 0; j < 2 * cols; ++j) {\n let h_val = B.entry(h, j);\n let i_val = B.entry(i_max, j);\n B.set_entry(h, j, h_val);\n B.set_entry(i_max, j, i_val);\n }\n for (let i = h + 1; i < rows; ++i) {\n let f = B.entry(i, k) / B.entry(h, k);\n B.set_entry(i, k, 0);\n for (let j = k + 1; j < 2 * cols; ++j) {\n B.set_entry(i, j, B.entry(i, j) - B.entry(h, j) * f);\n }\n }\n h++;\n k++;\n }\n }\n\n for (let row = 0; row < rows; ++row) {\n let f = B.entry(row, row);\n for (let col = row; col < 2 * cols; ++col) {\n B.set_entry(row, col, B.entry(row, col) / f);\n }\n }\n\n for (let row = rows - 1; row >= 0; --row) {\n let B_row_row = B.entry(row, row);\n for (let i = 0; i < row; i++) {\n let B_i_row = B.entry(i, row);\n let f = B_i_row / B_row_row;\n for (let j = i; j < 2 * cols; ++j) {\n let B_i_j = B.entry(i, j);\n let B_row_j = B.entry(row, j);\n B_i_j = B_i_j - B_row_j * f;\n B.set_entry(i, j, B_i_j);\n }\n }\n }\n\n return new Matrix(rows, cols, (i, j) => B.entry(i, j + cols));\n }\n\n /**\n * Returns the dot product. If {@link B} is an Array or Float64Array then an Array gets returned. If {@link B} is a Matrix then a Matrix gets returned.\n * @param {(Matrix|Array|Float64Array)} B the right side\n * @returns {(Matrix|Array)}\n */\n dot(B) {\n if (B instanceof Matrix) {\n let A = this;\n if (A.shape[1] !== B.shape[0]) {\n throw new Error(`A.dot(B): A is a ${A.shape.join(\" ⨯ \")}-Matrix, B is a ${B.shape.join(\" ⨯ \")}-Matrix: \n A has ${A.shape[1]} cols and B ${B.shape[0]} rows. \n Must be equal!`);\n }\n let I = A.shape[1];\n let C = new Matrix(A.shape[0], B.shape[1], (row, col) => {\n const A_i = A.row(row);\n const B_i = B.col(col);\n let sum = 0;\n for (let i = 0; i < I; ++i) {\n sum += A_i[i] * B_i[i];\n }\n return sum;\n });\n return C;\n } else if (Array.isArray(B) || B instanceof Float64Array) {\n let rows = this._rows;\n if (B.length !== rows) {\n throw new Error(`A.dot(B): A has ${rows} cols and B has ${B.length} rows. Must be equal!`);\n }\n let C = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n C[row] = neumair_sum(this.row(row).map((e) => e * B[row]));\n }\n return C;\n } else {\n throw new Error(`B must be Matrix or Array`);\n }\n }\n\n /**\n * Computes the outer product from {@link this} and {@link B}.\n * @param {Matrix} B\n * @returns {Matrix}\n */\n outer(B) {\n let A = this;\n let l = A._data.length;\n let r = B._data.length;\n if (l != r) return undefined;\n let C = new Matrix();\n C.shape = [\n l,\n l,\n (i, j) => {\n if (i <= j) {\n return A._data[i] * B._data[j];\n } else {\n return C.entry(j, i);\n }\n },\n ];\n return C;\n }\n\n /**\n * Appends matrix {@link B} to the matrix.\n * @param {Matrix} B - matrix to append.\n * @param {\"horizontal\"|\"vertical\"|\"diag\"} [type = \"horizontal\"] - type of concatenation.\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 1], [1, 1]]); // 2 by 2 matrix filled with ones.\n * let B = Matrix.from([[2, 2], [2, 2]]); // 2 by 2 matrix filled with twos.\n *\n * A.concat(B, \"horizontal\"); // 2 by 4 matrix. [[1, 1, 2, 2], [1, 1, 2, 2]]\n * A.concat(B, \"vertical\"); // 4 by 2 matrix. [[1, 1], [1, 1], [2, 2], [2, 2]]\n * A.concat(B, \"diag\"); // 4 by 4 matrix. [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 2, 2], [0, 0, 2, 2]]\n */\n concat(B, type = \"horizontal\") {\n const A = this;\n const [rows_A, cols_A] = A.shape;\n const [rows_B, cols_B] = B.shape;\n if (type == \"horizontal\") {\n if (rows_A != rows_B) {\n throw new Error(`A.concat(B, \"horizontal\"): A and B need same number of rows, A has ${rows_A} rows, B has ${rows_B} rows.`);\n }\n const X = new Matrix(rows_A, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(0, cols_A, B);\n return X;\n } else if (type == \"vertical\") {\n if (cols_A != cols_B) {\n throw new Error(`A.concat(B, \"vertical\"): A and B need same number of columns, A has ${cols_A} columns, B has ${cols_B} columns.`);\n }\n const X = new Matrix(rows_A + rows_B, cols_A, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, 0, B);\n return X;\n } else if (type == \"diag\") {\n const X = new Matrix(rows_A + rows_B, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, cols_A, B);\n return X;\n } else {\n throw new Error(`type must be \"horizontal\" or \"vertical\", but type is ${type}!`);\n }\n }\n\n /**\n * Writes the entries of B in A at an offset position given by {@link offset_row} and {@link offset_col}.\n * @param {int} offset_row\n * @param {int} offset_col\n * @param {Matrix} B\n * @returns {Matrix}\n */\n set_block(offset_row, offset_col, B) {\n let [rows, cols] = B.shape;\n for (let row = 0; row < rows; ++row) {\n if (row > this._rows) {\n continue;\n }\n for (let col = 0; col < cols; ++col) {\n if (col > this._cols) {\n continue;\n }\n this.set_entry(row + offset_row, col + offset_col, B.entry(row, col));\n }\n }\n return this;\n }\n\n /**\n * Extracts the entries from the {@link start_row}th row to the {@link end_row}th row, the {@link start_col}th column to the {@link end_col}th column of the matrix.\n * If {@link end_row} or {@link end_col} is empty, the respective value is set to {@link this.rows} or {@link this.cols}.\n * @param {Number} start_row\n * @param {Number} start_col\n * @param {Number} [end_row = null]\n * @param {Number} [end_col = null]\n * @returns {Matrix} Returns a end_row - start_row times end_col - start_col matrix, with respective entries from the matrix.\n * @example\n *\n * let A = Matrix.from([[1, 2, 3], [4, 5, 6], [7, 8, 9]]); // a 3 by 3 matrix.\n *\n * A.get_block(1, 1); // [[5, 6], [8, 9]]\n * A.get_block(0, 0, 1, 1); // [[1]]\n * A.get_block(1, 1, 2, 2); // [[5]]\n * A.get_block(0, 0, 2, 2); // [[1, 2], [4, 5]]\n */\n get_block(start_row, start_col, end_row = null, end_col = null) {\n const [rows, cols] = this.shape;\n end_row = end_row ?? rows;\n end_col = end_col ?? cols;\n if (end_row <= start_row || end_col <= start_col) {\n throw new Error(`\n end_row must be greater than start_row, and \n end_col must be greater than start_col, but\n end_row = ${end_row}, start_row = ${start_row}, end_col = ${end_col}, and start_col = ${start_col}!`);\n }\n const X = new Matrix(end_row - start_row, end_col - start_col, \"zeros\");\n for (let row = start_row, new_row = 0; row < end_row; ++row, ++new_row) {\n for (let col = start_col, new_col = 0; col < end_col; ++col, ++new_col) {\n X.set_entry(new_row, new_col, this.entry(row, col));\n }\n }\n return X;\n //return new Matrix(end_row - start_row, end_col - start_col, (i, j) => this.entry(i + start_row, j + start_col));\n }\n\n /**\n * Returns a new array gathering entries defined by the indices given by argument.\n * @param {Array} row_indices - Array consists of indices of rows for gathering entries of this matrix\n * @param {Array} col_indices - Array consists of indices of cols for gathering entries of this matrix\n * @returns {Matrix}\n */\n gather(row_indices, col_indices) {\n const N = row_indices.length;\n const D = col_indices.length;\n\n const R = new Matrix(N, D);\n for (let i = 0; i < N; ++i) {\n const row_index = row_indices[i];\n for (let j = 0; j < N; ++j) {\n const col_index = col_indices[j];\n R.set_entry(i, j, this.entry(row_index, col_index));\n }\n }\n\n return R;\n }\n\n /**\n * Applies a function to each entry of the matrix.\n * @private\n * @param {function} f function takes 2 parameters, the value of the actual entry and a value given by the function {@link v}. The result of {@link f} gets writen to the Matrix.\n * @param {function} v function takes 2 parameters for row and col, and returns a value witch should be applied to the colth entry of the rowth row of the matrix.\n */\n _apply_array(f, v) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], v(row, col));\n }\n }\n return this;\n }\n\n _apply_rowwise_array(values, f) {\n return this._apply_array(f, (_, j) => values[j]);\n }\n\n _apply_colwise_array(values, f) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], values[row]);\n }\n }\n return this;\n }\n\n _apply(value, f) {\n let data = this.values;\n if (value instanceof Matrix) {\n let [value_rows, value_cols] = value.shape;\n let [rows, cols] = this.shape;\n if (value_rows === 1) {\n if (cols !== value_cols) {\n throw new Error(`cols !== value_cols`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(0, col));\n }\n }\n } else if (value_cols === 1) {\n if (rows !== value_rows) {\n throw new Error(`rows !== value_rows`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, 0));\n }\n }\n } else if (rows == value_rows && cols == value_cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, col));\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else if (Array.isArray(value)) {\n let rows = this._rows;\n let cols = this._cols;\n if (value.length === rows) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[row]);\n }\n }\n } else if (value.length === cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[col]);\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else {\n for (let i = 0, n = this._rows * this._cols; i < n; ++i) {\n data[i] = f(data[i], value);\n }\n }\n return this;\n }\n\n /**\n * Clones the Matrix.\n * @returns {Matrix}\n */\n clone() {\n let B = new Matrix();\n B._rows = this._rows;\n B._cols = this._cols;\n B._data = this.values.slice(0);\n return B;\n }\n\n /**\n * Entrywise multiplication with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.mult(2); // [[2, 4], [6, 8]];\n * A.mult(B); // [[1, 4], [9, 16]];\n */\n mult(value) {\n return this.clone()._apply(value, (a, b) => a * b);\n }\n\n /**\n * Entrywise division with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.divide(2); // [[0.5, 1], [1.5, 2]];\n * A.divide(B); // [[1, 1], [1, 1]];\n */\n divide(value) {\n return this.clone()._apply(value, (a, b) => a / b);\n }\n\n /**\n * Entrywise addition with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.add(2); // [[3, 4], [5, 6]];\n * A.add(B); // [[2, 4], [6, 8]];\n */\n add(value) {\n return this.clone()._apply(value, (a, b) => a + b);\n }\n\n /**\n * Entrywise subtraction with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.sub(2); // [[-1, 0], [1, 2]];\n * A.sub(B); // [[0, 0], [0, 0]];\n */\n sub(value) {\n return this.clone()._apply(value, (a, b) => a - b);\n }\n\n /**\n * Returns the number of rows and columns of the Matrix.\n * @returns {Array} An Array in the form [rows, columns].\n */\n get shape() {\n return [this._rows, this._cols];\n }\n\n /**\n * Returns the matrix in the given shape with the given function which returns values for the entries of the matrix.\n * @param {Array} parameter - takes an Array in the form [rows, cols, value], where rows and cols are the number of rows and columns of the matrix, and value is a function which takes two parameters (row and col) which has to return a value for the colth entry of the rowth row.\n * @returns {Matrix}\n */\n set shape([rows, cols, value = () => 0]) {\n this._rows = rows;\n this._cols = cols;\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n\n /**\n * Returns the Matrix as a Array of Float64Arrays.\n * @returns {Array}\n */\n get to2dArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(row);\n }\n return result;\n }\n\n /**\n * Returns the Matrix as a Array of Arrays.\n * @returns {Array}\n */\n get asArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(Array.from(row));\n }\n return result;\n }\n\n /**\n * Returns the diagonal of the Matrix.\n * @returns {Float64Array}\n */\n get diag() {\n const rows = this._rows;\n const cols = this._cols;\n const min_row_col = Math.min(rows, cols);\n let result = new Float64Array(min_row_col);\n for (let i = 0; i < min_row_col; ++i) {\n result[i] = this.entry(i, i);\n }\n return result;\n }\n\n /**\n * Returns the mean of all entries of the Matrix.\n * @returns {Number}\n */\n get mean() {\n const sum = this.sum;\n const n = this._rows * this._cols;\n return sum / n;\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Number}\n */\n get sum() {\n const data = this.values;\n return neumair_sum(data);\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Float64Array}\n */\n get values() {\n const data = this._data;\n return data;\n }\n\n /**\n * Returns the mean of each row of the matrix.\n * @returns {Float64Array}\n */\n get meanRows() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: rows });\n for (let row = 0; row < rows; ++row) {\n result[row] = 0;\n for (let col = 0; col < cols; ++col) {\n result[row] += data[row * cols + col];\n }\n result[row] /= cols;\n }\n return result;\n }\n\n /** Returns the mean of each column of the matrix.\n * @returns {Float64Array}\n */\n get meanCols() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: cols });\n for (let col = 0; col < cols; ++col) {\n result[col] = 0;\n for (let row = 0; row < rows; ++row) {\n result[col] += data[row * cols + col];\n }\n result[col] /= rows;\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b} using the conjugate gradient method. Returns the result x.\n * @param {Matrix} A - Matrix\n * @param {Matrix} b - Matrix\n * @param {Randomizer} [randomizer=null]\n * @param {Number} [tol=1e-3]\n * @returns {Matrix}\n */\n static solve_CG(A, b, randomizer, tol = 1e-3) {\n if (randomizer === null) {\n randomizer = new Randomizer();\n }\n const rows = A.shape[0];\n const cols = b.shape[1];\n let result = new Matrix(rows, 0);\n for (let i = 0; i < cols; ++i) {\n const b_i = Matrix.from(b.col(i)).T;\n let x = new Matrix(rows, 1, () => randomizer.random);\n let r = b_i.sub(A.dot(x));\n let d = r.clone();\n do {\n const z = A.dot(d);\n const alpha = r.T.dot(r).entry(0, 0) / d.T.dot(z).entry(0, 0);\n x = x.add(d.mult(alpha));\n const r_next = r.sub(z.mult(alpha));\n const beta = r_next.T.dot(r_next).entry(0, 0) / r.T.dot(r).entry(0, 0);\n d = r_next.add(d.mult(beta));\n r = r_next;\n } while (Math.abs(r.mean) > tol);\n result = result.concat(x, \"horizontal\");\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b}. Returns the result x.\n * @param {Matrix} A - Matrix or LU Decomposition\n * @param {Matrix} b - Matrix\n * @returns {Matrix}\n */\n static solve(A, b) {\n let { L: L, U: U } = \"L\" in A && \"U\" in A ? A : Matrix.LU(A);\n let rows = L.shape[0];\n let x = b.clone();\n\n // forward\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < row - 1; ++col) {\n x.set_entry(0, row, x.entry(0, row) - L.entry(row, col) * x.entry(1, col));\n }\n x.set_entry(0, row, x.entry(0, row) / L.entry(row, row));\n }\n\n // backward\n for (let row = rows - 1; row >= 0; --row) {\n for (let col = rows - 1; col > row; --col) {\n x.set_entry(0, row, x.entry(0, row) - U.entry(row, col) * x.entry(0, col));\n }\n x.set_entry(0, row, x.entry(0, row) / U.entry(row, row));\n }\n\n return x;\n }\n\n /**\n * {@link L}{@link U} decomposition of the Matrix {@link A}. Creates two matrices, so that the dot product LU equals A.\n * @param {Matrix} A\n * @returns {{L: Matrix, U: Matrix}} result - Returns the left triangle matrix {@link L} and the upper triangle matrix {@link U}.\n */\n static LU(A) {\n const rows = A.shape[0];\n const L = new Matrix(rows, rows, \"zeros\");\n const U = new Matrix(rows, rows, \"identity\");\n\n for (let j = 0; j < rows; ++j) {\n for (let i = j; i < rows; ++i) {\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(i, k) * U.entry(k, j);\n }\n L.set_entry(i, j, A.entry(i, j) - sum);\n }\n for (let i = j; i < rows; ++i) {\n if (L.entry(j, j) === 0) {\n return undefined;\n }\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(j, k) * U.entry(k, i);\n }\n U.set_entry(j, i, (A.entry(j, i) - sum) / L.entry(j, j));\n }\n }\n\n return { L: L, U: U };\n }\n\n /**\n * Computes the determinante of {@link A}, by using the LU decomposition of {@link A}.\n * @param {Matrix} A\n * @returns {Number} det - Returns the determinate of the Matrix {@link A}.\n */\n static det(A) {\n const rows = A.shape[0];\n const { L, U } = Matrix.LU(A);\n const L_diag = L.diag;\n const U_diag = U.diag;\n let det = L_diag[0] * U_diag[0];\n for (let row = 1; row < rows; ++row) {\n det *= L_diag[row] * U_diag[row];\n }\n return det;\n }\n\n /**\n * Computes the {@link k} components of the SVD decomposition of the matrix {@link M}\n * @param {Matrix} M\n * @param {int} [k=2]\n * @returns {{U: Matrix, Sigma: Matrix, V: Matrix}}\n */\n static SVD(M, k = 2) {\n const MT = M.T;\n let MtM = MT.dot(M);\n let MMt = M.dot(MT);\n let { eigenvectors: V, eigenvalues: Sigma } = simultaneous_poweriteration(MtM, k);\n let { eigenvectors: U } = simultaneous_poweriteration(MMt, k);\n return { U: U, Sigma: Sigma.map((sigma) => Math.sqrt(sigma)), V: V };\n\n //Algorithm 1a: Householder reduction to bidiagonal form:\n /* const [m, n] = A.shape;\n let U = new Matrix(m, n, (i, j) => i == j ? 1 : 0);\n console.log(U.to2dArray)\n let V = new Matrix(n, m, (i, j) => i == j ? 1 : 0);\n console.log(V.to2dArray)\n let B = Matrix.bidiagonal(A.clone(), U, V);\n console.log(U,V,B)\n return { U: U, \"Sigma\": B, V: V }; */\n }\n}\n","import { linspace, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @memberof module:utils\n * @alias Randomizer\n */\nexport class Randomizer {\n /**\n * Mersenne Twister random number generator.\n * @constructor\n * @param {Number} [_seed=new Date().getTime()] - The seed for the random number generator. If _seed == null then the actual time gets used as seed.\n * @see https://github.com/bmurray7/mersenne-twister-examples/blob/master/javascript-mersenne-twister.js\n */\n constructor(_seed) {\n this._N = 624;\n this._M = 397;\n this._MATRIX_A = 0x9908b0df;\n this._UPPER_MASK = 0x80000000;\n this._LOWER_MASK = 0x7fffffff;\n this._mt = new Array(this._N);\n this._mti = this.N + 1;\n\n this.seed = _seed || new Date().getTime();\n return this;\n }\n\n set seed(_seed) {\n this._seed = _seed;\n let mt = this._mt;\n\n mt[0] = _seed >>> 0;\n for (this._mti = 1; this._mti < this._N; this._mti += 1) {\n let mti = this._mti;\n let s = mt[mti - 1] ^ (mt[mti - 1] >>> 30);\n mt[mti] = ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253 + mti;\n mt[mti] >>>= 0;\n }\n }\n\n /**\n * Returns the seed of the random number generator.\n * @returns {Number} - The seed.\n */\n get seed() {\n return this._seed;\n }\n\n /**\n * Returns a float between 0 and 1.\n * @returns {Number} - A random number between [0, 1]\n */\n get random() {\n return this.random_int * (1.0 / 4294967296.0);\n }\n\n /**\n * Returns an integer between 0 and MAX_INTEGER.\n * @returns {Integer} - A random integer.\n */\n get random_int() {\n let y,\n mag01 = new Array(0x0, this._MATRIX_A);\n if (this._mti >= this._N) {\n let kk;\n\n /* if (this._mti == this._N + 1) {\n this.seed = 5489;\n } */\n\n let N_M = this._N - this._M;\n let M_N = this._M - this._N;\n\n for (kk = 0; kk < N_M; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + this._M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (; kk < this._N - 1; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + M_N] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n\n y = (this._mt[this._N - 1] & this._UPPER_MASK) | (this._mt[0] & this._LOWER_MASK);\n this._mt[this._N - 1] = this._mt[this._M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this._mti = 0;\n }\n\n y = this._mt[(this._mti += 1)];\n y ^= y >>> 11;\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= y >>> 18;\n\n return y >>> 0;\n }\n\n /**\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n choice(A, n) {\n if (A instanceof Matrix) {\n let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A.row(d));\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let rows = A.length;\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A[d]);\n }\n }\n\n /**\n * @static\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @param {Number} seed - The seed for the random number generator.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n static choice(A, n, seed = 1212) {\n const R = new Randomizer(seed);\n return R.choice(A, n);\n /* let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let rand = new Randomizer(seed);\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = rand.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n //return result;\n //return new Matrix(n, cols, (row, col) => A.entry(sample[row], col))\n return sample.map((d) => A.row(d)); */\n }\n}\n","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias max\n * @param {Array} values \n * @returns {Number}\n */\nexport default function (values) {\n let max;\n for (const value of values) {\n if (value != null && (max < value || (max === undefined && value >= value))) {\n max = value;\n }\n }\n return max;\n}","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias min\n * @param {Array} values\n * @returns {Number}\n */\nexport default function (values) {\n let min;\n for (const value of values) {\n if (value != null && (min > value || (min === undefined && value <= value))) {\n min = value;\n }\n }\n return min;\n}","/**\n * @class\n * @alias Heap\n */\nexport class Heap {\n /**\n * A heap is a datastructure holding its elements in a specific way, so that the top element would be the first entry of an ordered list.\n * @constructor\n * @memberof module:datastructure\n * @alias Heap\n * @param {Array=} elements - Contains the elements for the Heap. {@link elements} can be null.\n * @param {Function} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(\"min\"|\"max\"|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n * @see {@link https://en.wikipedia.org/wiki/Binary_heap}\n */\n constructor(elements = null, accessor = d => d, comparator = \"min\") {\n if (elements) {\n return Heap.heapify(elements, accessor, comparator);\n } else {\n this._accessor = accessor;\n this._container = [];\n if (comparator == \"min\") {\n this._comparator = (a, b) => a < b;\n } else if (comparator == \"max\") {\n this._comparator = (a, b) => a > b;\n } else {\n this._comparator = comparator;\n }\n return this\n }\n }\n\n /**\n * Creates a Heap from an Array\n * @param {Array|Set} elements - Contains the elements for the Heap.\n * @param {Function=} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(String=|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n */\n static heapify(elements, accessor = d => d, comparator = \"min\") {\n const heap = new Heap(null, accessor, comparator);\n const container = heap._container;\n for (const e of elements) {\n container.push({\n \"element\": e,\n \"value\": accessor(e),\n });\n }\n for (let i = Math.floor((elements.length / 2) - 1); i >= 0; --i) {\n heap._heapify_down(i);\n }\n return heap;\n }\n\n /**\n * Swaps elements of container array.\n * @private\n * @param {Number} index_a \n * @param {Number} index_b \n */\n _swap(index_a, index_b) {\n const container = this._container;\n [container[index_b], container[index_a]] = [container[index_a], container[index_b]];\n return;\n }\n\n /**\n * @private\n */\n _heapify_up() {\n const container = this._container;\n let index = container.length - 1;\n while (index > 0) {\n let parentIndex = Math.floor((index - 1) / 2);\n if (!this._comparator(container[index].value, container[parentIndex].value)) {\n break;\n } else {\n this._swap(parentIndex, index)\n index = parentIndex;\n }\n }\n }\n\n /**\n * Pushes the element to the heap.\n * @param {} element\n * @returns {Heap}\n */\n push(element) {\n const value = this._accessor(element);\n //const node = new Node(element, value);\n const node = {\"element\": element, \"value\": value};\n this._container.push(node);\n this._heapify_up();\n return this;\n }\n\n /**\n * @private\n * @param {Number} [start_index = 0] \n */\n _heapify_down(start_index=0) {\n const container = this._container;\n const comparator = this._comparator;\n const length = container.length;\n let left = 2 * start_index + 1;\n let right = 2 * start_index + 2;\n let index = start_index;\n if (index > length) throw \"index higher than length\"\n if (left < length && comparator(container[left].value, container[index].value)) {\n index = left;\n }\n if (right < length && comparator(container[right].value, container[index].value)) {\n index = right;\n }\n if (index !== start_index) {\n this._swap(start_index, index);\n this._heapify_down(index);\n }\n }\n\n /**\n * Removes and returns the top entry of the heap.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n pop() {\n const container = this._container;\n if (container.length === 0) {\n return null;\n } else if (container.length === 1) {\n return container.pop();\n }\n this._swap(0, container.length - 1);\n const item = container.pop();\n this._heapify_down();\n return item;\n }\n\n /**\n * Returns the top entry of the heap without removing it.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n get first() {\n return this._container.length > 0 ? this._container[0] : null;\n }\n\n\n /**\n * Yields the raw data\n * @yields {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n * iterate() {\n for (let i = 0, n = this._container.length; i < n; ++i) {\n yield this._container[i].element;\n }\n }\n\n /**\n * Returns the heap as ordered array.\n * @returns {Array} Array consisting the elements ordered by {@link comparator}.\n */\n toArray() {\n return this.data()\n .sort((a,b) => this._comparator(a, b) ? -1 : 0)\n }\n\n /**\n * Returns elements of container array.\n * @returns {Array} Array consisting the elements.\n */\n data() {\n return this._container\n .map(d => d.element)\n }\n\n /**\n * Returns the container array.\n * @returns {Array} The container array.\n */\n raw_data() {\n return this._container;\n }\n\n /**\n * The size of the heap.\n * @returns {Number}\n */\n get length() {\n return this._container.length;\n }\n\n /**\n * Returns false if the the heap has entries, true if the heap has no entries.\n * @returns {Boolean}\n */\n get empty() {\n return this.length === 0;\n }\n}","/**\n * @class\n * @alias DisjointSet\n * @see {@link https://en.wikipedia.org/wiki/Disjoint-set_data_structure}\n */\nexport class DisjointSet {\n /**\n * @constructor\n * @alias DisjointSet\n * @memberof module:datastructure\n * @param {Array=} elements \n * @returns {DisjointSet}\n */\n constructor(elements = null) {\n this._list = new Set();\n if (elements) {\n for (const e of elements) {\n this.make_set(e);\n }\n }\n return this;\n }\n\n make_set(x) {\n const list = this._list;\n if (!list.has(x)) {\n list.add(x);\n x.__disjoint_set = {};\n x.__disjoint_set.parent = x;\n x.__disjoint_set.children = new Set([x]);\n x.__disjoint_set.size = 1;\n }\n return this;\n }\n\n find(x) {\n const list = this._list;\n if (list.has(x)) {\n if (x.__disjoint_set.parent !== x) {\n x.__disjoint_set.children.add(...x);\n x.__disjoint_set.parent = this.find(x.__disjoint_set.parent);\n return x.__disjoint_set.parent;\n } else {\n return x;\n }\n } else {\n return null;\n }\n }\n\n union(x, y) {\n let node_x = this.find(x);\n let node_y = this.find(y);\n\n if (node_x === node_y) return this;\n if (node_x.__disjoint_set.size < node_y.__disjoint_set.size) [node_x, node_y] = [node_y, node_x];\n\n node_y.__disjoint_set.parent = node_x;\n // keep track of children?\n node_y.__disjoint_set.children.forEach(node_x.__disjoint_set.children.add, node_x.__disjoint_set.children);\n node_x.__disjoint_set.size += node_y.__disjoint_set.size;\n\n return this;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n/**\n * @class\n * @alias BallTree\n */\nexport class BallTree {\n /**\n * Generates a BallTree with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias BallTree\n * @param {Array=} elements - Elements which should be added to the BallTree\n * @param {Function} [metric = euclidean] metric to use: (a, b) => distance\n * @see {@link https://en.wikipedia.org/wiki/Ball_tree}\n * @see {@link https://github.com/invisal/noobjs/blob/master/src/tree/BallTree.js}\n * @returns {BallTree}\n */\n constructor(elements = null, metric = euclidean) {\n this._Node = class {\n constructor(pivot, child1=null, child2=null, radius=null) {\n this.pivot = pivot;\n this.child1 = child1;\n this.child2 = child2;\n this.radius = radius;\n }\n }\n this._Leaf = class {\n constructor(points) {\n this.points = points;\n }\n }\n this._metric = metric;\n if (elements) {\n this.add(elements);\n }\n return this;\n }\n\n /**\n * \n * @param {Array<*>} elements - new elements.\n * @returns {BallTree}\n */\n add(elements) {\n elements = elements.map((element, index) => {\n return {index: index, element: element}\n })\n this._root = this._construct(elements);\n return this;\n }\n\n /**\n * @private\n * @param {Array<*>} elements \n * @returns {Node} root of balltree.\n */\n _construct(elements) {\n if (elements.length === 1) {\n return new this._Leaf(elements);\n } else {\n let c = this._greatest_spread(elements);\n let sorted_elements = elements.sort((a, b) => a.element[c] - b.element[c]);\n let n = sorted_elements.length;\n let p_index = Math.floor(n / 2);\n let p = elements[p_index];\n let L = sorted_elements.slice(0, p_index);\n let R = sorted_elements.slice(p_index, n);\n let radius = Math.max(...elements.map(d => this._metric(p.element, d.element)));\n let B\n if (L.length > 0 && R.length > 0) { \n B = new this._Node(p, this._construct(L), this._construct(R), radius);\n } else {\n B = new this._Leaf(elements);\n }\n return B;\n }\n }\n\n /**\n * @private\n * @param {Node} B \n * @returns {Number}\n */\n _greatest_spread(B) {\n let d = B[0].element.length;\n let start = new Array(d);\n\n for (let i = 0; i < d; ++i) {\n start[i] = [Infinity, -Infinity];\n }\n\n let spread = B.reduce((acc, current) => {\n for (let i = 0; i < d; ++i) {\n acc[i][0] = Math.min(acc[i][0], current.element[i]);\n acc[i][1] = Math.max(acc[i][1], current.element[i]);\n }\n return acc;\n }, start);\n spread = spread.map(d => d[1] - d[0]);\n \n let c = 0;\n for (let i = 0; i < d; ++i) {\n c = spread[i] > spread[c] ? i : c;\n }\n return c;\n }\n\n /**\n * \n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n return this._search(t, k, new Heap(null, d => this._metric(d.element, t), \"max\"), this._root);\n }\n\n /**\n * @private\n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @param {Heap} Q - Heap consists of the currently found {@link k} nearest neighbors.\n * @param {Node|Leaf} B \n */\n _search(t, k, Q, B) {\n // B is Node\n if (Q.length >= k && B.pivot && B.radius && this._metric(t, B.pivot.element) - B.radius >= Q.first.value) {\n return Q;\n } \n if (B.child1) this._search(t, k, Q, B.child1);\n if (B.child2) this._search(t, k, Q, B.child2);\n \n // B is leaf\n if (B.points) {\n for (let i = 0, n = B.points.length; i < n; ++i) {\n let p = B.points[i];\n if (k > Q.length) {\n Q.push(p);\n } else {\n Q.push(p);\n Q.pop();\n }\n }\n }\n return Q;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KNN\n */\nexport class KNN {\n /**\n * Generates a KNN list with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias KNN\n * @param {Array=} elements - Elements which should be added to the KNN list\n * @param {Function|\"precomputed\"} [metric = euclidean] metric is either precomputed or a function to use: (a, b) => distance\n * @returns {KNN}\n */\n constructor(elements=null, metric=euclidean) {\n this._metric = metric;\n this._elements = elements instanceof Matrix ? elements : Matrix.from(elements);\n const N = this._elements.shape[0];\n if (metric === \"precomputed\") {\n this._D = this._elements.clone();\n } else {\n this._D = distance_matrix(this._elements, metric);\n }\n this.KNN = [];\n for (let row = 0; row < N; ++row) {\n const distances = this._D.row(row);\n const H = new Heap(null, d => d.value, \"min\");\n for (let j = 0; j < N; ++j) {\n H.push({\n value: distances[j],\n index: j,\n });\n }\n this.KNN.push(H);\n }\n }\n\n /**\n * \n * @param {Array|Number} t - query element or index.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n const metric = this._metric;\n const KNN = this.KNN;\n let H;\n if (Array.isArray(t)) {\n if (this._metric == \"precomputed\") {\n throw \"Search by query element is only possible when not using a precomputed distance matrix!\"\n } \n const elements = this._elements;\n const N = KNN.length;\n let nearest_element_index = null;\n let nearest_dist = Infinity;\n for (let i = 0; i < N; ++i) {\n const element = elements.row(i);\n const dist = metric(t, element);\n if (dist < nearest_dist) {\n nearest_element_index = i;\n nearest_dist = dist;\n }\n }\n H = KNN[nearest_element_index];\n } else if (Number.isInteger(t)) {\n H = KNN[t]\n }\n\n let result = []\n for (let i = 0; i < k; ++i) {\n result.push(H.pop())\n }\n result.forEach(res => H.push(res.element))\n return result\n } \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n\n/**\n * @class\n * @alias DR\n * @borrows DR#parameter as DR#para\n * @borrows DR#parameter as DR#p\n */\nexport class DR {\n /**\n * Takes the default parameters and seals them, remembers the type of input {@link X}, and initializes the random number generator.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias DR\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed value for the random number generator.\n * @returns {DR}\n */\n constructor(X, default_parameters, parameters) {\n this._parameters = Object.assign(Object.seal(default_parameters), parameters);\n if (Array.isArray(X)) {\n this._type = \"array\";\n this.X = Matrix.from(X);\n } else if (X instanceof Matrix) {\n this._type = \"matrix\";\n this.X = X;\n } else {\n throw new Error(\"No valid type for X!\");\n }\n [this._N, this._D] = this.X.shape;\n this._randomizer = new Randomizer(this._parameters.seed);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * Set and get parameters\n * @param {String} name - name of the parameter.\n * @param {any} [value = null] - value of the parameter to set.\n * @returns {DR|any} - On setting a parameter, this function returns the DR object. If value == null then return actual parameter value.\n * @example\n * const DR = new druid.TSNE(X, {d: 3}); // creates a new DR object, with parameter for d = 3.\n * DR.parameter(\"d\"); // returns 3,\n * DR.parameter(\"d\", 2); // sets parameter d to 2 and returns DR.\n */\n parameter(name, value = null) {\n if (!this._parameters.hasOwnProperty(name)) {\n throw new Error(`${name} is not a valid parameter!`);\n }\n if (value) {\n this._parameters[name] = value;\n this._is_initialized = false;\n return this;\n } else {\n return this._parameters[name];\n }\n }\n\n para(name, value = null) {\n return this.parameter(name, value);\n }\n\n p(name, value = null) {\n return this.parameter(name, value);\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} - Returns the projection.\n */\n transform() {\n this.check_init();\n return this.projection;\n }\n\n /**\n * Computes the projection.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n *generator() {\n return this.transform();\n }\n\n /**\n * If the respective DR method has an init function, call it before transform.\n * @returns {DR}\n */\n check_init() {\n if (!this._is_initialized && typeof this.init === \"function\") {\n this.init();\n this._is_initialized = true;\n }\n return this;\n }\n\n /**\n * @returns {Matrix|Array} Returns the projection.\n */\n get projection() {\n if (this.hasOwnProperty(\"Y\")) {\n this.check_init();\n return this._type === \"matrix\" ? this.Y : this.Y.to2dArray;\n } else {\n throw new Error(\"The dataset is not transformed yet!\");\n }\n }\n\n /**\n *\n * @param {...any} args - Arguments the transform method of the respective DR method takes.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Matrix|Array} - The dimensionality reduced dataset.\n */\n static transform(...args) {\n let dr = new this(...args);\n return dr.transform();\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n static async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n static *generator(...args) {\n const dr = new this(...args);\n const generator = dr.generator();\n for (const result of generator) {\n yield result;\n }\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias PCA\n * @augments DR\n */\nexport class PCA extends DR {\n /**\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias PCA\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @returns {PCA}\n */\n constructor(X, parameters) {\n super(X, { d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}. If parameter {@link A} is given, then project {@link A} with the principal components of {@link X}.\n * @param {null|Matrix|Array} [A = null] - If given, the data to project.\n * @returns {Matrix|Array} - The projected data.\n */\n transform(A = null) {\n const V = this.principal_components();\n if (A == null) {\n const X = this.X;\n this.Y = X.dot(V);\n return this.projection;\n } else if (Array.isArray(A)) {\n return Matrix.from(A).dot(V).asArray;\n } else if (A instanceof Matrix) {\n return A.dot(V);\n } else {\n throw new Error(\"No valid type for A!\");\n }\n }\n\n /**\n * Computes the {@link d} principal components of Matrix {@link X}.\n * @returns {Matrix}\n */\n principal_components() {\n if (this.V) {\n return this.V;\n }\n const { d, eig_args } = this._parameters;\n const X = this.X;\n const means = Matrix.from(X.meanCols);\n const X_cent = X.sub(means);\n const C = X_cent.transpose().dot(X_cent);\n const { eigenvectors: V } = simultaneous_poweriteration(C, d, eig_args);\n this.V = Matrix.from(V).transpose();\n return this.V;\n }\n\n static principal_components(X, parameters) {\n const dr = new this(X, parameters);\n return dr.principal_components();\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias MDS\n * @extends DR\n */\nexport class MDS extends DR {\n /**\n * Classical MDS.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias MDS\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}.\n * @returns {Matrix|Array}\n */\n transform() {\n const X = this.X;\n const rows = X.shape[0];\n const { d, metric, eig_args } = this._parameters;\n const A = metric === \"precomputed\" ? X : distance_matrix(X, metric);\n const ai_ = A.meanCols;\n const a_j = A.meanRows;\n const a__ = A.mean;\n\n this._d_X = A;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n\n return this.projection;\n }\n\n /**\n * @returns {Number} - the stress of the projection.\n */\n stress() {\n const N = this.X.shape[0];\n const Y = this.Y;\n const d_X = this._d_X;\n const d_Y = new Matrix();\n d_Y.shape = [\n N,\n N,\n (i, j) => {\n return i < j ? euclidean(Y.row(i), Y.row(j)) : d_Y.entry(j, i);\n },\n ];\n let top_sum = 0;\n let bottom_sum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n top_sum += Math.pow(d_X.entry(i, j) - d_Y.entry(i, j), 2);\n bottom_sum += Math.pow(d_X.entry(i, j), 2);\n }\n }\n return Math.sqrt(top_sum / bottom_sum);\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { DR } from \"./DR.js\";\nimport euclidean from \"../metrics/euclidean.js\";\n\n/**\n * @class\n * @alias ISOMAP\n * @extends DR\n */\nexport class ISOMAP extends DR {\n /**\n * Isometric feature mapping (ISOMAP).\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias ISOMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link ISOMAP} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2319}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(this._parameters.neighbors ?? Math.max(Math.floor(this.X.shape[0] / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const X = this.X;\n const rows = this._N;\n const { d, metric, eig_args, neighbors } = this._parameters;\n // TODO: make knn extern and parameter for constructor or transform?\n const D = new Matrix();\n D.shape = [rows, rows, (i, j) => (i <= j ? metric(X.row(i), X.row(j)) : D.entry(j, i))];\n const kNearestNeighbors = [];\n for (let i = 0; i < rows; ++i) {\n const row = [];\n for (let j = 0; j < rows; ++j) {\n row.push({\n index: j,\n distance: D.entry(i, j),\n });\n }\n const H = new Heap(row, (d) => d.distance, \"min\");\n kNearestNeighbors.push(H.toArray().slice(1, neighbors + 1));\n }\n\n /*D = dijkstra(kNearestNeighbors);*/\n // compute shortest paths\n // TODO: make extern\n /** @see {@link https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm} */\n const G = new Matrix(rows, rows, (i, j) => {\n const other = kNearestNeighbors[i].find((n) => n.index === j);\n return other ? other.distance : Infinity;\n });\n\n for (let i = 0; i < rows; ++i) {\n for (let j = 0; j < rows; ++j) {\n for (let k = 0; k < rows; ++k) {\n G.set_entry(i, j, Math.min(G.entry(i, j), G.entry(i, k) + G.entry(k, j)));\n }\n }\n }\n\n let ai_ = new Float64Array(rows);\n let a_j = new Float64Array(rows);\n let a__ = 0;\n const A = new Matrix(rows, rows, (i, j) => {\n let val = G.entry(i, j);\n val = val === Infinity ? 0 : val;\n ai_[i] += val;\n a_j[j] += val;\n a__ += val;\n return val;\n });\n\n ai_ = ai_.map((v) => v / rows);\n a_j = a_j.map((v) => v / rows);\n a__ /= rows ** 2;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n // compute d eigenvectors\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n/**\n * @class\n * @alias FASTMAP\n * @extends DR\n */\nexport class FASTMAP extends DR {\n /**\n * FastMap: a fast algorithm for indexing, data-mining and visualization of traditional and multimedia datasets\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias FASTMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the dimensionality of the projection.\n * @returns {FASTMAP}\n * @see {@link https://doi.org/10.1145/223784.223812}\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n * Chooses two points which are the most distant in the actual projection.\n * @private\n * @param {Function} dist\n * @returns {Array} An array consisting of first index, second index, and distance between the two points.\n */\n _choose_distant_objects(dist) {\n const X = this.X;\n const N = X.shape[0];\n let a_index = (this._randomizer.random_int % N) - 1;\n let b_index = null;\n let max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n if (d_ai > max_dist) {\n max_dist = d_ai;\n b_index = i;\n }\n }\n max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_bi = dist(b_index, i);\n if (d_bi > max_dist) {\n max_dist = d_bi;\n a_index = i;\n }\n }\n return [a_index, b_index, max_dist];\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} The {@link d}-dimensional projection of the data matrix {@link X}.\n */\n transform() {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric } = this._parameters;\n const Y = new Matrix(N, d, 0);\n let dist = (a, b) => metric(X.row(a), X.row(b));\n\n for (let _col = 0; _col < d; ++_col) {\n let old_dist = dist;\n // choose pivot objects\n const [a_index, b_index, d_ab] = this._choose_distant_objects(dist);\n if (d_ab !== 0) {\n // project the objects on the line (O_a, O_b)\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n const d_bi = dist(b_index, i);\n const y_i = (d_ai ** 2 + d_ab ** 2 - d_bi ** 2) / (2 * d_ab);\n Y.set_entry(i, _col, y_i);\n }\n // consider the projections of the objects on a\n // hyperplane perpendicluar to the line (a, b);\n // the distance function D'() between two\n // projections is given by Eq.4\n dist = (a, b) => Math.sqrt(old_dist(a, b) ** 2 - (Y.entry(a, _col) - Y.entry(b, _col)) ** 2);\n }\n }\n // return embedding.\n this.Y = Y;\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LDA\n * @extends DR\n */\nexport class LDA extends DR {\n /**\n * Linear Discriminant Analysis.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LDA\n * @param {Matrix} X - The high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Array} parameters.labels - The labels / classes for each data point.\n * @param {number} [parameters.d = 2] - The dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://onlinelibrary.wiley.com/doi/10.1111/j.1469-1809.1936.tb02137.x}\n */\n constructor(X, parameters) {\n super(X, { labels: null, d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, cols] = X.shape;\n const { d, labels, eig_args } = this._parameters;\n if (labels === null || labels.length != rows) {\n throw new Error(\"LDA needs parameter label to every datapoint to work!\");\n }\n const unique_labels = {};\n let label_id = 0;\n labels.forEach((l, i) => {\n if (l in unique_labels) {\n unique_labels[l].count++;\n unique_labels[l].rows.push(X.row(i));\n } else {\n unique_labels[l] = {\n id: label_id++,\n count: 1,\n rows: [X.row(i)],\n };\n }\n });\n\n // create X_mean and vector means;\n const X_mean = X.mean;\n const V_mean = new Matrix(label_id, cols);\n for (const label in unique_labels) {\n const V = Matrix.from(unique_labels[label].rows);\n const v_mean = V.meanCols;\n for (let j = 0; j < cols; ++j) {\n V_mean.set_entry(unique_labels[label].id, j, v_mean[j]);\n }\n }\n // scatter_between\n let S_b = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j] - X_mean);\n const N = unique_labels[label].count;\n S_b = S_b.add(m.dot(m.transpose()).mult(N));\n }\n\n // scatter_within\n let S_w = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j]);\n const R = unique_labels[label].rows;\n for (let i = 0, n = unique_labels[label].count; i < n; ++i) {\n const row_v = new Matrix(cols, 1, (j, _) => R[i][j] - m.entry(j, 0));\n S_w = S_w.add(row_v.dot(row_v.transpose()));\n }\n }\n\n let { eigenvectors: V } = simultaneous_poweriteration(S_w.inverse().dot(S_b), d, eig_args);\n V = Matrix.from(V).transpose();\n this.Y = X.dot(V);\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { k_nearest_neighbors } from \"../matrix/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LLE\n * @extends DR\n */\nexport class LLE extends DR {\n /**\n * Locally Linear Embedding.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LLE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} neighbors - the label / class of each data point.\n * @param {Number} [d = 2] - the dimensionality of the projection.\n * @param {Function} [metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [seed = 1212] - the dimensionality of the projection.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2323}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const rows = this._N;\n const cols = this._D;\n const { neighbors, d, eig_args, metric } = this._parameters;\n const nN = k_nearest_neighbors(X, neighbors, metric);\n const O = new Matrix(neighbors, 1, 1);\n const W = new Matrix(rows, rows);\n\n for (let row = 0; row < rows; ++row) {\n const nN_row = nN[row];\n const Z = new Matrix(neighbors, cols, (i, j) => X.entry(nN_row[i].j, j) - X.entry(row, j));\n const C = Z.dot(Z.T);\n if (neighbors > cols) {\n const C_trace = neumair_sum(C.diag) / 1000;\n for (let j = 0; j < neighbors; ++j) {\n C.set_entry(j, j, C.entry(j, j) + C_trace);\n }\n }\n // reconstruct;\n let w = Matrix.solve_CG(C, O, this._randomizer);\n w = w.divide(w.sum);\n for (let j = 0; j < neighbors; ++j) {\n W.set_entry(row, nN_row[j].j, w.entry(j, 0));\n }\n }\n // comp embedding\n const I = new Matrix(rows, rows, \"identity\");\n const IW = I.sub(W);\n const M = IW.T.dot(IW);\n const { eigenvectors: V } = simultaneous_poweriteration(M.T.inverse(), d + 1, eig_args);\n this.Y = Matrix.from(V.slice(1, 1 + d)).T;\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix, k_nearest_neighbors } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LTSA\n * @extends DR\n */\nexport class LTSA extends DR {\n /**\n * Local Tangent Space Alignment\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LTSA\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link LTSA} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://epubs.siam.org/doi/abs/10.1137/S1064827502419154}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n if (this._D <= this.parameter(\"d\")) {\n throw new Error(`Dimensionality of X (D = ${this._D}) must be greater than the required dimensionality of the result (d = ${this.parameter(\"d\")})!`);\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, D] = X.shape;\n const { d, neighbors, metric, eig_args } = this._parameters;\n // 1.1 determine k nearest neighbors\n const nN = k_nearest_neighbors(X, neighbors, metric);\n // center matrix\n const O = new Matrix(D, D, \"center\");\n const B = new Matrix(rows, rows, 0);\n\n for (let row = 0; row < rows; ++row) {\n // 1.2 compute the d largest eigenvectors of the correlation matrix\n const I_i = [row, ...nN[row].map((n) => n.j)];\n let X_i = Matrix.from(I_i.map((n) => X.row(n)));\n // center X_i\n X_i = X_i.dot(O);\n // correlation matrix\n const C = X_i.dot(X_i.transpose());\n const { eigenvectors: g } = simultaneous_poweriteration(C, d, eig_args);\n //g.push(linspace(0, k).map(_ => 1 / Math.sqrt(k + 1)));\n const G_i_t = Matrix.from(g);\n // 2. Constructing alignment matrix\n const W_i = G_i_t.transpose()\n .dot(G_i_t)\n .add(1 / Math.sqrt(neighbors + 1));\n for (let i = 0; i < neighbors + 1; ++i) {\n for (let j = 0; j < neighbors + 1; ++j) {\n B.set_entry(I_i[i], I_i[j], B.entry(I_i[i], I_i[j]) - (i === j ? 1 : 0) + W_i.entry(i, j));\n }\n }\n }\n\n // 3. Aligning global coordinates\n const { eigenvectors: Y } = simultaneous_poweriteration(B, d + 1, eig_args);\n this.Y = Matrix.from(Y.slice(1)).transpose();\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TSNE\n * @extends DR\n */\nexport class TSNE extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TSNE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.perplexity = 50] - perplexity.\n * @param {Number} [parameters.epsilon = 10] - learning parameter.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TSNE}\n */\n constructor(X, parameters) {\n super(X, { perplexity: 50, epsilon: 10, d: 2, metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._iter = 0;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => this._randomizer.random);\n return this;\n }\n\n /**\n *\n * @param {Matrix} distance_matrix - accepts a precomputed distance matrix\n * @returns {TSNE}\n */\n init() {\n // init\n const Htarget = Math.log(this.parameter(\"perplexity\"));\n const N = this._N;\n const D = this._D;\n const {metric} = this._parameters;\n const X = this.X;\n let Delta;\n if (metric ==\"precomputed\") {\n Delta = druid.Matrix.from(X);\n } else {\n Delta = new Matrix(N, N);\n for (let i = 0; i < N; ++i) {\n const X_i = X.row(i);\n for (let j = i + 1; j < N; ++j) {\n const distance = metric(X_i, X.row(j));\n Delta.set_entry(i, j, distance);\n Delta.set_entry(j, i, distance);\n }\n }\n }\n\n const P = new Matrix(N, N, \"zeros\");\n\n this._ystep = new Matrix(N, D, \"zeros\");\n this._gains = new Matrix(N, D, 1);\n\n // search for fitting sigma\n let prow = new Float64Array(N)\n const tol = 1e-4;\n const maxtries = 50;\n for (let i = 0; i < N; ++i) {\n let betamin = -Infinity;\n let betamax = Infinity;\n let beta = 1;\n let done = false;\n\n let num = 0;\n while (!done) {\n let psum = 0;\n for (let j = 0; j < N; ++j) {\n let pj = Math.exp(-Delta.entry(i, j) * beta);\n if (i === j) pj = 0;\n prow[j] = pj;\n psum += pj;\n }\n let Hhere = 0;\n for (let j = 0; j < N; ++j) {\n let pj = psum === 0 ? 0 : prow[j] / psum;\n prow[j] = pj;\n if (pj > 1e-7) {\n Hhere -= pj * Math.log(pj);\n }\n }\n if (Hhere > Htarget) {\n betamin = beta;\n beta = betamax === Infinity ? beta * 2 : (beta + betamax) / 2;\n } else {\n betamax = beta;\n beta = betamin === -Infinity ? beta / 2 : (beta + betamin) / 2;\n }\n ++num;\n if (Math.abs(Hhere - Htarget) < tol) done = true;\n if (num >= maxtries) done = true;\n }\n\n for (let j = 0; j < N; ++j) {\n P.set_entry(i, j, prow[j]);\n }\n }\n\n //compute probabilities\n const Pout = new Matrix(N, N, \"zeros\");\n const N2 = N * 2;\n for (let i = 0; i < N; ++i) {\n for (let j = i; j < N; ++j) {\n const p = Math.max((P.entry(i, j) + P.entry(j, i)) / N2, 1e-100);\n Pout.set_entry(i, j, p);\n Pout.set_entry(j, i, p);\n }\n }\n this._P = Pout;\n return this;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n transform(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n *generator(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * performs a optimization step\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const P = this._P;\n const ystep = this._ystep;\n const gains = this._gains;\n const N = this._N;\n const { d: dim, epsilon} = this._parameters;\n let Y = this.Y;\n\n //calc cost gradient;\n const pmul = iter < 100 ? 4 : 1;\n\n // compute Q dist (unnormalized)\n const Qu = new Matrix(N, N, \"zeros\");\n let qsum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dsum = 0;\n for (let d = 0; d < dim; ++d) {\n const dhere = Y.entry(i, d) - Y.entry(j, d);\n dsum += dhere * dhere;\n }\n const qu = 1 / (1 + dsum);\n Qu.set_entry(i, j, qu);\n Qu.set_entry(j, i, qu);\n qsum += 2 * qu;\n }\n }\n\n // normalize Q dist\n const Q = new Matrix(N, N, 0);\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n const val = Math.max(Qu.entry(i, j) / qsum, 1e-100);\n Q.set_entry(i, j, val);\n Q.set_entry(j, i, val);\n }\n }\n\n const grad = new Matrix(N, dim, \"zeros\");\n for (let i = 0; i < N; ++i) {\n for (let j = 0; j < N; ++j) {\n const premult = 4 * (pmul * P.entry(i, j) - Q.entry(i, j)) * Qu.entry(i, j);\n for (let d = 0; d < dim; ++d) {\n grad.set_entry(i, d, grad.entry(i, d) + premult * (Y.entry(i, d) - Y.entry(j, d)));\n }\n }\n }\n\n // perform gradient step\n let ymean = new Float64Array(dim);\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const gid = grad.entry(i, d);\n const sid = ystep.entry(i, d);\n const gainid = gains.entry(i, d);\n\n let newgain = Math.sign(gid) === Math.sign(sid) ? gainid * 0.8 : gainid + 0.2;\n if (newgain < 0.01) newgain = 0.01;\n gains.set_entry(i, d, newgain);\n\n const momval = iter < 250 ? 0.5 : 0.8;\n const newsid = momval * sid - epsilon * newgain * gid;\n ystep.set_entry(i, d, newsid);\n\n Y.set_entry(i, d, Y.entry(i, d) + newsid);\n ymean[d] += Y.entry(i, d);\n }\n }\n\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < 2; ++d) {\n Y.set_entry(i, d, Y.entry(i, d) - ymean[d] / N);\n }\n }\n\n return this.Y;\n }\n}\n","/**\n *\n * @memberof module:optimization\n * @alias powell\n * @param {Function} f\n * @param {Array} x0\n * @param {Number} [max_iter = 300]\n * @returns {Array}\n * @see http://optimization-js.github.io/optimization-js/optimization.js.html#line438\n */\nexport default function (f, x0, max_iter = 300) {\n const epsilon = 1e-2;\n const n = x0.length;\n let alpha = 1e-3;\n let pfx = 10000;\n let x = x0.slice();\n let fx = f(x);\n let convergence = false;\n\n while (max_iter-- >= 0 && !convergence) {\n convergence = true;\n for (let i = 0; i < n; ++i) {\n x[i] += 1e-6;\n let fxi = f(x);\n x[i] -= 1e-6;\n let dx = (fxi - fx) / 1e-6;\n if (Math.abs(dx) > epsilon) {\n convergence = false;\n }\n x[i] -= alpha * dx;\n fx = f(x);\n }\n alpha *= pfx >= fx ? 1.05 : 0.4;\n pfx = fx;\n }\n return x;\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean, euclidean_squared } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { linspace } from \"../matrix/index.js\";\nimport { powell } from \"../optimization/index.js\";\nimport { DR } from \"./DR.js\";\nimport { max } from \"../util/index.js\";\nimport { KNN } from \"../knn/index.js\";\n\n/**\n * @class\n * @alias UMAP\n * @extends DR\n */\nexport class UMAP extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias UMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.n_neighbors = 15] - size of the local neighborhood.\n * @param {Number} [parameters.local_connectivity = 1] - number of nearest neighbors connected in the local neighborhood.\n * @param {Number} [parameters.min_dist = 1] - controls how tightly points get packed together.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points in the high-dimensional space.\n * @param {Number} [parameters._spread = 1] - The effective scale of embedded points. (In combination with {@link parameters.min_dist})\n * @param {Number} [parameters._set_op_mix_ratio = 1] - Interpolate between union and intersection.\n * @param {Number} [parameters._repulsion_strength = 1] - Weighting applied to negative samples.\n * @param {Number} [parameters._negative_sample_rate = 5] - The number of negative samples per positive sample.\n * @param {Number} [parameters._n_epochs = 350] - The number of training epochs.\n * @param {Number} [parameter._initial_alpha = 1] - The initial learning rate for the optimization.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {UMAP}\n */\n constructor(X, parameters) {\n super(X, { n_neighbors: 15, local_connectivity: 1, min_dist: 1, d: 2, metric: euclidean, seed: 1212, _spread: 1, _set_op_mix_ratio: 1, _repulsion_strength: 1, _negative_sample_rate: 5, _n_epochs: 350, _initial_alpha: 1 }, parameters);\n [this._N, this._D] = this.X.shape;\n /* let n_neighbors = Math.min(this._N - 1, parameters.n_neighbors);\n this.parameter(\"n_neighbors\", n_neighbors);\n this.parameter(\"local_connectivity\", Math.min(this.parameter(\"local_connectivity\"), n_neighbors - 1)); */\n if (this.parameter(\"n_neighbors\") > this._N) {\n throw new Error(`Parameter n_neighbors (=${this.parameter(\"n_neighbors\")}) needs to be smaller than dataset size (N=${this._N})!`);\n }\n if (this.parameter(\"local_connectivity\") > this.parameter(\"n_neighbors\")) {\n throw new Error(`Parameter local_connectivity (=${this.parameter(\"local_connectivity\")}) needs to be smaller than parameter n_neighbors (=${this.parameter(\"n_neighbors\")})`);\n }\n this._iter = 0;\n const randomizer = this._randomizer;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => randomizer.random);\n return this;\n }\n\n /**\n * @private\n * @param {Number} spread\n * @param {Number} min_dist\n * @returns {Array}\n */\n _find_ab_params(spread, min_dist) {\n const curve = (x, a, b) => 1 / (1 + a * Math.pow(x, 2 * b));\n const xv = linspace(0, spread * 3, 300);\n const yv = linspace(0, spread * 3, 300);\n\n for (let i = 0, n = xv.length; i < n; ++i) {\n const xv_i = xv[i];\n yv[i] = xv_i < min_dist ? 1 : Math.exp(-(xv_i - min_dist) / spread);\n }\n\n const err = (p) => {\n const error = linspace(1, 300).map((_, i) => yv[i] - curve(xv[i], p[0], p[1]));\n return Math.sqrt(neumair_sum(error.map((e) => e * e)));\n };\n\n return powell(err, [1, 1]);\n }\n\n /**\n * @private\n * @param {Array} distances\n * @param {Array} sigmas\n * @param {Array} rhos\n * @returns {Array}\n */\n _compute_membership_strengths(distances, sigmas, rhos) {\n for (let i = 0, n = distances.length; i < n; ++i) {\n for (let j = 0, m = distances[i].length; j < m; ++j) {\n const v = distances[i][j].value - rhos[i];\n distances[i][j].value = v > 0 ? Math.exp(-v / sigmas[i]) : 1;\n }\n }\n return distances;\n }\n\n /**\n * @private\n * @param {KNN|BallTree} knn\n * @param {Number} k\n * @returns {Object}\n */\n _smooth_knn_dist(knn, k) {\n const SMOOTH_K_TOLERANCE = 1e-5;\n const MIN_K_DIST_SCALE = 1e-3;\n const n_iter = 64;\n const { local_connectivity, metric } = this._parameters;\n const target = Math.log2(k);\n const rhos = [];\n const sigmas = [];\n const X = this.X;\n const N = X.shape[0];\n //const distances = [...X].map(x_i => knn.search(x_i, k).raw_data().reverse());\n\n const distances = [];\n if (metric === \"precomputed\") {\n for (let i = 0; i < N; ++i) {\n distances.push(knn.search(i, k).reverse());\n }\n } else {\n for (const x_i of X) {\n distances.push(knn.search(x_i, k).raw_data().reverse());\n }\n }\n\n for (let i = 0; i < N; ++i) {\n let lo = 0;\n let hi = Infinity;\n let mid = 1;\n\n const search_result = distances[i];\n const non_zero_dist = search_result.filter((d) => d.value > 0);\n const non_zero_dist_length = non_zero_dist.length;\n if (non_zero_dist_length >= local_connectivity) {\n const index = Math.floor(local_connectivity);\n const interpolation = local_connectivity - index;\n if (index > 0) {\n rhos.push(non_zero_dist[index - 1]);\n if (interpolation > SMOOTH_K_TOLERANCE) {\n rhos[i].value += interpolation * (non_zero_dist[index].value - non_zero_dist[index - 1]);\n }\n } else {\n rhos[i].value = interpolation * non_zero_dist[0].value;\n }\n } else if (non_zero_dist_length > 0) {\n rhos[i] = non_zero_dist[non_zero_dist_length - 1].value;\n }\n for (let x = 0; x < n_iter; ++x) {\n let psum = 0;\n for (let j = 0; j < k; ++j) {\n const d = search_result[j].value - rhos[i];\n psum += d > 0 ? Math.exp(-(d / mid)) : 1;\n }\n if (Math.abs(psum - target) < SMOOTH_K_TOLERANCE) {\n break;\n }\n if (psum > target) {\n [hi, mid] = [mid, (lo + hi) / 2];\n } else {\n if (hi === Infinity) {\n [lo, mid] = [mid, mid * 2];\n } else {\n [lo, mid] = [mid, (lo + hi) / 2];\n }\n }\n }\n sigmas[i] = mid;\n\n const mean_ithd = search_result.reduce((a, b) => a + b.value, 0) / search_result.length;\n //let mean_d = null;\n if (rhos[i] > 0) {\n if (sigmas[i] < MIN_K_DIST_SCALE * mean_ithd) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_ithd;\n }\n } else {\n const mean_d = distances.reduce((acc, res) => acc + res.reduce((a, b) => a + b.value, 0) / res.length);\n if (sigmas[i] > MIN_K_DIST_SCALE * mean_d) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_d;\n }\n }\n }\n return {\n distances: distances,\n sigmas: sigmas,\n rhos: rhos,\n };\n }\n\n /**\n * @private\n * @param {Matrix} X\n * @param {Number} n_neighbors\n * @returns {Matrix}\n */\n _fuzzy_simplicial_set(X, n_neighbors) {\n const N = X.shape[0];\n const { metric, _set_op_mix_ratio } = this._parameters;\n const knn = metric === \"precomputed\" ? new KNN(X, \"precomputed\") : new BallTree(X.to2dArray, metric);\n let { distances, sigmas, rhos } = this._smooth_knn_dist(knn, n_neighbors);\n distances = this._compute_membership_strengths(distances, sigmas, rhos);\n const result = new Matrix(N, N, \"zeros\");\n for (let i = 0; i < N; ++i) {\n const distances_i = distances[i];\n for (let j = 0; j < distances_i.length; ++j) {\n result.set_entry(i, distances_i[j].element.index, distances_i[j].value);\n }\n }\n\n const transposed_result = result.T;\n const prod_matrix = result.mult(transposed_result);\n return result\n .add(transposed_result)\n .sub(prod_matrix)\n .mult(_set_op_mix_ratio)\n .add(prod_matrix.mult(1 - _set_op_mix_ratio));\n }\n\n /**\n * @private\n * @param {Number} n_epochs\n * @returns {Array}\n */\n _make_epochs_per_sample(n_epochs) {\n const weights = this._weights;\n const result = new Float32Array(weights.length).fill(-1);\n const weights_max = max(weights);\n const n_samples = weights.map((w) => n_epochs * (w / weights_max));\n for (let i = 0; i < result.length; ++i) if (n_samples[i] > 0) result[i] = Math.round(n_epochs / n_samples[i]);\n return result;\n }\n\n /**\n * @private\n * @param {Matrix} graph\n * @returns {Object}\n */\n _tocoo(graph) {\n const rows = [];\n const cols = [];\n const data = [];\n const [rows_n, cols_n] = graph.shape;\n for (let row = 0; row < rows_n; ++row) {\n for (let col = 0; col < cols_n; ++col) {\n const entry = graph.entry(row, col);\n if (entry !== 0) {\n rows.push(row);\n cols.push(col);\n data.push(entry);\n }\n }\n }\n return {\n rows: rows,\n cols: cols,\n data: data,\n };\n }\n\n /**\n * Computes all necessary\n * @returns {UMAP}\n */\n init() {\n const { _spread, min_dist, n_neighbors, _n_epochs, _negative_sample_rate } = this._parameters;\n const [a, b] = this._find_ab_params(_spread, min_dist);\n this._a = a;\n this._b = b;\n this._graph = this._fuzzy_simplicial_set(this.X, n_neighbors);\n const { rows, cols, data: weights } = this._tocoo(this._graph);\n this._head = rows;\n this._tail = cols;\n this._weights = weights;\n this._epochs_per_sample = this._make_epochs_per_sample(_n_epochs);\n this._epochs_per_negative_sample = this._epochs_per_sample.map((d) => d * _negative_sample_rate);\n this._epoch_of_next_sample = this._epochs_per_sample.slice();\n this._epoch_of_next_negative_sample = this._epochs_per_negative_sample.slice();\n return this;\n }\n\n graph() {\n this.check_init();\n return { cols: this._head, rows: this._tail, weights: this._weights };\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n transform(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n *generator(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * @private\n * @param {Number} x\n * @returns {Number}\n */\n _clip(x) {\n if (x > 4) return 4;\n if (x < -4) return -4;\n return x;\n }\n\n /**\n * performs the optimization step.\n * @private\n * @param {Matrix} head_embedding\n * @param {Matrix} tail_embedding\n * @param {Matrix} head\n * @param {Matrix} tail\n * @returns {Matrix}\n */\n _optimize_layout(head_embedding, tail_embedding, head, tail) {\n const randomizer = this._randomizer;\n const { _repulsion_strength, d: dim } = this._parameters;\n const { _alpha: alpha, _a: a, _b: b, _epochs_per_sample: epochs_per_sample, _epochs_per_negative_sample: epochs_per_negative_sample, _epoch_of_next_negative_sample: epoch_of_next_negative_sample, _epoch_of_next_sample: epoch_of_next_sample, _clip: clip } = this;\n const tail_length = tail.length;\n\n for (let i = 0, n = epochs_per_sample.length; i < n; ++i) {\n if (epoch_of_next_sample[i] <= this._iter) {\n const j = head[i];\n const k = tail[i];\n const current = head_embedding.row(j);\n const other = tail_embedding.row(k);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (-2 * a * b * Math.pow(dist, b - 1)) / (a * Math.pow(dist, b) + 1);\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(k, d, o);\n }\n epoch_of_next_sample[i] += epochs_per_sample[i];\n const n_neg_samples = (this._iter - epoch_of_next_negative_sample[i]) / epochs_per_negative_sample[i];\n for (let p = 0; p < n_neg_samples; ++p) {\n const k = randomizer.random_int % tail_length;\n const other = tail_embedding.row(tail[k]);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (2 * _repulsion_strength * b) / ((0.01 + dist) * (a * Math.pow(dist, b) + 1));\n } else if (j === k) {\n continue;\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(tail[k], d, o);\n }\n }\n epoch_of_next_negative_sample[i] += n_neg_samples * epochs_per_negative_sample[i];\n }\n }\n return head_embedding;\n }\n\n /**\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const Y = this.Y;\n const { _initial_alpha, _n_epochs } = this._parameters;\n this._alpha = _initial_alpha * (1 - iter / _n_epochs);\n this.Y = this._optimize_layout(Y, Y, this._head, this._tail);\n\n return this.Y;\n }\n}\n","import { Matrix, linspace } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { PCA } from \"./PCA.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TriMap\n * @extends DR\n */\nexport class TriMap extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TriMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.weight_adj = 500] - scaling factor.\n * @param {Number} [parameters.c = 5] - number of triplets multiplier.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.tol = 1e-8] -\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TriMap}\n * @see {@link https://arxiv.org/pdf/1910.00204v1.pdf}\n * @see {@link https://github.com/eamid/trimap}\n */\n constructor(X, parameters) {\n super(X, { weight_adj: 500, c: 5, d: 2, metric: euclidean, tol: 1e-8, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n *\n * @param {Matrix} [pca = null] - Initial Embedding (if null then PCA gets used).\n * @param {KNN} [knn = null] - KNN Object (if null then BallTree gets used).\n */\n init(pca = null, knn = null) {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric, c } = this._parameters;\n this.n_inliers = 2 * c;\n this.n_outliers = 1 * c;\n this.n_random = 1 * c;\n this.Y = pca || new PCA(X, d).transform();\n this.knn = knn || new BallTree(X.to2dArray, metric);\n const { triplets, weights } = this._generate_triplets(this.n_inliers, this.n_outliers, this.n_random);\n this.triplets = triplets;\n this.weights = weights;\n this.lr = (1000 * N) / triplets.shape[0];\n this.C = Infinity;\n this.vel = new Matrix(N, d, 0);\n this.gain = new Matrix(N, d, 1);\n return this;\n }\n\n /**\n * Generates {@link n_inliers} x {@link n_outliers} x {@link n_random} triplets.\n * @param {Number} n_inliers\n * @param {Number} n_outliers\n * @param {Number} n_random\n */\n _generate_triplets(n_inliers, n_outliers, n_random) {\n const { metric, weight_adj } = this._parameters;\n const X = this.X;\n const N = X.shape[0];\n const knn = this.knn;\n const n_extra = Math.min(n_inliers + 20, N);\n const nbrs = new Matrix(N, n_extra);\n const knn_distances = new Matrix(N, n_extra);\n for (let i = 0; i < N; ++i) {\n knn.search(X.row(i), n_extra + 1)\n .raw_data()\n .filter((d) => d.value != 0)\n .sort((a, b) => a.value - b.value)\n .forEach((d, j) => {\n nbrs.set_entry(i, j, d.element.index);\n knn_distances.set_entry(i, j, d.value);\n });\n }\n // scale parameter\n const sig = new Float64Array(N);\n for (let i = 0; i < N; ++i) {\n sig[i] = Math.max((knn_distances.entry(i, 3) + knn_distances.entry(i, 4) + knn_distances.entry(i, 5) + knn_distances.entry(i, 6)) / 4, 1e-10);\n }\n\n const P = this._find_p(knn_distances, sig, nbrs);\n\n let triplets = this._sample_knn_triplets(P, nbrs, n_inliers, n_outliers);\n let n_triplets = triplets.shape[0];\n const outlier_distances = new Float64Array(n_triplets);\n for (let i = 0; i < n_triplets; ++i) {\n const j = triplets.entry(i, 0);\n const k = triplets.entry(i, 2);\n outlier_distances[i] = metric(X.row(j), X.row(k));\n }\n let weights = this._find_weights(triplets, P, nbrs, outlier_distances, sig);\n\n if (n_random > 0) {\n const { random_triplets, random_weights } = this._sample_random_triplets(X, n_random, sig);\n triplets = triplets.concat(random_triplets, \"vertical\");\n weights = Float64Array.from([...weights, ...random_weights]);\n }\n n_triplets = triplets.shape[0];\n let max_weight = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n if (isNaN(weights[i])) {\n weights[i] = 0;\n }\n if (max_weight < weights[i]) max_weight = weights[i];\n }\n let max_weight_2 = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight;\n weights[i] += 0.0001;\n weights[i] = Math.log(1 + weight_adj * weights[i]);\n if (max_weight_2 < weights[i]) max_weight_2 = weights[i];\n }\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight_2;\n }\n return {\n triplets: triplets,\n weights: weights,\n };\n }\n\n /**\n * Calculates the similarity matrix P\n * @private\n * @param {Matrix} knn_distances - matrix of pairwise knn distances\n * @param {Float64Array} sig - scaling factor for the distances\n * @param {Matrix} nbrs - nearest neighbors\n * @returns {Matrix} pairwise similarity matrix\n */\n _find_p(knn_distances, sig, nbrs) {\n const [N, n_neighbors] = knn_distances.shape;\n return new Matrix(N, n_neighbors, (i, j) => {\n return Math.exp(-(knn_distances.entry(i, j) ** 2 / sig[i] / sig[nbrs.entry(i, j)]));\n });\n }\n\n /**\n * Sample nearest neighbors triplets based on the similarity values given in P.\n * @private\n * @param {Matrix} P - Matrix of pairwise similarities between each point and its neighbors given in matrix nbrs.\n * @param {Matrix} nbrs - Nearest neighbors indices for each point. The similarity values are given in matrix {@link P}. Row i corresponds to the i-th point.\n * @param {Number} n_inliers - Number of inlier points.\n * @param {Number} n_outliers - Number of outlier points.\n *\n */\n _sample_knn_triplets(P, nbrs, n_inliers, n_outliers) {\n const N = nbrs.shape[0];\n const triplets = new Matrix(N * n_inliers * n_outliers, 3);\n for (let i = 0; i < N; ++i) {\n let n_i = i * n_inliers * n_outliers;\n const sort_indices = this.__argsort(P.row(i).map((d) => -d));\n for (let j = 0; j < n_inliers; ++j) {\n let n_j = j * n_outliers;\n const sim = nbrs.entry(i, sort_indices[j]);\n const samples = this._rejection_sample(n_outliers, N, sort_indices.slice(0, j + 1));\n for (let k = 0; k < n_outliers; ++k) {\n const index = n_i + n_j + k;\n const out = samples[k];\n triplets.set_entry(index, 0, i);\n triplets.set_entry(index, 1, sim);\n triplets.set_entry(index, 2, out);\n }\n }\n }\n return triplets;\n }\n\n /**\n * Should do the same as np.argsort()\n * @private\n * @param {Array} A\n */\n __argsort(A) {\n return A.map((d, i) => {\n return { d: d, i: i };\n })\n .sort((a, b) => a.d - b.d)\n .map((d) => d.i);\n }\n\n /**\n * Samples {@link n_samples} integers from a given interval [0, {@link max_int}] while rejection the values that are in the {@link rejects}.\n * @private\n * @param {*} n_samples\n * @param {*} max_int\n * @param {*} rejects\n */\n _rejection_sample(n_samples, max_int, rejects) {\n const randomizer = this._randomizer;\n const interval = linspace(0, max_int - 1).filter((d) => rejects.indexOf(d) < 0);\n return randomizer.choice(interval, Math.min(n_samples, interval.length - 2));\n }\n\n /**\n * Calculates the weights for the sampled nearest neighbors triplets\n * @private\n * @param {Matrix} triplets - Sampled Triplets.\n * @param {Matrix} P - Pairwise similarity matrix.\n * @param {Matrix} nbrs - nearest Neighbors\n * @param {Float64Array} outlier_distances - Matrix of pairwise outlier distances\n * @param {Float64Array} sig - scaling factor for the distances.\n */\n _find_weights(triplets, P, nbrs, outlier_distances, sig) {\n const n_triplets = triplets.shape[0];\n const weights = new Float64Array(n_triplets);\n for (let t = 0; t < n_triplets; ++t) {\n const i = triplets.entry(t, 0);\n const sim = nbrs.row(i).indexOf(triplets.entry(t, 1));\n const p_sim = P.entry(i, sim);\n let p_out = Math.exp(-(outlier_distances[t] ** 2 / (sig[i] * sig[triplets.entry(t, 2)])));\n if (p_out < 1e-20) p_out = 1e-20;\n weights[t] = p_sim / p_out;\n }\n return weights;\n }\n\n /**\n * Sample uniformly ranom triplets\n * @private\n * @param {Matrix} X - Data matrix.\n * @param {Number} n_random - Number of random triplets per point\n * @param {Float64Array} sig - Scaling factor for the distances\n */\n _sample_random_triplets(X, n_random, sig) {\n const metric = this.parameter(\"metric\");\n const randomizer = this._randomizer;\n const N = X.shape[0];\n const random_triplets = new Matrix(N * n_random, 3);\n const random_weights = new Float64Array(N * n_random);\n for (let i = 0; i < N; ++i) {\n const n_i = i * n_random;\n const indices = [...linspace(0, i - 1), ...linspace(i + 1, N - 1)];\n for (let j = 0; j < n_random; ++j) {\n let [sim, out] = randomizer.choice(indices, 2);\n let p_sim = Math.exp(-(metric(X.row(i), X.row(sim)) ** 2 / (sig[i] * sig[sim])));\n if (p_sim < 1e-20) p_sim = 1e-20;\n let p_out = Math.exp(-(metric(X.row(i), X.row(out)) ** 2 / (sig[i] * sig[out])));\n if (p_out < 1e-20) p_out = 1e-20;\n\n if (p_sim < p_out) {\n [sim, out] = [out, sim];\n [p_sim, p_out] = [p_out, p_sim];\n }\n const index = n_i + j;\n random_triplets.set_entry(index, 0, i);\n random_triplets.set_entry(index, 1, sim);\n random_triplets.set_entry(index, 2, out);\n random_weights[index] = p_sim / p_out;\n }\n }\n return {\n random_triplets: random_triplets,\n random_weights: random_weights,\n };\n }\n\n /**\n * Computes the gradient for updating the embedding.\n * @param {Matrix} Y - The embedding\n */\n _grad(Y) {\n const n_inliers = this.n_inliers;\n const n_outliers = this.n_outliers;\n const triplets = this.triplets;\n const weights = this.weights;\n const [N, dim] = Y.shape;\n const n_triplets = triplets.shape[0];\n const grad = new Matrix(N, dim, 0);\n let y_ij = new Float64Array(dim);\n let y_ik = new Float64Array(dim);\n let d_ij = 1;\n let d_ik = 1;\n let n_viol = 0;\n let loss = 0;\n const n_knn_triplets = N * n_inliers * n_outliers;\n\n for (let t = 0; t < n_triplets; ++t) {\n const [i, j, k] = triplets.row(t);\n // update y_ij, y_ik, d_ij, d_ik\n if (t % n_outliers == 0 || t >= n_knn_triplets) {\n d_ij = 1;\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_jd = Y.entry(j, d);\n const Y_kd = Y.entry(k, d);\n y_ij[d] = Y_id - Y_jd;\n y_ik[d] = Y_id - Y_kd;\n d_ij += y_ij[d] ** 2;\n d_ik += y_ik[d] ** 2;\n }\n // update y_ik and d_ik only\n } else {\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_kd = Y.entry(k, d);\n y_ik[d] = Y_id - Y_kd;\n d_ik += y_ik[d] ** 2;\n }\n }\n\n if (d_ij > d_ik) ++n_viol;\n loss += weights[t] / (1 + d_ik / d_ij);\n const w = (weights[t] / (d_ij + d_ik)) ** 2;\n for (let d = 0; d < dim; ++d) {\n const gs = y_ij[d] * d_ik * w;\n const go = y_ik[d] * d_ij * w;\n grad.set_entry(i, d, grad.entry(i, d) + gs - go);\n grad.set_entry(j, d, grad.entry(j, d) - gs);\n grad.set_entry(k, d, grad.entry(k, d) + go);\n }\n }\n return { grad, loss, n_viol };\n }\n\n /**\n *\n * @param {Number} max_iteration\n */\n transform(max_iteration = 400) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n }\n return this.projection;\n }\n\n /**\n * @param {Number} max_iteration\n * @yields {Matrix}\n * @returns {Matrix}\n */\n *generator(max_iteration = 800) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * Does the iteration step.\n * @private\n * @param {Number} iter\n */\n _next(iter) {\n const gamma = iter > 150 ? 0.5 : 0.3;\n const old_C = this.C;\n const vel = this.vel;\n const Y = this.Y.add(vel.mult(gamma));\n const { grad, loss, n_viol } = this._grad(Y);\n this.C = loss;\n this.Y = this._update_embedding(Y, iter, grad);\n this.lr *= old_C > loss + this._parameters.tol ? 1.01 : 0.9;\n return this.Y;\n }\n\n /**\n * Updates the embedding.\n * @private\n * @param {Matrix} Y\n * @param {Number} iter\n * @param {Matrix} grad\n */\n _update_embedding(Y, iter, grad) {\n const [N, dim] = Y.shape;\n const gamma = iter > 150 ? 0.9 : 0.5; // moment parameter\n const min_gain = 0.01;\n const gain = this.gain;\n const vel = this.vel;\n const lr = this.lr;\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const new_gain = Math.sign(vel.entry(i, d)) != Math.sign(grad.entry(i, d)) ? gain.entry(i, d) + 0.2 : Math.max(gain.entry(i, d) * 0.8, min_gain);\n gain.set_entry(i, d, new_gain);\n vel.set_entry(i, d, gamma * vel.entry(i, d) - lr * gain.entry(i, d) * grad.entry(i, d));\n Y.set_entry(i, d, Y.entry(i, d) + vel.entry(i, d));\n }\n }\n return Y;\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n/**\n * @class\n * @alias Hierarchical_Clustering\n */\nexport class Hierarchical_Clustering {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias Hierarchical_Clustering\n * @todo needs restructuring.\n * @param {Matrix} - Data or distance matrix if metric is 'precomputed'\n * @param {(\"single\"|\"complete\"|\"average\")} [linkage = \"complete\"]\n * @param {Function|\"precomputed\"} [metric = euclidean]\n * @returns {Hierarchical_Clustering}\n */\n constructor(matrix, linkage = \"complete\", metric = euclidean) {\n this._id = 0;\n this._matrix = matrix instanceof Matrix ? matrix : Matrix.from(matrix);\n this._metric = metric;\n this._linkage = linkage;\n if (metric === \"precomputed\" && this._matrix.shape[0] !== this._matrix.shape[1]) {\n throw new Error(\"If metric is 'precomputed', then matrix has to be square!\");\n }\n this.init();\n this.root = this.do();\n return this;\n }\n\n /**\n *\n * @param {Number} value - value where to cut the tree.\n * @param {(\"distance\"|\"depth\")} [type = \"distance\"] - type of value.\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters(value, type = \"distance\") {\n let clusters = [];\n let accessor;\n switch (type) {\n case \"distance\":\n accessor = (d) => d.dist;\n break;\n case \"depth\":\n accessor = (d) => d.depth;\n break;\n default:\n throw new Error(\"invalid type\");\n }\n this._traverse(this.root, accessor, value, clusters);\n return clusters;\n }\n\n /**\n * @private\n * @param {} node\n * @param {*} f\n * @param {*} value\n * @param {*} result\n */\n _traverse(node, f, value, result) {\n if (f(node) <= value) {\n result.push(node.leaves());\n } else {\n this._traverse(node.left, f, value, result);\n this._traverse(node.right, f, value, result);\n }\n }\n\n /**\n * computes the tree.\n */\n init() {\n const metric = this._metric;\n const A = this._matrix;\n const n = (this._n = A.shape[0]);\n const d_min = (this._d_min = new Float64Array(n));\n let distance_matrix;\n if (metric !== \"precomputed\") {\n distance_matrix = new Matrix(n, n, 0); //new Array(n);\n for (let i = 0; i < n; ++i) {\n d_min[i] = 0;\n //distance_matrix[i] = new Float64Array(n);\n for (let j = 0; j < n; ++j) {\n distance_matrix.set_entry(i, j, i === j ? Infinity : metric(A.row(i), A.row(j)));\n if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n } else {\n distance_matrix = this._matrix.clone();\n for (let i = 0; i < n; ++i) {\n for (let j = 0; j < n; ++j) {\n if (i === j) {\n distance_matrix.set_entry(i, j, Infinity);\n } else if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n }\n this._distance_matrix = distance_matrix;\n const clusters = (this._clusters = new Array(n));\n const c_size = (this._c_size = new Uint16Array(n));\n for (let i = 0; i < n; ++i) {\n clusters[i] = [];\n clusters[i][0] = new Cluster(this._id++, null, null, 0, A.row(i), i, 1, 0);\n c_size[i] = 1;\n }\n return this;\n }\n\n /**\n * computes the tree.\n */\n do() {\n const n = this._n;\n const d_min = this._d_min;\n const D = this._distance_matrix;\n const clusters = this._clusters;\n const c_size = this._c_size;\n const linkage = this._linkage;\n let root = null;\n for (let p = 0, p_max = n - 1; p < p_max; ++p) {\n let c1 = 0;\n for (let i = 0; i < n; ++i) {\n let D_i_min = D.entry(i, d_min[i]);\n for (let j = i + 1; j < n; ++j) {\n if (D_i_min > D.entry(i, j)) {\n d_min[i] = j;\n D_i_min = D.entry(i, d_min[i]);\n }\n }\n }\n for (let i = 0; i < n; ++i) {\n if (D.entry(i, d_min[i]) < D.entry(c1, d_min[c1])) {\n c1 = i;\n }\n }\n let c2 = d_min[c1];\n let c1_cluster = clusters[c1][0];\n let c2_cluster = clusters[c2][0];\n let c1_cluster_indices = c1_cluster.isLeaf ? [c1_cluster.index] : c1_cluster.index;\n let c2_cluster_indices = c2_cluster.isLeaf ? [c2_cluster.index] : c2_cluster.index;\n let indices = c1_cluster_indices.concat(c2_cluster_indices);\n let new_cluster = new Cluster(this._id++, c1_cluster, c2_cluster, D.entry(c1, c2), null, indices);\n c1_cluster.parent = new_cluster;\n c2_cluster.parent = new_cluster;\n clusters[c1].unshift(new_cluster);\n c_size[c1] += c_size[c2];\n for (let j = 0; j < n; ++j) {\n const D_c1_j = D.entry(c1, j);\n const D_c2_j = D.entry(c2, j);\n let value;\n switch (linkage) {\n case \"single\":\n value = Math.min(D_c1_j, D_c2_j);\n break;\n case \"complete\":\n value = Math.max(D_c1_j, D_c2_j);\n break;\n case \"average\":\n value = (c_size[c1] * D_c1_j + c_size[c2] * D_c2_j) / (c_size[c1] + c_size[j]);\n break;\n }\n D.set_entry(j, c1, value);\n D.set_entry(c1, j, value);\n }\n\n D.set_entry(c1, c1, Infinity);\n for (let i = 0; i < n; ++i) {\n D.set_entry(i, c2, Infinity);\n D.set_entry(c2, i, Infinity);\n }\n\n /* for (let j = 0; j < n; ++j) {\n if (d_min[j] === c2) {\n d_min[j] = c1;\n }\n if (D.entry(c1, j) < D.entry(c1, d_min[c1])) {\n d_min[c1] = j;\n }\n } */\n root = new_cluster;\n }\n return root;\n }\n}\n\nclass Cluster {\n constructor(id, left, right, dist, centroid, index, size, depth) {\n this.id = id;\n this.left = left;\n this.right = right;\n this.dist = dist;\n this.index = index;\n this.size = size ?? left.size + right.size;\n this.depth = depth ?? 1 + Math.max(left.depth, right.depth);\n this.centroid = centroid ?? this._calculate_centroid(left, right);\n this.parent = null;\n return this;\n }\n\n _calculate_centroid(left, right) {\n const l_size = left.size;\n const r_size = right.size;\n const l_centroid = left.centroid;\n const r_centroid = right.centroid;\n const size = this.size;\n const n = left.centroid.length;\n const new_centroid = new Float64Array(n);\n for (let i = 0; i < n; ++i) {\n new_centroid[i] = (l_size * l_centroid[i] + r_size * r_centroid[i]) / size;\n }\n return new_centroid;\n }\n\n get isLeaf() {\n return this.depth === 0;\n }\n\n leaves() {\n if (this.isLeaf) return [this];\n const left = this.left;\n const right = this.right;\n return (left.isLeaf ? [left] : left.leaves()).concat(right.isLeaf ? [right] : right.leaves());\n }\n\n descendants() {\n if (this.isLeaf) return [this];\n const left_descendants = this.left.descendants();\n const right_descendants = this.right.descendants();\n return left_descendants.concat(right_descendants).concat([this]);\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { linspace } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KMeans\n */\nexport class KMeans {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMeans\n * @todo needs restructuring. \n * @param {Matrix} matrix \n * @param {Numbers} K \n * @param {Function} [metric = euclidean] \n * @param {Number} [seed = 1987]\n * @param {Boolean} [init = true]\n * @returns {KMeans}\n */\n constructor(matrix, K, metric = euclidean, seed=1987, init = true) {\n this._metric = metric;\n this._matrix = matrix;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_centroids = this._get_random_centroids(K);\n if (init) this.init(K, this._cluster_centroids);\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const clusters = this._clusters;\n const result = new Array(K).fill().map(() => new Array());\n clusters.forEach((c, i) => result[c].push(i));\n return result;\n }\n\n /**\n * @private\n * @param {Array} points \n * @param {Array} candidates \n */\n _furthest_point(points, candidates) {\n const A = this._matrix;\n const metric = this._metric;\n let i = points.length;\n let H = Heap.heapify(\n candidates, \n (d) => {\n const Ad = A.row(d)\n let sum = 0;\n for (let j = 0; j < i; ++j) {\n sum += metric(Ad, points[j])\n }\n return sum;\n }, \n \"max\"\n )\n return H.pop().element;\n }\n\n _get_random_centroids(K) {\n const N = this._N;\n const randomizer = this._randomizer;\n const A = this._matrix;\n const cluster_centroids = new Array(K).fill()\n const indices = linspace(0, N - 1);\n const random_point = randomizer.random_int % (N - 1);\n cluster_centroids[0] = A.row(random_point);\n const init_points = [random_point];\n const sample_size = Math.floor((N - K) / K);// / K\n for (let i = 1; i < K; ++i) {\n // sampling + kmeans++ improvement?\n const sample = randomizer.choice(indices.filter(d => init_points.indexOf(d) == -1), sample_size);\n const furthest_point = this._furthest_point(cluster_centroids.slice(0, i), sample);\n init_points.push(furthest_point);\n cluster_centroids[i] = A.row(furthest_point);\n }\n return cluster_centroids;\n }\n\n _iteration(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const metric = this._metric;\n const clusters = this._clusters;\n let clusters_changed = false;\n // find nearest cluster centroid.\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i)\n let min_dist = Infinity;\n let min_cluster = null;\n for (let j = 0; j < K; ++j) {\n let d = metric(cluster_centroids[j], Ai);\n if (d < min_dist) {\n min_dist = d;\n min_cluster = j; \n }\n }\n if (clusters[i] !== min_cluster) {\n clusters_changed = true;\n }\n clusters[i] = min_cluster;\n }\n // update cluster centroid\n // reset cluster centroids to 0\n for (let i = 0; i < K; ++i) {\n const centroid = cluster_centroids[i];\n for (let j = 0; j < D; ++j) {\n centroid[j] = 0;\n }\n }\n // compute centroid\n this._compute_centroid(cluster_centroids);\n\n return { \n \"clusters_changed\": clusters_changed,\n \"cluster_centroids\": cluster_centroids\n };\n }\n\n _compute_centroid(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const clusters = this._clusters;\n const cluster_counter = new Array(K).fill(0);\n\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i);\n const ci = clusters[i];\n cluster_counter[ci]++;\n const centroid = cluster_centroids[ci];\n for (let j = 0; j < D; ++j) {\n centroid[j] += Ai[j];\n }\n }\n for (let i = 0; i < K; ++i) {\n const n = cluster_counter[i];\n cluster_centroids[i] = cluster_centroids[i].map(c => c / n);\n }\n \n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_centroids) {\n if (!K) K = this._K;\n if (!cluster_centroids) cluster_centroids = this._get_random_centroids(K);\n let clusters_changed = false;\n do {\n const iteration_result = this._iteration(cluster_centroids)\n cluster_centroids = iteration_result.cluster_centroids;\n clusters_changed = iteration_result.clusters_changed;\n } while (clusters_changed)\n }\n \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { linspace, Matrix } from \"../matrix/index.js\";\nimport { min } from \"../util/index.js\";\n/**\n * @class\n * @alias KMedoids\n */\nexport class KMedoids {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMedoids\n * @todo needs restructuring. \n * @param {Matrix} matrix - data matrix\n * @param {Numbers} K - number of clusters\n * @param {number} [max_iter=null] - maximum number of iterations. Default is 10 * Math.log10(N)\n * @param {Function} [metric = euclidean] - metric defining the dissimilarity \n * @param {Number} [seed = 1212] - seed value for random number generator\n * @returns {KMedoids}\n * @see {@link https://link.springer.com/chapter/10.1007/978-3-030-32047-8_16} Faster k-Medoids Clustering: Improving the PAM, CLARA, and CLARANS Algorithms\n */\n constructor(matrix, K, max_iter=null, metric = euclidean, seed=1212) {\n this._metric = metric;\n this._matrix = matrix;\n this._A = this._matrix.to2dArray;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n this._max_iter = max_iter || 10 * Math.log10(N) \n this._distance_matrix = new Matrix(N, N, \"zeros\");\n /* for (let i = 1; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dist = metric(this._A[i], this._A[j]);\n this._distance_matrix.set_entry(i, j, dist);\n this._distance_matrix.set_entry(j, i, dist)\n }\n } */\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_medoids = this._get_random_medoids(K);\n //if (init) this.init(K, this._cluster_medoids);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const A = this._A;\n if (!this._is_initialized) {\n this.init(K, this._cluster_medoids);\n }\n const result = new Array(K).fill().map(() => new Array());\n A.forEach((x_j, j) => {\n result[this._nearest_medoid(x_j, j).index_nearest].push(j);\n })\n result.medoids = this._cluster_medoids;\n return result;\n }\n\n async* generator() {\n const max_iter = this._max_iter;\n yield this.get_clusters()\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n yield this.get_clusters();\n } while (!finish && ++i < max_iter)\n }\n\n /**\n * Algorithm 1. FastPAM1: Improved SWAP algorithm\n */\n /* _iteration_1() {\n const A = this._A;\n const N = this._N;\n const K = this._K;\n const medoids = this._cluster_medoids;\n let DeltaTD = 0;\n let m0 = null;\n let x0 = null;\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const nearest_medoid = this._nearest_medoid(x_j, j);\n const d_j = nearest_medoid.distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n // disance to new medoid\n const d_oj = this._get_distance(o, j, x_o, x_j);\n const {\n \"index_nearest\": n,\n \"distance_nearest\": d_n,\n \"distance_second\": d_s,\n } = this._nearest_medoid(x_o, o); \n this._clusters[o] = n; // cached values\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change\n if (d_oj < d_n) { // reassignment check\n deltaTD.forEach((d_i, i) => {\n if (n !== i) {\n deltaTD[i] = d_i + d_oj - d_n; // update loss change\n }\n });\n }\n });\n // choose best medoid i;\n const i = deltaTD\n .map((d, i) => [d, i])\n .sort((d1, d2) => d1[0] - d2[0])[0][1];\n const deltaTD_i = deltaTD[i];\n // store\n if (deltaTD_i < DeltaTD) {\n DeltaTD = deltaTD_i;\n m0 = i;\n x0 = j;\n }\n }\n });\n\n if (DeltaTD >= 0) {\n return true // break loop if DeltaTD >= 0\n }\n // swap roles of medoid m and non-medoid x;\n medoids[m0] = x0;\n this._cluster_medoids = medoids;\n return false\n } */\n\n /** Algorithm 2. FastPAM2: SWAP with multiple candidates\n * \n */\n _iteration() {\n const A = this._A;\n const K = this._K;\n const medoids = this._cluster_medoids;\n const cache = A.map((x_o, o) => this._nearest_medoid(x_o, o));\n // empty best candidates array\n const DeltaTD = new Array(K).fill(0);\n const xs = new Array(K).fill(null);\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const d_j = cache[j].distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n if (j === o) return;\n const d_oj = this._get_distance(o, j, x_o, x_j); // distance to new medoid\n const {\"index_nearest\": n, \"distance_nearest\": d_n, \"distance_second\": d_s} = cache[o]; // cached\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change for x_o\n // Reassignment check\n if (d_oj < d_n) { \n // update loss change\n for (let i = 0; i < K; ++i) {\n if (i !== n) deltaTD[i] += d_oj - d_n;\n }\n }\n });\n // remember best swap for i;\n deltaTD\n .map((d, i) => [d, i])\n .filter(([d, i]) => d < DeltaTD[i])\n .forEach(([d, i]) => {\n if (d < DeltaTD[i]) {\n DeltaTD[i] = d;\n xs[i] = j;\n }\n })\n }\n })\n // stop if no improvements were found\n if (min(DeltaTD) >= 0) return true; \n\n // execute all improvements\n while (min(DeltaTD) < 0) {\n // swap roles of medoid m_i and non_medoid xs_i\n const i = DeltaTD\n .map((d, i) => [d, i])\n .sort(([a], [b]) => a - b)[0][1];\n if (medoids.filter(m => m == xs[i]).length == 0) {\n medoids[i] = xs[i];\n }\n // disable the swap just performed\n DeltaTD[i] = 0; \n // recompute TD for remaining swap candidates\n DeltaTD\n .map((d_j, j) => [d_j, j])\n .filter(([d_j]) => d_j < 0)\n .forEach(([_, j]) => {\n const x_j = A[j];\n let sum = 0;\n A.forEach((x_o, o) => {\n if (medoids.findIndex(m => m != j && m == o) >= 0) return;\n if (i == j) return;\n if (cache[o].index_nearest === medoids[j])\n sum += (Math.min(this._get_distance(o, j, x_o, x_j), cache[o].distance_second) - cache[o].distance_nearest); \n else {\n sum += (Math.min(this._get_distance(o, j, x_o, x_j) - cache[o].distance_nearest, 0));\n }\n });\n DeltaTD[j] = sum;\n })\n }\n this._cluster_medoids = medoids;\n return false;\n }\n\n _get_distance(i, j, x_i=null, x_j=null) {\n if (i === j) return 0;\n const D = this._distance_matrix;\n const A = this._A;\n const metric = this._metric;\n let d_ij = D.entry(i, j);\n if (d_ij === 0) {\n d_ij = metric(x_i || A[i], x_j || A[j]);\n D.set_entry(i, j, d_ij);\n D.set_entry(j, i, d_ij);\n }\n return d_ij;\n }\n\n _nearest_medoid(x_j, j) {\n const medoids = this._cluster_medoids;\n const A = this._A;\n const [nearest, second] = medoids\n .map((m, i) => {\n const x_m = A[m]; \n return [this._get_distance(j, m, x_j, x_m), i];\n })\n .sort((m1, m2) => m1[0] - m2[0]);\n \n return { \n \"distance_nearest\": nearest[0], \n \"index_nearest\": nearest[1],\n \"distance_second\": second[0],\n \"index_second\": second[1],\n };\n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_medoids) {\n if (!K) K = this._K;\n if (!cluster_medoids) cluster_medoids = this._get_random_medoids(K);\n const max_iter = this._max_iter;\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n } while (!finish && ++i < max_iter)\n return this;\n }\n\n /**\n * Algorithm 3. FastPAM LAB: Linear Approximate BUILD initialization.\n * @param {number} K - number of clusters\n * \n */\n _get_random_medoids(K) {\n const N = this._N;\n const A = this._A;\n const indices = linspace(0, N - 1);\n const randomizer = this._randomizer;\n const n = Math.min(N, 10 + Math.ceil(Math.sqrt(N)));\n const TD = new Array(n).fill(Infinity);\n const medoids = [];\n // first medoid\n let TD0 = Infinity;\n let S = randomizer.choice(indices, n);\n for (let j = 0; j < n; ++j) {\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const x_o = A[S[o]];\n TD[j] += this._get_distance(j, o, x_j, x_o);\n }\n if (TD[j] < TD0) {\n TD0 = TD[j]; // smallest distance sum\n medoids.push(S_j);\n }\n }\n // other medoids\n for (let i = 1; i < K; ++i) {\n let DeltaTD = Infinity;\n S = randomizer.choice(indices.filter(index => medoids.findIndex(d => d === index) < 0), n);\n for (let j = 0; j < n; ++j) {\n let deltaTD = 0;\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const S_o = S[o];\n const x_o = A[S_o];\n let delta = this._get_distance(S_j, S_o, x_j, x_o) - min(medoids.map(m => this._get_distance(S_o, m, x_o)));\n if (delta < 0) {\n deltaTD = deltaTD + delta;\n }\n }\n // best reduction\n if (deltaTD < DeltaTD) {\n DeltaTD = deltaTD;\n medoids.push(S_j);\n }\n }\n TD0 += DeltaTD;\n }\n return medoids.slice(0, K);\n }\n \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias OPTICS\n */\nexport class OPTICS {\n /**\n * **O**rdering **P**oints **T**o **I**dentify the **C**lustering **S**tructure.\n * @constructor\n * @memberof module:clustering\n * @alias OPTICS\n * @todo needs restructuring. \n * @param {Matrix} matrix - the data.\n * @param {Number} epsilon - the minimum distance which defines whether a point is a neighbor or not.\n * @param {Number} min_points - the minimum number of points which a point needs to create a cluster. (Should be higher than 1, else each point creates a cluster.)\n * @param {Function} [metric = euclidean] - the distance metric which defines the distance between two points of the {@link matrix}.\n * @returns {OPTICS}\n * @see {@link https://www.dbs.ifi.lmu.de/Publikationen/Papers/OPTICS.pdf}\n * @see {@link https://en.wikipedia.org/wiki/OPTICS_algorithm}\n */\n constructor(matrix, epsilon, min_points, metric = euclidean) {\n this._matrix = matrix;\n this._epsilon = epsilon;\n this._min_points = min_points;\n this._metric = metric;\n\n this._ordered_list = [];\n this._clusters = [];\n this._DB = new Array(matrix.shape[0]).fill();\n this.init();\n return this;\n }\n\n /**\n * Computes the clustering.\n */\n init() {\n const ordered_list = this._ordered_list;\n const matrix = this._matrix;\n const N = matrix.shape[0];\n const DB = this._DB;\n const clusters = this._clusters;\n let cluster_index = this._cluster_index = 0;\n\n for (let i = 0; i < N; ++i) {\n DB[i] = {\n \"element\": matrix.row(i),\n \"index\": i,\n \"reachability_distance\": undefined,\n \"processed\": false,\n }\n }\n for (const p of DB) {\n if (p.processed) continue;\n p.neighbors = this._get_neighbors(p);\n p.processed = true;\n clusters.push([p.index])\n cluster_index = clusters.length - 1;\n ordered_list.push(p);\n if (this._core_distance(p) != undefined) {\n const seeds = new Heap(null, d => d.reachability_distance, \"min\")\n this._update(p, seeds);\n this._expand_cluster(seeds, clusters[cluster_index]);\n }\n }\n return this;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Array} An array consisting of the {@link epsilon}-neighborhood of {@link p}.\n */\n _get_neighbors(p) {\n if (\"neighbors\" in p) return p.neighbors;\n const DB = this._DB;\n const metric = this._metric;\n const epsilon = this._epsilon;\n const neighbors = [];\n for (const q of DB) {\n if (q.index == p.index) continue;\n if (metric(p.element, q.element) < epsilon) {\n neighbors.push(q);\n }\n }\n return neighbors;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Number} The distance to the {@link min_points}-th nearest point of {@link p}, or undefined if the {@link epsilon}-neighborhood has fewer elements than {@link min_points}.\n */\n _core_distance(p) {\n const min_points = this._min_points;\n const metric = this._metric;\n if (p.neighbors && p.neighbors.length <= min_points) {\n return undefined;\n }\n return metric(p.element, p.neighbors[min_points].element);\n }\n\n /**\n * Updates the reachability distance of the points.\n * @private\n * @param {Object} p \n * @param {Heap} seeds \n */\n _update(p, seeds) {\n const metric = this._metric;\n const core_distance = this._core_distance(p);\n const neighbors = this._get_neighbors(p);//p.neighbors;\n for (const q of neighbors) {\n if (q.processed) continue;\n const new_reachability_distance = Math.max(core_distance, metric(p.element, q.element));\n //if (q.reachability_distance == undefined) { // q is not in seeds\n if (seeds.raw_data().findIndex(d => d.element == q) < 0) {\n q.reachability_distance = new_reachability_distance;\n seeds.push(q);\n } else { // q is in seeds\n if (new_reachability_distance < q.reachability_distance) {\n q.reachability_distance = new_reachability_distance;\n seeds = Heap.heapify(seeds.data(), d => d.reachability_distance, \"min\"); // seeds change key =/\n }\n }\n }\n }\n\n /**\n * Expands the {@link cluster} with points in {@link seeds}.\n * @private\n * @param {Heap} seeds \n * @param {Array} cluster \n */\n _expand_cluster(seeds, cluster) {\n const ordered_list = this._ordered_list;\n while (!seeds.empty) {\n const q = seeds.pop().element;\n q.neighbors = this._get_neighbors(q);\n q.processed = true;\n cluster.push(q.index);\n ordered_list.push(q);\n if (this._core_distance(q) != undefined) {\n this._update(q, seeds);\n this._expand_cluster(seeds, cluster);\n }\n }\n }\n\n /**\n * Returns an array of clusters.\n * @returns {Array} Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters() {\n const clusters = [];\n const outliers = [];\n const min_points = this._min_points;\n for (const cluster of this._clusters) {\n if (cluster.length < min_points) {\n outliers.push(...cluster);\n } else {\n clusters.push(cluster);\n }\n }\n clusters.push(outliers);\n return clusters;\n }\n\n /**\n * @returns {Array} Returns an array, where the ith entry defines the cluster affirmation of the ith point of {@link matrix}. (-1 stands for outlier)\n */\n get_cluster_affirmation() {\n const N = this._matrix.shape[0];\n const result = new Array(N).fill();\n const clusters = this.get_clusters();\n for (let i = 0, n = clusters.length; i < n; ++i) {\n const cluster = clusters[i]\n for (const index of cluster) {\n result[index] = (i < n - 1) ? i : -1;\n }\n }\n return result;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\nimport { MDS } from \"./MDS.js\";\nimport { KMedoids } from \"../clustering/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\n/**\n * @class\n * @alias LSP\n * @extends DR\n */\nexport class LSP extends DR {\n /**\n * Least Squares Projection.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LSP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.neighbors = Math.max(Math.floor(N / 10), 2)] - number of neighbors to consider.\n * @param {Number} [parameters.control_points = Math.ceil(Math.sqrt(N))] - number of controlpoints\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {LSP}\n * @see {@link https://ieeexplore.ieee.org/document/4378370}\n * @todo accept precomputed distance matrix.\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, control_points: undefined, d: 2, metric: euclidean, seed: 1212 }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n this.parameter(\"control_points\", Math.min(parameters.control_points ?? Math.ceil(Math.sqrt(this._N)), this._N - 1));\n this._is_initialized = false;\n return this;\n }\n\n /**\n *\n * @param {DR} DR - method used for position control points.\n * @param {Object} DR_parameters - Object containing parameters for the DR method which projects the control points\n * @returns {LSP}\n */\n init(DR = MDS, DR_parameters = {}, KNN = BallTree) {\n if (this._is_initialized) return this;\n const X = this.X;\n const N = this._N;\n const K = this.parameter(\"neighbors\");\n const d = this.parameter(\"d\");\n const seed = this.parameter(\"seed\");\n const metric = this.parameter(\"metric\");\n DR_parameters = Object.assign({d, metric, seed }, DR_parameters);\n const nc = this.parameter(\"control_points\");\n const control_points = new KMedoids(X, nc, null, metric).get_clusters().medoids;\n const C = new Matrix(nc, N, \"zeros\");\n control_points.forEach((c_i, i) => {\n C.set_entry(i, c_i, 1);\n });\n const Y_C = new DR(Matrix.from(control_points.map((c_i) => X.row(c_i))), DR_parameters).transform();\n\n const XA = X.to2dArray;\n const knn = new KNN(XA, metric);\n const L = new Matrix(N, N, \"I\");\n const alpha = -1 / K;\n XA.forEach((x_i, i) => {\n for (const { index: j } of knn.search(x_i, K).iterate()) {\n if (i === j) continue;\n L.set_entry(i, j, alpha);\n }\n });\n const A = L.concat(C, \"vertical\");\n\n const z = new Matrix(N, d, \"zeros\");\n const b = z.concat(Y_C, \"vertical\");\n\n this._A = A;\n this._b = b;\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const A = this._A;\n const AT = A.T;\n const b = this._b;\n const ATA = AT.dot(A);\n const ATb = AT.dot(b);\n this.Y = Matrix.solve_CG(ATA, ATb, this._randomizer);\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { DisjointSet } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias TopoMap\n * @memberof module:dimensionality_reduction\n * @extends DR\n */\nexport class TopoMap extends DR {\n /**\n * TopoMap: A 0-dimensional Homology Preserving Projection of High-Dimensional Data.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TopoMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TopoMap}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._distance_matrix = new Matrix(this._N, this._N, 0);\n return this;\n }\n\n /**\n * @private\n */\n __lazy_distance_matrix(i, j, metric) {\n const D = this._distance_matrix;\n const X = this.X;\n const D_ij = D.entry(i, j);\n if (D_ij === 0) {\n let dist = metric(X.row(i), X.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n return dist;\n }\n return D_ij;\n }\n\n /**\n * Computes the minimum spanning tree, using a given metric\n * @private\n * @param {Function} metric\n * @see {@link https://en.wikipedia.org/wiki/Kruskal%27s_algorithm}\n */\n _make_minimum_spanning_tree(metric = euclidean) {\n const N = this._N;\n const X = [...this.X];\n\n let disjoint_set = new DisjointSet(X);\n const F = [];\n let E = [];\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n E.push([i, j, this.__lazy_distance_matrix(i, j, metric)]);\n }\n }\n E = E.sort((a, b) => a[2] - b[2]);\n\n for (const [u, v, w] of E) {\n const set_u = disjoint_set.find(X[u]);\n const set_v = disjoint_set.find(X[v]);\n if (set_u !== set_v) {\n F.push([u, v, w]);\n disjoint_set.union(set_u, set_v);\n }\n }\n\n return F.sort((a, b) => a[2] - b[2]);\n }\n\n /**\n * initializes TopoMap. Sets all projcted points to zero, and computes a minimum spanning tree.\n */\n init() {\n const { metric} = this._parameters\n this.Y = new Matrix(this._N, 2, 0);\n this._Emst = this._make_minimum_spanning_tree(metric);\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Returns true if Point C is left of line AB.\n * @private\n * @param {Array} PointA - Point A of line AB\n * @param {Array} PointB - Point B of line AB\n * @param {Array} PointC - Point C\n * @returns {Boolean}\n */\n __hull_cross([ax, ay], [bx, by], [sx, sy]) {\n return (bx - ax) * (sy - ay) - (by - ay) * (sx - ax) <= 0;\n }\n\n /**\n * Computes the convex hull of the set of Points S\n * @private\n * @param {Array} S - Set of Points.\n * @see {@link https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain#JavaScript}\n * @returns {Array} convex hull of S. Starts at the bottom-most point and continues counter-clockwise.\n */\n __hull(S) {\n const points = S.sort(([x1, y1], [x2, y2]) => y1 - y2 || x1 - x2);\n const N = points.length;\n if (N <= 2) return points;\n\n const lower = [];\n for (let i = 0; i < N; ++i) {\n while (lower.length >= 2 && this.__hull_cross(lower[lower.length - 2], lower[lower.length - 1], points[i])) {\n lower.pop();\n }\n lower.push(points[i]);\n }\n const upper = [];\n for (let i = N - 1; i >= 0; --i) {\n while (upper.length >= 2 && this.__hull_cross(upper[upper.length - 2], upper[upper.length - 1], points[i])) {\n upper.pop();\n }\n upper.push(points[i]);\n }\n upper.pop();\n lower.pop();\n return lower.concat(upper);\n }\n\n /**\n * Finds the angle to rotate Point A and B to lie on a line parallel to the x-axis.\n * @private\n * @param {Array} PointA\n * @param {Array} PointB\n * @return {Object} Object containing the sinus- and cosinus-values for a rotation.\n */\n __findAngle([p1x, p1y], [p2x, p2y]) {\n const n = euclidean([p1x, p1y], [p2x, p2y]);\n if (n === 0)\n return {\n sin: 0,\n cos: 1,\n };\n const vec = [(p2x - p1x) / n, (p2y - p1y) / n];\n const cos = vec[0];\n let sin = Math.sqrt(1 - cos * cos);\n sin = vec[1] >= 0 ? -sin : sin;\n return {\n sin: sin,\n cos: cos,\n };\n }\n\n /**\n * @private\n * @param {Array} hull\n * @param {Array} p\n * @param {Bool} topEdge\n */\n __align_hull(hull, p, topEdge) {\n let v = -1;\n let d2;\n for (let i = 0; i < hull.length; ++i) {\n const d = euclidean(hull[i], p);\n if (v === -1) {\n d2 = d;\n v = i;\n } else {\n if (d2 > d) {\n d2 = d;\n v = i;\n }\n }\n }\n\n let v1;\n let v2;\n if (topEdge) {\n v1 = hull[v];\n v2 = hull[(v + 1) % hull.length];\n } else {\n if (v == 0) v = hull.length - 1;\n v1 = hull[v];\n v2 = hull[(v - 1) % hull.length];\n }\n\n const transformation = {\n tx: -hull[v][0],\n ty: -hull[v][1],\n };\n\n if (hull.length >= 2) {\n const { sin, cos } = this.__findAngle(v1, v2);\n transformation.sin = sin;\n transformation.cos = cos;\n } else {\n transformation.sin = 0;\n transformation.cos = 1;\n }\n\n return transformation;\n }\n\n /**\n * @private\n * @param {Array} Point - The point which should get transformed.\n * @param {Object} Transformation - contains the values for translation and rotation.\n */\n __transform([px, py], { tx, ty, sin, cos }) {\n let x = px + tx;\n let y = py + ty;\n let xx = x * cos - y * sin;\n let yy = x * sin + y * cos;\n return [xx, yy];\n }\n\n /**\n * Calls {@link __transform} for each point in Set C\n * @private\n * @param {Array} C - Set of points.\n * @param {Object} t - Transform object.\n * @param {Number} yOffset - value to offset set C.\n */\n __transform_component(C, t, yOffset) {\n const N = C.length;\n for (let i = 0; i < N; ++i) {\n const c = C[i];\n const [cx, cy] = this.__transform(c, t);\n c[0] = cx;\n c[1] = cy + yOffset;\n }\n }\n\n /**\n * @private\n * @param {Array} u - point u\n * @param {Array} v - point v\n * @param {Number} w - edge weight w\n */\n __align_components(u, v, w) {\n const points_u = [...u.__disjoint_set.children];\n const points_v = [...v.__disjoint_set.children];\n\n const hull_u = this.__hull(points_u);\n const hull_v = this.__hull(points_v);\n\n const t_u = this.__align_hull(hull_u, u, false);\n const t_v = this.__align_hull(hull_v, v, true);\n\n this.__transform_component(points_u, t_u, 0);\n this.__transform_component(points_v, t_v, w);\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality 2.\n */\n transform() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n }\n return this.projection;\n }\n\n *generator() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n yield this.projection;\n }\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { PCA, MDS } from \"./index.js\";\nimport { distance_matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias SAMMON\n * @extends DR\n */\nexport class SAMMON extends DR {\n /**\n * SAMMON's Mapping\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias SAMMON\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {\"PCA\"|\"MDS\"|\"random\"} [parameters.init = \"random\"] - Either \"PCA\" or \"MDS\", with which SAMMON initialiates the projection. With \"random\" a random matrix gets used as starting point.\n * @param {Object} [parameters.init_parameters] - Parameters for the {@link init}-DR method.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {SAMMON}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { magic: 0.1, d: 2, metric: euclidean, seed: 1212, init_DR: \"random\", init_parameters: {} }, parameters);\n return this;\n }\n\n /**\n * initializes the projection.\n * @private\n */\n init() {\n const N = this.X.shape[0];\n const { d, metric, init_DR: init_DR, init_parameters: DR_parameters } = this._parameters;\n if (init_DR === \"random\") {\n const randomizer = this._randomizer;\n this.Y = new Matrix(N, d, () => randomizer.random);\n } else if ([\"PCA\", \"MDS\"].includes(init_DR)) {\n this.Y = Matrix.from(init_DR == \"PCA\" ? PCA.transform(this.X, DR_parameters) : MDS.transform(this.X, DR_parameters));\n } else {\n throw new Error('init_DR needs to be either \"random\" or a DR method!')\n }\n this.distance_matrix = metric == \"precomputed\" ? Matrix.from(this.X) : distance_matrix(this.X, metric);\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Matrix|Array} - The projection of {@link X}.\n */\n transform(max_iter = 200) {\n if (!this._is_initialized) this.init();\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n }\n return this.projection;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Generator} - A generator yielding the intermediate steps of the projection of {@link X}.\n */\n *generator(max_iter = 200) {\n if (!this._is_initialized) this.init();\n\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n yield this.projection;\n }\n\n return this.projection;\n }\n\n _step() {\n const MAGIC = this.parameter(\"magic\");\n const D = this.distance_matrix;\n const N = this.X.shape[0];\n const { d, metric } = this._parameters;\n let Y = this.Y;\n\n let G = new Matrix(N, d, 0);\n\n let sum = new Float64Array(d);\n for (let i = 0; i < N; ++i) {\n let e1 = new Float64Array(d);\n let e2 = new Float64Array(d);\n const Yi = Y.row(i);\n for (let j = 0; j < N; ++j) {\n if (i === j) continue;\n const Yj = Y.row(j);\n const delta = new Float64Array(d);\n for (let k = 0; k < d; ++k) {\n delta[k] = Yi[k] - Yj[k];\n }\n const dY = metric(Yi, Yj);\n const dX = D.entry(i, j);\n const dq = dX - dY;\n const dr = Math.max(dX * dY, 1e-2);\n for (let k = 0; k < d; ++k) {\n e1[k] += (delta[k] * dq) / dr;\n e2[k] += (dq - (Math.pow(delta[k], 2) * (1 + dq / dY)) / dY) / dr;\n }\n }\n for (let k = 0; k < d; ++k) {\n const val = Y.entry(i, k) + ((MAGIC * e1[k]) / Math.abs(e2[k]) || 0);\n G.set_entry(i, k, val);\n sum[k] += val;\n }\n }\n for (let k = 0; k < d; ++k) {\n sum[k] /= N;\n }\n\n for (let i = 0; i < N; ++i) {\n for (let k = 0; k < d; ++k) {\n Y.set_entry(i, k, G.entry(i, k) - sum[k]);\n }\n }\n return Y;\n }\n}\n"],"names":["a","b","Math","sqrt","euclidean_squared","summands","y","t","n","length","sum","compensation","i","summand","abs","s","Array","x","neumair_sum","sum_a","sum_b","acos","res","push","max","num_non_zero","num_equal","disagree","num_not_equal","num_true_true","num_true_false","num_false_true","A","k","metric","euclidean","rows","shape","D","distance_matrix","nN","row","from","map","distance","col","j","sort","slice","Matrix","A_i","dist","set_entry","start","end","number","round","result","v","vector","cols","Error","Float64Array","v_norm","norm","value","Q","R","q","q_dot_v","q_","v_","clone","x_norm","x0","entry","rho","sign","u1","u","divide","beta","u_outer_u","outer","R_block","get_block","new_R","sub","dot","mult","Q_block","new_Q","set_block","seed","max_iterations","qr","qr_gramschmidt","tol","randomizer","Randomizer","random","oldQ","QR","values","eigenvalues","diag","eigenvectors","transpose","to2dArray","N","constructor","this","_rows","_cols","_data","static","type","isArray","m","_","data","subarray","iterate_rows","Symbol","iterator","set_row","offset","result_col","T","inverse","B","h","i_max","max_val","Infinity","val","h_val","i_val","f","B_row_row","B_i_j","join","I","B_i","C","e","l","concat","rows_A","cols_A","rows_B","cols_B","X","offset_row","offset_col","start_row","start_col","end_row","end_col","new_row","new_col","gather","row_indices","col_indices","row_index","col_index","_apply_array","_apply_rowwise_array","_apply_colwise_array","_apply","value_rows","value_cols","add","asArray","min_row_col","min","mean","meanRows","meanCols","b_i","r","d","z","alpha","r_next","L","U","LU","L_diag","U_diag","det","M","MT","MtM","MMt","V","Sigma","simultaneous_poweriteration","sigma","_seed","_N","_M","_MATRIX_A","_UPPER_MASK","_LOWER_MASK","_mt","_mti","Date","getTime","mt","mti","random_int","mag01","kk","N_M","M_N","choice","sample","index_list","linspace","random_index","splice","undefined","Heap","elements","accessor","comparator","heapify","_accessor","_container","_comparator","heap","container","element","floor","_heapify_down","_swap","index_a","index_b","_heapify_up","index","parentIndex","node","start_index","left","right","pop","item","first","iterate","toArray","raw_data","empty","DisjointSet","_list","Set","make_set","list","has","__disjoint_set","parent","children","size","find","union","node_x","node_y","forEach","BallTree","_Node","pivot","child1","child2","radius","_Leaf","points","_metric","_root","_construct","c","_greatest_spread","sorted_elements","p_index","p","spread","reduce","acc","current","search","_search","KNN","_elements","_D","distances","H","nearest_element_index","nearest_dist","Number","isInteger","DR","default_parameters","parameters","_parameters","Object","assign","seal","_type","_randomizer","_is_initialized","parameter","name","hasOwnProperty","para","transform","check_init","projection","generator","init","Y","async","args","PCA","super","eig_args","principal_components","means","X_cent","MDS","ai_","a_j","a__","_d_X","stress","d_X","d_Y","top_sum","bottom_sum","pow","ISOMAP","neighbors","kNearestNeighbors","G","other","FASTMAP","_choose_distant_objects","a_index","b_index","max_dist","d_ai","d_bi","_col","old_dist","d_ab","y_i","LDA","labels","unique_labels","label_id","count","id","X_mean","V_mean","label","v_mean","S_b","S_w","row_v","LLE","k_nearest_neighbors","O","W","nN_row","Z","C_trace","w","solve_CG","IW","LTSA","I_i","X_i","g","G_i_t","W_i","TSNE","perplexity","epsilon","_iter","Htarget","log","Delta","druid","P","_ystep","_gains","prow","betamin","betamax","done","num","psum","pj","exp","Hhere","Pout","N2","_P","iterations","next","iter","ystep","gains","dim","pmul","Qu","qsum","dsum","dhere","qu","grad","premult","ymean","gid","sid","gainid","newgain","newsid","max_iter","pfx","fx","convergence","fxi","dx","UMAP","n_neighbors","local_connectivity","min_dist","_spread","_set_op_mix_ratio","_repulsion_strength","_negative_sample_rate","_n_epochs","_initial_alpha","_find_ab_params","xv","yv","xv_i","powell","error","_compute_membership_strengths","sigmas","rhos","_smooth_knn_dist","knn","SMOOTH_K_TOLERANCE","MIN_K_DIST_SCALE","target","log2","reverse","x_i","lo","hi","mid","search_result","non_zero_dist","filter","non_zero_dist_length","interpolation","mean_ithd","mean_d","_fuzzy_simplicial_set","distances_i","transposed_result","prod_matrix","_make_epochs_per_sample","n_epochs","weights","_weights","Float32Array","fill","weights_max","n_samples","_tocoo","graph","rows_n","cols_n","_a","_b","_graph","_head","_tail","_epochs_per_sample","_epochs_per_negative_sample","_epoch_of_next_sample","_epoch_of_next_negative_sample","_clip","_optimize_layout","head_embedding","tail_embedding","head","tail","_alpha","epochs_per_sample","epochs_per_negative_sample","epoch_of_next_negative_sample","epoch_of_next_sample","clip","tail_length","grad_coeff","grad_d","o","n_neg_samples","TriMap","weight_adj","pca","n_inliers","n_outliers","n_random","triplets","_generate_triplets","lr","vel","gain","n_extra","nbrs","knn_distances","sig","_find_p","_sample_knn_triplets","n_triplets","outlier_distances","_find_weights","random_triplets","random_weights","_sample_random_triplets","max_weight","isNaN","max_weight_2","n_i","sort_indices","__argsort","n_j","sim","samples","_rejection_sample","out","max_int","rejects","interval","indexOf","p_sim","p_out","indices","_grad","y_ij","y_ik","d_ij","d_ik","n_viol","loss","n_knn_triplets","Y_id","Y_jd","Y_kd","gs","go","max_iteration","_next","gamma","old_C","_update_embedding","new_gain","Hierarchical_Clustering","matrix","linkage","_id","_matrix","_linkage","root","do","get_clusters","clusters","depth","_traverse","leaves","_n","d_min","_d_min","_distance_matrix","_clusters","c_size","_c_size","Uint16Array","Cluster","p_max","c1","D_i_min","c2","c1_cluster","c2_cluster","c1_cluster_indices","isLeaf","c2_cluster_indices","new_cluster","unshift","D_c1_j","D_c2_j","centroid","_calculate_centroid","l_size","r_size","l_centroid","r_centroid","new_centroid","descendants","left_descendants","right_descendants","KMeans","K","_K","_cluster_centroids","_get_random_centroids","_furthest_point","candidates","Ad","cluster_centroids","random_point","init_points","sample_size","furthest_point","_iteration","clusters_changed","Ai","min_cluster","_compute_centroid","cluster_counter","ci","iteration_result","KMedoids","_A","_max_iter","log10","_cluster_medoids","_get_random_medoids","x_j","_nearest_medoid","index_nearest","medoids","finish","cache","x_o","DeltaTD","xs","findIndex","d_j","distance_nearest","deltaTD","d_oj","_get_distance","d_n","distance_second","d_s","nearest","second","x_m","m1","m2","index_second","cluster_medoids","ceil","TD","TD0","S","S_j","S_o","delta","OPTICS","min_points","_epsilon","_min_points","_ordered_list","_DB","ordered_list","DB","cluster_index","_cluster_index","reachability_distance","processed","_get_neighbors","_core_distance","seeds","_update","_expand_cluster","core_distance","new_reachability_distance","cluster","outliers","get_cluster_affirmation","LSP","control_points","DR_parameters","nc","c_i","Y_C","XA","AT","ATA","ATb","TopoMap","__lazy_distance_matrix","D_ij","_make_minimum_spanning_tree","disjoint_set","F","E","set_u","set_v","_Emst","__hull_cross","ax","ay","bx","by","sx","sy","__hull","x1","y1","x2","y2","lower","upper","__findAngle","p1x","p1y","p2x","p2y","sin","cos","vec","__align_hull","hull","topEdge","d2","v1","v2","transformation","tx","ty","__transform","px","py","__transform_component","yOffset","cx","cy","__align_components","points_u","points_v","hull_u","hull_v","t_u","t_v","Emst","components","component_u","component_v","SAMMON","magic","init_DR","init_parameters","includes","_step","MAGIC","e1","e2","Yi","Yj","dY","dX","dq","dr"],"mappings":";;;;;;;;;AASe,mBAAUA,EAAGC,GACxB,OAAOC,KAAKC,KAAKC,kBAAkBJ,EAAGC;;;;;;;;GCF3B,mBAAUI,GACrB,IAGIC,EAAGC,EAHHC,EAAIH,EAASI,OACbC,EAAM,EACNC,EAAe,EAGnB,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,IAAKI,EACrBN,EAAID,EAASO,GAAKD,EAClBJ,EAAIG,EAAMJ,EACVK,EAAeJ,EAAIG,EAAMJ,EACzBI,EAAMH,EAEV,OAAOG;;;;;;;;GCZI,qBAAUL,GACrB,IAAIG,EAAIH,EAASI,OACbC,EAAM,EACNC,EAAe,EAEnB,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,IAAKI,EAAG,CACxB,IAAIC,EAAUR,EAASO,GACnBL,EAAIG,EAAMG,EACVX,KAAKY,IAAIJ,IAAQR,KAAKY,IAAID,GAC1BF,GAAgBD,EAAMH,EAAIM,EAE1BF,GAAgBE,EAAUN,EAAIG,EAElCA,EAAMH,EAEV,OAAOG,EAAMC;;;;;;;;GCdF,2BAAUX,EAAGC,GACxB,GAAID,EAAES,QAAUR,EAAEQ,OAAQ,OAC1B,IAAID,EAAIR,EAAES,OACNM,EAAI,IAAIC,MAAMR,GAClB,IAAK,IAAII,EAAI,EAAGA,EAAIJ,IAAKI,EAAG,CACxB,IAAIK,EAAIjB,EAAEY,GACNN,EAAIL,EAAEW,GACVG,EAAEH,IAAMK,EAAIX,IAAMW,EAAIX,GAE1B,OAAOY,YAAYH;;;;;;;;;;GCRR,gBAAUf,EAAGC,GACxB,GAAID,EAAES,SAAWR,EAAEQ,OAAQ,OAC3B,IAAID,EAAIR,EAAES,OACNC,EAAM,EACNS,EAAQ,EACRC,EA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GAAKvB,EAAIuB,IAG9C,OAAO6R"} \ No newline at end of file +{"version":3,"file":"druid.esm.js","sources":["../metrics/euclidean.js","../numerical/kahan_sum.js","../numerical/neumair_sum.js","../metrics/euclidean_squared.js","../metrics/cosine.js","../metrics/manhattan.js","../metrics/chebyshev.js","../metrics/canberra.js","../metrics/jaccard.js","../metrics/hamming.js","../metrics/sokal_michener.js","../metrics/yule.js","../matrix/k_nearest_neighbors.js","../matrix/distance_matrix.js","../matrix/linspace.js","../matrix/norm.js","../matrix/normalize.js","../linear_algebra/qr.js","../linear_algebra/qr_householder.js","../linear_algebra/simultaneous_poweriteration.js","../linear_algebra/inner_product.js","../matrix/Matrix.js","../util/randomizer.js","../util/max.js","../util/min.js","../datastructure/Heap.js","../datastructure/DisjointSet.js","../knn/BallTree.js","../knn/KNN.js","../dimred/DR.js","../dimred/PCA.js","../dimred/MDS.js","../dimred/ISOMAP.js","../dimred/FASTMAP.js","../dimred/LDA.js","../dimred/LLE.js","../dimred/LTSA.js","../dimred/TSNE.js","../optimization/powell.js","../dimred/UMAP.js","../dimred/TriMap.js","../clustering/Hierarchical_Clustering.js","../clustering/KMeans.js","../clustering/KMedoids.js","../clustering/OPTICS.js","../dimred/LSP.js","../dimred/TopoMap.js","../dimred/SAMMON.js"],"sourcesContent":["import { euclidean_squared } from \"../metrics/index.js\";\n/**\n * Computes the euclidean distance (l2) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n return Math.sqrt(euclidean_squared(a, b));\n}\n","/**\n * Numerical stable summation with the Kahan summation algorithm.\n * @memberof module:numerical\n * @alias kahan_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n let y, t;\n\n for (let i = 0; i < n; ++i) {\n y = summands[i] - compensation;\n t = sum + y;\n compensation = t - sum - y;\n sum = t;\n }\n return sum;\n}\n","/**\n * Numerical stable summation with the Neumair summation algorithm.\n * @memberof module:numerical\n * @alias neumair_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm#Further_enhancements}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n\n for (let i = 0; i < n; ++i) {\n let summand = summands[i];\n let t = sum + summand;\n if (Math.abs(sum) >= Math.abs(summand)) {\n compensation += sum - t + summand;\n } else {\n compensation += summand - t + sum;\n }\n sum = t;\n }\n return sum + compensation;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n/**\n * Computes the squared euclidean distance (l22) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean_squared\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the squared euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let s = new Array(n);\n for (let i = 0; i < n; ++i) {\n let x = a[i];\n let y = b[i];\n s[i] = (x - y) * (x - y);\n }\n return neumair_sum(s);\n}\n","/**\n * Computes the cosine distance (not similarity) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias cosine\n * @param {Array} a\n * @param {Array} b\n * @example\n * druid.cosine([1,0],[1,1]) == 0.7853981633974484 == π/4\n * @returns {Number} The cosine distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n let sum_a = 0;\n let sum_b = 0;\n for (let i = 0; i < n; ++i) {\n sum += a[i] * b[i];\n sum_a += a[i] * a[i];\n sum_b += b[i] * b[i];\n }\n return Math.acos(sum / (Math.sqrt(sum_a) * Math.sqrt(sum_b)));\n}\n","/**\n * Computes the manhattan distance (l1) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias manhattan\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the manhattan distance between {@link a} and {@link b}.\n */ \nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += Math.abs(a[i] - b[i]);\n }\n return sum;\n}\n","/**\n * Computes the chebyshev distance (L) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias chebyshev\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the chebyshev distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let res = [];\n for (let i = 0; i < n; ++i) {\n res.push(Math.abs(a[i] - b[i]));\n }\n return Math.max(...res);\n}\n","/**\n * Computes the canberra distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias canberra\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} The canberra distance between {@link a} and {@link b}.\n * @see {@link https://en.wikipedia.org/wiki/Canberra_distance}\n */\nexport default function(a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += (Math.abs(a[i] - b[i]) / (Math.abs(a[i]) + Math.abs(b[i])))\n }\n return sum;\n}","/**\n * Computes the jaccard distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias jaccard\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the jaccard distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_non_zero = 0;\n let num_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_non_zero += x || y;\n num_equal += x && y;\n }\n return (num_non_zero - num_equal) / num_non_zero;\n}\n","/**\n * Computes the hamming distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias hamming\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the hamming distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let disagree = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i];\n const y = b[i];\n disagree += x != y;\n }\n return disagree / n;\n}\n","/**\n * Computes the Sokal-Michener distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias sokal_michener\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} the Sokal-Michener distance between {@link a} and {@link b}. \n */\nexport default function(a, b) {\n if (a.length != b.length) return undefined\n const n = a.length;\n let num_not_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_not_equal += x != y;\n }\n return (2 * num_not_equal) / (n + num_not_equal);\n}","/**\n * Computes the yule distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias yule\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the yule distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_true_true = 0;\n let num_true_false = 0;\n let num_false_true = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_true_true += x && y;\n num_true_false += x && !y;\n num_false_true += !x && x;\n }\n const num_false_false = n - num_true_true - num_true_false - num_false_true;\n return num_true_false == 0 || num_false_true == 0 ? 0 : (2 * num_true_false * num_false_true) / (num_true_true * num_false_false + num_true_false * num_false_true);\n}\n","import { distance_matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Computes the k-nearest neighbors of each row of {@link A}.\n * @memberof module:matrix\n * @alias k_nearest_neigbhors\n * @param {Matrix} A - Either the data matrix, or a distance matrix.\n * @param {Number} k - The number of neighbors to compute.\n * @param {Function|\"precomputed\"} [metric=euclidean]\n * @returns {Array} -\n */\nexport default function (A, k, metric = euclidean) {\n const rows = A.shape[0];\n let D = metric == \"precomputed\" ? A : distance_matrix(A, metric);\n let nN = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n nN[row] = Array.from(D.row(row))\n .map((distance, col) => {\n return {\n i: row,\n j: col,\n distance: distance,\n };\n })\n .sort((a, b) => a.distance - b.distance)\n .slice(1, k + 1);\n }\n return nN;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"./index.js\";\n\n/**\n * Computes the distance matrix of datamatrix {@link A}.\n * @memberof module:matrix\n * @alias distance_matrix\n * @param {Matrix} A - Matrix.\n * @param {Function} [metric=euclidean] - The diistance metric.\n * @returns {Matrix} D - The distance matrix of {@link A}.\n */\nexport default function (A, metric = euclidean) {\n let n = A.shape[0];\n const D = new Matrix(n, n);\n for (let i = 0; i < n; ++i) {\n const A_i = A.row(i);\n for (let j = i + 1; j < n; ++j) {\n const dist = metric(A_i, A.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n }\n }\n return D;\n}\n","/**\n * Creates an Array containing {@link number} numbers from {@link start} to {@link end}.\n * If {@link number} = null.\n * @memberof module:matrix\n * @alias linspace\n * @param {Number} start - Start value.\n * @param {Number} end - End value.\n * @param {Number} [number = null] - Number of number between {@link start} and {@link end}.\n * @returns {Array} - An array with {@link number} entries, beginning at {@link start} ending at {@link end}.\n */\nexport default function (start, end, number = null) {\n if (!number) {\n number = Math.max(Math.round(end - start) + 1, 1);\n }\n if (number < 2) {\n return number === 1 ? [start] : [];\n }\n let result = new Array(number);\n number -= 1;\n for (let i = number; i >= 0; --i) {\n result[i] = (i * end + (number - i) * start) / number;\n }\n return result;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n//import { neumair_sum } from \"../numerical/index\";\n\n/**\n * Computes the norm of a vector, by computing its distance to **0**.\n * @memberof module:matrix\n * @alias norm\n * @param {Matrix|Array|Float64Array} v - Vector. \n * @param {Function} [metric = euclidean] - Which metric should be used to compute the norm.\n * @returns {Number} - The norm of {@link v}.\n */\nexport default function (v, metric = euclidean) {\n let vector = null;\n if (v instanceof Matrix) {\n let [rows, cols] = v.shape;\n if (rows === 1) vector = v.row(0);\n else if (cols === 1) vector = v.col(0);\n else throw new Error(\"Matrix must be 1d!\");\n } else {\n vector = v;\n }\n const n = vector.length;\n const zeros = Float64Array.from({ length: n }, () => 0);\n return metric(vector, zeros);\n}\n","import { norm } from \"./index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Normalizes Vector {@link v}.\n * @memberof module:matrix\n * @alias normalize\n * @param {Array|Float64Array} v - Vector\n * @param {Function} metric \n * @returns {Array|Float64Array} - The normalized vector with length 1.\n */\nexport default function(v, metric = euclidean) {\n const v_norm = norm(v, metric);\n return v.map(value => value / v_norm);\n}","import { Matrix, norm } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} using Gram-Schmidt process.\n * @memberof module:linear_algebra\n * @alias qr\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_the_Gram%E2%80%93Schmidt_process}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, cols, \"identity\");\n const R = new Matrix(cols, cols, 0);\n\n for (let j = 0; j < cols; ++j) {\n let v = A.col(j);\n for (let i = 0; i < j; ++i) {\n const q = Q.col(i);\n const q_dot_v = neumair_sum(q.map((q_, k) => q_ * v[k]));\n R.set_entry(i, j, q_dot_v);\n v = v.map((v_, k) => v_ - q_dot_v * q[k]);\n }\n const v_norm = norm(v, euclidean);\n for (let k = 0; k < rows; ++k) {\n Q.set_entry(k, j, v[k] / v_norm);\n }\n R.set_entry(j, j, v_norm);\n }\n return { R, Q };\n}\n","import { Matrix, norm } from \"../matrix/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} with householder transformations.\n * @memberof module:linear_algebra\n * @alias qr_householder\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections}\n * @see {@link http://mlwiki.org/index.php/Householder_Transformation}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, rows, \"I\");\n const R = A.clone();\n\n for (let j = 0; j < cols; ++j) {\n const x = Matrix.from(R.col(j).slice(j));\n const x_norm = norm(x);\n const x0 = x.entry(0, 0);\n const rho = -Math.sign(x0);\n const u1 = x0 - rho * x_norm;\n const u = x.divide(u1).set_entry(0, 0, 1);\n const beta = (-rho * u1) / x_norm;\n\n const u_outer_u = u.outer(u);\n const R_block = R.get_block(j, 0);\n const new_R = R_block.sub(u_outer_u.dot(R_block).mult(beta));\n const Q_block = Q.get_block(0, j);\n const new_Q = Q_block.sub(Q_block.dot(u_outer_u).mult(beta));\n R.set_block(j, 0, new_R);\n Q.set_block(0, j, new_Q);\n }\n return { R, Q };\n}\n","import { qr as qr_gramschmidt } from \"./index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { euclidean_squared } from \"../metrics/index.js\";\n\n/**\n * Computes the {@link k} biggest Eigenvectors and Eigenvalues from Matrix {@link A} with the QR-Algorithm.\n * @memberof module:linear_algebra\n * @alias simultaneous_poweriteration\n * @param {Matrix} A - The Matrix\n * @param {Number} k - The number of eigenvectors and eigenvalues to compute.\n * @param {Object} parameters - Object containing parameterization of the simultanious poweriteration method.\n * @param {Number} [parameters.max_iterations=100] - The number of maxiumum iterations the algorithm should run.\n * @param {Number|Randomizer} [parameters.seed=1212] - The seed value or a randomizer used in the algorithm.\n * @param {Function} [parameters.qr=qr_gramschmidt] - The QR technique to use.\n * @param {Number} [parameters.tol=1e-8] - Allowed error for stopping criteria\n * @returns {{eigenvalues: Array, eigenvectors: Array}} - The {@link k} biggest eigenvectors and eigenvalues of Matrix {@link A}.\n */\nexport default function (A, k = 2, {seed = 1212, max_iterations = 100, qr = qr_gramschmidt, tol = 1e-8} = {}) {\n const randomizer = seed instanceof Randomizer ? seed : new Randomizer(seed);\n if (!(A instanceof Matrix)) A = Matrix.from(A);\n const n = A.shape[0];\n let { Q, R } = qr(new Matrix(n, k, () => (randomizer.random - .5) * 2));\n while (max_iterations--) {\n const oldQ = Q.clone();\n const Z = A.dot(Q);\n const QR = qr(Z);\n Q = QR.Q;\n R = QR.R;\n const error = euclidean_squared(Q.values, oldQ.values);\n if (error < tol) {\n break;\n }\n }\n\n const eigenvalues = R.diag;\n const eigenvectors = Q.transpose().to2dArray;\n return { eigenvalues, eigenvectors };\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the inner product between two arrays of the same length.\n * @memberof module:linear_algebra\n * @alias inner_product\n * @param {Array|Float64Array} a - Array a\n * @param {Array|Float64Array} b - Array b\n * @returns The inner product between {@link a} and {@link b}\n */\nexport default function (a, b) {\n const N = a.length;\n if (N != b.length) {\n throw new Error(\"Array a and b must have the same length!\")\n }\n let sum = 0;\n for (let i = 0; i < N; ++i) {\n sum += a * b;\n }\n return sum;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n/**\n * @class\n * @alias Matrix\n * @requires module:numerical/neumair_sum\n */\nexport class Matrix {\n /**\n * creates a new Matrix. Entries are stored in a Float64Array.\n * @constructor\n * @memberof module:matrix\n * @alias Matrix\n * @param {number} rows - The amount of rows of the matrix.\n * @param {number} cols - The amount of columns of the matrix.\n * @param {(function|string|number)} value=0 - Can be a function with row and col as parameters, a number, or \"zeros\", \"identity\" or \"I\", or \"center\".\n * - **function**: for each entry the function gets called with the parameters for the actual row and column.\n * - **string**: allowed are\n * - \"zero\", creates a zero matrix.\n * - \"identity\" or \"I\", creates an identity matrix.\n * - \"center\", creates an center matrix.\n * - **number**: create a matrix filled with the given value.\n * @example\n *\n * let A = new Matrix(10, 10, () => Math.random()); //creates a 10 times 10 random matrix.\n * let B = new Matrix(3, 3, \"I\"); // creates a 3 times 3 identity matrix.\n * @returns {Matrix} returns a {@link rows} times {@link cols} Matrix filled with {@link value}.\n */\n constructor(rows = null, cols = null, value = null) {\n this._rows = rows;\n this._cols = cols;\n this._data = null;\n if (rows && cols) {\n if (!value) {\n this._data = new Float64Array(rows * cols);\n return this;\n }\n if (typeof value === \"function\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n if (typeof value === \"string\") {\n if (value === \"zeros\") {\n return new Matrix(rows, cols, 0);\n }\n if (value === \"identity\" || value === \"I\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n this._data[row * cols + row] = 1;\n }\n return this;\n }\n if (value === \"center\" && rows == cols) {\n this._data = new Float64Array(rows * cols);\n value = (i, j) => (i === j ? 1 : 0) - 1 / rows;\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n }\n if (typeof value === \"number\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value;\n }\n }\n return this;\n }\n }\n return this;\n }\n\n /**\n * Creates a Matrix out of {@link A}.\n * @param {(Matrix|Array|Float64Array|number)} A - The matrix, array, or number, which should converted to a Matrix.\n * @param {\"row\"|\"col\"|\"diag\"} [type = \"row\"] - If {@link A} is a Array or Float64Array, then type defines if it is a row- or a column vector.\n * @returns {Matrix}\n *\n * @example\n * let A = Matrix.from([[1, 0], [0, 1]]); //creates a two by two identity matrix.\n * let S = Matrix.from([1, 2, 3], \"diag\"); // creates a 3 by 3 matrix with 1, 2, 3 on its diagonal. [[1, 0, 0], [0, 2, 0], [0, 0, 3]]\n */\n static from(A, type = \"row\") {\n if (A instanceof Matrix) {\n return A.clone();\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let m = A.length;\n if (m === 0) throw new Error(\"Array is empty\");\n // 1d\n if (!Array.isArray(A[0]) && !(A[0] instanceof Float64Array)) {\n if (type === \"row\") {\n return new Matrix(1, m, (_, j) => A[j]);\n } else if (type === \"col\") {\n return new Matrix(m, 1, (i) => A[i]);\n } else if (type === \"diag\") {\n return new Matrix(m, m, (i, j) => (i == j ? A[i] : 0));\n } else {\n throw new Error(\"1d array has NaN entries\");\n }\n // 2d\n } else if (Array.isArray(A[0]) || A[0] instanceof Float64Array) {\n let n = A[0].length;\n for (let row = 0; row < m; ++row) {\n if (A[row].length !== n) {\n throw new Error(\"various array lengths\");\n }\n }\n return new Matrix(m, n, (i, j) => A[i][j]);\n }\n } else if (typeof A === \"number\") {\n return new Matrix(1, 1, A);\n } else {\n throw new Error(\"error\");\n }\n }\n\n /**\n * Returns the {@link row}th row from the Matrix.\n * @param {Number} row\n * @returns {Float64Array}\n */\n row(row) {\n const data = this.values;\n const cols = this._cols;\n return data.subarray(row * cols, (row + 1) * cols);\n }\n\n /**\n * Returns an generator yielding each row of the Matrix.\n * @yields {Float64Array}\n */\n *iterate_rows() {\n const cols = this._cols;\n const rows = this._rows;\n const data = this.values;\n for (let row = 0; row < rows; ++row) {\n yield data.subarray(row * cols, (row + 1) * cols);\n }\n }\n\n /**\n * Makes a {@link Matrix} object an iterable object.\n * @yields {Float64Array}\n */\n *[Symbol.iterator]() {\n for (const row of this.iterate_rows()) {\n yield row;\n }\n }\n\n /**\n * Sets the entries of {@link row}th row from the Matrix to the entries from {@link values}.\n * @param {int} row\n * @param {Array} values\n * @returns {Matrix}\n */\n set_row(row, values) {\n let cols = this._cols;\n if (Array.isArray(values) && values.length === cols) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values[col];\n }\n } else if (values instanceof Matrix && values.shape[1] === cols && values.shape[0] === 1) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values._data[col];\n }\n }\n return this;\n }\n\n /**\n * Returns the {@link col}th column from the Matrix.\n * @param {int} col\n * @returns {Array}\n */\n col(col) {\n let result_col = new Float64Array(this._rows);\n for (let row = 0; row < this._rows; ++row) {\n result_col[row] = this.values[row * this._cols + col];\n }\n return result_col;\n }\n\n /**\n * Returns the {@link col}th entry from the {@link row}th row of the Matrix.\n * @param {int} row\n * @param {int} col\n * @returns {float64}\n */\n entry(row, col) {\n return this.values[row * this._cols + col];\n }\n\n /**\n * Sets the {@link col}th entry from the {@link row}th row of the Matrix to the given {@link value}.\n * @param {int} row\n * @param {int} col\n * @param {float64} value\n * @returns {Matrix}\n */\n set_entry(row, col, value) {\n this.values[row * this._cols + col] = value;\n return this;\n }\n\n /**\n * Returns a new transposed Matrix.\n * @returns {Matrix}\n */\n transpose() {\n let B = new Matrix(this._cols, this._rows, (row, col) => this.entry(col, row));\n return B;\n }\n\n /**\n * Returns a new transposed Matrix. Short-form of {@function transpose}.\n * @returns {Matrix}\n */\n get T() {\n return this.transpose();\n }\n\n /**\n * Returns the inverse of the Matrix.\n * @returns {Matrix}\n */\n inverse() {\n const rows = this._rows;\n const cols = this._cols;\n let B = new Matrix(rows, 2 * cols, (i, j) => {\n if (j >= cols) {\n return i === j - cols ? 1 : 0;\n } else {\n return this.entry(i, j);\n }\n });\n let h = 0;\n let k = 0;\n while (h < rows && k < cols) {\n var i_max = 0;\n let max_val = -Infinity;\n for (let i = h; i < rows; ++i) {\n let val = Math.abs(B.entry(i, k));\n if (max_val < val) {\n i_max = i;\n max_val = val;\n }\n }\n if (B.entry(i_max, k) == 0) {\n k++;\n } else {\n // swap rows\n for (let j = 0; j < 2 * cols; ++j) {\n let h_val = B.entry(h, j);\n let i_val = B.entry(i_max, j);\n B.set_entry(h, j, h_val);\n B.set_entry(i_max, j, i_val);\n }\n for (let i = h + 1; i < rows; ++i) {\n let f = B.entry(i, k) / B.entry(h, k);\n B.set_entry(i, k, 0);\n for (let j = k + 1; j < 2 * cols; ++j) {\n B.set_entry(i, j, B.entry(i, j) - B.entry(h, j) * f);\n }\n }\n h++;\n k++;\n }\n }\n\n for (let row = 0; row < rows; ++row) {\n let f = B.entry(row, row);\n for (let col = row; col < 2 * cols; ++col) {\n B.set_entry(row, col, B.entry(row, col) / f);\n }\n }\n\n for (let row = rows - 1; row >= 0; --row) {\n let B_row_row = B.entry(row, row);\n for (let i = 0; i < row; i++) {\n let B_i_row = B.entry(i, row);\n let f = B_i_row / B_row_row;\n for (let j = i; j < 2 * cols; ++j) {\n let B_i_j = B.entry(i, j);\n let B_row_j = B.entry(row, j);\n B_i_j = B_i_j - B_row_j * f;\n B.set_entry(i, j, B_i_j);\n }\n }\n }\n\n return new Matrix(rows, cols, (i, j) => B.entry(i, j + cols));\n }\n\n /**\n * Returns the dot product. If {@link B} is an Array or Float64Array then an Array gets returned. If {@link B} is a Matrix then a Matrix gets returned.\n * @param {(Matrix|Array|Float64Array)} B the right side\n * @returns {(Matrix|Array)}\n */\n dot(B) {\n if (B instanceof Matrix) {\n let A = this;\n if (A.shape[1] !== B.shape[0]) {\n throw new Error(`A.dot(B): A is a ${A.shape.join(\" ⨯ \")}-Matrix, B is a ${B.shape.join(\" ⨯ \")}-Matrix: \n A has ${A.shape[1]} cols and B ${B.shape[0]} rows. \n Must be equal!`);\n }\n let I = A.shape[1];\n let C = new Matrix(A.shape[0], B.shape[1], (row, col) => {\n const A_i = A.row(row);\n const B_i = B.col(col);\n let sum = 0;\n for (let i = 0; i < I; ++i) {\n sum += A_i[i] * B_i[i];\n }\n return sum;\n });\n return C;\n } else if (Array.isArray(B) || B instanceof Float64Array) {\n let rows = this._rows;\n if (B.length !== rows) {\n throw new Error(`A.dot(B): A has ${rows} cols and B has ${B.length} rows. Must be equal!`);\n }\n let C = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n C[row] = neumair_sum(this.row(row).map((e) => e * B[row]));\n }\n return C;\n } else {\n throw new Error(`B must be Matrix or Array`);\n }\n }\n\n /**\n * Computes the outer product from {@link this} and {@link B}.\n * @param {Matrix} B\n * @returns {Matrix}\n */\n outer(B) {\n let A = this;\n let l = A._data.length;\n let r = B._data.length;\n if (l != r) return undefined;\n let C = new Matrix();\n C.shape = [\n l,\n l,\n (i, j) => {\n if (i <= j) {\n return A._data[i] * B._data[j];\n } else {\n return C.entry(j, i);\n }\n },\n ];\n return C;\n }\n\n /**\n * Appends matrix {@link B} to the matrix.\n * @param {Matrix} B - matrix to append.\n * @param {\"horizontal\"|\"vertical\"|\"diag\"} [type = \"horizontal\"] - type of concatenation.\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 1], [1, 1]]); // 2 by 2 matrix filled with ones.\n * let B = Matrix.from([[2, 2], [2, 2]]); // 2 by 2 matrix filled with twos.\n *\n * A.concat(B, \"horizontal\"); // 2 by 4 matrix. [[1, 1, 2, 2], [1, 1, 2, 2]]\n * A.concat(B, \"vertical\"); // 4 by 2 matrix. [[1, 1], [1, 1], [2, 2], [2, 2]]\n * A.concat(B, \"diag\"); // 4 by 4 matrix. [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 2, 2], [0, 0, 2, 2]]\n */\n concat(B, type = \"horizontal\") {\n const A = this;\n const [rows_A, cols_A] = A.shape;\n const [rows_B, cols_B] = B.shape;\n if (type == \"horizontal\") {\n if (rows_A != rows_B) {\n throw new Error(`A.concat(B, \"horizontal\"): A and B need same number of rows, A has ${rows_A} rows, B has ${rows_B} rows.`);\n }\n const X = new Matrix(rows_A, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(0, cols_A, B);\n return X;\n } else if (type == \"vertical\") {\n if (cols_A != cols_B) {\n throw new Error(`A.concat(B, \"vertical\"): A and B need same number of columns, A has ${cols_A} columns, B has ${cols_B} columns.`);\n }\n const X = new Matrix(rows_A + rows_B, cols_A, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, 0, B);\n return X;\n } else if (type == \"diag\") {\n const X = new Matrix(rows_A + rows_B, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, cols_A, B);\n return X;\n } else {\n throw new Error(`type must be \"horizontal\" or \"vertical\", but type is ${type}!`);\n }\n }\n\n /**\n * Writes the entries of B in A at an offset position given by {@link offset_row} and {@link offset_col}.\n * @param {int} offset_row\n * @param {int} offset_col\n * @param {Matrix} B\n * @returns {Matrix}\n */\n set_block(offset_row, offset_col, B) {\n let [rows, cols] = B.shape;\n for (let row = 0; row < rows; ++row) {\n if (row > this._rows) {\n continue;\n }\n for (let col = 0; col < cols; ++col) {\n if (col > this._cols) {\n continue;\n }\n this.set_entry(row + offset_row, col + offset_col, B.entry(row, col));\n }\n }\n return this;\n }\n\n /**\n * Extracts the entries from the {@link start_row}th row to the {@link end_row}th row, the {@link start_col}th column to the {@link end_col}th column of the matrix.\n * If {@link end_row} or {@link end_col} is empty, the respective value is set to {@link this.rows} or {@link this.cols}.\n * @param {Number} start_row\n * @param {Number} start_col\n * @param {Number} [end_row = null]\n * @param {Number} [end_col = null]\n * @returns {Matrix} Returns a end_row - start_row times end_col - start_col matrix, with respective entries from the matrix.\n * @example\n *\n * let A = Matrix.from([[1, 2, 3], [4, 5, 6], [7, 8, 9]]); // a 3 by 3 matrix.\n *\n * A.get_block(1, 1); // [[5, 6], [8, 9]]\n * A.get_block(0, 0, 1, 1); // [[1]]\n * A.get_block(1, 1, 2, 2); // [[5]]\n * A.get_block(0, 0, 2, 2); // [[1, 2], [4, 5]]\n */\n get_block(start_row, start_col, end_row = null, end_col = null) {\n const [rows, cols] = this.shape;\n end_row = end_row ?? rows;\n end_col = end_col ?? cols;\n if (end_row <= start_row || end_col <= start_col) {\n throw new Error(`\n end_row must be greater than start_row, and \n end_col must be greater than start_col, but\n end_row = ${end_row}, start_row = ${start_row}, end_col = ${end_col}, and start_col = ${start_col}!`);\n }\n const X = new Matrix(end_row - start_row, end_col - start_col, \"zeros\");\n for (let row = start_row, new_row = 0; row < end_row; ++row, ++new_row) {\n for (let col = start_col, new_col = 0; col < end_col; ++col, ++new_col) {\n X.set_entry(new_row, new_col, this.entry(row, col));\n }\n }\n return X;\n //return new Matrix(end_row - start_row, end_col - start_col, (i, j) => this.entry(i + start_row, j + start_col));\n }\n\n /**\n * Returns a new array gathering entries defined by the indices given by argument.\n * @param {Array} row_indices - Array consists of indices of rows for gathering entries of this matrix\n * @param {Array} col_indices - Array consists of indices of cols for gathering entries of this matrix\n * @returns {Matrix}\n */\n gather(row_indices, col_indices) {\n const N = row_indices.length;\n const D = col_indices.length;\n\n const R = new Matrix(N, D);\n for (let i = 0; i < N; ++i) {\n const row_index = row_indices[i];\n for (let j = 0; j < N; ++j) {\n const col_index = col_indices[j];\n R.set_entry(i, j, this.entry(row_index, col_index));\n }\n }\n\n return R;\n }\n\n /**\n * Applies a function to each entry of the matrix.\n * @private\n * @param {function} f function takes 2 parameters, the value of the actual entry and a value given by the function {@link v}. The result of {@link f} gets writen to the Matrix.\n * @param {function} v function takes 2 parameters for row and col, and returns a value witch should be applied to the colth entry of the rowth row of the matrix.\n */\n _apply_array(f, v) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], v(row, col));\n }\n }\n return this;\n }\n\n _apply_rowwise_array(values, f) {\n return this._apply_array(f, (_, j) => values[j]);\n }\n\n _apply_colwise_array(values, f) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], values[row]);\n }\n }\n return this;\n }\n\n _apply(value, f) {\n let data = this.values;\n if (value instanceof Matrix) {\n let [value_rows, value_cols] = value.shape;\n let [rows, cols] = this.shape;\n if (value_rows === 1) {\n if (cols !== value_cols) {\n throw new Error(`cols !== value_cols`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(0, col));\n }\n }\n } else if (value_cols === 1) {\n if (rows !== value_rows) {\n throw new Error(`rows !== value_rows`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, 0));\n }\n }\n } else if (rows == value_rows && cols == value_cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, col));\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else if (Array.isArray(value)) {\n let rows = this._rows;\n let cols = this._cols;\n if (value.length === rows) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[row]);\n }\n }\n } else if (value.length === cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[col]);\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else {\n for (let i = 0, n = this._rows * this._cols; i < n; ++i) {\n data[i] = f(data[i], value);\n }\n }\n return this;\n }\n\n /**\n * Clones the Matrix.\n * @returns {Matrix}\n */\n clone() {\n let B = new Matrix();\n B._rows = this._rows;\n B._cols = this._cols;\n B._data = this.values.slice(0);\n return B;\n }\n\n /**\n * Entrywise multiplication with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.mult(2); // [[2, 4], [6, 8]];\n * A.mult(B); // [[1, 4], [9, 16]];\n */\n mult(value) {\n return this.clone()._apply(value, (a, b) => a * b);\n }\n\n /**\n * Entrywise division with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.divide(2); // [[0.5, 1], [1.5, 2]];\n * A.divide(B); // [[1, 1], [1, 1]];\n */\n divide(value) {\n return this.clone()._apply(value, (a, b) => a / b);\n }\n\n /**\n * Entrywise addition with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.add(2); // [[3, 4], [5, 6]];\n * A.add(B); // [[2, 4], [6, 8]];\n */\n add(value) {\n return this.clone()._apply(value, (a, b) => a + b);\n }\n\n /**\n * Entrywise subtraction with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.sub(2); // [[-1, 0], [1, 2]];\n * A.sub(B); // [[0, 0], [0, 0]];\n */\n sub(value) {\n return this.clone()._apply(value, (a, b) => a - b);\n }\n\n /**\n * Returns the number of rows and columns of the Matrix.\n * @returns {Array} An Array in the form [rows, columns].\n */\n get shape() {\n return [this._rows, this._cols];\n }\n\n /**\n * Returns the matrix in the given shape with the given function which returns values for the entries of the matrix.\n * @param {Array} parameter - takes an Array in the form [rows, cols, value], where rows and cols are the number of rows and columns of the matrix, and value is a function which takes two parameters (row and col) which has to return a value for the colth entry of the rowth row.\n * @returns {Matrix}\n */\n set shape([rows, cols, value = () => 0]) {\n this._rows = rows;\n this._cols = cols;\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n\n /**\n * Returns the Matrix as a Array of Float64Arrays.\n * @returns {Array}\n */\n get to2dArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(row);\n }\n return result;\n }\n\n /**\n * Returns the Matrix as a Array of Arrays.\n * @returns {Array}\n */\n get asArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(Array.from(row));\n }\n return result;\n }\n\n /**\n * Returns the diagonal of the Matrix.\n * @returns {Float64Array}\n */\n get diag() {\n const rows = this._rows;\n const cols = this._cols;\n const min_row_col = Math.min(rows, cols);\n let result = new Float64Array(min_row_col);\n for (let i = 0; i < min_row_col; ++i) {\n result[i] = this.entry(i, i);\n }\n return result;\n }\n\n /**\n * Returns the mean of all entries of the Matrix.\n * @returns {Number}\n */\n get mean() {\n const sum = this.sum;\n const n = this._rows * this._cols;\n return sum / n;\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Number}\n */\n get sum() {\n const data = this.values;\n return neumair_sum(data);\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Float64Array}\n */\n get values() {\n const data = this._data;\n return data;\n }\n\n /**\n * Returns the mean of each row of the matrix.\n * @returns {Float64Array}\n */\n get meanRows() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: rows });\n for (let row = 0; row < rows; ++row) {\n result[row] = 0;\n for (let col = 0; col < cols; ++col) {\n result[row] += data[row * cols + col];\n }\n result[row] /= cols;\n }\n return result;\n }\n\n /** Returns the mean of each column of the matrix.\n * @returns {Float64Array}\n */\n get meanCols() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: cols });\n for (let col = 0; col < cols; ++col) {\n result[col] = 0;\n for (let row = 0; row < rows; ++row) {\n result[col] += data[row * cols + col];\n }\n result[col] /= rows;\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b} using the conjugate gradient method. Returns the result x.\n * @param {Matrix} A - Matrix\n * @param {Matrix} b - Matrix\n * @param {Randomizer} [randomizer=null]\n * @param {Number} [tol=1e-3]\n * @returns {Matrix}\n */\n static solve_CG(A, b, randomizer, tol = 1e-3) {\n if (randomizer === null) {\n randomizer = new Randomizer();\n }\n const rows = A.shape[0];\n const cols = b.shape[1];\n let result = new Matrix(rows, 0);\n for (let i = 0; i < cols; ++i) {\n const b_i = Matrix.from(b.col(i)).T;\n let x = new Matrix(rows, 1, () => randomizer.random);\n let r = b_i.sub(A.dot(x));\n let d = r.clone();\n do {\n const z = A.dot(d);\n const alpha = r.T.dot(r).entry(0, 0) / d.T.dot(z).entry(0, 0);\n x = x.add(d.mult(alpha));\n const r_next = r.sub(z.mult(alpha));\n const beta = r_next.T.dot(r_next).entry(0, 0) / r.T.dot(r).entry(0, 0);\n d = r_next.add(d.mult(beta));\n r = r_next;\n } while (Math.abs(r.mean) > tol);\n result = result.concat(x, \"horizontal\");\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b}. Returns the result x.\n * @param {Matrix} A - Matrix or LU Decomposition\n * @param {Matrix} b - Matrix\n * @returns {Matrix}\n */\n static solve(A, b) {\n let { L: L, U: U } = \"L\" in A && \"U\" in A ? A : Matrix.LU(A);\n let rows = L.shape[0];\n let x = b.clone();\n\n // forward\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < row - 1; ++col) {\n x.set_entry(0, row, x.entry(0, row) - L.entry(row, col) * x.entry(1, col));\n }\n x.set_entry(0, row, x.entry(0, row) / L.entry(row, row));\n }\n\n // backward\n for (let row = rows - 1; row >= 0; --row) {\n for (let col = rows - 1; col > row; --col) {\n x.set_entry(0, row, x.entry(0, row) - U.entry(row, col) * x.entry(0, col));\n }\n x.set_entry(0, row, x.entry(0, row) / U.entry(row, row));\n }\n\n return x;\n }\n\n /**\n * {@link L}{@link U} decomposition of the Matrix {@link A}. Creates two matrices, so that the dot product LU equals A.\n * @param {Matrix} A\n * @returns {{L: Matrix, U: Matrix}} result - Returns the left triangle matrix {@link L} and the upper triangle matrix {@link U}.\n */\n static LU(A) {\n const rows = A.shape[0];\n const L = new Matrix(rows, rows, \"zeros\");\n const U = new Matrix(rows, rows, \"identity\");\n\n for (let j = 0; j < rows; ++j) {\n for (let i = j; i < rows; ++i) {\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(i, k) * U.entry(k, j);\n }\n L.set_entry(i, j, A.entry(i, j) - sum);\n }\n for (let i = j; i < rows; ++i) {\n if (L.entry(j, j) === 0) {\n return undefined;\n }\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(j, k) * U.entry(k, i);\n }\n U.set_entry(j, i, (A.entry(j, i) - sum) / L.entry(j, j));\n }\n }\n\n return { L: L, U: U };\n }\n\n /**\n * Computes the determinante of {@link A}, by using the LU decomposition of {@link A}.\n * @param {Matrix} A\n * @returns {Number} det - Returns the determinate of the Matrix {@link A}.\n */\n static det(A) {\n const rows = A.shape[0];\n const { L, U } = Matrix.LU(A);\n const L_diag = L.diag;\n const U_diag = U.diag;\n let det = L_diag[0] * U_diag[0];\n for (let row = 1; row < rows; ++row) {\n det *= L_diag[row] * U_diag[row];\n }\n return det;\n }\n\n /**\n * Computes the {@link k} components of the SVD decomposition of the matrix {@link M}\n * @param {Matrix} M\n * @param {int} [k=2]\n * @returns {{U: Matrix, Sigma: Matrix, V: Matrix}}\n */\n static SVD(M, k = 2) {\n const MT = M.T;\n let MtM = MT.dot(M);\n let MMt = M.dot(MT);\n let { eigenvectors: V, eigenvalues: Sigma } = simultaneous_poweriteration(MtM, k);\n let { eigenvectors: U } = simultaneous_poweriteration(MMt, k);\n return { U: U, Sigma: Sigma.map((sigma) => Math.sqrt(sigma)), V: V };\n\n //Algorithm 1a: Householder reduction to bidiagonal form:\n /* const [m, n] = A.shape;\n let U = new Matrix(m, n, (i, j) => i == j ? 1 : 0);\n console.log(U.to2dArray)\n let V = new Matrix(n, m, (i, j) => i == j ? 1 : 0);\n console.log(V.to2dArray)\n let B = Matrix.bidiagonal(A.clone(), U, V);\n console.log(U,V,B)\n return { U: U, \"Sigma\": B, V: V }; */\n }\n}\n","import { linspace, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @memberof module:utils\n * @alias Randomizer\n */\nexport class Randomizer {\n /**\n * Mersenne Twister random number generator.\n * @constructor\n * @param {Number} [_seed=new Date().getTime()] - The seed for the random number generator. If _seed == null then the actual time gets used as seed.\n * @see https://github.com/bmurray7/mersenne-twister-examples/blob/master/javascript-mersenne-twister.js\n */\n constructor(_seed) {\n this._N = 624;\n this._M = 397;\n this._MATRIX_A = 0x9908b0df;\n this._UPPER_MASK = 0x80000000;\n this._LOWER_MASK = 0x7fffffff;\n this._mt = new Array(this._N);\n this._mti = this.N + 1;\n\n this.seed = _seed || new Date().getTime();\n return this;\n }\n\n set seed(_seed) {\n this._seed = _seed;\n let mt = this._mt;\n\n mt[0] = _seed >>> 0;\n for (this._mti = 1; this._mti < this._N; this._mti += 1) {\n let mti = this._mti;\n let s = mt[mti - 1] ^ (mt[mti - 1] >>> 30);\n mt[mti] = ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253 + mti;\n mt[mti] >>>= 0;\n }\n }\n\n /**\n * Returns the seed of the random number generator.\n * @returns {Number} - The seed.\n */\n get seed() {\n return this._seed;\n }\n\n /**\n * Returns a float between 0 and 1.\n * @returns {Number} - A random number between [0, 1]\n */\n get random() {\n return this.random_int * (1.0 / 4294967296.0);\n }\n\n /**\n * Returns an integer between 0 and MAX_INTEGER.\n * @returns {Integer} - A random integer.\n */\n get random_int() {\n let y,\n mag01 = new Array(0x0, this._MATRIX_A);\n if (this._mti >= this._N) {\n let kk;\n\n /* if (this._mti == this._N + 1) {\n this.seed = 5489;\n } */\n\n let N_M = this._N - this._M;\n let M_N = this._M - this._N;\n\n for (kk = 0; kk < N_M; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + this._M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (; kk < this._N - 1; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + M_N] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n\n y = (this._mt[this._N - 1] & this._UPPER_MASK) | (this._mt[0] & this._LOWER_MASK);\n this._mt[this._N - 1] = this._mt[this._M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this._mti = 0;\n }\n\n y = this._mt[(this._mti += 1)];\n y ^= y >>> 11;\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= y >>> 18;\n\n return y >>> 0;\n }\n\n /**\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n choice(A, n) {\n if (A instanceof Matrix) {\n let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A.row(d));\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let rows = A.length;\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A[d]);\n }\n }\n\n /**\n * @static\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @param {Number} seed - The seed for the random number generator.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n static choice(A, n, seed = 1212) {\n const R = new Randomizer(seed);\n return R.choice(A, n);\n /* let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let rand = new Randomizer(seed);\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = rand.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n //return result;\n //return new Matrix(n, cols, (row, col) => A.entry(sample[row], col))\n return sample.map((d) => A.row(d)); */\n }\n}\n","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias max\n * @param {Array} values \n * @returns {Number}\n */\nexport default function (values) {\n let max;\n for (const value of values) {\n if (value != null && (max < value || (max === undefined && value >= value))) {\n max = value;\n }\n }\n return max;\n}","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias min\n * @param {Array} values\n * @returns {Number}\n */\nexport default function (values) {\n let min;\n for (const value of values) {\n if (value != null && (min > value || (min === undefined && value <= value))) {\n min = value;\n }\n }\n return min;\n}","/**\n * @class\n * @alias Heap\n */\nexport class Heap {\n /**\n * A heap is a datastructure holding its elements in a specific way, so that the top element would be the first entry of an ordered list.\n * @constructor\n * @memberof module:datastructure\n * @alias Heap\n * @param {Array=} elements - Contains the elements for the Heap. {@link elements} can be null.\n * @param {Function} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(\"min\"|\"max\"|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n * @see {@link https://en.wikipedia.org/wiki/Binary_heap}\n */\n constructor(elements = null, accessor = d => d, comparator = \"min\") {\n if (elements) {\n return Heap.heapify(elements, accessor, comparator);\n } else {\n this._accessor = accessor;\n this._container = [];\n if (comparator == \"min\") {\n this._comparator = (a, b) => a < b;\n } else if (comparator == \"max\") {\n this._comparator = (a, b) => a > b;\n } else {\n this._comparator = comparator;\n }\n return this\n }\n }\n\n /**\n * Creates a Heap from an Array\n * @param {Array|Set} elements - Contains the elements for the Heap.\n * @param {Function=} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(String=|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n */\n static heapify(elements, accessor = d => d, comparator = \"min\") {\n const heap = new Heap(null, accessor, comparator);\n const container = heap._container;\n for (const e of elements) {\n container.push({\n \"element\": e,\n \"value\": accessor(e),\n });\n }\n for (let i = Math.floor((elements.length / 2) - 1); i >= 0; --i) {\n heap._heapify_down(i);\n }\n return heap;\n }\n\n /**\n * Swaps elements of container array.\n * @private\n * @param {Number} index_a \n * @param {Number} index_b \n */\n _swap(index_a, index_b) {\n const container = this._container;\n [container[index_b], container[index_a]] = [container[index_a], container[index_b]];\n return;\n }\n\n /**\n * @private\n */\n _heapify_up() {\n const container = this._container;\n let index = container.length - 1;\n while (index > 0) {\n let parentIndex = Math.floor((index - 1) / 2);\n if (!this._comparator(container[index].value, container[parentIndex].value)) {\n break;\n } else {\n this._swap(parentIndex, index)\n index = parentIndex;\n }\n }\n }\n\n /**\n * Pushes the element to the heap.\n * @param {} element\n * @returns {Heap}\n */\n push(element) {\n const value = this._accessor(element);\n //const node = new Node(element, value);\n const node = {\"element\": element, \"value\": value};\n this._container.push(node);\n this._heapify_up();\n return this;\n }\n\n /**\n * @private\n * @param {Number} [start_index = 0] \n */\n _heapify_down(start_index=0) {\n const container = this._container;\n const comparator = this._comparator;\n const length = container.length;\n let left = 2 * start_index + 1;\n let right = 2 * start_index + 2;\n let index = start_index;\n if (index > length) throw \"index higher than length\"\n if (left < length && comparator(container[left].value, container[index].value)) {\n index = left;\n }\n if (right < length && comparator(container[right].value, container[index].value)) {\n index = right;\n }\n if (index !== start_index) {\n this._swap(start_index, index);\n this._heapify_down(index);\n }\n }\n\n /**\n * Removes and returns the top entry of the heap.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n pop() {\n const container = this._container;\n if (container.length === 0) {\n return null;\n } else if (container.length === 1) {\n return container.pop();\n }\n this._swap(0, container.length - 1);\n const item = container.pop();\n this._heapify_down();\n return item;\n }\n\n /**\n * Returns the top entry of the heap without removing it.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n get first() {\n return this._container.length > 0 ? this._container[0] : null;\n }\n\n\n /**\n * Yields the raw data\n * @yields {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n * iterate() {\n for (let i = 0, n = this._container.length; i < n; ++i) {\n yield this._container[i].element;\n }\n }\n\n /**\n * Returns the heap as ordered array.\n * @returns {Array} Array consisting the elements ordered by {@link comparator}.\n */\n toArray() {\n return this.data()\n .sort((a,b) => this._comparator(a, b) ? -1 : 0)\n }\n\n /**\n * Returns elements of container array.\n * @returns {Array} Array consisting the elements.\n */\n data() {\n return this._container\n .map(d => d.element)\n }\n\n /**\n * Returns the container array.\n * @returns {Array} The container array.\n */\n raw_data() {\n return this._container;\n }\n\n /**\n * The size of the heap.\n * @returns {Number}\n */\n get length() {\n return this._container.length;\n }\n\n /**\n * Returns false if the the heap has entries, true if the heap has no entries.\n * @returns {Boolean}\n */\n get empty() {\n return this.length === 0;\n }\n}","/**\n * @class\n * @alias DisjointSet\n * @see {@link https://en.wikipedia.org/wiki/Disjoint-set_data_structure}\n */\nexport class DisjointSet {\n /**\n * @constructor\n * @alias DisjointSet\n * @memberof module:datastructure\n * @param {Array=} elements \n * @returns {DisjointSet}\n */\n constructor(elements = null) {\n this._list = new Set();\n if (elements) {\n for (const e of elements) {\n this.make_set(e);\n }\n }\n return this;\n }\n\n make_set(x) {\n const list = this._list;\n if (!list.has(x)) {\n list.add(x);\n x.__disjoint_set = {};\n x.__disjoint_set.parent = x;\n x.__disjoint_set.children = new Set([x]);\n x.__disjoint_set.size = 1;\n }\n return this;\n }\n\n find(x) {\n const list = this._list;\n if (list.has(x)) {\n if (x.__disjoint_set.parent !== x) {\n x.__disjoint_set.children.add(...x);\n x.__disjoint_set.parent = this.find(x.__disjoint_set.parent);\n return x.__disjoint_set.parent;\n } else {\n return x;\n }\n } else {\n return null;\n }\n }\n\n union(x, y) {\n let node_x = this.find(x);\n let node_y = this.find(y);\n\n if (node_x === node_y) return this;\n if (node_x.__disjoint_set.size < node_y.__disjoint_set.size) [node_x, node_y] = [node_y, node_x];\n\n node_y.__disjoint_set.parent = node_x;\n // keep track of children?\n node_y.__disjoint_set.children.forEach(node_x.__disjoint_set.children.add, node_x.__disjoint_set.children);\n node_x.__disjoint_set.size += node_y.__disjoint_set.size;\n\n return this;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n/**\n * @class\n * @alias BallTree\n */\nexport class BallTree {\n /**\n * Generates a BallTree with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias BallTree\n * @param {Array=} elements - Elements which should be added to the BallTree\n * @param {Function} [metric = euclidean] metric to use: (a, b) => distance\n * @see {@link https://en.wikipedia.org/wiki/Ball_tree}\n * @see {@link https://github.com/invisal/noobjs/blob/master/src/tree/BallTree.js}\n * @returns {BallTree}\n */\n constructor(elements = null, metric = euclidean) {\n this._Node = class {\n constructor(pivot, child1=null, child2=null, radius=null) {\n this.pivot = pivot;\n this.child1 = child1;\n this.child2 = child2;\n this.radius = radius;\n }\n }\n this._Leaf = class {\n constructor(points) {\n this.points = points;\n }\n }\n this._metric = metric;\n if (elements) {\n this.add(elements);\n }\n return this;\n }\n\n /**\n * \n * @param {Array<*>} elements - new elements.\n * @returns {BallTree}\n */\n add(elements) {\n elements = elements.map((element, index) => {\n return {index: index, element: element}\n })\n this._root = this._construct(elements);\n return this;\n }\n\n /**\n * @private\n * @param {Array<*>} elements \n * @returns {Node} root of balltree.\n */\n _construct(elements) {\n if (elements.length === 1) {\n return new this._Leaf(elements);\n } else {\n let c = this._greatest_spread(elements);\n let sorted_elements = elements.sort((a, b) => a.element[c] - b.element[c]);\n let n = sorted_elements.length;\n let p_index = Math.floor(n / 2);\n let p = elements[p_index];\n let L = sorted_elements.slice(0, p_index);\n let R = sorted_elements.slice(p_index, n);\n let radius = Math.max(...elements.map(d => this._metric(p.element, d.element)));\n let B\n if (L.length > 0 && R.length > 0) { \n B = new this._Node(p, this._construct(L), this._construct(R), radius);\n } else {\n B = new this._Leaf(elements);\n }\n return B;\n }\n }\n\n /**\n * @private\n * @param {Node} B \n * @returns {Number}\n */\n _greatest_spread(B) {\n let d = B[0].element.length;\n let start = new Array(d);\n\n for (let i = 0; i < d; ++i) {\n start[i] = [Infinity, -Infinity];\n }\n\n let spread = B.reduce((acc, current) => {\n for (let i = 0; i < d; ++i) {\n acc[i][0] = Math.min(acc[i][0], current.element[i]);\n acc[i][1] = Math.max(acc[i][1], current.element[i]);\n }\n return acc;\n }, start);\n spread = spread.map(d => d[1] - d[0]);\n \n let c = 0;\n for (let i = 0; i < d; ++i) {\n c = spread[i] > spread[c] ? i : c;\n }\n return c;\n }\n\n /**\n * \n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n return this._search(t, k, new Heap(null, d => this._metric(d.element, t), \"max\"), this._root);\n }\n\n /**\n * @private\n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @param {Heap} Q - Heap consists of the currently found {@link k} nearest neighbors.\n * @param {Node|Leaf} B \n */\n _search(t, k, Q, B) {\n // B is Node\n if (Q.length >= k && B.pivot && B.radius && this._metric(t, B.pivot.element) - B.radius >= Q.first.value) {\n return Q;\n } \n if (B.child1) this._search(t, k, Q, B.child1);\n if (B.child2) this._search(t, k, Q, B.child2);\n \n // B is leaf\n if (B.points) {\n for (let i = 0, n = B.points.length; i < n; ++i) {\n let p = B.points[i];\n if (k > Q.length) {\n Q.push(p);\n } else {\n Q.push(p);\n Q.pop();\n }\n }\n }\n return Q;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KNN\n */\nexport class KNN {\n /**\n * Generates a KNN list with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias KNN\n * @param {Array=} elements - Elements which should be added to the KNN list\n * @param {Function|\"precomputed\"} [metric = euclidean] metric is either precomputed or a function to use: (a, b) => distance\n * @returns {KNN}\n */\n constructor(elements=null, metric=euclidean) {\n this._metric = metric;\n this._elements = elements instanceof Matrix ? elements : Matrix.from(elements);\n const N = this._elements.shape[0];\n if (metric === \"precomputed\") {\n this._D = this._elements.clone();\n } else {\n this._D = distance_matrix(this._elements, metric);\n }\n this.KNN = [];\n for (let row = 0; row < N; ++row) {\n const distances = this._D.row(row);\n const H = new Heap(null, d => d.value, \"min\");\n for (let j = 0; j < N; ++j) {\n H.push({\n value: distances[j],\n index: j,\n });\n }\n this.KNN.push(H);\n }\n }\n\n /**\n * \n * @param {Array|Number} t - query element or index.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n const metric = this._metric;\n const KNN = this.KNN;\n let H;\n if (Array.isArray(t)) {\n if (this._metric == \"precomputed\") {\n throw \"Search by query element is only possible when not using a precomputed distance matrix!\"\n } \n const elements = this._elements;\n const N = KNN.length;\n let nearest_element_index = null;\n let nearest_dist = Infinity;\n for (let i = 0; i < N; ++i) {\n const element = elements.row(i);\n const dist = metric(t, element);\n if (dist < nearest_dist) {\n nearest_element_index = i;\n nearest_dist = dist;\n }\n }\n H = KNN[nearest_element_index];\n } else if (Number.isInteger(t)) {\n H = KNN[t]\n }\n\n let result = []\n for (let i = 0; i < k; ++i) {\n result.push(H.pop())\n }\n result.forEach(res => H.push(res.element))\n return result\n } \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n\n/**\n * @class\n * @alias DR\n * @borrows DR#parameter as DR#para\n * @borrows DR#parameter as DR#p\n */\nexport class DR {\n /**\n * Takes the default parameters and seals them, remembers the type of input {@link X}, and initializes the random number generator.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias DR\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed value for the random number generator.\n * @returns {DR}\n */\n constructor(X, default_parameters, parameters) {\n this._parameters = Object.assign(Object.seal(default_parameters), parameters);\n if (Array.isArray(X)) {\n this._type = \"array\";\n this.X = Matrix.from(X);\n } else if (X instanceof Matrix) {\n this._type = \"matrix\";\n this.X = X;\n } else {\n throw new Error(\"No valid type for X!\");\n }\n [this._N, this._D] = this.X.shape;\n this._randomizer = new Randomizer(this._parameters.seed);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * Set and get parameters\n * @param {String} name - name of the parameter.\n * @param {any} [value = null] - value of the parameter to set.\n * @returns {DR|any} - On setting a parameter, this function returns the DR object. If value == null then return actual parameter value.\n * @example\n * const DR = new druid.TSNE(X, {d: 3}); // creates a new DR object, with parameter for d = 3.\n * DR.parameter(\"d\"); // returns 3,\n * DR.parameter(\"d\", 2); // sets parameter d to 2 and returns DR.\n */\n parameter(name, value = null) {\n if (!this._parameters.hasOwnProperty(name)) {\n throw new Error(`${name} is not a valid parameter!`);\n }\n if (value !== null) {\n this._parameters[name] = value;\n this._is_initialized = false;\n return this;\n } else {\n return this._parameters[name];\n }\n }\n\n para(name, value = null) {\n return this.parameter(name, value);\n }\n\n p(name, value = null) {\n return this.parameter(name, value);\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} - Returns the projection.\n */\n transform() {\n this.check_init();\n return this.projection;\n }\n\n /**\n * Computes the projection.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n *generator() {\n return this.transform();\n }\n\n /**\n * If the respective DR method has an init function, call it before transform.\n * @returns {DR}\n */\n check_init() {\n if (!this._is_initialized && typeof this.init === \"function\") {\n this.init();\n this._is_initialized = true;\n }\n return this;\n }\n\n /**\n * @returns {Matrix|Array} Returns the projection.\n */\n get projection() {\n if (this.hasOwnProperty(\"Y\")) {\n this.check_init();\n return this._type === \"matrix\" ? this.Y : this.Y.to2dArray;\n } else {\n throw new Error(\"The dataset is not transformed yet!\");\n }\n }\n\n /**\n *\n * @param {...any} args - Arguments the transform method of the respective DR method takes.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Matrix|Array} - The dimensionality reduced dataset.\n */\n static transform(...args) {\n let dr = new this(...args);\n return dr.transform();\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n static async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n static *generator(...args) {\n const dr = new this(...args);\n const generator = dr.generator();\n for (const result of generator) {\n yield result;\n }\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias PCA\n * @augments DR\n */\nexport class PCA extends DR {\n /**\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias PCA\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @returns {PCA}\n */\n constructor(X, parameters) {\n super(X, { d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}. If parameter {@link A} is given, then project {@link A} with the principal components of {@link X}.\n * @param {null|Matrix|Array} [A = null] - If given, the data to project.\n * @returns {Matrix|Array} - The projected data.\n */\n transform(A = null) {\n const V = this.principal_components();\n if (A == null) {\n const X = this.X;\n this.Y = X.dot(V);\n return this.projection;\n } else if (Array.isArray(A)) {\n return Matrix.from(A).dot(V).asArray;\n } else if (A instanceof Matrix) {\n return A.dot(V);\n } else {\n throw new Error(\"No valid type for A!\");\n }\n }\n\n /**\n * Computes the {@link d} principal components of Matrix {@link X}.\n * @returns {Matrix}\n */\n principal_components() {\n if (this.V) {\n return this.V;\n }\n const { d, eig_args } = this._parameters;\n const X = this.X;\n const means = Matrix.from(X.meanCols);\n const X_cent = X.sub(means);\n const C = X_cent.transpose().dot(X_cent);\n const { eigenvectors: V } = simultaneous_poweriteration(C, d, eig_args);\n this.V = Matrix.from(V).transpose();\n return this.V;\n }\n\n static principal_components(X, parameters) {\n const dr = new this(X, parameters);\n return dr.principal_components();\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias MDS\n * @extends DR\n */\nexport class MDS extends DR {\n /**\n * Classical MDS.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias MDS\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}.\n * @returns {Matrix|Array}\n */\n transform() {\n const X = this.X;\n const rows = X.shape[0];\n const { d, metric, eig_args } = this._parameters;\n const A = metric === \"precomputed\" ? X : distance_matrix(X, metric);\n const ai_ = A.meanCols;\n const a_j = A.meanRows;\n const a__ = A.mean;\n\n this._d_X = A;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n\n return this.projection;\n }\n\n /**\n * @returns {Number} - the stress of the projection.\n */\n stress() {\n const N = this.X.shape[0];\n const Y = this.Y;\n const d_X = this._d_X;\n const d_Y = new Matrix();\n d_Y.shape = [\n N,\n N,\n (i, j) => {\n return i < j ? euclidean(Y.row(i), Y.row(j)) : d_Y.entry(j, i);\n },\n ];\n let top_sum = 0;\n let bottom_sum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n top_sum += Math.pow(d_X.entry(i, j) - d_Y.entry(i, j), 2);\n bottom_sum += Math.pow(d_X.entry(i, j), 2);\n }\n }\n return Math.sqrt(top_sum / bottom_sum);\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { DR } from \"./DR.js\";\nimport euclidean from \"../metrics/euclidean.js\";\n\n/**\n * @class\n * @alias ISOMAP\n * @extends DR\n */\nexport class ISOMAP extends DR {\n /**\n * Isometric feature mapping (ISOMAP).\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias ISOMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link ISOMAP} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2319}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(this._parameters.neighbors ?? Math.max(Math.floor(this.X.shape[0] / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const X = this.X;\n const rows = this._N;\n const { d, metric, eig_args, neighbors } = this._parameters;\n // TODO: make knn extern and parameter for constructor or transform?\n const D = new Matrix();\n D.shape = [rows, rows, (i, j) => (i <= j ? metric(X.row(i), X.row(j)) : D.entry(j, i))];\n const kNearestNeighbors = [];\n for (let i = 0; i < rows; ++i) {\n const row = [];\n for (let j = 0; j < rows; ++j) {\n row.push({\n index: j,\n distance: D.entry(i, j),\n });\n }\n const H = new Heap(row, (d) => d.distance, \"min\");\n kNearestNeighbors.push(H.toArray().slice(1, neighbors + 1));\n }\n\n /*D = dijkstra(kNearestNeighbors);*/\n // compute shortest paths\n // TODO: make extern\n /** @see {@link https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm} */\n const G = new Matrix(rows, rows, (i, j) => {\n const other = kNearestNeighbors[i].find((n) => n.index === j);\n return other ? other.distance : Infinity;\n });\n\n for (let i = 0; i < rows; ++i) {\n for (let j = 0; j < rows; ++j) {\n for (let k = 0; k < rows; ++k) {\n G.set_entry(i, j, Math.min(G.entry(i, j), G.entry(i, k) + G.entry(k, j)));\n }\n }\n }\n\n let ai_ = new Float64Array(rows);\n let a_j = new Float64Array(rows);\n let a__ = 0;\n const A = new Matrix(rows, rows, (i, j) => {\n let val = G.entry(i, j);\n val = val === Infinity ? 0 : val;\n ai_[i] += val;\n a_j[j] += val;\n a__ += val;\n return val;\n });\n\n ai_ = ai_.map((v) => v / rows);\n a_j = a_j.map((v) => v / rows);\n a__ /= rows ** 2;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n // compute d eigenvectors\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n/**\n * @class\n * @alias FASTMAP\n * @extends DR\n */\nexport class FASTMAP extends DR {\n /**\n * FastMap: a fast algorithm for indexing, data-mining and visualization of traditional and multimedia datasets\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias FASTMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the dimensionality of the projection.\n * @returns {FASTMAP}\n * @see {@link https://doi.org/10.1145/223784.223812}\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n * Chooses two points which are the most distant in the actual projection.\n * @private\n * @param {Function} dist\n * @returns {Array} An array consisting of first index, second index, and distance between the two points.\n */\n _choose_distant_objects(dist) {\n const X = this.X;\n const N = X.shape[0];\n let a_index = (this._randomizer.random_int % N) - 1;\n let b_index = null;\n let max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n if (d_ai > max_dist) {\n max_dist = d_ai;\n b_index = i;\n }\n }\n max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_bi = dist(b_index, i);\n if (d_bi > max_dist) {\n max_dist = d_bi;\n a_index = i;\n }\n }\n return [a_index, b_index, max_dist];\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} The {@link d}-dimensional projection of the data matrix {@link X}.\n */\n transform() {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric } = this._parameters;\n const Y = new Matrix(N, d, 0);\n let dist = (a, b) => metric(X.row(a), X.row(b));\n\n for (let _col = 0; _col < d; ++_col) {\n let old_dist = dist;\n // choose pivot objects\n const [a_index, b_index, d_ab] = this._choose_distant_objects(dist);\n if (d_ab !== 0) {\n // project the objects on the line (O_a, O_b)\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n const d_bi = dist(b_index, i);\n const y_i = (d_ai ** 2 + d_ab ** 2 - d_bi ** 2) / (2 * d_ab);\n Y.set_entry(i, _col, y_i);\n }\n // consider the projections of the objects on a\n // hyperplane perpendicluar to the line (a, b);\n // the distance function D'() between two\n // projections is given by Eq.4\n dist = (a, b) => Math.sqrt(old_dist(a, b) ** 2 - (Y.entry(a, _col) - Y.entry(b, _col)) ** 2);\n }\n }\n // return embedding.\n this.Y = Y;\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LDA\n * @extends DR\n */\nexport class LDA extends DR {\n /**\n * Linear Discriminant Analysis.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LDA\n * @param {Matrix} X - The high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Array} parameters.labels - The labels / classes for each data point.\n * @param {number} [parameters.d = 2] - The dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://onlinelibrary.wiley.com/doi/10.1111/j.1469-1809.1936.tb02137.x}\n */\n constructor(X, parameters) {\n super(X, { labels: null, d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, cols] = X.shape;\n const { d, labels, eig_args } = this._parameters;\n if (labels === null || labels.length != rows) {\n throw new Error(\"LDA needs parameter label to every datapoint to work!\");\n }\n const unique_labels = {};\n let label_id = 0;\n labels.forEach((l, i) => {\n if (l in unique_labels) {\n unique_labels[l].count++;\n unique_labels[l].rows.push(X.row(i));\n } else {\n unique_labels[l] = {\n id: label_id++,\n count: 1,\n rows: [X.row(i)],\n };\n }\n });\n\n // create X_mean and vector means;\n const X_mean = X.mean;\n const V_mean = new Matrix(label_id, cols);\n for (const label in unique_labels) {\n const V = Matrix.from(unique_labels[label].rows);\n const v_mean = V.meanCols;\n for (let j = 0; j < cols; ++j) {\n V_mean.set_entry(unique_labels[label].id, j, v_mean[j]);\n }\n }\n // scatter_between\n let S_b = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j] - X_mean);\n const N = unique_labels[label].count;\n S_b = S_b.add(m.dot(m.transpose()).mult(N));\n }\n\n // scatter_within\n let S_w = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j]);\n const R = unique_labels[label].rows;\n for (let i = 0, n = unique_labels[label].count; i < n; ++i) {\n const row_v = new Matrix(cols, 1, (j, _) => R[i][j] - m.entry(j, 0));\n S_w = S_w.add(row_v.dot(row_v.transpose()));\n }\n }\n\n let { eigenvectors: V } = simultaneous_poweriteration(S_w.inverse().dot(S_b), d, eig_args);\n V = Matrix.from(V).transpose();\n this.Y = X.dot(V);\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { k_nearest_neighbors } from \"../matrix/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LLE\n * @extends DR\n */\nexport class LLE extends DR {\n /**\n * Locally Linear Embedding.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LLE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} neighbors - the label / class of each data point.\n * @param {Number} [d = 2] - the dimensionality of the projection.\n * @param {Function} [metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [seed = 1212] - the dimensionality of the projection.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2323}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const rows = this._N;\n const cols = this._D;\n const { neighbors, d, eig_args, metric } = this._parameters;\n const nN = k_nearest_neighbors(X, neighbors, metric);\n const O = new Matrix(neighbors, 1, 1);\n const W = new Matrix(rows, rows);\n\n for (let row = 0; row < rows; ++row) {\n const nN_row = nN[row];\n const Z = new Matrix(neighbors, cols, (i, j) => X.entry(nN_row[i].j, j) - X.entry(row, j));\n const C = Z.dot(Z.T);\n if (neighbors > cols) {\n const C_trace = neumair_sum(C.diag) / 1000;\n for (let j = 0; j < neighbors; ++j) {\n C.set_entry(j, j, C.entry(j, j) + C_trace);\n }\n }\n // reconstruct;\n let w = Matrix.solve_CG(C, O, this._randomizer);\n w = w.divide(w.sum);\n for (let j = 0; j < neighbors; ++j) {\n W.set_entry(row, nN_row[j].j, w.entry(j, 0));\n }\n }\n // comp embedding\n const I = new Matrix(rows, rows, \"identity\");\n const IW = I.sub(W);\n const M = IW.T.dot(IW);\n const { eigenvectors: V } = simultaneous_poweriteration(M.T.inverse(), d + 1, eig_args);\n this.Y = Matrix.from(V.slice(1, 1 + d)).T;\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix, k_nearest_neighbors } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LTSA\n * @extends DR\n */\nexport class LTSA extends DR {\n /**\n * Local Tangent Space Alignment\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LTSA\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link LTSA} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://epubs.siam.org/doi/abs/10.1137/S1064827502419154}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n if (this._D <= this.parameter(\"d\")) {\n throw new Error(`Dimensionality of X (D = ${this._D}) must be greater than the required dimensionality of the result (d = ${this.parameter(\"d\")})!`);\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, D] = X.shape;\n const { d, neighbors, metric, eig_args } = this._parameters;\n // 1.1 determine k nearest neighbors\n const nN = k_nearest_neighbors(X, neighbors, metric);\n // center matrix\n const O = new Matrix(D, D, \"center\");\n const B = new Matrix(rows, rows, 0);\n\n for (let row = 0; row < rows; ++row) {\n // 1.2 compute the d largest eigenvectors of the correlation matrix\n const I_i = [row, ...nN[row].map((n) => n.j)];\n let X_i = Matrix.from(I_i.map((n) => X.row(n)));\n // center X_i\n X_i = X_i.dot(O);\n // correlation matrix\n const C = X_i.dot(X_i.transpose());\n const { eigenvectors: g } = simultaneous_poweriteration(C, d, eig_args);\n //g.push(linspace(0, k).map(_ => 1 / Math.sqrt(k + 1)));\n const G_i_t = Matrix.from(g);\n // 2. Constructing alignment matrix\n const W_i = G_i_t.transpose()\n .dot(G_i_t)\n .add(1 / Math.sqrt(neighbors + 1));\n for (let i = 0; i < neighbors + 1; ++i) {\n for (let j = 0; j < neighbors + 1; ++j) {\n B.set_entry(I_i[i], I_i[j], B.entry(I_i[i], I_i[j]) - (i === j ? 1 : 0) + W_i.entry(i, j));\n }\n }\n }\n\n // 3. Aligning global coordinates\n const { eigenvectors: Y } = simultaneous_poweriteration(B, d + 1, eig_args);\n this.Y = Matrix.from(Y.slice(1)).transpose();\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TSNE\n * @extends DR\n */\nexport class TSNE extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TSNE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.perplexity = 50] - perplexity.\n * @param {Number} [parameters.epsilon = 10] - learning parameter.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TSNE}\n */\n constructor(X, parameters) {\n super(X, { perplexity: 50, epsilon: 10, d: 2, metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._iter = 0;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => this._randomizer.random);\n return this;\n }\n\n /**\n *\n * @param {Matrix} distance_matrix - accepts a precomputed distance matrix\n * @returns {TSNE}\n */\n init() {\n // init\n const Htarget = Math.log(this.parameter(\"perplexity\"));\n const N = this._N;\n const D = this._D;\n const {metric} = this._parameters;\n const X = this.X;\n let Delta;\n if (metric ==\"precomputed\") {\n Delta = druid.Matrix.from(X);\n } else {\n Delta = new Matrix(N, N);\n for (let i = 0; i < N; ++i) {\n const X_i = X.row(i);\n for (let j = i + 1; j < N; ++j) {\n const distance = metric(X_i, X.row(j));\n Delta.set_entry(i, j, distance);\n Delta.set_entry(j, i, distance);\n }\n }\n }\n\n const P = new Matrix(N, N, \"zeros\");\n\n this._ystep = new Matrix(N, D, \"zeros\");\n this._gains = new Matrix(N, D, 1);\n\n // search for fitting sigma\n let prow = new Float64Array(N)\n const tol = 1e-4;\n const maxtries = 50;\n for (let i = 0; i < N; ++i) {\n let betamin = -Infinity;\n let betamax = Infinity;\n let beta = 1;\n let done = false;\n\n let num = 0;\n while (!done) {\n let psum = 0;\n for (let j = 0; j < N; ++j) {\n let pj = Math.exp(-Delta.entry(i, j) * beta);\n if (i === j) pj = 0;\n prow[j] = pj;\n psum += pj;\n }\n let Hhere = 0;\n for (let j = 0; j < N; ++j) {\n let pj = psum === 0 ? 0 : prow[j] / psum;\n prow[j] = pj;\n if (pj > 1e-7) {\n Hhere -= pj * Math.log(pj);\n }\n }\n if (Hhere > Htarget) {\n betamin = beta;\n beta = betamax === Infinity ? beta * 2 : (beta + betamax) / 2;\n } else {\n betamax = beta;\n beta = betamin === -Infinity ? beta / 2 : (beta + betamin) / 2;\n }\n ++num;\n if (Math.abs(Hhere - Htarget) < tol) done = true;\n if (num >= maxtries) done = true;\n }\n\n for (let j = 0; j < N; ++j) {\n P.set_entry(i, j, prow[j]);\n }\n }\n\n //compute probabilities\n const Pout = new Matrix(N, N, \"zeros\");\n const N2 = N * 2;\n for (let i = 0; i < N; ++i) {\n for (let j = i; j < N; ++j) {\n const p = Math.max((P.entry(i, j) + P.entry(j, i)) / N2, 1e-100);\n Pout.set_entry(i, j, p);\n Pout.set_entry(j, i, p);\n }\n }\n this._P = Pout;\n return this;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n transform(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n *generator(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * performs a optimization step\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const P = this._P;\n const ystep = this._ystep;\n const gains = this._gains;\n const N = this._N;\n const { d: dim, epsilon} = this._parameters;\n let Y = this.Y;\n\n //calc cost gradient;\n const pmul = iter < 100 ? 4 : 1;\n\n // compute Q dist (unnormalized)\n const Qu = new Matrix(N, N, \"zeros\");\n let qsum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dsum = 0;\n for (let d = 0; d < dim; ++d) {\n const dhere = Y.entry(i, d) - Y.entry(j, d);\n dsum += dhere * dhere;\n }\n const qu = 1 / (1 + dsum);\n Qu.set_entry(i, j, qu);\n Qu.set_entry(j, i, qu);\n qsum += 2 * qu;\n }\n }\n\n // normalize Q dist\n const Q = new Matrix(N, N, 0);\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n const val = Math.max(Qu.entry(i, j) / qsum, 1e-100);\n Q.set_entry(i, j, val);\n Q.set_entry(j, i, val);\n }\n }\n\n const grad = new Matrix(N, dim, \"zeros\");\n for (let i = 0; i < N; ++i) {\n for (let j = 0; j < N; ++j) {\n const premult = 4 * (pmul * P.entry(i, j) - Q.entry(i, j)) * Qu.entry(i, j);\n for (let d = 0; d < dim; ++d) {\n grad.set_entry(i, d, grad.entry(i, d) + premult * (Y.entry(i, d) - Y.entry(j, d)));\n }\n }\n }\n\n // perform gradient step\n let ymean = new Float64Array(dim);\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const gid = grad.entry(i, d);\n const sid = ystep.entry(i, d);\n const gainid = gains.entry(i, d);\n\n let newgain = Math.sign(gid) === Math.sign(sid) ? gainid * 0.8 : gainid + 0.2;\n if (newgain < 0.01) newgain = 0.01;\n gains.set_entry(i, d, newgain);\n\n const momval = iter < 250 ? 0.5 : 0.8;\n const newsid = momval * sid - epsilon * newgain * gid;\n ystep.set_entry(i, d, newsid);\n\n Y.set_entry(i, d, Y.entry(i, d) + newsid);\n ymean[d] += Y.entry(i, d);\n }\n }\n\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < 2; ++d) {\n Y.set_entry(i, d, Y.entry(i, d) - ymean[d] / N);\n }\n }\n\n return this.Y;\n }\n}\n","/**\n *\n * @memberof module:optimization\n * @alias powell\n * @param {Function} f\n * @param {Array} x0\n * @param {Number} [max_iter = 300]\n * @returns {Array}\n * @see http://optimization-js.github.io/optimization-js/optimization.js.html#line438\n */\nexport default function (f, x0, max_iter = 300) {\n const epsilon = 1e-2;\n const n = x0.length;\n let alpha = 1e-3;\n let pfx = 10000;\n let x = x0.slice();\n let fx = f(x);\n let convergence = false;\n\n while (max_iter-- >= 0 && !convergence) {\n convergence = true;\n for (let i = 0; i < n; ++i) {\n x[i] += 1e-6;\n let fxi = f(x);\n x[i] -= 1e-6;\n let dx = (fxi - fx) / 1e-6;\n if (Math.abs(dx) > epsilon) {\n convergence = false;\n }\n x[i] -= alpha * dx;\n fx = f(x);\n }\n alpha *= pfx >= fx ? 1.05 : 0.4;\n pfx = fx;\n }\n return x;\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean, euclidean_squared } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { linspace } from \"../matrix/index.js\";\nimport { powell } from \"../optimization/index.js\";\nimport { DR } from \"./DR.js\";\nimport { max } from \"../util/index.js\";\nimport { KNN } from \"../knn/index.js\";\n\n/**\n * @class\n * @alias UMAP\n * @extends DR\n */\nexport class UMAP extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias UMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.n_neighbors = 15] - size of the local neighborhood.\n * @param {Number} [parameters.local_connectivity = 1] - number of nearest neighbors connected in the local neighborhood.\n * @param {Number} [parameters.min_dist = 1] - controls how tightly points get packed together.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points in the high-dimensional space.\n * @param {Number} [parameters._spread = 1] - The effective scale of embedded points. (In combination with {@link parameters.min_dist})\n * @param {Number} [parameters._set_op_mix_ratio = 1] - Interpolate between union and intersection.\n * @param {Number} [parameters._repulsion_strength = 1] - Weighting applied to negative samples.\n * @param {Number} [parameters._negative_sample_rate = 5] - The number of negative samples per positive sample.\n * @param {Number} [parameters._n_epochs = 350] - The number of training epochs.\n * @param {Number} [parameter._initial_alpha = 1] - The initial learning rate for the optimization.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {UMAP}\n */\n constructor(X, parameters) {\n super(X, { n_neighbors: 15, local_connectivity: 1, min_dist: 1, d: 2, metric: euclidean, seed: 1212, _spread: 1, _set_op_mix_ratio: 1, _repulsion_strength: 1, _negative_sample_rate: 5, _n_epochs: 350, _initial_alpha: 1 }, parameters);\n [this._N, this._D] = this.X.shape;\n /* let n_neighbors = Math.min(this._N - 1, parameters.n_neighbors);\n this.parameter(\"n_neighbors\", n_neighbors);\n this.parameter(\"local_connectivity\", Math.min(this.parameter(\"local_connectivity\"), n_neighbors - 1)); */\n if (this.parameter(\"n_neighbors\") > this._N) {\n throw new Error(`Parameter n_neighbors (=${this.parameter(\"n_neighbors\")}) needs to be smaller than dataset size (N=${this._N})!`);\n }\n if (this.parameter(\"local_connectivity\") > this.parameter(\"n_neighbors\")) {\n throw new Error(`Parameter local_connectivity (=${this.parameter(\"local_connectivity\")}) needs to be smaller than parameter n_neighbors (=${this.parameter(\"n_neighbors\")})`);\n }\n this._iter = 0;\n const randomizer = this._randomizer;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => randomizer.random);\n return this;\n }\n\n /**\n * @private\n * @param {Number} spread\n * @param {Number} min_dist\n * @returns {Array}\n */\n _find_ab_params(spread, min_dist) {\n const curve = (x, a, b) => 1 / (1 + a * Math.pow(x, 2 * b));\n const xv = linspace(0, spread * 3, 300);\n const yv = linspace(0, spread * 3, 300);\n\n for (let i = 0, n = xv.length; i < n; ++i) {\n const xv_i = xv[i];\n yv[i] = xv_i < min_dist ? 1 : Math.exp(-(xv_i - min_dist) / spread);\n }\n\n const err = (p) => {\n const error = linspace(1, 300).map((_, i) => yv[i] - curve(xv[i], p[0], p[1]));\n return Math.sqrt(neumair_sum(error.map((e) => e * e)));\n };\n\n return powell(err, [1, 1]);\n }\n\n /**\n * @private\n * @param {Array} distances\n * @param {Array} sigmas\n * @param {Array} rhos\n * @returns {Array}\n */\n _compute_membership_strengths(distances, sigmas, rhos) {\n for (let i = 0, n = distances.length; i < n; ++i) {\n for (let j = 0, m = distances[i].length; j < m; ++j) {\n const v = distances[i][j].value - rhos[i];\n distances[i][j].value = v > 0 ? Math.exp(-v / sigmas[i]) : 1;\n }\n }\n return distances;\n }\n\n /**\n * @private\n * @param {KNN|BallTree} knn\n * @param {Number} k\n * @returns {Object}\n */\n _smooth_knn_dist(knn, k) {\n const SMOOTH_K_TOLERANCE = 1e-5;\n const MIN_K_DIST_SCALE = 1e-3;\n const n_iter = 64;\n const { local_connectivity, metric } = this._parameters;\n const target = Math.log2(k);\n const rhos = [];\n const sigmas = [];\n const X = this.X;\n const N = X.shape[0];\n //const distances = [...X].map(x_i => knn.search(x_i, k).raw_data().reverse());\n\n const distances = [];\n if (metric === \"precomputed\") {\n for (let i = 0; i < N; ++i) {\n distances.push(knn.search(i, k).reverse());\n }\n } else {\n for (const x_i of X) {\n distances.push(knn.search(x_i, k).raw_data().reverse());\n }\n }\n\n for (let i = 0; i < N; ++i) {\n let lo = 0;\n let hi = Infinity;\n let mid = 1;\n\n const search_result = distances[i];\n const non_zero_dist = search_result.filter((d) => d.value > 0);\n const non_zero_dist_length = non_zero_dist.length;\n if (non_zero_dist_length >= local_connectivity) {\n const index = Math.floor(local_connectivity);\n const interpolation = local_connectivity - index;\n if (index > 0) {\n rhos.push(non_zero_dist[index - 1]);\n if (interpolation > SMOOTH_K_TOLERANCE) {\n rhos[i].value += interpolation * (non_zero_dist[index].value - non_zero_dist[index - 1]);\n }\n } else {\n rhos[i].value = interpolation * non_zero_dist[0].value;\n }\n } else if (non_zero_dist_length > 0) {\n rhos[i] = non_zero_dist[non_zero_dist_length - 1].value;\n }\n for (let x = 0; x < n_iter; ++x) {\n let psum = 0;\n for (let j = 0; j < k; ++j) {\n const d = search_result[j].value - rhos[i];\n psum += d > 0 ? Math.exp(-(d / mid)) : 1;\n }\n if (Math.abs(psum - target) < SMOOTH_K_TOLERANCE) {\n break;\n }\n if (psum > target) {\n [hi, mid] = [mid, (lo + hi) / 2];\n } else {\n if (hi === Infinity) {\n [lo, mid] = [mid, mid * 2];\n } else {\n [lo, mid] = [mid, (lo + hi) / 2];\n }\n }\n }\n sigmas[i] = mid;\n\n const mean_ithd = search_result.reduce((a, b) => a + b.value, 0) / search_result.length;\n //let mean_d = null;\n if (rhos[i] > 0) {\n if (sigmas[i] < MIN_K_DIST_SCALE * mean_ithd) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_ithd;\n }\n } else {\n const mean_d = distances.reduce((acc, res) => acc + res.reduce((a, b) => a + b.value, 0) / res.length);\n if (sigmas[i] > MIN_K_DIST_SCALE * mean_d) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_d;\n }\n }\n }\n return {\n distances: distances,\n sigmas: sigmas,\n rhos: rhos,\n };\n }\n\n /**\n * @private\n * @param {Matrix} X\n * @param {Number} n_neighbors\n * @returns {Matrix}\n */\n _fuzzy_simplicial_set(X, n_neighbors) {\n const N = X.shape[0];\n const { metric, _set_op_mix_ratio } = this._parameters;\n const knn = metric === \"precomputed\" ? new KNN(X, \"precomputed\") : new BallTree(X.to2dArray, metric);\n let { distances, sigmas, rhos } = this._smooth_knn_dist(knn, n_neighbors);\n distances = this._compute_membership_strengths(distances, sigmas, rhos);\n const result = new Matrix(N, N, \"zeros\");\n for (let i = 0; i < N; ++i) {\n const distances_i = distances[i];\n for (let j = 0; j < distances_i.length; ++j) {\n result.set_entry(i, distances_i[j].element.index, distances_i[j].value);\n }\n }\n\n const transposed_result = result.T;\n const prod_matrix = result.mult(transposed_result);\n return result\n .add(transposed_result)\n .sub(prod_matrix)\n .mult(_set_op_mix_ratio)\n .add(prod_matrix.mult(1 - _set_op_mix_ratio));\n }\n\n /**\n * @private\n * @param {Number} n_epochs\n * @returns {Array}\n */\n _make_epochs_per_sample(n_epochs) {\n const weights = this._weights;\n const result = new Float32Array(weights.length).fill(-1);\n const weights_max = max(weights);\n const n_samples = weights.map((w) => n_epochs * (w / weights_max));\n for (let i = 0; i < result.length; ++i) if (n_samples[i] > 0) result[i] = Math.round(n_epochs / n_samples[i]);\n return result;\n }\n\n /**\n * @private\n * @param {Matrix} graph\n * @returns {Object}\n */\n _tocoo(graph) {\n const rows = [];\n const cols = [];\n const data = [];\n const [rows_n, cols_n] = graph.shape;\n for (let row = 0; row < rows_n; ++row) {\n for (let col = 0; col < cols_n; ++col) {\n const entry = graph.entry(row, col);\n if (entry !== 0) {\n rows.push(row);\n cols.push(col);\n data.push(entry);\n }\n }\n }\n return {\n rows: rows,\n cols: cols,\n data: data,\n };\n }\n\n /**\n * Computes all necessary\n * @returns {UMAP}\n */\n init() {\n const { _spread, min_dist, n_neighbors, _n_epochs, _negative_sample_rate } = this._parameters;\n const [a, b] = this._find_ab_params(_spread, min_dist);\n this._a = a;\n this._b = b;\n this._graph = this._fuzzy_simplicial_set(this.X, n_neighbors);\n const { rows, cols, data: weights } = this._tocoo(this._graph);\n this._head = rows;\n this._tail = cols;\n this._weights = weights;\n this._epochs_per_sample = this._make_epochs_per_sample(_n_epochs);\n this._epochs_per_negative_sample = this._epochs_per_sample.map((d) => d * _negative_sample_rate);\n this._epoch_of_next_sample = this._epochs_per_sample.slice();\n this._epoch_of_next_negative_sample = this._epochs_per_negative_sample.slice();\n return this;\n }\n\n graph() {\n this.check_init();\n return { cols: this._head, rows: this._tail, weights: this._weights };\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n transform(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n *generator(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * @private\n * @param {Number} x\n * @returns {Number}\n */\n _clip(x) {\n if (x > 4) return 4;\n if (x < -4) return -4;\n return x;\n }\n\n /**\n * performs the optimization step.\n * @private\n * @param {Matrix} head_embedding\n * @param {Matrix} tail_embedding\n * @param {Matrix} head\n * @param {Matrix} tail\n * @returns {Matrix}\n */\n _optimize_layout(head_embedding, tail_embedding, head, tail) {\n const randomizer = this._randomizer;\n const { _repulsion_strength, d: dim } = this._parameters;\n const { _alpha: alpha, _a: a, _b: b, _epochs_per_sample: epochs_per_sample, _epochs_per_negative_sample: epochs_per_negative_sample, _epoch_of_next_negative_sample: epoch_of_next_negative_sample, _epoch_of_next_sample: epoch_of_next_sample, _clip: clip } = this;\n const tail_length = tail.length;\n\n for (let i = 0, n = epochs_per_sample.length; i < n; ++i) {\n if (epoch_of_next_sample[i] <= this._iter) {\n const j = head[i];\n const k = tail[i];\n const current = head_embedding.row(j);\n const other = tail_embedding.row(k);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (-2 * a * b * Math.pow(dist, b - 1)) / (a * Math.pow(dist, b) + 1);\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(k, d, o);\n }\n epoch_of_next_sample[i] += epochs_per_sample[i];\n const n_neg_samples = (this._iter - epoch_of_next_negative_sample[i]) / epochs_per_negative_sample[i];\n for (let p = 0; p < n_neg_samples; ++p) {\n const k = randomizer.random_int % tail_length;\n const other = tail_embedding.row(tail[k]);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (2 * _repulsion_strength * b) / ((0.01 + dist) * (a * Math.pow(dist, b) + 1));\n } else if (j === k) {\n continue;\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(tail[k], d, o);\n }\n }\n epoch_of_next_negative_sample[i] += n_neg_samples * epochs_per_negative_sample[i];\n }\n }\n return head_embedding;\n }\n\n /**\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const Y = this.Y;\n const { _initial_alpha, _n_epochs } = this._parameters;\n this._alpha = _initial_alpha * (1 - iter / _n_epochs);\n this.Y = this._optimize_layout(Y, Y, this._head, this._tail);\n\n return this.Y;\n }\n}\n","import { Matrix, linspace } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { PCA } from \"./PCA.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TriMap\n * @extends DR\n */\nexport class TriMap extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TriMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.weight_adj = 500] - scaling factor.\n * @param {Number} [parameters.c = 5] - number of triplets multiplier.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.tol = 1e-8] -\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TriMap}\n * @see {@link https://arxiv.org/pdf/1910.00204v1.pdf}\n * @see {@link https://github.com/eamid/trimap}\n */\n constructor(X, parameters) {\n super(X, { weight_adj: 500, c: 5, d: 2, metric: euclidean, tol: 1e-8, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n *\n * @param {Matrix} [pca = null] - Initial Embedding (if null then PCA gets used).\n * @param {KNN} [knn = null] - KNN Object (if null then BallTree gets used).\n */\n init(pca = null, knn = null) {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric, c } = this._parameters;\n this.n_inliers = 2 * c;\n this.n_outliers = 1 * c;\n this.n_random = 1 * c;\n this.Y = pca || new PCA(X, d).transform();\n this.knn = knn || new BallTree(X.to2dArray, metric);\n const { triplets, weights } = this._generate_triplets(this.n_inliers, this.n_outliers, this.n_random);\n this.triplets = triplets;\n this.weights = weights;\n this.lr = (1000 * N) / triplets.shape[0];\n this.C = Infinity;\n this.vel = new Matrix(N, d, 0);\n this.gain = new Matrix(N, d, 1);\n return this;\n }\n\n /**\n * Generates {@link n_inliers} x {@link n_outliers} x {@link n_random} triplets.\n * @param {Number} n_inliers\n * @param {Number} n_outliers\n * @param {Number} n_random\n */\n _generate_triplets(n_inliers, n_outliers, n_random) {\n const { metric, weight_adj } = this._parameters;\n const X = this.X;\n const N = X.shape[0];\n const knn = this.knn;\n const n_extra = Math.min(n_inliers + 20, N);\n const nbrs = new Matrix(N, n_extra);\n const knn_distances = new Matrix(N, n_extra);\n for (let i = 0; i < N; ++i) {\n knn.search(X.row(i), n_extra + 1)\n .raw_data()\n .filter((d) => d.value != 0)\n .sort((a, b) => a.value - b.value)\n .forEach((d, j) => {\n nbrs.set_entry(i, j, d.element.index);\n knn_distances.set_entry(i, j, d.value);\n });\n }\n // scale parameter\n const sig = new Float64Array(N);\n for (let i = 0; i < N; ++i) {\n sig[i] = Math.max((knn_distances.entry(i, 3) + knn_distances.entry(i, 4) + knn_distances.entry(i, 5) + knn_distances.entry(i, 6)) / 4, 1e-10);\n }\n\n const P = this._find_p(knn_distances, sig, nbrs);\n\n let triplets = this._sample_knn_triplets(P, nbrs, n_inliers, n_outliers);\n let n_triplets = triplets.shape[0];\n const outlier_distances = new Float64Array(n_triplets);\n for (let i = 0; i < n_triplets; ++i) {\n const j = triplets.entry(i, 0);\n const k = triplets.entry(i, 2);\n outlier_distances[i] = metric(X.row(j), X.row(k));\n }\n let weights = this._find_weights(triplets, P, nbrs, outlier_distances, sig);\n\n if (n_random > 0) {\n const { random_triplets, random_weights } = this._sample_random_triplets(X, n_random, sig);\n triplets = triplets.concat(random_triplets, \"vertical\");\n weights = Float64Array.from([...weights, ...random_weights]);\n }\n n_triplets = triplets.shape[0];\n let max_weight = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n if (isNaN(weights[i])) {\n weights[i] = 0;\n }\n if (max_weight < weights[i]) max_weight = weights[i];\n }\n let max_weight_2 = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight;\n weights[i] += 0.0001;\n weights[i] = Math.log(1 + weight_adj * weights[i]);\n if (max_weight_2 < weights[i]) max_weight_2 = weights[i];\n }\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight_2;\n }\n return {\n triplets: triplets,\n weights: weights,\n };\n }\n\n /**\n * Calculates the similarity matrix P\n * @private\n * @param {Matrix} knn_distances - matrix of pairwise knn distances\n * @param {Float64Array} sig - scaling factor for the distances\n * @param {Matrix} nbrs - nearest neighbors\n * @returns {Matrix} pairwise similarity matrix\n */\n _find_p(knn_distances, sig, nbrs) {\n const [N, n_neighbors] = knn_distances.shape;\n return new Matrix(N, n_neighbors, (i, j) => {\n return Math.exp(-(knn_distances.entry(i, j) ** 2 / sig[i] / sig[nbrs.entry(i, j)]));\n });\n }\n\n /**\n * Sample nearest neighbors triplets based on the similarity values given in P.\n * @private\n * @param {Matrix} P - Matrix of pairwise similarities between each point and its neighbors given in matrix nbrs.\n * @param {Matrix} nbrs - Nearest neighbors indices for each point. The similarity values are given in matrix {@link P}. Row i corresponds to the i-th point.\n * @param {Number} n_inliers - Number of inlier points.\n * @param {Number} n_outliers - Number of outlier points.\n *\n */\n _sample_knn_triplets(P, nbrs, n_inliers, n_outliers) {\n const N = nbrs.shape[0];\n const triplets = new Matrix(N * n_inliers * n_outliers, 3);\n for (let i = 0; i < N; ++i) {\n let n_i = i * n_inliers * n_outliers;\n const sort_indices = this.__argsort(P.row(i).map((d) => -d));\n for (let j = 0; j < n_inliers; ++j) {\n let n_j = j * n_outliers;\n const sim = nbrs.entry(i, sort_indices[j]);\n const samples = this._rejection_sample(n_outliers, N, sort_indices.slice(0, j + 1));\n for (let k = 0; k < n_outliers; ++k) {\n const index = n_i + n_j + k;\n const out = samples[k];\n triplets.set_entry(index, 0, i);\n triplets.set_entry(index, 1, sim);\n triplets.set_entry(index, 2, out);\n }\n }\n }\n return triplets;\n }\n\n /**\n * Should do the same as np.argsort()\n * @private\n * @param {Array} A\n */\n __argsort(A) {\n return A.map((d, i) => {\n return { d: d, i: i };\n })\n .sort((a, b) => a.d - b.d)\n .map((d) => d.i);\n }\n\n /**\n * Samples {@link n_samples} integers from a given interval [0, {@link max_int}] while rejection the values that are in the {@link rejects}.\n * @private\n * @param {*} n_samples\n * @param {*} max_int\n * @param {*} rejects\n */\n _rejection_sample(n_samples, max_int, rejects) {\n const randomizer = this._randomizer;\n const interval = linspace(0, max_int - 1).filter((d) => rejects.indexOf(d) < 0);\n return randomizer.choice(interval, Math.min(n_samples, interval.length - 2));\n }\n\n /**\n * Calculates the weights for the sampled nearest neighbors triplets\n * @private\n * @param {Matrix} triplets - Sampled Triplets.\n * @param {Matrix} P - Pairwise similarity matrix.\n * @param {Matrix} nbrs - nearest Neighbors\n * @param {Float64Array} outlier_distances - Matrix of pairwise outlier distances\n * @param {Float64Array} sig - scaling factor for the distances.\n */\n _find_weights(triplets, P, nbrs, outlier_distances, sig) {\n const n_triplets = triplets.shape[0];\n const weights = new Float64Array(n_triplets);\n for (let t = 0; t < n_triplets; ++t) {\n const i = triplets.entry(t, 0);\n const sim = nbrs.row(i).indexOf(triplets.entry(t, 1));\n const p_sim = P.entry(i, sim);\n let p_out = Math.exp(-(outlier_distances[t] ** 2 / (sig[i] * sig[triplets.entry(t, 2)])));\n if (p_out < 1e-20) p_out = 1e-20;\n weights[t] = p_sim / p_out;\n }\n return weights;\n }\n\n /**\n * Sample uniformly ranom triplets\n * @private\n * @param {Matrix} X - Data matrix.\n * @param {Number} n_random - Number of random triplets per point\n * @param {Float64Array} sig - Scaling factor for the distances\n */\n _sample_random_triplets(X, n_random, sig) {\n const metric = this.parameter(\"metric\");\n const randomizer = this._randomizer;\n const N = X.shape[0];\n const random_triplets = new Matrix(N * n_random, 3);\n const random_weights = new Float64Array(N * n_random);\n for (let i = 0; i < N; ++i) {\n const n_i = i * n_random;\n const indices = [...linspace(0, i - 1), ...linspace(i + 1, N - 1)];\n for (let j = 0; j < n_random; ++j) {\n let [sim, out] = randomizer.choice(indices, 2);\n let p_sim = Math.exp(-(metric(X.row(i), X.row(sim)) ** 2 / (sig[i] * sig[sim])));\n if (p_sim < 1e-20) p_sim = 1e-20;\n let p_out = Math.exp(-(metric(X.row(i), X.row(out)) ** 2 / (sig[i] * sig[out])));\n if (p_out < 1e-20) p_out = 1e-20;\n\n if (p_sim < p_out) {\n [sim, out] = [out, sim];\n [p_sim, p_out] = [p_out, p_sim];\n }\n const index = n_i + j;\n random_triplets.set_entry(index, 0, i);\n random_triplets.set_entry(index, 1, sim);\n random_triplets.set_entry(index, 2, out);\n random_weights[index] = p_sim / p_out;\n }\n }\n return {\n random_triplets: random_triplets,\n random_weights: random_weights,\n };\n }\n\n /**\n * Computes the gradient for updating the embedding.\n * @param {Matrix} Y - The embedding\n */\n _grad(Y) {\n const n_inliers = this.n_inliers;\n const n_outliers = this.n_outliers;\n const triplets = this.triplets;\n const weights = this.weights;\n const [N, dim] = Y.shape;\n const n_triplets = triplets.shape[0];\n const grad = new Matrix(N, dim, 0);\n let y_ij = new Float64Array(dim);\n let y_ik = new Float64Array(dim);\n let d_ij = 1;\n let d_ik = 1;\n let n_viol = 0;\n let loss = 0;\n const n_knn_triplets = N * n_inliers * n_outliers;\n\n for (let t = 0; t < n_triplets; ++t) {\n const [i, j, k] = triplets.row(t);\n // update y_ij, y_ik, d_ij, d_ik\n if (t % n_outliers == 0 || t >= n_knn_triplets) {\n d_ij = 1;\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_jd = Y.entry(j, d);\n const Y_kd = Y.entry(k, d);\n y_ij[d] = Y_id - Y_jd;\n y_ik[d] = Y_id - Y_kd;\n d_ij += y_ij[d] ** 2;\n d_ik += y_ik[d] ** 2;\n }\n // update y_ik and d_ik only\n } else {\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_kd = Y.entry(k, d);\n y_ik[d] = Y_id - Y_kd;\n d_ik += y_ik[d] ** 2;\n }\n }\n\n if (d_ij > d_ik) ++n_viol;\n loss += weights[t] / (1 + d_ik / d_ij);\n const w = (weights[t] / (d_ij + d_ik)) ** 2;\n for (let d = 0; d < dim; ++d) {\n const gs = y_ij[d] * d_ik * w;\n const go = y_ik[d] * d_ij * w;\n grad.set_entry(i, d, grad.entry(i, d) + gs - go);\n grad.set_entry(j, d, grad.entry(j, d) - gs);\n grad.set_entry(k, d, grad.entry(k, d) + go);\n }\n }\n return { grad, loss, n_viol };\n }\n\n /**\n *\n * @param {Number} max_iteration\n */\n transform(max_iteration = 400) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n }\n return this.projection;\n }\n\n /**\n * @param {Number} max_iteration\n * @yields {Matrix}\n * @returns {Matrix}\n */\n *generator(max_iteration = 800) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * Does the iteration step.\n * @private\n * @param {Number} iter\n */\n _next(iter) {\n const gamma = iter > 150 ? 0.5 : 0.3;\n const old_C = this.C;\n const vel = this.vel;\n const Y = this.Y.add(vel.mult(gamma));\n const { grad, loss, n_viol } = this._grad(Y);\n this.C = loss;\n this.Y = this._update_embedding(Y, iter, grad);\n this.lr *= old_C > loss + this._parameters.tol ? 1.01 : 0.9;\n return this.Y;\n }\n\n /**\n * Updates the embedding.\n * @private\n * @param {Matrix} Y\n * @param {Number} iter\n * @param {Matrix} grad\n */\n _update_embedding(Y, iter, grad) {\n const [N, dim] = Y.shape;\n const gamma = iter > 150 ? 0.9 : 0.5; // moment parameter\n const min_gain = 0.01;\n const gain = this.gain;\n const vel = this.vel;\n const lr = this.lr;\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const new_gain = Math.sign(vel.entry(i, d)) != Math.sign(grad.entry(i, d)) ? gain.entry(i, d) + 0.2 : Math.max(gain.entry(i, d) * 0.8, min_gain);\n gain.set_entry(i, d, new_gain);\n vel.set_entry(i, d, gamma * vel.entry(i, d) - lr * gain.entry(i, d) * grad.entry(i, d));\n Y.set_entry(i, d, Y.entry(i, d) + vel.entry(i, d));\n }\n }\n return Y;\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n/**\n * @class\n * @alias Hierarchical_Clustering\n */\nexport class Hierarchical_Clustering {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias Hierarchical_Clustering\n * @todo needs restructuring.\n * @param {Matrix} - Data or distance matrix if metric is 'precomputed'\n * @param {(\"single\"|\"complete\"|\"average\")} [linkage = \"complete\"]\n * @param {Function|\"precomputed\"} [metric = euclidean]\n * @returns {Hierarchical_Clustering}\n */\n constructor(matrix, linkage = \"complete\", metric = euclidean) {\n this._id = 0;\n this._matrix = matrix instanceof Matrix ? matrix : Matrix.from(matrix);\n this._metric = metric;\n this._linkage = linkage;\n if (metric === \"precomputed\" && this._matrix.shape[0] !== this._matrix.shape[1]) {\n throw new Error(\"If metric is 'precomputed', then matrix has to be square!\");\n }\n this.init();\n this.root = this.do();\n return this;\n }\n\n /**\n *\n * @param {Number} value - value where to cut the tree.\n * @param {(\"distance\"|\"depth\")} [type = \"distance\"] - type of value.\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters(value, type = \"distance\") {\n let clusters = [];\n let accessor;\n switch (type) {\n case \"distance\":\n accessor = (d) => d.dist;\n break;\n case \"depth\":\n accessor = (d) => d.depth;\n break;\n default:\n throw new Error(\"invalid type\");\n }\n this._traverse(this.root, accessor, value, clusters);\n return clusters;\n }\n\n /**\n * @private\n * @param {} node\n * @param {*} f\n * @param {*} value\n * @param {*} result\n */\n _traverse(node, f, value, result) {\n if (f(node) <= value) {\n result.push(node.leaves());\n } else {\n this._traverse(node.left, f, value, result);\n this._traverse(node.right, f, value, result);\n }\n }\n\n /**\n * computes the tree.\n */\n init() {\n const metric = this._metric;\n const A = this._matrix;\n const n = (this._n = A.shape[0]);\n const d_min = (this._d_min = new Float64Array(n));\n let distance_matrix;\n if (metric !== \"precomputed\") {\n distance_matrix = new Matrix(n, n, 0); //new Array(n);\n for (let i = 0; i < n; ++i) {\n d_min[i] = 0;\n //distance_matrix[i] = new Float64Array(n);\n for (let j = 0; j < n; ++j) {\n distance_matrix.set_entry(i, j, i === j ? Infinity : metric(A.row(i), A.row(j)));\n if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n } else {\n distance_matrix = this._matrix.clone();\n for (let i = 0; i < n; ++i) {\n for (let j = 0; j < n; ++j) {\n if (i === j) {\n distance_matrix.set_entry(i, j, Infinity);\n } else if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n }\n this._distance_matrix = distance_matrix;\n const clusters = (this._clusters = new Array(n));\n const c_size = (this._c_size = new Uint16Array(n));\n for (let i = 0; i < n; ++i) {\n clusters[i] = [];\n clusters[i][0] = new Cluster(this._id++, null, null, 0, A.row(i), i, 1, 0);\n c_size[i] = 1;\n }\n return this;\n }\n\n /**\n * computes the tree.\n */\n do() {\n const n = this._n;\n const d_min = this._d_min;\n const D = this._distance_matrix;\n const clusters = this._clusters;\n const c_size = this._c_size;\n const linkage = this._linkage;\n let root = null;\n for (let p = 0, p_max = n - 1; p < p_max; ++p) {\n let c1 = 0;\n for (let i = 0; i < n; ++i) {\n let D_i_min = D.entry(i, d_min[i]);\n for (let j = i + 1; j < n; ++j) {\n if (D_i_min > D.entry(i, j)) {\n d_min[i] = j;\n D_i_min = D.entry(i, d_min[i]);\n }\n }\n }\n for (let i = 0; i < n; ++i) {\n if (D.entry(i, d_min[i]) < D.entry(c1, d_min[c1])) {\n c1 = i;\n }\n }\n let c2 = d_min[c1];\n let c1_cluster = clusters[c1][0];\n let c2_cluster = clusters[c2][0];\n let c1_cluster_indices = c1_cluster.isLeaf ? [c1_cluster.index] : c1_cluster.index;\n let c2_cluster_indices = c2_cluster.isLeaf ? [c2_cluster.index] : c2_cluster.index;\n let indices = c1_cluster_indices.concat(c2_cluster_indices);\n let new_cluster = new Cluster(this._id++, c1_cluster, c2_cluster, D.entry(c1, c2), null, indices);\n c1_cluster.parent = new_cluster;\n c2_cluster.parent = new_cluster;\n clusters[c1].unshift(new_cluster);\n c_size[c1] += c_size[c2];\n for (let j = 0; j < n; ++j) {\n const D_c1_j = D.entry(c1, j);\n const D_c2_j = D.entry(c2, j);\n let value;\n switch (linkage) {\n case \"single\":\n value = Math.min(D_c1_j, D_c2_j);\n break;\n case \"complete\":\n value = Math.max(D_c1_j, D_c2_j);\n break;\n case \"average\":\n value = (c_size[c1] * D_c1_j + c_size[c2] * D_c2_j) / (c_size[c1] + c_size[j]);\n break;\n }\n D.set_entry(j, c1, value);\n D.set_entry(c1, j, value);\n }\n\n D.set_entry(c1, c1, Infinity);\n for (let i = 0; i < n; ++i) {\n D.set_entry(i, c2, Infinity);\n D.set_entry(c2, i, Infinity);\n }\n\n /* for (let j = 0; j < n; ++j) {\n if (d_min[j] === c2) {\n d_min[j] = c1;\n }\n if (D.entry(c1, j) < D.entry(c1, d_min[c1])) {\n d_min[c1] = j;\n }\n } */\n root = new_cluster;\n }\n return root;\n }\n}\n\nclass Cluster {\n constructor(id, left, right, dist, centroid, index, size, depth) {\n this.id = id;\n this.left = left;\n this.right = right;\n this.dist = dist;\n this.index = index;\n this.size = size ?? left.size + right.size;\n this.depth = depth ?? 1 + Math.max(left.depth, right.depth);\n this.centroid = centroid ?? this._calculate_centroid(left, right);\n this.parent = null;\n return this;\n }\n\n _calculate_centroid(left, right) {\n const l_size = left.size;\n const r_size = right.size;\n const l_centroid = left.centroid;\n const r_centroid = right.centroid;\n const size = this.size;\n const n = left.centroid.length;\n const new_centroid = new Float64Array(n);\n for (let i = 0; i < n; ++i) {\n new_centroid[i] = (l_size * l_centroid[i] + r_size * r_centroid[i]) / size;\n }\n return new_centroid;\n }\n\n get isLeaf() {\n return this.depth === 0;\n }\n\n leaves() {\n if (this.isLeaf) return [this];\n const left = this.left;\n const right = this.right;\n return (left.isLeaf ? [left] : left.leaves()).concat(right.isLeaf ? [right] : right.leaves());\n }\n\n descendants() {\n if (this.isLeaf) return [this];\n const left_descendants = this.left.descendants();\n const right_descendants = this.right.descendants();\n return left_descendants.concat(right_descendants).concat([this]);\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { linspace } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KMeans\n */\nexport class KMeans {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMeans\n * @todo needs restructuring. \n * @param {Matrix} matrix \n * @param {Numbers} K \n * @param {Function} [metric = euclidean] \n * @param {Number} [seed = 1987]\n * @param {Boolean} [init = true]\n * @returns {KMeans}\n */\n constructor(matrix, K, metric = euclidean, seed=1987, init = true) {\n this._metric = metric;\n this._matrix = matrix;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_centroids = this._get_random_centroids(K);\n if (init) this.init(K, this._cluster_centroids);\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const clusters = this._clusters;\n const result = new Array(K).fill().map(() => new Array());\n clusters.forEach((c, i) => result[c].push(i));\n return result;\n }\n\n /**\n * @private\n * @param {Array} points \n * @param {Array} candidates \n */\n _furthest_point(points, candidates) {\n const A = this._matrix;\n const metric = this._metric;\n let i = points.length;\n let H = Heap.heapify(\n candidates, \n (d) => {\n const Ad = A.row(d)\n let sum = 0;\n for (let j = 0; j < i; ++j) {\n sum += metric(Ad, points[j])\n }\n return sum;\n }, \n \"max\"\n )\n return H.pop().element;\n }\n\n _get_random_centroids(K) {\n const N = this._N;\n const randomizer = this._randomizer;\n const A = this._matrix;\n const cluster_centroids = new Array(K).fill()\n const indices = linspace(0, N - 1);\n const random_point = randomizer.random_int % (N - 1);\n cluster_centroids[0] = A.row(random_point);\n const init_points = [random_point];\n const sample_size = Math.floor((N - K) / K);// / K\n for (let i = 1; i < K; ++i) {\n // sampling + kmeans++ improvement?\n const sample = randomizer.choice(indices.filter(d => init_points.indexOf(d) == -1), sample_size);\n const furthest_point = this._furthest_point(cluster_centroids.slice(0, i), sample);\n init_points.push(furthest_point);\n cluster_centroids[i] = A.row(furthest_point);\n }\n return cluster_centroids;\n }\n\n _iteration(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const metric = this._metric;\n const clusters = this._clusters;\n let clusters_changed = false;\n // find nearest cluster centroid.\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i)\n let min_dist = Infinity;\n let min_cluster = null;\n for (let j = 0; j < K; ++j) {\n let d = metric(cluster_centroids[j], Ai);\n if (d < min_dist) {\n min_dist = d;\n min_cluster = j; \n }\n }\n if (clusters[i] !== min_cluster) {\n clusters_changed = true;\n }\n clusters[i] = min_cluster;\n }\n // update cluster centroid\n // reset cluster centroids to 0\n for (let i = 0; i < K; ++i) {\n const centroid = cluster_centroids[i];\n for (let j = 0; j < D; ++j) {\n centroid[j] = 0;\n }\n }\n // compute centroid\n this._compute_centroid(cluster_centroids);\n\n return { \n \"clusters_changed\": clusters_changed,\n \"cluster_centroids\": cluster_centroids\n };\n }\n\n _compute_centroid(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const clusters = this._clusters;\n const cluster_counter = new Array(K).fill(0);\n\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i);\n const ci = clusters[i];\n cluster_counter[ci]++;\n const centroid = cluster_centroids[ci];\n for (let j = 0; j < D; ++j) {\n centroid[j] += Ai[j];\n }\n }\n for (let i = 0; i < K; ++i) {\n const n = cluster_counter[i];\n cluster_centroids[i] = cluster_centroids[i].map(c => c / n);\n }\n \n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_centroids) {\n if (!K) K = this._K;\n if (!cluster_centroids) cluster_centroids = this._get_random_centroids(K);\n let clusters_changed = false;\n do {\n const iteration_result = this._iteration(cluster_centroids)\n cluster_centroids = iteration_result.cluster_centroids;\n clusters_changed = iteration_result.clusters_changed;\n } while (clusters_changed)\n }\n \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { linspace, Matrix } from \"../matrix/index.js\";\nimport { min } from \"../util/index.js\";\n/**\n * @class\n * @alias KMedoids\n */\nexport class KMedoids {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMedoids\n * @todo needs restructuring. \n * @param {Matrix} matrix - data matrix\n * @param {Numbers} K - number of clusters\n * @param {number} [max_iter=null] - maximum number of iterations. Default is 10 * Math.log10(N)\n * @param {Function} [metric = euclidean] - metric defining the dissimilarity \n * @param {Number} [seed = 1212] - seed value for random number generator\n * @returns {KMedoids}\n * @see {@link https://link.springer.com/chapter/10.1007/978-3-030-32047-8_16} Faster k-Medoids Clustering: Improving the PAM, CLARA, and CLARANS Algorithms\n */\n constructor(matrix, K, max_iter=null, metric = euclidean, seed=1212) {\n this._metric = metric;\n this._matrix = matrix;\n this._A = this._matrix.to2dArray;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n this._max_iter = max_iter || 10 * Math.log10(N) \n this._distance_matrix = new Matrix(N, N, \"zeros\");\n /* for (let i = 1; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dist = metric(this._A[i], this._A[j]);\n this._distance_matrix.set_entry(i, j, dist);\n this._distance_matrix.set_entry(j, i, dist)\n }\n } */\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_medoids = this._get_random_medoids(K);\n //if (init) this.init(K, this._cluster_medoids);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const A = this._A;\n if (!this._is_initialized) {\n this.init(K, this._cluster_medoids);\n }\n const result = new Array(K).fill().map(() => new Array());\n A.forEach((x_j, j) => {\n result[this._nearest_medoid(x_j, j).index_nearest].push(j);\n })\n result.medoids = this._cluster_medoids;\n return result;\n }\n\n async* generator() {\n const max_iter = this._max_iter;\n yield this.get_clusters()\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n yield this.get_clusters();\n } while (!finish && ++i < max_iter)\n }\n\n /**\n * Algorithm 1. FastPAM1: Improved SWAP algorithm\n */\n /* _iteration_1() {\n const A = this._A;\n const N = this._N;\n const K = this._K;\n const medoids = this._cluster_medoids;\n let DeltaTD = 0;\n let m0 = null;\n let x0 = null;\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const nearest_medoid = this._nearest_medoid(x_j, j);\n const d_j = nearest_medoid.distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n // disance to new medoid\n const d_oj = this._get_distance(o, j, x_o, x_j);\n const {\n \"index_nearest\": n,\n \"distance_nearest\": d_n,\n \"distance_second\": d_s,\n } = this._nearest_medoid(x_o, o); \n this._clusters[o] = n; // cached values\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change\n if (d_oj < d_n) { // reassignment check\n deltaTD.forEach((d_i, i) => {\n if (n !== i) {\n deltaTD[i] = d_i + d_oj - d_n; // update loss change\n }\n });\n }\n });\n // choose best medoid i;\n const i = deltaTD\n .map((d, i) => [d, i])\n .sort((d1, d2) => d1[0] - d2[0])[0][1];\n const deltaTD_i = deltaTD[i];\n // store\n if (deltaTD_i < DeltaTD) {\n DeltaTD = deltaTD_i;\n m0 = i;\n x0 = j;\n }\n }\n });\n\n if (DeltaTD >= 0) {\n return true // break loop if DeltaTD >= 0\n }\n // swap roles of medoid m and non-medoid x;\n medoids[m0] = x0;\n this._cluster_medoids = medoids;\n return false\n } */\n\n /** Algorithm 2. FastPAM2: SWAP with multiple candidates\n * \n */\n _iteration() {\n const A = this._A;\n const K = this._K;\n const medoids = this._cluster_medoids;\n const cache = A.map((x_o, o) => this._nearest_medoid(x_o, o));\n // empty best candidates array\n const DeltaTD = new Array(K).fill(0);\n const xs = new Array(K).fill(null);\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const d_j = cache[j].distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n if (j === o) return;\n const d_oj = this._get_distance(o, j, x_o, x_j); // distance to new medoid\n const {\"index_nearest\": n, \"distance_nearest\": d_n, \"distance_second\": d_s} = cache[o]; // cached\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change for x_o\n // Reassignment check\n if (d_oj < d_n) { \n // update loss change\n for (let i = 0; i < K; ++i) {\n if (i !== n) deltaTD[i] += d_oj - d_n;\n }\n }\n });\n // remember best swap for i;\n deltaTD\n .map((d, i) => [d, i])\n .filter(([d, i]) => d < DeltaTD[i])\n .forEach(([d, i]) => {\n if (d < DeltaTD[i]) {\n DeltaTD[i] = d;\n xs[i] = j;\n }\n })\n }\n })\n // stop if no improvements were found\n if (min(DeltaTD) >= 0) return true; \n\n // execute all improvements\n while (min(DeltaTD) < 0) {\n // swap roles of medoid m_i and non_medoid xs_i\n const i = DeltaTD\n .map((d, i) => [d, i])\n .sort(([a], [b]) => a - b)[0][1];\n if (medoids.filter(m => m == xs[i]).length == 0) {\n medoids[i] = xs[i];\n }\n // disable the swap just performed\n DeltaTD[i] = 0; \n // recompute TD for remaining swap candidates\n DeltaTD\n .map((d_j, j) => [d_j, j])\n .filter(([d_j]) => d_j < 0)\n .forEach(([_, j]) => {\n const x_j = A[j];\n let sum = 0;\n A.forEach((x_o, o) => {\n if (medoids.findIndex(m => m != j && m == o) >= 0) return;\n if (i == j) return;\n if (cache[o].index_nearest === medoids[j])\n sum += (Math.min(this._get_distance(o, j, x_o, x_j), cache[o].distance_second) - cache[o].distance_nearest); \n else {\n sum += (Math.min(this._get_distance(o, j, x_o, x_j) - cache[o].distance_nearest, 0));\n }\n });\n DeltaTD[j] = sum;\n })\n }\n this._cluster_medoids = medoids;\n return false;\n }\n\n _get_distance(i, j, x_i=null, x_j=null) {\n if (i === j) return 0;\n const D = this._distance_matrix;\n const A = this._A;\n const metric = this._metric;\n let d_ij = D.entry(i, j);\n if (d_ij === 0) {\n d_ij = metric(x_i || A[i], x_j || A[j]);\n D.set_entry(i, j, d_ij);\n D.set_entry(j, i, d_ij);\n }\n return d_ij;\n }\n\n _nearest_medoid(x_j, j) {\n const medoids = this._cluster_medoids;\n const A = this._A;\n const [nearest, second] = medoids\n .map((m, i) => {\n const x_m = A[m]; \n return [this._get_distance(j, m, x_j, x_m), i];\n })\n .sort((m1, m2) => m1[0] - m2[0]);\n \n return { \n \"distance_nearest\": nearest[0], \n \"index_nearest\": nearest[1],\n \"distance_second\": second[0],\n \"index_second\": second[1],\n };\n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_medoids) {\n if (!K) K = this._K;\n if (!cluster_medoids) cluster_medoids = this._get_random_medoids(K);\n const max_iter = this._max_iter;\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n } while (!finish && ++i < max_iter)\n return this;\n }\n\n /**\n * Algorithm 3. FastPAM LAB: Linear Approximate BUILD initialization.\n * @param {number} K - number of clusters\n * \n */\n _get_random_medoids(K) {\n const N = this._N;\n const A = this._A;\n const indices = linspace(0, N - 1);\n const randomizer = this._randomizer;\n const n = Math.min(N, 10 + Math.ceil(Math.sqrt(N)));\n const TD = new Array(n).fill(Infinity);\n const medoids = [];\n // first medoid\n let TD0 = Infinity;\n let S = randomizer.choice(indices, n);\n for (let j = 0; j < n; ++j) {\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const x_o = A[S[o]];\n TD[j] += this._get_distance(j, o, x_j, x_o);\n }\n if (TD[j] < TD0) {\n TD0 = TD[j]; // smallest distance sum\n medoids.push(S_j);\n }\n }\n // other medoids\n for (let i = 1; i < K; ++i) {\n let DeltaTD = Infinity;\n S = randomizer.choice(indices.filter(index => medoids.findIndex(d => d === index) < 0), n);\n for (let j = 0; j < n; ++j) {\n let deltaTD = 0;\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const S_o = S[o];\n const x_o = A[S_o];\n let delta = this._get_distance(S_j, S_o, x_j, x_o) - min(medoids.map(m => this._get_distance(S_o, m, x_o)));\n if (delta < 0) {\n deltaTD = deltaTD + delta;\n }\n }\n // best reduction\n if (deltaTD < DeltaTD) {\n DeltaTD = deltaTD;\n medoids.push(S_j);\n }\n }\n TD0 += DeltaTD;\n }\n return medoids.slice(0, K);\n }\n \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias OPTICS\n */\nexport class OPTICS {\n /**\n * **O**rdering **P**oints **T**o **I**dentify the **C**lustering **S**tructure.\n * @constructor\n * @memberof module:clustering\n * @alias OPTICS\n * @todo needs restructuring. \n * @param {Matrix} matrix - the data.\n * @param {Number} epsilon - the minimum distance which defines whether a point is a neighbor or not.\n * @param {Number} min_points - the minimum number of points which a point needs to create a cluster. (Should be higher than 1, else each point creates a cluster.)\n * @param {Function} [metric = euclidean] - the distance metric which defines the distance between two points of the {@link matrix}.\n * @returns {OPTICS}\n * @see {@link https://www.dbs.ifi.lmu.de/Publikationen/Papers/OPTICS.pdf}\n * @see {@link https://en.wikipedia.org/wiki/OPTICS_algorithm}\n */\n constructor(matrix, epsilon, min_points, metric = euclidean) {\n this._matrix = matrix;\n this._epsilon = epsilon;\n this._min_points = min_points;\n this._metric = metric;\n\n this._ordered_list = [];\n this._clusters = [];\n this._DB = new Array(matrix.shape[0]).fill();\n this.init();\n return this;\n }\n\n /**\n * Computes the clustering.\n */\n init() {\n const ordered_list = this._ordered_list;\n const matrix = this._matrix;\n const N = matrix.shape[0];\n const DB = this._DB;\n const clusters = this._clusters;\n let cluster_index = this._cluster_index = 0;\n\n for (let i = 0; i < N; ++i) {\n DB[i] = {\n \"element\": matrix.row(i),\n \"index\": i,\n \"reachability_distance\": undefined,\n \"processed\": false,\n }\n }\n for (const p of DB) {\n if (p.processed) continue;\n p.neighbors = this._get_neighbors(p);\n p.processed = true;\n clusters.push([p.index])\n cluster_index = clusters.length - 1;\n ordered_list.push(p);\n if (this._core_distance(p) != undefined) {\n const seeds = new Heap(null, d => d.reachability_distance, \"min\")\n this._update(p, seeds);\n this._expand_cluster(seeds, clusters[cluster_index]);\n }\n }\n return this;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Array} An array consisting of the {@link epsilon}-neighborhood of {@link p}.\n */\n _get_neighbors(p) {\n if (\"neighbors\" in p) return p.neighbors;\n const DB = this._DB;\n const metric = this._metric;\n const epsilon = this._epsilon;\n const neighbors = [];\n for (const q of DB) {\n if (q.index == p.index) continue;\n if (metric(p.element, q.element) < epsilon) {\n neighbors.push(q);\n }\n }\n return neighbors;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Number} The distance to the {@link min_points}-th nearest point of {@link p}, or undefined if the {@link epsilon}-neighborhood has fewer elements than {@link min_points}.\n */\n _core_distance(p) {\n const min_points = this._min_points;\n const metric = this._metric;\n if (p.neighbors && p.neighbors.length <= min_points) {\n return undefined;\n }\n return metric(p.element, p.neighbors[min_points].element);\n }\n\n /**\n * Updates the reachability distance of the points.\n * @private\n * @param {Object} p \n * @param {Heap} seeds \n */\n _update(p, seeds) {\n const metric = this._metric;\n const core_distance = this._core_distance(p);\n const neighbors = this._get_neighbors(p);//p.neighbors;\n for (const q of neighbors) {\n if (q.processed) continue;\n const new_reachability_distance = Math.max(core_distance, metric(p.element, q.element));\n //if (q.reachability_distance == undefined) { // q is not in seeds\n if (seeds.raw_data().findIndex(d => d.element == q) < 0) {\n q.reachability_distance = new_reachability_distance;\n seeds.push(q);\n } else { // q is in seeds\n if (new_reachability_distance < q.reachability_distance) {\n q.reachability_distance = new_reachability_distance;\n seeds = Heap.heapify(seeds.data(), d => d.reachability_distance, \"min\"); // seeds change key =/\n }\n }\n }\n }\n\n /**\n * Expands the {@link cluster} with points in {@link seeds}.\n * @private\n * @param {Heap} seeds \n * @param {Array} cluster \n */\n _expand_cluster(seeds, cluster) {\n const ordered_list = this._ordered_list;\n while (!seeds.empty) {\n const q = seeds.pop().element;\n q.neighbors = this._get_neighbors(q);\n q.processed = true;\n cluster.push(q.index);\n ordered_list.push(q);\n if (this._core_distance(q) != undefined) {\n this._update(q, seeds);\n this._expand_cluster(seeds, cluster);\n }\n }\n }\n\n /**\n * Returns an array of clusters.\n * @returns {Array} Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters() {\n const clusters = [];\n const outliers = [];\n const min_points = this._min_points;\n for (const cluster of this._clusters) {\n if (cluster.length < min_points) {\n outliers.push(...cluster);\n } else {\n clusters.push(cluster);\n }\n }\n clusters.push(outliers);\n return clusters;\n }\n\n /**\n * @returns {Array} Returns an array, where the ith entry defines the cluster affirmation of the ith point of {@link matrix}. (-1 stands for outlier)\n */\n get_cluster_affirmation() {\n const N = this._matrix.shape[0];\n const result = new Array(N).fill();\n const clusters = this.get_clusters();\n for (let i = 0, n = clusters.length; i < n; ++i) {\n const cluster = clusters[i]\n for (const index of cluster) {\n result[index] = (i < n - 1) ? i : -1;\n }\n }\n return result;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\nimport { MDS } from \"./MDS.js\";\nimport { KMedoids } from \"../clustering/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\n/**\n * @class\n * @alias LSP\n * @extends DR\n */\nexport class LSP extends DR {\n /**\n * Least Squares Projection.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LSP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.neighbors = Math.max(Math.floor(N / 10), 2)] - number of neighbors to consider.\n * @param {Number} [parameters.control_points = Math.ceil(Math.sqrt(N))] - number of controlpoints\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {LSP}\n * @see {@link https://ieeexplore.ieee.org/document/4378370}\n * @todo accept precomputed distance matrix.\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, control_points: undefined, d: 2, metric: euclidean, seed: 1212 }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n this.parameter(\"control_points\", Math.min(parameters.control_points ?? Math.ceil(Math.sqrt(this._N)), this._N - 1));\n this._is_initialized = false;\n return this;\n }\n\n /**\n *\n * @param {DR} DR - method used for position control points.\n * @param {Object} DR_parameters - Object containing parameters for the DR method which projects the control points\n * @returns {LSP}\n */\n init(DR = MDS, DR_parameters = {}, KNN = BallTree) {\n if (this._is_initialized) return this;\n const X = this.X;\n const N = this._N;\n const K = this.parameter(\"neighbors\");\n const d = this.parameter(\"d\");\n const seed = this.parameter(\"seed\");\n const metric = this.parameter(\"metric\");\n DR_parameters = Object.assign({d, metric, seed }, DR_parameters);\n const nc = this.parameter(\"control_points\");\n const control_points = new KMedoids(X, nc, null, metric).get_clusters().medoids;\n const C = new Matrix(nc, N, \"zeros\");\n control_points.forEach((c_i, i) => {\n C.set_entry(i, c_i, 1);\n });\n const Y_C = new DR(Matrix.from(control_points.map((c_i) => X.row(c_i))), DR_parameters).transform();\n\n const XA = X.to2dArray;\n const knn = new KNN(XA, metric);\n const L = new Matrix(N, N, \"I\");\n const alpha = -1 / K;\n XA.forEach((x_i, i) => {\n for (const { index: j } of knn.search(x_i, K).iterate()) {\n if (i === j) continue;\n L.set_entry(i, j, alpha);\n }\n });\n const A = L.concat(C, \"vertical\");\n\n const z = new Matrix(N, d, \"zeros\");\n const b = z.concat(Y_C, \"vertical\");\n\n this._A = A;\n this._b = b;\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const A = this._A;\n const AT = A.T;\n const b = this._b;\n const ATA = AT.dot(A);\n const ATb = AT.dot(b);\n this.Y = Matrix.solve_CG(ATA, ATb, this._randomizer);\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { DisjointSet } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias TopoMap\n * @memberof module:dimensionality_reduction\n * @extends DR\n */\nexport class TopoMap extends DR {\n /**\n * TopoMap: A 0-dimensional Homology Preserving Projection of High-Dimensional Data.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TopoMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TopoMap}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._distance_matrix = new Matrix(this._N, this._N, 0);\n return this;\n }\n\n /**\n * @private\n */\n __lazy_distance_matrix(i, j, metric) {\n const D = this._distance_matrix;\n const X = this.X;\n const D_ij = D.entry(i, j);\n if (D_ij === 0) {\n let dist = metric(X.row(i), X.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n return dist;\n }\n return D_ij;\n }\n\n /**\n * Computes the minimum spanning tree, using a given metric\n * @private\n * @param {Function} metric\n * @see {@link https://en.wikipedia.org/wiki/Kruskal%27s_algorithm}\n */\n _make_minimum_spanning_tree(metric = euclidean) {\n const N = this._N;\n const X = [...this.X];\n\n let disjoint_set = new DisjointSet(X);\n const F = [];\n let E = [];\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n E.push([i, j, this.__lazy_distance_matrix(i, j, metric)]);\n }\n }\n E = E.sort((a, b) => a[2] - b[2]);\n\n for (const [u, v, w] of E) {\n const set_u = disjoint_set.find(X[u]);\n const set_v = disjoint_set.find(X[v]);\n if (set_u !== set_v) {\n F.push([u, v, w]);\n disjoint_set.union(set_u, set_v);\n }\n }\n\n return F.sort((a, b) => a[2] - b[2]);\n }\n\n /**\n * initializes TopoMap. Sets all projcted points to zero, and computes a minimum spanning tree.\n */\n init() {\n const { metric} = this._parameters\n this.Y = new Matrix(this._N, 2, 0);\n this._Emst = this._make_minimum_spanning_tree(metric);\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Returns true if Point C is left of line AB.\n * @private\n * @param {Array} PointA - Point A of line AB\n * @param {Array} PointB - Point B of line AB\n * @param {Array} PointC - Point C\n * @returns {Boolean}\n */\n __hull_cross([ax, ay], [bx, by], [sx, sy]) {\n return (bx - ax) * (sy - ay) - (by - ay) * (sx - ax) <= 0;\n }\n\n /**\n * Computes the convex hull of the set of Points S\n * @private\n * @param {Array} S - Set of Points.\n * @see {@link https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain#JavaScript}\n * @returns {Array} convex hull of S. Starts at the bottom-most point and continues counter-clockwise.\n */\n __hull(S) {\n const points = S.sort(([x1, y1], [x2, y2]) => y1 - y2 || x1 - x2);\n const N = points.length;\n if (N <= 2) return points;\n\n const lower = [];\n for (let i = 0; i < N; ++i) {\n while (lower.length >= 2 && this.__hull_cross(lower[lower.length - 2], lower[lower.length - 1], points[i])) {\n lower.pop();\n }\n lower.push(points[i]);\n }\n const upper = [];\n for (let i = N - 1; i >= 0; --i) {\n while (upper.length >= 2 && this.__hull_cross(upper[upper.length - 2], upper[upper.length - 1], points[i])) {\n upper.pop();\n }\n upper.push(points[i]);\n }\n upper.pop();\n lower.pop();\n return lower.concat(upper);\n }\n\n /**\n * Finds the angle to rotate Point A and B to lie on a line parallel to the x-axis.\n * @private\n * @param {Array} PointA\n * @param {Array} PointB\n * @return {Object} Object containing the sinus- and cosinus-values for a rotation.\n */\n __findAngle([p1x, p1y], [p2x, p2y]) {\n const n = euclidean([p1x, p1y], [p2x, p2y]);\n if (n === 0)\n return {\n sin: 0,\n cos: 1,\n };\n const vec = [(p2x - p1x) / n, (p2y - p1y) / n];\n const cos = vec[0];\n let sin = Math.sqrt(1 - cos * cos);\n sin = vec[1] >= 0 ? -sin : sin;\n return {\n sin: sin,\n cos: cos,\n };\n }\n\n /**\n * @private\n * @param {Array} hull\n * @param {Array} p\n * @param {Bool} topEdge\n */\n __align_hull(hull, p, topEdge) {\n let v = -1;\n let d2;\n for (let i = 0; i < hull.length; ++i) {\n const d = euclidean(hull[i], p);\n if (v === -1) {\n d2 = d;\n v = i;\n } else {\n if (d2 > d) {\n d2 = d;\n v = i;\n }\n }\n }\n\n let v1;\n let v2;\n if (topEdge) {\n v1 = hull[v];\n v2 = hull[(v + 1) % hull.length];\n } else {\n if (v == 0) v = hull.length - 1;\n v1 = hull[v];\n v2 = hull[(v - 1) % hull.length];\n }\n\n const transformation = {\n tx: -hull[v][0],\n ty: -hull[v][1],\n };\n\n if (hull.length >= 2) {\n const { sin, cos } = this.__findAngle(v1, v2);\n transformation.sin = sin;\n transformation.cos = cos;\n } else {\n transformation.sin = 0;\n transformation.cos = 1;\n }\n\n return transformation;\n }\n\n /**\n * @private\n * @param {Array} Point - The point which should get transformed.\n * @param {Object} Transformation - contains the values for translation and rotation.\n */\n __transform([px, py], { tx, ty, sin, cos }) {\n let x = px + tx;\n let y = py + ty;\n let xx = x * cos - y * sin;\n let yy = x * sin + y * cos;\n return [xx, yy];\n }\n\n /**\n * Calls {@link __transform} for each point in Set C\n * @private\n * @param {Array} C - Set of points.\n * @param {Object} t - Transform object.\n * @param {Number} yOffset - value to offset set C.\n */\n __transform_component(C, t, yOffset) {\n const N = C.length;\n for (let i = 0; i < N; ++i) {\n const c = C[i];\n const [cx, cy] = this.__transform(c, t);\n c[0] = cx;\n c[1] = cy + yOffset;\n }\n }\n\n /**\n * @private\n * @param {Array} u - point u\n * @param {Array} v - point v\n * @param {Number} w - edge weight w\n */\n __align_components(u, v, w) {\n const points_u = [...u.__disjoint_set.children];\n const points_v = [...v.__disjoint_set.children];\n\n const hull_u = this.__hull(points_u);\n const hull_v = this.__hull(points_v);\n\n const t_u = this.__align_hull(hull_u, u, false);\n const t_v = this.__align_hull(hull_v, v, true);\n\n this.__transform_component(points_u, t_u, 0);\n this.__transform_component(points_v, t_v, w);\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality 2.\n */\n transform() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n }\n return this.projection;\n }\n\n *generator() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n yield this.projection;\n }\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { PCA, MDS } from \"./index.js\";\nimport { distance_matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias SAMMON\n * @extends DR\n */\nexport class SAMMON extends DR {\n /**\n * SAMMON's Mapping\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias SAMMON\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {\"PCA\"|\"MDS\"|\"random\"} [parameters.init = \"random\"] - Either \"PCA\" or \"MDS\", with which SAMMON initialiates the projection. With \"random\" a random matrix gets used as starting point.\n * @param {Object} [parameters.init_parameters] - Parameters for the {@link init}-DR method.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {SAMMON}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { magic: 0.1, d: 2, metric: euclidean, seed: 1212, init_DR: \"random\", init_parameters: {} }, parameters);\n return this;\n }\n\n /**\n * initializes the projection.\n * @private\n */\n init() {\n const N = this.X.shape[0];\n const { d, metric, init_DR: init_DR, init_parameters: DR_parameters } = this._parameters;\n if (init_DR === \"random\") {\n const randomizer = this._randomizer;\n this.Y = new Matrix(N, d, () => randomizer.random);\n } else if ([\"PCA\", \"MDS\"].includes(init_DR)) {\n this.Y = Matrix.from(init_DR == \"PCA\" ? PCA.transform(this.X, DR_parameters) : MDS.transform(this.X, DR_parameters));\n } else {\n throw new Error('init_DR needs to be either \"random\" or a DR method!')\n }\n this.distance_matrix = metric == \"precomputed\" ? Matrix.from(this.X) : distance_matrix(this.X, metric);\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Matrix|Array} - The projection of {@link X}.\n */\n transform(max_iter = 200) {\n if (!this._is_initialized) this.init();\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n }\n return this.projection;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Generator} - A generator yielding the intermediate steps of the projection of {@link X}.\n */\n *generator(max_iter = 200) {\n if (!this._is_initialized) this.init();\n\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n yield this.projection;\n }\n\n return this.projection;\n }\n\n _step() {\n const MAGIC = this.parameter(\"magic\");\n const D = this.distance_matrix;\n const N = this.X.shape[0];\n const { d, metric } = this._parameters;\n let Y = this.Y;\n\n let G = new Matrix(N, d, 0);\n\n let sum = new Float64Array(d);\n for (let i = 0; i < N; ++i) {\n let e1 = new Float64Array(d);\n let e2 = new Float64Array(d);\n const Yi = Y.row(i);\n for (let j = 0; j < N; ++j) {\n if (i === j) continue;\n const Yj = Y.row(j);\n const delta = new Float64Array(d);\n for (let k = 0; k < d; ++k) {\n delta[k] = Yi[k] - Yj[k];\n }\n const dY = metric(Yi, Yj);\n const dX = D.entry(i, j);\n const dq = dX - dY;\n const dr = Math.max(dX * dY, 1e-2);\n for (let k = 0; k < d; ++k) {\n e1[k] += (delta[k] * dq) / dr;\n e2[k] += (dq - (Math.pow(delta[k], 2) * (1 + dq / dY)) / dY) / dr;\n }\n }\n for (let k = 0; k < d; ++k) {\n const val = Y.entry(i, k) + ((MAGIC * e1[k]) / Math.abs(e2[k]) || 0);\n G.set_entry(i, k, val);\n sum[k] += val;\n }\n }\n for (let k = 0; k < d; ++k) {\n sum[k] /= N;\n }\n\n for (let i = 0; i < N; ++i) {\n for (let k = 0; k < d; ++k) {\n Y.set_entry(i, k, G.entry(i, k) - sum[k]);\n }\n }\n return Y;\n }\n}\n"],"names":["a","b","Math","sqrt","euclidean_squared","summands","y","t","n","length","sum","compensation","i","summand","abs","s","Array","x","neumair_sum","sum_a","sum_b","acos","res","push","max","num_non_zero","num_equal","disagree","num_not_equal","num_true_true","num_true_false","num_false_true","A","k","metric","euclidean","rows","shape","D","distance_matrix","nN","row","from","map","distance","col","j","sort","slice","Matrix","A_i","dist","set_entry","start","end","number","round","result","v","vector","cols","Error","Float64Array","v_norm","norm","value","Q","R","q","q_dot_v","q_","v_","clone","x_norm","x0","entry","rho","sign","u1","u","divide","beta","u_outer_u","outer","R_block","get_block","new_R","sub","dot","mult","Q_block","new_Q","set_block","seed","max_iterations","qr","qr_gramschmidt","tol","randomizer","Randomizer","random","oldQ","QR","values","eigenvalues","diag","eigenvectors","transpose","to2dArray","N","constructor","this","_rows","_cols","_data","static","type","isArray","m","_","data","subarray","iterate_rows","Symbol","iterator","set_row","offset","result_col","T","inverse","B","h","i_max","max_val","Infinity","val","h_val","i_val","f","B_row_row","B_i_j","join","I","B_i","C","e","l","concat","rows_A","cols_A","rows_B","cols_B","X","offset_row","offset_col","start_row","start_col","end_row","end_col","new_row","new_col","gather","row_indices","col_indices","row_index","col_index","_apply_array","_apply_rowwise_array","_apply_colwise_array","_apply","value_rows","value_cols","add","asArray","min_row_col","min","mean","meanRows","meanCols","b_i","r","d","z","alpha","r_next","L","U","LU","L_diag","U_diag","det","M","MT","MtM","MMt","V","Sigma","simultaneous_poweriteration","sigma","_seed","_N","_M","_MATRIX_A","_UPPER_MASK","_LOWER_MASK","_mt","_mti","Date","getTime","mt","mti","random_int","mag01","kk","N_M","M_N","choice","sample","index_list","linspace","random_index","splice","undefined","Heap","elements","accessor","comparator","heapify","_accessor","_container","_comparator","heap","container","element","floor","_heapify_down","_swap","index_a","index_b","_heapify_up","index","parentIndex","node","start_index","left","right","pop","item","first","iterate","toArray","raw_data","empty","DisjointSet","_list","Set","make_set","list","has","__disjoint_set","parent","children","size","find","union","node_x","node_y","forEach","BallTree","_Node","pivot","child1","child2","radius","_Leaf","points","_metric","_root","_construct","c","_greatest_spread","sorted_elements","p_index","p","spread","reduce","acc","current","search","_search","KNN","_elements","_D","distances","H","nearest_element_index","nearest_dist","Number","isInteger","DR","default_parameters","parameters","_parameters","Object","assign","seal","_type","_randomizer","_is_initialized","parameter","name","hasOwnProperty","para","transform","check_init","projection","generator","init","Y","async","args","PCA","super","eig_args","principal_components","means","X_cent","MDS","ai_","a_j","a__","_d_X","stress","d_X","d_Y","top_sum","bottom_sum","pow","ISOMAP","neighbors","kNearestNeighbors","G","other","FASTMAP","_choose_distant_objects","a_index","b_index","max_dist","d_ai","d_bi","_col","old_dist","d_ab","y_i","LDA","labels","unique_labels","label_id","count","id","X_mean","V_mean","label","v_mean","S_b","S_w","row_v","LLE","k_nearest_neighbors","O","W","nN_row","Z","C_trace","w","solve_CG","IW","LTSA","I_i","X_i","g","G_i_t","W_i","TSNE","perplexity","epsilon","_iter","Htarget","log","Delta","druid","P","_ystep","_gains","prow","betamin","betamax","done","num","psum","pj","exp","Hhere","Pout","N2","_P","iterations","next","iter","ystep","gains","dim","pmul","Qu","qsum","dsum","dhere","qu","grad","premult","ymean","gid","sid","gainid","newgain","newsid","max_iter","pfx","fx","convergence","fxi","dx","UMAP","n_neighbors","local_connectivity","min_dist","_spread","_set_op_mix_ratio","_repulsion_strength","_negative_sample_rate","_n_epochs","_initial_alpha","_find_ab_params","xv","yv","xv_i","powell","error","_compute_membership_strengths","sigmas","rhos","_smooth_knn_dist","knn","SMOOTH_K_TOLERANCE","MIN_K_DIST_SCALE","target","log2","reverse","x_i","lo","hi","mid","search_result","non_zero_dist","filter","non_zero_dist_length","interpolation","mean_ithd","mean_d","_fuzzy_simplicial_set","distances_i","transposed_result","prod_matrix","_make_epochs_per_sample","n_epochs","weights","_weights","Float32Array","fill","weights_max","n_samples","_tocoo","graph","rows_n","cols_n","_a","_b","_graph","_head","_tail","_epochs_per_sample","_epochs_per_negative_sample","_epoch_of_next_sample","_epoch_of_next_negative_sample","_clip","_optimize_layout","head_embedding","tail_embedding","head","tail","_alpha","epochs_per_sample","epochs_per_negative_sample","epoch_of_next_negative_sample","epoch_of_next_sample","clip","tail_length","grad_coeff","grad_d","o","n_neg_samples","TriMap","weight_adj","pca","n_inliers","n_outliers","n_random","triplets","_generate_triplets","lr","vel","gain","n_extra","nbrs","knn_distances","sig","_find_p","_sample_knn_triplets","n_triplets","outlier_distances","_find_weights","random_triplets","random_weights","_sample_random_triplets","max_weight","isNaN","max_weight_2","n_i","sort_indices","__argsort","n_j","sim","samples","_rejection_sample","out","max_int","rejects","interval","indexOf","p_sim","p_out","indices","_grad","y_ij","y_ik","d_ij","d_ik","n_viol","loss","n_knn_triplets","Y_id","Y_jd","Y_kd","gs","go","max_iteration","_next","gamma","old_C","_update_embedding","new_gain","Hierarchical_Clustering","matrix","linkage","_id","_matrix","_linkage","root","do","get_clusters","clusters","depth","_traverse","leaves","_n","d_min","_d_min","_distance_matrix","_clusters","c_size","_c_size","Uint16Array","Cluster","p_max","c1","D_i_min","c2","c1_cluster","c2_cluster","c1_cluster_indices","isLeaf","c2_cluster_indices","new_cluster","unshift","D_c1_j","D_c2_j","centroid","_calculate_centroid","l_size","r_size","l_centroid","r_centroid","new_centroid","descendants","left_descendants","right_descendants","KMeans","K","_K","_cluster_centroids","_get_random_centroids","_furthest_point","candidates","Ad","cluster_centroids","random_point","init_points","sample_size","furthest_point","_iteration","clusters_changed","Ai","min_cluster","_compute_centroid","cluster_counter","ci","iteration_result","KMedoids","_A","_max_iter","log10","_cluster_medoids","_get_random_medoids","x_j","_nearest_medoid","index_nearest","medoids","finish","cache","x_o","DeltaTD","xs","findIndex","d_j","distance_nearest","deltaTD","d_oj","_get_distance","d_n","distance_second","d_s","nearest","second","x_m","m1","m2","index_second","cluster_medoids","ceil","TD","TD0","S","S_j","S_o","delta","OPTICS","min_points","_epsilon","_min_points","_ordered_list","_DB","ordered_list","DB","cluster_index","_cluster_index","reachability_distance","processed","_get_neighbors","_core_distance","seeds","_update","_expand_cluster","core_distance","new_reachability_distance","cluster","outliers","get_cluster_affirmation","LSP","control_points","DR_parameters","nc","c_i","Y_C","XA","AT","ATA","ATb","TopoMap","__lazy_distance_matrix","D_ij","_make_minimum_spanning_tree","disjoint_set","F","E","set_u","set_v","_Emst","__hull_cross","ax","ay","bx","by","sx","sy","__hull","x1","y1","x2","y2","lower","upper","__findAngle","p1x","p1y","p2x","p2y","sin","cos","vec","__align_hull","hull","topEdge","d2","v1","v2","transformation","tx","ty","__transform","px","py","__transform_component","yOffset","cx","cy","__align_components","points_u","points_v","hull_u","hull_v","t_u","t_v","Emst","components","component_u","component_v","SAMMON","magic","init_DR","init_parameters","includes","_step","MAGIC","e1","e2","Yi","Yj","dY","dX","dq","dr"],"mappings":";;;;;;;;;AASe,mBAAUA,EAAGC,GACxB,OAAOC,KAAKC,KAAKC,kBAAkBJ,EAAGC;;;;;;;;GCF3B,mBAAUI,GACrB,IAGIC,EAAGC,EAHHC,EAAIH,EAASI,OACbC,EAAM,EACNC,EAAe,EAGnB,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,IAAKI,EACrBN,EAAID,EAASO,GAAKD,EAClBJ,EAAIG,EAAMJ,EACVK,EAAeJ,EAAIG,EAAMJ,EACzBI,EAAMH,EAEV,OAAOG;;;;;;;;GCZI,qBAAUL,GACrB,IAAIG,EAAIH,EAASI,OACbC,EAAM,EACNC,EAAe,EAEnB,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,IAAKI,EAAG,CACxB,IAAIC,EAAUR,EAASO,GACnBL,EAAIG,EAAMG,EACVX,KAAKY,IAAIJ,IAAQR,KAAKY,IAAID,GAC1BF,GAAgBD,EAAMH,EAAIM,EAE1BF,GAAgBE,EAAUN,EAAIG,EAElCA,EAAMH,EAEV,OAAOG,EAAMC;;;;;;;;GCdF,2BAAUX,EAAGC,GACxB,GAAID,EAAES,QAAUR,EAAEQ,OAAQ,OAC1B,IAAID,EAAIR,EAAES,OACNM,EAAI,IAAIC,MAAMR,GAClB,IAAK,IAAII,EAAI,EAAGA,EAAIJ,IAAKI,EAAG,CACxB,IAAIK,EAAIjB,EAAEY,GACNN,EAAIL,EAAEW,GACVG,EAAEH,IAAMK,EAAIX,IAAMW,EAAIX,GAE1B,OAAOY,YAAYH;;;;;;;;;;GCRR,gBAAUf,EAAGC,GACxB,GAAID,EAAES,SAAWR,EAAEQ,OAAQ,OAC3B,IAAID,EAAIR,EAAES,OACNC,EAAM,EACNS,EAAQ,EACRC,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EAAGqB,GAAKvB,EAAIuB,IAG9C,OAAO6R"} \ No newline at end of file diff --git a/dist/druid.js b/dist/druid.js index dae7957..7e2fe9d 100644 --- a/dist/druid.js +++ b/dist/druid.js @@ -2148,7 +2148,7 @@ class DR { if (!this._parameters.hasOwnProperty(name)) { throw new Error(`${name} is not a valid parameter!`); } - if (value) { + if (value !== null) { this._parameters[name] = value; this._is_initialized = false; return this; diff --git a/dist/druid.js.map b/dist/druid.js.map index 1c5d81a..aea7b0e 100644 --- a/dist/druid.js.map +++ b/dist/druid.js.map @@ -1 +1 @@ -{"version":3,"file":"druid.js","sources":["../metrics/euclidean.js","../numerical/kahan_sum.js","../numerical/neumair_sum.js","../metrics/euclidean_squared.js","../metrics/cosine.js","../metrics/manhattan.js","../metrics/chebyshev.js","../metrics/canberra.js","../metrics/jaccard.js","../metrics/hamming.js","../metrics/sokal_michener.js","../metrics/yule.js","../matrix/k_nearest_neighbors.js","../matrix/distance_matrix.js","../matrix/linspace.js","../matrix/norm.js","../matrix/normalize.js","../linear_algebra/qr.js","../linear_algebra/qr_householder.js","../linear_algebra/simultaneous_poweriteration.js","../linear_algebra/inner_product.js","../matrix/Matrix.js","../util/randomizer.js","../util/max.js","../util/min.js","../datastructure/Heap.js","../datastructure/DisjointSet.js","../knn/BallTree.js","../knn/KNN.js","../dimred/DR.js","../dimred/PCA.js","../dimred/MDS.js","../dimred/ISOMAP.js","../dimred/FASTMAP.js","../dimred/LDA.js","../dimred/LLE.js","../dimred/LTSA.js","../dimred/TSNE.js","../optimization/powell.js","../dimred/UMAP.js","../dimred/TriMap.js","../clustering/Hierarchical_Clustering.js","../clustering/KMeans.js","../clustering/KMedoids.js","../clustering/OPTICS.js","../dimred/LSP.js","../dimred/TopoMap.js","../dimred/SAMMON.js"],"sourcesContent":["import { euclidean_squared } from \"../metrics/index.js\";\n/**\n * Computes the euclidean distance (l2) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n return Math.sqrt(euclidean_squared(a, b));\n}\n","/**\n * Numerical stable summation with the Kahan summation algorithm.\n * @memberof module:numerical\n * @alias kahan_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n let y, t;\n\n for (let i = 0; i < n; ++i) {\n y = summands[i] - compensation;\n t = sum + y;\n compensation = t - sum - y;\n sum = t;\n }\n return sum;\n}\n","/**\n * Numerical stable summation with the Neumair summation algorithm.\n * @memberof module:numerical\n * @alias neumair_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm#Further_enhancements}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n\n for (let i = 0; i < n; ++i) {\n let summand = summands[i];\n let t = sum + summand;\n if (Math.abs(sum) >= Math.abs(summand)) {\n compensation += sum - t + summand;\n } else {\n compensation += summand - t + sum;\n }\n sum = t;\n }\n return sum + compensation;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n/**\n * Computes the squared euclidean distance (l22) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean_squared\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the squared euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let s = new Array(n);\n for (let i = 0; i < n; ++i) {\n let x = a[i];\n let y = b[i];\n s[i] = (x - y) * (x - y);\n }\n return neumair_sum(s);\n}\n","/**\n * Computes the cosine distance (not similarity) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias cosine\n * @param {Array} a\n * @param {Array} b\n * @example\n * druid.cosine([1,0],[1,1]) == 0.7853981633974484 == π/4\n * @returns {Number} The cosine distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n let sum_a = 0;\n let sum_b = 0;\n for (let i = 0; i < n; ++i) {\n sum += a[i] * b[i];\n sum_a += a[i] * a[i];\n sum_b += b[i] * b[i];\n }\n return Math.acos(sum / (Math.sqrt(sum_a) * Math.sqrt(sum_b)));\n}\n","/**\n * Computes the manhattan distance (l1) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias manhattan\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the manhattan distance between {@link a} and {@link b}.\n */ \nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += Math.abs(a[i] - b[i]);\n }\n return sum;\n}\n","/**\n * Computes the chebyshev distance (L) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias chebyshev\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the chebyshev distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let res = [];\n for (let i = 0; i < n; ++i) {\n res.push(Math.abs(a[i] - b[i]));\n }\n return Math.max(...res);\n}\n","/**\n * Computes the canberra distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias canberra\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} The canberra distance between {@link a} and {@link b}.\n * @see {@link https://en.wikipedia.org/wiki/Canberra_distance}\n */\nexport default function(a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += (Math.abs(a[i] - b[i]) / (Math.abs(a[i]) + Math.abs(b[i])))\n }\n return sum;\n}","/**\n * Computes the jaccard distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias jaccard\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the jaccard distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_non_zero = 0;\n let num_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_non_zero += x || y;\n num_equal += x && y;\n }\n return (num_non_zero - num_equal) / num_non_zero;\n}\n","/**\n * Computes the hamming distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias hamming\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the hamming distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let disagree = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i];\n const y = b[i];\n disagree += x != y;\n }\n return disagree / n;\n}\n","/**\n * Computes the Sokal-Michener distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias sokal_michener\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} the Sokal-Michener distance between {@link a} and {@link b}. \n */\nexport default function(a, b) {\n if (a.length != b.length) return undefined\n const n = a.length;\n let num_not_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_not_equal += x != y;\n }\n return (2 * num_not_equal) / (n + num_not_equal);\n}","/**\n * Computes the yule distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias yule\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the yule distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_true_true = 0;\n let num_true_false = 0;\n let num_false_true = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_true_true += x && y;\n num_true_false += x && !y;\n num_false_true += !x && x;\n }\n const num_false_false = n - num_true_true - num_true_false - num_false_true;\n return num_true_false == 0 || num_false_true == 0 ? 0 : (2 * num_true_false * num_false_true) / (num_true_true * num_false_false + num_true_false * num_false_true);\n}\n","import { distance_matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Computes the k-nearest neighbors of each row of {@link A}.\n * @memberof module:matrix\n * @alias k_nearest_neigbhors\n * @param {Matrix} A - Either the data matrix, or a distance matrix.\n * @param {Number} k - The number of neighbors to compute.\n * @param {Function|\"precomputed\"} [metric=euclidean]\n * @returns {Array} -\n */\nexport default function (A, k, metric = euclidean) {\n const rows = A.shape[0];\n let D = metric == \"precomputed\" ? A : distance_matrix(A, metric);\n let nN = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n nN[row] = Array.from(D.row(row))\n .map((distance, col) => {\n return {\n i: row,\n j: col,\n distance: distance,\n };\n })\n .sort((a, b) => a.distance - b.distance)\n .slice(1, k + 1);\n }\n return nN;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"./index.js\";\n\n/**\n * Computes the distance matrix of datamatrix {@link A}.\n * @memberof module:matrix\n * @alias distance_matrix\n * @param {Matrix} A - Matrix.\n * @param {Function} [metric=euclidean] - The diistance metric.\n * @returns {Matrix} D - The distance matrix of {@link A}.\n */\nexport default function (A, metric = euclidean) {\n let n = A.shape[0];\n const D = new Matrix(n, n);\n for (let i = 0; i < n; ++i) {\n const A_i = A.row(i);\n for (let j = i + 1; j < n; ++j) {\n const dist = metric(A_i, A.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n }\n }\n return D;\n}\n","/**\n * Creates an Array containing {@link number} numbers from {@link start} to {@link end}.\n * If {@link number} = null.\n * @memberof module:matrix\n * @alias linspace\n * @param {Number} start - Start value.\n * @param {Number} end - End value.\n * @param {Number} [number = null] - Number of number between {@link start} and {@link end}.\n * @returns {Array} - An array with {@link number} entries, beginning at {@link start} ending at {@link end}.\n */\nexport default function (start, end, number = null) {\n if (!number) {\n number = Math.max(Math.round(end - start) + 1, 1);\n }\n if (number < 2) {\n return number === 1 ? [start] : [];\n }\n let result = new Array(number);\n number -= 1;\n for (let i = number; i >= 0; --i) {\n result[i] = (i * end + (number - i) * start) / number;\n }\n return result;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n//import { neumair_sum } from \"../numerical/index\";\n\n/**\n * Computes the norm of a vector, by computing its distance to **0**.\n * @memberof module:matrix\n * @alias norm\n * @param {Matrix|Array|Float64Array} v - Vector. \n * @param {Function} [metric = euclidean] - Which metric should be used to compute the norm.\n * @returns {Number} - The norm of {@link v}.\n */\nexport default function (v, metric = euclidean) {\n let vector = null;\n if (v instanceof Matrix) {\n let [rows, cols] = v.shape;\n if (rows === 1) vector = v.row(0);\n else if (cols === 1) vector = v.col(0);\n else throw new Error(\"Matrix must be 1d!\");\n } else {\n vector = v;\n }\n const n = vector.length;\n const zeros = Float64Array.from({ length: n }, () => 0);\n return metric(vector, zeros);\n}\n","import { norm } from \"./index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Normalizes Vector {@link v}.\n * @memberof module:matrix\n * @alias normalize\n * @param {Array|Float64Array} v - Vector\n * @param {Function} metric \n * @returns {Array|Float64Array} - The normalized vector with length 1.\n */\nexport default function(v, metric = euclidean) {\n const v_norm = norm(v, metric);\n return v.map(value => value / v_norm);\n}","import { Matrix, norm } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} using Gram-Schmidt process.\n * @memberof module:linear_algebra\n * @alias qr\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_the_Gram%E2%80%93Schmidt_process}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, cols, \"identity\");\n const R = new Matrix(cols, cols, 0);\n\n for (let j = 0; j < cols; ++j) {\n let v = A.col(j);\n for (let i = 0; i < j; ++i) {\n const q = Q.col(i);\n const q_dot_v = neumair_sum(q.map((q_, k) => q_ * v[k]));\n R.set_entry(i, j, q_dot_v);\n v = v.map((v_, k) => v_ - q_dot_v * q[k]);\n }\n const v_norm = norm(v, euclidean);\n for (let k = 0; k < rows; ++k) {\n Q.set_entry(k, j, v[k] / v_norm);\n }\n R.set_entry(j, j, v_norm);\n }\n return { R, Q };\n}\n","import { Matrix, norm } from \"../matrix/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} with householder transformations.\n * @memberof module:linear_algebra\n * @alias qr_householder\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections}\n * @see {@link http://mlwiki.org/index.php/Householder_Transformation}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, rows, \"I\");\n const R = A.clone();\n\n for (let j = 0; j < cols; ++j) {\n const x = Matrix.from(R.col(j).slice(j));\n const x_norm = norm(x);\n const x0 = x.entry(0, 0);\n const rho = -Math.sign(x0);\n const u1 = x0 - rho * x_norm;\n const u = x.divide(u1).set_entry(0, 0, 1);\n const beta = (-rho * u1) / x_norm;\n\n const u_outer_u = u.outer(u);\n const R_block = R.get_block(j, 0);\n const new_R = R_block.sub(u_outer_u.dot(R_block).mult(beta));\n const Q_block = Q.get_block(0, j);\n const new_Q = Q_block.sub(Q_block.dot(u_outer_u).mult(beta));\n R.set_block(j, 0, new_R);\n Q.set_block(0, j, new_Q);\n }\n return { R, Q };\n}\n","import { qr as qr_gramschmidt } from \"./index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { euclidean_squared } from \"../metrics/index.js\";\n\n/**\n * Computes the {@link k} biggest Eigenvectors and Eigenvalues from Matrix {@link A} with the QR-Algorithm.\n * @memberof module:linear_algebra\n * @alias simultaneous_poweriteration\n * @param {Matrix} A - The Matrix\n * @param {Number} k - The number of eigenvectors and eigenvalues to compute.\n * @param {Object} parameters - Object containing parameterization of the simultanious poweriteration method.\n * @param {Number} [parameters.max_iterations=100] - The number of maxiumum iterations the algorithm should run.\n * @param {Number|Randomizer} [parameters.seed=1212] - The seed value or a randomizer used in the algorithm.\n * @param {Function} [parameters.qr=qr_gramschmidt] - The QR technique to use.\n * @param {Number} [parameters.tol=1e-8] - Allowed error for stopping criteria\n * @returns {{eigenvalues: Array, eigenvectors: Array}} - The {@link k} biggest eigenvectors and eigenvalues of Matrix {@link A}.\n */\nexport default function (A, k = 2, {seed = 1212, max_iterations = 100, qr = qr_gramschmidt, tol = 1e-8} = {}) {\n const randomizer = seed instanceof Randomizer ? seed : new Randomizer(seed);\n if (!(A instanceof Matrix)) A = Matrix.from(A);\n const n = A.shape[0];\n let { Q, R } = qr(new Matrix(n, k, () => (randomizer.random - .5) * 2));\n while (max_iterations--) {\n const oldQ = Q.clone();\n const Z = A.dot(Q);\n const QR = qr(Z);\n Q = QR.Q;\n R = QR.R;\n const error = euclidean_squared(Q.values, oldQ.values);\n if (error < tol) {\n break;\n }\n }\n\n const eigenvalues = R.diag;\n const eigenvectors = Q.transpose().to2dArray;\n return { eigenvalues, eigenvectors };\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the inner product between two arrays of the same length.\n * @memberof module:linear_algebra\n * @alias inner_product\n * @param {Array|Float64Array} a - Array a\n * @param {Array|Float64Array} b - Array b\n * @returns The inner product between {@link a} and {@link b}\n */\nexport default function (a, b) {\n const N = a.length;\n if (N != b.length) {\n throw new Error(\"Array a and b must have the same length!\")\n }\n let sum = 0;\n for (let i = 0; i < N; ++i) {\n sum += a * b;\n }\n return sum;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n/**\n * @class\n * @alias Matrix\n * @requires module:numerical/neumair_sum\n */\nexport class Matrix {\n /**\n * creates a new Matrix. Entries are stored in a Float64Array.\n * @constructor\n * @memberof module:matrix\n * @alias Matrix\n * @param {number} rows - The amount of rows of the matrix.\n * @param {number} cols - The amount of columns of the matrix.\n * @param {(function|string|number)} value=0 - Can be a function with row and col as parameters, a number, or \"zeros\", \"identity\" or \"I\", or \"center\".\n * - **function**: for each entry the function gets called with the parameters for the actual row and column.\n * - **string**: allowed are\n * - \"zero\", creates a zero matrix.\n * - \"identity\" or \"I\", creates an identity matrix.\n * - \"center\", creates an center matrix.\n * - **number**: create a matrix filled with the given value.\n * @example\n *\n * let A = new Matrix(10, 10, () => Math.random()); //creates a 10 times 10 random matrix.\n * let B = new Matrix(3, 3, \"I\"); // creates a 3 times 3 identity matrix.\n * @returns {Matrix} returns a {@link rows} times {@link cols} Matrix filled with {@link value}.\n */\n constructor(rows = null, cols = null, value = null) {\n this._rows = rows;\n this._cols = cols;\n this._data = null;\n if (rows && cols) {\n if (!value) {\n this._data = new Float64Array(rows * cols);\n return this;\n }\n if (typeof value === \"function\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n if (typeof value === \"string\") {\n if (value === \"zeros\") {\n return new Matrix(rows, cols, 0);\n }\n if (value === \"identity\" || value === \"I\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n this._data[row * cols + row] = 1;\n }\n return this;\n }\n if (value === \"center\" && rows == cols) {\n this._data = new Float64Array(rows * cols);\n value = (i, j) => (i === j ? 1 : 0) - 1 / rows;\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n }\n if (typeof value === \"number\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value;\n }\n }\n return this;\n }\n }\n return this;\n }\n\n /**\n * Creates a Matrix out of {@link A}.\n * @param {(Matrix|Array|Float64Array|number)} A - The matrix, array, or number, which should converted to a Matrix.\n * @param {\"row\"|\"col\"|\"diag\"} [type = \"row\"] - If {@link A} is a Array or Float64Array, then type defines if it is a row- or a column vector.\n * @returns {Matrix}\n *\n * @example\n * let A = Matrix.from([[1, 0], [0, 1]]); //creates a two by two identity matrix.\n * let S = Matrix.from([1, 2, 3], \"diag\"); // creates a 3 by 3 matrix with 1, 2, 3 on its diagonal. [[1, 0, 0], [0, 2, 0], [0, 0, 3]]\n */\n static from(A, type = \"row\") {\n if (A instanceof Matrix) {\n return A.clone();\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let m = A.length;\n if (m === 0) throw new Error(\"Array is empty\");\n // 1d\n if (!Array.isArray(A[0]) && !(A[0] instanceof Float64Array)) {\n if (type === \"row\") {\n return new Matrix(1, m, (_, j) => A[j]);\n } else if (type === \"col\") {\n return new Matrix(m, 1, (i) => A[i]);\n } else if (type === \"diag\") {\n return new Matrix(m, m, (i, j) => (i == j ? A[i] : 0));\n } else {\n throw new Error(\"1d array has NaN entries\");\n }\n // 2d\n } else if (Array.isArray(A[0]) || A[0] instanceof Float64Array) {\n let n = A[0].length;\n for (let row = 0; row < m; ++row) {\n if (A[row].length !== n) {\n throw new Error(\"various array lengths\");\n }\n }\n return new Matrix(m, n, (i, j) => A[i][j]);\n }\n } else if (typeof A === \"number\") {\n return new Matrix(1, 1, A);\n } else {\n throw new Error(\"error\");\n }\n }\n\n /**\n * Returns the {@link row}th row from the Matrix.\n * @param {Number} row\n * @returns {Float64Array}\n */\n row(row) {\n const data = this.values;\n const cols = this._cols;\n return data.subarray(row * cols, (row + 1) * cols);\n }\n\n /**\n * Returns an generator yielding each row of the Matrix.\n * @yields {Float64Array}\n */\n *iterate_rows() {\n const cols = this._cols;\n const rows = this._rows;\n const data = this.values;\n for (let row = 0; row < rows; ++row) {\n yield data.subarray(row * cols, (row + 1) * cols);\n }\n }\n\n /**\n * Makes a {@link Matrix} object an iterable object.\n * @yields {Float64Array}\n */\n *[Symbol.iterator]() {\n for (const row of this.iterate_rows()) {\n yield row;\n }\n }\n\n /**\n * Sets the entries of {@link row}th row from the Matrix to the entries from {@link values}.\n * @param {int} row\n * @param {Array} values\n * @returns {Matrix}\n */\n set_row(row, values) {\n let cols = this._cols;\n if (Array.isArray(values) && values.length === cols) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values[col];\n }\n } else if (values instanceof Matrix && values.shape[1] === cols && values.shape[0] === 1) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values._data[col];\n }\n }\n return this;\n }\n\n /**\n * Returns the {@link col}th column from the Matrix.\n * @param {int} col\n * @returns {Array}\n */\n col(col) {\n let result_col = new Float64Array(this._rows);\n for (let row = 0; row < this._rows; ++row) {\n result_col[row] = this.values[row * this._cols + col];\n }\n return result_col;\n }\n\n /**\n * Returns the {@link col}th entry from the {@link row}th row of the Matrix.\n * @param {int} row\n * @param {int} col\n * @returns {float64}\n */\n entry(row, col) {\n return this.values[row * this._cols + col];\n }\n\n /**\n * Sets the {@link col}th entry from the {@link row}th row of the Matrix to the given {@link value}.\n * @param {int} row\n * @param {int} col\n * @param {float64} value\n * @returns {Matrix}\n */\n set_entry(row, col, value) {\n this.values[row * this._cols + col] = value;\n return this;\n }\n\n /**\n * Returns a new transposed Matrix.\n * @returns {Matrix}\n */\n transpose() {\n let B = new Matrix(this._cols, this._rows, (row, col) => this.entry(col, row));\n return B;\n }\n\n /**\n * Returns a new transposed Matrix. Short-form of {@function transpose}.\n * @returns {Matrix}\n */\n get T() {\n return this.transpose();\n }\n\n /**\n * Returns the inverse of the Matrix.\n * @returns {Matrix}\n */\n inverse() {\n const rows = this._rows;\n const cols = this._cols;\n let B = new Matrix(rows, 2 * cols, (i, j) => {\n if (j >= cols) {\n return i === j - cols ? 1 : 0;\n } else {\n return this.entry(i, j);\n }\n });\n let h = 0;\n let k = 0;\n while (h < rows && k < cols) {\n var i_max = 0;\n let max_val = -Infinity;\n for (let i = h; i < rows; ++i) {\n let val = Math.abs(B.entry(i, k));\n if (max_val < val) {\n i_max = i;\n max_val = val;\n }\n }\n if (B.entry(i_max, k) == 0) {\n k++;\n } else {\n // swap rows\n for (let j = 0; j < 2 * cols; ++j) {\n let h_val = B.entry(h, j);\n let i_val = B.entry(i_max, j);\n B.set_entry(h, j, h_val);\n B.set_entry(i_max, j, i_val);\n }\n for (let i = h + 1; i < rows; ++i) {\n let f = B.entry(i, k) / B.entry(h, k);\n B.set_entry(i, k, 0);\n for (let j = k + 1; j < 2 * cols; ++j) {\n B.set_entry(i, j, B.entry(i, j) - B.entry(h, j) * f);\n }\n }\n h++;\n k++;\n }\n }\n\n for (let row = 0; row < rows; ++row) {\n let f = B.entry(row, row);\n for (let col = row; col < 2 * cols; ++col) {\n B.set_entry(row, col, B.entry(row, col) / f);\n }\n }\n\n for (let row = rows - 1; row >= 0; --row) {\n let B_row_row = B.entry(row, row);\n for (let i = 0; i < row; i++) {\n let B_i_row = B.entry(i, row);\n let f = B_i_row / B_row_row;\n for (let j = i; j < 2 * cols; ++j) {\n let B_i_j = B.entry(i, j);\n let B_row_j = B.entry(row, j);\n B_i_j = B_i_j - B_row_j * f;\n B.set_entry(i, j, B_i_j);\n }\n }\n }\n\n return new Matrix(rows, cols, (i, j) => B.entry(i, j + cols));\n }\n\n /**\n * Returns the dot product. If {@link B} is an Array or Float64Array then an Array gets returned. If {@link B} is a Matrix then a Matrix gets returned.\n * @param {(Matrix|Array|Float64Array)} B the right side\n * @returns {(Matrix|Array)}\n */\n dot(B) {\n if (B instanceof Matrix) {\n let A = this;\n if (A.shape[1] !== B.shape[0]) {\n throw new Error(`A.dot(B): A is a ${A.shape.join(\" ⨯ \")}-Matrix, B is a ${B.shape.join(\" ⨯ \")}-Matrix: \n A has ${A.shape[1]} cols and B ${B.shape[0]} rows. \n Must be equal!`);\n }\n let I = A.shape[1];\n let C = new Matrix(A.shape[0], B.shape[1], (row, col) => {\n const A_i = A.row(row);\n const B_i = B.col(col);\n let sum = 0;\n for (let i = 0; i < I; ++i) {\n sum += A_i[i] * B_i[i];\n }\n return sum;\n });\n return C;\n } else if (Array.isArray(B) || B instanceof Float64Array) {\n let rows = this._rows;\n if (B.length !== rows) {\n throw new Error(`A.dot(B): A has ${rows} cols and B has ${B.length} rows. Must be equal!`);\n }\n let C = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n C[row] = neumair_sum(this.row(row).map((e) => e * B[row]));\n }\n return C;\n } else {\n throw new Error(`B must be Matrix or Array`);\n }\n }\n\n /**\n * Computes the outer product from {@link this} and {@link B}.\n * @param {Matrix} B\n * @returns {Matrix}\n */\n outer(B) {\n let A = this;\n let l = A._data.length;\n let r = B._data.length;\n if (l != r) return undefined;\n let C = new Matrix();\n C.shape = [\n l,\n l,\n (i, j) => {\n if (i <= j) {\n return A._data[i] * B._data[j];\n } else {\n return C.entry(j, i);\n }\n },\n ];\n return C;\n }\n\n /**\n * Appends matrix {@link B} to the matrix.\n * @param {Matrix} B - matrix to append.\n * @param {\"horizontal\"|\"vertical\"|\"diag\"} [type = \"horizontal\"] - type of concatenation.\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 1], [1, 1]]); // 2 by 2 matrix filled with ones.\n * let B = Matrix.from([[2, 2], [2, 2]]); // 2 by 2 matrix filled with twos.\n *\n * A.concat(B, \"horizontal\"); // 2 by 4 matrix. [[1, 1, 2, 2], [1, 1, 2, 2]]\n * A.concat(B, \"vertical\"); // 4 by 2 matrix. [[1, 1], [1, 1], [2, 2], [2, 2]]\n * A.concat(B, \"diag\"); // 4 by 4 matrix. [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 2, 2], [0, 0, 2, 2]]\n */\n concat(B, type = \"horizontal\") {\n const A = this;\n const [rows_A, cols_A] = A.shape;\n const [rows_B, cols_B] = B.shape;\n if (type == \"horizontal\") {\n if (rows_A != rows_B) {\n throw new Error(`A.concat(B, \"horizontal\"): A and B need same number of rows, A has ${rows_A} rows, B has ${rows_B} rows.`);\n }\n const X = new Matrix(rows_A, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(0, cols_A, B);\n return X;\n } else if (type == \"vertical\") {\n if (cols_A != cols_B) {\n throw new Error(`A.concat(B, \"vertical\"): A and B need same number of columns, A has ${cols_A} columns, B has ${cols_B} columns.`);\n }\n const X = new Matrix(rows_A + rows_B, cols_A, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, 0, B);\n return X;\n } else if (type == \"diag\") {\n const X = new Matrix(rows_A + rows_B, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, cols_A, B);\n return X;\n } else {\n throw new Error(`type must be \"horizontal\" or \"vertical\", but type is ${type}!`);\n }\n }\n\n /**\n * Writes the entries of B in A at an offset position given by {@link offset_row} and {@link offset_col}.\n * @param {int} offset_row\n * @param {int} offset_col\n * @param {Matrix} B\n * @returns {Matrix}\n */\n set_block(offset_row, offset_col, B) {\n let [rows, cols] = B.shape;\n for (let row = 0; row < rows; ++row) {\n if (row > this._rows) {\n continue;\n }\n for (let col = 0; col < cols; ++col) {\n if (col > this._cols) {\n continue;\n }\n this.set_entry(row + offset_row, col + offset_col, B.entry(row, col));\n }\n }\n return this;\n }\n\n /**\n * Extracts the entries from the {@link start_row}th row to the {@link end_row}th row, the {@link start_col}th column to the {@link end_col}th column of the matrix.\n * If {@link end_row} or {@link end_col} is empty, the respective value is set to {@link this.rows} or {@link this.cols}.\n * @param {Number} start_row\n * @param {Number} start_col\n * @param {Number} [end_row = null]\n * @param {Number} [end_col = null]\n * @returns {Matrix} Returns a end_row - start_row times end_col - start_col matrix, with respective entries from the matrix.\n * @example\n *\n * let A = Matrix.from([[1, 2, 3], [4, 5, 6], [7, 8, 9]]); // a 3 by 3 matrix.\n *\n * A.get_block(1, 1); // [[5, 6], [8, 9]]\n * A.get_block(0, 0, 1, 1); // [[1]]\n * A.get_block(1, 1, 2, 2); // [[5]]\n * A.get_block(0, 0, 2, 2); // [[1, 2], [4, 5]]\n */\n get_block(start_row, start_col, end_row = null, end_col = null) {\n const [rows, cols] = this.shape;\n end_row = end_row ?? rows;\n end_col = end_col ?? cols;\n if (end_row <= start_row || end_col <= start_col) {\n throw new Error(`\n end_row must be greater than start_row, and \n end_col must be greater than start_col, but\n end_row = ${end_row}, start_row = ${start_row}, end_col = ${end_col}, and start_col = ${start_col}!`);\n }\n const X = new Matrix(end_row - start_row, end_col - start_col, \"zeros\");\n for (let row = start_row, new_row = 0; row < end_row; ++row, ++new_row) {\n for (let col = start_col, new_col = 0; col < end_col; ++col, ++new_col) {\n X.set_entry(new_row, new_col, this.entry(row, col));\n }\n }\n return X;\n //return new Matrix(end_row - start_row, end_col - start_col, (i, j) => this.entry(i + start_row, j + start_col));\n }\n\n /**\n * Returns a new array gathering entries defined by the indices given by argument.\n * @param {Array} row_indices - Array consists of indices of rows for gathering entries of this matrix\n * @param {Array} col_indices - Array consists of indices of cols for gathering entries of this matrix\n * @returns {Matrix}\n */\n gather(row_indices, col_indices) {\n const N = row_indices.length;\n const D = col_indices.length;\n\n const R = new Matrix(N, D);\n for (let i = 0; i < N; ++i) {\n const row_index = row_indices[i];\n for (let j = 0; j < N; ++j) {\n const col_index = col_indices[j];\n R.set_entry(i, j, this.entry(row_index, col_index));\n }\n }\n\n return R;\n }\n\n /**\n * Applies a function to each entry of the matrix.\n * @private\n * @param {function} f function takes 2 parameters, the value of the actual entry and a value given by the function {@link v}. The result of {@link f} gets writen to the Matrix.\n * @param {function} v function takes 2 parameters for row and col, and returns a value witch should be applied to the colth entry of the rowth row of the matrix.\n */\n _apply_array(f, v) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], v(row, col));\n }\n }\n return this;\n }\n\n _apply_rowwise_array(values, f) {\n return this._apply_array(f, (_, j) => values[j]);\n }\n\n _apply_colwise_array(values, f) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], values[row]);\n }\n }\n return this;\n }\n\n _apply(value, f) {\n let data = this.values;\n if (value instanceof Matrix) {\n let [value_rows, value_cols] = value.shape;\n let [rows, cols] = this.shape;\n if (value_rows === 1) {\n if (cols !== value_cols) {\n throw new Error(`cols !== value_cols`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(0, col));\n }\n }\n } else if (value_cols === 1) {\n if (rows !== value_rows) {\n throw new Error(`rows !== value_rows`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, 0));\n }\n }\n } else if (rows == value_rows && cols == value_cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, col));\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else if (Array.isArray(value)) {\n let rows = this._rows;\n let cols = this._cols;\n if (value.length === rows) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[row]);\n }\n }\n } else if (value.length === cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[col]);\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else {\n for (let i = 0, n = this._rows * this._cols; i < n; ++i) {\n data[i] = f(data[i], value);\n }\n }\n return this;\n }\n\n /**\n * Clones the Matrix.\n * @returns {Matrix}\n */\n clone() {\n let B = new Matrix();\n B._rows = this._rows;\n B._cols = this._cols;\n B._data = this.values.slice(0);\n return B;\n }\n\n /**\n * Entrywise multiplication with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.mult(2); // [[2, 4], [6, 8]];\n * A.mult(B); // [[1, 4], [9, 16]];\n */\n mult(value) {\n return this.clone()._apply(value, (a, b) => a * b);\n }\n\n /**\n * Entrywise division with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.divide(2); // [[0.5, 1], [1.5, 2]];\n * A.divide(B); // [[1, 1], [1, 1]];\n */\n divide(value) {\n return this.clone()._apply(value, (a, b) => a / b);\n }\n\n /**\n * Entrywise addition with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.add(2); // [[3, 4], [5, 6]];\n * A.add(B); // [[2, 4], [6, 8]];\n */\n add(value) {\n return this.clone()._apply(value, (a, b) => a + b);\n }\n\n /**\n * Entrywise subtraction with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.sub(2); // [[-1, 0], [1, 2]];\n * A.sub(B); // [[0, 0], [0, 0]];\n */\n sub(value) {\n return this.clone()._apply(value, (a, b) => a - b);\n }\n\n /**\n * Returns the number of rows and columns of the Matrix.\n * @returns {Array} An Array in the form [rows, columns].\n */\n get shape() {\n return [this._rows, this._cols];\n }\n\n /**\n * Returns the matrix in the given shape with the given function which returns values for the entries of the matrix.\n * @param {Array} parameter - takes an Array in the form [rows, cols, value], where rows and cols are the number of rows and columns of the matrix, and value is a function which takes two parameters (row and col) which has to return a value for the colth entry of the rowth row.\n * @returns {Matrix}\n */\n set shape([rows, cols, value = () => 0]) {\n this._rows = rows;\n this._cols = cols;\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n\n /**\n * Returns the Matrix as a Array of Float64Arrays.\n * @returns {Array}\n */\n get to2dArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(row);\n }\n return result;\n }\n\n /**\n * Returns the Matrix as a Array of Arrays.\n * @returns {Array}\n */\n get asArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(Array.from(row));\n }\n return result;\n }\n\n /**\n * Returns the diagonal of the Matrix.\n * @returns {Float64Array}\n */\n get diag() {\n const rows = this._rows;\n const cols = this._cols;\n const min_row_col = Math.min(rows, cols);\n let result = new Float64Array(min_row_col);\n for (let i = 0; i < min_row_col; ++i) {\n result[i] = this.entry(i, i);\n }\n return result;\n }\n\n /**\n * Returns the mean of all entries of the Matrix.\n * @returns {Number}\n */\n get mean() {\n const sum = this.sum;\n const n = this._rows * this._cols;\n return sum / n;\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Number}\n */\n get sum() {\n const data = this.values;\n return neumair_sum(data);\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Float64Array}\n */\n get values() {\n const data = this._data;\n return data;\n }\n\n /**\n * Returns the mean of each row of the matrix.\n * @returns {Float64Array}\n */\n get meanRows() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: rows });\n for (let row = 0; row < rows; ++row) {\n result[row] = 0;\n for (let col = 0; col < cols; ++col) {\n result[row] += data[row * cols + col];\n }\n result[row] /= cols;\n }\n return result;\n }\n\n /** Returns the mean of each column of the matrix.\n * @returns {Float64Array}\n */\n get meanCols() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: cols });\n for (let col = 0; col < cols; ++col) {\n result[col] = 0;\n for (let row = 0; row < rows; ++row) {\n result[col] += data[row * cols + col];\n }\n result[col] /= rows;\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b} using the conjugate gradient method. Returns the result x.\n * @param {Matrix} A - Matrix\n * @param {Matrix} b - Matrix\n * @param {Randomizer} [randomizer=null]\n * @param {Number} [tol=1e-3]\n * @returns {Matrix}\n */\n static solve_CG(A, b, randomizer, tol = 1e-3) {\n if (randomizer === null) {\n randomizer = new Randomizer();\n }\n const rows = A.shape[0];\n const cols = b.shape[1];\n let result = new Matrix(rows, 0);\n for (let i = 0; i < cols; ++i) {\n const b_i = Matrix.from(b.col(i)).T;\n let x = new Matrix(rows, 1, () => randomizer.random);\n let r = b_i.sub(A.dot(x));\n let d = r.clone();\n do {\n const z = A.dot(d);\n const alpha = r.T.dot(r).entry(0, 0) / d.T.dot(z).entry(0, 0);\n x = x.add(d.mult(alpha));\n const r_next = r.sub(z.mult(alpha));\n const beta = r_next.T.dot(r_next).entry(0, 0) / r.T.dot(r).entry(0, 0);\n d = r_next.add(d.mult(beta));\n r = r_next;\n } while (Math.abs(r.mean) > tol);\n result = result.concat(x, \"horizontal\");\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b}. Returns the result x.\n * @param {Matrix} A - Matrix or LU Decomposition\n * @param {Matrix} b - Matrix\n * @returns {Matrix}\n */\n static solve(A, b) {\n let { L: L, U: U } = \"L\" in A && \"U\" in A ? A : Matrix.LU(A);\n let rows = L.shape[0];\n let x = b.clone();\n\n // forward\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < row - 1; ++col) {\n x.set_entry(0, row, x.entry(0, row) - L.entry(row, col) * x.entry(1, col));\n }\n x.set_entry(0, row, x.entry(0, row) / L.entry(row, row));\n }\n\n // backward\n for (let row = rows - 1; row >= 0; --row) {\n for (let col = rows - 1; col > row; --col) {\n x.set_entry(0, row, x.entry(0, row) - U.entry(row, col) * x.entry(0, col));\n }\n x.set_entry(0, row, x.entry(0, row) / U.entry(row, row));\n }\n\n return x;\n }\n\n /**\n * {@link L}{@link U} decomposition of the Matrix {@link A}. Creates two matrices, so that the dot product LU equals A.\n * @param {Matrix} A\n * @returns {{L: Matrix, U: Matrix}} result - Returns the left triangle matrix {@link L} and the upper triangle matrix {@link U}.\n */\n static LU(A) {\n const rows = A.shape[0];\n const L = new Matrix(rows, rows, \"zeros\");\n const U = new Matrix(rows, rows, \"identity\");\n\n for (let j = 0; j < rows; ++j) {\n for (let i = j; i < rows; ++i) {\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(i, k) * U.entry(k, j);\n }\n L.set_entry(i, j, A.entry(i, j) - sum);\n }\n for (let i = j; i < rows; ++i) {\n if (L.entry(j, j) === 0) {\n return undefined;\n }\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(j, k) * U.entry(k, i);\n }\n U.set_entry(j, i, (A.entry(j, i) - sum) / L.entry(j, j));\n }\n }\n\n return { L: L, U: U };\n }\n\n /**\n * Computes the determinante of {@link A}, by using the LU decomposition of {@link A}.\n * @param {Matrix} A\n * @returns {Number} det - Returns the determinate of the Matrix {@link A}.\n */\n static det(A) {\n const rows = A.shape[0];\n const { L, U } = Matrix.LU(A);\n const L_diag = L.diag;\n const U_diag = U.diag;\n let det = L_diag[0] * U_diag[0];\n for (let row = 1; row < rows; ++row) {\n det *= L_diag[row] * U_diag[row];\n }\n return det;\n }\n\n /**\n * Computes the {@link k} components of the SVD decomposition of the matrix {@link M}\n * @param {Matrix} M\n * @param {int} [k=2]\n * @returns {{U: Matrix, Sigma: Matrix, V: Matrix}}\n */\n static SVD(M, k = 2) {\n const MT = M.T;\n let MtM = MT.dot(M);\n let MMt = M.dot(MT);\n let { eigenvectors: V, eigenvalues: Sigma } = simultaneous_poweriteration(MtM, k);\n let { eigenvectors: U } = simultaneous_poweriteration(MMt, k);\n return { U: U, Sigma: Sigma.map((sigma) => Math.sqrt(sigma)), V: V };\n\n //Algorithm 1a: Householder reduction to bidiagonal form:\n /* const [m, n] = A.shape;\n let U = new Matrix(m, n, (i, j) => i == j ? 1 : 0);\n console.log(U.to2dArray)\n let V = new Matrix(n, m, (i, j) => i == j ? 1 : 0);\n console.log(V.to2dArray)\n let B = Matrix.bidiagonal(A.clone(), U, V);\n console.log(U,V,B)\n return { U: U, \"Sigma\": B, V: V }; */\n }\n}\n","import { linspace, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @memberof module:utils\n * @alias Randomizer\n */\nexport class Randomizer {\n /**\n * Mersenne Twister random number generator.\n * @constructor\n * @param {Number} [_seed=new Date().getTime()] - The seed for the random number generator. If _seed == null then the actual time gets used as seed.\n * @see https://github.com/bmurray7/mersenne-twister-examples/blob/master/javascript-mersenne-twister.js\n */\n constructor(_seed) {\n this._N = 624;\n this._M = 397;\n this._MATRIX_A = 0x9908b0df;\n this._UPPER_MASK = 0x80000000;\n this._LOWER_MASK = 0x7fffffff;\n this._mt = new Array(this._N);\n this._mti = this.N + 1;\n\n this.seed = _seed || new Date().getTime();\n return this;\n }\n\n set seed(_seed) {\n this._seed = _seed;\n let mt = this._mt;\n\n mt[0] = _seed >>> 0;\n for (this._mti = 1; this._mti < this._N; this._mti += 1) {\n let mti = this._mti;\n let s = mt[mti - 1] ^ (mt[mti - 1] >>> 30);\n mt[mti] = ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253 + mti;\n mt[mti] >>>= 0;\n }\n }\n\n /**\n * Returns the seed of the random number generator.\n * @returns {Number} - The seed.\n */\n get seed() {\n return this._seed;\n }\n\n /**\n * Returns a float between 0 and 1.\n * @returns {Number} - A random number between [0, 1]\n */\n get random() {\n return this.random_int * (1.0 / 4294967296.0);\n }\n\n /**\n * Returns an integer between 0 and MAX_INTEGER.\n * @returns {Integer} - A random integer.\n */\n get random_int() {\n let y,\n mag01 = new Array(0x0, this._MATRIX_A);\n if (this._mti >= this._N) {\n let kk;\n\n /* if (this._mti == this._N + 1) {\n this.seed = 5489;\n } */\n\n let N_M = this._N - this._M;\n let M_N = this._M - this._N;\n\n for (kk = 0; kk < N_M; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + this._M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (; kk < this._N - 1; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + M_N] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n\n y = (this._mt[this._N - 1] & this._UPPER_MASK) | (this._mt[0] & this._LOWER_MASK);\n this._mt[this._N - 1] = this._mt[this._M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this._mti = 0;\n }\n\n y = this._mt[(this._mti += 1)];\n y ^= y >>> 11;\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= y >>> 18;\n\n return y >>> 0;\n }\n\n /**\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n choice(A, n) {\n if (A instanceof Matrix) {\n let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A.row(d));\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let rows = A.length;\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A[d]);\n }\n }\n\n /**\n * @static\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @param {Number} seed - The seed for the random number generator.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n static choice(A, n, seed = 1212) {\n const R = new Randomizer(seed);\n return R.choice(A, n);\n /* let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let rand = new Randomizer(seed);\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = rand.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n //return result;\n //return new Matrix(n, cols, (row, col) => A.entry(sample[row], col))\n return sample.map((d) => A.row(d)); */\n }\n}\n","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias max\n * @param {Array} values \n * @returns {Number}\n */\nexport default function (values) {\n let max;\n for (const value of values) {\n if (value != null && (max < value || (max === undefined && value >= value))) {\n max = value;\n }\n }\n return max;\n}","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias min\n * @param {Array} values\n * @returns {Number}\n */\nexport default function (values) {\n let min;\n for (const value of values) {\n if (value != null && (min > value || (min === undefined && value <= value))) {\n min = value;\n }\n }\n return min;\n}","/**\n * @class\n * @alias Heap\n */\nexport class Heap {\n /**\n * A heap is a datastructure holding its elements in a specific way, so that the top element would be the first entry of an ordered list.\n * @constructor\n * @memberof module:datastructure\n * @alias Heap\n * @param {Array=} elements - Contains the elements for the Heap. {@link elements} can be null.\n * @param {Function} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(\"min\"|\"max\"|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n * @see {@link https://en.wikipedia.org/wiki/Binary_heap}\n */\n constructor(elements = null, accessor = d => d, comparator = \"min\") {\n if (elements) {\n return Heap.heapify(elements, accessor, comparator);\n } else {\n this._accessor = accessor;\n this._container = [];\n if (comparator == \"min\") {\n this._comparator = (a, b) => a < b;\n } else if (comparator == \"max\") {\n this._comparator = (a, b) => a > b;\n } else {\n this._comparator = comparator;\n }\n return this\n }\n }\n\n /**\n * Creates a Heap from an Array\n * @param {Array|Set} elements - Contains the elements for the Heap.\n * @param {Function=} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(String=|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n */\n static heapify(elements, accessor = d => d, comparator = \"min\") {\n const heap = new Heap(null, accessor, comparator);\n const container = heap._container;\n for (const e of elements) {\n container.push({\n \"element\": e,\n \"value\": accessor(e),\n });\n }\n for (let i = Math.floor((elements.length / 2) - 1); i >= 0; --i) {\n heap._heapify_down(i);\n }\n return heap;\n }\n\n /**\n * Swaps elements of container array.\n * @private\n * @param {Number} index_a \n * @param {Number} index_b \n */\n _swap(index_a, index_b) {\n const container = this._container;\n [container[index_b], container[index_a]] = [container[index_a], container[index_b]];\n return;\n }\n\n /**\n * @private\n */\n _heapify_up() {\n const container = this._container;\n let index = container.length - 1;\n while (index > 0) {\n let parentIndex = Math.floor((index - 1) / 2);\n if (!this._comparator(container[index].value, container[parentIndex].value)) {\n break;\n } else {\n this._swap(parentIndex, index)\n index = parentIndex;\n }\n }\n }\n\n /**\n * Pushes the element to the heap.\n * @param {} element\n * @returns {Heap}\n */\n push(element) {\n const value = this._accessor(element);\n //const node = new Node(element, value);\n const node = {\"element\": element, \"value\": value};\n this._container.push(node);\n this._heapify_up();\n return this;\n }\n\n /**\n * @private\n * @param {Number} [start_index = 0] \n */\n _heapify_down(start_index=0) {\n const container = this._container;\n const comparator = this._comparator;\n const length = container.length;\n let left = 2 * start_index + 1;\n let right = 2 * start_index + 2;\n let index = start_index;\n if (index > length) throw \"index higher than length\"\n if (left < length && comparator(container[left].value, container[index].value)) {\n index = left;\n }\n if (right < length && comparator(container[right].value, container[index].value)) {\n index = right;\n }\n if (index !== start_index) {\n this._swap(start_index, index);\n this._heapify_down(index);\n }\n }\n\n /**\n * Removes and returns the top entry of the heap.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n pop() {\n const container = this._container;\n if (container.length === 0) {\n return null;\n } else if (container.length === 1) {\n return container.pop();\n }\n this._swap(0, container.length - 1);\n const item = container.pop();\n this._heapify_down();\n return item;\n }\n\n /**\n * Returns the top entry of the heap without removing it.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n get first() {\n return this._container.length > 0 ? this._container[0] : null;\n }\n\n\n /**\n * Yields the raw data\n * @yields {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n * iterate() {\n for (let i = 0, n = this._container.length; i < n; ++i) {\n yield this._container[i].element;\n }\n }\n\n /**\n * Returns the heap as ordered array.\n * @returns {Array} Array consisting the elements ordered by {@link comparator}.\n */\n toArray() {\n return this.data()\n .sort((a,b) => this._comparator(a, b) ? -1 : 0)\n }\n\n /**\n * Returns elements of container array.\n * @returns {Array} Array consisting the elements.\n */\n data() {\n return this._container\n .map(d => d.element)\n }\n\n /**\n * Returns the container array.\n * @returns {Array} The container array.\n */\n raw_data() {\n return this._container;\n }\n\n /**\n * The size of the heap.\n * @returns {Number}\n */\n get length() {\n return this._container.length;\n }\n\n /**\n * Returns false if the the heap has entries, true if the heap has no entries.\n * @returns {Boolean}\n */\n get empty() {\n return this.length === 0;\n }\n}","/**\n * @class\n * @alias DisjointSet\n * @see {@link https://en.wikipedia.org/wiki/Disjoint-set_data_structure}\n */\nexport class DisjointSet {\n /**\n * @constructor\n * @alias DisjointSet\n * @memberof module:datastructure\n * @param {Array=} elements \n * @returns {DisjointSet}\n */\n constructor(elements = null) {\n this._list = new Set();\n if (elements) {\n for (const e of elements) {\n this.make_set(e);\n }\n }\n return this;\n }\n\n make_set(x) {\n const list = this._list;\n if (!list.has(x)) {\n list.add(x);\n x.__disjoint_set = {};\n x.__disjoint_set.parent = x;\n x.__disjoint_set.children = new Set([x]);\n x.__disjoint_set.size = 1;\n }\n return this;\n }\n\n find(x) {\n const list = this._list;\n if (list.has(x)) {\n if (x.__disjoint_set.parent !== x) {\n x.__disjoint_set.children.add(...x);\n x.__disjoint_set.parent = this.find(x.__disjoint_set.parent);\n return x.__disjoint_set.parent;\n } else {\n return x;\n }\n } else {\n return null;\n }\n }\n\n union(x, y) {\n let node_x = this.find(x);\n let node_y = this.find(y);\n\n if (node_x === node_y) return this;\n if (node_x.__disjoint_set.size < node_y.__disjoint_set.size) [node_x, node_y] = [node_y, node_x];\n\n node_y.__disjoint_set.parent = node_x;\n // keep track of children?\n node_y.__disjoint_set.children.forEach(node_x.__disjoint_set.children.add, node_x.__disjoint_set.children);\n node_x.__disjoint_set.size += node_y.__disjoint_set.size;\n\n return this;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n/**\n * @class\n * @alias BallTree\n */\nexport class BallTree {\n /**\n * Generates a BallTree with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias BallTree\n * @param {Array=} elements - Elements which should be added to the BallTree\n * @param {Function} [metric = euclidean] metric to use: (a, b) => distance\n * @see {@link https://en.wikipedia.org/wiki/Ball_tree}\n * @see {@link https://github.com/invisal/noobjs/blob/master/src/tree/BallTree.js}\n * @returns {BallTree}\n */\n constructor(elements = null, metric = euclidean) {\n this._Node = class {\n constructor(pivot, child1=null, child2=null, radius=null) {\n this.pivot = pivot;\n this.child1 = child1;\n this.child2 = child2;\n this.radius = radius;\n }\n }\n this._Leaf = class {\n constructor(points) {\n this.points = points;\n }\n }\n this._metric = metric;\n if (elements) {\n this.add(elements);\n }\n return this;\n }\n\n /**\n * \n * @param {Array<*>} elements - new elements.\n * @returns {BallTree}\n */\n add(elements) {\n elements = elements.map((element, index) => {\n return {index: index, element: element}\n })\n this._root = this._construct(elements);\n return this;\n }\n\n /**\n * @private\n * @param {Array<*>} elements \n * @returns {Node} root of balltree.\n */\n _construct(elements) {\n if (elements.length === 1) {\n return new this._Leaf(elements);\n } else {\n let c = this._greatest_spread(elements);\n let sorted_elements = elements.sort((a, b) => a.element[c] - b.element[c]);\n let n = sorted_elements.length;\n let p_index = Math.floor(n / 2);\n let p = elements[p_index];\n let L = sorted_elements.slice(0, p_index);\n let R = sorted_elements.slice(p_index, n);\n let radius = Math.max(...elements.map(d => this._metric(p.element, d.element)));\n let B\n if (L.length > 0 && R.length > 0) { \n B = new this._Node(p, this._construct(L), this._construct(R), radius);\n } else {\n B = new this._Leaf(elements);\n }\n return B;\n }\n }\n\n /**\n * @private\n * @param {Node} B \n * @returns {Number}\n */\n _greatest_spread(B) {\n let d = B[0].element.length;\n let start = new Array(d);\n\n for (let i = 0; i < d; ++i) {\n start[i] = [Infinity, -Infinity];\n }\n\n let spread = B.reduce((acc, current) => {\n for (let i = 0; i < d; ++i) {\n acc[i][0] = Math.min(acc[i][0], current.element[i]);\n acc[i][1] = Math.max(acc[i][1], current.element[i]);\n }\n return acc;\n }, start);\n spread = spread.map(d => d[1] - d[0]);\n \n let c = 0;\n for (let i = 0; i < d; ++i) {\n c = spread[i] > spread[c] ? i : c;\n }\n return c;\n }\n\n /**\n * \n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n return this._search(t, k, new Heap(null, d => this._metric(d.element, t), \"max\"), this._root);\n }\n\n /**\n * @private\n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @param {Heap} Q - Heap consists of the currently found {@link k} nearest neighbors.\n * @param {Node|Leaf} B \n */\n _search(t, k, Q, B) {\n // B is Node\n if (Q.length >= k && B.pivot && B.radius && this._metric(t, B.pivot.element) - B.radius >= Q.first.value) {\n return Q;\n } \n if (B.child1) this._search(t, k, Q, B.child1);\n if (B.child2) this._search(t, k, Q, B.child2);\n \n // B is leaf\n if (B.points) {\n for (let i = 0, n = B.points.length; i < n; ++i) {\n let p = B.points[i];\n if (k > Q.length) {\n Q.push(p);\n } else {\n Q.push(p);\n Q.pop();\n }\n }\n }\n return Q;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KNN\n */\nexport class KNN {\n /**\n * Generates a KNN list with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias KNN\n * @param {Array=} elements - Elements which should be added to the KNN list\n * @param {Function|\"precomputed\"} [metric = euclidean] metric is either precomputed or a function to use: (a, b) => distance\n * @returns {KNN}\n */\n constructor(elements=null, metric=euclidean) {\n this._metric = metric;\n this._elements = elements instanceof Matrix ? elements : Matrix.from(elements);\n const N = this._elements.shape[0];\n if (metric === \"precomputed\") {\n this._D = this._elements.clone();\n } else {\n this._D = distance_matrix(this._elements, metric);\n }\n this.KNN = [];\n for (let row = 0; row < N; ++row) {\n const distances = this._D.row(row);\n const H = new Heap(null, d => d.value, \"min\");\n for (let j = 0; j < N; ++j) {\n H.push({\n value: distances[j],\n index: j,\n });\n }\n this.KNN.push(H);\n }\n }\n\n /**\n * \n * @param {Array|Number} t - query element or index.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n const metric = this._metric;\n const KNN = this.KNN;\n let H;\n if (Array.isArray(t)) {\n if (this._metric == \"precomputed\") {\n throw \"Search by query element is only possible when not using a precomputed distance matrix!\"\n } \n const elements = this._elements;\n const N = KNN.length;\n let nearest_element_index = null;\n let nearest_dist = Infinity;\n for (let i = 0; i < N; ++i) {\n const element = elements.row(i);\n const dist = metric(t, element);\n if (dist < nearest_dist) {\n nearest_element_index = i;\n nearest_dist = dist;\n }\n }\n H = KNN[nearest_element_index];\n } else if (Number.isInteger(t)) {\n H = KNN[t]\n }\n\n let result = []\n for (let i = 0; i < k; ++i) {\n result.push(H.pop())\n }\n result.forEach(res => H.push(res.element))\n return result\n } \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n\n/**\n * @class\n * @alias DR\n * @borrows DR#parameter as DR#para\n * @borrows DR#parameter as DR#p\n */\nexport class DR {\n /**\n * Takes the default parameters and seals them, remembers the type of input {@link X}, and initializes the random number generator.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias DR\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed value for the random number generator.\n * @returns {DR}\n */\n constructor(X, default_parameters, parameters) {\n this._parameters = Object.assign(Object.seal(default_parameters), parameters);\n if (Array.isArray(X)) {\n this._type = \"array\";\n this.X = Matrix.from(X);\n } else if (X instanceof Matrix) {\n this._type = \"matrix\";\n this.X = X;\n } else {\n throw new Error(\"No valid type for X!\");\n }\n [this._N, this._D] = this.X.shape;\n this._randomizer = new Randomizer(this._parameters.seed);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * Set and get parameters\n * @param {String} name - name of the parameter.\n * @param {any} [value = null] - value of the parameter to set.\n * @returns {DR|any} - On setting a parameter, this function returns the DR object. If value == null then return actual parameter value.\n * @example\n * const DR = new druid.TSNE(X, {d: 3}); // creates a new DR object, with parameter for d = 3.\n * DR.parameter(\"d\"); // returns 3,\n * DR.parameter(\"d\", 2); // sets parameter d to 2 and returns DR.\n */\n parameter(name, value = null) {\n if (!this._parameters.hasOwnProperty(name)) {\n throw new Error(`${name} is not a valid parameter!`);\n }\n if (value) {\n this._parameters[name] = value;\n this._is_initialized = false;\n return this;\n } else {\n return this._parameters[name];\n }\n }\n\n para(name, value = null) {\n return this.parameter(name, value);\n }\n\n p(name, value = null) {\n return this.parameter(name, value);\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} - Returns the projection.\n */\n transform() {\n this.check_init();\n return this.projection;\n }\n\n /**\n * Computes the projection.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n *generator() {\n return this.transform();\n }\n\n /**\n * If the respective DR method has an init function, call it before transform.\n * @returns {DR}\n */\n check_init() {\n if (!this._is_initialized && typeof this.init === \"function\") {\n this.init();\n this._is_initialized = true;\n }\n return this;\n }\n\n /**\n * @returns {Matrix|Array} Returns the projection.\n */\n get projection() {\n if (this.hasOwnProperty(\"Y\")) {\n this.check_init();\n return this._type === \"matrix\" ? this.Y : this.Y.to2dArray;\n } else {\n throw new Error(\"The dataset is not transformed yet!\");\n }\n }\n\n /**\n *\n * @param {...any} args - Arguments the transform method of the respective DR method takes.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Matrix|Array} - The dimensionality reduced dataset.\n */\n static transform(...args) {\n let dr = new this(...args);\n return dr.transform();\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n static async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n static *generator(...args) {\n const dr = new this(...args);\n const generator = dr.generator();\n for (const result of generator) {\n yield result;\n }\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias PCA\n * @augments DR\n */\nexport class PCA extends DR {\n /**\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias PCA\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @returns {PCA}\n */\n constructor(X, parameters) {\n super(X, { d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}. If parameter {@link A} is given, then project {@link A} with the principal components of {@link X}.\n * @param {null|Matrix|Array} [A = null] - If given, the data to project.\n * @returns {Matrix|Array} - The projected data.\n */\n transform(A = null) {\n const V = this.principal_components();\n if (A == null) {\n const X = this.X;\n this.Y = X.dot(V);\n return this.projection;\n } else if (Array.isArray(A)) {\n return Matrix.from(A).dot(V).asArray;\n } else if (A instanceof Matrix) {\n return A.dot(V);\n } else {\n throw new Error(\"No valid type for A!\");\n }\n }\n\n /**\n * Computes the {@link d} principal components of Matrix {@link X}.\n * @returns {Matrix}\n */\n principal_components() {\n if (this.V) {\n return this.V;\n }\n const { d, eig_args } = this._parameters;\n const X = this.X;\n const means = Matrix.from(X.meanCols);\n const X_cent = X.sub(means);\n const C = X_cent.transpose().dot(X_cent);\n const { eigenvectors: V } = simultaneous_poweriteration(C, d, eig_args);\n this.V = Matrix.from(V).transpose();\n return this.V;\n }\n\n static principal_components(X, parameters) {\n const dr = new this(X, parameters);\n return dr.principal_components();\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias MDS\n * @extends DR\n */\nexport class MDS extends DR {\n /**\n * Classical MDS.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias MDS\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}.\n * @returns {Matrix|Array}\n */\n transform() {\n const X = this.X;\n const rows = X.shape[0];\n const { d, metric, eig_args } = this._parameters;\n const A = metric === \"precomputed\" ? X : distance_matrix(X, metric);\n const ai_ = A.meanCols;\n const a_j = A.meanRows;\n const a__ = A.mean;\n\n this._d_X = A;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n\n return this.projection;\n }\n\n /**\n * @returns {Number} - the stress of the projection.\n */\n stress() {\n const N = this.X.shape[0];\n const Y = this.Y;\n const d_X = this._d_X;\n const d_Y = new Matrix();\n d_Y.shape = [\n N,\n N,\n (i, j) => {\n return i < j ? euclidean(Y.row(i), Y.row(j)) : d_Y.entry(j, i);\n },\n ];\n let top_sum = 0;\n let bottom_sum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n top_sum += Math.pow(d_X.entry(i, j) - d_Y.entry(i, j), 2);\n bottom_sum += Math.pow(d_X.entry(i, j), 2);\n }\n }\n return Math.sqrt(top_sum / bottom_sum);\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { DR } from \"./DR.js\";\nimport euclidean from \"../metrics/euclidean.js\";\n\n/**\n * @class\n * @alias ISOMAP\n * @extends DR\n */\nexport class ISOMAP extends DR {\n /**\n * Isometric feature mapping (ISOMAP).\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias ISOMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link ISOMAP} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2319}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(this._parameters.neighbors ?? Math.max(Math.floor(this.X.shape[0] / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const X = this.X;\n const rows = this._N;\n const { d, metric, eig_args, neighbors } = this._parameters;\n // TODO: make knn extern and parameter for constructor or transform?\n const D = new Matrix();\n D.shape = [rows, rows, (i, j) => (i <= j ? metric(X.row(i), X.row(j)) : D.entry(j, i))];\n const kNearestNeighbors = [];\n for (let i = 0; i < rows; ++i) {\n const row = [];\n for (let j = 0; j < rows; ++j) {\n row.push({\n index: j,\n distance: D.entry(i, j),\n });\n }\n const H = new Heap(row, (d) => d.distance, \"min\");\n kNearestNeighbors.push(H.toArray().slice(1, neighbors + 1));\n }\n\n /*D = dijkstra(kNearestNeighbors);*/\n // compute shortest paths\n // TODO: make extern\n /** @see {@link https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm} */\n const G = new Matrix(rows, rows, (i, j) => {\n const other = kNearestNeighbors[i].find((n) => n.index === j);\n return other ? other.distance : Infinity;\n });\n\n for (let i = 0; i < rows; ++i) {\n for (let j = 0; j < rows; ++j) {\n for (let k = 0; k < rows; ++k) {\n G.set_entry(i, j, Math.min(G.entry(i, j), G.entry(i, k) + G.entry(k, j)));\n }\n }\n }\n\n let ai_ = new Float64Array(rows);\n let a_j = new Float64Array(rows);\n let a__ = 0;\n const A = new Matrix(rows, rows, (i, j) => {\n let val = G.entry(i, j);\n val = val === Infinity ? 0 : val;\n ai_[i] += val;\n a_j[j] += val;\n a__ += val;\n return val;\n });\n\n ai_ = ai_.map((v) => v / rows);\n a_j = a_j.map((v) => v / rows);\n a__ /= rows ** 2;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n // compute d eigenvectors\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n/**\n * @class\n * @alias FASTMAP\n * @extends DR\n */\nexport class FASTMAP extends DR {\n /**\n * FastMap: a fast algorithm for indexing, data-mining and visualization of traditional and multimedia datasets\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias FASTMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the dimensionality of the projection.\n * @returns {FASTMAP}\n * @see {@link https://doi.org/10.1145/223784.223812}\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n * Chooses two points which are the most distant in the actual projection.\n * @private\n * @param {Function} dist\n * @returns {Array} An array consisting of first index, second index, and distance between the two points.\n */\n _choose_distant_objects(dist) {\n const X = this.X;\n const N = X.shape[0];\n let a_index = (this._randomizer.random_int % N) - 1;\n let b_index = null;\n let max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n if (d_ai > max_dist) {\n max_dist = d_ai;\n b_index = i;\n }\n }\n max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_bi = dist(b_index, i);\n if (d_bi > max_dist) {\n max_dist = d_bi;\n a_index = i;\n }\n }\n return [a_index, b_index, max_dist];\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} The {@link d}-dimensional projection of the data matrix {@link X}.\n */\n transform() {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric } = this._parameters;\n const Y = new Matrix(N, d, 0);\n let dist = (a, b) => metric(X.row(a), X.row(b));\n\n for (let _col = 0; _col < d; ++_col) {\n let old_dist = dist;\n // choose pivot objects\n const [a_index, b_index, d_ab] = this._choose_distant_objects(dist);\n if (d_ab !== 0) {\n // project the objects on the line (O_a, O_b)\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n const d_bi = dist(b_index, i);\n const y_i = (d_ai ** 2 + d_ab ** 2 - d_bi ** 2) / (2 * d_ab);\n Y.set_entry(i, _col, y_i);\n }\n // consider the projections of the objects on a\n // hyperplane perpendicluar to the line (a, b);\n // the distance function D'() between two\n // projections is given by Eq.4\n dist = (a, b) => Math.sqrt(old_dist(a, b) ** 2 - (Y.entry(a, _col) - Y.entry(b, _col)) ** 2);\n }\n }\n // return embedding.\n this.Y = Y;\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LDA\n * @extends DR\n */\nexport class LDA extends DR {\n /**\n * Linear Discriminant Analysis.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LDA\n * @param {Matrix} X - The high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Array} parameters.labels - The labels / classes for each data point.\n * @param {number} [parameters.d = 2] - The dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://onlinelibrary.wiley.com/doi/10.1111/j.1469-1809.1936.tb02137.x}\n */\n constructor(X, parameters) {\n super(X, { labels: null, d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, cols] = X.shape;\n const { d, labels, eig_args } = this._parameters;\n if (labels === null || labels.length != rows) {\n throw new Error(\"LDA needs parameter label to every datapoint to work!\");\n }\n const unique_labels = {};\n let label_id = 0;\n labels.forEach((l, i) => {\n if (l in unique_labels) {\n unique_labels[l].count++;\n unique_labels[l].rows.push(X.row(i));\n } else {\n unique_labels[l] = {\n id: label_id++,\n count: 1,\n rows: [X.row(i)],\n };\n }\n });\n\n // create X_mean and vector means;\n const X_mean = X.mean;\n const V_mean = new Matrix(label_id, cols);\n for (const label in unique_labels) {\n const V = Matrix.from(unique_labels[label].rows);\n const v_mean = V.meanCols;\n for (let j = 0; j < cols; ++j) {\n V_mean.set_entry(unique_labels[label].id, j, v_mean[j]);\n }\n }\n // scatter_between\n let S_b = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j] - X_mean);\n const N = unique_labels[label].count;\n S_b = S_b.add(m.dot(m.transpose()).mult(N));\n }\n\n // scatter_within\n let S_w = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j]);\n const R = unique_labels[label].rows;\n for (let i = 0, n = unique_labels[label].count; i < n; ++i) {\n const row_v = new Matrix(cols, 1, (j, _) => R[i][j] - m.entry(j, 0));\n S_w = S_w.add(row_v.dot(row_v.transpose()));\n }\n }\n\n let { eigenvectors: V } = simultaneous_poweriteration(S_w.inverse().dot(S_b), d, eig_args);\n V = Matrix.from(V).transpose();\n this.Y = X.dot(V);\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { k_nearest_neighbors } from \"../matrix/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LLE\n * @extends DR\n */\nexport class LLE extends DR {\n /**\n * Locally Linear Embedding.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LLE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} neighbors - the label / class of each data point.\n * @param {Number} [d = 2] - the dimensionality of the projection.\n * @param {Function} [metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [seed = 1212] - the dimensionality of the projection.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2323}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const rows = this._N;\n const cols = this._D;\n const { neighbors, d, eig_args, metric } = this._parameters;\n const nN = k_nearest_neighbors(X, neighbors, metric);\n const O = new Matrix(neighbors, 1, 1);\n const W = new Matrix(rows, rows);\n\n for (let row = 0; row < rows; ++row) {\n const nN_row = nN[row];\n const Z = new Matrix(neighbors, cols, (i, j) => X.entry(nN_row[i].j, j) - X.entry(row, j));\n const C = Z.dot(Z.T);\n if (neighbors > cols) {\n const C_trace = neumair_sum(C.diag) / 1000;\n for (let j = 0; j < neighbors; ++j) {\n C.set_entry(j, j, C.entry(j, j) + C_trace);\n }\n }\n // reconstruct;\n let w = Matrix.solve_CG(C, O, this._randomizer);\n w = w.divide(w.sum);\n for (let j = 0; j < neighbors; ++j) {\n W.set_entry(row, nN_row[j].j, w.entry(j, 0));\n }\n }\n // comp embedding\n const I = new Matrix(rows, rows, \"identity\");\n const IW = I.sub(W);\n const M = IW.T.dot(IW);\n const { eigenvectors: V } = simultaneous_poweriteration(M.T.inverse(), d + 1, eig_args);\n this.Y = Matrix.from(V.slice(1, 1 + d)).T;\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix, k_nearest_neighbors } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LTSA\n * @extends DR\n */\nexport class LTSA extends DR {\n /**\n * Local Tangent Space Alignment\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LTSA\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link LTSA} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://epubs.siam.org/doi/abs/10.1137/S1064827502419154}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n if (this._D <= this.parameter(\"d\")) {\n throw new Error(`Dimensionality of X (D = ${this._D}) must be greater than the required dimensionality of the result (d = ${this.parameter(\"d\")})!`);\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, D] = X.shape;\n const { d, neighbors, metric, eig_args } = this._parameters;\n // 1.1 determine k nearest neighbors\n const nN = k_nearest_neighbors(X, neighbors, metric);\n // center matrix\n const O = new Matrix(D, D, \"center\");\n const B = new Matrix(rows, rows, 0);\n\n for (let row = 0; row < rows; ++row) {\n // 1.2 compute the d largest eigenvectors of the correlation matrix\n const I_i = [row, ...nN[row].map((n) => n.j)];\n let X_i = Matrix.from(I_i.map((n) => X.row(n)));\n // center X_i\n X_i = X_i.dot(O);\n // correlation matrix\n const C = X_i.dot(X_i.transpose());\n const { eigenvectors: g } = simultaneous_poweriteration(C, d, eig_args);\n //g.push(linspace(0, k).map(_ => 1 / Math.sqrt(k + 1)));\n const G_i_t = Matrix.from(g);\n // 2. Constructing alignment matrix\n const W_i = G_i_t.transpose()\n .dot(G_i_t)\n .add(1 / Math.sqrt(neighbors + 1));\n for (let i = 0; i < neighbors + 1; ++i) {\n for (let j = 0; j < neighbors + 1; ++j) {\n B.set_entry(I_i[i], I_i[j], B.entry(I_i[i], I_i[j]) - (i === j ? 1 : 0) + W_i.entry(i, j));\n }\n }\n }\n\n // 3. Aligning global coordinates\n const { eigenvectors: Y } = simultaneous_poweriteration(B, d + 1, eig_args);\n this.Y = Matrix.from(Y.slice(1)).transpose();\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TSNE\n * @extends DR\n */\nexport class TSNE extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TSNE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.perplexity = 50] - perplexity.\n * @param {Number} [parameters.epsilon = 10] - learning parameter.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TSNE}\n */\n constructor(X, parameters) {\n super(X, { perplexity: 50, epsilon: 10, d: 2, metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._iter = 0;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => this._randomizer.random);\n return this;\n }\n\n /**\n *\n * @param {Matrix} distance_matrix - accepts a precomputed distance matrix\n * @returns {TSNE}\n */\n init() {\n // init\n const Htarget = Math.log(this.parameter(\"perplexity\"));\n const N = this._N;\n const D = this._D;\n const {metric} = this._parameters;\n const X = this.X;\n let Delta;\n if (metric ==\"precomputed\") {\n Delta = druid.Matrix.from(X);\n } else {\n Delta = new Matrix(N, N);\n for (let i = 0; i < N; ++i) {\n const X_i = X.row(i);\n for (let j = i + 1; j < N; ++j) {\n const distance = metric(X_i, X.row(j));\n Delta.set_entry(i, j, distance);\n Delta.set_entry(j, i, distance);\n }\n }\n }\n\n const P = new Matrix(N, N, \"zeros\");\n\n this._ystep = new Matrix(N, D, \"zeros\");\n this._gains = new Matrix(N, D, 1);\n\n // search for fitting sigma\n let prow = new Float64Array(N)\n const tol = 1e-4;\n const maxtries = 50;\n for (let i = 0; i < N; ++i) {\n let betamin = -Infinity;\n let betamax = Infinity;\n let beta = 1;\n let done = false;\n\n let num = 0;\n while (!done) {\n let psum = 0;\n for (let j = 0; j < N; ++j) {\n let pj = Math.exp(-Delta.entry(i, j) * beta);\n if (i === j) pj = 0;\n prow[j] = pj;\n psum += pj;\n }\n let Hhere = 0;\n for (let j = 0; j < N; ++j) {\n let pj = psum === 0 ? 0 : prow[j] / psum;\n prow[j] = pj;\n if (pj > 1e-7) {\n Hhere -= pj * Math.log(pj);\n }\n }\n if (Hhere > Htarget) {\n betamin = beta;\n beta = betamax === Infinity ? beta * 2 : (beta + betamax) / 2;\n } else {\n betamax = beta;\n beta = betamin === -Infinity ? beta / 2 : (beta + betamin) / 2;\n }\n ++num;\n if (Math.abs(Hhere - Htarget) < tol) done = true;\n if (num >= maxtries) done = true;\n }\n\n for (let j = 0; j < N; ++j) {\n P.set_entry(i, j, prow[j]);\n }\n }\n\n //compute probabilities\n const Pout = new Matrix(N, N, \"zeros\");\n const N2 = N * 2;\n for (let i = 0; i < N; ++i) {\n for (let j = i; j < N; ++j) {\n const p = Math.max((P.entry(i, j) + P.entry(j, i)) / N2, 1e-100);\n Pout.set_entry(i, j, p);\n Pout.set_entry(j, i, p);\n }\n }\n this._P = Pout;\n return this;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n transform(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n *generator(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * performs a optimization step\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const P = this._P;\n const ystep = this._ystep;\n const gains = this._gains;\n const N = this._N;\n const { d: dim, epsilon} = this._parameters;\n let Y = this.Y;\n\n //calc cost gradient;\n const pmul = iter < 100 ? 4 : 1;\n\n // compute Q dist (unnormalized)\n const Qu = new Matrix(N, N, \"zeros\");\n let qsum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dsum = 0;\n for (let d = 0; d < dim; ++d) {\n const dhere = Y.entry(i, d) - Y.entry(j, d);\n dsum += dhere * dhere;\n }\n const qu = 1 / (1 + dsum);\n Qu.set_entry(i, j, qu);\n Qu.set_entry(j, i, qu);\n qsum += 2 * qu;\n }\n }\n\n // normalize Q dist\n const Q = new Matrix(N, N, 0);\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n const val = Math.max(Qu.entry(i, j) / qsum, 1e-100);\n Q.set_entry(i, j, val);\n Q.set_entry(j, i, val);\n }\n }\n\n const grad = new Matrix(N, dim, \"zeros\");\n for (let i = 0; i < N; ++i) {\n for (let j = 0; j < N; ++j) {\n const premult = 4 * (pmul * P.entry(i, j) - Q.entry(i, j)) * Qu.entry(i, j);\n for (let d = 0; d < dim; ++d) {\n grad.set_entry(i, d, grad.entry(i, d) + premult * (Y.entry(i, d) - Y.entry(j, d)));\n }\n }\n }\n\n // perform gradient step\n let ymean = new Float64Array(dim);\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const gid = grad.entry(i, d);\n const sid = ystep.entry(i, d);\n const gainid = gains.entry(i, d);\n\n let newgain = Math.sign(gid) === Math.sign(sid) ? gainid * 0.8 : gainid + 0.2;\n if (newgain < 0.01) newgain = 0.01;\n gains.set_entry(i, d, newgain);\n\n const momval = iter < 250 ? 0.5 : 0.8;\n const newsid = momval * sid - epsilon * newgain * gid;\n ystep.set_entry(i, d, newsid);\n\n Y.set_entry(i, d, Y.entry(i, d) + newsid);\n ymean[d] += Y.entry(i, d);\n }\n }\n\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < 2; ++d) {\n Y.set_entry(i, d, Y.entry(i, d) - ymean[d] / N);\n }\n }\n\n return this.Y;\n }\n}\n","/**\n *\n * @memberof module:optimization\n * @alias powell\n * @param {Function} f\n * @param {Array} x0\n * @param {Number} [max_iter = 300]\n * @returns {Array}\n * @see http://optimization-js.github.io/optimization-js/optimization.js.html#line438\n */\nexport default function (f, x0, max_iter = 300) {\n const epsilon = 1e-2;\n const n = x0.length;\n let alpha = 1e-3;\n let pfx = 10000;\n let x = x0.slice();\n let fx = f(x);\n let convergence = false;\n\n while (max_iter-- >= 0 && !convergence) {\n convergence = true;\n for (let i = 0; i < n; ++i) {\n x[i] += 1e-6;\n let fxi = f(x);\n x[i] -= 1e-6;\n let dx = (fxi - fx) / 1e-6;\n if (Math.abs(dx) > epsilon) {\n convergence = false;\n }\n x[i] -= alpha * dx;\n fx = f(x);\n }\n alpha *= pfx >= fx ? 1.05 : 0.4;\n pfx = fx;\n }\n return x;\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean, euclidean_squared } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { linspace } from \"../matrix/index.js\";\nimport { powell } from \"../optimization/index.js\";\nimport { DR } from \"./DR.js\";\nimport { max } from \"../util/index.js\";\nimport { KNN } from \"../knn/index.js\";\n\n/**\n * @class\n * @alias UMAP\n * @extends DR\n */\nexport class UMAP extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias UMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.n_neighbors = 15] - size of the local neighborhood.\n * @param {Number} [parameters.local_connectivity = 1] - number of nearest neighbors connected in the local neighborhood.\n * @param {Number} [parameters.min_dist = 1] - controls how tightly points get packed together.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points in the high-dimensional space.\n * @param {Number} [parameters._spread = 1] - The effective scale of embedded points. (In combination with {@link parameters.min_dist})\n * @param {Number} [parameters._set_op_mix_ratio = 1] - Interpolate between union and intersection.\n * @param {Number} [parameters._repulsion_strength = 1] - Weighting applied to negative samples.\n * @param {Number} [parameters._negative_sample_rate = 5] - The number of negative samples per positive sample.\n * @param {Number} [parameters._n_epochs = 350] - The number of training epochs.\n * @param {Number} [parameter._initial_alpha = 1] - The initial learning rate for the optimization.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {UMAP}\n */\n constructor(X, parameters) {\n super(X, { n_neighbors: 15, local_connectivity: 1, min_dist: 1, d: 2, metric: euclidean, seed: 1212, _spread: 1, _set_op_mix_ratio: 1, _repulsion_strength: 1, _negative_sample_rate: 5, _n_epochs: 350, _initial_alpha: 1 }, parameters);\n [this._N, this._D] = this.X.shape;\n /* let n_neighbors = Math.min(this._N - 1, parameters.n_neighbors);\n this.parameter(\"n_neighbors\", n_neighbors);\n this.parameter(\"local_connectivity\", Math.min(this.parameter(\"local_connectivity\"), n_neighbors - 1)); */\n if (this.parameter(\"n_neighbors\") > this._N) {\n throw new Error(`Parameter n_neighbors (=${this.parameter(\"n_neighbors\")}) needs to be smaller than dataset size (N=${this._N})!`);\n }\n if (this.parameter(\"local_connectivity\") > this.parameter(\"n_neighbors\")) {\n throw new Error(`Parameter local_connectivity (=${this.parameter(\"local_connectivity\")}) needs to be smaller than parameter n_neighbors (=${this.parameter(\"n_neighbors\")})`);\n }\n this._iter = 0;\n const randomizer = this._randomizer;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => randomizer.random);\n return this;\n }\n\n /**\n * @private\n * @param {Number} spread\n * @param {Number} min_dist\n * @returns {Array}\n */\n _find_ab_params(spread, min_dist) {\n const curve = (x, a, b) => 1 / (1 + a * Math.pow(x, 2 * b));\n const xv = linspace(0, spread * 3, 300);\n const yv = linspace(0, spread * 3, 300);\n\n for (let i = 0, n = xv.length; i < n; ++i) {\n const xv_i = xv[i];\n yv[i] = xv_i < min_dist ? 1 : Math.exp(-(xv_i - min_dist) / spread);\n }\n\n const err = (p) => {\n const error = linspace(1, 300).map((_, i) => yv[i] - curve(xv[i], p[0], p[1]));\n return Math.sqrt(neumair_sum(error.map((e) => e * e)));\n };\n\n return powell(err, [1, 1]);\n }\n\n /**\n * @private\n * @param {Array} distances\n * @param {Array} sigmas\n * @param {Array} rhos\n * @returns {Array}\n */\n _compute_membership_strengths(distances, sigmas, rhos) {\n for (let i = 0, n = distances.length; i < n; ++i) {\n for (let j = 0, m = distances[i].length; j < m; ++j) {\n const v = distances[i][j].value - rhos[i];\n distances[i][j].value = v > 0 ? Math.exp(-v / sigmas[i]) : 1;\n }\n }\n return distances;\n }\n\n /**\n * @private\n * @param {KNN|BallTree} knn\n * @param {Number} k\n * @returns {Object}\n */\n _smooth_knn_dist(knn, k) {\n const SMOOTH_K_TOLERANCE = 1e-5;\n const MIN_K_DIST_SCALE = 1e-3;\n const n_iter = 64;\n const { local_connectivity, metric } = this._parameters;\n const target = Math.log2(k);\n const rhos = [];\n const sigmas = [];\n const X = this.X;\n const N = X.shape[0];\n //const distances = [...X].map(x_i => knn.search(x_i, k).raw_data().reverse());\n\n const distances = [];\n if (metric === \"precomputed\") {\n for (let i = 0; i < N; ++i) {\n distances.push(knn.search(i, k).reverse());\n }\n } else {\n for (const x_i of X) {\n distances.push(knn.search(x_i, k).raw_data().reverse());\n }\n }\n\n for (let i = 0; i < N; ++i) {\n let lo = 0;\n let hi = Infinity;\n let mid = 1;\n\n const search_result = distances[i];\n const non_zero_dist = search_result.filter((d) => d.value > 0);\n const non_zero_dist_length = non_zero_dist.length;\n if (non_zero_dist_length >= local_connectivity) {\n const index = Math.floor(local_connectivity);\n const interpolation = local_connectivity - index;\n if (index > 0) {\n rhos.push(non_zero_dist[index - 1]);\n if (interpolation > SMOOTH_K_TOLERANCE) {\n rhos[i].value += interpolation * (non_zero_dist[index].value - non_zero_dist[index - 1]);\n }\n } else {\n rhos[i].value = interpolation * non_zero_dist[0].value;\n }\n } else if (non_zero_dist_length > 0) {\n rhos[i] = non_zero_dist[non_zero_dist_length - 1].value;\n }\n for (let x = 0; x < n_iter; ++x) {\n let psum = 0;\n for (let j = 0; j < k; ++j) {\n const d = search_result[j].value - rhos[i];\n psum += d > 0 ? Math.exp(-(d / mid)) : 1;\n }\n if (Math.abs(psum - target) < SMOOTH_K_TOLERANCE) {\n break;\n }\n if (psum > target) {\n [hi, mid] = [mid, (lo + hi) / 2];\n } else {\n if (hi === Infinity) {\n [lo, mid] = [mid, mid * 2];\n } else {\n [lo, mid] = [mid, (lo + hi) / 2];\n }\n }\n }\n sigmas[i] = mid;\n\n const mean_ithd = search_result.reduce((a, b) => a + b.value, 0) / search_result.length;\n //let mean_d = null;\n if (rhos[i] > 0) {\n if (sigmas[i] < MIN_K_DIST_SCALE * mean_ithd) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_ithd;\n }\n } else {\n const mean_d = distances.reduce((acc, res) => acc + res.reduce((a, b) => a + b.value, 0) / res.length);\n if (sigmas[i] > MIN_K_DIST_SCALE * mean_d) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_d;\n }\n }\n }\n return {\n distances: distances,\n sigmas: sigmas,\n rhos: rhos,\n };\n }\n\n /**\n * @private\n * @param {Matrix} X\n * @param {Number} n_neighbors\n * @returns {Matrix}\n */\n _fuzzy_simplicial_set(X, n_neighbors) {\n const N = X.shape[0];\n const { metric, _set_op_mix_ratio } = this._parameters;\n const knn = metric === \"precomputed\" ? new KNN(X, \"precomputed\") : new BallTree(X.to2dArray, metric);\n let { distances, sigmas, rhos } = this._smooth_knn_dist(knn, n_neighbors);\n distances = this._compute_membership_strengths(distances, sigmas, rhos);\n const result = new Matrix(N, N, \"zeros\");\n for (let i = 0; i < N; ++i) {\n const distances_i = distances[i];\n for (let j = 0; j < distances_i.length; ++j) {\n result.set_entry(i, distances_i[j].element.index, distances_i[j].value);\n }\n }\n\n const transposed_result = result.T;\n const prod_matrix = result.mult(transposed_result);\n return result\n .add(transposed_result)\n .sub(prod_matrix)\n .mult(_set_op_mix_ratio)\n .add(prod_matrix.mult(1 - _set_op_mix_ratio));\n }\n\n /**\n * @private\n * @param {Number} n_epochs\n * @returns {Array}\n */\n _make_epochs_per_sample(n_epochs) {\n const weights = this._weights;\n const result = new Float32Array(weights.length).fill(-1);\n const weights_max = max(weights);\n const n_samples = weights.map((w) => n_epochs * (w / weights_max));\n for (let i = 0; i < result.length; ++i) if (n_samples[i] > 0) result[i] = Math.round(n_epochs / n_samples[i]);\n return result;\n }\n\n /**\n * @private\n * @param {Matrix} graph\n * @returns {Object}\n */\n _tocoo(graph) {\n const rows = [];\n const cols = [];\n const data = [];\n const [rows_n, cols_n] = graph.shape;\n for (let row = 0; row < rows_n; ++row) {\n for (let col = 0; col < cols_n; ++col) {\n const entry = graph.entry(row, col);\n if (entry !== 0) {\n rows.push(row);\n cols.push(col);\n data.push(entry);\n }\n }\n }\n return {\n rows: rows,\n cols: cols,\n data: data,\n };\n }\n\n /**\n * Computes all necessary\n * @returns {UMAP}\n */\n init() {\n const { _spread, min_dist, n_neighbors, _n_epochs, _negative_sample_rate } = this._parameters;\n const [a, b] = this._find_ab_params(_spread, min_dist);\n this._a = a;\n this._b = b;\n this._graph = this._fuzzy_simplicial_set(this.X, n_neighbors);\n const { rows, cols, data: weights } = this._tocoo(this._graph);\n this._head = rows;\n this._tail = cols;\n this._weights = weights;\n this._epochs_per_sample = this._make_epochs_per_sample(_n_epochs);\n this._epochs_per_negative_sample = this._epochs_per_sample.map((d) => d * _negative_sample_rate);\n this._epoch_of_next_sample = this._epochs_per_sample.slice();\n this._epoch_of_next_negative_sample = this._epochs_per_negative_sample.slice();\n return this;\n }\n\n graph() {\n this.check_init();\n return { cols: this._head, rows: this._tail, weights: this._weights };\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n transform(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n *generator(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * @private\n * @param {Number} x\n * @returns {Number}\n */\n _clip(x) {\n if (x > 4) return 4;\n if (x < -4) return -4;\n return x;\n }\n\n /**\n * performs the optimization step.\n * @private\n * @param {Matrix} head_embedding\n * @param {Matrix} tail_embedding\n * @param {Matrix} head\n * @param {Matrix} tail\n * @returns {Matrix}\n */\n _optimize_layout(head_embedding, tail_embedding, head, tail) {\n const randomizer = this._randomizer;\n const { _repulsion_strength, d: dim } = this._parameters;\n const { _alpha: alpha, _a: a, _b: b, _epochs_per_sample: epochs_per_sample, _epochs_per_negative_sample: epochs_per_negative_sample, _epoch_of_next_negative_sample: epoch_of_next_negative_sample, _epoch_of_next_sample: epoch_of_next_sample, _clip: clip } = this;\n const tail_length = tail.length;\n\n for (let i = 0, n = epochs_per_sample.length; i < n; ++i) {\n if (epoch_of_next_sample[i] <= this._iter) {\n const j = head[i];\n const k = tail[i];\n const current = head_embedding.row(j);\n const other = tail_embedding.row(k);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (-2 * a * b * Math.pow(dist, b - 1)) / (a * Math.pow(dist, b) + 1);\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(k, d, o);\n }\n epoch_of_next_sample[i] += epochs_per_sample[i];\n const n_neg_samples = (this._iter - epoch_of_next_negative_sample[i]) / epochs_per_negative_sample[i];\n for (let p = 0; p < n_neg_samples; ++p) {\n const k = randomizer.random_int % tail_length;\n const other = tail_embedding.row(tail[k]);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (2 * _repulsion_strength * b) / ((0.01 + dist) * (a * Math.pow(dist, b) + 1));\n } else if (j === k) {\n continue;\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(tail[k], d, o);\n }\n }\n epoch_of_next_negative_sample[i] += n_neg_samples * epochs_per_negative_sample[i];\n }\n }\n return head_embedding;\n }\n\n /**\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const Y = this.Y;\n const { _initial_alpha, _n_epochs } = this._parameters;\n this._alpha = _initial_alpha * (1 - iter / _n_epochs);\n this.Y = this._optimize_layout(Y, Y, this._head, this._tail);\n\n return this.Y;\n }\n}\n","import { Matrix, linspace } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { PCA } from \"./PCA.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TriMap\n * @extends DR\n */\nexport class TriMap extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TriMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.weight_adj = 500] - scaling factor.\n * @param {Number} [parameters.c = 5] - number of triplets multiplier.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.tol = 1e-8] -\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TriMap}\n * @see {@link https://arxiv.org/pdf/1910.00204v1.pdf}\n * @see {@link https://github.com/eamid/trimap}\n */\n constructor(X, parameters) {\n super(X, { weight_adj: 500, c: 5, d: 2, metric: euclidean, tol: 1e-8, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n *\n * @param {Matrix} [pca = null] - Initial Embedding (if null then PCA gets used).\n * @param {KNN} [knn = null] - KNN Object (if null then BallTree gets used).\n */\n init(pca = null, knn = null) {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric, c } = this._parameters;\n this.n_inliers = 2 * c;\n this.n_outliers = 1 * c;\n this.n_random = 1 * c;\n this.Y = pca || new PCA(X, d).transform();\n this.knn = knn || new BallTree(X.to2dArray, metric);\n const { triplets, weights } = this._generate_triplets(this.n_inliers, this.n_outliers, this.n_random);\n this.triplets = triplets;\n this.weights = weights;\n this.lr = (1000 * N) / triplets.shape[0];\n this.C = Infinity;\n this.vel = new Matrix(N, d, 0);\n this.gain = new Matrix(N, d, 1);\n return this;\n }\n\n /**\n * Generates {@link n_inliers} x {@link n_outliers} x {@link n_random} triplets.\n * @param {Number} n_inliers\n * @param {Number} n_outliers\n * @param {Number} n_random\n */\n _generate_triplets(n_inliers, n_outliers, n_random) {\n const { metric, weight_adj } = this._parameters;\n const X = this.X;\n const N = X.shape[0];\n const knn = this.knn;\n const n_extra = Math.min(n_inliers + 20, N);\n const nbrs = new Matrix(N, n_extra);\n const knn_distances = new Matrix(N, n_extra);\n for (let i = 0; i < N; ++i) {\n knn.search(X.row(i), n_extra + 1)\n .raw_data()\n .filter((d) => d.value != 0)\n .sort((a, b) => a.value - b.value)\n .forEach((d, j) => {\n nbrs.set_entry(i, j, d.element.index);\n knn_distances.set_entry(i, j, d.value);\n });\n }\n // scale parameter\n const sig = new Float64Array(N);\n for (let i = 0; i < N; ++i) {\n sig[i] = Math.max((knn_distances.entry(i, 3) + knn_distances.entry(i, 4) + knn_distances.entry(i, 5) + knn_distances.entry(i, 6)) / 4, 1e-10);\n }\n\n const P = this._find_p(knn_distances, sig, nbrs);\n\n let triplets = this._sample_knn_triplets(P, nbrs, n_inliers, n_outliers);\n let n_triplets = triplets.shape[0];\n const outlier_distances = new Float64Array(n_triplets);\n for (let i = 0; i < n_triplets; ++i) {\n const j = triplets.entry(i, 0);\n const k = triplets.entry(i, 2);\n outlier_distances[i] = metric(X.row(j), X.row(k));\n }\n let weights = this._find_weights(triplets, P, nbrs, outlier_distances, sig);\n\n if (n_random > 0) {\n const { random_triplets, random_weights } = this._sample_random_triplets(X, n_random, sig);\n triplets = triplets.concat(random_triplets, \"vertical\");\n weights = Float64Array.from([...weights, ...random_weights]);\n }\n n_triplets = triplets.shape[0];\n let max_weight = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n if (isNaN(weights[i])) {\n weights[i] = 0;\n }\n if (max_weight < weights[i]) max_weight = weights[i];\n }\n let max_weight_2 = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight;\n weights[i] += 0.0001;\n weights[i] = Math.log(1 + weight_adj * weights[i]);\n if (max_weight_2 < weights[i]) max_weight_2 = weights[i];\n }\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight_2;\n }\n return {\n triplets: triplets,\n weights: weights,\n };\n }\n\n /**\n * Calculates the similarity matrix P\n * @private\n * @param {Matrix} knn_distances - matrix of pairwise knn distances\n * @param {Float64Array} sig - scaling factor for the distances\n * @param {Matrix} nbrs - nearest neighbors\n * @returns {Matrix} pairwise similarity matrix\n */\n _find_p(knn_distances, sig, nbrs) {\n const [N, n_neighbors] = knn_distances.shape;\n return new Matrix(N, n_neighbors, (i, j) => {\n return Math.exp(-(knn_distances.entry(i, j) ** 2 / sig[i] / sig[nbrs.entry(i, j)]));\n });\n }\n\n /**\n * Sample nearest neighbors triplets based on the similarity values given in P.\n * @private\n * @param {Matrix} P - Matrix of pairwise similarities between each point and its neighbors given in matrix nbrs.\n * @param {Matrix} nbrs - Nearest neighbors indices for each point. The similarity values are given in matrix {@link P}. Row i corresponds to the i-th point.\n * @param {Number} n_inliers - Number of inlier points.\n * @param {Number} n_outliers - Number of outlier points.\n *\n */\n _sample_knn_triplets(P, nbrs, n_inliers, n_outliers) {\n const N = nbrs.shape[0];\n const triplets = new Matrix(N * n_inliers * n_outliers, 3);\n for (let i = 0; i < N; ++i) {\n let n_i = i * n_inliers * n_outliers;\n const sort_indices = this.__argsort(P.row(i).map((d) => -d));\n for (let j = 0; j < n_inliers; ++j) {\n let n_j = j * n_outliers;\n const sim = nbrs.entry(i, sort_indices[j]);\n const samples = this._rejection_sample(n_outliers, N, sort_indices.slice(0, j + 1));\n for (let k = 0; k < n_outliers; ++k) {\n const index = n_i + n_j + k;\n const out = samples[k];\n triplets.set_entry(index, 0, i);\n triplets.set_entry(index, 1, sim);\n triplets.set_entry(index, 2, out);\n }\n }\n }\n return triplets;\n }\n\n /**\n * Should do the same as np.argsort()\n * @private\n * @param {Array} A\n */\n __argsort(A) {\n return A.map((d, i) => {\n return { d: d, i: i };\n })\n .sort((a, b) => a.d - b.d)\n .map((d) => d.i);\n }\n\n /**\n * Samples {@link n_samples} integers from a given interval [0, {@link max_int}] while rejection the values that are in the {@link rejects}.\n * @private\n * @param {*} n_samples\n * @param {*} max_int\n * @param {*} rejects\n */\n _rejection_sample(n_samples, max_int, rejects) {\n const randomizer = this._randomizer;\n const interval = linspace(0, max_int - 1).filter((d) => rejects.indexOf(d) < 0);\n return randomizer.choice(interval, Math.min(n_samples, interval.length - 2));\n }\n\n /**\n * Calculates the weights for the sampled nearest neighbors triplets\n * @private\n * @param {Matrix} triplets - Sampled Triplets.\n * @param {Matrix} P - Pairwise similarity matrix.\n * @param {Matrix} nbrs - nearest Neighbors\n * @param {Float64Array} outlier_distances - Matrix of pairwise outlier distances\n * @param {Float64Array} sig - scaling factor for the distances.\n */\n _find_weights(triplets, P, nbrs, outlier_distances, sig) {\n const n_triplets = triplets.shape[0];\n const weights = new Float64Array(n_triplets);\n for (let t = 0; t < n_triplets; ++t) {\n const i = triplets.entry(t, 0);\n const sim = nbrs.row(i).indexOf(triplets.entry(t, 1));\n const p_sim = P.entry(i, sim);\n let p_out = Math.exp(-(outlier_distances[t] ** 2 / (sig[i] * sig[triplets.entry(t, 2)])));\n if (p_out < 1e-20) p_out = 1e-20;\n weights[t] = p_sim / p_out;\n }\n return weights;\n }\n\n /**\n * Sample uniformly ranom triplets\n * @private\n * @param {Matrix} X - Data matrix.\n * @param {Number} n_random - Number of random triplets per point\n * @param {Float64Array} sig - Scaling factor for the distances\n */\n _sample_random_triplets(X, n_random, sig) {\n const metric = this.parameter(\"metric\");\n const randomizer = this._randomizer;\n const N = X.shape[0];\n const random_triplets = new Matrix(N * n_random, 3);\n const random_weights = new Float64Array(N * n_random);\n for (let i = 0; i < N; ++i) {\n const n_i = i * n_random;\n const indices = [...linspace(0, i - 1), ...linspace(i + 1, N - 1)];\n for (let j = 0; j < n_random; ++j) {\n let [sim, out] = randomizer.choice(indices, 2);\n let p_sim = Math.exp(-(metric(X.row(i), X.row(sim)) ** 2 / (sig[i] * sig[sim])));\n if (p_sim < 1e-20) p_sim = 1e-20;\n let p_out = Math.exp(-(metric(X.row(i), X.row(out)) ** 2 / (sig[i] * sig[out])));\n if (p_out < 1e-20) p_out = 1e-20;\n\n if (p_sim < p_out) {\n [sim, out] = [out, sim];\n [p_sim, p_out] = [p_out, p_sim];\n }\n const index = n_i + j;\n random_triplets.set_entry(index, 0, i);\n random_triplets.set_entry(index, 1, sim);\n random_triplets.set_entry(index, 2, out);\n random_weights[index] = p_sim / p_out;\n }\n }\n return {\n random_triplets: random_triplets,\n random_weights: random_weights,\n };\n }\n\n /**\n * Computes the gradient for updating the embedding.\n * @param {Matrix} Y - The embedding\n */\n _grad(Y) {\n const n_inliers = this.n_inliers;\n const n_outliers = this.n_outliers;\n const triplets = this.triplets;\n const weights = this.weights;\n const [N, dim] = Y.shape;\n const n_triplets = triplets.shape[0];\n const grad = new Matrix(N, dim, 0);\n let y_ij = new Float64Array(dim);\n let y_ik = new Float64Array(dim);\n let d_ij = 1;\n let d_ik = 1;\n let n_viol = 0;\n let loss = 0;\n const n_knn_triplets = N * n_inliers * n_outliers;\n\n for (let t = 0; t < n_triplets; ++t) {\n const [i, j, k] = triplets.row(t);\n // update y_ij, y_ik, d_ij, d_ik\n if (t % n_outliers == 0 || t >= n_knn_triplets) {\n d_ij = 1;\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_jd = Y.entry(j, d);\n const Y_kd = Y.entry(k, d);\n y_ij[d] = Y_id - Y_jd;\n y_ik[d] = Y_id - Y_kd;\n d_ij += y_ij[d] ** 2;\n d_ik += y_ik[d] ** 2;\n }\n // update y_ik and d_ik only\n } else {\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_kd = Y.entry(k, d);\n y_ik[d] = Y_id - Y_kd;\n d_ik += y_ik[d] ** 2;\n }\n }\n\n if (d_ij > d_ik) ++n_viol;\n loss += weights[t] / (1 + d_ik / d_ij);\n const w = (weights[t] / (d_ij + d_ik)) ** 2;\n for (let d = 0; d < dim; ++d) {\n const gs = y_ij[d] * d_ik * w;\n const go = y_ik[d] * d_ij * w;\n grad.set_entry(i, d, grad.entry(i, d) + gs - go);\n grad.set_entry(j, d, grad.entry(j, d) - gs);\n grad.set_entry(k, d, grad.entry(k, d) + go);\n }\n }\n return { grad, loss, n_viol };\n }\n\n /**\n *\n * @param {Number} max_iteration\n */\n transform(max_iteration = 400) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n }\n return this.projection;\n }\n\n /**\n * @param {Number} max_iteration\n * @yields {Matrix}\n * @returns {Matrix}\n */\n *generator(max_iteration = 800) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * Does the iteration step.\n * @private\n * @param {Number} iter\n */\n _next(iter) {\n const gamma = iter > 150 ? 0.5 : 0.3;\n const old_C = this.C;\n const vel = this.vel;\n const Y = this.Y.add(vel.mult(gamma));\n const { grad, loss, n_viol } = this._grad(Y);\n this.C = loss;\n this.Y = this._update_embedding(Y, iter, grad);\n this.lr *= old_C > loss + this._parameters.tol ? 1.01 : 0.9;\n return this.Y;\n }\n\n /**\n * Updates the embedding.\n * @private\n * @param {Matrix} Y\n * @param {Number} iter\n * @param {Matrix} grad\n */\n _update_embedding(Y, iter, grad) {\n const [N, dim] = Y.shape;\n const gamma = iter > 150 ? 0.9 : 0.5; // moment parameter\n const min_gain = 0.01;\n const gain = this.gain;\n const vel = this.vel;\n const lr = this.lr;\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const new_gain = Math.sign(vel.entry(i, d)) != Math.sign(grad.entry(i, d)) ? gain.entry(i, d) + 0.2 : Math.max(gain.entry(i, d) * 0.8, min_gain);\n gain.set_entry(i, d, new_gain);\n vel.set_entry(i, d, gamma * vel.entry(i, d) - lr * gain.entry(i, d) * grad.entry(i, d));\n Y.set_entry(i, d, Y.entry(i, d) + vel.entry(i, d));\n }\n }\n return Y;\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n/**\n * @class\n * @alias Hierarchical_Clustering\n */\nexport class Hierarchical_Clustering {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias Hierarchical_Clustering\n * @todo needs restructuring.\n * @param {Matrix} - Data or distance matrix if metric is 'precomputed'\n * @param {(\"single\"|\"complete\"|\"average\")} [linkage = \"complete\"]\n * @param {Function|\"precomputed\"} [metric = euclidean]\n * @returns {Hierarchical_Clustering}\n */\n constructor(matrix, linkage = \"complete\", metric = euclidean) {\n this._id = 0;\n this._matrix = matrix instanceof Matrix ? matrix : Matrix.from(matrix);\n this._metric = metric;\n this._linkage = linkage;\n if (metric === \"precomputed\" && this._matrix.shape[0] !== this._matrix.shape[1]) {\n throw new Error(\"If metric is 'precomputed', then matrix has to be square!\");\n }\n this.init();\n this.root = this.do();\n return this;\n }\n\n /**\n *\n * @param {Number} value - value where to cut the tree.\n * @param {(\"distance\"|\"depth\")} [type = \"distance\"] - type of value.\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters(value, type = \"distance\") {\n let clusters = [];\n let accessor;\n switch (type) {\n case \"distance\":\n accessor = (d) => d.dist;\n break;\n case \"depth\":\n accessor = (d) => d.depth;\n break;\n default:\n throw new Error(\"invalid type\");\n }\n this._traverse(this.root, accessor, value, clusters);\n return clusters;\n }\n\n /**\n * @private\n * @param {} node\n * @param {*} f\n * @param {*} value\n * @param {*} result\n */\n _traverse(node, f, value, result) {\n if (f(node) <= value) {\n result.push(node.leaves());\n } else {\n this._traverse(node.left, f, value, result);\n this._traverse(node.right, f, value, result);\n }\n }\n\n /**\n * computes the tree.\n */\n init() {\n const metric = this._metric;\n const A = this._matrix;\n const n = (this._n = A.shape[0]);\n const d_min = (this._d_min = new Float64Array(n));\n let distance_matrix;\n if (metric !== \"precomputed\") {\n distance_matrix = new Matrix(n, n, 0); //new Array(n);\n for (let i = 0; i < n; ++i) {\n d_min[i] = 0;\n //distance_matrix[i] = new Float64Array(n);\n for (let j = 0; j < n; ++j) {\n distance_matrix.set_entry(i, j, i === j ? Infinity : metric(A.row(i), A.row(j)));\n if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n } else {\n distance_matrix = this._matrix.clone();\n for (let i = 0; i < n; ++i) {\n for (let j = 0; j < n; ++j) {\n if (i === j) {\n distance_matrix.set_entry(i, j, Infinity);\n } else if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n }\n this._distance_matrix = distance_matrix;\n const clusters = (this._clusters = new Array(n));\n const c_size = (this._c_size = new Uint16Array(n));\n for (let i = 0; i < n; ++i) {\n clusters[i] = [];\n clusters[i][0] = new Cluster(this._id++, null, null, 0, A.row(i), i, 1, 0);\n c_size[i] = 1;\n }\n return this;\n }\n\n /**\n * computes the tree.\n */\n do() {\n const n = this._n;\n const d_min = this._d_min;\n const D = this._distance_matrix;\n const clusters = this._clusters;\n const c_size = this._c_size;\n const linkage = this._linkage;\n let root = null;\n for (let p = 0, p_max = n - 1; p < p_max; ++p) {\n let c1 = 0;\n for (let i = 0; i < n; ++i) {\n let D_i_min = D.entry(i, d_min[i]);\n for (let j = i + 1; j < n; ++j) {\n if (D_i_min > D.entry(i, j)) {\n d_min[i] = j;\n D_i_min = D.entry(i, d_min[i]);\n }\n }\n }\n for (let i = 0; i < n; ++i) {\n if (D.entry(i, d_min[i]) < D.entry(c1, d_min[c1])) {\n c1 = i;\n }\n }\n let c2 = d_min[c1];\n let c1_cluster = clusters[c1][0];\n let c2_cluster = clusters[c2][0];\n let c1_cluster_indices = c1_cluster.isLeaf ? [c1_cluster.index] : c1_cluster.index;\n let c2_cluster_indices = c2_cluster.isLeaf ? [c2_cluster.index] : c2_cluster.index;\n let indices = c1_cluster_indices.concat(c2_cluster_indices);\n let new_cluster = new Cluster(this._id++, c1_cluster, c2_cluster, D.entry(c1, c2), null, indices);\n c1_cluster.parent = new_cluster;\n c2_cluster.parent = new_cluster;\n clusters[c1].unshift(new_cluster);\n c_size[c1] += c_size[c2];\n for (let j = 0; j < n; ++j) {\n const D_c1_j = D.entry(c1, j);\n const D_c2_j = D.entry(c2, j);\n let value;\n switch (linkage) {\n case \"single\":\n value = Math.min(D_c1_j, D_c2_j);\n break;\n case \"complete\":\n value = Math.max(D_c1_j, D_c2_j);\n break;\n case \"average\":\n value = (c_size[c1] * D_c1_j + c_size[c2] * D_c2_j) / (c_size[c1] + c_size[j]);\n break;\n }\n D.set_entry(j, c1, value);\n D.set_entry(c1, j, value);\n }\n\n D.set_entry(c1, c1, Infinity);\n for (let i = 0; i < n; ++i) {\n D.set_entry(i, c2, Infinity);\n D.set_entry(c2, i, Infinity);\n }\n\n /* for (let j = 0; j < n; ++j) {\n if (d_min[j] === c2) {\n d_min[j] = c1;\n }\n if (D.entry(c1, j) < D.entry(c1, d_min[c1])) {\n d_min[c1] = j;\n }\n } */\n root = new_cluster;\n }\n return root;\n }\n}\n\nclass Cluster {\n constructor(id, left, right, dist, centroid, index, size, depth) {\n this.id = id;\n this.left = left;\n this.right = right;\n this.dist = dist;\n this.index = index;\n this.size = size ?? left.size + right.size;\n this.depth = depth ?? 1 + Math.max(left.depth, right.depth);\n this.centroid = centroid ?? this._calculate_centroid(left, right);\n this.parent = null;\n return this;\n }\n\n _calculate_centroid(left, right) {\n const l_size = left.size;\n const r_size = right.size;\n const l_centroid = left.centroid;\n const r_centroid = right.centroid;\n const size = this.size;\n const n = left.centroid.length;\n const new_centroid = new Float64Array(n);\n for (let i = 0; i < n; ++i) {\n new_centroid[i] = (l_size * l_centroid[i] + r_size * r_centroid[i]) / size;\n }\n return new_centroid;\n }\n\n get isLeaf() {\n return this.depth === 0;\n }\n\n leaves() {\n if (this.isLeaf) return [this];\n const left = this.left;\n const right = this.right;\n return (left.isLeaf ? [left] : left.leaves()).concat(right.isLeaf ? [right] : right.leaves());\n }\n\n descendants() {\n if (this.isLeaf) return [this];\n const left_descendants = this.left.descendants();\n const right_descendants = this.right.descendants();\n return left_descendants.concat(right_descendants).concat([this]);\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { linspace } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KMeans\n */\nexport class KMeans {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMeans\n * @todo needs restructuring. \n * @param {Matrix} matrix \n * @param {Numbers} K \n * @param {Function} [metric = euclidean] \n * @param {Number} [seed = 1987]\n * @param {Boolean} [init = true]\n * @returns {KMeans}\n */\n constructor(matrix, K, metric = euclidean, seed=1987, init = true) {\n this._metric = metric;\n this._matrix = matrix;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_centroids = this._get_random_centroids(K);\n if (init) this.init(K, this._cluster_centroids);\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const clusters = this._clusters;\n const result = new Array(K).fill().map(() => new Array());\n clusters.forEach((c, i) => result[c].push(i));\n return result;\n }\n\n /**\n * @private\n * @param {Array} points \n * @param {Array} candidates \n */\n _furthest_point(points, candidates) {\n const A = this._matrix;\n const metric = this._metric;\n let i = points.length;\n let H = Heap.heapify(\n candidates, \n (d) => {\n const Ad = A.row(d)\n let sum = 0;\n for (let j = 0; j < i; ++j) {\n sum += metric(Ad, points[j])\n }\n return sum;\n }, \n \"max\"\n )\n return H.pop().element;\n }\n\n _get_random_centroids(K) {\n const N = this._N;\n const randomizer = this._randomizer;\n const A = this._matrix;\n const cluster_centroids = new Array(K).fill()\n const indices = linspace(0, N - 1);\n const random_point = randomizer.random_int % (N - 1);\n cluster_centroids[0] = A.row(random_point);\n const init_points = [random_point];\n const sample_size = Math.floor((N - K) / K);// / K\n for (let i = 1; i < K; ++i) {\n // sampling + kmeans++ improvement?\n const sample = randomizer.choice(indices.filter(d => init_points.indexOf(d) == -1), sample_size);\n const furthest_point = this._furthest_point(cluster_centroids.slice(0, i), sample);\n init_points.push(furthest_point);\n cluster_centroids[i] = A.row(furthest_point);\n }\n return cluster_centroids;\n }\n\n _iteration(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const metric = this._metric;\n const clusters = this._clusters;\n let clusters_changed = false;\n // find nearest cluster centroid.\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i)\n let min_dist = Infinity;\n let min_cluster = null;\n for (let j = 0; j < K; ++j) {\n let d = metric(cluster_centroids[j], Ai);\n if (d < min_dist) {\n min_dist = d;\n min_cluster = j; \n }\n }\n if (clusters[i] !== min_cluster) {\n clusters_changed = true;\n }\n clusters[i] = min_cluster;\n }\n // update cluster centroid\n // reset cluster centroids to 0\n for (let i = 0; i < K; ++i) {\n const centroid = cluster_centroids[i];\n for (let j = 0; j < D; ++j) {\n centroid[j] = 0;\n }\n }\n // compute centroid\n this._compute_centroid(cluster_centroids);\n\n return { \n \"clusters_changed\": clusters_changed,\n \"cluster_centroids\": cluster_centroids\n };\n }\n\n _compute_centroid(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const clusters = this._clusters;\n const cluster_counter = new Array(K).fill(0);\n\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i);\n const ci = clusters[i];\n cluster_counter[ci]++;\n const centroid = cluster_centroids[ci];\n for (let j = 0; j < D; ++j) {\n centroid[j] += Ai[j];\n }\n }\n for (let i = 0; i < K; ++i) {\n const n = cluster_counter[i];\n cluster_centroids[i] = cluster_centroids[i].map(c => c / n);\n }\n \n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_centroids) {\n if (!K) K = this._K;\n if (!cluster_centroids) cluster_centroids = this._get_random_centroids(K);\n let clusters_changed = false;\n do {\n const iteration_result = this._iteration(cluster_centroids)\n cluster_centroids = iteration_result.cluster_centroids;\n clusters_changed = iteration_result.clusters_changed;\n } while (clusters_changed)\n }\n \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { linspace, Matrix } from \"../matrix/index.js\";\nimport { min } from \"../util/index.js\";\n/**\n * @class\n * @alias KMedoids\n */\nexport class KMedoids {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMedoids\n * @todo needs restructuring. \n * @param {Matrix} matrix - data matrix\n * @param {Numbers} K - number of clusters\n * @param {number} [max_iter=null] - maximum number of iterations. Default is 10 * Math.log10(N)\n * @param {Function} [metric = euclidean] - metric defining the dissimilarity \n * @param {Number} [seed = 1212] - seed value for random number generator\n * @returns {KMedoids}\n * @see {@link https://link.springer.com/chapter/10.1007/978-3-030-32047-8_16} Faster k-Medoids Clustering: Improving the PAM, CLARA, and CLARANS Algorithms\n */\n constructor(matrix, K, max_iter=null, metric = euclidean, seed=1212) {\n this._metric = metric;\n this._matrix = matrix;\n this._A = this._matrix.to2dArray;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n this._max_iter = max_iter || 10 * Math.log10(N) \n this._distance_matrix = new Matrix(N, N, \"zeros\");\n /* for (let i = 1; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dist = metric(this._A[i], this._A[j]);\n this._distance_matrix.set_entry(i, j, dist);\n this._distance_matrix.set_entry(j, i, dist)\n }\n } */\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_medoids = this._get_random_medoids(K);\n //if (init) this.init(K, this._cluster_medoids);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const A = this._A;\n if (!this._is_initialized) {\n this.init(K, this._cluster_medoids);\n }\n const result = new Array(K).fill().map(() => new Array());\n A.forEach((x_j, j) => {\n result[this._nearest_medoid(x_j, j).index_nearest].push(j);\n })\n result.medoids = this._cluster_medoids;\n return result;\n }\n\n async* generator() {\n const max_iter = this._max_iter;\n yield this.get_clusters()\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n yield this.get_clusters();\n } while (!finish && ++i < max_iter)\n }\n\n /**\n * Algorithm 1. FastPAM1: Improved SWAP algorithm\n */\n /* _iteration_1() {\n const A = this._A;\n const N = this._N;\n const K = this._K;\n const medoids = this._cluster_medoids;\n let DeltaTD = 0;\n let m0 = null;\n let x0 = null;\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const nearest_medoid = this._nearest_medoid(x_j, j);\n const d_j = nearest_medoid.distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n // disance to new medoid\n const d_oj = this._get_distance(o, j, x_o, x_j);\n const {\n \"index_nearest\": n,\n \"distance_nearest\": d_n,\n \"distance_second\": d_s,\n } = this._nearest_medoid(x_o, o); \n this._clusters[o] = n; // cached values\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change\n if (d_oj < d_n) { // reassignment check\n deltaTD.forEach((d_i, i) => {\n if (n !== i) {\n deltaTD[i] = d_i + d_oj - d_n; // update loss change\n }\n });\n }\n });\n // choose best medoid i;\n const i = deltaTD\n .map((d, i) => [d, i])\n .sort((d1, d2) => d1[0] - d2[0])[0][1];\n const deltaTD_i = deltaTD[i];\n // store\n if (deltaTD_i < DeltaTD) {\n DeltaTD = deltaTD_i;\n m0 = i;\n x0 = j;\n }\n }\n });\n\n if (DeltaTD >= 0) {\n return true // break loop if DeltaTD >= 0\n }\n // swap roles of medoid m and non-medoid x;\n medoids[m0] = x0;\n this._cluster_medoids = medoids;\n return false\n } */\n\n /** Algorithm 2. FastPAM2: SWAP with multiple candidates\n * \n */\n _iteration() {\n const A = this._A;\n const K = this._K;\n const medoids = this._cluster_medoids;\n const cache = A.map((x_o, o) => this._nearest_medoid(x_o, o));\n // empty best candidates array\n const DeltaTD = new Array(K).fill(0);\n const xs = new Array(K).fill(null);\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const d_j = cache[j].distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n if (j === o) return;\n const d_oj = this._get_distance(o, j, x_o, x_j); // distance to new medoid\n const {\"index_nearest\": n, \"distance_nearest\": d_n, \"distance_second\": d_s} = cache[o]; // cached\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change for x_o\n // Reassignment check\n if (d_oj < d_n) { \n // update loss change\n for (let i = 0; i < K; ++i) {\n if (i !== n) deltaTD[i] += d_oj - d_n;\n }\n }\n });\n // remember best swap for i;\n deltaTD\n .map((d, i) => [d, i])\n .filter(([d, i]) => d < DeltaTD[i])\n .forEach(([d, i]) => {\n if (d < DeltaTD[i]) {\n DeltaTD[i] = d;\n xs[i] = j;\n }\n })\n }\n })\n // stop if no improvements were found\n if (min(DeltaTD) >= 0) return true; \n\n // execute all improvements\n while (min(DeltaTD) < 0) {\n // swap roles of medoid m_i and non_medoid xs_i\n const i = DeltaTD\n .map((d, i) => [d, i])\n .sort(([a], [b]) => a - b)[0][1];\n if (medoids.filter(m => m == xs[i]).length == 0) {\n medoids[i] = xs[i];\n }\n // disable the swap just performed\n DeltaTD[i] = 0; \n // recompute TD for remaining swap candidates\n DeltaTD\n .map((d_j, j) => [d_j, j])\n .filter(([d_j]) => d_j < 0)\n .forEach(([_, j]) => {\n const x_j = A[j];\n let sum = 0;\n A.forEach((x_o, o) => {\n if (medoids.findIndex(m => m != j && m == o) >= 0) return;\n if (i == j) return;\n if (cache[o].index_nearest === medoids[j])\n sum += (Math.min(this._get_distance(o, j, x_o, x_j), cache[o].distance_second) - cache[o].distance_nearest); \n else {\n sum += (Math.min(this._get_distance(o, j, x_o, x_j) - cache[o].distance_nearest, 0));\n }\n });\n DeltaTD[j] = sum;\n })\n }\n this._cluster_medoids = medoids;\n return false;\n }\n\n _get_distance(i, j, x_i=null, x_j=null) {\n if (i === j) return 0;\n const D = this._distance_matrix;\n const A = this._A;\n const metric = this._metric;\n let d_ij = D.entry(i, j);\n if (d_ij === 0) {\n d_ij = metric(x_i || A[i], x_j || A[j]);\n D.set_entry(i, j, d_ij);\n D.set_entry(j, i, d_ij);\n }\n return d_ij;\n }\n\n _nearest_medoid(x_j, j) {\n const medoids = this._cluster_medoids;\n const A = this._A;\n const [nearest, second] = medoids\n .map((m, i) => {\n const x_m = A[m]; \n return [this._get_distance(j, m, x_j, x_m), i];\n })\n .sort((m1, m2) => m1[0] - m2[0]);\n \n return { \n \"distance_nearest\": nearest[0], \n \"index_nearest\": nearest[1],\n \"distance_second\": second[0],\n \"index_second\": second[1],\n };\n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_medoids) {\n if (!K) K = this._K;\n if (!cluster_medoids) cluster_medoids = this._get_random_medoids(K);\n const max_iter = this._max_iter;\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n } while (!finish && ++i < max_iter)\n return this;\n }\n\n /**\n * Algorithm 3. FastPAM LAB: Linear Approximate BUILD initialization.\n * @param {number} K - number of clusters\n * \n */\n _get_random_medoids(K) {\n const N = this._N;\n const A = this._A;\n const indices = linspace(0, N - 1);\n const randomizer = this._randomizer;\n const n = Math.min(N, 10 + Math.ceil(Math.sqrt(N)));\n const TD = new Array(n).fill(Infinity);\n const medoids = [];\n // first medoid\n let TD0 = Infinity;\n let S = randomizer.choice(indices, n);\n for (let j = 0; j < n; ++j) {\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const x_o = A[S[o]];\n TD[j] += this._get_distance(j, o, x_j, x_o);\n }\n if (TD[j] < TD0) {\n TD0 = TD[j]; // smallest distance sum\n medoids.push(S_j);\n }\n }\n // other medoids\n for (let i = 1; i < K; ++i) {\n let DeltaTD = Infinity;\n S = randomizer.choice(indices.filter(index => medoids.findIndex(d => d === index) < 0), n);\n for (let j = 0; j < n; ++j) {\n let deltaTD = 0;\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const S_o = S[o];\n const x_o = A[S_o];\n let delta = this._get_distance(S_j, S_o, x_j, x_o) - min(medoids.map(m => this._get_distance(S_o, m, x_o)));\n if (delta < 0) {\n deltaTD = deltaTD + delta;\n }\n }\n // best reduction\n if (deltaTD < DeltaTD) {\n DeltaTD = deltaTD;\n medoids.push(S_j);\n }\n }\n TD0 += DeltaTD;\n }\n return medoids.slice(0, K);\n }\n \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias OPTICS\n */\nexport class OPTICS {\n /**\n * **O**rdering **P**oints **T**o **I**dentify the **C**lustering **S**tructure.\n * @constructor\n * @memberof module:clustering\n * @alias OPTICS\n * @todo needs restructuring. \n * @param {Matrix} matrix - the data.\n * @param {Number} epsilon - the minimum distance which defines whether a point is a neighbor or not.\n * @param {Number} min_points - the minimum number of points which a point needs to create a cluster. (Should be higher than 1, else each point creates a cluster.)\n * @param {Function} [metric = euclidean] - the distance metric which defines the distance between two points of the {@link matrix}.\n * @returns {OPTICS}\n * @see {@link https://www.dbs.ifi.lmu.de/Publikationen/Papers/OPTICS.pdf}\n * @see {@link https://en.wikipedia.org/wiki/OPTICS_algorithm}\n */\n constructor(matrix, epsilon, min_points, metric = euclidean) {\n this._matrix = matrix;\n this._epsilon = epsilon;\n this._min_points = min_points;\n this._metric = metric;\n\n this._ordered_list = [];\n this._clusters = [];\n this._DB = new Array(matrix.shape[0]).fill();\n this.init();\n return this;\n }\n\n /**\n * Computes the clustering.\n */\n init() {\n const ordered_list = this._ordered_list;\n const matrix = this._matrix;\n const N = matrix.shape[0];\n const DB = this._DB;\n const clusters = this._clusters;\n let cluster_index = this._cluster_index = 0;\n\n for (let i = 0; i < N; ++i) {\n DB[i] = {\n \"element\": matrix.row(i),\n \"index\": i,\n \"reachability_distance\": undefined,\n \"processed\": false,\n }\n }\n for (const p of DB) {\n if (p.processed) continue;\n p.neighbors = this._get_neighbors(p);\n p.processed = true;\n clusters.push([p.index])\n cluster_index = clusters.length - 1;\n ordered_list.push(p);\n if (this._core_distance(p) != undefined) {\n const seeds = new Heap(null, d => d.reachability_distance, \"min\")\n this._update(p, seeds);\n this._expand_cluster(seeds, clusters[cluster_index]);\n }\n }\n return this;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Array} An array consisting of the {@link epsilon}-neighborhood of {@link p}.\n */\n _get_neighbors(p) {\n if (\"neighbors\" in p) return p.neighbors;\n const DB = this._DB;\n const metric = this._metric;\n const epsilon = this._epsilon;\n const neighbors = [];\n for (const q of DB) {\n if (q.index == p.index) continue;\n if (metric(p.element, q.element) < epsilon) {\n neighbors.push(q);\n }\n }\n return neighbors;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Number} The distance to the {@link min_points}-th nearest point of {@link p}, or undefined if the {@link epsilon}-neighborhood has fewer elements than {@link min_points}.\n */\n _core_distance(p) {\n const min_points = this._min_points;\n const metric = this._metric;\n if (p.neighbors && p.neighbors.length <= min_points) {\n return undefined;\n }\n return metric(p.element, p.neighbors[min_points].element);\n }\n\n /**\n * Updates the reachability distance of the points.\n * @private\n * @param {Object} p \n * @param {Heap} seeds \n */\n _update(p, seeds) {\n const metric = this._metric;\n const core_distance = this._core_distance(p);\n const neighbors = this._get_neighbors(p);//p.neighbors;\n for (const q of neighbors) {\n if (q.processed) continue;\n const new_reachability_distance = Math.max(core_distance, metric(p.element, q.element));\n //if (q.reachability_distance == undefined) { // q is not in seeds\n if (seeds.raw_data().findIndex(d => d.element == q) < 0) {\n q.reachability_distance = new_reachability_distance;\n seeds.push(q);\n } else { // q is in seeds\n if (new_reachability_distance < q.reachability_distance) {\n q.reachability_distance = new_reachability_distance;\n seeds = Heap.heapify(seeds.data(), d => d.reachability_distance, \"min\"); // seeds change key =/\n }\n }\n }\n }\n\n /**\n * Expands the {@link cluster} with points in {@link seeds}.\n * @private\n * @param {Heap} seeds \n * @param {Array} cluster \n */\n _expand_cluster(seeds, cluster) {\n const ordered_list = this._ordered_list;\n while (!seeds.empty) {\n const q = seeds.pop().element;\n q.neighbors = this._get_neighbors(q);\n q.processed = true;\n cluster.push(q.index);\n ordered_list.push(q);\n if (this._core_distance(q) != undefined) {\n this._update(q, seeds);\n this._expand_cluster(seeds, cluster);\n }\n }\n }\n\n /**\n * Returns an array of clusters.\n * @returns {Array} Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters() {\n const clusters = [];\n const outliers = [];\n const min_points = this._min_points;\n for (const cluster of this._clusters) {\n if (cluster.length < min_points) {\n outliers.push(...cluster);\n } else {\n clusters.push(cluster);\n }\n }\n clusters.push(outliers);\n return clusters;\n }\n\n /**\n * @returns {Array} Returns an array, where the ith entry defines the cluster affirmation of the ith point of {@link matrix}. (-1 stands for outlier)\n */\n get_cluster_affirmation() {\n const N = this._matrix.shape[0];\n const result = new Array(N).fill();\n const clusters = this.get_clusters();\n for (let i = 0, n = clusters.length; i < n; ++i) {\n const cluster = clusters[i]\n for (const index of cluster) {\n result[index] = (i < n - 1) ? i : -1;\n }\n }\n return result;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\nimport { MDS } from \"./MDS.js\";\nimport { KMedoids } from \"../clustering/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\n/**\n * @class\n * @alias LSP\n * @extends DR\n */\nexport class LSP extends DR {\n /**\n * Least Squares Projection.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LSP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.neighbors = Math.max(Math.floor(N / 10), 2)] - number of neighbors to consider.\n * @param {Number} [parameters.control_points = Math.ceil(Math.sqrt(N))] - number of controlpoints\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {LSP}\n * @see {@link https://ieeexplore.ieee.org/document/4378370}\n * @todo accept precomputed distance matrix.\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, control_points: undefined, d: 2, metric: euclidean, seed: 1212 }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n this.parameter(\"control_points\", Math.min(parameters.control_points ?? Math.ceil(Math.sqrt(this._N)), this._N - 1));\n this._is_initialized = false;\n return this;\n }\n\n /**\n *\n * @param {DR} DR - method used for position control points.\n * @param {Object} DR_parameters - Object containing parameters for the DR method which projects the control points\n * @returns {LSP}\n */\n init(DR = MDS, DR_parameters = {}, KNN = BallTree) {\n if (this._is_initialized) return this;\n const X = this.X;\n const N = this._N;\n const K = this.parameter(\"neighbors\");\n const d = this.parameter(\"d\");\n const seed = this.parameter(\"seed\");\n const metric = this.parameter(\"metric\");\n DR_parameters = Object.assign({d, metric, seed }, DR_parameters);\n const nc = this.parameter(\"control_points\");\n const control_points = new KMedoids(X, nc, null, metric).get_clusters().medoids;\n const C = new Matrix(nc, N, \"zeros\");\n control_points.forEach((c_i, i) => {\n C.set_entry(i, c_i, 1);\n });\n const Y_C = new DR(Matrix.from(control_points.map((c_i) => X.row(c_i))), DR_parameters).transform();\n\n const XA = X.to2dArray;\n const knn = new KNN(XA, metric);\n const L = new Matrix(N, N, \"I\");\n const alpha = -1 / K;\n XA.forEach((x_i, i) => {\n for (const { index: j } of knn.search(x_i, K).iterate()) {\n if (i === j) continue;\n L.set_entry(i, j, alpha);\n }\n });\n const A = L.concat(C, \"vertical\");\n\n const z = new Matrix(N, d, \"zeros\");\n const b = z.concat(Y_C, \"vertical\");\n\n this._A = A;\n this._b = b;\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const A = this._A;\n const AT = A.T;\n const b = this._b;\n const ATA = AT.dot(A);\n const ATb = AT.dot(b);\n this.Y = Matrix.solve_CG(ATA, ATb, this._randomizer);\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { DisjointSet } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias TopoMap\n * @memberof module:dimensionality_reduction\n * @extends DR\n */\nexport class TopoMap extends DR {\n /**\n * TopoMap: A 0-dimensional Homology Preserving Projection of High-Dimensional Data.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TopoMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TopoMap}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._distance_matrix = new Matrix(this._N, this._N, 0);\n return this;\n }\n\n /**\n * @private\n */\n __lazy_distance_matrix(i, j, metric) {\n const D = this._distance_matrix;\n const X = this.X;\n const D_ij = D.entry(i, j);\n if (D_ij === 0) {\n let dist = metric(X.row(i), X.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n return dist;\n }\n return D_ij;\n }\n\n /**\n * Computes the minimum spanning tree, using a given metric\n * @private\n * @param {Function} metric\n * @see {@link https://en.wikipedia.org/wiki/Kruskal%27s_algorithm}\n */\n _make_minimum_spanning_tree(metric = euclidean) {\n const N = this._N;\n const X = [...this.X];\n\n let disjoint_set = new DisjointSet(X);\n const F = [];\n let E = [];\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n E.push([i, j, this.__lazy_distance_matrix(i, j, metric)]);\n }\n }\n E = E.sort((a, b) => a[2] - b[2]);\n\n for (const [u, v, w] of E) {\n const set_u = disjoint_set.find(X[u]);\n const set_v = disjoint_set.find(X[v]);\n if (set_u !== set_v) {\n F.push([u, v, w]);\n disjoint_set.union(set_u, set_v);\n }\n }\n\n return F.sort((a, b) => a[2] - b[2]);\n }\n\n /**\n * initializes TopoMap. Sets all projcted points to zero, and computes a minimum spanning tree.\n */\n init() {\n const { metric} = this._parameters\n this.Y = new Matrix(this._N, 2, 0);\n this._Emst = this._make_minimum_spanning_tree(metric);\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Returns true if Point C is left of line AB.\n * @private\n * @param {Array} PointA - Point A of line AB\n * @param {Array} PointB - Point B of line AB\n * @param {Array} PointC - Point C\n * @returns {Boolean}\n */\n __hull_cross([ax, ay], [bx, by], [sx, sy]) {\n return (bx - ax) * (sy - ay) - (by - ay) * (sx - ax) <= 0;\n }\n\n /**\n * Computes the convex hull of the set of Points S\n * @private\n * @param {Array} S - Set of Points.\n * @see {@link https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain#JavaScript}\n * @returns {Array} convex hull of S. Starts at the bottom-most point and continues counter-clockwise.\n */\n __hull(S) {\n const points = S.sort(([x1, y1], [x2, y2]) => y1 - y2 || x1 - x2);\n const N = points.length;\n if (N <= 2) return points;\n\n const lower = [];\n for (let i = 0; i < N; ++i) {\n while (lower.length >= 2 && this.__hull_cross(lower[lower.length - 2], lower[lower.length - 1], points[i])) {\n lower.pop();\n }\n lower.push(points[i]);\n }\n const upper = [];\n for (let i = N - 1; i >= 0; --i) {\n while (upper.length >= 2 && this.__hull_cross(upper[upper.length - 2], upper[upper.length - 1], points[i])) {\n upper.pop();\n }\n upper.push(points[i]);\n }\n upper.pop();\n lower.pop();\n return lower.concat(upper);\n }\n\n /**\n * Finds the angle to rotate Point A and B to lie on a line parallel to the x-axis.\n * @private\n * @param {Array} PointA\n * @param {Array} PointB\n * @return {Object} Object containing the sinus- and cosinus-values for a rotation.\n */\n __findAngle([p1x, p1y], [p2x, p2y]) {\n const n = euclidean([p1x, p1y], [p2x, p2y]);\n if (n === 0)\n return {\n sin: 0,\n cos: 1,\n };\n const vec = [(p2x - p1x) / n, (p2y - p1y) / n];\n const cos = vec[0];\n let sin = Math.sqrt(1 - cos * cos);\n sin = vec[1] >= 0 ? -sin : sin;\n return {\n sin: sin,\n cos: cos,\n };\n }\n\n /**\n * @private\n * @param {Array} hull\n * @param {Array} p\n * @param {Bool} topEdge\n */\n __align_hull(hull, p, topEdge) {\n let v = -1;\n let d2;\n for (let i = 0; i < hull.length; ++i) {\n const d = euclidean(hull[i], p);\n if (v === -1) {\n d2 = d;\n v = i;\n } else {\n if (d2 > d) {\n d2 = d;\n v = i;\n }\n }\n }\n\n let v1;\n let v2;\n if (topEdge) {\n v1 = hull[v];\n v2 = hull[(v + 1) % hull.length];\n } else {\n if (v == 0) v = hull.length - 1;\n v1 = hull[v];\n v2 = hull[(v - 1) % hull.length];\n }\n\n const transformation = {\n tx: -hull[v][0],\n ty: -hull[v][1],\n };\n\n if (hull.length >= 2) {\n const { sin, cos } = this.__findAngle(v1, v2);\n transformation.sin = sin;\n transformation.cos = cos;\n } else {\n transformation.sin = 0;\n transformation.cos = 1;\n }\n\n return transformation;\n }\n\n /**\n * @private\n * @param {Array} Point - The point which should get transformed.\n * @param {Object} Transformation - contains the values for translation and rotation.\n */\n __transform([px, py], { tx, ty, sin, cos }) {\n let x = px + tx;\n let y = py + ty;\n let xx = x * cos - y * sin;\n let yy = x * sin + y * cos;\n return [xx, yy];\n }\n\n /**\n * Calls {@link __transform} for each point in Set C\n * @private\n * @param {Array} C - Set of points.\n * @param {Object} t - Transform object.\n * @param {Number} yOffset - value to offset set C.\n */\n __transform_component(C, t, yOffset) {\n const N = C.length;\n for (let i = 0; i < N; ++i) {\n const c = C[i];\n const [cx, cy] = this.__transform(c, t);\n c[0] = cx;\n c[1] = cy + yOffset;\n }\n }\n\n /**\n * @private\n * @param {Array} u - point u\n * @param {Array} v - point v\n * @param {Number} w - edge weight w\n */\n __align_components(u, v, w) {\n const points_u = [...u.__disjoint_set.children];\n const points_v = [...v.__disjoint_set.children];\n\n const hull_u = this.__hull(points_u);\n const hull_v = this.__hull(points_v);\n\n const t_u = this.__align_hull(hull_u, u, false);\n const t_v = this.__align_hull(hull_v, v, true);\n\n this.__transform_component(points_u, t_u, 0);\n this.__transform_component(points_v, t_v, w);\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality 2.\n */\n transform() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n }\n return this.projection;\n }\n\n *generator() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n yield this.projection;\n }\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { PCA, MDS } from \"./index.js\";\nimport { distance_matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias SAMMON\n * @extends DR\n */\nexport class SAMMON extends DR {\n /**\n * SAMMON's Mapping\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias SAMMON\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {\"PCA\"|\"MDS\"|\"random\"} [parameters.init = \"random\"] - Either \"PCA\" or \"MDS\", with which SAMMON initialiates the projection. With \"random\" a random matrix gets used as starting point.\n * @param {Object} [parameters.init_parameters] - Parameters for the {@link init}-DR method.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {SAMMON}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { magic: 0.1, d: 2, metric: euclidean, seed: 1212, init_DR: \"random\", init_parameters: {} }, parameters);\n return this;\n }\n\n /**\n * initializes the projection.\n * @private\n */\n init() {\n const N = this.X.shape[0];\n const { d, metric, init_DR: init_DR, init_parameters: DR_parameters } = this._parameters;\n if (init_DR === \"random\") {\n const randomizer = this._randomizer;\n this.Y = new Matrix(N, d, () => randomizer.random);\n } else if ([\"PCA\", \"MDS\"].includes(init_DR)) {\n this.Y = Matrix.from(init_DR == \"PCA\" ? PCA.transform(this.X, DR_parameters) : MDS.transform(this.X, DR_parameters));\n } else {\n throw new Error('init_DR needs to be either \"random\" or a DR method!')\n }\n this.distance_matrix = metric == \"precomputed\" ? Matrix.from(this.X) : distance_matrix(this.X, metric);\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Matrix|Array} - The projection of {@link X}.\n */\n transform(max_iter = 200) {\n if (!this._is_initialized) this.init();\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n }\n return this.projection;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Generator} - A generator yielding the intermediate steps of the projection of {@link X}.\n */\n *generator(max_iter = 200) {\n if (!this._is_initialized) this.init();\n\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n yield this.projection;\n }\n\n return this.projection;\n }\n\n _step() {\n const MAGIC = this.parameter(\"magic\");\n const D = this.distance_matrix;\n const N = this.X.shape[0];\n const { d, metric } = this._parameters;\n let Y = this.Y;\n\n let G = new Matrix(N, d, 0);\n\n let sum = new Float64Array(d);\n for (let i = 0; i < N; ++i) {\n let e1 = new Float64Array(d);\n let e2 = new Float64Array(d);\n const Yi = Y.row(i);\n for (let j = 0; j < N; ++j) {\n if (i === j) continue;\n const Yj = Y.row(j);\n const delta = new Float64Array(d);\n for (let k = 0; k < d; ++k) {\n delta[k] = Yi[k] - Yj[k];\n }\n const dY = metric(Yi, Yj);\n const dX = D.entry(i, j);\n const dq = dX - dY;\n const dr = Math.max(dX * dY, 1e-2);\n for (let k = 0; k < d; ++k) {\n e1[k] += (delta[k] * dq) / dr;\n e2[k] += (dq - (Math.pow(delta[k], 2) * (1 + dq / dY)) / dY) / dr;\n }\n }\n for (let k = 0; k < d; ++k) {\n const val = Y.entry(i, k) + ((MAGIC * e1[k]) / Math.abs(e2[k]) || 0);\n G.set_entry(i, k, val);\n sum[k] += val;\n }\n }\n for (let k = 0; k < d; ++k) {\n sum[k] /= N;\n }\n\n for (let i = 0; i < N; ++i) {\n for (let k = 0; k < d; ++k) {\n Y.set_entry(i, k, G.entry(i, k) - sum[k]);\n }\n }\n return Y;\n }\n}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,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACrF,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;AACvC,gBAAgB,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;AAC9B,aAAa;AACb,SAAS;AACT,QAAQ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;AACpC,YAAY,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACxB,SAAS;AACT;AACA,QAAQ,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;AACpC,YAAY,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;AACxC,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,aAAa;AACb,SAAS;AACT,QAAQ,OAAO,CAAC,CAAC;AACjB,KAAK;AACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"druid.js","sources":["../metrics/euclidean.js","../numerical/kahan_sum.js","../numerical/neumair_sum.js","../metrics/euclidean_squared.js","../metrics/cosine.js","../metrics/manhattan.js","../metrics/chebyshev.js","../metrics/canberra.js","../metrics/jaccard.js","../metrics/hamming.js","../metrics/sokal_michener.js","../metrics/yule.js","../matrix/k_nearest_neighbors.js","../matrix/distance_matrix.js","../matrix/linspace.js","../matrix/norm.js","../matrix/normalize.js","../linear_algebra/qr.js","../linear_algebra/qr_householder.js","../linear_algebra/simultaneous_poweriteration.js","../linear_algebra/inner_product.js","../matrix/Matrix.js","../util/randomizer.js","../util/max.js","../util/min.js","../datastructure/Heap.js","../datastructure/DisjointSet.js","../knn/BallTree.js","../knn/KNN.js","../dimred/DR.js","../dimred/PCA.js","../dimred/MDS.js","../dimred/ISOMAP.js","../dimred/FASTMAP.js","../dimred/LDA.js","../dimred/LLE.js","../dimred/LTSA.js","../dimred/TSNE.js","../optimization/powell.js","../dimred/UMAP.js","../dimred/TriMap.js","../clustering/Hierarchical_Clustering.js","../clustering/KMeans.js","../clustering/KMedoids.js","../clustering/OPTICS.js","../dimred/LSP.js","../dimred/TopoMap.js","../dimred/SAMMON.js"],"sourcesContent":["import { euclidean_squared } from \"../metrics/index.js\";\n/**\n * Computes the euclidean distance (l2) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n return Math.sqrt(euclidean_squared(a, b));\n}\n","/**\n * Numerical stable summation with the Kahan summation algorithm.\n * @memberof module:numerical\n * @alias kahan_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n let y, t;\n\n for (let i = 0; i < n; ++i) {\n y = summands[i] - compensation;\n t = sum + y;\n compensation = t - sum - y;\n sum = t;\n }\n return sum;\n}\n","/**\n * Numerical stable summation with the Neumair summation algorithm.\n * @memberof module:numerical\n * @alias neumair_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm#Further_enhancements}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n\n for (let i = 0; i < n; ++i) {\n let summand = summands[i];\n let t = sum + summand;\n if (Math.abs(sum) >= Math.abs(summand)) {\n compensation += sum - t + summand;\n } else {\n compensation += summand - t + sum;\n }\n sum = t;\n }\n return sum + compensation;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n/**\n * Computes the squared euclidean distance (l22) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean_squared\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the squared euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let s = new Array(n);\n for (let i = 0; i < n; ++i) {\n let x = a[i];\n let y = b[i];\n s[i] = (x - y) * (x - y);\n }\n return neumair_sum(s);\n}\n","/**\n * Computes the cosine distance (not similarity) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias cosine\n * @param {Array} a\n * @param {Array} b\n * @example\n * druid.cosine([1,0],[1,1]) == 0.7853981633974484 == π/4\n * @returns {Number} The cosine distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n let sum_a = 0;\n let sum_b = 0;\n for (let i = 0; i < n; ++i) {\n sum += a[i] * b[i];\n sum_a += a[i] * a[i];\n sum_b += b[i] * b[i];\n }\n return Math.acos(sum / (Math.sqrt(sum_a) * Math.sqrt(sum_b)));\n}\n","/**\n * Computes the manhattan distance (l1) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias manhattan\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the manhattan distance between {@link a} and {@link b}.\n */ \nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += Math.abs(a[i] - b[i]);\n }\n return sum;\n}\n","/**\n * Computes the chebyshev distance (L) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias chebyshev\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the chebyshev distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let res = [];\n for (let i = 0; i < n; ++i) {\n res.push(Math.abs(a[i] - b[i]));\n }\n return Math.max(...res);\n}\n","/**\n * Computes the canberra distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias canberra\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} The canberra distance between {@link a} and {@link b}.\n * @see {@link https://en.wikipedia.org/wiki/Canberra_distance}\n */\nexport default function(a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += (Math.abs(a[i] - b[i]) / (Math.abs(a[i]) + Math.abs(b[i])))\n }\n return sum;\n}","/**\n * Computes the jaccard distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias jaccard\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the jaccard distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_non_zero = 0;\n let num_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_non_zero += x || y;\n num_equal += x && y;\n }\n return (num_non_zero - num_equal) / num_non_zero;\n}\n","/**\n * Computes the hamming distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias hamming\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the hamming distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let disagree = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i];\n const y = b[i];\n disagree += x != y;\n }\n return disagree / n;\n}\n","/**\n * Computes the Sokal-Michener distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias sokal_michener\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} the Sokal-Michener distance between {@link a} and {@link b}. \n */\nexport default function(a, b) {\n if (a.length != b.length) return undefined\n const n = a.length;\n let num_not_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_not_equal += x != y;\n }\n return (2 * num_not_equal) / (n + num_not_equal);\n}","/**\n * Computes the yule distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias yule\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the yule distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_true_true = 0;\n let num_true_false = 0;\n let num_false_true = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_true_true += x && y;\n num_true_false += x && !y;\n num_false_true += !x && x;\n }\n const num_false_false = n - num_true_true - num_true_false - num_false_true;\n return num_true_false == 0 || num_false_true == 0 ? 0 : (2 * num_true_false * num_false_true) / (num_true_true * num_false_false + num_true_false * num_false_true);\n}\n","import { distance_matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Computes the k-nearest neighbors of each row of {@link A}.\n * @memberof module:matrix\n * @alias k_nearest_neigbhors\n * @param {Matrix} A - Either the data matrix, or a distance matrix.\n * @param {Number} k - The number of neighbors to compute.\n * @param {Function|\"precomputed\"} [metric=euclidean]\n * @returns {Array} -\n */\nexport default function (A, k, metric = euclidean) {\n const rows = A.shape[0];\n let D = metric == \"precomputed\" ? A : distance_matrix(A, metric);\n let nN = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n nN[row] = Array.from(D.row(row))\n .map((distance, col) => {\n return {\n i: row,\n j: col,\n distance: distance,\n };\n })\n .sort((a, b) => a.distance - b.distance)\n .slice(1, k + 1);\n }\n return nN;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"./index.js\";\n\n/**\n * Computes the distance matrix of datamatrix {@link A}.\n * @memberof module:matrix\n * @alias distance_matrix\n * @param {Matrix} A - Matrix.\n * @param {Function} [metric=euclidean] - The diistance metric.\n * @returns {Matrix} D - The distance matrix of {@link A}.\n */\nexport default function (A, metric = euclidean) {\n let n = A.shape[0];\n const D = new Matrix(n, n);\n for (let i = 0; i < n; ++i) {\n const A_i = A.row(i);\n for (let j = i + 1; j < n; ++j) {\n const dist = metric(A_i, A.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n }\n }\n return D;\n}\n","/**\n * Creates an Array containing {@link number} numbers from {@link start} to {@link end}.\n * If {@link number} = null.\n * @memberof module:matrix\n * @alias linspace\n * @param {Number} start - Start value.\n * @param {Number} end - End value.\n * @param {Number} [number = null] - Number of number between {@link start} and {@link end}.\n * @returns {Array} - An array with {@link number} entries, beginning at {@link start} ending at {@link end}.\n */\nexport default function (start, end, number = null) {\n if (!number) {\n number = Math.max(Math.round(end - start) + 1, 1);\n }\n if (number < 2) {\n return number === 1 ? [start] : [];\n }\n let result = new Array(number);\n number -= 1;\n for (let i = number; i >= 0; --i) {\n result[i] = (i * end + (number - i) * start) / number;\n }\n return result;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n//import { neumair_sum } from \"../numerical/index\";\n\n/**\n * Computes the norm of a vector, by computing its distance to **0**.\n * @memberof module:matrix\n * @alias norm\n * @param {Matrix|Array|Float64Array} v - Vector. \n * @param {Function} [metric = euclidean] - Which metric should be used to compute the norm.\n * @returns {Number} - The norm of {@link v}.\n */\nexport default function (v, metric = euclidean) {\n let vector = null;\n if (v instanceof Matrix) {\n let [rows, cols] = v.shape;\n if (rows === 1) vector = v.row(0);\n else if (cols === 1) vector = v.col(0);\n else throw new Error(\"Matrix must be 1d!\");\n } else {\n vector = v;\n }\n const n = vector.length;\n const zeros = Float64Array.from({ length: n }, () => 0);\n return metric(vector, zeros);\n}\n","import { norm } from \"./index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Normalizes Vector {@link v}.\n * @memberof module:matrix\n * @alias normalize\n * @param {Array|Float64Array} v - Vector\n * @param {Function} metric \n * @returns {Array|Float64Array} - The normalized vector with length 1.\n */\nexport default function(v, metric = euclidean) {\n const v_norm = norm(v, metric);\n return v.map(value => value / v_norm);\n}","import { Matrix, norm } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} using Gram-Schmidt process.\n * @memberof module:linear_algebra\n * @alias qr\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_the_Gram%E2%80%93Schmidt_process}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, cols, \"identity\");\n const R = new Matrix(cols, cols, 0);\n\n for (let j = 0; j < cols; ++j) {\n let v = A.col(j);\n for (let i = 0; i < j; ++i) {\n const q = Q.col(i);\n const q_dot_v = neumair_sum(q.map((q_, k) => q_ * v[k]));\n R.set_entry(i, j, q_dot_v);\n v = v.map((v_, k) => v_ - q_dot_v * q[k]);\n }\n const v_norm = norm(v, euclidean);\n for (let k = 0; k < rows; ++k) {\n Q.set_entry(k, j, v[k] / v_norm);\n }\n R.set_entry(j, j, v_norm);\n }\n return { R, Q };\n}\n","import { Matrix, norm } from \"../matrix/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} with householder transformations.\n * @memberof module:linear_algebra\n * @alias qr_householder\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections}\n * @see {@link http://mlwiki.org/index.php/Householder_Transformation}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, rows, \"I\");\n const R = A.clone();\n\n for (let j = 0; j < cols; ++j) {\n const x = Matrix.from(R.col(j).slice(j));\n const x_norm = norm(x);\n const x0 = x.entry(0, 0);\n const rho = -Math.sign(x0);\n const u1 = x0 - rho * x_norm;\n const u = x.divide(u1).set_entry(0, 0, 1);\n const beta = (-rho * u1) / x_norm;\n\n const u_outer_u = u.outer(u);\n const R_block = R.get_block(j, 0);\n const new_R = R_block.sub(u_outer_u.dot(R_block).mult(beta));\n const Q_block = Q.get_block(0, j);\n const new_Q = Q_block.sub(Q_block.dot(u_outer_u).mult(beta));\n R.set_block(j, 0, new_R);\n Q.set_block(0, j, new_Q);\n }\n return { R, Q };\n}\n","import { qr as qr_gramschmidt } from \"./index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { euclidean_squared } from \"../metrics/index.js\";\n\n/**\n * Computes the {@link k} biggest Eigenvectors and Eigenvalues from Matrix {@link A} with the QR-Algorithm.\n * @memberof module:linear_algebra\n * @alias simultaneous_poweriteration\n * @param {Matrix} A - The Matrix\n * @param {Number} k - The number of eigenvectors and eigenvalues to compute.\n * @param {Object} parameters - Object containing parameterization of the simultanious poweriteration method.\n * @param {Number} [parameters.max_iterations=100] - The number of maxiumum iterations the algorithm should run.\n * @param {Number|Randomizer} [parameters.seed=1212] - The seed value or a randomizer used in the algorithm.\n * @param {Function} [parameters.qr=qr_gramschmidt] - The QR technique to use.\n * @param {Number} [parameters.tol=1e-8] - Allowed error for stopping criteria\n * @returns {{eigenvalues: Array, eigenvectors: Array}} - The {@link k} biggest eigenvectors and eigenvalues of Matrix {@link A}.\n */\nexport default function (A, k = 2, {seed = 1212, max_iterations = 100, qr = qr_gramschmidt, tol = 1e-8} = {}) {\n const randomizer = seed instanceof Randomizer ? seed : new Randomizer(seed);\n if (!(A instanceof Matrix)) A = Matrix.from(A);\n const n = A.shape[0];\n let { Q, R } = qr(new Matrix(n, k, () => (randomizer.random - .5) * 2));\n while (max_iterations--) {\n const oldQ = Q.clone();\n const Z = A.dot(Q);\n const QR = qr(Z);\n Q = QR.Q;\n R = QR.R;\n const error = euclidean_squared(Q.values, oldQ.values);\n if (error < tol) {\n break;\n }\n }\n\n const eigenvalues = R.diag;\n const eigenvectors = Q.transpose().to2dArray;\n return { eigenvalues, eigenvectors };\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the inner product between two arrays of the same length.\n * @memberof module:linear_algebra\n * @alias inner_product\n * @param {Array|Float64Array} a - Array a\n * @param {Array|Float64Array} b - Array b\n * @returns The inner product between {@link a} and {@link b}\n */\nexport default function (a, b) {\n const N = a.length;\n if (N != b.length) {\n throw new Error(\"Array a and b must have the same length!\")\n }\n let sum = 0;\n for (let i = 0; i < N; ++i) {\n sum += a * b;\n }\n return sum;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n/**\n * @class\n * @alias Matrix\n * @requires module:numerical/neumair_sum\n */\nexport class Matrix {\n /**\n * creates a new Matrix. Entries are stored in a Float64Array.\n * @constructor\n * @memberof module:matrix\n * @alias Matrix\n * @param {number} rows - The amount of rows of the matrix.\n * @param {number} cols - The amount of columns of the matrix.\n * @param {(function|string|number)} value=0 - Can be a function with row and col as parameters, a number, or \"zeros\", \"identity\" or \"I\", or \"center\".\n * - **function**: for each entry the function gets called with the parameters for the actual row and column.\n * - **string**: allowed are\n * - \"zero\", creates a zero matrix.\n * - \"identity\" or \"I\", creates an identity matrix.\n * - \"center\", creates an center matrix.\n * - **number**: create a matrix filled with the given value.\n * @example\n *\n * let A = new Matrix(10, 10, () => Math.random()); //creates a 10 times 10 random matrix.\n * let B = new Matrix(3, 3, \"I\"); // creates a 3 times 3 identity matrix.\n * @returns {Matrix} returns a {@link rows} times {@link cols} Matrix filled with {@link value}.\n */\n constructor(rows = null, cols = null, value = null) {\n this._rows = rows;\n this._cols = cols;\n this._data = null;\n if (rows && cols) {\n if (!value) {\n this._data = new Float64Array(rows * cols);\n return this;\n }\n if (typeof value === \"function\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n if (typeof value === \"string\") {\n if (value === \"zeros\") {\n return new Matrix(rows, cols, 0);\n }\n if (value === \"identity\" || value === \"I\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n this._data[row * cols + row] = 1;\n }\n return this;\n }\n if (value === \"center\" && rows == cols) {\n this._data = new Float64Array(rows * cols);\n value = (i, j) => (i === j ? 1 : 0) - 1 / rows;\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n }\n if (typeof value === \"number\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value;\n }\n }\n return this;\n }\n }\n return this;\n }\n\n /**\n * Creates a Matrix out of {@link A}.\n * @param {(Matrix|Array|Float64Array|number)} A - The matrix, array, or number, which should converted to a Matrix.\n * @param {\"row\"|\"col\"|\"diag\"} [type = \"row\"] - If {@link A} is a Array or Float64Array, then type defines if it is a row- or a column vector.\n * @returns {Matrix}\n *\n * @example\n * let A = Matrix.from([[1, 0], [0, 1]]); //creates a two by two identity matrix.\n * let S = Matrix.from([1, 2, 3], \"diag\"); // creates a 3 by 3 matrix with 1, 2, 3 on its diagonal. [[1, 0, 0], [0, 2, 0], [0, 0, 3]]\n */\n static from(A, type = \"row\") {\n if (A instanceof Matrix) {\n return A.clone();\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let m = A.length;\n if (m === 0) throw new Error(\"Array is empty\");\n // 1d\n if (!Array.isArray(A[0]) && !(A[0] instanceof Float64Array)) {\n if (type === \"row\") {\n return new Matrix(1, m, (_, j) => A[j]);\n } else if (type === \"col\") {\n return new Matrix(m, 1, (i) => A[i]);\n } else if (type === \"diag\") {\n return new Matrix(m, m, (i, j) => (i == j ? A[i] : 0));\n } else {\n throw new Error(\"1d array has NaN entries\");\n }\n // 2d\n } else if (Array.isArray(A[0]) || A[0] instanceof Float64Array) {\n let n = A[0].length;\n for (let row = 0; row < m; ++row) {\n if (A[row].length !== n) {\n throw new Error(\"various array lengths\");\n }\n }\n return new Matrix(m, n, (i, j) => A[i][j]);\n }\n } else if (typeof A === \"number\") {\n return new Matrix(1, 1, A);\n } else {\n throw new Error(\"error\");\n }\n }\n\n /**\n * Returns the {@link row}th row from the Matrix.\n * @param {Number} row\n * @returns {Float64Array}\n */\n row(row) {\n const data = this.values;\n const cols = this._cols;\n return data.subarray(row * cols, (row + 1) * cols);\n }\n\n /**\n * Returns an generator yielding each row of the Matrix.\n * @yields {Float64Array}\n */\n *iterate_rows() {\n const cols = this._cols;\n const rows = this._rows;\n const data = this.values;\n for (let row = 0; row < rows; ++row) {\n yield data.subarray(row * cols, (row + 1) * cols);\n }\n }\n\n /**\n * Makes a {@link Matrix} object an iterable object.\n * @yields {Float64Array}\n */\n *[Symbol.iterator]() {\n for (const row of this.iterate_rows()) {\n yield row;\n }\n }\n\n /**\n * Sets the entries of {@link row}th row from the Matrix to the entries from {@link values}.\n * @param {int} row\n * @param {Array} values\n * @returns {Matrix}\n */\n set_row(row, values) {\n let cols = this._cols;\n if (Array.isArray(values) && values.length === cols) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values[col];\n }\n } else if (values instanceof Matrix && values.shape[1] === cols && values.shape[0] === 1) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values._data[col];\n }\n }\n return this;\n }\n\n /**\n * Returns the {@link col}th column from the Matrix.\n * @param {int} col\n * @returns {Array}\n */\n col(col) {\n let result_col = new Float64Array(this._rows);\n for (let row = 0; row < this._rows; ++row) {\n result_col[row] = this.values[row * this._cols + col];\n }\n return result_col;\n }\n\n /**\n * Returns the {@link col}th entry from the {@link row}th row of the Matrix.\n * @param {int} row\n * @param {int} col\n * @returns {float64}\n */\n entry(row, col) {\n return this.values[row * this._cols + col];\n }\n\n /**\n * Sets the {@link col}th entry from the {@link row}th row of the Matrix to the given {@link value}.\n * @param {int} row\n * @param {int} col\n * @param {float64} value\n * @returns {Matrix}\n */\n set_entry(row, col, value) {\n this.values[row * this._cols + col] = value;\n return this;\n }\n\n /**\n * Returns a new transposed Matrix.\n * @returns {Matrix}\n */\n transpose() {\n let B = new Matrix(this._cols, this._rows, (row, col) => this.entry(col, row));\n return B;\n }\n\n /**\n * Returns a new transposed Matrix. Short-form of {@function transpose}.\n * @returns {Matrix}\n */\n get T() {\n return this.transpose();\n }\n\n /**\n * Returns the inverse of the Matrix.\n * @returns {Matrix}\n */\n inverse() {\n const rows = this._rows;\n const cols = this._cols;\n let B = new Matrix(rows, 2 * cols, (i, j) => {\n if (j >= cols) {\n return i === j - cols ? 1 : 0;\n } else {\n return this.entry(i, j);\n }\n });\n let h = 0;\n let k = 0;\n while (h < rows && k < cols) {\n var i_max = 0;\n let max_val = -Infinity;\n for (let i = h; i < rows; ++i) {\n let val = Math.abs(B.entry(i, k));\n if (max_val < val) {\n i_max = i;\n max_val = val;\n }\n }\n if (B.entry(i_max, k) == 0) {\n k++;\n } else {\n // swap rows\n for (let j = 0; j < 2 * cols; ++j) {\n let h_val = B.entry(h, j);\n let i_val = B.entry(i_max, j);\n B.set_entry(h, j, h_val);\n B.set_entry(i_max, j, i_val);\n }\n for (let i = h + 1; i < rows; ++i) {\n let f = B.entry(i, k) / B.entry(h, k);\n B.set_entry(i, k, 0);\n for (let j = k + 1; j < 2 * cols; ++j) {\n B.set_entry(i, j, B.entry(i, j) - B.entry(h, j) * f);\n }\n }\n h++;\n k++;\n }\n }\n\n for (let row = 0; row < rows; ++row) {\n let f = B.entry(row, row);\n for (let col = row; col < 2 * cols; ++col) {\n B.set_entry(row, col, B.entry(row, col) / f);\n }\n }\n\n for (let row = rows - 1; row >= 0; --row) {\n let B_row_row = B.entry(row, row);\n for (let i = 0; i < row; i++) {\n let B_i_row = B.entry(i, row);\n let f = B_i_row / B_row_row;\n for (let j = i; j < 2 * cols; ++j) {\n let B_i_j = B.entry(i, j);\n let B_row_j = B.entry(row, j);\n B_i_j = B_i_j - B_row_j * f;\n B.set_entry(i, j, B_i_j);\n }\n }\n }\n\n return new Matrix(rows, cols, (i, j) => B.entry(i, j + cols));\n }\n\n /**\n * Returns the dot product. If {@link B} is an Array or Float64Array then an Array gets returned. If {@link B} is a Matrix then a Matrix gets returned.\n * @param {(Matrix|Array|Float64Array)} B the right side\n * @returns {(Matrix|Array)}\n */\n dot(B) {\n if (B instanceof Matrix) {\n let A = this;\n if (A.shape[1] !== B.shape[0]) {\n throw new Error(`A.dot(B): A is a ${A.shape.join(\" ⨯ \")}-Matrix, B is a ${B.shape.join(\" ⨯ \")}-Matrix: \n A has ${A.shape[1]} cols and B ${B.shape[0]} rows. \n Must be equal!`);\n }\n let I = A.shape[1];\n let C = new Matrix(A.shape[0], B.shape[1], (row, col) => {\n const A_i = A.row(row);\n const B_i = B.col(col);\n let sum = 0;\n for (let i = 0; i < I; ++i) {\n sum += A_i[i] * B_i[i];\n }\n return sum;\n });\n return C;\n } else if (Array.isArray(B) || B instanceof Float64Array) {\n let rows = this._rows;\n if (B.length !== rows) {\n throw new Error(`A.dot(B): A has ${rows} cols and B has ${B.length} rows. Must be equal!`);\n }\n let C = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n C[row] = neumair_sum(this.row(row).map((e) => e * B[row]));\n }\n return C;\n } else {\n throw new Error(`B must be Matrix or Array`);\n }\n }\n\n /**\n * Computes the outer product from {@link this} and {@link B}.\n * @param {Matrix} B\n * @returns {Matrix}\n */\n outer(B) {\n let A = this;\n let l = A._data.length;\n let r = B._data.length;\n if (l != r) return undefined;\n let C = new Matrix();\n C.shape = [\n l,\n l,\n (i, j) => {\n if (i <= j) {\n return A._data[i] * B._data[j];\n } else {\n return C.entry(j, i);\n }\n },\n ];\n return C;\n }\n\n /**\n * Appends matrix {@link B} to the matrix.\n * @param {Matrix} B - matrix to append.\n * @param {\"horizontal\"|\"vertical\"|\"diag\"} [type = \"horizontal\"] - type of concatenation.\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 1], [1, 1]]); // 2 by 2 matrix filled with ones.\n * let B = Matrix.from([[2, 2], [2, 2]]); // 2 by 2 matrix filled with twos.\n *\n * A.concat(B, \"horizontal\"); // 2 by 4 matrix. [[1, 1, 2, 2], [1, 1, 2, 2]]\n * A.concat(B, \"vertical\"); // 4 by 2 matrix. [[1, 1], [1, 1], [2, 2], [2, 2]]\n * A.concat(B, \"diag\"); // 4 by 4 matrix. [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 2, 2], [0, 0, 2, 2]]\n */\n concat(B, type = \"horizontal\") {\n const A = this;\n const [rows_A, cols_A] = A.shape;\n const [rows_B, cols_B] = B.shape;\n if (type == \"horizontal\") {\n if (rows_A != rows_B) {\n throw new Error(`A.concat(B, \"horizontal\"): A and B need same number of rows, A has ${rows_A} rows, B has ${rows_B} rows.`);\n }\n const X = new Matrix(rows_A, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(0, cols_A, B);\n return X;\n } else if (type == \"vertical\") {\n if (cols_A != cols_B) {\n throw new Error(`A.concat(B, \"vertical\"): A and B need same number of columns, A has ${cols_A} columns, B has ${cols_B} columns.`);\n }\n const X = new Matrix(rows_A + rows_B, cols_A, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, 0, B);\n return X;\n } else if (type == \"diag\") {\n const X = new Matrix(rows_A + rows_B, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, cols_A, B);\n return X;\n } else {\n throw new Error(`type must be \"horizontal\" or \"vertical\", but type is ${type}!`);\n }\n }\n\n /**\n * Writes the entries of B in A at an offset position given by {@link offset_row} and {@link offset_col}.\n * @param {int} offset_row\n * @param {int} offset_col\n * @param {Matrix} B\n * @returns {Matrix}\n */\n set_block(offset_row, offset_col, B) {\n let [rows, cols] = B.shape;\n for (let row = 0; row < rows; ++row) {\n if (row > this._rows) {\n continue;\n }\n for (let col = 0; col < cols; ++col) {\n if (col > this._cols) {\n continue;\n }\n this.set_entry(row + offset_row, col + offset_col, B.entry(row, col));\n }\n }\n return this;\n }\n\n /**\n * Extracts the entries from the {@link start_row}th row to the {@link end_row}th row, the {@link start_col}th column to the {@link end_col}th column of the matrix.\n * If {@link end_row} or {@link end_col} is empty, the respective value is set to {@link this.rows} or {@link this.cols}.\n * @param {Number} start_row\n * @param {Number} start_col\n * @param {Number} [end_row = null]\n * @param {Number} [end_col = null]\n * @returns {Matrix} Returns a end_row - start_row times end_col - start_col matrix, with respective entries from the matrix.\n * @example\n *\n * let A = Matrix.from([[1, 2, 3], [4, 5, 6], [7, 8, 9]]); // a 3 by 3 matrix.\n *\n * A.get_block(1, 1); // [[5, 6], [8, 9]]\n * A.get_block(0, 0, 1, 1); // [[1]]\n * A.get_block(1, 1, 2, 2); // [[5]]\n * A.get_block(0, 0, 2, 2); // [[1, 2], [4, 5]]\n */\n get_block(start_row, start_col, end_row = null, end_col = null) {\n const [rows, cols] = this.shape;\n end_row = end_row ?? rows;\n end_col = end_col ?? cols;\n if (end_row <= start_row || end_col <= start_col) {\n throw new Error(`\n end_row must be greater than start_row, and \n end_col must be greater than start_col, but\n end_row = ${end_row}, start_row = ${start_row}, end_col = ${end_col}, and start_col = ${start_col}!`);\n }\n const X = new Matrix(end_row - start_row, end_col - start_col, \"zeros\");\n for (let row = start_row, new_row = 0; row < end_row; ++row, ++new_row) {\n for (let col = start_col, new_col = 0; col < end_col; ++col, ++new_col) {\n X.set_entry(new_row, new_col, this.entry(row, col));\n }\n }\n return X;\n //return new Matrix(end_row - start_row, end_col - start_col, (i, j) => this.entry(i + start_row, j + start_col));\n }\n\n /**\n * Returns a new array gathering entries defined by the indices given by argument.\n * @param {Array} row_indices - Array consists of indices of rows for gathering entries of this matrix\n * @param {Array} col_indices - Array consists of indices of cols for gathering entries of this matrix\n * @returns {Matrix}\n */\n gather(row_indices, col_indices) {\n const N = row_indices.length;\n const D = col_indices.length;\n\n const R = new Matrix(N, D);\n for (let i = 0; i < N; ++i) {\n const row_index = row_indices[i];\n for (let j = 0; j < N; ++j) {\n const col_index = col_indices[j];\n R.set_entry(i, j, this.entry(row_index, col_index));\n }\n }\n\n return R;\n }\n\n /**\n * Applies a function to each entry of the matrix.\n * @private\n * @param {function} f function takes 2 parameters, the value of the actual entry and a value given by the function {@link v}. The result of {@link f} gets writen to the Matrix.\n * @param {function} v function takes 2 parameters for row and col, and returns a value witch should be applied to the colth entry of the rowth row of the matrix.\n */\n _apply_array(f, v) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], v(row, col));\n }\n }\n return this;\n }\n\n _apply_rowwise_array(values, f) {\n return this._apply_array(f, (_, j) => values[j]);\n }\n\n _apply_colwise_array(values, f) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], values[row]);\n }\n }\n return this;\n }\n\n _apply(value, f) {\n let data = this.values;\n if (value instanceof Matrix) {\n let [value_rows, value_cols] = value.shape;\n let [rows, cols] = this.shape;\n if (value_rows === 1) {\n if (cols !== value_cols) {\n throw new Error(`cols !== value_cols`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(0, col));\n }\n }\n } else if (value_cols === 1) {\n if (rows !== value_rows) {\n throw new Error(`rows !== value_rows`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, 0));\n }\n }\n } else if (rows == value_rows && cols == value_cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, col));\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else if (Array.isArray(value)) {\n let rows = this._rows;\n let cols = this._cols;\n if (value.length === rows) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[row]);\n }\n }\n } else if (value.length === cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[col]);\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else {\n for (let i = 0, n = this._rows * this._cols; i < n; ++i) {\n data[i] = f(data[i], value);\n }\n }\n return this;\n }\n\n /**\n * Clones the Matrix.\n * @returns {Matrix}\n */\n clone() {\n let B = new Matrix();\n B._rows = this._rows;\n B._cols = this._cols;\n B._data = this.values.slice(0);\n return B;\n }\n\n /**\n * Entrywise multiplication with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.mult(2); // [[2, 4], [6, 8]];\n * A.mult(B); // [[1, 4], [9, 16]];\n */\n mult(value) {\n return this.clone()._apply(value, (a, b) => a * b);\n }\n\n /**\n * Entrywise division with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.divide(2); // [[0.5, 1], [1.5, 2]];\n * A.divide(B); // [[1, 1], [1, 1]];\n */\n divide(value) {\n return this.clone()._apply(value, (a, b) => a / b);\n }\n\n /**\n * Entrywise addition with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.add(2); // [[3, 4], [5, 6]];\n * A.add(B); // [[2, 4], [6, 8]];\n */\n add(value) {\n return this.clone()._apply(value, (a, b) => a + b);\n }\n\n /**\n * Entrywise subtraction with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.sub(2); // [[-1, 0], [1, 2]];\n * A.sub(B); // [[0, 0], [0, 0]];\n */\n sub(value) {\n return this.clone()._apply(value, (a, b) => a - b);\n }\n\n /**\n * Returns the number of rows and columns of the Matrix.\n * @returns {Array} An Array in the form [rows, columns].\n */\n get shape() {\n return [this._rows, this._cols];\n }\n\n /**\n * Returns the matrix in the given shape with the given function which returns values for the entries of the matrix.\n * @param {Array} parameter - takes an Array in the form [rows, cols, value], where rows and cols are the number of rows and columns of the matrix, and value is a function which takes two parameters (row and col) which has to return a value for the colth entry of the rowth row.\n * @returns {Matrix}\n */\n set shape([rows, cols, value = () => 0]) {\n this._rows = rows;\n this._cols = cols;\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n\n /**\n * Returns the Matrix as a Array of Float64Arrays.\n * @returns {Array}\n */\n get to2dArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(row);\n }\n return result;\n }\n\n /**\n * Returns the Matrix as a Array of Arrays.\n * @returns {Array}\n */\n get asArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(Array.from(row));\n }\n return result;\n }\n\n /**\n * Returns the diagonal of the Matrix.\n * @returns {Float64Array}\n */\n get diag() {\n const rows = this._rows;\n const cols = this._cols;\n const min_row_col = Math.min(rows, cols);\n let result = new Float64Array(min_row_col);\n for (let i = 0; i < min_row_col; ++i) {\n result[i] = this.entry(i, i);\n }\n return result;\n }\n\n /**\n * Returns the mean of all entries of the Matrix.\n * @returns {Number}\n */\n get mean() {\n const sum = this.sum;\n const n = this._rows * this._cols;\n return sum / n;\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Number}\n */\n get sum() {\n const data = this.values;\n return neumair_sum(data);\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Float64Array}\n */\n get values() {\n const data = this._data;\n return data;\n }\n\n /**\n * Returns the mean of each row of the matrix.\n * @returns {Float64Array}\n */\n get meanRows() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: rows });\n for (let row = 0; row < rows; ++row) {\n result[row] = 0;\n for (let col = 0; col < cols; ++col) {\n result[row] += data[row * cols + col];\n }\n result[row] /= cols;\n }\n return result;\n }\n\n /** Returns the mean of each column of the matrix.\n * @returns {Float64Array}\n */\n get meanCols() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: cols });\n for (let col = 0; col < cols; ++col) {\n result[col] = 0;\n for (let row = 0; row < rows; ++row) {\n result[col] += data[row * cols + col];\n }\n result[col] /= rows;\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b} using the conjugate gradient method. Returns the result x.\n * @param {Matrix} A - Matrix\n * @param {Matrix} b - Matrix\n * @param {Randomizer} [randomizer=null]\n * @param {Number} [tol=1e-3]\n * @returns {Matrix}\n */\n static solve_CG(A, b, randomizer, tol = 1e-3) {\n if (randomizer === null) {\n randomizer = new Randomizer();\n }\n const rows = A.shape[0];\n const cols = b.shape[1];\n let result = new Matrix(rows, 0);\n for (let i = 0; i < cols; ++i) {\n const b_i = Matrix.from(b.col(i)).T;\n let x = new Matrix(rows, 1, () => randomizer.random);\n let r = b_i.sub(A.dot(x));\n let d = r.clone();\n do {\n const z = A.dot(d);\n const alpha = r.T.dot(r).entry(0, 0) / d.T.dot(z).entry(0, 0);\n x = x.add(d.mult(alpha));\n const r_next = r.sub(z.mult(alpha));\n const beta = r_next.T.dot(r_next).entry(0, 0) / r.T.dot(r).entry(0, 0);\n d = r_next.add(d.mult(beta));\n r = r_next;\n } while (Math.abs(r.mean) > tol);\n result = result.concat(x, \"horizontal\");\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b}. Returns the result x.\n * @param {Matrix} A - Matrix or LU Decomposition\n * @param {Matrix} b - Matrix\n * @returns {Matrix}\n */\n static solve(A, b) {\n let { L: L, U: U } = \"L\" in A && \"U\" in A ? A : Matrix.LU(A);\n let rows = L.shape[0];\n let x = b.clone();\n\n // forward\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < row - 1; ++col) {\n x.set_entry(0, row, x.entry(0, row) - L.entry(row, col) * x.entry(1, col));\n }\n x.set_entry(0, row, x.entry(0, row) / L.entry(row, row));\n }\n\n // backward\n for (let row = rows - 1; row >= 0; --row) {\n for (let col = rows - 1; col > row; --col) {\n x.set_entry(0, row, x.entry(0, row) - U.entry(row, col) * x.entry(0, col));\n }\n x.set_entry(0, row, x.entry(0, row) / U.entry(row, row));\n }\n\n return x;\n }\n\n /**\n * {@link L}{@link U} decomposition of the Matrix {@link A}. Creates two matrices, so that the dot product LU equals A.\n * @param {Matrix} A\n * @returns {{L: Matrix, U: Matrix}} result - Returns the left triangle matrix {@link L} and the upper triangle matrix {@link U}.\n */\n static LU(A) {\n const rows = A.shape[0];\n const L = new Matrix(rows, rows, \"zeros\");\n const U = new Matrix(rows, rows, \"identity\");\n\n for (let j = 0; j < rows; ++j) {\n for (let i = j; i < rows; ++i) {\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(i, k) * U.entry(k, j);\n }\n L.set_entry(i, j, A.entry(i, j) - sum);\n }\n for (let i = j; i < rows; ++i) {\n if (L.entry(j, j) === 0) {\n return undefined;\n }\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(j, k) * U.entry(k, i);\n }\n U.set_entry(j, i, (A.entry(j, i) - sum) / L.entry(j, j));\n }\n }\n\n return { L: L, U: U };\n }\n\n /**\n * Computes the determinante of {@link A}, by using the LU decomposition of {@link A}.\n * @param {Matrix} A\n * @returns {Number} det - Returns the determinate of the Matrix {@link A}.\n */\n static det(A) {\n const rows = A.shape[0];\n const { L, U } = Matrix.LU(A);\n const L_diag = L.diag;\n const U_diag = U.diag;\n let det = L_diag[0] * U_diag[0];\n for (let row = 1; row < rows; ++row) {\n det *= L_diag[row] * U_diag[row];\n }\n return det;\n }\n\n /**\n * Computes the {@link k} components of the SVD decomposition of the matrix {@link M}\n * @param {Matrix} M\n * @param {int} [k=2]\n * @returns {{U: Matrix, Sigma: Matrix, V: Matrix}}\n */\n static SVD(M, k = 2) {\n const MT = M.T;\n let MtM = MT.dot(M);\n let MMt = M.dot(MT);\n let { eigenvectors: V, eigenvalues: Sigma } = simultaneous_poweriteration(MtM, k);\n let { eigenvectors: U } = simultaneous_poweriteration(MMt, k);\n return { U: U, Sigma: Sigma.map((sigma) => Math.sqrt(sigma)), V: V };\n\n //Algorithm 1a: Householder reduction to bidiagonal form:\n /* const [m, n] = A.shape;\n let U = new Matrix(m, n, (i, j) => i == j ? 1 : 0);\n console.log(U.to2dArray)\n let V = new Matrix(n, m, (i, j) => i == j ? 1 : 0);\n console.log(V.to2dArray)\n let B = Matrix.bidiagonal(A.clone(), U, V);\n console.log(U,V,B)\n return { U: U, \"Sigma\": B, V: V }; */\n }\n}\n","import { linspace, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @memberof module:utils\n * @alias Randomizer\n */\nexport class Randomizer {\n /**\n * Mersenne Twister random number generator.\n * @constructor\n * @param {Number} [_seed=new Date().getTime()] - The seed for the random number generator. If _seed == null then the actual time gets used as seed.\n * @see https://github.com/bmurray7/mersenne-twister-examples/blob/master/javascript-mersenne-twister.js\n */\n constructor(_seed) {\n this._N = 624;\n this._M = 397;\n this._MATRIX_A = 0x9908b0df;\n this._UPPER_MASK = 0x80000000;\n this._LOWER_MASK = 0x7fffffff;\n this._mt = new Array(this._N);\n this._mti = this.N + 1;\n\n this.seed = _seed || new Date().getTime();\n return this;\n }\n\n set seed(_seed) {\n this._seed = _seed;\n let mt = this._mt;\n\n mt[0] = _seed >>> 0;\n for (this._mti = 1; this._mti < this._N; this._mti += 1) {\n let mti = this._mti;\n let s = mt[mti - 1] ^ (mt[mti - 1] >>> 30);\n mt[mti] = ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253 + mti;\n mt[mti] >>>= 0;\n }\n }\n\n /**\n * Returns the seed of the random number generator.\n * @returns {Number} - The seed.\n */\n get seed() {\n return this._seed;\n }\n\n /**\n * Returns a float between 0 and 1.\n * @returns {Number} - A random number between [0, 1]\n */\n get random() {\n return this.random_int * (1.0 / 4294967296.0);\n }\n\n /**\n * Returns an integer between 0 and MAX_INTEGER.\n * @returns {Integer} - A random integer.\n */\n get random_int() {\n let y,\n mag01 = new Array(0x0, this._MATRIX_A);\n if (this._mti >= this._N) {\n let kk;\n\n /* if (this._mti == this._N + 1) {\n this.seed = 5489;\n } */\n\n let N_M = this._N - this._M;\n let M_N = this._M - this._N;\n\n for (kk = 0; kk < N_M; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + this._M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (; kk < this._N - 1; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + M_N] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n\n y = (this._mt[this._N - 1] & this._UPPER_MASK) | (this._mt[0] & this._LOWER_MASK);\n this._mt[this._N - 1] = this._mt[this._M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this._mti = 0;\n }\n\n y = this._mt[(this._mti += 1)];\n y ^= y >>> 11;\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= y >>> 18;\n\n return y >>> 0;\n }\n\n /**\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n choice(A, n) {\n if (A instanceof Matrix) {\n let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A.row(d));\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let rows = A.length;\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A[d]);\n }\n }\n\n /**\n * @static\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @param {Number} seed - The seed for the random number generator.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n static choice(A, n, seed = 1212) {\n const R = new Randomizer(seed);\n return R.choice(A, n);\n /* let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let rand = new Randomizer(seed);\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = rand.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n //return result;\n //return new Matrix(n, cols, (row, col) => A.entry(sample[row], col))\n return sample.map((d) => A.row(d)); */\n }\n}\n","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias max\n * @param {Array} values \n * @returns {Number}\n */\nexport default function (values) {\n let max;\n for (const value of values) {\n if (value != null && (max < value || (max === undefined && value >= value))) {\n max = value;\n }\n }\n return max;\n}","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias min\n * @param {Array} values\n * @returns {Number}\n */\nexport default function (values) {\n let min;\n for (const value of values) {\n if (value != null && (min > value || (min === undefined && value <= value))) {\n min = value;\n }\n }\n return min;\n}","/**\n * @class\n * @alias Heap\n */\nexport class Heap {\n /**\n * A heap is a datastructure holding its elements in a specific way, so that the top element would be the first entry of an ordered list.\n * @constructor\n * @memberof module:datastructure\n * @alias Heap\n * @param {Array=} elements - Contains the elements for the Heap. {@link elements} can be null.\n * @param {Function} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(\"min\"|\"max\"|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n * @see {@link https://en.wikipedia.org/wiki/Binary_heap}\n */\n constructor(elements = null, accessor = d => d, comparator = \"min\") {\n if (elements) {\n return Heap.heapify(elements, accessor, comparator);\n } else {\n this._accessor = accessor;\n this._container = [];\n if (comparator == \"min\") {\n this._comparator = (a, b) => a < b;\n } else if (comparator == \"max\") {\n this._comparator = (a, b) => a > b;\n } else {\n this._comparator = comparator;\n }\n return this\n }\n }\n\n /**\n * Creates a Heap from an Array\n * @param {Array|Set} elements - Contains the elements for the Heap.\n * @param {Function=} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(String=|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n */\n static heapify(elements, accessor = d => d, comparator = \"min\") {\n const heap = new Heap(null, accessor, comparator);\n const container = heap._container;\n for (const e of elements) {\n container.push({\n \"element\": e,\n \"value\": accessor(e),\n });\n }\n for (let i = Math.floor((elements.length / 2) - 1); i >= 0; --i) {\n heap._heapify_down(i);\n }\n return heap;\n }\n\n /**\n * Swaps elements of container array.\n * @private\n * @param {Number} index_a \n * @param {Number} index_b \n */\n _swap(index_a, index_b) {\n const container = this._container;\n [container[index_b], container[index_a]] = [container[index_a], container[index_b]];\n return;\n }\n\n /**\n * @private\n */\n _heapify_up() {\n const container = this._container;\n let index = container.length - 1;\n while (index > 0) {\n let parentIndex = Math.floor((index - 1) / 2);\n if (!this._comparator(container[index].value, container[parentIndex].value)) {\n break;\n } else {\n this._swap(parentIndex, index)\n index = parentIndex;\n }\n }\n }\n\n /**\n * Pushes the element to the heap.\n * @param {} element\n * @returns {Heap}\n */\n push(element) {\n const value = this._accessor(element);\n //const node = new Node(element, value);\n const node = {\"element\": element, \"value\": value};\n this._container.push(node);\n this._heapify_up();\n return this;\n }\n\n /**\n * @private\n * @param {Number} [start_index = 0] \n */\n _heapify_down(start_index=0) {\n const container = this._container;\n const comparator = this._comparator;\n const length = container.length;\n let left = 2 * start_index + 1;\n let right = 2 * start_index + 2;\n let index = start_index;\n if (index > length) throw \"index higher than length\"\n if (left < length && comparator(container[left].value, container[index].value)) {\n index = left;\n }\n if (right < length && comparator(container[right].value, container[index].value)) {\n index = right;\n }\n if (index !== start_index) {\n this._swap(start_index, index);\n this._heapify_down(index);\n }\n }\n\n /**\n * Removes and returns the top entry of the heap.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n pop() {\n const container = this._container;\n if (container.length === 0) {\n return null;\n } else if (container.length === 1) {\n return container.pop();\n }\n this._swap(0, container.length - 1);\n const item = container.pop();\n this._heapify_down();\n return item;\n }\n\n /**\n * Returns the top entry of the heap without removing it.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n get first() {\n return this._container.length > 0 ? this._container[0] : null;\n }\n\n\n /**\n * Yields the raw data\n * @yields {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n * iterate() {\n for (let i = 0, n = this._container.length; i < n; ++i) {\n yield this._container[i].element;\n }\n }\n\n /**\n * Returns the heap as ordered array.\n * @returns {Array} Array consisting the elements ordered by {@link comparator}.\n */\n toArray() {\n return this.data()\n .sort((a,b) => this._comparator(a, b) ? -1 : 0)\n }\n\n /**\n * Returns elements of container array.\n * @returns {Array} Array consisting the elements.\n */\n data() {\n return this._container\n .map(d => d.element)\n }\n\n /**\n * Returns the container array.\n * @returns {Array} The container array.\n */\n raw_data() {\n return this._container;\n }\n\n /**\n * The size of the heap.\n * @returns {Number}\n */\n get length() {\n return this._container.length;\n }\n\n /**\n * Returns false if the the heap has entries, true if the heap has no entries.\n * @returns {Boolean}\n */\n get empty() {\n return this.length === 0;\n }\n}","/**\n * @class\n * @alias DisjointSet\n * @see {@link https://en.wikipedia.org/wiki/Disjoint-set_data_structure}\n */\nexport class DisjointSet {\n /**\n * @constructor\n * @alias DisjointSet\n * @memberof module:datastructure\n * @param {Array=} elements \n * @returns {DisjointSet}\n */\n constructor(elements = null) {\n this._list = new Set();\n if (elements) {\n for (const e of elements) {\n this.make_set(e);\n }\n }\n return this;\n }\n\n make_set(x) {\n const list = this._list;\n if (!list.has(x)) {\n list.add(x);\n x.__disjoint_set = {};\n x.__disjoint_set.parent = x;\n x.__disjoint_set.children = new Set([x]);\n x.__disjoint_set.size = 1;\n }\n return this;\n }\n\n find(x) {\n const list = this._list;\n if (list.has(x)) {\n if (x.__disjoint_set.parent !== x) {\n x.__disjoint_set.children.add(...x);\n x.__disjoint_set.parent = this.find(x.__disjoint_set.parent);\n return x.__disjoint_set.parent;\n } else {\n return x;\n }\n } else {\n return null;\n }\n }\n\n union(x, y) {\n let node_x = this.find(x);\n let node_y = this.find(y);\n\n if (node_x === node_y) return this;\n if (node_x.__disjoint_set.size < node_y.__disjoint_set.size) [node_x, node_y] = [node_y, node_x];\n\n node_y.__disjoint_set.parent = node_x;\n // keep track of children?\n node_y.__disjoint_set.children.forEach(node_x.__disjoint_set.children.add, node_x.__disjoint_set.children);\n node_x.__disjoint_set.size += node_y.__disjoint_set.size;\n\n return this;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n/**\n * @class\n * @alias BallTree\n */\nexport class BallTree {\n /**\n * Generates a BallTree with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias BallTree\n * @param {Array=} elements - Elements which should be added to the BallTree\n * @param {Function} [metric = euclidean] metric to use: (a, b) => distance\n * @see {@link https://en.wikipedia.org/wiki/Ball_tree}\n * @see {@link https://github.com/invisal/noobjs/blob/master/src/tree/BallTree.js}\n * @returns {BallTree}\n */\n constructor(elements = null, metric = euclidean) {\n this._Node = class {\n constructor(pivot, child1=null, child2=null, radius=null) {\n this.pivot = pivot;\n this.child1 = child1;\n this.child2 = child2;\n this.radius = radius;\n }\n }\n this._Leaf = class {\n constructor(points) {\n this.points = points;\n }\n }\n this._metric = metric;\n if (elements) {\n this.add(elements);\n }\n return this;\n }\n\n /**\n * \n * @param {Array<*>} elements - new elements.\n * @returns {BallTree}\n */\n add(elements) {\n elements = elements.map((element, index) => {\n return {index: index, element: element}\n })\n this._root = this._construct(elements);\n return this;\n }\n\n /**\n * @private\n * @param {Array<*>} elements \n * @returns {Node} root of balltree.\n */\n _construct(elements) {\n if (elements.length === 1) {\n return new this._Leaf(elements);\n } else {\n let c = this._greatest_spread(elements);\n let sorted_elements = elements.sort((a, b) => a.element[c] - b.element[c]);\n let n = sorted_elements.length;\n let p_index = Math.floor(n / 2);\n let p = elements[p_index];\n let L = sorted_elements.slice(0, p_index);\n let R = sorted_elements.slice(p_index, n);\n let radius = Math.max(...elements.map(d => this._metric(p.element, d.element)));\n let B\n if (L.length > 0 && R.length > 0) { \n B = new this._Node(p, this._construct(L), this._construct(R), radius);\n } else {\n B = new this._Leaf(elements);\n }\n return B;\n }\n }\n\n /**\n * @private\n * @param {Node} B \n * @returns {Number}\n */\n _greatest_spread(B) {\n let d = B[0].element.length;\n let start = new Array(d);\n\n for (let i = 0; i < d; ++i) {\n start[i] = [Infinity, -Infinity];\n }\n\n let spread = B.reduce((acc, current) => {\n for (let i = 0; i < d; ++i) {\n acc[i][0] = Math.min(acc[i][0], current.element[i]);\n acc[i][1] = Math.max(acc[i][1], current.element[i]);\n }\n return acc;\n }, start);\n spread = spread.map(d => d[1] - d[0]);\n \n let c = 0;\n for (let i = 0; i < d; ++i) {\n c = spread[i] > spread[c] ? i : c;\n }\n return c;\n }\n\n /**\n * \n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n return this._search(t, k, new Heap(null, d => this._metric(d.element, t), \"max\"), this._root);\n }\n\n /**\n * @private\n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @param {Heap} Q - Heap consists of the currently found {@link k} nearest neighbors.\n * @param {Node|Leaf} B \n */\n _search(t, k, Q, B) {\n // B is Node\n if (Q.length >= k && B.pivot && B.radius && this._metric(t, B.pivot.element) - B.radius >= Q.first.value) {\n return Q;\n } \n if (B.child1) this._search(t, k, Q, B.child1);\n if (B.child2) this._search(t, k, Q, B.child2);\n \n // B is leaf\n if (B.points) {\n for (let i = 0, n = B.points.length; i < n; ++i) {\n let p = B.points[i];\n if (k > Q.length) {\n Q.push(p);\n } else {\n Q.push(p);\n Q.pop();\n }\n }\n }\n return Q;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KNN\n */\nexport class KNN {\n /**\n * Generates a KNN list with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias KNN\n * @param {Array=} elements - Elements which should be added to the KNN list\n * @param {Function|\"precomputed\"} [metric = euclidean] metric is either precomputed or a function to use: (a, b) => distance\n * @returns {KNN}\n */\n constructor(elements=null, metric=euclidean) {\n this._metric = metric;\n this._elements = elements instanceof Matrix ? elements : Matrix.from(elements);\n const N = this._elements.shape[0];\n if (metric === \"precomputed\") {\n this._D = this._elements.clone();\n } else {\n this._D = distance_matrix(this._elements, metric);\n }\n this.KNN = [];\n for (let row = 0; row < N; ++row) {\n const distances = this._D.row(row);\n const H = new Heap(null, d => d.value, \"min\");\n for (let j = 0; j < N; ++j) {\n H.push({\n value: distances[j],\n index: j,\n });\n }\n this.KNN.push(H);\n }\n }\n\n /**\n * \n * @param {Array|Number} t - query element or index.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n const metric = this._metric;\n const KNN = this.KNN;\n let H;\n if (Array.isArray(t)) {\n if (this._metric == \"precomputed\") {\n throw \"Search by query element is only possible when not using a precomputed distance matrix!\"\n } \n const elements = this._elements;\n const N = KNN.length;\n let nearest_element_index = null;\n let nearest_dist = Infinity;\n for (let i = 0; i < N; ++i) {\n const element = elements.row(i);\n const dist = metric(t, element);\n if (dist < nearest_dist) {\n nearest_element_index = i;\n nearest_dist = dist;\n }\n }\n H = KNN[nearest_element_index];\n } else if (Number.isInteger(t)) {\n H = KNN[t]\n }\n\n let result = []\n for (let i = 0; i < k; ++i) {\n result.push(H.pop())\n }\n result.forEach(res => H.push(res.element))\n return result\n } \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n\n/**\n * @class\n * @alias DR\n * @borrows DR#parameter as DR#para\n * @borrows DR#parameter as DR#p\n */\nexport class DR {\n /**\n * Takes the default parameters and seals them, remembers the type of input {@link X}, and initializes the random number generator.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias DR\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed value for the random number generator.\n * @returns {DR}\n */\n constructor(X, default_parameters, parameters) {\n this._parameters = Object.assign(Object.seal(default_parameters), parameters);\n if (Array.isArray(X)) {\n this._type = \"array\";\n this.X = Matrix.from(X);\n } else if (X instanceof Matrix) {\n this._type = \"matrix\";\n this.X = X;\n } else {\n throw new Error(\"No valid type for X!\");\n }\n [this._N, this._D] = this.X.shape;\n this._randomizer = new Randomizer(this._parameters.seed);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * Set and get parameters\n * @param {String} name - name of the parameter.\n * @param {any} [value = null] - value of the parameter to set.\n * @returns {DR|any} - On setting a parameter, this function returns the DR object. If value == null then return actual parameter value.\n * @example\n * const DR = new druid.TSNE(X, {d: 3}); // creates a new DR object, with parameter for d = 3.\n * DR.parameter(\"d\"); // returns 3,\n * DR.parameter(\"d\", 2); // sets parameter d to 2 and returns DR.\n */\n parameter(name, value = null) {\n if (!this._parameters.hasOwnProperty(name)) {\n throw new Error(`${name} is not a valid parameter!`);\n }\n if (value !== null) {\n this._parameters[name] = value;\n this._is_initialized = false;\n return this;\n } else {\n return this._parameters[name];\n }\n }\n\n para(name, value = null) {\n return this.parameter(name, value);\n }\n\n p(name, value = null) {\n return this.parameter(name, value);\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} - Returns the projection.\n */\n transform() {\n this.check_init();\n return this.projection;\n }\n\n /**\n * Computes the projection.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n *generator() {\n return this.transform();\n }\n\n /**\n * If the respective DR method has an init function, call it before transform.\n * @returns {DR}\n */\n check_init() {\n if (!this._is_initialized && typeof this.init === \"function\") {\n this.init();\n this._is_initialized = true;\n }\n return this;\n }\n\n /**\n * @returns {Matrix|Array} Returns the projection.\n */\n get projection() {\n if (this.hasOwnProperty(\"Y\")) {\n this.check_init();\n return this._type === \"matrix\" ? this.Y : this.Y.to2dArray;\n } else {\n throw new Error(\"The dataset is not transformed yet!\");\n }\n }\n\n /**\n *\n * @param {...any} args - Arguments the transform method of the respective DR method takes.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Matrix|Array} - The dimensionality reduced dataset.\n */\n static transform(...args) {\n let dr = new this(...args);\n return dr.transform();\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n static async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n static *generator(...args) {\n const dr = new this(...args);\n const generator = dr.generator();\n for (const result of generator) {\n yield result;\n }\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias PCA\n * @augments DR\n */\nexport class PCA extends DR {\n /**\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias PCA\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @returns {PCA}\n */\n constructor(X, parameters) {\n super(X, { d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}. If parameter {@link A} is given, then project {@link A} with the principal components of {@link X}.\n * @param {null|Matrix|Array} [A = null] - If given, the data to project.\n * @returns {Matrix|Array} - The projected data.\n */\n transform(A = null) {\n const V = this.principal_components();\n if (A == null) {\n const X = this.X;\n this.Y = X.dot(V);\n return this.projection;\n } else if (Array.isArray(A)) {\n return Matrix.from(A).dot(V).asArray;\n } else if (A instanceof Matrix) {\n return A.dot(V);\n } else {\n throw new Error(\"No valid type for A!\");\n }\n }\n\n /**\n * Computes the {@link d} principal components of Matrix {@link X}.\n * @returns {Matrix}\n */\n principal_components() {\n if (this.V) {\n return this.V;\n }\n const { d, eig_args } = this._parameters;\n const X = this.X;\n const means = Matrix.from(X.meanCols);\n const X_cent = X.sub(means);\n const C = X_cent.transpose().dot(X_cent);\n const { eigenvectors: V } = simultaneous_poweriteration(C, d, eig_args);\n this.V = Matrix.from(V).transpose();\n return this.V;\n }\n\n static principal_components(X, parameters) {\n const dr = new this(X, parameters);\n return dr.principal_components();\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias MDS\n * @extends DR\n */\nexport class MDS extends DR {\n /**\n * Classical MDS.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias MDS\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}.\n * @returns {Matrix|Array}\n */\n transform() {\n const X = this.X;\n const rows = X.shape[0];\n const { d, metric, eig_args } = this._parameters;\n const A = metric === \"precomputed\" ? X : distance_matrix(X, metric);\n const ai_ = A.meanCols;\n const a_j = A.meanRows;\n const a__ = A.mean;\n\n this._d_X = A;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n\n return this.projection;\n }\n\n /**\n * @returns {Number} - the stress of the projection.\n */\n stress() {\n const N = this.X.shape[0];\n const Y = this.Y;\n const d_X = this._d_X;\n const d_Y = new Matrix();\n d_Y.shape = [\n N,\n N,\n (i, j) => {\n return i < j ? euclidean(Y.row(i), Y.row(j)) : d_Y.entry(j, i);\n },\n ];\n let top_sum = 0;\n let bottom_sum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n top_sum += Math.pow(d_X.entry(i, j) - d_Y.entry(i, j), 2);\n bottom_sum += Math.pow(d_X.entry(i, j), 2);\n }\n }\n return Math.sqrt(top_sum / bottom_sum);\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { DR } from \"./DR.js\";\nimport euclidean from \"../metrics/euclidean.js\";\n\n/**\n * @class\n * @alias ISOMAP\n * @extends DR\n */\nexport class ISOMAP extends DR {\n /**\n * Isometric feature mapping (ISOMAP).\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias ISOMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link ISOMAP} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2319}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(this._parameters.neighbors ?? Math.max(Math.floor(this.X.shape[0] / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const X = this.X;\n const rows = this._N;\n const { d, metric, eig_args, neighbors } = this._parameters;\n // TODO: make knn extern and parameter for constructor or transform?\n const D = new Matrix();\n D.shape = [rows, rows, (i, j) => (i <= j ? metric(X.row(i), X.row(j)) : D.entry(j, i))];\n const kNearestNeighbors = [];\n for (let i = 0; i < rows; ++i) {\n const row = [];\n for (let j = 0; j < rows; ++j) {\n row.push({\n index: j,\n distance: D.entry(i, j),\n });\n }\n const H = new Heap(row, (d) => d.distance, \"min\");\n kNearestNeighbors.push(H.toArray().slice(1, neighbors + 1));\n }\n\n /*D = dijkstra(kNearestNeighbors);*/\n // compute shortest paths\n // TODO: make extern\n /** @see {@link https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm} */\n const G = new Matrix(rows, rows, (i, j) => {\n const other = kNearestNeighbors[i].find((n) => n.index === j);\n return other ? other.distance : Infinity;\n });\n\n for (let i = 0; i < rows; ++i) {\n for (let j = 0; j < rows; ++j) {\n for (let k = 0; k < rows; ++k) {\n G.set_entry(i, j, Math.min(G.entry(i, j), G.entry(i, k) + G.entry(k, j)));\n }\n }\n }\n\n let ai_ = new Float64Array(rows);\n let a_j = new Float64Array(rows);\n let a__ = 0;\n const A = new Matrix(rows, rows, (i, j) => {\n let val = G.entry(i, j);\n val = val === Infinity ? 0 : val;\n ai_[i] += val;\n a_j[j] += val;\n a__ += val;\n return val;\n });\n\n ai_ = ai_.map((v) => v / rows);\n a_j = a_j.map((v) => v / rows);\n a__ /= rows ** 2;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n // compute d eigenvectors\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n/**\n * @class\n * @alias FASTMAP\n * @extends DR\n */\nexport class FASTMAP extends DR {\n /**\n * FastMap: a fast algorithm for indexing, data-mining and visualization of traditional and multimedia datasets\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias FASTMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the dimensionality of the projection.\n * @returns {FASTMAP}\n * @see {@link https://doi.org/10.1145/223784.223812}\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n * Chooses two points which are the most distant in the actual projection.\n * @private\n * @param {Function} dist\n * @returns {Array} An array consisting of first index, second index, and distance between the two points.\n */\n _choose_distant_objects(dist) {\n const X = this.X;\n const N = X.shape[0];\n let a_index = (this._randomizer.random_int % N) - 1;\n let b_index = null;\n let max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n if (d_ai > max_dist) {\n max_dist = d_ai;\n b_index = i;\n }\n }\n max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_bi = dist(b_index, i);\n if (d_bi > max_dist) {\n max_dist = d_bi;\n a_index = i;\n }\n }\n return [a_index, b_index, max_dist];\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} The {@link d}-dimensional projection of the data matrix {@link X}.\n */\n transform() {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric } = this._parameters;\n const Y = new Matrix(N, d, 0);\n let dist = (a, b) => metric(X.row(a), X.row(b));\n\n for (let _col = 0; _col < d; ++_col) {\n let old_dist = dist;\n // choose pivot objects\n const [a_index, b_index, d_ab] = this._choose_distant_objects(dist);\n if (d_ab !== 0) {\n // project the objects on the line (O_a, O_b)\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n const d_bi = dist(b_index, i);\n const y_i = (d_ai ** 2 + d_ab ** 2 - d_bi ** 2) / (2 * d_ab);\n Y.set_entry(i, _col, y_i);\n }\n // consider the projections of the objects on a\n // hyperplane perpendicluar to the line (a, b);\n // the distance function D'() between two\n // projections is given by Eq.4\n dist = (a, b) => Math.sqrt(old_dist(a, b) ** 2 - (Y.entry(a, _col) - Y.entry(b, _col)) ** 2);\n }\n }\n // return embedding.\n this.Y = Y;\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LDA\n * @extends DR\n */\nexport class LDA extends DR {\n /**\n * Linear Discriminant Analysis.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LDA\n * @param {Matrix} X - The high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Array} parameters.labels - The labels / classes for each data point.\n * @param {number} [parameters.d = 2] - The dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://onlinelibrary.wiley.com/doi/10.1111/j.1469-1809.1936.tb02137.x}\n */\n constructor(X, parameters) {\n super(X, { labels: null, d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, cols] = X.shape;\n const { d, labels, eig_args } = this._parameters;\n if (labels === null || labels.length != rows) {\n throw new Error(\"LDA needs parameter label to every datapoint to work!\");\n }\n const unique_labels = {};\n let label_id = 0;\n labels.forEach((l, i) => {\n if (l in unique_labels) {\n unique_labels[l].count++;\n unique_labels[l].rows.push(X.row(i));\n } else {\n unique_labels[l] = {\n id: label_id++,\n count: 1,\n rows: [X.row(i)],\n };\n }\n });\n\n // create X_mean and vector means;\n const X_mean = X.mean;\n const V_mean = new Matrix(label_id, cols);\n for (const label in unique_labels) {\n const V = Matrix.from(unique_labels[label].rows);\n const v_mean = V.meanCols;\n for (let j = 0; j < cols; ++j) {\n V_mean.set_entry(unique_labels[label].id, j, v_mean[j]);\n }\n }\n // scatter_between\n let S_b = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j] - X_mean);\n const N = unique_labels[label].count;\n S_b = S_b.add(m.dot(m.transpose()).mult(N));\n }\n\n // scatter_within\n let S_w = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j]);\n const R = unique_labels[label].rows;\n for (let i = 0, n = unique_labels[label].count; i < n; ++i) {\n const row_v = new Matrix(cols, 1, (j, _) => R[i][j] - m.entry(j, 0));\n S_w = S_w.add(row_v.dot(row_v.transpose()));\n }\n }\n\n let { eigenvectors: V } = simultaneous_poweriteration(S_w.inverse().dot(S_b), d, eig_args);\n V = Matrix.from(V).transpose();\n this.Y = X.dot(V);\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { k_nearest_neighbors } from \"../matrix/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LLE\n * @extends DR\n */\nexport class LLE extends DR {\n /**\n * Locally Linear Embedding.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LLE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} neighbors - the label / class of each data point.\n * @param {Number} [d = 2] - the dimensionality of the projection.\n * @param {Function} [metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [seed = 1212] - the dimensionality of the projection.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2323}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const rows = this._N;\n const cols = this._D;\n const { neighbors, d, eig_args, metric } = this._parameters;\n const nN = k_nearest_neighbors(X, neighbors, metric);\n const O = new Matrix(neighbors, 1, 1);\n const W = new Matrix(rows, rows);\n\n for (let row = 0; row < rows; ++row) {\n const nN_row = nN[row];\n const Z = new Matrix(neighbors, cols, (i, j) => X.entry(nN_row[i].j, j) - X.entry(row, j));\n const C = Z.dot(Z.T);\n if (neighbors > cols) {\n const C_trace = neumair_sum(C.diag) / 1000;\n for (let j = 0; j < neighbors; ++j) {\n C.set_entry(j, j, C.entry(j, j) + C_trace);\n }\n }\n // reconstruct;\n let w = Matrix.solve_CG(C, O, this._randomizer);\n w = w.divide(w.sum);\n for (let j = 0; j < neighbors; ++j) {\n W.set_entry(row, nN_row[j].j, w.entry(j, 0));\n }\n }\n // comp embedding\n const I = new Matrix(rows, rows, \"identity\");\n const IW = I.sub(W);\n const M = IW.T.dot(IW);\n const { eigenvectors: V } = simultaneous_poweriteration(M.T.inverse(), d + 1, eig_args);\n this.Y = Matrix.from(V.slice(1, 1 + d)).T;\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix, k_nearest_neighbors } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LTSA\n * @extends DR\n */\nexport class LTSA extends DR {\n /**\n * Local Tangent Space Alignment\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LTSA\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link LTSA} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://epubs.siam.org/doi/abs/10.1137/S1064827502419154}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n if (this._D <= this.parameter(\"d\")) {\n throw new Error(`Dimensionality of X (D = ${this._D}) must be greater than the required dimensionality of the result (d = ${this.parameter(\"d\")})!`);\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, D] = X.shape;\n const { d, neighbors, metric, eig_args } = this._parameters;\n // 1.1 determine k nearest neighbors\n const nN = k_nearest_neighbors(X, neighbors, metric);\n // center matrix\n const O = new Matrix(D, D, \"center\");\n const B = new Matrix(rows, rows, 0);\n\n for (let row = 0; row < rows; ++row) {\n // 1.2 compute the d largest eigenvectors of the correlation matrix\n const I_i = [row, ...nN[row].map((n) => n.j)];\n let X_i = Matrix.from(I_i.map((n) => X.row(n)));\n // center X_i\n X_i = X_i.dot(O);\n // correlation matrix\n const C = X_i.dot(X_i.transpose());\n const { eigenvectors: g } = simultaneous_poweriteration(C, d, eig_args);\n //g.push(linspace(0, k).map(_ => 1 / Math.sqrt(k + 1)));\n const G_i_t = Matrix.from(g);\n // 2. Constructing alignment matrix\n const W_i = G_i_t.transpose()\n .dot(G_i_t)\n .add(1 / Math.sqrt(neighbors + 1));\n for (let i = 0; i < neighbors + 1; ++i) {\n for (let j = 0; j < neighbors + 1; ++j) {\n B.set_entry(I_i[i], I_i[j], B.entry(I_i[i], I_i[j]) - (i === j ? 1 : 0) + W_i.entry(i, j));\n }\n }\n }\n\n // 3. Aligning global coordinates\n const { eigenvectors: Y } = simultaneous_poweriteration(B, d + 1, eig_args);\n this.Y = Matrix.from(Y.slice(1)).transpose();\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TSNE\n * @extends DR\n */\nexport class TSNE extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TSNE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.perplexity = 50] - perplexity.\n * @param {Number} [parameters.epsilon = 10] - learning parameter.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TSNE}\n */\n constructor(X, parameters) {\n super(X, { perplexity: 50, epsilon: 10, d: 2, metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._iter = 0;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => this._randomizer.random);\n return this;\n }\n\n /**\n *\n * @param {Matrix} distance_matrix - accepts a precomputed distance matrix\n * @returns {TSNE}\n */\n init() {\n // init\n const Htarget = Math.log(this.parameter(\"perplexity\"));\n const N = this._N;\n const D = this._D;\n const {metric} = this._parameters;\n const X = this.X;\n let Delta;\n if (metric ==\"precomputed\") {\n Delta = druid.Matrix.from(X);\n } else {\n Delta = new Matrix(N, N);\n for (let i = 0; i < N; ++i) {\n const X_i = X.row(i);\n for (let j = i + 1; j < N; ++j) {\n const distance = metric(X_i, X.row(j));\n Delta.set_entry(i, j, distance);\n Delta.set_entry(j, i, distance);\n }\n }\n }\n\n const P = new Matrix(N, N, \"zeros\");\n\n this._ystep = new Matrix(N, D, \"zeros\");\n this._gains = new Matrix(N, D, 1);\n\n // search for fitting sigma\n let prow = new Float64Array(N)\n const tol = 1e-4;\n const maxtries = 50;\n for (let i = 0; i < N; ++i) {\n let betamin = -Infinity;\n let betamax = Infinity;\n let beta = 1;\n let done = false;\n\n let num = 0;\n while (!done) {\n let psum = 0;\n for (let j = 0; j < N; ++j) {\n let pj = Math.exp(-Delta.entry(i, j) * beta);\n if (i === j) pj = 0;\n prow[j] = pj;\n psum += pj;\n }\n let Hhere = 0;\n for (let j = 0; j < N; ++j) {\n let pj = psum === 0 ? 0 : prow[j] / psum;\n prow[j] = pj;\n if (pj > 1e-7) {\n Hhere -= pj * Math.log(pj);\n }\n }\n if (Hhere > Htarget) {\n betamin = beta;\n beta = betamax === Infinity ? beta * 2 : (beta + betamax) / 2;\n } else {\n betamax = beta;\n beta = betamin === -Infinity ? beta / 2 : (beta + betamin) / 2;\n }\n ++num;\n if (Math.abs(Hhere - Htarget) < tol) done = true;\n if (num >= maxtries) done = true;\n }\n\n for (let j = 0; j < N; ++j) {\n P.set_entry(i, j, prow[j]);\n }\n }\n\n //compute probabilities\n const Pout = new Matrix(N, N, \"zeros\");\n const N2 = N * 2;\n for (let i = 0; i < N; ++i) {\n for (let j = i; j < N; ++j) {\n const p = Math.max((P.entry(i, j) + P.entry(j, i)) / N2, 1e-100);\n Pout.set_entry(i, j, p);\n Pout.set_entry(j, i, p);\n }\n }\n this._P = Pout;\n return this;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n transform(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n *generator(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * performs a optimization step\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const P = this._P;\n const ystep = this._ystep;\n const gains = this._gains;\n const N = this._N;\n const { d: dim, epsilon} = this._parameters;\n let Y = this.Y;\n\n //calc cost gradient;\n const pmul = iter < 100 ? 4 : 1;\n\n // compute Q dist (unnormalized)\n const Qu = new Matrix(N, N, \"zeros\");\n let qsum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dsum = 0;\n for (let d = 0; d < dim; ++d) {\n const dhere = Y.entry(i, d) - Y.entry(j, d);\n dsum += dhere * dhere;\n }\n const qu = 1 / (1 + dsum);\n Qu.set_entry(i, j, qu);\n Qu.set_entry(j, i, qu);\n qsum += 2 * qu;\n }\n }\n\n // normalize Q dist\n const Q = new Matrix(N, N, 0);\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n const val = Math.max(Qu.entry(i, j) / qsum, 1e-100);\n Q.set_entry(i, j, val);\n Q.set_entry(j, i, val);\n }\n }\n\n const grad = new Matrix(N, dim, \"zeros\");\n for (let i = 0; i < N; ++i) {\n for (let j = 0; j < N; ++j) {\n const premult = 4 * (pmul * P.entry(i, j) - Q.entry(i, j)) * Qu.entry(i, j);\n for (let d = 0; d < dim; ++d) {\n grad.set_entry(i, d, grad.entry(i, d) + premult * (Y.entry(i, d) - Y.entry(j, d)));\n }\n }\n }\n\n // perform gradient step\n let ymean = new Float64Array(dim);\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const gid = grad.entry(i, d);\n const sid = ystep.entry(i, d);\n const gainid = gains.entry(i, d);\n\n let newgain = Math.sign(gid) === Math.sign(sid) ? gainid * 0.8 : gainid + 0.2;\n if (newgain < 0.01) newgain = 0.01;\n gains.set_entry(i, d, newgain);\n\n const momval = iter < 250 ? 0.5 : 0.8;\n const newsid = momval * sid - epsilon * newgain * gid;\n ystep.set_entry(i, d, newsid);\n\n Y.set_entry(i, d, Y.entry(i, d) + newsid);\n ymean[d] += Y.entry(i, d);\n }\n }\n\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < 2; ++d) {\n Y.set_entry(i, d, Y.entry(i, d) - ymean[d] / N);\n }\n }\n\n return this.Y;\n }\n}\n","/**\n *\n * @memberof module:optimization\n * @alias powell\n * @param {Function} f\n * @param {Array} x0\n * @param {Number} [max_iter = 300]\n * @returns {Array}\n * @see http://optimization-js.github.io/optimization-js/optimization.js.html#line438\n */\nexport default function (f, x0, max_iter = 300) {\n const epsilon = 1e-2;\n const n = x0.length;\n let alpha = 1e-3;\n let pfx = 10000;\n let x = x0.slice();\n let fx = f(x);\n let convergence = false;\n\n while (max_iter-- >= 0 && !convergence) {\n convergence = true;\n for (let i = 0; i < n; ++i) {\n x[i] += 1e-6;\n let fxi = f(x);\n x[i] -= 1e-6;\n let dx = (fxi - fx) / 1e-6;\n if (Math.abs(dx) > epsilon) {\n convergence = false;\n }\n x[i] -= alpha * dx;\n fx = f(x);\n }\n alpha *= pfx >= fx ? 1.05 : 0.4;\n pfx = fx;\n }\n return x;\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean, euclidean_squared } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { linspace } from \"../matrix/index.js\";\nimport { powell } from \"../optimization/index.js\";\nimport { DR } from \"./DR.js\";\nimport { max } from \"../util/index.js\";\nimport { KNN } from \"../knn/index.js\";\n\n/**\n * @class\n * @alias UMAP\n * @extends DR\n */\nexport class UMAP extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias UMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.n_neighbors = 15] - size of the local neighborhood.\n * @param {Number} [parameters.local_connectivity = 1] - number of nearest neighbors connected in the local neighborhood.\n * @param {Number} [parameters.min_dist = 1] - controls how tightly points get packed together.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points in the high-dimensional space.\n * @param {Number} [parameters._spread = 1] - The effective scale of embedded points. (In combination with {@link parameters.min_dist})\n * @param {Number} [parameters._set_op_mix_ratio = 1] - Interpolate between union and intersection.\n * @param {Number} [parameters._repulsion_strength = 1] - Weighting applied to negative samples.\n * @param {Number} [parameters._negative_sample_rate = 5] - The number of negative samples per positive sample.\n * @param {Number} [parameters._n_epochs = 350] - The number of training epochs.\n * @param {Number} [parameter._initial_alpha = 1] - The initial learning rate for the optimization.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {UMAP}\n */\n constructor(X, parameters) {\n super(X, { n_neighbors: 15, local_connectivity: 1, min_dist: 1, d: 2, metric: euclidean, seed: 1212, _spread: 1, _set_op_mix_ratio: 1, _repulsion_strength: 1, _negative_sample_rate: 5, _n_epochs: 350, _initial_alpha: 1 }, parameters);\n [this._N, this._D] = this.X.shape;\n /* let n_neighbors = Math.min(this._N - 1, parameters.n_neighbors);\n this.parameter(\"n_neighbors\", n_neighbors);\n this.parameter(\"local_connectivity\", Math.min(this.parameter(\"local_connectivity\"), n_neighbors - 1)); */\n if (this.parameter(\"n_neighbors\") > this._N) {\n throw new Error(`Parameter n_neighbors (=${this.parameter(\"n_neighbors\")}) needs to be smaller than dataset size (N=${this._N})!`);\n }\n if (this.parameter(\"local_connectivity\") > this.parameter(\"n_neighbors\")) {\n throw new Error(`Parameter local_connectivity (=${this.parameter(\"local_connectivity\")}) needs to be smaller than parameter n_neighbors (=${this.parameter(\"n_neighbors\")})`);\n }\n this._iter = 0;\n const randomizer = this._randomizer;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => randomizer.random);\n return this;\n }\n\n /**\n * @private\n * @param {Number} spread\n * @param {Number} min_dist\n * @returns {Array}\n */\n _find_ab_params(spread, min_dist) {\n const curve = (x, a, b) => 1 / (1 + a * Math.pow(x, 2 * b));\n const xv = linspace(0, spread * 3, 300);\n const yv = linspace(0, spread * 3, 300);\n\n for (let i = 0, n = xv.length; i < n; ++i) {\n const xv_i = xv[i];\n yv[i] = xv_i < min_dist ? 1 : Math.exp(-(xv_i - min_dist) / spread);\n }\n\n const err = (p) => {\n const error = linspace(1, 300).map((_, i) => yv[i] - curve(xv[i], p[0], p[1]));\n return Math.sqrt(neumair_sum(error.map((e) => e * e)));\n };\n\n return powell(err, [1, 1]);\n }\n\n /**\n * @private\n * @param {Array} distances\n * @param {Array} sigmas\n * @param {Array} rhos\n * @returns {Array}\n */\n _compute_membership_strengths(distances, sigmas, rhos) {\n for (let i = 0, n = distances.length; i < n; ++i) {\n for (let j = 0, m = distances[i].length; j < m; ++j) {\n const v = distances[i][j].value - rhos[i];\n distances[i][j].value = v > 0 ? Math.exp(-v / sigmas[i]) : 1;\n }\n }\n return distances;\n }\n\n /**\n * @private\n * @param {KNN|BallTree} knn\n * @param {Number} k\n * @returns {Object}\n */\n _smooth_knn_dist(knn, k) {\n const SMOOTH_K_TOLERANCE = 1e-5;\n const MIN_K_DIST_SCALE = 1e-3;\n const n_iter = 64;\n const { local_connectivity, metric } = this._parameters;\n const target = Math.log2(k);\n const rhos = [];\n const sigmas = [];\n const X = this.X;\n const N = X.shape[0];\n //const distances = [...X].map(x_i => knn.search(x_i, k).raw_data().reverse());\n\n const distances = [];\n if (metric === \"precomputed\") {\n for (let i = 0; i < N; ++i) {\n distances.push(knn.search(i, k).reverse());\n }\n } else {\n for (const x_i of X) {\n distances.push(knn.search(x_i, k).raw_data().reverse());\n }\n }\n\n for (let i = 0; i < N; ++i) {\n let lo = 0;\n let hi = Infinity;\n let mid = 1;\n\n const search_result = distances[i];\n const non_zero_dist = search_result.filter((d) => d.value > 0);\n const non_zero_dist_length = non_zero_dist.length;\n if (non_zero_dist_length >= local_connectivity) {\n const index = Math.floor(local_connectivity);\n const interpolation = local_connectivity - index;\n if (index > 0) {\n rhos.push(non_zero_dist[index - 1]);\n if (interpolation > SMOOTH_K_TOLERANCE) {\n rhos[i].value += interpolation * (non_zero_dist[index].value - non_zero_dist[index - 1]);\n }\n } else {\n rhos[i].value = interpolation * non_zero_dist[0].value;\n }\n } else if (non_zero_dist_length > 0) {\n rhos[i] = non_zero_dist[non_zero_dist_length - 1].value;\n }\n for (let x = 0; x < n_iter; ++x) {\n let psum = 0;\n for (let j = 0; j < k; ++j) {\n const d = search_result[j].value - rhos[i];\n psum += d > 0 ? Math.exp(-(d / mid)) : 1;\n }\n if (Math.abs(psum - target) < SMOOTH_K_TOLERANCE) {\n break;\n }\n if (psum > target) {\n [hi, mid] = [mid, (lo + hi) / 2];\n } else {\n if (hi === Infinity) {\n [lo, mid] = [mid, mid * 2];\n } else {\n [lo, mid] = [mid, (lo + hi) / 2];\n }\n }\n }\n sigmas[i] = mid;\n\n const mean_ithd = search_result.reduce((a, b) => a + b.value, 0) / search_result.length;\n //let mean_d = null;\n if (rhos[i] > 0) {\n if (sigmas[i] < MIN_K_DIST_SCALE * mean_ithd) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_ithd;\n }\n } else {\n const mean_d = distances.reduce((acc, res) => acc + res.reduce((a, b) => a + b.value, 0) / res.length);\n if (sigmas[i] > MIN_K_DIST_SCALE * mean_d) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_d;\n }\n }\n }\n return {\n distances: distances,\n sigmas: sigmas,\n rhos: rhos,\n };\n }\n\n /**\n * @private\n * @param {Matrix} X\n * @param {Number} n_neighbors\n * @returns {Matrix}\n */\n _fuzzy_simplicial_set(X, n_neighbors) {\n const N = X.shape[0];\n const { metric, _set_op_mix_ratio } = this._parameters;\n const knn = metric === \"precomputed\" ? new KNN(X, \"precomputed\") : new BallTree(X.to2dArray, metric);\n let { distances, sigmas, rhos } = this._smooth_knn_dist(knn, n_neighbors);\n distances = this._compute_membership_strengths(distances, sigmas, rhos);\n const result = new Matrix(N, N, \"zeros\");\n for (let i = 0; i < N; ++i) {\n const distances_i = distances[i];\n for (let j = 0; j < distances_i.length; ++j) {\n result.set_entry(i, distances_i[j].element.index, distances_i[j].value);\n }\n }\n\n const transposed_result = result.T;\n const prod_matrix = result.mult(transposed_result);\n return result\n .add(transposed_result)\n .sub(prod_matrix)\n .mult(_set_op_mix_ratio)\n .add(prod_matrix.mult(1 - _set_op_mix_ratio));\n }\n\n /**\n * @private\n * @param {Number} n_epochs\n * @returns {Array}\n */\n _make_epochs_per_sample(n_epochs) {\n const weights = this._weights;\n const result = new Float32Array(weights.length).fill(-1);\n const weights_max = max(weights);\n const n_samples = weights.map((w) => n_epochs * (w / weights_max));\n for (let i = 0; i < result.length; ++i) if (n_samples[i] > 0) result[i] = Math.round(n_epochs / n_samples[i]);\n return result;\n }\n\n /**\n * @private\n * @param {Matrix} graph\n * @returns {Object}\n */\n _tocoo(graph) {\n const rows = [];\n const cols = [];\n const data = [];\n const [rows_n, cols_n] = graph.shape;\n for (let row = 0; row < rows_n; ++row) {\n for (let col = 0; col < cols_n; ++col) {\n const entry = graph.entry(row, col);\n if (entry !== 0) {\n rows.push(row);\n cols.push(col);\n data.push(entry);\n }\n }\n }\n return {\n rows: rows,\n cols: cols,\n data: data,\n };\n }\n\n /**\n * Computes all necessary\n * @returns {UMAP}\n */\n init() {\n const { _spread, min_dist, n_neighbors, _n_epochs, _negative_sample_rate } = this._parameters;\n const [a, b] = this._find_ab_params(_spread, min_dist);\n this._a = a;\n this._b = b;\n this._graph = this._fuzzy_simplicial_set(this.X, n_neighbors);\n const { rows, cols, data: weights } = this._tocoo(this._graph);\n this._head = rows;\n this._tail = cols;\n this._weights = weights;\n this._epochs_per_sample = this._make_epochs_per_sample(_n_epochs);\n this._epochs_per_negative_sample = this._epochs_per_sample.map((d) => d * _negative_sample_rate);\n this._epoch_of_next_sample = this._epochs_per_sample.slice();\n this._epoch_of_next_negative_sample = this._epochs_per_negative_sample.slice();\n return this;\n }\n\n graph() {\n this.check_init();\n return { cols: this._head, rows: this._tail, weights: this._weights };\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n transform(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n *generator(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * @private\n * @param {Number} x\n * @returns {Number}\n */\n _clip(x) {\n if (x > 4) return 4;\n if (x < -4) return -4;\n return x;\n }\n\n /**\n * performs the optimization step.\n * @private\n * @param {Matrix} head_embedding\n * @param {Matrix} tail_embedding\n * @param {Matrix} head\n * @param {Matrix} tail\n * @returns {Matrix}\n */\n _optimize_layout(head_embedding, tail_embedding, head, tail) {\n const randomizer = this._randomizer;\n const { _repulsion_strength, d: dim } = this._parameters;\n const { _alpha: alpha, _a: a, _b: b, _epochs_per_sample: epochs_per_sample, _epochs_per_negative_sample: epochs_per_negative_sample, _epoch_of_next_negative_sample: epoch_of_next_negative_sample, _epoch_of_next_sample: epoch_of_next_sample, _clip: clip } = this;\n const tail_length = tail.length;\n\n for (let i = 0, n = epochs_per_sample.length; i < n; ++i) {\n if (epoch_of_next_sample[i] <= this._iter) {\n const j = head[i];\n const k = tail[i];\n const current = head_embedding.row(j);\n const other = tail_embedding.row(k);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (-2 * a * b * Math.pow(dist, b - 1)) / (a * Math.pow(dist, b) + 1);\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(k, d, o);\n }\n epoch_of_next_sample[i] += epochs_per_sample[i];\n const n_neg_samples = (this._iter - epoch_of_next_negative_sample[i]) / epochs_per_negative_sample[i];\n for (let p = 0; p < n_neg_samples; ++p) {\n const k = randomizer.random_int % tail_length;\n const other = tail_embedding.row(tail[k]);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (2 * _repulsion_strength * b) / ((0.01 + dist) * (a * Math.pow(dist, b) + 1));\n } else if (j === k) {\n continue;\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(tail[k], d, o);\n }\n }\n epoch_of_next_negative_sample[i] += n_neg_samples * epochs_per_negative_sample[i];\n }\n }\n return head_embedding;\n }\n\n /**\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const Y = this.Y;\n const { _initial_alpha, _n_epochs } = this._parameters;\n this._alpha = _initial_alpha * (1 - iter / _n_epochs);\n this.Y = this._optimize_layout(Y, Y, this._head, this._tail);\n\n return this.Y;\n }\n}\n","import { Matrix, linspace } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { PCA } from \"./PCA.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TriMap\n * @extends DR\n */\nexport class TriMap extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TriMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.weight_adj = 500] - scaling factor.\n * @param {Number} [parameters.c = 5] - number of triplets multiplier.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.tol = 1e-8] -\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TriMap}\n * @see {@link https://arxiv.org/pdf/1910.00204v1.pdf}\n * @see {@link https://github.com/eamid/trimap}\n */\n constructor(X, parameters) {\n super(X, { weight_adj: 500, c: 5, d: 2, metric: euclidean, tol: 1e-8, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n *\n * @param {Matrix} [pca = null] - Initial Embedding (if null then PCA gets used).\n * @param {KNN} [knn = null] - KNN Object (if null then BallTree gets used).\n */\n init(pca = null, knn = null) {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric, c } = this._parameters;\n this.n_inliers = 2 * c;\n this.n_outliers = 1 * c;\n this.n_random = 1 * c;\n this.Y = pca || new PCA(X, d).transform();\n this.knn = knn || new BallTree(X.to2dArray, metric);\n const { triplets, weights } = this._generate_triplets(this.n_inliers, this.n_outliers, this.n_random);\n this.triplets = triplets;\n this.weights = weights;\n this.lr = (1000 * N) / triplets.shape[0];\n this.C = Infinity;\n this.vel = new Matrix(N, d, 0);\n this.gain = new Matrix(N, d, 1);\n return this;\n }\n\n /**\n * Generates {@link n_inliers} x {@link n_outliers} x {@link n_random} triplets.\n * @param {Number} n_inliers\n * @param {Number} n_outliers\n * @param {Number} n_random\n */\n _generate_triplets(n_inliers, n_outliers, n_random) {\n const { metric, weight_adj } = this._parameters;\n const X = this.X;\n const N = X.shape[0];\n const knn = this.knn;\n const n_extra = Math.min(n_inliers + 20, N);\n const nbrs = new Matrix(N, n_extra);\n const knn_distances = new Matrix(N, n_extra);\n for (let i = 0; i < N; ++i) {\n knn.search(X.row(i), n_extra + 1)\n .raw_data()\n .filter((d) => d.value != 0)\n .sort((a, b) => a.value - b.value)\n .forEach((d, j) => {\n nbrs.set_entry(i, j, d.element.index);\n knn_distances.set_entry(i, j, d.value);\n });\n }\n // scale parameter\n const sig = new Float64Array(N);\n for (let i = 0; i < N; ++i) {\n sig[i] = Math.max((knn_distances.entry(i, 3) + knn_distances.entry(i, 4) + knn_distances.entry(i, 5) + knn_distances.entry(i, 6)) / 4, 1e-10);\n }\n\n const P = this._find_p(knn_distances, sig, nbrs);\n\n let triplets = this._sample_knn_triplets(P, nbrs, n_inliers, n_outliers);\n let n_triplets = triplets.shape[0];\n const outlier_distances = new Float64Array(n_triplets);\n for (let i = 0; i < n_triplets; ++i) {\n const j = triplets.entry(i, 0);\n const k = triplets.entry(i, 2);\n outlier_distances[i] = metric(X.row(j), X.row(k));\n }\n let weights = this._find_weights(triplets, P, nbrs, outlier_distances, sig);\n\n if (n_random > 0) {\n const { random_triplets, random_weights } = this._sample_random_triplets(X, n_random, sig);\n triplets = triplets.concat(random_triplets, \"vertical\");\n weights = Float64Array.from([...weights, ...random_weights]);\n }\n n_triplets = triplets.shape[0];\n let max_weight = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n if (isNaN(weights[i])) {\n weights[i] = 0;\n }\n if (max_weight < weights[i]) max_weight = weights[i];\n }\n let max_weight_2 = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight;\n weights[i] += 0.0001;\n weights[i] = Math.log(1 + weight_adj * weights[i]);\n if (max_weight_2 < weights[i]) max_weight_2 = weights[i];\n }\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight_2;\n }\n return {\n triplets: triplets,\n weights: weights,\n };\n }\n\n /**\n * Calculates the similarity matrix P\n * @private\n * @param {Matrix} knn_distances - matrix of pairwise knn distances\n * @param {Float64Array} sig - scaling factor for the distances\n * @param {Matrix} nbrs - nearest neighbors\n * @returns {Matrix} pairwise similarity matrix\n */\n _find_p(knn_distances, sig, nbrs) {\n const [N, n_neighbors] = knn_distances.shape;\n return new Matrix(N, n_neighbors, (i, j) => {\n return Math.exp(-(knn_distances.entry(i, j) ** 2 / sig[i] / sig[nbrs.entry(i, j)]));\n });\n }\n\n /**\n * Sample nearest neighbors triplets based on the similarity values given in P.\n * @private\n * @param {Matrix} P - Matrix of pairwise similarities between each point and its neighbors given in matrix nbrs.\n * @param {Matrix} nbrs - Nearest neighbors indices for each point. The similarity values are given in matrix {@link P}. Row i corresponds to the i-th point.\n * @param {Number} n_inliers - Number of inlier points.\n * @param {Number} n_outliers - Number of outlier points.\n *\n */\n _sample_knn_triplets(P, nbrs, n_inliers, n_outliers) {\n const N = nbrs.shape[0];\n const triplets = new Matrix(N * n_inliers * n_outliers, 3);\n for (let i = 0; i < N; ++i) {\n let n_i = i * n_inliers * n_outliers;\n const sort_indices = this.__argsort(P.row(i).map((d) => -d));\n for (let j = 0; j < n_inliers; ++j) {\n let n_j = j * n_outliers;\n const sim = nbrs.entry(i, sort_indices[j]);\n const samples = this._rejection_sample(n_outliers, N, sort_indices.slice(0, j + 1));\n for (let k = 0; k < n_outliers; ++k) {\n const index = n_i + n_j + k;\n const out = samples[k];\n triplets.set_entry(index, 0, i);\n triplets.set_entry(index, 1, sim);\n triplets.set_entry(index, 2, out);\n }\n }\n }\n return triplets;\n }\n\n /**\n * Should do the same as np.argsort()\n * @private\n * @param {Array} A\n */\n __argsort(A) {\n return A.map((d, i) => {\n return { d: d, i: i };\n })\n .sort((a, b) => a.d - b.d)\n .map((d) => d.i);\n }\n\n /**\n * Samples {@link n_samples} integers from a given interval [0, {@link max_int}] while rejection the values that are in the {@link rejects}.\n * @private\n * @param {*} n_samples\n * @param {*} max_int\n * @param {*} rejects\n */\n _rejection_sample(n_samples, max_int, rejects) {\n const randomizer = this._randomizer;\n const interval = linspace(0, max_int - 1).filter((d) => rejects.indexOf(d) < 0);\n return randomizer.choice(interval, Math.min(n_samples, interval.length - 2));\n }\n\n /**\n * Calculates the weights for the sampled nearest neighbors triplets\n * @private\n * @param {Matrix} triplets - Sampled Triplets.\n * @param {Matrix} P - Pairwise similarity matrix.\n * @param {Matrix} nbrs - nearest Neighbors\n * @param {Float64Array} outlier_distances - Matrix of pairwise outlier distances\n * @param {Float64Array} sig - scaling factor for the distances.\n */\n _find_weights(triplets, P, nbrs, outlier_distances, sig) {\n const n_triplets = triplets.shape[0];\n const weights = new Float64Array(n_triplets);\n for (let t = 0; t < n_triplets; ++t) {\n const i = triplets.entry(t, 0);\n const sim = nbrs.row(i).indexOf(triplets.entry(t, 1));\n const p_sim = P.entry(i, sim);\n let p_out = Math.exp(-(outlier_distances[t] ** 2 / (sig[i] * sig[triplets.entry(t, 2)])));\n if (p_out < 1e-20) p_out = 1e-20;\n weights[t] = p_sim / p_out;\n }\n return weights;\n }\n\n /**\n * Sample uniformly ranom triplets\n * @private\n * @param {Matrix} X - Data matrix.\n * @param {Number} n_random - Number of random triplets per point\n * @param {Float64Array} sig - Scaling factor for the distances\n */\n _sample_random_triplets(X, n_random, sig) {\n const metric = this.parameter(\"metric\");\n const randomizer = this._randomizer;\n const N = X.shape[0];\n const random_triplets = new Matrix(N * n_random, 3);\n const random_weights = new Float64Array(N * n_random);\n for (let i = 0; i < N; ++i) {\n const n_i = i * n_random;\n const indices = [...linspace(0, i - 1), ...linspace(i + 1, N - 1)];\n for (let j = 0; j < n_random; ++j) {\n let [sim, out] = randomizer.choice(indices, 2);\n let p_sim = Math.exp(-(metric(X.row(i), X.row(sim)) ** 2 / (sig[i] * sig[sim])));\n if (p_sim < 1e-20) p_sim = 1e-20;\n let p_out = Math.exp(-(metric(X.row(i), X.row(out)) ** 2 / (sig[i] * sig[out])));\n if (p_out < 1e-20) p_out = 1e-20;\n\n if (p_sim < p_out) {\n [sim, out] = [out, sim];\n [p_sim, p_out] = [p_out, p_sim];\n }\n const index = n_i + j;\n random_triplets.set_entry(index, 0, i);\n random_triplets.set_entry(index, 1, sim);\n random_triplets.set_entry(index, 2, out);\n random_weights[index] = p_sim / p_out;\n }\n }\n return {\n random_triplets: random_triplets,\n random_weights: random_weights,\n };\n }\n\n /**\n * Computes the gradient for updating the embedding.\n * @param {Matrix} Y - The embedding\n */\n _grad(Y) {\n const n_inliers = this.n_inliers;\n const n_outliers = this.n_outliers;\n const triplets = this.triplets;\n const weights = this.weights;\n const [N, dim] = Y.shape;\n const n_triplets = triplets.shape[0];\n const grad = new Matrix(N, dim, 0);\n let y_ij = new Float64Array(dim);\n let y_ik = new Float64Array(dim);\n let d_ij = 1;\n let d_ik = 1;\n let n_viol = 0;\n let loss = 0;\n const n_knn_triplets = N * n_inliers * n_outliers;\n\n for (let t = 0; t < n_triplets; ++t) {\n const [i, j, k] = triplets.row(t);\n // update y_ij, y_ik, d_ij, d_ik\n if (t % n_outliers == 0 || t >= n_knn_triplets) {\n d_ij = 1;\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_jd = Y.entry(j, d);\n const Y_kd = Y.entry(k, d);\n y_ij[d] = Y_id - Y_jd;\n y_ik[d] = Y_id - Y_kd;\n d_ij += y_ij[d] ** 2;\n d_ik += y_ik[d] ** 2;\n }\n // update y_ik and d_ik only\n } else {\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_kd = Y.entry(k, d);\n y_ik[d] = Y_id - Y_kd;\n d_ik += y_ik[d] ** 2;\n }\n }\n\n if (d_ij > d_ik) ++n_viol;\n loss += weights[t] / (1 + d_ik / d_ij);\n const w = (weights[t] / (d_ij + d_ik)) ** 2;\n for (let d = 0; d < dim; ++d) {\n const gs = y_ij[d] * d_ik * w;\n const go = y_ik[d] * d_ij * w;\n grad.set_entry(i, d, grad.entry(i, d) + gs - go);\n grad.set_entry(j, d, grad.entry(j, d) - gs);\n grad.set_entry(k, d, grad.entry(k, d) + go);\n }\n }\n return { grad, loss, n_viol };\n }\n\n /**\n *\n * @param {Number} max_iteration\n */\n transform(max_iteration = 400) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n }\n return this.projection;\n }\n\n /**\n * @param {Number} max_iteration\n * @yields {Matrix}\n * @returns {Matrix}\n */\n *generator(max_iteration = 800) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * Does the iteration step.\n * @private\n * @param {Number} iter\n */\n _next(iter) {\n const gamma = iter > 150 ? 0.5 : 0.3;\n const old_C = this.C;\n const vel = this.vel;\n const Y = this.Y.add(vel.mult(gamma));\n const { grad, loss, n_viol } = this._grad(Y);\n this.C = loss;\n this.Y = this._update_embedding(Y, iter, grad);\n this.lr *= old_C > loss + this._parameters.tol ? 1.01 : 0.9;\n return this.Y;\n }\n\n /**\n * Updates the embedding.\n * @private\n * @param {Matrix} Y\n * @param {Number} iter\n * @param {Matrix} grad\n */\n _update_embedding(Y, iter, grad) {\n const [N, dim] = Y.shape;\n const gamma = iter > 150 ? 0.9 : 0.5; // moment parameter\n const min_gain = 0.01;\n const gain = this.gain;\n const vel = this.vel;\n const lr = this.lr;\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const new_gain = Math.sign(vel.entry(i, d)) != Math.sign(grad.entry(i, d)) ? gain.entry(i, d) + 0.2 : Math.max(gain.entry(i, d) * 0.8, min_gain);\n gain.set_entry(i, d, new_gain);\n vel.set_entry(i, d, gamma * vel.entry(i, d) - lr * gain.entry(i, d) * grad.entry(i, d));\n Y.set_entry(i, d, Y.entry(i, d) + vel.entry(i, d));\n }\n }\n return Y;\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n/**\n * @class\n * @alias Hierarchical_Clustering\n */\nexport class Hierarchical_Clustering {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias Hierarchical_Clustering\n * @todo needs restructuring.\n * @param {Matrix} - Data or distance matrix if metric is 'precomputed'\n * @param {(\"single\"|\"complete\"|\"average\")} [linkage = \"complete\"]\n * @param {Function|\"precomputed\"} [metric = euclidean]\n * @returns {Hierarchical_Clustering}\n */\n constructor(matrix, linkage = \"complete\", metric = euclidean) {\n this._id = 0;\n this._matrix = matrix instanceof Matrix ? matrix : Matrix.from(matrix);\n this._metric = metric;\n this._linkage = linkage;\n if (metric === \"precomputed\" && this._matrix.shape[0] !== this._matrix.shape[1]) {\n throw new Error(\"If metric is 'precomputed', then matrix has to be square!\");\n }\n this.init();\n this.root = this.do();\n return this;\n }\n\n /**\n *\n * @param {Number} value - value where to cut the tree.\n * @param {(\"distance\"|\"depth\")} [type = \"distance\"] - type of value.\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters(value, type = \"distance\") {\n let clusters = [];\n let accessor;\n switch (type) {\n case \"distance\":\n accessor = (d) => d.dist;\n break;\n case \"depth\":\n accessor = (d) => d.depth;\n break;\n default:\n throw new Error(\"invalid type\");\n }\n this._traverse(this.root, accessor, value, clusters);\n return clusters;\n }\n\n /**\n * @private\n * @param {} node\n * @param {*} f\n * @param {*} value\n * @param {*} result\n */\n _traverse(node, f, value, result) {\n if (f(node) <= value) {\n result.push(node.leaves());\n } else {\n this._traverse(node.left, f, value, result);\n this._traverse(node.right, f, value, result);\n }\n }\n\n /**\n * computes the tree.\n */\n init() {\n const metric = this._metric;\n const A = this._matrix;\n const n = (this._n = A.shape[0]);\n const d_min = (this._d_min = new Float64Array(n));\n let distance_matrix;\n if (metric !== \"precomputed\") {\n distance_matrix = new Matrix(n, n, 0); //new Array(n);\n for (let i = 0; i < n; ++i) {\n d_min[i] = 0;\n //distance_matrix[i] = new Float64Array(n);\n for (let j = 0; j < n; ++j) {\n distance_matrix.set_entry(i, j, i === j ? Infinity : metric(A.row(i), A.row(j)));\n if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n } else {\n distance_matrix = this._matrix.clone();\n for (let i = 0; i < n; ++i) {\n for (let j = 0; j < n; ++j) {\n if (i === j) {\n distance_matrix.set_entry(i, j, Infinity);\n } else if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n }\n this._distance_matrix = distance_matrix;\n const clusters = (this._clusters = new Array(n));\n const c_size = (this._c_size = new Uint16Array(n));\n for (let i = 0; i < n; ++i) {\n clusters[i] = [];\n clusters[i][0] = new Cluster(this._id++, null, null, 0, A.row(i), i, 1, 0);\n c_size[i] = 1;\n }\n return this;\n }\n\n /**\n * computes the tree.\n */\n do() {\n const n = this._n;\n const d_min = this._d_min;\n const D = this._distance_matrix;\n const clusters = this._clusters;\n const c_size = this._c_size;\n const linkage = this._linkage;\n let root = null;\n for (let p = 0, p_max = n - 1; p < p_max; ++p) {\n let c1 = 0;\n for (let i = 0; i < n; ++i) {\n let D_i_min = D.entry(i, d_min[i]);\n for (let j = i + 1; j < n; ++j) {\n if (D_i_min > D.entry(i, j)) {\n d_min[i] = j;\n D_i_min = D.entry(i, d_min[i]);\n }\n }\n }\n for (let i = 0; i < n; ++i) {\n if (D.entry(i, d_min[i]) < D.entry(c1, d_min[c1])) {\n c1 = i;\n }\n }\n let c2 = d_min[c1];\n let c1_cluster = clusters[c1][0];\n let c2_cluster = clusters[c2][0];\n let c1_cluster_indices = c1_cluster.isLeaf ? [c1_cluster.index] : c1_cluster.index;\n let c2_cluster_indices = c2_cluster.isLeaf ? [c2_cluster.index] : c2_cluster.index;\n let indices = c1_cluster_indices.concat(c2_cluster_indices);\n let new_cluster = new Cluster(this._id++, c1_cluster, c2_cluster, D.entry(c1, c2), null, indices);\n c1_cluster.parent = new_cluster;\n c2_cluster.parent = new_cluster;\n clusters[c1].unshift(new_cluster);\n c_size[c1] += c_size[c2];\n for (let j = 0; j < n; ++j) {\n const D_c1_j = D.entry(c1, j);\n const D_c2_j = D.entry(c2, j);\n let value;\n switch (linkage) {\n case \"single\":\n value = Math.min(D_c1_j, D_c2_j);\n break;\n case \"complete\":\n value = Math.max(D_c1_j, D_c2_j);\n break;\n case \"average\":\n value = (c_size[c1] * D_c1_j + c_size[c2] * D_c2_j) / (c_size[c1] + c_size[j]);\n break;\n }\n D.set_entry(j, c1, value);\n D.set_entry(c1, j, value);\n }\n\n D.set_entry(c1, c1, Infinity);\n for (let i = 0; i < n; ++i) {\n D.set_entry(i, c2, Infinity);\n D.set_entry(c2, i, Infinity);\n }\n\n /* for (let j = 0; j < n; ++j) {\n if (d_min[j] === c2) {\n d_min[j] = c1;\n }\n if (D.entry(c1, j) < D.entry(c1, d_min[c1])) {\n d_min[c1] = j;\n }\n } */\n root = new_cluster;\n }\n return root;\n }\n}\n\nclass Cluster {\n constructor(id, left, right, dist, centroid, index, size, depth) {\n this.id = id;\n this.left = left;\n this.right = right;\n this.dist = dist;\n this.index = index;\n this.size = size ?? left.size + right.size;\n this.depth = depth ?? 1 + Math.max(left.depth, right.depth);\n this.centroid = centroid ?? this._calculate_centroid(left, right);\n this.parent = null;\n return this;\n }\n\n _calculate_centroid(left, right) {\n const l_size = left.size;\n const r_size = right.size;\n const l_centroid = left.centroid;\n const r_centroid = right.centroid;\n const size = this.size;\n const n = left.centroid.length;\n const new_centroid = new Float64Array(n);\n for (let i = 0; i < n; ++i) {\n new_centroid[i] = (l_size * l_centroid[i] + r_size * r_centroid[i]) / size;\n }\n return new_centroid;\n }\n\n get isLeaf() {\n return this.depth === 0;\n }\n\n leaves() {\n if (this.isLeaf) return [this];\n const left = this.left;\n const right = this.right;\n return (left.isLeaf ? [left] : left.leaves()).concat(right.isLeaf ? [right] : right.leaves());\n }\n\n descendants() {\n if (this.isLeaf) return [this];\n const left_descendants = this.left.descendants();\n const right_descendants = this.right.descendants();\n return left_descendants.concat(right_descendants).concat([this]);\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { linspace } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KMeans\n */\nexport class KMeans {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMeans\n * @todo needs restructuring. \n * @param {Matrix} matrix \n * @param {Numbers} K \n * @param {Function} [metric = euclidean] \n * @param {Number} [seed = 1987]\n * @param {Boolean} [init = true]\n * @returns {KMeans}\n */\n constructor(matrix, K, metric = euclidean, seed=1987, init = true) {\n this._metric = metric;\n this._matrix = matrix;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_centroids = this._get_random_centroids(K);\n if (init) this.init(K, this._cluster_centroids);\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const clusters = this._clusters;\n const result = new Array(K).fill().map(() => new Array());\n clusters.forEach((c, i) => result[c].push(i));\n return result;\n }\n\n /**\n * @private\n * @param {Array} points \n * @param {Array} candidates \n */\n _furthest_point(points, candidates) {\n const A = this._matrix;\n const metric = this._metric;\n let i = points.length;\n let H = Heap.heapify(\n candidates, \n (d) => {\n const Ad = A.row(d)\n let sum = 0;\n for (let j = 0; j < i; ++j) {\n sum += metric(Ad, points[j])\n }\n return sum;\n }, \n \"max\"\n )\n return H.pop().element;\n }\n\n _get_random_centroids(K) {\n const N = this._N;\n const randomizer = this._randomizer;\n const A = this._matrix;\n const cluster_centroids = new Array(K).fill()\n const indices = linspace(0, N - 1);\n const random_point = randomizer.random_int % (N - 1);\n cluster_centroids[0] = A.row(random_point);\n const init_points = [random_point];\n const sample_size = Math.floor((N - K) / K);// / K\n for (let i = 1; i < K; ++i) {\n // sampling + kmeans++ improvement?\n const sample = randomizer.choice(indices.filter(d => init_points.indexOf(d) == -1), sample_size);\n const furthest_point = this._furthest_point(cluster_centroids.slice(0, i), sample);\n init_points.push(furthest_point);\n cluster_centroids[i] = A.row(furthest_point);\n }\n return cluster_centroids;\n }\n\n _iteration(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const metric = this._metric;\n const clusters = this._clusters;\n let clusters_changed = false;\n // find nearest cluster centroid.\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i)\n let min_dist = Infinity;\n let min_cluster = null;\n for (let j = 0; j < K; ++j) {\n let d = metric(cluster_centroids[j], Ai);\n if (d < min_dist) {\n min_dist = d;\n min_cluster = j; \n }\n }\n if (clusters[i] !== min_cluster) {\n clusters_changed = true;\n }\n clusters[i] = min_cluster;\n }\n // update cluster centroid\n // reset cluster centroids to 0\n for (let i = 0; i < K; ++i) {\n const centroid = cluster_centroids[i];\n for (let j = 0; j < D; ++j) {\n centroid[j] = 0;\n }\n }\n // compute centroid\n this._compute_centroid(cluster_centroids);\n\n return { \n \"clusters_changed\": clusters_changed,\n \"cluster_centroids\": cluster_centroids\n };\n }\n\n _compute_centroid(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const clusters = this._clusters;\n const cluster_counter = new Array(K).fill(0);\n\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i);\n const ci = clusters[i];\n cluster_counter[ci]++;\n const centroid = cluster_centroids[ci];\n for (let j = 0; j < D; ++j) {\n centroid[j] += Ai[j];\n }\n }\n for (let i = 0; i < K; ++i) {\n const n = cluster_counter[i];\n cluster_centroids[i] = cluster_centroids[i].map(c => c / n);\n }\n \n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_centroids) {\n if (!K) K = this._K;\n if (!cluster_centroids) cluster_centroids = this._get_random_centroids(K);\n let clusters_changed = false;\n do {\n const iteration_result = this._iteration(cluster_centroids)\n cluster_centroids = iteration_result.cluster_centroids;\n clusters_changed = iteration_result.clusters_changed;\n } while (clusters_changed)\n }\n \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { linspace, Matrix } from \"../matrix/index.js\";\nimport { min } from \"../util/index.js\";\n/**\n * @class\n * @alias KMedoids\n */\nexport class KMedoids {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMedoids\n * @todo needs restructuring. \n * @param {Matrix} matrix - data matrix\n * @param {Numbers} K - number of clusters\n * @param {number} [max_iter=null] - maximum number of iterations. Default is 10 * Math.log10(N)\n * @param {Function} [metric = euclidean] - metric defining the dissimilarity \n * @param {Number} [seed = 1212] - seed value for random number generator\n * @returns {KMedoids}\n * @see {@link https://link.springer.com/chapter/10.1007/978-3-030-32047-8_16} Faster k-Medoids Clustering: Improving the PAM, CLARA, and CLARANS Algorithms\n */\n constructor(matrix, K, max_iter=null, metric = euclidean, seed=1212) {\n this._metric = metric;\n this._matrix = matrix;\n this._A = this._matrix.to2dArray;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n this._max_iter = max_iter || 10 * Math.log10(N) \n this._distance_matrix = new Matrix(N, N, \"zeros\");\n /* for (let i = 1; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dist = metric(this._A[i], this._A[j]);\n this._distance_matrix.set_entry(i, j, dist);\n this._distance_matrix.set_entry(j, i, dist)\n }\n } */\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_medoids = this._get_random_medoids(K);\n //if (init) this.init(K, this._cluster_medoids);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const A = this._A;\n if (!this._is_initialized) {\n this.init(K, this._cluster_medoids);\n }\n const result = new Array(K).fill().map(() => new Array());\n A.forEach((x_j, j) => {\n result[this._nearest_medoid(x_j, j).index_nearest].push(j);\n })\n result.medoids = this._cluster_medoids;\n return result;\n }\n\n async* generator() {\n const max_iter = this._max_iter;\n yield this.get_clusters()\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n yield this.get_clusters();\n } while (!finish && ++i < max_iter)\n }\n\n /**\n * Algorithm 1. FastPAM1: Improved SWAP algorithm\n */\n /* _iteration_1() {\n const A = this._A;\n const N = this._N;\n const K = this._K;\n const medoids = this._cluster_medoids;\n let DeltaTD = 0;\n let m0 = null;\n let x0 = null;\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const nearest_medoid = this._nearest_medoid(x_j, j);\n const d_j = nearest_medoid.distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n // disance to new medoid\n const d_oj = this._get_distance(o, j, x_o, x_j);\n const {\n \"index_nearest\": n,\n \"distance_nearest\": d_n,\n \"distance_second\": d_s,\n } = this._nearest_medoid(x_o, o); \n this._clusters[o] = n; // cached values\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change\n if (d_oj < d_n) { // reassignment check\n deltaTD.forEach((d_i, i) => {\n if (n !== i) {\n deltaTD[i] = d_i + d_oj - d_n; // update loss change\n }\n });\n }\n });\n // choose best medoid i;\n const i = deltaTD\n .map((d, i) => [d, i])\n .sort((d1, d2) => d1[0] - d2[0])[0][1];\n const deltaTD_i = deltaTD[i];\n // store\n if (deltaTD_i < DeltaTD) {\n DeltaTD = deltaTD_i;\n m0 = i;\n x0 = j;\n }\n }\n });\n\n if (DeltaTD >= 0) {\n return true // break loop if DeltaTD >= 0\n }\n // swap roles of medoid m and non-medoid x;\n medoids[m0] = x0;\n this._cluster_medoids = medoids;\n return false\n } */\n\n /** Algorithm 2. FastPAM2: SWAP with multiple candidates\n * \n */\n _iteration() {\n const A = this._A;\n const K = this._K;\n const medoids = this._cluster_medoids;\n const cache = A.map((x_o, o) => this._nearest_medoid(x_o, o));\n // empty best candidates array\n const DeltaTD = new Array(K).fill(0);\n const xs = new Array(K).fill(null);\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const d_j = cache[j].distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n if (j === o) return;\n const d_oj = this._get_distance(o, j, x_o, x_j); // distance to new medoid\n const {\"index_nearest\": n, \"distance_nearest\": d_n, \"distance_second\": d_s} = cache[o]; // cached\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change for x_o\n // Reassignment check\n if (d_oj < d_n) { \n // update loss change\n for (let i = 0; i < K; ++i) {\n if (i !== n) deltaTD[i] += d_oj - d_n;\n }\n }\n });\n // remember best swap for i;\n deltaTD\n .map((d, i) => [d, i])\n .filter(([d, i]) => d < DeltaTD[i])\n .forEach(([d, i]) => {\n if (d < DeltaTD[i]) {\n DeltaTD[i] = d;\n xs[i] = j;\n }\n })\n }\n })\n // stop if no improvements were found\n if (min(DeltaTD) >= 0) return true; \n\n // execute all improvements\n while (min(DeltaTD) < 0) {\n // swap roles of medoid m_i and non_medoid xs_i\n const i = DeltaTD\n .map((d, i) => [d, i])\n .sort(([a], [b]) => a - b)[0][1];\n if (medoids.filter(m => m == xs[i]).length == 0) {\n medoids[i] = xs[i];\n }\n // disable the swap just performed\n DeltaTD[i] = 0; \n // recompute TD for remaining swap candidates\n DeltaTD\n .map((d_j, j) => [d_j, j])\n .filter(([d_j]) => d_j < 0)\n .forEach(([_, j]) => {\n const x_j = A[j];\n let sum = 0;\n A.forEach((x_o, o) => {\n if (medoids.findIndex(m => m != j && m == o) >= 0) return;\n if (i == j) return;\n if (cache[o].index_nearest === medoids[j])\n sum += (Math.min(this._get_distance(o, j, x_o, x_j), cache[o].distance_second) - cache[o].distance_nearest); \n else {\n sum += (Math.min(this._get_distance(o, j, x_o, x_j) - cache[o].distance_nearest, 0));\n }\n });\n DeltaTD[j] = sum;\n })\n }\n this._cluster_medoids = medoids;\n return false;\n }\n\n _get_distance(i, j, x_i=null, x_j=null) {\n if (i === j) return 0;\n const D = this._distance_matrix;\n const A = this._A;\n const metric = this._metric;\n let d_ij = D.entry(i, j);\n if (d_ij === 0) {\n d_ij = metric(x_i || A[i], x_j || A[j]);\n D.set_entry(i, j, d_ij);\n D.set_entry(j, i, d_ij);\n }\n return d_ij;\n }\n\n _nearest_medoid(x_j, j) {\n const medoids = this._cluster_medoids;\n const A = this._A;\n const [nearest, second] = medoids\n .map((m, i) => {\n const x_m = A[m]; \n return [this._get_distance(j, m, x_j, x_m), i];\n })\n .sort((m1, m2) => m1[0] - m2[0]);\n \n return { \n \"distance_nearest\": nearest[0], \n \"index_nearest\": nearest[1],\n \"distance_second\": second[0],\n \"index_second\": second[1],\n };\n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_medoids) {\n if (!K) K = this._K;\n if (!cluster_medoids) cluster_medoids = this._get_random_medoids(K);\n const max_iter = this._max_iter;\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n } while (!finish && ++i < max_iter)\n return this;\n }\n\n /**\n * Algorithm 3. FastPAM LAB: Linear Approximate BUILD initialization.\n * @param {number} K - number of clusters\n * \n */\n _get_random_medoids(K) {\n const N = this._N;\n const A = this._A;\n const indices = linspace(0, N - 1);\n const randomizer = this._randomizer;\n const n = Math.min(N, 10 + Math.ceil(Math.sqrt(N)));\n const TD = new Array(n).fill(Infinity);\n const medoids = [];\n // first medoid\n let TD0 = Infinity;\n let S = randomizer.choice(indices, n);\n for (let j = 0; j < n; ++j) {\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const x_o = A[S[o]];\n TD[j] += this._get_distance(j, o, x_j, x_o);\n }\n if (TD[j] < TD0) {\n TD0 = TD[j]; // smallest distance sum\n medoids.push(S_j);\n }\n }\n // other medoids\n for (let i = 1; i < K; ++i) {\n let DeltaTD = Infinity;\n S = randomizer.choice(indices.filter(index => medoids.findIndex(d => d === index) < 0), n);\n for (let j = 0; j < n; ++j) {\n let deltaTD = 0;\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const S_o = S[o];\n const x_o = A[S_o];\n let delta = this._get_distance(S_j, S_o, x_j, x_o) - min(medoids.map(m => this._get_distance(S_o, m, x_o)));\n if (delta < 0) {\n deltaTD = deltaTD + delta;\n }\n }\n // best reduction\n if (deltaTD < DeltaTD) {\n DeltaTD = deltaTD;\n medoids.push(S_j);\n }\n }\n TD0 += DeltaTD;\n }\n return medoids.slice(0, K);\n }\n \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias OPTICS\n */\nexport class OPTICS {\n /**\n * **O**rdering **P**oints **T**o **I**dentify the **C**lustering **S**tructure.\n * @constructor\n * @memberof module:clustering\n * @alias OPTICS\n * @todo needs restructuring. \n * @param {Matrix} matrix - the data.\n * @param {Number} epsilon - the minimum distance which defines whether a point is a neighbor or not.\n * @param {Number} min_points - the minimum number of points which a point needs to create a cluster. (Should be higher than 1, else each point creates a cluster.)\n * @param {Function} [metric = euclidean] - the distance metric which defines the distance between two points of the {@link matrix}.\n * @returns {OPTICS}\n * @see {@link https://www.dbs.ifi.lmu.de/Publikationen/Papers/OPTICS.pdf}\n * @see {@link https://en.wikipedia.org/wiki/OPTICS_algorithm}\n */\n constructor(matrix, epsilon, min_points, metric = euclidean) {\n this._matrix = matrix;\n this._epsilon = epsilon;\n this._min_points = min_points;\n this._metric = metric;\n\n this._ordered_list = [];\n this._clusters = [];\n this._DB = new Array(matrix.shape[0]).fill();\n this.init();\n return this;\n }\n\n /**\n * Computes the clustering.\n */\n init() {\n const ordered_list = this._ordered_list;\n const matrix = this._matrix;\n const N = matrix.shape[0];\n const DB = this._DB;\n const clusters = this._clusters;\n let cluster_index = this._cluster_index = 0;\n\n for (let i = 0; i < N; ++i) {\n DB[i] = {\n \"element\": matrix.row(i),\n \"index\": i,\n \"reachability_distance\": undefined,\n \"processed\": false,\n }\n }\n for (const p of DB) {\n if (p.processed) continue;\n p.neighbors = this._get_neighbors(p);\n p.processed = true;\n clusters.push([p.index])\n cluster_index = clusters.length - 1;\n ordered_list.push(p);\n if (this._core_distance(p) != undefined) {\n const seeds = new Heap(null, d => d.reachability_distance, \"min\")\n this._update(p, seeds);\n this._expand_cluster(seeds, clusters[cluster_index]);\n }\n }\n return this;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Array} An array consisting of the {@link epsilon}-neighborhood of {@link p}.\n */\n _get_neighbors(p) {\n if (\"neighbors\" in p) return p.neighbors;\n const DB = this._DB;\n const metric = this._metric;\n const epsilon = this._epsilon;\n const neighbors = [];\n for (const q of DB) {\n if (q.index == p.index) continue;\n if (metric(p.element, q.element) < epsilon) {\n neighbors.push(q);\n }\n }\n return neighbors;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Number} The distance to the {@link min_points}-th nearest point of {@link p}, or undefined if the {@link epsilon}-neighborhood has fewer elements than {@link min_points}.\n */\n _core_distance(p) {\n const min_points = this._min_points;\n const metric = this._metric;\n if (p.neighbors && p.neighbors.length <= min_points) {\n return undefined;\n }\n return metric(p.element, p.neighbors[min_points].element);\n }\n\n /**\n * Updates the reachability distance of the points.\n * @private\n * @param {Object} p \n * @param {Heap} seeds \n */\n _update(p, seeds) {\n const metric = this._metric;\n const core_distance = this._core_distance(p);\n const neighbors = this._get_neighbors(p);//p.neighbors;\n for (const q of neighbors) {\n if (q.processed) continue;\n const new_reachability_distance = Math.max(core_distance, metric(p.element, q.element));\n //if (q.reachability_distance == undefined) { // q is not in seeds\n if (seeds.raw_data().findIndex(d => d.element == q) < 0) {\n q.reachability_distance = new_reachability_distance;\n seeds.push(q);\n } else { // q is in seeds\n if (new_reachability_distance < q.reachability_distance) {\n q.reachability_distance = new_reachability_distance;\n seeds = Heap.heapify(seeds.data(), d => d.reachability_distance, \"min\"); // seeds change key =/\n }\n }\n }\n }\n\n /**\n * Expands the {@link cluster} with points in {@link seeds}.\n * @private\n * @param {Heap} seeds \n * @param {Array} cluster \n */\n _expand_cluster(seeds, cluster) {\n const ordered_list = this._ordered_list;\n while (!seeds.empty) {\n const q = seeds.pop().element;\n q.neighbors = this._get_neighbors(q);\n q.processed = true;\n cluster.push(q.index);\n ordered_list.push(q);\n if (this._core_distance(q) != undefined) {\n this._update(q, seeds);\n this._expand_cluster(seeds, cluster);\n }\n }\n }\n\n /**\n * Returns an array of clusters.\n * @returns {Array} Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters() {\n const clusters = [];\n const outliers = [];\n const min_points = this._min_points;\n for (const cluster of this._clusters) {\n if (cluster.length < min_points) {\n outliers.push(...cluster);\n } else {\n clusters.push(cluster);\n }\n }\n clusters.push(outliers);\n return clusters;\n }\n\n /**\n * @returns {Array} Returns an array, where the ith entry defines the cluster affirmation of the ith point of {@link matrix}. (-1 stands for outlier)\n */\n get_cluster_affirmation() {\n const N = this._matrix.shape[0];\n const result = new Array(N).fill();\n const clusters = this.get_clusters();\n for (let i = 0, n = clusters.length; i < n; ++i) {\n const cluster = clusters[i]\n for (const index of cluster) {\n result[index] = (i < n - 1) ? i : -1;\n }\n }\n return result;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\nimport { MDS } from \"./MDS.js\";\nimport { KMedoids } from \"../clustering/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\n/**\n * @class\n * @alias LSP\n * @extends DR\n */\nexport class LSP extends DR {\n /**\n * Least Squares Projection.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LSP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.neighbors = Math.max(Math.floor(N / 10), 2)] - number of neighbors to consider.\n * @param {Number} [parameters.control_points = Math.ceil(Math.sqrt(N))] - number of controlpoints\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {LSP}\n * @see {@link https://ieeexplore.ieee.org/document/4378370}\n * @todo accept precomputed distance matrix.\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, control_points: undefined, d: 2, metric: euclidean, seed: 1212 }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n this.parameter(\"control_points\", Math.min(parameters.control_points ?? Math.ceil(Math.sqrt(this._N)), this._N - 1));\n this._is_initialized = false;\n return this;\n }\n\n /**\n *\n * @param {DR} DR - method used for position control points.\n * @param {Object} DR_parameters - Object containing parameters for the DR method which projects the control points\n * @returns {LSP}\n */\n init(DR = MDS, DR_parameters = {}, KNN = BallTree) {\n if (this._is_initialized) return this;\n const X = this.X;\n const N = this._N;\n const K = this.parameter(\"neighbors\");\n const d = this.parameter(\"d\");\n const seed = this.parameter(\"seed\");\n const metric = this.parameter(\"metric\");\n DR_parameters = Object.assign({d, metric, seed }, DR_parameters);\n const nc = this.parameter(\"control_points\");\n const control_points = new KMedoids(X, nc, null, metric).get_clusters().medoids;\n const C = new Matrix(nc, N, \"zeros\");\n control_points.forEach((c_i, i) => {\n C.set_entry(i, c_i, 1);\n });\n const Y_C = new DR(Matrix.from(control_points.map((c_i) => X.row(c_i))), DR_parameters).transform();\n\n const XA = X.to2dArray;\n const knn = new KNN(XA, metric);\n const L = new Matrix(N, N, \"I\");\n const alpha = -1 / K;\n XA.forEach((x_i, i) => {\n for (const { index: j } of knn.search(x_i, K).iterate()) {\n if (i === j) continue;\n L.set_entry(i, j, alpha);\n }\n });\n const A = L.concat(C, \"vertical\");\n\n const z = new Matrix(N, d, \"zeros\");\n const b = z.concat(Y_C, \"vertical\");\n\n this._A = A;\n this._b = b;\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const A = this._A;\n const AT = A.T;\n const b = this._b;\n const ATA = AT.dot(A);\n const ATb = AT.dot(b);\n this.Y = Matrix.solve_CG(ATA, ATb, this._randomizer);\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { DisjointSet } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias TopoMap\n * @memberof module:dimensionality_reduction\n * @extends DR\n */\nexport class TopoMap extends DR {\n /**\n * TopoMap: A 0-dimensional Homology Preserving Projection of High-Dimensional Data.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TopoMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TopoMap}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._distance_matrix = new Matrix(this._N, this._N, 0);\n return this;\n }\n\n /**\n * @private\n */\n __lazy_distance_matrix(i, j, metric) {\n const D = this._distance_matrix;\n const X = this.X;\n const D_ij = D.entry(i, j);\n if (D_ij === 0) {\n let dist = metric(X.row(i), X.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n return dist;\n }\n return D_ij;\n }\n\n /**\n * Computes the minimum spanning tree, using a given metric\n * @private\n * @param {Function} metric\n * @see {@link https://en.wikipedia.org/wiki/Kruskal%27s_algorithm}\n */\n _make_minimum_spanning_tree(metric = euclidean) {\n const N = this._N;\n const X = [...this.X];\n\n let disjoint_set = new DisjointSet(X);\n const F = [];\n let E = [];\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n E.push([i, j, this.__lazy_distance_matrix(i, j, metric)]);\n }\n }\n E = E.sort((a, b) => a[2] - b[2]);\n\n for (const [u, v, w] of E) {\n const set_u = disjoint_set.find(X[u]);\n const set_v = disjoint_set.find(X[v]);\n if (set_u !== set_v) {\n F.push([u, v, w]);\n disjoint_set.union(set_u, set_v);\n }\n }\n\n return F.sort((a, b) => a[2] - b[2]);\n }\n\n /**\n * initializes TopoMap. Sets all projcted points to zero, and computes a minimum spanning tree.\n */\n init() {\n const { metric} = this._parameters\n this.Y = new Matrix(this._N, 2, 0);\n this._Emst = this._make_minimum_spanning_tree(metric);\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Returns true if Point C is left of line AB.\n * @private\n * @param {Array} PointA - Point A of line AB\n * @param {Array} PointB - Point B of line AB\n * @param {Array} PointC - Point C\n * @returns {Boolean}\n */\n __hull_cross([ax, ay], [bx, by], [sx, sy]) {\n return (bx - ax) * (sy - ay) - (by - ay) * (sx - ax) <= 0;\n }\n\n /**\n * Computes the convex hull of the set of Points S\n * @private\n * @param {Array} S - Set of Points.\n * @see {@link https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain#JavaScript}\n * @returns {Array} convex hull of S. Starts at the bottom-most point and continues counter-clockwise.\n */\n __hull(S) {\n const points = S.sort(([x1, y1], [x2, y2]) => y1 - y2 || x1 - x2);\n const N = points.length;\n if (N <= 2) return points;\n\n const lower = [];\n for (let i = 0; i < N; ++i) {\n while (lower.length >= 2 && this.__hull_cross(lower[lower.length - 2], lower[lower.length - 1], points[i])) {\n lower.pop();\n }\n lower.push(points[i]);\n }\n const upper = [];\n for (let i = N - 1; i >= 0; --i) {\n while (upper.length >= 2 && this.__hull_cross(upper[upper.length - 2], upper[upper.length - 1], points[i])) {\n upper.pop();\n }\n upper.push(points[i]);\n }\n upper.pop();\n lower.pop();\n return lower.concat(upper);\n }\n\n /**\n * Finds the angle to rotate Point A and B to lie on a line parallel to the x-axis.\n * @private\n * @param {Array} PointA\n * @param {Array} PointB\n * @return {Object} Object containing the sinus- and cosinus-values for a rotation.\n */\n __findAngle([p1x, p1y], [p2x, p2y]) {\n const n = euclidean([p1x, p1y], [p2x, p2y]);\n if (n === 0)\n return {\n sin: 0,\n cos: 1,\n };\n const vec = [(p2x - p1x) / n, (p2y - p1y) / n];\n const cos = vec[0];\n let sin = Math.sqrt(1 - cos * cos);\n sin = vec[1] >= 0 ? -sin : sin;\n return {\n sin: sin,\n cos: cos,\n };\n }\n\n /**\n * @private\n * @param {Array} hull\n * @param {Array} p\n * @param {Bool} topEdge\n */\n __align_hull(hull, p, topEdge) {\n let v = -1;\n let d2;\n for (let i = 0; i < hull.length; ++i) {\n const d = euclidean(hull[i], p);\n if (v === -1) {\n d2 = d;\n v = i;\n } else {\n if (d2 > d) {\n d2 = d;\n v = i;\n }\n }\n }\n\n let v1;\n let v2;\n if (topEdge) {\n v1 = hull[v];\n v2 = hull[(v + 1) % hull.length];\n } else {\n if (v == 0) v = hull.length - 1;\n v1 = hull[v];\n v2 = hull[(v - 1) % hull.length];\n }\n\n const transformation = {\n tx: -hull[v][0],\n ty: -hull[v][1],\n };\n\n if (hull.length >= 2) {\n const { sin, cos } = this.__findAngle(v1, v2);\n transformation.sin = sin;\n transformation.cos = cos;\n } else {\n transformation.sin = 0;\n transformation.cos = 1;\n }\n\n return transformation;\n }\n\n /**\n * @private\n * @param {Array} Point - The point which should get transformed.\n * @param {Object} Transformation - contains the values for translation and rotation.\n */\n __transform([px, py], { tx, ty, sin, cos }) {\n let x = px + tx;\n let y = py + ty;\n let xx = x * cos - y * sin;\n let yy = x * sin + y * cos;\n return [xx, yy];\n }\n\n /**\n * Calls {@link __transform} for each point in Set C\n * @private\n * @param {Array} C - Set of points.\n * @param {Object} t - Transform object.\n * @param {Number} yOffset - value to offset set C.\n */\n __transform_component(C, t, yOffset) {\n const N = C.length;\n for (let i = 0; i < N; ++i) {\n const c = C[i];\n const [cx, cy] = this.__transform(c, t);\n c[0] = cx;\n c[1] = cy + yOffset;\n }\n }\n\n /**\n * @private\n * @param {Array} u - point u\n * @param {Array} v - point v\n * @param {Number} w - edge weight w\n */\n __align_components(u, v, w) {\n const points_u = [...u.__disjoint_set.children];\n const points_v = [...v.__disjoint_set.children];\n\n const hull_u = this.__hull(points_u);\n const hull_v = this.__hull(points_v);\n\n const t_u = this.__align_hull(hull_u, u, false);\n const t_v = this.__align_hull(hull_v, v, true);\n\n this.__transform_component(points_u, t_u, 0);\n this.__transform_component(points_v, t_v, w);\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality 2.\n */\n transform() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n }\n return this.projection;\n }\n\n *generator() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n yield this.projection;\n }\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { PCA, MDS } from \"./index.js\";\nimport { distance_matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias SAMMON\n * @extends DR\n */\nexport class SAMMON extends DR {\n /**\n * SAMMON's Mapping\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias SAMMON\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {\"PCA\"|\"MDS\"|\"random\"} [parameters.init = \"random\"] - Either \"PCA\" or \"MDS\", with which SAMMON initialiates the projection. With \"random\" a random matrix gets used as starting point.\n * @param {Object} [parameters.init_parameters] - Parameters for the {@link init}-DR method.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {SAMMON}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { magic: 0.1, d: 2, metric: euclidean, seed: 1212, init_DR: \"random\", init_parameters: {} }, parameters);\n return this;\n }\n\n /**\n * initializes the projection.\n * @private\n */\n init() {\n const N = this.X.shape[0];\n const { d, metric, init_DR: init_DR, init_parameters: DR_parameters } = this._parameters;\n if (init_DR === \"random\") {\n const randomizer = this._randomizer;\n this.Y = new Matrix(N, d, () => randomizer.random);\n } else if ([\"PCA\", \"MDS\"].includes(init_DR)) {\n this.Y = Matrix.from(init_DR == \"PCA\" ? PCA.transform(this.X, DR_parameters) : MDS.transform(this.X, DR_parameters));\n } else {\n throw new Error('init_DR needs to be either \"random\" or a DR method!')\n }\n this.distance_matrix = metric == \"precomputed\" ? Matrix.from(this.X) : distance_matrix(this.X, metric);\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Matrix|Array} - The projection of {@link X}.\n */\n transform(max_iter = 200) {\n if (!this._is_initialized) this.init();\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n }\n return this.projection;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Generator} - A generator yielding the intermediate steps of the projection of {@link X}.\n */\n *generator(max_iter = 200) {\n if (!this._is_initialized) this.init();\n\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n yield this.projection;\n }\n\n return this.projection;\n }\n\n _step() {\n const MAGIC = this.parameter(\"magic\");\n const D = this.distance_matrix;\n const N = this.X.shape[0];\n const { d, metric } = this._parameters;\n let Y = this.Y;\n\n let G = new Matrix(N, d, 0);\n\n let sum = new Float64Array(d);\n for (let i = 0; i < N; ++i) {\n let e1 = new Float64Array(d);\n let e2 = new Float64Array(d);\n const Yi = Y.row(i);\n for (let j = 0; j < N; ++j) {\n if (i === j) continue;\n const Yj = Y.row(j);\n const delta = new Float64Array(d);\n for (let k = 0; k < d; ++k) {\n delta[k] = Yi[k] - Yj[k];\n }\n const dY = metric(Yi, Yj);\n const dX = D.entry(i, j);\n const dq = dX - dY;\n const dr = Math.max(dX * dY, 1e-2);\n for (let k = 0; k < d; ++k) {\n e1[k] += (delta[k] * dq) / dr;\n e2[k] += (dq - (Math.pow(delta[k], 2) * (1 + dq / dY)) / dY) / dr;\n }\n }\n for (let k = 0; k < d; ++k) {\n const val = Y.entry(i, k) + ((MAGIC * e1[k]) / Math.abs(e2[k]) || 0);\n G.set_entry(i, k, val);\n sum[k] += val;\n }\n }\n for (let k = 0; k < d; ++k) {\n sum[k] /= N;\n }\n\n for (let i = 0; i < N; ++i) {\n for (let k = 0; k < d; ++k) {\n Y.set_entry(i, k, G.entry(i, k) - sum[k]);\n }\n }\n return Y;\n }\n}\n"],"names":[],"mappings":";;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,kBAAQ,EAAE,CAAC,EAAE,CAAC,EAAE;AAC/B,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9C;;ACXA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,kBAAQ,EAAE,QAAQ,EAAE;AACnC,IAAI,IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC;AAC5B,IAAI,IAAI,GAAG,GAAG,CAAC,CAAC;AAChB,IAAI,IAAI,YAAY,GAAG,CAAC,CAAC;AACzB,IAAI,IAAI,CAAC,EAAE,CAAC,CAAC;AACb;AACA,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;AAChC,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,G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AI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE;AACxC,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAC1D,aAAa;AACb,SAAS;AACT,QAAQ,OAAO,CAAC,CAAC;AACjB,KAAK;AACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/druid.min.js b/dist/druid.min.js index 3dff153..2a4f11c 100644 --- a/dist/druid.min.js +++ b/dist/druid.min.js @@ -1,3 +1,3 @@ // https://renecutura.eu v0.5.2 Copyright 2022 Rene Cutura -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).druid=t.druid||{})}(this,(function(t){"use strict";function e(t,e){return Math.sqrt(s(t,e))}function r(t){let e=t.length,r=0,s=0;for(let n=0;n=Math.abs(e)?s+=r-i+e:s+=e-i+r,r=i}return r+s}function s(t,e){if(t.length!=e.length)return;let s=t.length,n=new Array(s);for(let r=0;r({i:t,j:r,distance:e}))).sort(((t,e)=>t.distance-e.distance)).slice(1,r+1);return a}function i(t,r=e){let s=t.shape[0];const n=new _(s,s);for(let e=0;e=0;--n)s[n]=(n*e+(r-n)*t)/r;return s}function a(t,r=e){let s=null;if(t instanceof _){let[e,r]=t.shape;if(1===e)s=t.row(0);else{if(1!==r)throw new Error("Matrix must be 1d!");s=t.col(0)}}else s=t;const n=s.length;return r(s,Float64Array.from({length:n},(()=>0)))}function h(t){const[s,n]=t.shape,i=new _(s,n,"identity"),o=new _(n,n,0);for(let h=0;ht*n[e])));o.set_entry(t,h,s),n=n.map(((t,r)=>t-s*e[r]))}const l=a(n,e);for(let t=0;t2*(a.random-.5))));for(;n--;){const e=u.clone(),r=i(t.dot(u));u=r.Q,f=r.R;if(s(u.values,e.values)(e===r?1:0)-1/t;for(let s=0;st[r]));if("col"===e)return new _(r,1,(e=>t[e]));if("diag"===e)return new _(r,r,((e,r)=>e==r?t[e]:0));throw new Error("1d array has NaN entries")}if(Array.isArray(t[0])||t[0]instanceof Float64Array){let e=t[0].length;for(let s=0;st[e][r]))}}}row(t){const e=this.values,r=this._cols;return e.subarray(t*r,(t+1)*r)}*iterate_rows(){const t=this._cols,e=this._rows,r=this.values;for(let s=0;sthis.entry(e,t)))}get T(){return this.transpose()}inverse(){const t=this._rows,e=this._cols;let r=new _(t,2*e,((t,r)=>r>=e?t===r-e?1:0:this.entry(t,r))),s=0,n=0;for(;s=0;--s){let t=r.entry(s,s);for(let n=0;nr.entry(t,s+e)))}dot(t){if(t instanceof _){let e=this;if(e.shape[1]!==t.shape[0])throw new Error(`A.dot(B): A is a ${e.shape.join(" ⨯ ")}-Matrix, B is a ${t.shape.join(" ⨯ ")}-Matrix: \n A has ${e.shape[1]} cols and B ${t.shape[0]} rows. \n Must be equal!`);let r=e.shape[1];return new _(e.shape[0],t.shape[1],((s,n)=>{const i=e.row(s),o=t.col(n);let a=0;for(let t=0;te*t[n])));return s}throw new Error("B must be Matrix or Array")}outer(t){let e=this,r=e._data.length;if(r!=t._data.length)return;let s=new _;return s.shape=[r,r,(r,n)=>r<=n?e._data[r]*t._data[n]:s.entry(n,r)],s}concat(t,e="horizontal"){const r=this,[s,n]=r.shape,[i,o]=t.shape;if("horizontal"==e){if(s!=i)throw new Error(`A.concat(B, "horizontal"): A and B need same number of rows, A has ${s} rows, B has ${i} rows.`);const e=new _(s,n+o,"zeros");return e.set_block(0,0,r),e.set_block(0,n,t),e}if("vertical"==e){if(n!=o)throw new Error(`A.concat(B, "vertical"): A and B need same number of columns, A has ${n} columns, B has ${o} columns.`);const e=new _(s+i,n,"zeros");return e.set_block(0,0,r),e.set_block(s,0,t),e}if("diag"==e){const e=new _(s+i,n+o,"zeros");return e.set_block(0,0,r),e.set_block(s,n,t),e}throw new Error(`type must be "horizontal" or "vertical", but type is ${e}!`)}set_block(t,e,r){let[s,n]=r.shape;for(let i=0;ithis._rows))for(let s=0;sthis._cols||this.set_entry(i+t,s+e,r.entry(i,s));return this}get_block(t,e,r=null,s=null){const[n,i]=this.shape;if(s=s??i,(r=r??n)<=t||s<=e)throw new Error(`\n end_row must be greater than start_row, and \n end_col must be greater than start_col, but\n end_row = ${r}, start_row = ${t}, end_col = ${s}, and start_col = ${e}!`);const o=new _(r-t,s-e,"zeros");for(let n=t,i=0;nt[r]))}_apply_colwise_array(t,e){const r=this.values,[s,n]=this.shape;for(let i=0;it*e))}divide(t){return this.clone()._apply(t,((t,e)=>t/e))}add(t){return this.clone()._apply(t,((t,e)=>t+e))}sub(t){return this.clone()._apply(t,((t,e)=>t-e))}get shape(){return[this._rows,this._cols]}set shape([t,e,r=(()=>0)]){this._rows=t,this._cols=e,this._data=new Float64Array(t*e);for(let s=0;sr.random)),l=i.sub(t.dot(h)),c=l.clone();do{const e=t.dot(c),r=l.T.dot(l).entry(0,0)/c.T.dot(e).entry(0,0);h=h.add(c.mult(r));const s=l.sub(e.mult(r)),n=s.T.dot(s).entry(0,0)/l.T.dot(l).entry(0,0);c=s.add(c.mult(n)),l=s}while(Math.abs(l.mean)>s);o=o.concat(h,"horizontal")}return o}static solve(t,e){let{L:r,U:s}="L"in t&&"U"in t?t:_.LU(t),n=r.shape[0],i=e.clone();for(let t=0;t=0;--t){for(let e=n-1;e>t;--e)i.set_entry(0,t,i.entry(0,t)-s.entry(t,e)*i.entry(0,e));i.set_entry(0,t,i.entry(0,t)/s.entry(t,t))}return i}static LU(t){const e=t.shape[0],r=new _(e,e,"zeros"),s=new _(e,e,"identity");for(let n=0;nMath.sqrt(t))),V:i}}}class c{constructor(t){return this._N=624,this._M=397,this._MATRIX_A=2567483615,this._UPPER_MASK=2147483648,this._LOWER_MASK=2147483647,this._mt=new Array(this._N),this._mti=this.N+1,this.seed=t||(new Date).getTime(),this}set seed(t){this._seed=t;let e=this._mt;for(e[0]=t>>>0,this._mti=1;this._mti>>30;e[t]=(1812433253*((4294901760&r)>>>16)<<16)+1812433253*(65535&r)+t,e[t]>>>=0}}get seed(){return this._seed}get random(){return this.random_int*(1/4294967296)}get random_int(){let t,e=new Array(0,this._MATRIX_A);if(this._mti>=this._N){let r,s=this._N-this._M,n=this._M-this._N;for(r=0;r>>1^e[1&t];for(;r>>1^e[1&t];t=this._mt[this._N-1]&this._UPPER_MASK|this._mt[0]&this._LOWER_MASK,this._mt[this._N-1]=this._mt[this._M-1]^t>>>1^e[1&t],this._mti=0}return t=this._mt[this._mti+=1],t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0}choice(t,e){if(t instanceof _){let r=t.shape[0];if(e>r)throw new Error("n bigger than A!");let s=new Array(e),n=o(0,r-1);for(let t=0,r=n.length;tt.row(e)))}if(Array.isArray(t)||t instanceof Float64Array){let r=t.length;if(e>r)throw new Error("n bigger than A!");let s=new Array(e),n=o(0,r-1);for(let t=0,r=n.length;tt[e]))}}static choice(t,e,r=1212){return new c(r).choice(t,e)}}function u(t){let e;for(const r of t)null!=r&&(e=r)&&(e=r);return e}function f(t){let e;for(const r of t)null!=r&&(e>r||void 0===e&&r<=r)&&(e=r);return e}class d{constructor(t=null,e=(t=>t),r="min"){return t?d.heapify(t,e,r):(this._accessor=e,this._container=[],this._comparator="min"==r?(t,e)=>tt>e:r,this)}static heapify(t,e=(t=>t),r="min"){const s=new d(null,e,r),n=s._container;for(const r of t)n.push({element:r,value:e(r)});for(let e=Math.floor(t.length/2-1);e>=0;--e)s._heapify_down(e);return s}_swap(t,e){const r=this._container;[r[e],r[t]]=[r[t],r[e]]}_heapify_up(){const t=this._container;let e=t.length-1;for(;e>0;){let r=Math.floor((e-1)/2);if(!this._comparator(t[e].value,t[r].value))break;this._swap(r,e),e=r}}push(t){const e={element:t,value:this._accessor(t)};return this._container.push(e),this._heapify_up(),this}_heapify_down(t=0){const e=this._container,r=this._comparator,s=e.length;let n=2*t+1,i=2*t+2,o=t;if(o>s)throw"index higher than length";n0?this._container[0]:null}*iterate(){for(let t=0,e=this._container.length;tthis._comparator(t,e)?-1:0))}data(){return this._container.map((t=>t.element))}raw_data(){return this._container}get length(){return this._container.length}get empty(){return 0===this.length}}class p{constructor(t=null){if(this._list=new Set,t)for(const e of t)this.make_set(e);return this}make_set(t){const e=this._list;return e.has(t)||(e.add(t),t.__disjoint_set={},t.__disjoint_set.parent=t,t.__disjoint_set.children=new Set([t]),t.__disjoint_set.size=1),this}find(t){return this._list.has(t)?t.__disjoint_set.parent!==t?(t.__disjoint_set.children.add(...t),t.__disjoint_set.parent=this.find(t.__disjoint_set.parent),t.__disjoint_set.parent):t:null}union(t,e){let r=this.find(t),s=this.find(e);return r===s||(r.__disjoint_set.size({index:e,element:t}))),this._root=this._construct(t),this}_construct(t){if(1===t.length)return new this._Leaf(t);{let e,r=this._greatest_spread(t),s=t.sort(((t,e)=>t.element[r]-e.element[r])),n=s.length,i=Math.floor(n/2),o=t[i],a=s.slice(0,i),h=s.slice(i,n),l=Math.max(...t.map((t=>this._metric(o.element,t.element))));return e=a.length>0&&h.length>0?new this._Node(o,this._construct(a),this._construct(h),l):new this._Leaf(t),e}}_greatest_spread(t){let e=t[0].element.length,r=new Array(e);for(let t=0;t{for(let s=0;st[1]-t[0]));let n=0;for(let t=0;ts[n]?t:n;return n}search(t,e=5){return this._search(t,e,new d(null,(e=>this._metric(e.element,t)),"max"),this._root)}_search(t,e,r,s){if(r.length>=e&&s.pivot&&s.radius&&this._metric(t,s.pivot.element)-s.radius>=r.first.value)return r;if(s.child1&&this._search(t,e,r,s.child1),s.child2&&this._search(t,e,r,s.child2),s.points)for(let t=0,n=s.points.length;tr.length?r.push(n):(r.push(n),r.pop())}return r}}class y{constructor(t=null,r=e){this._metric=r,this._elements=t instanceof _?t:_.from(t);const s=this._elements.shape[0];this._D="precomputed"===r?this._elements.clone():i(this._elements,r),this.KNN=[];for(let t=0;tt.value),"min");for(let t=0;tn.push(t.element))),i}}class g{constructor(t,e,r){if(this._parameters=Object.assign(Object.seal(e),r),Array.isArray(t))this._type="array",this.X=_.from(t);else{if(!(t instanceof _))throw new Error("No valid type for X!");this._type="matrix",this.X=t}return[this._N,this._D]=this.X.shape,this._randomizer=new c(this._parameters.seed),this._is_initialized=!1,this}parameter(t,e=null){if(!this._parameters.hasOwnProperty(t))throw new Error(`${t} is not a valid parameter!`);return e?(this._parameters[t]=e,this._is_initialized=!1,this):this._parameters[t]}para(t,e=null){return this.parameter(t,e)}p(t,e=null){return this.parameter(t,e)}transform(){return this.check_init(),this.projection}*generator(){return this.transform()}check_init(){return this._is_initialized||"function"!=typeof this.init||(this.init(),this._is_initialized=!0),this}get projection(){if(this.hasOwnProperty("Y"))return this.check_init(),"matrix"===this._type?this.Y:this.Y.to2dArray;throw new Error("The dataset is not transformed yet!")}async transform_async(...t){return this.transform(...t)}static transform(...t){return new this(...t).transform()}static async transform_async(...t){return this.transform(...t)}static*generator(...t){const e=new this(...t).generator();for(const t of e)yield t}}class w extends g{constructor(t,e){return super(t,{d:2,seed:1212,eig_args:{}},e),this._parameters.eig_args.hasOwnProperty("seed")||(this._parameters.eig_args.seed=this._randomizer),this}transform(t=null){const e=this.principal_components();if(null==t){const t=this.X;return this.Y=t.dot(e),this.projection}if(Array.isArray(t))return _.from(t).dot(e).asArray;if(t instanceof _)return t.dot(e);throw new Error("No valid type for A!")}principal_components(){if(this.V)return this.V;const{d:t,eig_args:e}=this._parameters,r=this.X,s=_.from(r.meanCols),n=r.sub(s),i=n.transpose().dot(n),{eigenvectors:o}=l(i,t,e);return this.V=_.from(o).transpose(),this.V}static principal_components(t,e){return new this(t,e).principal_components()}}class A extends g{constructor(t,r){return super(t,{d:2,metric:e,seed:1212,eig_args:{}},r),this._parameters.eig_args.hasOwnProperty("seed")||(this._parameters.eig_args.seed=this._randomizer),this}transform(){const t=this.X,e=t.shape[0],{d:r,metric:s,eig_args:n}=this._parameters,o="precomputed"===s?t:i(t,s),a=o.meanCols,h=o.meanRows,c=o.mean;this._d_X=o;const u=new _(e,e,((t,e)=>o.entry(t,e)-a[t]-h[e]+c)),{eigenvectors:f}=l(u,r,n);return this.Y=_.from(f).transpose(),this.projection}stress(){const t=this.X.shape[0],r=this.Y,s=this._d_X,n=new _;n.shape=[t,t,(t,s)=>t=0&&!h;){h=!0;for(let e=0;e.01&&(h=!1),o[e]-=n*s,a=t(o)}n*=i>=a?1.05:.4,i=a}return o}class b{constructor(t,e,r,s,n,i,o,a){return this.id=t,this.left=e,this.right=r,this.dist=s,this.index=i,this.size=o??e.size+r.size,this.depth=a??1+Math.max(e.depth,r.depth),this.centroid=n??this._calculate_centroid(e,r),this.parent=null,this}_calculate_centroid(t,e){const r=t.size,s=e.size,n=t.centroid,i=e.centroid,o=this.size,a=t.centroid.length,h=new Float64Array(a);for(let t=0;to&&(r=o),this._randomizer=new c(i),this._clusters=new Array(o).fill(void 0),this._cluster_medoids=this._get_random_medoids(r),this._is_initialized=!1,this}get_clusters(){const t=this._K,e=this._A;this._is_initialized||this.init(t,this._cluster_medoids);const r=new Array(t).fill().map((()=>new Array));return e.forEach(((t,e)=>{r[this._nearest_medoid(t,e).index_nearest].push(e)})),r.medoids=this._cluster_medoids,r}async*generator(){const t=this._max_iter;yield this.get_clusters();let e=!1,r=0;do{e=this._iteration(),yield this.get_clusters()}while(!e&&++rthis._nearest_medoid(t,e))),n=new Array(e).fill(0),i=new Array(e).fill(null);if(t.forEach(((o,a)=>{if(r.findIndex((t=>t===a))<0){const r=s[a].distance_nearest,h=new Array(e).fill(-r);t.forEach(((t,r)=>{if(a===r)return;const n=this._get_distance(r,a,t,o),{index_nearest:i,distance_nearest:l,distance_second:_}=s[r];if(h[i]+=Math.min(n,_)-l,n[t,e])).filter((([t,e])=>t{t=0)return!0;for(;f(n)<0;){const e=n.map(((t,e)=>[t,e])).sort((([t],[e])=>t-e))[0][1];0==r.filter((t=>t==i[e])).length&&(r[e]=i[e]),n[e]=0,n.map(((t,e)=>[t,e])).filter((([t])=>t<0)).forEach((([i,o])=>{const a=t[o];let h=0;t.forEach(((t,n)=>{r.findIndex((t=>t!=o&&t==n))>=0||e!=o&&(s[n].index_nearest===r[o]?h+=Math.min(this._get_distance(n,o,t,a),s[n].distance_second)-s[n].distance_nearest:h+=Math.min(this._get_distance(n,o,t,a)-s[n].distance_nearest,0))})),n[o]=h}))}return this._cluster_medoids=r,!1}_get_distance(t,e,r=null,s=null){if(t===e)return 0;const n=this._distance_matrix,i=this._A,o=this._metric;let a=n.entry(t,e);return 0===a&&(a=o(r||i[t],s||i[e]),n.set_entry(t,e,a),n.set_entry(e,t,a)),a}_nearest_medoid(t,e){const r=this._cluster_medoids,s=this._A,[n,i]=r.map(((r,n)=>{const i=s[r];return[this._get_distance(e,r,t,i),n]})).sort(((t,e)=>t[0]-e[0]));return{distance_nearest:n[0],index_nearest:n[1],distance_second:i[0],index_second:i[1]}}init(t,e){t||(t=this._K),e||(e=this._get_random_medoids(t));const r=this._max_iter;let s=!1,n=0;do{s=this._iteration()}while(!s&&++nh.findIndex((e=>e===t))<0)),i);for(let e=0;ethis._get_distance(i,t,a))));l<0&&(s+=l)}sn&&(n=e,s=i)}n=-1/0;for(let i=0;in&&(n=e,r=i)}return[r,s,n]}transform(){const t=this.X,e=t.shape[0],{d:r,metric:s}=this._parameters,n=new _(e,r,0);let i=(e,r)=>s(t.row(e),t.row(r));for(let t=0;tMath.sqrt(r(e,s)**2-(n.entry(e,t)-n.entry(s,t))**2)}}return this.Y=n,this.projection}},t.Heap=d,t.Hierarchical_Clustering=class{constructor(t,r="complete",s=e){if(this._id=0,this._matrix=t instanceof _?t:_.from(t),this._metric=s,this._linkage=r,"precomputed"===s&&this._matrix.shape[0]!==this._matrix.shape[1])throw new Error("If metric is 'precomputed', then matrix has to be square!");return this.init(),this.root=this.do(),this}get_clusters(t,e="distance"){let r,s=[];switch(e){case"distance":r=t=>t.dist;break;case"depth":r=t=>t.depth;break;default:throw new Error("invalid type")}return this._traverse(this.root,r,t,s),s}_traverse(t,e,r,s){e(t)<=r?s.push(t.leaves()):(this._traverse(t.left,e,r,s),this._traverse(t.right,e,r,s))}init(){const t=this._metric,e=this._matrix,r=this._n=e.shape[0],s=this._d_min=new Float64Array(r);let n;if("precomputed"!==t){n=new _(r,r,0);for(let i=0;in.entry(i,o)&&(s[i]=o)}}else{n=this._matrix.clone();for(let t=0;tn.entry(t,e)&&(s[t]=e)}this._distance_matrix=n;const i=this._clusters=new Array(r),o=this._c_size=new Uint16Array(r);for(let t=0;tr.entry(s,i)&&(e[s]=i,n=r.entry(s,e[s]))}for(let s=0;se<=r?s(t.row(e),t.row(r)):o.entry(r,e)];const a=[];for(let t=0;tt.distance),"min");a.push(s.toArray().slice(1,i+1))}const h=new _(e,e,((t,e)=>{const r=a[t].find((t=>t.index===e));return r?r.distance:1/0}));for(let t=0;t{let r=h.entry(t,e);return r=r===1/0?0:r,c[t]+=r,u[e]+=r,f+=r,r}));c=c.map((t=>t/e)),u=u.map((t=>t/e)),f/=e**2;const m=new _(e,e,((t,e)=>p.entry(t,e)-c[t]-u[e]+f)),{eigenvectors:y}=l(m,r,n);return this.Y=_.from(y).transpose(),this.projection}},t.KMeans=class{constructor(t,r,s=e,n=1987,i=!0){this._metric=s,this._matrix=t,this._K=r;const[o,a]=t.shape;return this._N=o,this._D=a,r>o&&(r=o),this._randomizer=new c(n),this._clusters=new Array(o).fill(void 0),this._cluster_centroids=this._get_random_centroids(r),i&&this.init(r,this._cluster_centroids),this}get_clusters(){const t=this._K,e=this._clusters,r=new Array(t).fill().map((()=>new Array));return e.forEach(((t,e)=>r[t].push(e))),r}_furthest_point(t,e){const r=this._matrix,s=this._metric;let n=t.length;return d.heapify(e,(e=>{const i=r.row(e);let o=0;for(let e=0;e-1==h.indexOf(t))),l),o=this._furthest_point(n.slice(0,e),t);h.push(o),n[e]=s.row(o)}return n}_iteration(t){const e=t.length,r=this._N,s=this._D,n=this._matrix,i=this._metric,o=this._clusters;let a=!1;for(let s=0;st/e))}}init(t,e){t||(t=this._K),e||(e=this._get_random_centroids(t));let r=!1;do{const t=this._iteration(e);e=t.cluster_centroids,r=t.clusters_changed}while(r)}},t.KMedoids=M,t.KNN=y,t.LDA=class extends g{constructor(t,e){return super(t,{labels:null,d:2,seed:1212,eig_args:{}},e),this._parameters.eig_args.hasOwnProperty("seed")||(this._parameters.eig_args.seed=this._randomizer),this}transform(){const t=this.X,[e,r]=t.shape,{d:s,labels:n,eig_args:i}=this._parameters;if(null===n||n.length!=e)throw new Error("LDA needs parameter label to every datapoint to work!");const o={};let a=0;n.forEach(((e,r)=>{e in o?(o[e].count++,o[e].rows.push(t.row(r))):o[e]={id:a++,count:1,rows:[t.row(r)]}}));const h=t.mean,c=new _(a,r);for(const t in o){const e=_.from(o[t].rows).meanCols;for(let s=0;se[t]-h)),n=o[t].count;u=u.add(s.dot(s.transpose()).mult(n))}let f=new _(r,r);for(const t in o){const e=c.row(o[t].id),s=new _(r,1,(t=>e[t])),n=o[t].rows;for(let e=0,i=o[t].count;en[e][t]-s.entry(t,0)));f=f.add(t.dot(t.transpose()))}}let{eigenvectors:d}=l(f.inverse().dot(u),s,i);return d=_.from(d).transpose(),this.Y=t.dot(d),this.projection}},t.LLE=class extends g{constructor(t,r){return super(t,{neighbors:void 0,d:2,metric:e,seed:1212,eig_args:{}},r),this.parameter("neighbors",Math.min(r.neighbors??Math.max(Math.floor(this._N/10),2),this._N-1)),this._parameters.eig_args.hasOwnProperty("seed")||(this._parameters.eig_args.seed=this._randomizer),this}transform(){const t=this.X,e=this._N,s=this._D,{neighbors:i,d:o,eig_args:a,metric:h}=this._parameters,c=n(t,i,h),u=new _(i,1,1),f=new _(e,e);for(let n=0;nt.entry(e[r].j,s)-t.entry(n,s))),a=o.dot(o.T);if(i>s){const t=r(a.diag)/1e3;for(let e=0;e{u.set_entry(e,t,1)}));const f=new t(_.from(c.map((t=>s.row(t)))),e).transform(),d=s.to2dArray,p=new r(d,h),y=new _(n,n,"I"),g=-1/i;d.forEach(((t,e)=>{for(const{index:r}of p.search(t,i).iterate())e!==r&&y.set_entry(e,r,g)}));const w=y.concat(u,"vertical"),x=new _(n,o,"zeros").concat(f,"vertical");return this._A=w,this._b=x,this._is_initialized=!0,this}transform(){this.check_init();const t=this._A,e=t.T,r=this._b,s=e.dot(t),n=e.dot(r);return this.Y=_.solve_CG(s,n,this._randomizer),this.projection}},t.LTSA=class extends g{constructor(t,r){if(super(t,{neighbors:void 0,d:2,metric:e,seed:1212,eig_args:{}},r),this.parameter("neighbors",Math.min(r.neighbors??Math.max(Math.floor(this._N/10),2),this._N-1)),this._parameters.eig_args.hasOwnProperty("seed")||(this._parameters.eig_args.seed=this._randomizer),this._D<=this.parameter("d"))throw new Error(`Dimensionality of X (D = ${this._D}) must be greater than the required dimensionality of the result (d = ${this.parameter("d")})!`);return this}transform(){const t=this.X,[e,r]=t.shape,{d:s,neighbors:i,metric:o,eig_args:a}=this._parameters,h=n(t,i,o),c=new _(r,r,"center"),u=new _(e,e,0);for(let r=0;rt.j))];let n=_.from(e.map((e=>t.row(e))));n=n.dot(c);const o=n.dot(n.transpose()),{eigenvectors:f}=l(o,s,a),d=_.from(f),p=d.transpose().dot(d).add(1/Math.sqrt(i+1));for(let t=0;tt.reachability_distance),"min");this._update(e,t),this._expand_cluster(t,n[i])}return this}_get_neighbors(t){if("neighbors"in t)return t.neighbors;const e=this._DB,r=this._metric,s=this._epsilon,n=[];for(const i of e)i.index!=t.index&&r(t.element,i.element)t.element==i))<0?(i.reachability_distance=n,e.push(i)):nt.reachability_distance),"min"))}}_expand_cluster(t,e){const r=this._ordered_list;for(;!t.empty;){const s=t.pop().element;s.neighbors=this._get_neighbors(s),s.processed=!0,e.push(s.index),r.push(s),null!=this._core_distance(s)&&(this._update(s,t),this._expand_cluster(t,e))}}get_clusters(){const t=[],e=[],r=this._min_points;for(const s of this._clusters)s.lengthr.random))}else{if(!["PCA","MDS"].includes(s))throw new Error('init_DR needs to be either "random" or a DR method!');this.Y=_.from("PCA"==s?w.transform(this.X,n):A.transform(this.X,n))}return this.distance_matrix="precomputed"==r?_.from(this.X):i(this.X,r),this}transform(t=200){this._is_initialized||this.init();for(let e=0;ethis._randomizer.random)),this}init(){const t=Math.log(this.parameter("perplexity")),e=this._N,r=this._D,{metric:s}=this._parameters,n=this.X;let i;if("precomputed"==s)i=druid.Matrix.from(n);else{i=new _(e,e);for(let t=0;t1e-7&&(c-=e*Math.log(e))}c>t?(s=h,h=n===1/0?2*h:(h+n)/2):(n=h,h=s===-1/0?h/2:(h+s)/2),++_,Math.abs(c-t)<1e-4&&(l=!0),_>=50&&(l=!0)}for(let t=0;tt[2]-e[2]));for(const[t,e,r]of o){const o=n.find(s[t]),a=n.find(s[e]);o!==a&&(i.push([t,e,r]),n.union(o,a))}return i.sort(((t,e)=>t[2]-e[2]))}init(){const{metric:t}=this._parameters;return this.Y=new _(this._N,2,0),this._Emst=this._make_minimum_spanning_tree(t),this._is_initialized=!0,this}__hull_cross([t,e],[r,s],[n,i]){return(r-t)*(i-e)-(s-e)*(n-t)<=0}__hull(t){const e=t.sort((([t,e],[r,s])=>e-s||t-r)),r=e.length;if(r<=2)return e;const s=[];for(let t=0;t=2&&this.__hull_cross(s[s.length-2],s[s.length-1],e[t]);)s.pop();s.push(e[t])}const n=[];for(let t=r-1;t>=0;--t){for(;n.length>=2&&this.__hull_cross(n[n.length-2],n[n.length-1],e[t]);)n.pop();n.push(e[t])}return n.pop(),s.pop(),s.concat(n)}__findAngle([t,r],[s,n]){const i=e([t,r],[s,n]);if(0===i)return{sin:0,cos:1};const o=[(s-t)/i,(n-r)/i],a=o[0];let h=Math.sqrt(1-a*a);return h=o[1]>=0?-h:h,{sin:h,cos:a}}__align_hull(t,r,s){let n,i,o,a=-1;for(let s=0;si)&&(n=i,a=s)}s?(i=t[a],o=t[(a+1)%t.length]):(0==a&&(a=t.length-1),i=t[a],o=t[(a-1)%t.length]);const h={tx:-t[a][0],ty:-t[a][1]};if(t.length>=2){const{sin:t,cos:e}=this.__findAngle(i,o);h.sin=t,h.cos=e}else h.sin=0,h.cos=1;return h}__transform([t,e],{tx:r,ty:s,sin:n,cos:i}){let o=t+r,a=e+s;return[o*i-a*n,o*n+a*i]}__transform_component(t,e,r){const s=t.length;for(let n=0;n(t.i=e,t))));for(const[s,n,i]of t){const t=r.find(e[s]),o=r.find(e[n]);t!==o&&(this.__align_components(t,o,i),r.union(t,o))}return this.projection}*generator(){this._is_initialized||this.init();const t=this._Emst,e=this.Y.to2dArray,r=new p(e.map(((t,e)=>(t.i=e,t))));for(const[s,n,i]of t){const t=r.find(e[s]),o=r.find(e[n]);t!==o&&(this.__align_components(t,o,i),r.union(t,o),yield this.projection)}return this.projection}},t.TriMap=class extends g{constructor(t,r){return super(t,{weight_adj:500,c:5,d:2,metric:e,tol:1e-8,seed:1212},r),this}init(t=null,e=null){const r=this.X,s=r.shape[0],{d:n,metric:i,c:o}=this._parameters;this.n_inliers=2*o,this.n_outliers=1*o,this.n_random=1*o,this.Y=t||new w(r,n).transform(),this.knn=e||new m(r.to2dArray,i);const{triplets:a,weights:h}=this._generate_triplets(this.n_inliers,this.n_outliers,this.n_random);return this.triplets=a,this.weights=h,this.lr=1e3*s/a.shape[0],this.C=1/0,this.vel=new _(s,n,0),this.gain=new _(s,n,1),this}_generate_triplets(t,e,r){const{metric:s,weight_adj:n}=this._parameters,i=this.X,o=i.shape[0],a=this.knn,h=Math.min(t+20,o),l=new _(o,h),c=new _(o,h);for(let t=0;t0!=t.value)).sort(((t,e)=>t.value-e.value)).forEach(((e,r)=>{l.set_entry(t,r,e.element.index),c.set_entry(t,r,e.value)}));const u=new Float64Array(o);for(let t=0;t0){const{random_triplets:t,random_weights:e}=this._sample_random_triplets(i,r,u);d=d.concat(t,"vertical"),y=Float64Array.from([...y,...e])}p=d.shape[0];let g=-1/0;for(let t=0;tMath.exp(-(t.entry(s,n)**2)/e[s]/e[r.entry(s,n)])))}_sample_knn_triplets(t,e,r,s){const n=e.shape[0],i=new _(n*r*s,3);for(let o=0;o-t)));for(let t=0;t({d:t,i:e}))).sort(((t,e)=>t.d-e.d)).map((t=>t.i))}_rejection_sample(t,e,r){const s=this._randomizer,n=o(0,e-1).filter((t=>r.indexOf(t)<0));return s.choice(n,Math.min(t,n.length-2))}_find_weights(t,e,r,s,n){const i=t.shape[0],o=new Float64Array(i);for(let a=0;a=m){u=1,f=1;for(let e=0;ef&&++d,p+=n[e]/(1+f/u);const y=(n[e]/(u+f))**2;for(let t=0;t150?.5:.3,r=this.C,s=this.vel,n=this.Y.add(s.mult(e)),{grad:i,loss:o,n_viol:a}=this._grad(n);return this.C=o,this.Y=this._update_embedding(n,t,i),this.lr*=r>o+this._parameters.tol?1.01:.9,this.Y}_update_embedding(t,e,r){const[s,n]=t.shape,i=e>150?.9:.5,o=this.gain,a=this.vel,h=this.lr;for(let e=0;ethis._N)throw new Error(`Parameter n_neighbors (=${this.parameter("n_neighbors")}) needs to be smaller than dataset size (N=${this._N})!`);if(this.parameter("local_connectivity")>this.parameter("n_neighbors"))throw new Error(`Parameter local_connectivity (=${this.parameter("local_connectivity")}) needs to be smaller than parameter n_neighbors (=${this.parameter("n_neighbors")})`);this._iter=0;const s=this._randomizer;return this.Y=new _(this._N,this.parameter("d"),(()=>s.random)),this}_find_ab_params(t,e){const s=o(0,3*t,300),n=o(0,3*t,300);for(let r=0,i=s.length;r{const e=o(1,300).map(((e,r)=>{return n[r]-(i=s[r],o=t[0],a=t[1],1/(1+o*Math.pow(i,2*a)));var i,o,a}));return Math.sqrt(r(e.map((t=>t*t))))}),[1,1])}_compute_membership_strengths(t,e,r){for(let s=0,n=t.length;s0?Math.exp(-i/e[s]):1}return t}_smooth_knn_dist(t,e){const r=1e-5,s=.001,{local_connectivity:n,metric:i}=this._parameters,o=Math.log2(e),a=[],h=[],l=this.X,_=l.shape[0],c=[];if("precomputed"===i)for(let r=0;r<_;++r)c.push(t.search(r,e).reverse());else for(const r of l)c.push(t.search(r,e).raw_data().reverse());for(let t=0;t<_;++t){let i=0,l=1/0,_=1;const u=c[t],f=u.filter((t=>t.value>0)),d=f.length;if(d>=n){const e=Math.floor(n),s=n-e;e>0?(a.push(f[e-1]),s>r&&(a[t].value+=s*(f[e].value-f[e-1]))):a[t].value=s*f[0].value}else d>0&&(a[t]=f[d-1].value);for(let s=0;s<64;++s){let s=0;for(let r=0;r0?Math.exp(-e/_):1}if(Math.abs(s-o)o?[l,_]=[_,(i+l)/2]:[i,_]=l===1/0?[_,2*_]:[_,(i+l)/2]}h[t]=_;const p=u.reduce(((t,e)=>t+e.value),0)/u.length;if(a[t]>0)h[t]t+e.reduce(((t,e)=>t+e.value),0)/e.length));h[t]>s*e&&(h[t]=s*e)}}return{distances:c,sigmas:h,rhos:a}}_fuzzy_simplicial_set(t,e){const r=t.shape[0],{metric:s,_set_op_mix_ratio:n}=this._parameters,i="precomputed"===s?new y(t,"precomputed"):new m(t.to2dArray,s);let{distances:o,sigmas:a,rhos:h}=this._smooth_knn_dist(i,e);o=this._compute_membership_strengths(o,a,h);const l=new _(r,r,"zeros");for(let t=0;tt*(e/s)));for(let e=0;e0&&(r[e]=Math.round(t/n[e]));return r}_tocoo(t){const e=[],r=[],s=[],[n,i]=t.shape;for(let o=0;ot*n)),this._epoch_of_next_sample=this._epochs_per_sample.slice(),this._epoch_of_next_negative_sample=this._epochs_per_negative_sample.slice(),this}graph(){return this.check_init(),{cols:this._head,rows:this._tail,weights:this._weights}}transform(t=350){this.parameter("_n_epochs")!=t&&(this.parameter("_n_epochs",t),this.init()),this.check_init();for(let e=0;e4?4:t<-4?-4:t}_optimize_layout(t,e,r,n){const i=this._randomizer,{_repulsion_strength:o,d:a}=this._parameters,{_alpha:h,_a:l,_b:_,_epochs_per_sample:c,_epochs_per_negative_sample:u,_epoch_of_next_negative_sample:f,_epoch_of_next_sample:d,_clip:p}=this,m=n.length;for(let y=0,g=c.length;y0&&(M=-2*l*_*Math.pow(b,_-1)/(l*Math.pow(b,_)+1));for(let r=0;r0)f=2*o*_/((.01+u)*(l*Math.pow(u,_)+1));else if(g===r)continue;for(let s=0;st/s))},t.powell=x,t.qr=h,t.qr_householder=function(t){const[e,r]=t.shape,s=new _(e,e,"I"),n=t.clone();for(let t=0;t=Math.abs(e)?s+=r-i+e:s+=e-i+r,r=i}return r+s}function s(t,e){if(t.length!=e.length)return;let s=t.length,n=new Array(s);for(let r=0;r({i:t,j:r,distance:e}))).sort(((t,e)=>t.distance-e.distance)).slice(1,r+1);return a}function i(t,r=e){let s=t.shape[0];const n=new _(s,s);for(let e=0;e=0;--n)s[n]=(n*e+(r-n)*t)/r;return s}function a(t,r=e){let s=null;if(t instanceof _){let[e,r]=t.shape;if(1===e)s=t.row(0);else{if(1!==r)throw new Error("Matrix must be 1d!");s=t.col(0)}}else s=t;const n=s.length;return r(s,Float64Array.from({length:n},(()=>0)))}function h(t){const[s,n]=t.shape,i=new _(s,n,"identity"),o=new _(n,n,0);for(let h=0;ht*n[e])));o.set_entry(t,h,s),n=n.map(((t,r)=>t-s*e[r]))}const l=a(n,e);for(let t=0;t2*(a.random-.5))));for(;n--;){const e=u.clone(),r=i(t.dot(u));u=r.Q,f=r.R;if(s(u.values,e.values)(e===r?1:0)-1/t;for(let s=0;st[r]));if("col"===e)return new _(r,1,(e=>t[e]));if("diag"===e)return new _(r,r,((e,r)=>e==r?t[e]:0));throw new Error("1d array has NaN entries")}if(Array.isArray(t[0])||t[0]instanceof Float64Array){let e=t[0].length;for(let s=0;st[e][r]))}}}row(t){const e=this.values,r=this._cols;return e.subarray(t*r,(t+1)*r)}*iterate_rows(){const t=this._cols,e=this._rows,r=this.values;for(let s=0;sthis.entry(e,t)))}get T(){return this.transpose()}inverse(){const t=this._rows,e=this._cols;let r=new _(t,2*e,((t,r)=>r>=e?t===r-e?1:0:this.entry(t,r))),s=0,n=0;for(;s=0;--s){let t=r.entry(s,s);for(let n=0;nr.entry(t,s+e)))}dot(t){if(t instanceof _){let e=this;if(e.shape[1]!==t.shape[0])throw new Error(`A.dot(B): A is a ${e.shape.join(" ⨯ ")}-Matrix, B is a ${t.shape.join(" ⨯ ")}-Matrix: \n A has ${e.shape[1]} cols and B ${t.shape[0]} rows. \n Must be equal!`);let r=e.shape[1];return new _(e.shape[0],t.shape[1],((s,n)=>{const i=e.row(s),o=t.col(n);let a=0;for(let t=0;te*t[n])));return s}throw new Error("B must be Matrix or Array")}outer(t){let e=this,r=e._data.length;if(r!=t._data.length)return;let s=new _;return s.shape=[r,r,(r,n)=>r<=n?e._data[r]*t._data[n]:s.entry(n,r)],s}concat(t,e="horizontal"){const r=this,[s,n]=r.shape,[i,o]=t.shape;if("horizontal"==e){if(s!=i)throw new Error(`A.concat(B, "horizontal"): A and B need same number of rows, A has ${s} rows, B has ${i} rows.`);const e=new _(s,n+o,"zeros");return e.set_block(0,0,r),e.set_block(0,n,t),e}if("vertical"==e){if(n!=o)throw new Error(`A.concat(B, "vertical"): A and B need same number of columns, A has ${n} columns, B has ${o} columns.`);const e=new _(s+i,n,"zeros");return e.set_block(0,0,r),e.set_block(s,0,t),e}if("diag"==e){const e=new _(s+i,n+o,"zeros");return e.set_block(0,0,r),e.set_block(s,n,t),e}throw new Error(`type must be "horizontal" or "vertical", but type is ${e}!`)}set_block(t,e,r){let[s,n]=r.shape;for(let i=0;ithis._rows))for(let s=0;sthis._cols||this.set_entry(i+t,s+e,r.entry(i,s));return this}get_block(t,e,r=null,s=null){const[n,i]=this.shape;if(s=s??i,(r=r??n)<=t||s<=e)throw new Error(`\n end_row must be greater than start_row, and \n end_col must be greater than start_col, but\n end_row = ${r}, start_row = ${t}, end_col = ${s}, and start_col = ${e}!`);const o=new _(r-t,s-e,"zeros");for(let n=t,i=0;nt[r]))}_apply_colwise_array(t,e){const r=this.values,[s,n]=this.shape;for(let i=0;it*e))}divide(t){return this.clone()._apply(t,((t,e)=>t/e))}add(t){return this.clone()._apply(t,((t,e)=>t+e))}sub(t){return this.clone()._apply(t,((t,e)=>t-e))}get shape(){return[this._rows,this._cols]}set shape([t,e,r=(()=>0)]){this._rows=t,this._cols=e,this._data=new Float64Array(t*e);for(let s=0;sr.random)),l=i.sub(t.dot(h)),c=l.clone();do{const e=t.dot(c),r=l.T.dot(l).entry(0,0)/c.T.dot(e).entry(0,0);h=h.add(c.mult(r));const s=l.sub(e.mult(r)),n=s.T.dot(s).entry(0,0)/l.T.dot(l).entry(0,0);c=s.add(c.mult(n)),l=s}while(Math.abs(l.mean)>s);o=o.concat(h,"horizontal")}return o}static solve(t,e){let{L:r,U:s}="L"in t&&"U"in t?t:_.LU(t),n=r.shape[0],i=e.clone();for(let t=0;t=0;--t){for(let e=n-1;e>t;--e)i.set_entry(0,t,i.entry(0,t)-s.entry(t,e)*i.entry(0,e));i.set_entry(0,t,i.entry(0,t)/s.entry(t,t))}return i}static LU(t){const e=t.shape[0],r=new _(e,e,"zeros"),s=new _(e,e,"identity");for(let n=0;nMath.sqrt(t))),V:i}}}class c{constructor(t){return this._N=624,this._M=397,this._MATRIX_A=2567483615,this._UPPER_MASK=2147483648,this._LOWER_MASK=2147483647,this._mt=new Array(this._N),this._mti=this.N+1,this.seed=t||(new Date).getTime(),this}set seed(t){this._seed=t;let e=this._mt;for(e[0]=t>>>0,this._mti=1;this._mti>>30;e[t]=(1812433253*((4294901760&r)>>>16)<<16)+1812433253*(65535&r)+t,e[t]>>>=0}}get seed(){return this._seed}get random(){return this.random_int*(1/4294967296)}get random_int(){let t,e=new Array(0,this._MATRIX_A);if(this._mti>=this._N){let r,s=this._N-this._M,n=this._M-this._N;for(r=0;r>>1^e[1&t];for(;r>>1^e[1&t];t=this._mt[this._N-1]&this._UPPER_MASK|this._mt[0]&this._LOWER_MASK,this._mt[this._N-1]=this._mt[this._M-1]^t>>>1^e[1&t],this._mti=0}return t=this._mt[this._mti+=1],t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0}choice(t,e){if(t instanceof _){let r=t.shape[0];if(e>r)throw new Error("n bigger than A!");let s=new Array(e),n=o(0,r-1);for(let t=0,r=n.length;tt.row(e)))}if(Array.isArray(t)||t instanceof Float64Array){let r=t.length;if(e>r)throw new Error("n bigger than A!");let s=new Array(e),n=o(0,r-1);for(let t=0,r=n.length;tt[e]))}}static choice(t,e,r=1212){return new c(r).choice(t,e)}}function u(t){let e;for(const r of t)null!=r&&(e=r)&&(e=r);return e}function f(t){let e;for(const r of t)null!=r&&(e>r||void 0===e&&r<=r)&&(e=r);return e}class d{constructor(t=null,e=(t=>t),r="min"){return t?d.heapify(t,e,r):(this._accessor=e,this._container=[],this._comparator="min"==r?(t,e)=>tt>e:r,this)}static heapify(t,e=(t=>t),r="min"){const s=new d(null,e,r),n=s._container;for(const r of t)n.push({element:r,value:e(r)});for(let e=Math.floor(t.length/2-1);e>=0;--e)s._heapify_down(e);return s}_swap(t,e){const r=this._container;[r[e],r[t]]=[r[t],r[e]]}_heapify_up(){const t=this._container;let e=t.length-1;for(;e>0;){let r=Math.floor((e-1)/2);if(!this._comparator(t[e].value,t[r].value))break;this._swap(r,e),e=r}}push(t){const e={element:t,value:this._accessor(t)};return this._container.push(e),this._heapify_up(),this}_heapify_down(t=0){const e=this._container,r=this._comparator,s=e.length;let n=2*t+1,i=2*t+2,o=t;if(o>s)throw"index higher than length";n0?this._container[0]:null}*iterate(){for(let t=0,e=this._container.length;tthis._comparator(t,e)?-1:0))}data(){return this._container.map((t=>t.element))}raw_data(){return this._container}get length(){return this._container.length}get empty(){return 0===this.length}}class p{constructor(t=null){if(this._list=new Set,t)for(const e of t)this.make_set(e);return this}make_set(t){const e=this._list;return e.has(t)||(e.add(t),t.__disjoint_set={},t.__disjoint_set.parent=t,t.__disjoint_set.children=new Set([t]),t.__disjoint_set.size=1),this}find(t){return this._list.has(t)?t.__disjoint_set.parent!==t?(t.__disjoint_set.children.add(...t),t.__disjoint_set.parent=this.find(t.__disjoint_set.parent),t.__disjoint_set.parent):t:null}union(t,e){let r=this.find(t),s=this.find(e);return r===s||(r.__disjoint_set.size({index:e,element:t}))),this._root=this._construct(t),this}_construct(t){if(1===t.length)return new this._Leaf(t);{let e,r=this._greatest_spread(t),s=t.sort(((t,e)=>t.element[r]-e.element[r])),n=s.length,i=Math.floor(n/2),o=t[i],a=s.slice(0,i),h=s.slice(i,n),l=Math.max(...t.map((t=>this._metric(o.element,t.element))));return e=a.length>0&&h.length>0?new this._Node(o,this._construct(a),this._construct(h),l):new this._Leaf(t),e}}_greatest_spread(t){let e=t[0].element.length,r=new Array(e);for(let t=0;t{for(let s=0;st[1]-t[0]));let n=0;for(let t=0;ts[n]?t:n;return n}search(t,e=5){return this._search(t,e,new d(null,(e=>this._metric(e.element,t)),"max"),this._root)}_search(t,e,r,s){if(r.length>=e&&s.pivot&&s.radius&&this._metric(t,s.pivot.element)-s.radius>=r.first.value)return r;if(s.child1&&this._search(t,e,r,s.child1),s.child2&&this._search(t,e,r,s.child2),s.points)for(let t=0,n=s.points.length;tr.length?r.push(n):(r.push(n),r.pop())}return r}}class y{constructor(t=null,r=e){this._metric=r,this._elements=t instanceof _?t:_.from(t);const s=this._elements.shape[0];this._D="precomputed"===r?this._elements.clone():i(this._elements,r),this.KNN=[];for(let t=0;tt.value),"min");for(let t=0;tn.push(t.element))),i}}class g{constructor(t,e,r){if(this._parameters=Object.assign(Object.seal(e),r),Array.isArray(t))this._type="array",this.X=_.from(t);else{if(!(t instanceof _))throw new Error("No valid type for X!");this._type="matrix",this.X=t}return[this._N,this._D]=this.X.shape,this._randomizer=new c(this._parameters.seed),this._is_initialized=!1,this}parameter(t,e=null){if(!this._parameters.hasOwnProperty(t))throw new Error(`${t} is not a valid parameter!`);return null!==e?(this._parameters[t]=e,this._is_initialized=!1,this):this._parameters[t]}para(t,e=null){return this.parameter(t,e)}p(t,e=null){return this.parameter(t,e)}transform(){return this.check_init(),this.projection}*generator(){return this.transform()}check_init(){return this._is_initialized||"function"!=typeof this.init||(this.init(),this._is_initialized=!0),this}get projection(){if(this.hasOwnProperty("Y"))return this.check_init(),"matrix"===this._type?this.Y:this.Y.to2dArray;throw new Error("The dataset is not transformed yet!")}async transform_async(...t){return this.transform(...t)}static transform(...t){return new this(...t).transform()}static async transform_async(...t){return this.transform(...t)}static*generator(...t){const e=new this(...t).generator();for(const t of e)yield t}}class w extends g{constructor(t,e){return super(t,{d:2,seed:1212,eig_args:{}},e),this._parameters.eig_args.hasOwnProperty("seed")||(this._parameters.eig_args.seed=this._randomizer),this}transform(t=null){const e=this.principal_components();if(null==t){const t=this.X;return this.Y=t.dot(e),this.projection}if(Array.isArray(t))return _.from(t).dot(e).asArray;if(t instanceof _)return t.dot(e);throw new Error("No valid type for A!")}principal_components(){if(this.V)return this.V;const{d:t,eig_args:e}=this._parameters,r=this.X,s=_.from(r.meanCols),n=r.sub(s),i=n.transpose().dot(n),{eigenvectors:o}=l(i,t,e);return this.V=_.from(o).transpose(),this.V}static principal_components(t,e){return new this(t,e).principal_components()}}class A extends g{constructor(t,r){return super(t,{d:2,metric:e,seed:1212,eig_args:{}},r),this._parameters.eig_args.hasOwnProperty("seed")||(this._parameters.eig_args.seed=this._randomizer),this}transform(){const t=this.X,e=t.shape[0],{d:r,metric:s,eig_args:n}=this._parameters,o="precomputed"===s?t:i(t,s),a=o.meanCols,h=o.meanRows,c=o.mean;this._d_X=o;const u=new _(e,e,((t,e)=>o.entry(t,e)-a[t]-h[e]+c)),{eigenvectors:f}=l(u,r,n);return this.Y=_.from(f).transpose(),this.projection}stress(){const t=this.X.shape[0],r=this.Y,s=this._d_X,n=new _;n.shape=[t,t,(t,s)=>t=0&&!h;){h=!0;for(let e=0;e.01&&(h=!1),o[e]-=n*s,a=t(o)}n*=i>=a?1.05:.4,i=a}return o}class b{constructor(t,e,r,s,n,i,o,a){return this.id=t,this.left=e,this.right=r,this.dist=s,this.index=i,this.size=o??e.size+r.size,this.depth=a??1+Math.max(e.depth,r.depth),this.centroid=n??this._calculate_centroid(e,r),this.parent=null,this}_calculate_centroid(t,e){const r=t.size,s=e.size,n=t.centroid,i=e.centroid,o=this.size,a=t.centroid.length,h=new Float64Array(a);for(let t=0;to&&(r=o),this._randomizer=new c(i),this._clusters=new Array(o).fill(void 0),this._cluster_medoids=this._get_random_medoids(r),this._is_initialized=!1,this}get_clusters(){const t=this._K,e=this._A;this._is_initialized||this.init(t,this._cluster_medoids);const r=new Array(t).fill().map((()=>new Array));return e.forEach(((t,e)=>{r[this._nearest_medoid(t,e).index_nearest].push(e)})),r.medoids=this._cluster_medoids,r}async*generator(){const t=this._max_iter;yield this.get_clusters();let e=!1,r=0;do{e=this._iteration(),yield this.get_clusters()}while(!e&&++rthis._nearest_medoid(t,e))),n=new Array(e).fill(0),i=new Array(e).fill(null);if(t.forEach(((o,a)=>{if(r.findIndex((t=>t===a))<0){const r=s[a].distance_nearest,h=new Array(e).fill(-r);t.forEach(((t,r)=>{if(a===r)return;const n=this._get_distance(r,a,t,o),{index_nearest:i,distance_nearest:l,distance_second:_}=s[r];if(h[i]+=Math.min(n,_)-l,n[t,e])).filter((([t,e])=>t{t=0)return!0;for(;f(n)<0;){const e=n.map(((t,e)=>[t,e])).sort((([t],[e])=>t-e))[0][1];0==r.filter((t=>t==i[e])).length&&(r[e]=i[e]),n[e]=0,n.map(((t,e)=>[t,e])).filter((([t])=>t<0)).forEach((([i,o])=>{const a=t[o];let h=0;t.forEach(((t,n)=>{r.findIndex((t=>t!=o&&t==n))>=0||e!=o&&(s[n].index_nearest===r[o]?h+=Math.min(this._get_distance(n,o,t,a),s[n].distance_second)-s[n].distance_nearest:h+=Math.min(this._get_distance(n,o,t,a)-s[n].distance_nearest,0))})),n[o]=h}))}return this._cluster_medoids=r,!1}_get_distance(t,e,r=null,s=null){if(t===e)return 0;const n=this._distance_matrix,i=this._A,o=this._metric;let a=n.entry(t,e);return 0===a&&(a=o(r||i[t],s||i[e]),n.set_entry(t,e,a),n.set_entry(e,t,a)),a}_nearest_medoid(t,e){const r=this._cluster_medoids,s=this._A,[n,i]=r.map(((r,n)=>{const i=s[r];return[this._get_distance(e,r,t,i),n]})).sort(((t,e)=>t[0]-e[0]));return{distance_nearest:n[0],index_nearest:n[1],distance_second:i[0],index_second:i[1]}}init(t,e){t||(t=this._K),e||(e=this._get_random_medoids(t));const r=this._max_iter;let s=!1,n=0;do{s=this._iteration()}while(!s&&++nh.findIndex((e=>e===t))<0)),i);for(let e=0;ethis._get_distance(i,t,a))));l<0&&(s+=l)}sn&&(n=e,s=i)}n=-1/0;for(let i=0;in&&(n=e,r=i)}return[r,s,n]}transform(){const t=this.X,e=t.shape[0],{d:r,metric:s}=this._parameters,n=new _(e,r,0);let i=(e,r)=>s(t.row(e),t.row(r));for(let t=0;tMath.sqrt(r(e,s)**2-(n.entry(e,t)-n.entry(s,t))**2)}}return this.Y=n,this.projection}},t.Heap=d,t.Hierarchical_Clustering=class{constructor(t,r="complete",s=e){if(this._id=0,this._matrix=t instanceof _?t:_.from(t),this._metric=s,this._linkage=r,"precomputed"===s&&this._matrix.shape[0]!==this._matrix.shape[1])throw new Error("If metric is 'precomputed', then matrix has to be square!");return this.init(),this.root=this.do(),this}get_clusters(t,e="distance"){let r,s=[];switch(e){case"distance":r=t=>t.dist;break;case"depth":r=t=>t.depth;break;default:throw new Error("invalid type")}return this._traverse(this.root,r,t,s),s}_traverse(t,e,r,s){e(t)<=r?s.push(t.leaves()):(this._traverse(t.left,e,r,s),this._traverse(t.right,e,r,s))}init(){const t=this._metric,e=this._matrix,r=this._n=e.shape[0],s=this._d_min=new Float64Array(r);let n;if("precomputed"!==t){n=new _(r,r,0);for(let i=0;in.entry(i,o)&&(s[i]=o)}}else{n=this._matrix.clone();for(let t=0;tn.entry(t,e)&&(s[t]=e)}this._distance_matrix=n;const i=this._clusters=new Array(r),o=this._c_size=new Uint16Array(r);for(let t=0;tr.entry(s,i)&&(e[s]=i,n=r.entry(s,e[s]))}for(let s=0;se<=r?s(t.row(e),t.row(r)):o.entry(r,e)];const a=[];for(let t=0;tt.distance),"min");a.push(s.toArray().slice(1,i+1))}const h=new _(e,e,((t,e)=>{const r=a[t].find((t=>t.index===e));return r?r.distance:1/0}));for(let t=0;t{let r=h.entry(t,e);return r=r===1/0?0:r,c[t]+=r,u[e]+=r,f+=r,r}));c=c.map((t=>t/e)),u=u.map((t=>t/e)),f/=e**2;const m=new _(e,e,((t,e)=>p.entry(t,e)-c[t]-u[e]+f)),{eigenvectors:y}=l(m,r,n);return this.Y=_.from(y).transpose(),this.projection}},t.KMeans=class{constructor(t,r,s=e,n=1987,i=!0){this._metric=s,this._matrix=t,this._K=r;const[o,a]=t.shape;return this._N=o,this._D=a,r>o&&(r=o),this._randomizer=new c(n),this._clusters=new Array(o).fill(void 0),this._cluster_centroids=this._get_random_centroids(r),i&&this.init(r,this._cluster_centroids),this}get_clusters(){const t=this._K,e=this._clusters,r=new Array(t).fill().map((()=>new Array));return e.forEach(((t,e)=>r[t].push(e))),r}_furthest_point(t,e){const r=this._matrix,s=this._metric;let n=t.length;return d.heapify(e,(e=>{const i=r.row(e);let o=0;for(let e=0;e-1==h.indexOf(t))),l),o=this._furthest_point(n.slice(0,e),t);h.push(o),n[e]=s.row(o)}return n}_iteration(t){const e=t.length,r=this._N,s=this._D,n=this._matrix,i=this._metric,o=this._clusters;let a=!1;for(let s=0;st/e))}}init(t,e){t||(t=this._K),e||(e=this._get_random_centroids(t));let r=!1;do{const t=this._iteration(e);e=t.cluster_centroids,r=t.clusters_changed}while(r)}},t.KMedoids=M,t.KNN=y,t.LDA=class extends g{constructor(t,e){return super(t,{labels:null,d:2,seed:1212,eig_args:{}},e),this._parameters.eig_args.hasOwnProperty("seed")||(this._parameters.eig_args.seed=this._randomizer),this}transform(){const t=this.X,[e,r]=t.shape,{d:s,labels:n,eig_args:i}=this._parameters;if(null===n||n.length!=e)throw new Error("LDA needs parameter label to every datapoint to work!");const o={};let a=0;n.forEach(((e,r)=>{e in o?(o[e].count++,o[e].rows.push(t.row(r))):o[e]={id:a++,count:1,rows:[t.row(r)]}}));const h=t.mean,c=new _(a,r);for(const t in o){const e=_.from(o[t].rows).meanCols;for(let s=0;se[t]-h)),n=o[t].count;u=u.add(s.dot(s.transpose()).mult(n))}let f=new _(r,r);for(const t in o){const e=c.row(o[t].id),s=new _(r,1,(t=>e[t])),n=o[t].rows;for(let e=0,i=o[t].count;en[e][t]-s.entry(t,0)));f=f.add(t.dot(t.transpose()))}}let{eigenvectors:d}=l(f.inverse().dot(u),s,i);return d=_.from(d).transpose(),this.Y=t.dot(d),this.projection}},t.LLE=class extends g{constructor(t,r){return super(t,{neighbors:void 0,d:2,metric:e,seed:1212,eig_args:{}},r),this.parameter("neighbors",Math.min(r.neighbors??Math.max(Math.floor(this._N/10),2),this._N-1)),this._parameters.eig_args.hasOwnProperty("seed")||(this._parameters.eig_args.seed=this._randomizer),this}transform(){const t=this.X,e=this._N,s=this._D,{neighbors:i,d:o,eig_args:a,metric:h}=this._parameters,c=n(t,i,h),u=new _(i,1,1),f=new _(e,e);for(let n=0;nt.entry(e[r].j,s)-t.entry(n,s))),a=o.dot(o.T);if(i>s){const t=r(a.diag)/1e3;for(let e=0;e{u.set_entry(e,t,1)}));const f=new t(_.from(c.map((t=>s.row(t)))),e).transform(),d=s.to2dArray,p=new r(d,h),y=new _(n,n,"I"),g=-1/i;d.forEach(((t,e)=>{for(const{index:r}of p.search(t,i).iterate())e!==r&&y.set_entry(e,r,g)}));const w=y.concat(u,"vertical"),x=new _(n,o,"zeros").concat(f,"vertical");return this._A=w,this._b=x,this._is_initialized=!0,this}transform(){this.check_init();const t=this._A,e=t.T,r=this._b,s=e.dot(t),n=e.dot(r);return this.Y=_.solve_CG(s,n,this._randomizer),this.projection}},t.LTSA=class extends g{constructor(t,r){if(super(t,{neighbors:void 0,d:2,metric:e,seed:1212,eig_args:{}},r),this.parameter("neighbors",Math.min(r.neighbors??Math.max(Math.floor(this._N/10),2),this._N-1)),this._parameters.eig_args.hasOwnProperty("seed")||(this._parameters.eig_args.seed=this._randomizer),this._D<=this.parameter("d"))throw new Error(`Dimensionality of X (D = ${this._D}) must be greater than the required dimensionality of the result (d = ${this.parameter("d")})!`);return this}transform(){const t=this.X,[e,r]=t.shape,{d:s,neighbors:i,metric:o,eig_args:a}=this._parameters,h=n(t,i,o),c=new _(r,r,"center"),u=new _(e,e,0);for(let r=0;rt.j))];let n=_.from(e.map((e=>t.row(e))));n=n.dot(c);const o=n.dot(n.transpose()),{eigenvectors:f}=l(o,s,a),d=_.from(f),p=d.transpose().dot(d).add(1/Math.sqrt(i+1));for(let t=0;tt.reachability_distance),"min");this._update(e,t),this._expand_cluster(t,n[i])}return this}_get_neighbors(t){if("neighbors"in t)return t.neighbors;const e=this._DB,r=this._metric,s=this._epsilon,n=[];for(const i of e)i.index!=t.index&&r(t.element,i.element)t.element==i))<0?(i.reachability_distance=n,e.push(i)):nt.reachability_distance),"min"))}}_expand_cluster(t,e){const r=this._ordered_list;for(;!t.empty;){const s=t.pop().element;s.neighbors=this._get_neighbors(s),s.processed=!0,e.push(s.index),r.push(s),null!=this._core_distance(s)&&(this._update(s,t),this._expand_cluster(t,e))}}get_clusters(){const t=[],e=[],r=this._min_points;for(const s of this._clusters)s.lengthr.random))}else{if(!["PCA","MDS"].includes(s))throw new Error('init_DR needs to be either "random" or a DR method!');this.Y=_.from("PCA"==s?w.transform(this.X,n):A.transform(this.X,n))}return this.distance_matrix="precomputed"==r?_.from(this.X):i(this.X,r),this}transform(t=200){this._is_initialized||this.init();for(let e=0;ethis._randomizer.random)),this}init(){const t=Math.log(this.parameter("perplexity")),e=this._N,r=this._D,{metric:s}=this._parameters,n=this.X;let i;if("precomputed"==s)i=druid.Matrix.from(n);else{i=new _(e,e);for(let t=0;t1e-7&&(c-=e*Math.log(e))}c>t?(s=h,h=n===1/0?2*h:(h+n)/2):(n=h,h=s===-1/0?h/2:(h+s)/2),++_,Math.abs(c-t)<1e-4&&(l=!0),_>=50&&(l=!0)}for(let t=0;tt[2]-e[2]));for(const[t,e,r]of o){const o=n.find(s[t]),a=n.find(s[e]);o!==a&&(i.push([t,e,r]),n.union(o,a))}return i.sort(((t,e)=>t[2]-e[2]))}init(){const{metric:t}=this._parameters;return this.Y=new _(this._N,2,0),this._Emst=this._make_minimum_spanning_tree(t),this._is_initialized=!0,this}__hull_cross([t,e],[r,s],[n,i]){return(r-t)*(i-e)-(s-e)*(n-t)<=0}__hull(t){const e=t.sort((([t,e],[r,s])=>e-s||t-r)),r=e.length;if(r<=2)return e;const s=[];for(let t=0;t=2&&this.__hull_cross(s[s.length-2],s[s.length-1],e[t]);)s.pop();s.push(e[t])}const n=[];for(let t=r-1;t>=0;--t){for(;n.length>=2&&this.__hull_cross(n[n.length-2],n[n.length-1],e[t]);)n.pop();n.push(e[t])}return n.pop(),s.pop(),s.concat(n)}__findAngle([t,r],[s,n]){const i=e([t,r],[s,n]);if(0===i)return{sin:0,cos:1};const o=[(s-t)/i,(n-r)/i],a=o[0];let h=Math.sqrt(1-a*a);return h=o[1]>=0?-h:h,{sin:h,cos:a}}__align_hull(t,r,s){let n,i,o,a=-1;for(let s=0;si)&&(n=i,a=s)}s?(i=t[a],o=t[(a+1)%t.length]):(0==a&&(a=t.length-1),i=t[a],o=t[(a-1)%t.length]);const h={tx:-t[a][0],ty:-t[a][1]};if(t.length>=2){const{sin:t,cos:e}=this.__findAngle(i,o);h.sin=t,h.cos=e}else h.sin=0,h.cos=1;return h}__transform([t,e],{tx:r,ty:s,sin:n,cos:i}){let o=t+r,a=e+s;return[o*i-a*n,o*n+a*i]}__transform_component(t,e,r){const s=t.length;for(let n=0;n(t.i=e,t))));for(const[s,n,i]of t){const t=r.find(e[s]),o=r.find(e[n]);t!==o&&(this.__align_components(t,o,i),r.union(t,o))}return this.projection}*generator(){this._is_initialized||this.init();const t=this._Emst,e=this.Y.to2dArray,r=new p(e.map(((t,e)=>(t.i=e,t))));for(const[s,n,i]of t){const t=r.find(e[s]),o=r.find(e[n]);t!==o&&(this.__align_components(t,o,i),r.union(t,o),yield this.projection)}return this.projection}},t.TriMap=class extends g{constructor(t,r){return super(t,{weight_adj:500,c:5,d:2,metric:e,tol:1e-8,seed:1212},r),this}init(t=null,e=null){const r=this.X,s=r.shape[0],{d:n,metric:i,c:o}=this._parameters;this.n_inliers=2*o,this.n_outliers=1*o,this.n_random=1*o,this.Y=t||new w(r,n).transform(),this.knn=e||new m(r.to2dArray,i);const{triplets:a,weights:h}=this._generate_triplets(this.n_inliers,this.n_outliers,this.n_random);return this.triplets=a,this.weights=h,this.lr=1e3*s/a.shape[0],this.C=1/0,this.vel=new _(s,n,0),this.gain=new _(s,n,1),this}_generate_triplets(t,e,r){const{metric:s,weight_adj:n}=this._parameters,i=this.X,o=i.shape[0],a=this.knn,h=Math.min(t+20,o),l=new _(o,h),c=new _(o,h);for(let t=0;t0!=t.value)).sort(((t,e)=>t.value-e.value)).forEach(((e,r)=>{l.set_entry(t,r,e.element.index),c.set_entry(t,r,e.value)}));const u=new Float64Array(o);for(let t=0;t0){const{random_triplets:t,random_weights:e}=this._sample_random_triplets(i,r,u);d=d.concat(t,"vertical"),y=Float64Array.from([...y,...e])}p=d.shape[0];let g=-1/0;for(let t=0;tMath.exp(-(t.entry(s,n)**2)/e[s]/e[r.entry(s,n)])))}_sample_knn_triplets(t,e,r,s){const n=e.shape[0],i=new _(n*r*s,3);for(let o=0;o-t)));for(let t=0;t({d:t,i:e}))).sort(((t,e)=>t.d-e.d)).map((t=>t.i))}_rejection_sample(t,e,r){const s=this._randomizer,n=o(0,e-1).filter((t=>r.indexOf(t)<0));return s.choice(n,Math.min(t,n.length-2))}_find_weights(t,e,r,s,n){const i=t.shape[0],o=new Float64Array(i);for(let a=0;a=m){u=1,f=1;for(let e=0;ef&&++d,p+=n[e]/(1+f/u);const y=(n[e]/(u+f))**2;for(let t=0;t150?.5:.3,r=this.C,s=this.vel,n=this.Y.add(s.mult(e)),{grad:i,loss:o,n_viol:a}=this._grad(n);return this.C=o,this.Y=this._update_embedding(n,t,i),this.lr*=r>o+this._parameters.tol?1.01:.9,this.Y}_update_embedding(t,e,r){const[s,n]=t.shape,i=e>150?.9:.5,o=this.gain,a=this.vel,h=this.lr;for(let e=0;ethis._N)throw new Error(`Parameter n_neighbors (=${this.parameter("n_neighbors")}) needs to be smaller than dataset size (N=${this._N})!`);if(this.parameter("local_connectivity")>this.parameter("n_neighbors"))throw new Error(`Parameter local_connectivity (=${this.parameter("local_connectivity")}) needs to be smaller than parameter n_neighbors (=${this.parameter("n_neighbors")})`);this._iter=0;const s=this._randomizer;return this.Y=new _(this._N,this.parameter("d"),(()=>s.random)),this}_find_ab_params(t,e){const s=o(0,3*t,300),n=o(0,3*t,300);for(let r=0,i=s.length;r{const e=o(1,300).map(((e,r)=>{return n[r]-(i=s[r],o=t[0],a=t[1],1/(1+o*Math.pow(i,2*a)));var i,o,a}));return Math.sqrt(r(e.map((t=>t*t))))}),[1,1])}_compute_membership_strengths(t,e,r){for(let s=0,n=t.length;s0?Math.exp(-i/e[s]):1}return t}_smooth_knn_dist(t,e){const r=1e-5,s=.001,{local_connectivity:n,metric:i}=this._parameters,o=Math.log2(e),a=[],h=[],l=this.X,_=l.shape[0],c=[];if("precomputed"===i)for(let r=0;r<_;++r)c.push(t.search(r,e).reverse());else for(const r of l)c.push(t.search(r,e).raw_data().reverse());for(let t=0;t<_;++t){let i=0,l=1/0,_=1;const u=c[t],f=u.filter((t=>t.value>0)),d=f.length;if(d>=n){const e=Math.floor(n),s=n-e;e>0?(a.push(f[e-1]),s>r&&(a[t].value+=s*(f[e].value-f[e-1]))):a[t].value=s*f[0].value}else d>0&&(a[t]=f[d-1].value);for(let s=0;s<64;++s){let s=0;for(let r=0;r0?Math.exp(-e/_):1}if(Math.abs(s-o)o?[l,_]=[_,(i+l)/2]:[i,_]=l===1/0?[_,2*_]:[_,(i+l)/2]}h[t]=_;const p=u.reduce(((t,e)=>t+e.value),0)/u.length;if(a[t]>0)h[t]t+e.reduce(((t,e)=>t+e.value),0)/e.length));h[t]>s*e&&(h[t]=s*e)}}return{distances:c,sigmas:h,rhos:a}}_fuzzy_simplicial_set(t,e){const r=t.shape[0],{metric:s,_set_op_mix_ratio:n}=this._parameters,i="precomputed"===s?new y(t,"precomputed"):new m(t.to2dArray,s);let{distances:o,sigmas:a,rhos:h}=this._smooth_knn_dist(i,e);o=this._compute_membership_strengths(o,a,h);const l=new _(r,r,"zeros");for(let t=0;tt*(e/s)));for(let e=0;e0&&(r[e]=Math.round(t/n[e]));return r}_tocoo(t){const e=[],r=[],s=[],[n,i]=t.shape;for(let o=0;ot*n)),this._epoch_of_next_sample=this._epochs_per_sample.slice(),this._epoch_of_next_negative_sample=this._epochs_per_negative_sample.slice(),this}graph(){return this.check_init(),{cols:this._head,rows:this._tail,weights:this._weights}}transform(t=350){this.parameter("_n_epochs")!=t&&(this.parameter("_n_epochs",t),this.init()),this.check_init();for(let e=0;e4?4:t<-4?-4:t}_optimize_layout(t,e,r,n){const i=this._randomizer,{_repulsion_strength:o,d:a}=this._parameters,{_alpha:h,_a:l,_b:_,_epochs_per_sample:c,_epochs_per_negative_sample:u,_epoch_of_next_negative_sample:f,_epoch_of_next_sample:d,_clip:p}=this,m=n.length;for(let y=0,g=c.length;y0&&(M=-2*l*_*Math.pow(b,_-1)/(l*Math.pow(b,_)+1));for(let r=0;r0)f=2*o*_/((.01+u)*(l*Math.pow(u,_)+1));else if(g===r)continue;for(let s=0;st/s))},t.powell=x,t.qr=h,t.qr_householder=function(t){const[e,r]=t.shape,s=new _(e,e,"I"),n=t.clone();for(let t=0;t2) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n return Math.sqrt(euclidean_squared(a, b));\n}\n","/**\n * Numerical stable summation with the Neumair summation algorithm.\n * @memberof module:numerical\n * @alias neumair_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm#Further_enhancements}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n\n for (let i = 0; i < n; ++i) {\n let summand = summands[i];\n let t = sum + summand;\n if (Math.abs(sum) >= Math.abs(summand)) {\n compensation += sum - t + summand;\n } else {\n compensation += summand - t + sum;\n }\n sum = t;\n }\n return sum + compensation;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n/**\n * Computes the squared euclidean distance (l22) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean_squared\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the squared euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let s = new Array(n);\n for (let i = 0; i < n; ++i) {\n let x = a[i];\n let y = b[i];\n s[i] = (x - y) * (x - y);\n }\n return neumair_sum(s);\n}\n","import { distance_matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Computes the k-nearest neighbors of each row of {@link A}.\n * @memberof module:matrix\n * @alias k_nearest_neigbhors\n * @param {Matrix} A - Either the data matrix, or a distance matrix.\n * @param {Number} k - The number of neighbors to compute.\n * @param {Function|\"precomputed\"} [metric=euclidean]\n * @returns {Array} -\n */\nexport default function (A, k, metric = euclidean) {\n const rows = A.shape[0];\n let D = metric == \"precomputed\" ? A : distance_matrix(A, metric);\n let nN = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n nN[row] = Array.from(D.row(row))\n .map((distance, col) => {\n return {\n i: row,\n j: col,\n distance: distance,\n };\n })\n .sort((a, b) => a.distance - b.distance)\n .slice(1, k + 1);\n }\n return nN;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"./index.js\";\n\n/**\n * Computes the distance matrix of datamatrix {@link A}.\n * @memberof module:matrix\n * @alias distance_matrix\n * @param {Matrix} A - Matrix.\n * @param {Function} [metric=euclidean] - The diistance metric.\n * @returns {Matrix} D - The distance matrix of {@link A}.\n */\nexport default function (A, metric = euclidean) {\n let n = A.shape[0];\n const D = new Matrix(n, n);\n for (let i = 0; i < n; ++i) {\n const A_i = A.row(i);\n for (let j = i + 1; j < n; ++j) {\n const dist = metric(A_i, A.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n }\n }\n return D;\n}\n","/**\n * Creates an Array containing {@link number} numbers from {@link start} to {@link end}.\n * If {@link number} = null.\n * @memberof module:matrix\n * @alias linspace\n * @param {Number} start - Start value.\n * @param {Number} end - End value.\n * @param {Number} [number = null] - Number of number between {@link start} and {@link end}.\n * @returns {Array} - An array with {@link number} entries, beginning at {@link start} ending at {@link end}.\n */\nexport default function (start, end, number = null) {\n if (!number) {\n number = Math.max(Math.round(end - start) + 1, 1);\n }\n if (number < 2) {\n return number === 1 ? [start] : [];\n }\n let result = new Array(number);\n number -= 1;\n for (let i = number; i >= 0; --i) {\n result[i] = (i * end + (number - i) * start) / number;\n }\n return result;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n//import { neumair_sum } from \"../numerical/index\";\n\n/**\n * Computes the norm of a vector, by computing its distance to **0**.\n * @memberof module:matrix\n * @alias norm\n * @param {Matrix|Array|Float64Array} v - Vector. \n * @param {Function} [metric = euclidean] - Which metric should be used to compute the norm.\n * @returns {Number} - The norm of {@link v}.\n */\nexport default function (v, metric = euclidean) {\n let vector = null;\n if (v instanceof Matrix) {\n let [rows, cols] = v.shape;\n if (rows === 1) vector = v.row(0);\n else if (cols === 1) vector = v.col(0);\n else throw new Error(\"Matrix must be 1d!\");\n } else {\n vector = v;\n }\n const n = vector.length;\n const zeros = Float64Array.from({ length: n }, () => 0);\n return metric(vector, zeros);\n}\n","import { Matrix, norm } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} using Gram-Schmidt process.\n * @memberof module:linear_algebra\n * @alias qr\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_the_Gram%E2%80%93Schmidt_process}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, cols, \"identity\");\n const R = new Matrix(cols, cols, 0);\n\n for (let j = 0; j < cols; ++j) {\n let v = A.col(j);\n for (let i = 0; i < j; ++i) {\n const q = Q.col(i);\n const q_dot_v = neumair_sum(q.map((q_, k) => q_ * v[k]));\n R.set_entry(i, j, q_dot_v);\n v = v.map((v_, k) => v_ - q_dot_v * q[k]);\n }\n const v_norm = norm(v, euclidean);\n for (let k = 0; k < rows; ++k) {\n Q.set_entry(k, j, v[k] / v_norm);\n }\n R.set_entry(j, j, v_norm);\n }\n return { R, Q };\n}\n","import { qr as qr_gramschmidt } from \"./index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { euclidean_squared } from \"../metrics/index.js\";\n\n/**\n * Computes the {@link k} biggest Eigenvectors and Eigenvalues from Matrix {@link A} with the QR-Algorithm.\n * @memberof module:linear_algebra\n * @alias simultaneous_poweriteration\n * @param {Matrix} A - The Matrix\n * @param {Number} k - The number of eigenvectors and eigenvalues to compute.\n * @param {Object} parameters - Object containing parameterization of the simultanious poweriteration method.\n * @param {Number} [parameters.max_iterations=100] - The number of maxiumum iterations the algorithm should run.\n * @param {Number|Randomizer} [parameters.seed=1212] - The seed value or a randomizer used in the algorithm.\n * @param {Function} [parameters.qr=qr_gramschmidt] - The QR technique to use.\n * @param {Number} [parameters.tol=1e-8] - Allowed error for stopping criteria\n * @returns {{eigenvalues: Array, eigenvectors: Array}} - The {@link k} biggest eigenvectors and eigenvalues of Matrix {@link A}.\n */\nexport default function (A, k = 2, {seed = 1212, max_iterations = 100, qr = qr_gramschmidt, tol = 1e-8} = {}) {\n const randomizer = seed instanceof Randomizer ? seed : new Randomizer(seed);\n if (!(A instanceof Matrix)) A = Matrix.from(A);\n const n = A.shape[0];\n let { Q, R } = qr(new Matrix(n, k, () => (randomizer.random - .5) * 2));\n while (max_iterations--) {\n const oldQ = Q.clone();\n const Z = A.dot(Q);\n const QR = qr(Z);\n Q = QR.Q;\n R = QR.R;\n const error = euclidean_squared(Q.values, oldQ.values);\n if (error < tol) {\n break;\n }\n }\n\n const eigenvalues = R.diag;\n const eigenvectors = Q.transpose().to2dArray;\n return { eigenvalues, eigenvectors };\n}\n","import { neumair_sum } from \"../numerical/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n/**\n * @class\n * @alias Matrix\n * @requires module:numerical/neumair_sum\n */\nexport class Matrix {\n /**\n * creates a new Matrix. Entries are stored in a Float64Array.\n * @constructor\n * @memberof module:matrix\n * @alias Matrix\n * @param {number} rows - The amount of rows of the matrix.\n * @param {number} cols - The amount of columns of the matrix.\n * @param {(function|string|number)} value=0 - Can be a function with row and col as parameters, a number, or \"zeros\", \"identity\" or \"I\", or \"center\".\n * - **function**: for each entry the function gets called with the parameters for the actual row and column.\n * - **string**: allowed are\n * - \"zero\", creates a zero matrix.\n * - \"identity\" or \"I\", creates an identity matrix.\n * - \"center\", creates an center matrix.\n * - **number**: create a matrix filled with the given value.\n * @example\n *\n * let A = new Matrix(10, 10, () => Math.random()); //creates a 10 times 10 random matrix.\n * let B = new Matrix(3, 3, \"I\"); // creates a 3 times 3 identity matrix.\n * @returns {Matrix} returns a {@link rows} times {@link cols} Matrix filled with {@link value}.\n */\n constructor(rows = null, cols = null, value = null) {\n this._rows = rows;\n this._cols = cols;\n this._data = null;\n if (rows && cols) {\n if (!value) {\n this._data = new Float64Array(rows * cols);\n return this;\n }\n if (typeof value === \"function\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n if (typeof value === \"string\") {\n if (value === \"zeros\") {\n return new Matrix(rows, cols, 0);\n }\n if (value === \"identity\" || value === \"I\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n this._data[row * cols + row] = 1;\n }\n return this;\n }\n if (value === \"center\" && rows == cols) {\n this._data = new Float64Array(rows * cols);\n value = (i, j) => (i === j ? 1 : 0) - 1 / rows;\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n }\n if (typeof value === \"number\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value;\n }\n }\n return this;\n }\n }\n return this;\n }\n\n /**\n * Creates a Matrix out of {@link A}.\n * @param {(Matrix|Array|Float64Array|number)} A - The matrix, array, or number, which should converted to a Matrix.\n * @param {\"row\"|\"col\"|\"diag\"} [type = \"row\"] - If {@link A} is a Array or Float64Array, then type defines if it is a row- or a column vector.\n * @returns {Matrix}\n *\n * @example\n * let A = Matrix.from([[1, 0], [0, 1]]); //creates a two by two identity matrix.\n * let S = Matrix.from([1, 2, 3], \"diag\"); // creates a 3 by 3 matrix with 1, 2, 3 on its diagonal. [[1, 0, 0], [0, 2, 0], [0, 0, 3]]\n */\n static from(A, type = \"row\") {\n if (A instanceof Matrix) {\n return A.clone();\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let m = A.length;\n if (m === 0) throw new Error(\"Array is empty\");\n // 1d\n if (!Array.isArray(A[0]) && !(A[0] instanceof Float64Array)) {\n if (type === \"row\") {\n return new Matrix(1, m, (_, j) => A[j]);\n } else if (type === \"col\") {\n return new Matrix(m, 1, (i) => A[i]);\n } else if (type === \"diag\") {\n return new Matrix(m, m, (i, j) => (i == j ? A[i] : 0));\n } else {\n throw new Error(\"1d array has NaN entries\");\n }\n // 2d\n } else if (Array.isArray(A[0]) || A[0] instanceof Float64Array) {\n let n = A[0].length;\n for (let row = 0; row < m; ++row) {\n if (A[row].length !== n) {\n throw new Error(\"various array lengths\");\n }\n }\n return new Matrix(m, n, (i, j) => A[i][j]);\n }\n } else if (typeof A === \"number\") {\n return new Matrix(1, 1, A);\n } else {\n throw new Error(\"error\");\n }\n }\n\n /**\n * Returns the {@link row}th row from the Matrix.\n * @param {Number} row\n * @returns {Float64Array}\n */\n row(row) {\n const data = this.values;\n const cols = this._cols;\n return data.subarray(row * cols, (row + 1) * cols);\n }\n\n /**\n * Returns an generator yielding each row of the Matrix.\n * @yields {Float64Array}\n */\n *iterate_rows() {\n const cols = this._cols;\n const rows = this._rows;\n const data = this.values;\n for (let row = 0; row < rows; ++row) {\n yield data.subarray(row * cols, (row + 1) * cols);\n }\n }\n\n /**\n * Makes a {@link Matrix} object an iterable object.\n * @yields {Float64Array}\n */\n *[Symbol.iterator]() {\n for (const row of this.iterate_rows()) {\n yield row;\n }\n }\n\n /**\n * Sets the entries of {@link row}th row from the Matrix to the entries from {@link values}.\n * @param {int} row\n * @param {Array} values\n * @returns {Matrix}\n */\n set_row(row, values) {\n let cols = this._cols;\n if (Array.isArray(values) && values.length === cols) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values[col];\n }\n } else if (values instanceof Matrix && values.shape[1] === cols && values.shape[0] === 1) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values._data[col];\n }\n }\n return this;\n }\n\n /**\n * Returns the {@link col}th column from the Matrix.\n * @param {int} col\n * @returns {Array}\n */\n col(col) {\n let result_col = new Float64Array(this._rows);\n for (let row = 0; row < this._rows; ++row) {\n result_col[row] = this.values[row * this._cols + col];\n }\n return result_col;\n }\n\n /**\n * Returns the {@link col}th entry from the {@link row}th row of the Matrix.\n * @param {int} row\n * @param {int} col\n * @returns {float64}\n */\n entry(row, col) {\n return this.values[row * this._cols + col];\n }\n\n /**\n * Sets the {@link col}th entry from the {@link row}th row of the Matrix to the given {@link value}.\n * @param {int} row\n * @param {int} col\n * @param {float64} value\n * @returns {Matrix}\n */\n set_entry(row, col, value) {\n this.values[row * this._cols + col] = value;\n return this;\n }\n\n /**\n * Returns a new transposed Matrix.\n * @returns {Matrix}\n */\n transpose() {\n let B = new Matrix(this._cols, this._rows, (row, col) => this.entry(col, row));\n return B;\n }\n\n /**\n * Returns a new transposed Matrix. Short-form of {@function transpose}.\n * @returns {Matrix}\n */\n get T() {\n return this.transpose();\n }\n\n /**\n * Returns the inverse of the Matrix.\n * @returns {Matrix}\n */\n inverse() {\n const rows = this._rows;\n const cols = this._cols;\n let B = new Matrix(rows, 2 * cols, (i, j) => {\n if (j >= cols) {\n return i === j - cols ? 1 : 0;\n } else {\n return this.entry(i, j);\n }\n });\n let h = 0;\n let k = 0;\n while (h < rows && k < cols) {\n var i_max = 0;\n let max_val = -Infinity;\n for (let i = h; i < rows; ++i) {\n let val = Math.abs(B.entry(i, k));\n if (max_val < val) {\n i_max = i;\n max_val = val;\n }\n }\n if (B.entry(i_max, k) == 0) {\n k++;\n } else {\n // swap rows\n for (let j = 0; j < 2 * cols; ++j) {\n let h_val = B.entry(h, j);\n let i_val = B.entry(i_max, j);\n B.set_entry(h, j, h_val);\n B.set_entry(i_max, j, i_val);\n }\n for (let i = h + 1; i < rows; ++i) {\n let f = B.entry(i, k) / B.entry(h, k);\n B.set_entry(i, k, 0);\n for (let j = k + 1; j < 2 * cols; ++j) {\n B.set_entry(i, j, B.entry(i, j) - B.entry(h, j) * f);\n }\n }\n h++;\n k++;\n }\n }\n\n for (let row = 0; row < rows; ++row) {\n let f = B.entry(row, row);\n for (let col = row; col < 2 * cols; ++col) {\n B.set_entry(row, col, B.entry(row, col) / f);\n }\n }\n\n for (let row = rows - 1; row >= 0; --row) {\n let B_row_row = B.entry(row, row);\n for (let i = 0; i < row; i++) {\n let B_i_row = B.entry(i, row);\n let f = B_i_row / B_row_row;\n for (let j = i; j < 2 * cols; ++j) {\n let B_i_j = B.entry(i, j);\n let B_row_j = B.entry(row, j);\n B_i_j = B_i_j - B_row_j * f;\n B.set_entry(i, j, B_i_j);\n }\n }\n }\n\n return new Matrix(rows, cols, (i, j) => B.entry(i, j + cols));\n }\n\n /**\n * Returns the dot product. If {@link B} is an Array or Float64Array then an Array gets returned. If {@link B} is a Matrix then a Matrix gets returned.\n * @param {(Matrix|Array|Float64Array)} B the right side\n * @returns {(Matrix|Array)}\n */\n dot(B) {\n if (B instanceof Matrix) {\n let A = this;\n if (A.shape[1] !== B.shape[0]) {\n throw new Error(`A.dot(B): A is a ${A.shape.join(\" ⨯ \")}-Matrix, B is a ${B.shape.join(\" ⨯ \")}-Matrix: \n A has ${A.shape[1]} cols and B ${B.shape[0]} rows. \n Must be equal!`);\n }\n let I = A.shape[1];\n let C = new Matrix(A.shape[0], B.shape[1], (row, col) => {\n const A_i = A.row(row);\n const B_i = B.col(col);\n let sum = 0;\n for (let i = 0; i < I; ++i) {\n sum += A_i[i] * B_i[i];\n }\n return sum;\n });\n return C;\n } else if (Array.isArray(B) || B instanceof Float64Array) {\n let rows = this._rows;\n if (B.length !== rows) {\n throw new Error(`A.dot(B): A has ${rows} cols and B has ${B.length} rows. Must be equal!`);\n }\n let C = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n C[row] = neumair_sum(this.row(row).map((e) => e * B[row]));\n }\n return C;\n } else {\n throw new Error(`B must be Matrix or Array`);\n }\n }\n\n /**\n * Computes the outer product from {@link this} and {@link B}.\n * @param {Matrix} B\n * @returns {Matrix}\n */\n outer(B) {\n let A = this;\n let l = A._data.length;\n let r = B._data.length;\n if (l != r) return undefined;\n let C = new Matrix();\n C.shape = [\n l,\n l,\n (i, j) => {\n if (i <= j) {\n return A._data[i] * B._data[j];\n } else {\n return C.entry(j, i);\n }\n },\n ];\n return C;\n }\n\n /**\n * Appends matrix {@link B} to the matrix.\n * @param {Matrix} B - matrix to append.\n * @param {\"horizontal\"|\"vertical\"|\"diag\"} [type = \"horizontal\"] - type of concatenation.\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 1], [1, 1]]); // 2 by 2 matrix filled with ones.\n * let B = Matrix.from([[2, 2], [2, 2]]); // 2 by 2 matrix filled with twos.\n *\n * A.concat(B, \"horizontal\"); // 2 by 4 matrix. [[1, 1, 2, 2], [1, 1, 2, 2]]\n * A.concat(B, \"vertical\"); // 4 by 2 matrix. [[1, 1], [1, 1], [2, 2], [2, 2]]\n * A.concat(B, \"diag\"); // 4 by 4 matrix. [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 2, 2], [0, 0, 2, 2]]\n */\n concat(B, type = \"horizontal\") {\n const A = this;\n const [rows_A, cols_A] = A.shape;\n const [rows_B, cols_B] = B.shape;\n if (type == \"horizontal\") {\n if (rows_A != rows_B) {\n throw new Error(`A.concat(B, \"horizontal\"): A and B need same number of rows, A has ${rows_A} rows, B has ${rows_B} rows.`);\n }\n const X = new Matrix(rows_A, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(0, cols_A, B);\n return X;\n } else if (type == \"vertical\") {\n if (cols_A != cols_B) {\n throw new Error(`A.concat(B, \"vertical\"): A and B need same number of columns, A has ${cols_A} columns, B has ${cols_B} columns.`);\n }\n const X = new Matrix(rows_A + rows_B, cols_A, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, 0, B);\n return X;\n } else if (type == \"diag\") {\n const X = new Matrix(rows_A + rows_B, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, cols_A, B);\n return X;\n } else {\n throw new Error(`type must be \"horizontal\" or \"vertical\", but type is ${type}!`);\n }\n }\n\n /**\n * Writes the entries of B in A at an offset position given by {@link offset_row} and {@link offset_col}.\n * @param {int} offset_row\n * @param {int} offset_col\n * @param {Matrix} B\n * @returns {Matrix}\n */\n set_block(offset_row, offset_col, B) {\n let [rows, cols] = B.shape;\n for (let row = 0; row < rows; ++row) {\n if (row > this._rows) {\n continue;\n }\n for (let col = 0; col < cols; ++col) {\n if (col > this._cols) {\n continue;\n }\n this.set_entry(row + offset_row, col + offset_col, B.entry(row, col));\n }\n }\n return this;\n }\n\n /**\n * Extracts the entries from the {@link start_row}th row to the {@link end_row}th row, the {@link start_col}th column to the {@link end_col}th column of the matrix.\n * If {@link end_row} or {@link end_col} is empty, the respective value is set to {@link this.rows} or {@link this.cols}.\n * @param {Number} start_row\n * @param {Number} start_col\n * @param {Number} [end_row = null]\n * @param {Number} [end_col = null]\n * @returns {Matrix} Returns a end_row - start_row times end_col - start_col matrix, with respective entries from the matrix.\n * @example\n *\n * let A = Matrix.from([[1, 2, 3], [4, 5, 6], [7, 8, 9]]); // a 3 by 3 matrix.\n *\n * A.get_block(1, 1); // [[5, 6], [8, 9]]\n * A.get_block(0, 0, 1, 1); // [[1]]\n * A.get_block(1, 1, 2, 2); // [[5]]\n * A.get_block(0, 0, 2, 2); // [[1, 2], [4, 5]]\n */\n get_block(start_row, start_col, end_row = null, end_col = null) {\n const [rows, cols] = this.shape;\n end_row = end_row ?? rows;\n end_col = end_col ?? cols;\n if (end_row <= start_row || end_col <= start_col) {\n throw new Error(`\n end_row must be greater than start_row, and \n end_col must be greater than start_col, but\n end_row = ${end_row}, start_row = ${start_row}, end_col = ${end_col}, and start_col = ${start_col}!`);\n }\n const X = new Matrix(end_row - start_row, end_col - start_col, \"zeros\");\n for (let row = start_row, new_row = 0; row < end_row; ++row, ++new_row) {\n for (let col = start_col, new_col = 0; col < end_col; ++col, ++new_col) {\n X.set_entry(new_row, new_col, this.entry(row, col));\n }\n }\n return X;\n //return new Matrix(end_row - start_row, end_col - start_col, (i, j) => this.entry(i + start_row, j + start_col));\n }\n\n /**\n * Returns a new array gathering entries defined by the indices given by argument.\n * @param {Array} row_indices - Array consists of indices of rows for gathering entries of this matrix\n * @param {Array} col_indices - Array consists of indices of cols for gathering entries of this matrix\n * @returns {Matrix}\n */\n gather(row_indices, col_indices) {\n const N = row_indices.length;\n const D = col_indices.length;\n\n const R = new Matrix(N, D);\n for (let i = 0; i < N; ++i) {\n const row_index = row_indices[i];\n for (let j = 0; j < N; ++j) {\n const col_index = col_indices[j];\n R.set_entry(i, j, this.entry(row_index, col_index));\n }\n }\n\n return R;\n }\n\n /**\n * Applies a function to each entry of the matrix.\n * @private\n * @param {function} f function takes 2 parameters, the value of the actual entry and a value given by the function {@link v}. The result of {@link f} gets writen to the Matrix.\n * @param {function} v function takes 2 parameters for row and col, and returns a value witch should be applied to the colth entry of the rowth row of the matrix.\n */\n _apply_array(f, v) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], v(row, col));\n }\n }\n return this;\n }\n\n _apply_rowwise_array(values, f) {\n return this._apply_array(f, (_, j) => values[j]);\n }\n\n _apply_colwise_array(values, f) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], values[row]);\n }\n }\n return this;\n }\n\n _apply(value, f) {\n let data = this.values;\n if (value instanceof Matrix) {\n let [value_rows, value_cols] = value.shape;\n let [rows, cols] = this.shape;\n if (value_rows === 1) {\n if (cols !== value_cols) {\n throw new Error(`cols !== value_cols`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(0, col));\n }\n }\n } else if (value_cols === 1) {\n if (rows !== value_rows) {\n throw new Error(`rows !== value_rows`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, 0));\n }\n }\n } else if (rows == value_rows && cols == value_cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, col));\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else if (Array.isArray(value)) {\n let rows = this._rows;\n let cols = this._cols;\n if (value.length === rows) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[row]);\n }\n }\n } else if (value.length === cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[col]);\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else {\n for (let i = 0, n = this._rows * this._cols; i < n; ++i) {\n data[i] = f(data[i], value);\n }\n }\n return this;\n }\n\n /**\n * Clones the Matrix.\n * @returns {Matrix}\n */\n clone() {\n let B = new Matrix();\n B._rows = this._rows;\n B._cols = this._cols;\n B._data = this.values.slice(0);\n return B;\n }\n\n /**\n * Entrywise multiplication with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.mult(2); // [[2, 4], [6, 8]];\n * A.mult(B); // [[1, 4], [9, 16]];\n */\n mult(value) {\n return this.clone()._apply(value, (a, b) => a * b);\n }\n\n /**\n * Entrywise division with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.divide(2); // [[0.5, 1], [1.5, 2]];\n * A.divide(B); // [[1, 1], [1, 1]];\n */\n divide(value) {\n return this.clone()._apply(value, (a, b) => a / b);\n }\n\n /**\n * Entrywise addition with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.add(2); // [[3, 4], [5, 6]];\n * A.add(B); // [[2, 4], [6, 8]];\n */\n add(value) {\n return this.clone()._apply(value, (a, b) => a + b);\n }\n\n /**\n * Entrywise subtraction with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.sub(2); // [[-1, 0], [1, 2]];\n * A.sub(B); // [[0, 0], [0, 0]];\n */\n sub(value) {\n return this.clone()._apply(value, (a, b) => a - b);\n }\n\n /**\n * Returns the number of rows and columns of the Matrix.\n * @returns {Array} An Array in the form [rows, columns].\n */\n get shape() {\n return [this._rows, this._cols];\n }\n\n /**\n * Returns the matrix in the given shape with the given function which returns values for the entries of the matrix.\n * @param {Array} parameter - takes an Array in the form [rows, cols, value], where rows and cols are the number of rows and columns of the matrix, and value is a function which takes two parameters (row and col) which has to return a value for the colth entry of the rowth row.\n * @returns {Matrix}\n */\n set shape([rows, cols, value = () => 0]) {\n this._rows = rows;\n this._cols = cols;\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n\n /**\n * Returns the Matrix as a Array of Float64Arrays.\n * @returns {Array}\n */\n get to2dArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(row);\n }\n return result;\n }\n\n /**\n * Returns the Matrix as a Array of Arrays.\n * @returns {Array}\n */\n get asArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(Array.from(row));\n }\n return result;\n }\n\n /**\n * Returns the diagonal of the Matrix.\n * @returns {Float64Array}\n */\n get diag() {\n const rows = this._rows;\n const cols = this._cols;\n const min_row_col = Math.min(rows, cols);\n let result = new Float64Array(min_row_col);\n for (let i = 0; i < min_row_col; ++i) {\n result[i] = this.entry(i, i);\n }\n return result;\n }\n\n /**\n * Returns the mean of all entries of the Matrix.\n * @returns {Number}\n */\n get mean() {\n const sum = this.sum;\n const n = this._rows * this._cols;\n return sum / n;\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Number}\n */\n get sum() {\n const data = this.values;\n return neumair_sum(data);\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Float64Array}\n */\n get values() {\n const data = this._data;\n return data;\n }\n\n /**\n * Returns the mean of each row of the matrix.\n * @returns {Float64Array}\n */\n get meanRows() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: rows });\n for (let row = 0; row < rows; ++row) {\n result[row] = 0;\n for (let col = 0; col < cols; ++col) {\n result[row] += data[row * cols + col];\n }\n result[row] /= cols;\n }\n return result;\n }\n\n /** Returns the mean of each column of the matrix.\n * @returns {Float64Array}\n */\n get meanCols() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: cols });\n for (let col = 0; col < cols; ++col) {\n result[col] = 0;\n for (let row = 0; row < rows; ++row) {\n result[col] += data[row * cols + col];\n }\n result[col] /= rows;\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b} using the conjugate gradient method. Returns the result x.\n * @param {Matrix} A - Matrix\n * @param {Matrix} b - Matrix\n * @param {Randomizer} [randomizer=null]\n * @param {Number} [tol=1e-3]\n * @returns {Matrix}\n */\n static solve_CG(A, b, randomizer, tol = 1e-3) {\n if (randomizer === null) {\n randomizer = new Randomizer();\n }\n const rows = A.shape[0];\n const cols = b.shape[1];\n let result = new Matrix(rows, 0);\n for (let i = 0; i < cols; ++i) {\n const b_i = Matrix.from(b.col(i)).T;\n let x = new Matrix(rows, 1, () => randomizer.random);\n let r = b_i.sub(A.dot(x));\n let d = r.clone();\n do {\n const z = A.dot(d);\n const alpha = r.T.dot(r).entry(0, 0) / d.T.dot(z).entry(0, 0);\n x = x.add(d.mult(alpha));\n const r_next = r.sub(z.mult(alpha));\n const beta = r_next.T.dot(r_next).entry(0, 0) / r.T.dot(r).entry(0, 0);\n d = r_next.add(d.mult(beta));\n r = r_next;\n } while (Math.abs(r.mean) > tol);\n result = result.concat(x, \"horizontal\");\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b}. Returns the result x.\n * @param {Matrix} A - Matrix or LU Decomposition\n * @param {Matrix} b - Matrix\n * @returns {Matrix}\n */\n static solve(A, b) {\n let { L: L, U: U } = \"L\" in A && \"U\" in A ? A : Matrix.LU(A);\n let rows = L.shape[0];\n let x = b.clone();\n\n // forward\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < row - 1; ++col) {\n x.set_entry(0, row, x.entry(0, row) - L.entry(row, col) * x.entry(1, col));\n }\n x.set_entry(0, row, x.entry(0, row) / L.entry(row, row));\n }\n\n // backward\n for (let row = rows - 1; row >= 0; --row) {\n for (let col = rows - 1; col > row; --col) {\n x.set_entry(0, row, x.entry(0, row) - U.entry(row, col) * x.entry(0, col));\n }\n x.set_entry(0, row, x.entry(0, row) / U.entry(row, row));\n }\n\n return x;\n }\n\n /**\n * {@link L}{@link U} decomposition of the Matrix {@link A}. Creates two matrices, so that the dot product LU equals A.\n * @param {Matrix} A\n * @returns {{L: Matrix, U: Matrix}} result - Returns the left triangle matrix {@link L} and the upper triangle matrix {@link U}.\n */\n static LU(A) {\n const rows = A.shape[0];\n const L = new Matrix(rows, rows, \"zeros\");\n const U = new Matrix(rows, rows, \"identity\");\n\n for (let j = 0; j < rows; ++j) {\n for (let i = j; i < rows; ++i) {\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(i, k) * U.entry(k, j);\n }\n L.set_entry(i, j, A.entry(i, j) - sum);\n }\n for (let i = j; i < rows; ++i) {\n if (L.entry(j, j) === 0) {\n return undefined;\n }\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(j, k) * U.entry(k, i);\n }\n U.set_entry(j, i, (A.entry(j, i) - sum) / L.entry(j, j));\n }\n }\n\n return { L: L, U: U };\n }\n\n /**\n * Computes the determinante of {@link A}, by using the LU decomposition of {@link A}.\n * @param {Matrix} A\n * @returns {Number} det - Returns the determinate of the Matrix {@link A}.\n */\n static det(A) {\n const rows = A.shape[0];\n const { L, U } = Matrix.LU(A);\n const L_diag = L.diag;\n const U_diag = U.diag;\n let det = L_diag[0] * U_diag[0];\n for (let row = 1; row < rows; ++row) {\n det *= L_diag[row] * U_diag[row];\n }\n return det;\n }\n\n /**\n * Computes the {@link k} components of the SVD decomposition of the matrix {@link M}\n * @param {Matrix} M\n * @param {int} [k=2]\n * @returns {{U: Matrix, Sigma: Matrix, V: Matrix}}\n */\n static SVD(M, k = 2) {\n const MT = M.T;\n let MtM = MT.dot(M);\n let MMt = M.dot(MT);\n let { eigenvectors: V, eigenvalues: Sigma } = simultaneous_poweriteration(MtM, k);\n let { eigenvectors: U } = simultaneous_poweriteration(MMt, k);\n return { U: U, Sigma: Sigma.map((sigma) => Math.sqrt(sigma)), V: V };\n\n //Algorithm 1a: Householder reduction to bidiagonal form:\n /* const [m, n] = A.shape;\n let U = new Matrix(m, n, (i, j) => i == j ? 1 : 0);\n console.log(U.to2dArray)\n let V = new Matrix(n, m, (i, j) => i == j ? 1 : 0);\n console.log(V.to2dArray)\n let B = Matrix.bidiagonal(A.clone(), U, V);\n console.log(U,V,B)\n return { U: U, \"Sigma\": B, V: V }; */\n }\n}\n","import { linspace, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @memberof module:utils\n * @alias Randomizer\n */\nexport class Randomizer {\n /**\n * Mersenne Twister random number generator.\n * @constructor\n * @param {Number} [_seed=new Date().getTime()] - The seed for the random number generator. If _seed == null then the actual time gets used as seed.\n * @see https://github.com/bmurray7/mersenne-twister-examples/blob/master/javascript-mersenne-twister.js\n */\n constructor(_seed) {\n this._N = 624;\n this._M = 397;\n this._MATRIX_A = 0x9908b0df;\n this._UPPER_MASK = 0x80000000;\n this._LOWER_MASK = 0x7fffffff;\n this._mt = new Array(this._N);\n this._mti = this.N + 1;\n\n this.seed = _seed || new Date().getTime();\n return this;\n }\n\n set seed(_seed) {\n this._seed = _seed;\n let mt = this._mt;\n\n mt[0] = _seed >>> 0;\n for (this._mti = 1; this._mti < this._N; this._mti += 1) {\n let mti = this._mti;\n let s = mt[mti - 1] ^ (mt[mti - 1] >>> 30);\n mt[mti] = ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253 + mti;\n mt[mti] >>>= 0;\n }\n }\n\n /**\n * Returns the seed of the random number generator.\n * @returns {Number} - The seed.\n */\n get seed() {\n return this._seed;\n }\n\n /**\n * Returns a float between 0 and 1.\n * @returns {Number} - A random number between [0, 1]\n */\n get random() {\n return this.random_int * (1.0 / 4294967296.0);\n }\n\n /**\n * Returns an integer between 0 and MAX_INTEGER.\n * @returns {Integer} - A random integer.\n */\n get random_int() {\n let y,\n mag01 = new Array(0x0, this._MATRIX_A);\n if (this._mti >= this._N) {\n let kk;\n\n /* if (this._mti == this._N + 1) {\n this.seed = 5489;\n } */\n\n let N_M = this._N - this._M;\n let M_N = this._M - this._N;\n\n for (kk = 0; kk < N_M; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + this._M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (; kk < this._N - 1; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + M_N] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n\n y = (this._mt[this._N - 1] & this._UPPER_MASK) | (this._mt[0] & this._LOWER_MASK);\n this._mt[this._N - 1] = this._mt[this._M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this._mti = 0;\n }\n\n y = this._mt[(this._mti += 1)];\n y ^= y >>> 11;\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= y >>> 18;\n\n return y >>> 0;\n }\n\n /**\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n choice(A, n) {\n if (A instanceof Matrix) {\n let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A.row(d));\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let rows = A.length;\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A[d]);\n }\n }\n\n /**\n * @static\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @param {Number} seed - The seed for the random number generator.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n static choice(A, n, seed = 1212) {\n const R = new Randomizer(seed);\n return R.choice(A, n);\n /* let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let rand = new Randomizer(seed);\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = rand.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n //return result;\n //return new Matrix(n, cols, (row, col) => A.entry(sample[row], col))\n return sample.map((d) => A.row(d)); */\n }\n}\n","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias max\n * @param {Array} values \n * @returns {Number}\n */\nexport default function (values) {\n let max;\n for (const value of values) {\n if (value != null && (max < value || (max === undefined && value >= value))) {\n max = value;\n }\n }\n return max;\n}","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias min\n * @param {Array} values\n * @returns {Number}\n */\nexport default function (values) {\n let min;\n for (const value of values) {\n if (value != null && (min > value || (min === undefined && value <= value))) {\n min = value;\n }\n }\n return min;\n}","/**\n * @class\n * @alias Heap\n */\nexport class Heap {\n /**\n * A heap is a datastructure holding its elements in a specific way, so that the top element would be the first entry of an ordered list.\n * @constructor\n * @memberof module:datastructure\n * @alias Heap\n * @param {Array=} elements - Contains the elements for the Heap. {@link elements} can be null.\n * @param {Function} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(\"min\"|\"max\"|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n * @see {@link https://en.wikipedia.org/wiki/Binary_heap}\n */\n constructor(elements = null, accessor = d => d, comparator = \"min\") {\n if (elements) {\n return Heap.heapify(elements, accessor, comparator);\n } else {\n this._accessor = accessor;\n this._container = [];\n if (comparator == \"min\") {\n this._comparator = (a, b) => a < b;\n } else if (comparator == \"max\") {\n this._comparator = (a, b) => a > b;\n } else {\n this._comparator = comparator;\n }\n return this\n }\n }\n\n /**\n * Creates a Heap from an Array\n * @param {Array|Set} elements - Contains the elements for the Heap.\n * @param {Function=} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(String=|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n */\n static heapify(elements, accessor = d => d, comparator = \"min\") {\n const heap = new Heap(null, accessor, comparator);\n const container = heap._container;\n for (const e of elements) {\n container.push({\n \"element\": e,\n \"value\": accessor(e),\n });\n }\n for (let i = Math.floor((elements.length / 2) - 1); i >= 0; --i) {\n heap._heapify_down(i);\n }\n return heap;\n }\n\n /**\n * Swaps elements of container array.\n * @private\n * @param {Number} index_a \n * @param {Number} index_b \n */\n _swap(index_a, index_b) {\n const container = this._container;\n [container[index_b], container[index_a]] = [container[index_a], container[index_b]];\n return;\n }\n\n /**\n * @private\n */\n _heapify_up() {\n const container = this._container;\n let index = container.length - 1;\n while (index > 0) {\n let parentIndex = Math.floor((index - 1) / 2);\n if (!this._comparator(container[index].value, container[parentIndex].value)) {\n break;\n } else {\n this._swap(parentIndex, index)\n index = parentIndex;\n }\n }\n }\n\n /**\n * Pushes the element to the heap.\n * @param {} element\n * @returns {Heap}\n */\n push(element) {\n const value = this._accessor(element);\n //const node = new Node(element, value);\n const node = {\"element\": element, \"value\": value};\n this._container.push(node);\n this._heapify_up();\n return this;\n }\n\n /**\n * @private\n * @param {Number} [start_index = 0] \n */\n _heapify_down(start_index=0) {\n const container = this._container;\n const comparator = this._comparator;\n const length = container.length;\n let left = 2 * start_index + 1;\n let right = 2 * start_index + 2;\n let index = start_index;\n if (index > length) throw \"index higher than length\"\n if (left < length && comparator(container[left].value, container[index].value)) {\n index = left;\n }\n if (right < length && comparator(container[right].value, container[index].value)) {\n index = right;\n }\n if (index !== start_index) {\n this._swap(start_index, index);\n this._heapify_down(index);\n }\n }\n\n /**\n * Removes and returns the top entry of the heap.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n pop() {\n const container = this._container;\n if (container.length === 0) {\n return null;\n } else if (container.length === 1) {\n return container.pop();\n }\n this._swap(0, container.length - 1);\n const item = container.pop();\n this._heapify_down();\n return item;\n }\n\n /**\n * Returns the top entry of the heap without removing it.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n get first() {\n return this._container.length > 0 ? this._container[0] : null;\n }\n\n\n /**\n * Yields the raw data\n * @yields {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n * iterate() {\n for (let i = 0, n = this._container.length; i < n; ++i) {\n yield this._container[i].element;\n }\n }\n\n /**\n * Returns the heap as ordered array.\n * @returns {Array} Array consisting the elements ordered by {@link comparator}.\n */\n toArray() {\n return this.data()\n .sort((a,b) => this._comparator(a, b) ? -1 : 0)\n }\n\n /**\n * Returns elements of container array.\n * @returns {Array} Array consisting the elements.\n */\n data() {\n return this._container\n .map(d => d.element)\n }\n\n /**\n * Returns the container array.\n * @returns {Array} The container array.\n */\n raw_data() {\n return this._container;\n }\n\n /**\n * The size of the heap.\n * @returns {Number}\n */\n get length() {\n return this._container.length;\n }\n\n /**\n * Returns false if the the heap has entries, true if the heap has no entries.\n * @returns {Boolean}\n */\n get empty() {\n return this.length === 0;\n }\n}","/**\n * @class\n * @alias DisjointSet\n * @see {@link https://en.wikipedia.org/wiki/Disjoint-set_data_structure}\n */\nexport class DisjointSet {\n /**\n * @constructor\n * @alias DisjointSet\n * @memberof module:datastructure\n * @param {Array=} elements \n * @returns {DisjointSet}\n */\n constructor(elements = null) {\n this._list = new Set();\n if (elements) {\n for (const e of elements) {\n this.make_set(e);\n }\n }\n return this;\n }\n\n make_set(x) {\n const list = this._list;\n if (!list.has(x)) {\n list.add(x);\n x.__disjoint_set = {};\n x.__disjoint_set.parent = x;\n x.__disjoint_set.children = new Set([x]);\n x.__disjoint_set.size = 1;\n }\n return this;\n }\n\n find(x) {\n const list = this._list;\n if (list.has(x)) {\n if (x.__disjoint_set.parent !== x) {\n x.__disjoint_set.children.add(...x);\n x.__disjoint_set.parent = this.find(x.__disjoint_set.parent);\n return x.__disjoint_set.parent;\n } else {\n return x;\n }\n } else {\n return null;\n }\n }\n\n union(x, y) {\n let node_x = this.find(x);\n let node_y = this.find(y);\n\n if (node_x === node_y) return this;\n if (node_x.__disjoint_set.size < node_y.__disjoint_set.size) [node_x, node_y] = [node_y, node_x];\n\n node_y.__disjoint_set.parent = node_x;\n // keep track of children?\n node_y.__disjoint_set.children.forEach(node_x.__disjoint_set.children.add, node_x.__disjoint_set.children);\n node_x.__disjoint_set.size += node_y.__disjoint_set.size;\n\n return this;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n/**\n * @class\n * @alias BallTree\n */\nexport class BallTree {\n /**\n * Generates a BallTree with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias BallTree\n * @param {Array=} elements - Elements which should be added to the BallTree\n * @param {Function} [metric = euclidean] metric to use: (a, b) => distance\n * @see {@link https://en.wikipedia.org/wiki/Ball_tree}\n * @see {@link https://github.com/invisal/noobjs/blob/master/src/tree/BallTree.js}\n * @returns {BallTree}\n */\n constructor(elements = null, metric = euclidean) {\n this._Node = class {\n constructor(pivot, child1=null, child2=null, radius=null) {\n this.pivot = pivot;\n this.child1 = child1;\n this.child2 = child2;\n this.radius = radius;\n }\n }\n this._Leaf = class {\n constructor(points) {\n this.points = points;\n }\n }\n this._metric = metric;\n if (elements) {\n this.add(elements);\n }\n return this;\n }\n\n /**\n * \n * @param {Array<*>} elements - new elements.\n * @returns {BallTree}\n */\n add(elements) {\n elements = elements.map((element, index) => {\n return {index: index, element: element}\n })\n this._root = this._construct(elements);\n return this;\n }\n\n /**\n * @private\n * @param {Array<*>} elements \n * @returns {Node} root of balltree.\n */\n _construct(elements) {\n if (elements.length === 1) {\n return new this._Leaf(elements);\n } else {\n let c = this._greatest_spread(elements);\n let sorted_elements = elements.sort((a, b) => a.element[c] - b.element[c]);\n let n = sorted_elements.length;\n let p_index = Math.floor(n / 2);\n let p = elements[p_index];\n let L = sorted_elements.slice(0, p_index);\n let R = sorted_elements.slice(p_index, n);\n let radius = Math.max(...elements.map(d => this._metric(p.element, d.element)));\n let B\n if (L.length > 0 && R.length > 0) { \n B = new this._Node(p, this._construct(L), this._construct(R), radius);\n } else {\n B = new this._Leaf(elements);\n }\n return B;\n }\n }\n\n /**\n * @private\n * @param {Node} B \n * @returns {Number}\n */\n _greatest_spread(B) {\n let d = B[0].element.length;\n let start = new Array(d);\n\n for (let i = 0; i < d; ++i) {\n start[i] = [Infinity, -Infinity];\n }\n\n let spread = B.reduce((acc, current) => {\n for (let i = 0; i < d; ++i) {\n acc[i][0] = Math.min(acc[i][0], current.element[i]);\n acc[i][1] = Math.max(acc[i][1], current.element[i]);\n }\n return acc;\n }, start);\n spread = spread.map(d => d[1] - d[0]);\n \n let c = 0;\n for (let i = 0; i < d; ++i) {\n c = spread[i] > spread[c] ? i : c;\n }\n return c;\n }\n\n /**\n * \n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n return this._search(t, k, new Heap(null, d => this._metric(d.element, t), \"max\"), this._root);\n }\n\n /**\n * @private\n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @param {Heap} Q - Heap consists of the currently found {@link k} nearest neighbors.\n * @param {Node|Leaf} B \n */\n _search(t, k, Q, B) {\n // B is Node\n if (Q.length >= k && B.pivot && B.radius && this._metric(t, B.pivot.element) - B.radius >= Q.first.value) {\n return Q;\n } \n if (B.child1) this._search(t, k, Q, B.child1);\n if (B.child2) this._search(t, k, Q, B.child2);\n \n // B is leaf\n if (B.points) {\n for (let i = 0, n = B.points.length; i < n; ++i) {\n let p = B.points[i];\n if (k > Q.length) {\n Q.push(p);\n } else {\n Q.push(p);\n Q.pop();\n }\n }\n }\n return Q;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KNN\n */\nexport class KNN {\n /**\n * Generates a KNN list with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias KNN\n * @param {Array=} elements - Elements which should be added to the KNN list\n * @param {Function|\"precomputed\"} [metric = euclidean] metric is either precomputed or a function to use: (a, b) => distance\n * @returns {KNN}\n */\n constructor(elements=null, metric=euclidean) {\n this._metric = metric;\n this._elements = elements instanceof Matrix ? elements : Matrix.from(elements);\n const N = this._elements.shape[0];\n if (metric === \"precomputed\") {\n this._D = this._elements.clone();\n } else {\n this._D = distance_matrix(this._elements, metric);\n }\n this.KNN = [];\n for (let row = 0; row < N; ++row) {\n const distances = this._D.row(row);\n const H = new Heap(null, d => d.value, \"min\");\n for (let j = 0; j < N; ++j) {\n H.push({\n value: distances[j],\n index: j,\n });\n }\n this.KNN.push(H);\n }\n }\n\n /**\n * \n * @param {Array|Number} t - query element or index.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n const metric = this._metric;\n const KNN = this.KNN;\n let H;\n if (Array.isArray(t)) {\n if (this._metric == \"precomputed\") {\n throw \"Search by query element is only possible when not using a precomputed distance matrix!\"\n } \n const elements = this._elements;\n const N = KNN.length;\n let nearest_element_index = null;\n let nearest_dist = Infinity;\n for (let i = 0; i < N; ++i) {\n const element = elements.row(i);\n const dist = metric(t, element);\n if (dist < nearest_dist) {\n nearest_element_index = i;\n nearest_dist = dist;\n }\n }\n H = KNN[nearest_element_index];\n } else if (Number.isInteger(t)) {\n H = KNN[t]\n }\n\n let result = []\n for (let i = 0; i < k; ++i) {\n result.push(H.pop())\n }\n result.forEach(res => H.push(res.element))\n return result\n } \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n\n/**\n * @class\n * @alias DR\n * @borrows DR#parameter as DR#para\n * @borrows DR#parameter as DR#p\n */\nexport class DR {\n /**\n * Takes the default parameters and seals them, remembers the type of input {@link X}, and initializes the random number generator.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias DR\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed value for the random number generator.\n * @returns {DR}\n */\n constructor(X, default_parameters, parameters) {\n this._parameters = Object.assign(Object.seal(default_parameters), parameters);\n if (Array.isArray(X)) {\n this._type = \"array\";\n this.X = Matrix.from(X);\n } else if (X instanceof Matrix) {\n this._type = \"matrix\";\n this.X = X;\n } else {\n throw new Error(\"No valid type for X!\");\n }\n [this._N, this._D] = this.X.shape;\n this._randomizer = new Randomizer(this._parameters.seed);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * Set and get parameters\n * @param {String} name - name of the parameter.\n * @param {any} [value = null] - value of the parameter to set.\n * @returns {DR|any} - On setting a parameter, this function returns the DR object. If value == null then return actual parameter value.\n * @example\n * const DR = new druid.TSNE(X, {d: 3}); // creates a new DR object, with parameter for d = 3.\n * DR.parameter(\"d\"); // returns 3,\n * DR.parameter(\"d\", 2); // sets parameter d to 2 and returns DR.\n */\n parameter(name, value = null) {\n if (!this._parameters.hasOwnProperty(name)) {\n throw new Error(`${name} is not a valid parameter!`);\n }\n if (value) {\n this._parameters[name] = value;\n this._is_initialized = false;\n return this;\n } else {\n return this._parameters[name];\n }\n }\n\n para(name, value = null) {\n return this.parameter(name, value);\n }\n\n p(name, value = null) {\n return this.parameter(name, value);\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} - Returns the projection.\n */\n transform() {\n this.check_init();\n return this.projection;\n }\n\n /**\n * Computes the projection.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n *generator() {\n return this.transform();\n }\n\n /**\n * If the respective DR method has an init function, call it before transform.\n * @returns {DR}\n */\n check_init() {\n if (!this._is_initialized && typeof this.init === \"function\") {\n this.init();\n this._is_initialized = true;\n }\n return this;\n }\n\n /**\n * @returns {Matrix|Array} Returns the projection.\n */\n get projection() {\n if (this.hasOwnProperty(\"Y\")) {\n this.check_init();\n return this._type === \"matrix\" ? this.Y : this.Y.to2dArray;\n } else {\n throw new Error(\"The dataset is not transformed yet!\");\n }\n }\n\n /**\n *\n * @param {...any} args - Arguments the transform method of the respective DR method takes.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Matrix|Array} - The dimensionality reduced dataset.\n */\n static transform(...args) {\n let dr = new this(...args);\n return dr.transform();\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n static async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n static *generator(...args) {\n const dr = new this(...args);\n const generator = dr.generator();\n for (const result of generator) {\n yield result;\n }\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias PCA\n * @augments DR\n */\nexport class PCA extends DR {\n /**\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias PCA\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @returns {PCA}\n */\n constructor(X, parameters) {\n super(X, { d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}. If parameter {@link A} is given, then project {@link A} with the principal components of {@link X}.\n * @param {null|Matrix|Array} [A = null] - If given, the data to project.\n * @returns {Matrix|Array} - The projected data.\n */\n transform(A = null) {\n const V = this.principal_components();\n if (A == null) {\n const X = this.X;\n this.Y = X.dot(V);\n return this.projection;\n } else if (Array.isArray(A)) {\n return Matrix.from(A).dot(V).asArray;\n } else if (A instanceof Matrix) {\n return A.dot(V);\n } else {\n throw new Error(\"No valid type for A!\");\n }\n }\n\n /**\n * Computes the {@link d} principal components of Matrix {@link X}.\n * @returns {Matrix}\n */\n principal_components() {\n if (this.V) {\n return this.V;\n }\n const { d, eig_args } = this._parameters;\n const X = this.X;\n const means = Matrix.from(X.meanCols);\n const X_cent = X.sub(means);\n const C = X_cent.transpose().dot(X_cent);\n const { eigenvectors: V } = simultaneous_poweriteration(C, d, eig_args);\n this.V = Matrix.from(V).transpose();\n return this.V;\n }\n\n static principal_components(X, parameters) {\n const dr = new this(X, parameters);\n return dr.principal_components();\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias MDS\n * @extends DR\n */\nexport class MDS extends DR {\n /**\n * Classical MDS.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias MDS\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}.\n * @returns {Matrix|Array}\n */\n transform() {\n const X = this.X;\n const rows = X.shape[0];\n const { d, metric, eig_args } = this._parameters;\n const A = metric === \"precomputed\" ? X : distance_matrix(X, metric);\n const ai_ = A.meanCols;\n const a_j = A.meanRows;\n const a__ = A.mean;\n\n this._d_X = A;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n\n return this.projection;\n }\n\n /**\n * @returns {Number} - the stress of the projection.\n */\n stress() {\n const N = this.X.shape[0];\n const Y = this.Y;\n const d_X = this._d_X;\n const d_Y = new Matrix();\n d_Y.shape = [\n N,\n N,\n (i, j) => {\n return i < j ? euclidean(Y.row(i), Y.row(j)) : d_Y.entry(j, i);\n },\n ];\n let top_sum = 0;\n let bottom_sum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n top_sum += Math.pow(d_X.entry(i, j) - d_Y.entry(i, j), 2);\n bottom_sum += Math.pow(d_X.entry(i, j), 2);\n }\n }\n return Math.sqrt(top_sum / bottom_sum);\n }\n}\n","/**\n *\n * @memberof module:optimization\n * @alias powell\n * @param {Function} f\n * @param {Array} x0\n * @param {Number} [max_iter = 300]\n * @returns {Array}\n * @see http://optimization-js.github.io/optimization-js/optimization.js.html#line438\n */\nexport default function (f, x0, max_iter = 300) {\n const epsilon = 1e-2;\n const n = x0.length;\n let alpha = 1e-3;\n let pfx = 10000;\n let x = x0.slice();\n let fx = f(x);\n let convergence = false;\n\n while (max_iter-- >= 0 && !convergence) {\n convergence = true;\n for (let i = 0; i < n; ++i) {\n x[i] += 1e-6;\n let fxi = f(x);\n x[i] -= 1e-6;\n let dx = (fxi - fx) / 1e-6;\n if (Math.abs(dx) > epsilon) {\n convergence = false;\n }\n x[i] -= alpha * dx;\n fx = f(x);\n }\n alpha *= pfx >= fx ? 1.05 : 0.4;\n pfx = fx;\n }\n return x;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n/**\n * @class\n * @alias Hierarchical_Clustering\n */\nexport class Hierarchical_Clustering {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias Hierarchical_Clustering\n * @todo needs restructuring.\n * @param {Matrix} - Data or distance matrix if metric is 'precomputed'\n * @param {(\"single\"|\"complete\"|\"average\")} [linkage = \"complete\"]\n * @param {Function|\"precomputed\"} [metric = euclidean]\n * @returns {Hierarchical_Clustering}\n */\n constructor(matrix, linkage = \"complete\", metric = euclidean) {\n this._id = 0;\n this._matrix = matrix instanceof Matrix ? matrix : Matrix.from(matrix);\n this._metric = metric;\n this._linkage = linkage;\n if (metric === \"precomputed\" && this._matrix.shape[0] !== this._matrix.shape[1]) {\n throw new Error(\"If metric is 'precomputed', then matrix has to be square!\");\n }\n this.init();\n this.root = this.do();\n return this;\n }\n\n /**\n *\n * @param {Number} value - value where to cut the tree.\n * @param {(\"distance\"|\"depth\")} [type = \"distance\"] - type of value.\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters(value, type = \"distance\") {\n let clusters = [];\n let accessor;\n switch (type) {\n case \"distance\":\n accessor = (d) => d.dist;\n break;\n case \"depth\":\n accessor = (d) => d.depth;\n break;\n default:\n throw new Error(\"invalid type\");\n }\n this._traverse(this.root, accessor, value, clusters);\n return clusters;\n }\n\n /**\n * @private\n * @param {} node\n * @param {*} f\n * @param {*} value\n * @param {*} result\n */\n _traverse(node, f, value, result) {\n if (f(node) <= value) {\n result.push(node.leaves());\n } else {\n this._traverse(node.left, f, value, result);\n this._traverse(node.right, f, value, result);\n }\n }\n\n /**\n * computes the tree.\n */\n init() {\n const metric = this._metric;\n const A = this._matrix;\n const n = (this._n = A.shape[0]);\n const d_min = (this._d_min = new Float64Array(n));\n let distance_matrix;\n if (metric !== \"precomputed\") {\n distance_matrix = new Matrix(n, n, 0); //new Array(n);\n for (let i = 0; i < n; ++i) {\n d_min[i] = 0;\n //distance_matrix[i] = new Float64Array(n);\n for (let j = 0; j < n; ++j) {\n distance_matrix.set_entry(i, j, i === j ? Infinity : metric(A.row(i), A.row(j)));\n if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n } else {\n distance_matrix = this._matrix.clone();\n for (let i = 0; i < n; ++i) {\n for (let j = 0; j < n; ++j) {\n if (i === j) {\n distance_matrix.set_entry(i, j, Infinity);\n } else if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n }\n this._distance_matrix = distance_matrix;\n const clusters = (this._clusters = new Array(n));\n const c_size = (this._c_size = new Uint16Array(n));\n for (let i = 0; i < n; ++i) {\n clusters[i] = [];\n clusters[i][0] = new Cluster(this._id++, null, null, 0, A.row(i), i, 1, 0);\n c_size[i] = 1;\n }\n return this;\n }\n\n /**\n * computes the tree.\n */\n do() {\n const n = this._n;\n const d_min = this._d_min;\n const D = this._distance_matrix;\n const clusters = this._clusters;\n const c_size = this._c_size;\n const linkage = this._linkage;\n let root = null;\n for (let p = 0, p_max = n - 1; p < p_max; ++p) {\n let c1 = 0;\n for (let i = 0; i < n; ++i) {\n let D_i_min = D.entry(i, d_min[i]);\n for (let j = i + 1; j < n; ++j) {\n if (D_i_min > D.entry(i, j)) {\n d_min[i] = j;\n D_i_min = D.entry(i, d_min[i]);\n }\n }\n }\n for (let i = 0; i < n; ++i) {\n if (D.entry(i, d_min[i]) < D.entry(c1, d_min[c1])) {\n c1 = i;\n }\n }\n let c2 = d_min[c1];\n let c1_cluster = clusters[c1][0];\n let c2_cluster = clusters[c2][0];\n let c1_cluster_indices = c1_cluster.isLeaf ? [c1_cluster.index] : c1_cluster.index;\n let c2_cluster_indices = c2_cluster.isLeaf ? [c2_cluster.index] : c2_cluster.index;\n let indices = c1_cluster_indices.concat(c2_cluster_indices);\n let new_cluster = new Cluster(this._id++, c1_cluster, c2_cluster, D.entry(c1, c2), null, indices);\n c1_cluster.parent = new_cluster;\n c2_cluster.parent = new_cluster;\n clusters[c1].unshift(new_cluster);\n c_size[c1] += c_size[c2];\n for (let j = 0; j < n; ++j) {\n const D_c1_j = D.entry(c1, j);\n const D_c2_j = D.entry(c2, j);\n let value;\n switch (linkage) {\n case \"single\":\n value = Math.min(D_c1_j, D_c2_j);\n break;\n case \"complete\":\n value = Math.max(D_c1_j, D_c2_j);\n break;\n case \"average\":\n value = (c_size[c1] * D_c1_j + c_size[c2] * D_c2_j) / (c_size[c1] + c_size[j]);\n break;\n }\n D.set_entry(j, c1, value);\n D.set_entry(c1, j, value);\n }\n\n D.set_entry(c1, c1, Infinity);\n for (let i = 0; i < n; ++i) {\n D.set_entry(i, c2, Infinity);\n D.set_entry(c2, i, Infinity);\n }\n\n /* for (let j = 0; j < n; ++j) {\n if (d_min[j] === c2) {\n d_min[j] = c1;\n }\n if (D.entry(c1, j) < D.entry(c1, d_min[c1])) {\n d_min[c1] = j;\n }\n } */\n root = new_cluster;\n }\n return root;\n }\n}\n\nclass Cluster {\n constructor(id, left, right, dist, centroid, index, size, depth) {\n this.id = id;\n this.left = left;\n this.right = right;\n this.dist = dist;\n this.index = index;\n this.size = size ?? left.size + right.size;\n this.depth = depth ?? 1 + Math.max(left.depth, right.depth);\n this.centroid = centroid ?? this._calculate_centroid(left, right);\n this.parent = null;\n return this;\n }\n\n _calculate_centroid(left, right) {\n const l_size = left.size;\n const r_size = right.size;\n const l_centroid = left.centroid;\n const r_centroid = right.centroid;\n const size = this.size;\n const n = left.centroid.length;\n const new_centroid = new Float64Array(n);\n for (let i = 0; i < n; ++i) {\n new_centroid[i] = (l_size * l_centroid[i] + r_size * r_centroid[i]) / size;\n }\n return new_centroid;\n }\n\n get isLeaf() {\n return this.depth === 0;\n }\n\n leaves() {\n if (this.isLeaf) return [this];\n const left = this.left;\n const right = this.right;\n return (left.isLeaf ? [left] : left.leaves()).concat(right.isLeaf ? [right] : right.leaves());\n }\n\n descendants() {\n if (this.isLeaf) return [this];\n const left_descendants = this.left.descendants();\n const right_descendants = this.right.descendants();\n return left_descendants.concat(right_descendants).concat([this]);\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { linspace, Matrix } from \"../matrix/index.js\";\nimport { min } from \"../util/index.js\";\n/**\n * @class\n * @alias KMedoids\n */\nexport class KMedoids {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMedoids\n * @todo needs restructuring. \n * @param {Matrix} matrix - data matrix\n * @param {Numbers} K - number of clusters\n * @param {number} [max_iter=null] - maximum number of iterations. Default is 10 * Math.log10(N)\n * @param {Function} [metric = euclidean] - metric defining the dissimilarity \n * @param {Number} [seed = 1212] - seed value for random number generator\n * @returns {KMedoids}\n * @see {@link https://link.springer.com/chapter/10.1007/978-3-030-32047-8_16} Faster k-Medoids Clustering: Improving the PAM, CLARA, and CLARANS Algorithms\n */\n constructor(matrix, K, max_iter=null, metric = euclidean, seed=1212) {\n this._metric = metric;\n this._matrix = matrix;\n this._A = this._matrix.to2dArray;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n this._max_iter = max_iter || 10 * Math.log10(N) \n this._distance_matrix = new Matrix(N, N, \"zeros\");\n /* for (let i = 1; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dist = metric(this._A[i], this._A[j]);\n this._distance_matrix.set_entry(i, j, dist);\n this._distance_matrix.set_entry(j, i, dist)\n }\n } */\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_medoids = this._get_random_medoids(K);\n //if (init) this.init(K, this._cluster_medoids);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const A = this._A;\n if (!this._is_initialized) {\n this.init(K, this._cluster_medoids);\n }\n const result = new Array(K).fill().map(() => new Array());\n A.forEach((x_j, j) => {\n result[this._nearest_medoid(x_j, j).index_nearest].push(j);\n })\n result.medoids = this._cluster_medoids;\n return result;\n }\n\n async* generator() {\n const max_iter = this._max_iter;\n yield this.get_clusters()\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n yield this.get_clusters();\n } while (!finish && ++i < max_iter)\n }\n\n /**\n * Algorithm 1. FastPAM1: Improved SWAP algorithm\n */\n /* _iteration_1() {\n const A = this._A;\n const N = this._N;\n const K = this._K;\n const medoids = this._cluster_medoids;\n let DeltaTD = 0;\n let m0 = null;\n let x0 = null;\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const nearest_medoid = this._nearest_medoid(x_j, j);\n const d_j = nearest_medoid.distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n // disance to new medoid\n const d_oj = this._get_distance(o, j, x_o, x_j);\n const {\n \"index_nearest\": n,\n \"distance_nearest\": d_n,\n \"distance_second\": d_s,\n } = this._nearest_medoid(x_o, o); \n this._clusters[o] = n; // cached values\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change\n if (d_oj < d_n) { // reassignment check\n deltaTD.forEach((d_i, i) => {\n if (n !== i) {\n deltaTD[i] = d_i + d_oj - d_n; // update loss change\n }\n });\n }\n });\n // choose best medoid i;\n const i = deltaTD\n .map((d, i) => [d, i])\n .sort((d1, d2) => d1[0] - d2[0])[0][1];\n const deltaTD_i = deltaTD[i];\n // store\n if (deltaTD_i < DeltaTD) {\n DeltaTD = deltaTD_i;\n m0 = i;\n x0 = j;\n }\n }\n });\n\n if (DeltaTD >= 0) {\n return true // break loop if DeltaTD >= 0\n }\n // swap roles of medoid m and non-medoid x;\n medoids[m0] = x0;\n this._cluster_medoids = medoids;\n return false\n } */\n\n /** Algorithm 2. FastPAM2: SWAP with multiple candidates\n * \n */\n _iteration() {\n const A = this._A;\n const K = this._K;\n const medoids = this._cluster_medoids;\n const cache = A.map((x_o, o) => this._nearest_medoid(x_o, o));\n // empty best candidates array\n const DeltaTD = new Array(K).fill(0);\n const xs = new Array(K).fill(null);\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const d_j = cache[j].distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n if (j === o) return;\n const d_oj = this._get_distance(o, j, x_o, x_j); // distance to new medoid\n const {\"index_nearest\": n, \"distance_nearest\": d_n, \"distance_second\": d_s} = cache[o]; // cached\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change for x_o\n // Reassignment check\n if (d_oj < d_n) { \n // update loss change\n for (let i = 0; i < K; ++i) {\n if (i !== n) deltaTD[i] += d_oj - d_n;\n }\n }\n });\n // remember best swap for i;\n deltaTD\n .map((d, i) => [d, i])\n .filter(([d, i]) => d < DeltaTD[i])\n .forEach(([d, i]) => {\n if (d < DeltaTD[i]) {\n DeltaTD[i] = d;\n xs[i] = j;\n }\n })\n }\n })\n // stop if no improvements were found\n if (min(DeltaTD) >= 0) return true; \n\n // execute all improvements\n while (min(DeltaTD) < 0) {\n // swap roles of medoid m_i and non_medoid xs_i\n const i = DeltaTD\n .map((d, i) => [d, i])\n .sort(([a], [b]) => a - b)[0][1];\n if (medoids.filter(m => m == xs[i]).length == 0) {\n medoids[i] = xs[i];\n }\n // disable the swap just performed\n DeltaTD[i] = 0; \n // recompute TD for remaining swap candidates\n DeltaTD\n .map((d_j, j) => [d_j, j])\n .filter(([d_j]) => d_j < 0)\n .forEach(([_, j]) => {\n const x_j = A[j];\n let sum = 0;\n A.forEach((x_o, o) => {\n if (medoids.findIndex(m => m != j && m == o) >= 0) return;\n if (i == j) return;\n if (cache[o].index_nearest === medoids[j])\n sum += (Math.min(this._get_distance(o, j, x_o, x_j), cache[o].distance_second) - cache[o].distance_nearest); \n else {\n sum += (Math.min(this._get_distance(o, j, x_o, x_j) - cache[o].distance_nearest, 0));\n }\n });\n DeltaTD[j] = sum;\n })\n }\n this._cluster_medoids = medoids;\n return false;\n }\n\n _get_distance(i, j, x_i=null, x_j=null) {\n if (i === j) return 0;\n const D = this._distance_matrix;\n const A = this._A;\n const metric = this._metric;\n let d_ij = D.entry(i, j);\n if (d_ij === 0) {\n d_ij = metric(x_i || A[i], x_j || A[j]);\n D.set_entry(i, j, d_ij);\n D.set_entry(j, i, d_ij);\n }\n return d_ij;\n }\n\n _nearest_medoid(x_j, j) {\n const medoids = this._cluster_medoids;\n const A = this._A;\n const [nearest, second] = medoids\n .map((m, i) => {\n const x_m = A[m]; \n return [this._get_distance(j, m, x_j, x_m), i];\n })\n .sort((m1, m2) => m1[0] - m2[0]);\n \n return { \n \"distance_nearest\": nearest[0], \n \"index_nearest\": nearest[1],\n \"distance_second\": second[0],\n \"index_second\": second[1],\n };\n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_medoids) {\n if (!K) K = this._K;\n if (!cluster_medoids) cluster_medoids = this._get_random_medoids(K);\n const max_iter = this._max_iter;\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n } while (!finish && ++i < max_iter)\n return this;\n }\n\n /**\n * Algorithm 3. FastPAM LAB: Linear Approximate BUILD initialization.\n * @param {number} K - number of clusters\n * \n */\n _get_random_medoids(K) {\n const N = this._N;\n const A = this._A;\n const indices = linspace(0, N - 1);\n const randomizer = this._randomizer;\n const n = Math.min(N, 10 + Math.ceil(Math.sqrt(N)));\n const TD = new Array(n).fill(Infinity);\n const medoids = [];\n // first medoid\n let TD0 = Infinity;\n let S = randomizer.choice(indices, n);\n for (let j = 0; j < n; ++j) {\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const x_o = A[S[o]];\n TD[j] += this._get_distance(j, o, x_j, x_o);\n }\n if (TD[j] < TD0) {\n TD0 = TD[j]; // smallest distance sum\n medoids.push(S_j);\n }\n }\n // other medoids\n for (let i = 1; i < K; ++i) {\n let DeltaTD = Infinity;\n S = randomizer.choice(indices.filter(index => medoids.findIndex(d => d === index) < 0), n);\n for (let j = 0; j < n; ++j) {\n let deltaTD = 0;\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const S_o = S[o];\n const x_o = A[S_o];\n let delta = this._get_distance(S_j, S_o, x_j, x_o) - min(medoids.map(m => this._get_distance(S_o, m, x_o)));\n if (delta < 0) {\n deltaTD = deltaTD + delta;\n }\n }\n // best reduction\n if (deltaTD < DeltaTD) {\n DeltaTD = deltaTD;\n medoids.push(S_j);\n }\n }\n TD0 += DeltaTD;\n }\n return medoids.slice(0, K);\n }\n \n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n/**\n * @class\n * @alias FASTMAP\n * @extends DR\n */\nexport class FASTMAP extends DR {\n /**\n * FastMap: a fast algorithm for indexing, data-mining and visualization of traditional and multimedia datasets\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias FASTMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the dimensionality of the projection.\n * @returns {FASTMAP}\n * @see {@link https://doi.org/10.1145/223784.223812}\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n * Chooses two points which are the most distant in the actual projection.\n * @private\n * @param {Function} dist\n * @returns {Array} An array consisting of first index, second index, and distance between the two points.\n */\n _choose_distant_objects(dist) {\n const X = this.X;\n const N = X.shape[0];\n let a_index = (this._randomizer.random_int % N) - 1;\n let b_index = null;\n let max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n if (d_ai > max_dist) {\n max_dist = d_ai;\n b_index = i;\n }\n }\n max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_bi = dist(b_index, i);\n if (d_bi > max_dist) {\n max_dist = d_bi;\n a_index = i;\n }\n }\n return [a_index, b_index, max_dist];\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} The {@link d}-dimensional projection of the data matrix {@link X}.\n */\n transform() {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric } = this._parameters;\n const Y = new Matrix(N, d, 0);\n let dist = (a, b) => metric(X.row(a), X.row(b));\n\n for (let _col = 0; _col < d; ++_col) {\n let old_dist = dist;\n // choose pivot objects\n const [a_index, b_index, d_ab] = this._choose_distant_objects(dist);\n if (d_ab !== 0) {\n // project the objects on the line (O_a, O_b)\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n const d_bi = dist(b_index, i);\n const y_i = (d_ai ** 2 + d_ab ** 2 - d_bi ** 2) / (2 * d_ab);\n Y.set_entry(i, _col, y_i);\n }\n // consider the projections of the objects on a\n // hyperplane perpendicluar to the line (a, b);\n // the distance function D'() between two\n // projections is given by Eq.4\n dist = (a, b) => Math.sqrt(old_dist(a, b) ** 2 - (Y.entry(a, _col) - Y.entry(b, _col)) ** 2);\n }\n }\n // return embedding.\n this.Y = Y;\n return this.projection;\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { DR } from \"./DR.js\";\nimport euclidean from \"../metrics/euclidean.js\";\n\n/**\n * @class\n * @alias ISOMAP\n * @extends DR\n */\nexport class ISOMAP extends DR {\n /**\n * Isometric feature mapping (ISOMAP).\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias ISOMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link ISOMAP} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2319}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(this._parameters.neighbors ?? Math.max(Math.floor(this.X.shape[0] / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const X = this.X;\n const rows = this._N;\n const { d, metric, eig_args, neighbors } = this._parameters;\n // TODO: make knn extern and parameter for constructor or transform?\n const D = new Matrix();\n D.shape = [rows, rows, (i, j) => (i <= j ? metric(X.row(i), X.row(j)) : D.entry(j, i))];\n const kNearestNeighbors = [];\n for (let i = 0; i < rows; ++i) {\n const row = [];\n for (let j = 0; j < rows; ++j) {\n row.push({\n index: j,\n distance: D.entry(i, j),\n });\n }\n const H = new Heap(row, (d) => d.distance, \"min\");\n kNearestNeighbors.push(H.toArray().slice(1, neighbors + 1));\n }\n\n /*D = dijkstra(kNearestNeighbors);*/\n // compute shortest paths\n // TODO: make extern\n /** @see {@link https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm} */\n const G = new Matrix(rows, rows, (i, j) => {\n const other = kNearestNeighbors[i].find((n) => n.index === j);\n return other ? other.distance : Infinity;\n });\n\n for (let i = 0; i < rows; ++i) {\n for (let j = 0; j < rows; ++j) {\n for (let k = 0; k < rows; ++k) {\n G.set_entry(i, j, Math.min(G.entry(i, j), G.entry(i, k) + G.entry(k, j)));\n }\n }\n }\n\n let ai_ = new Float64Array(rows);\n let a_j = new Float64Array(rows);\n let a__ = 0;\n const A = new Matrix(rows, rows, (i, j) => {\n let val = G.entry(i, j);\n val = val === Infinity ? 0 : val;\n ai_[i] += val;\n a_j[j] += val;\n a__ += val;\n return val;\n });\n\n ai_ = ai_.map((v) => v / rows);\n a_j = a_j.map((v) => v / rows);\n a__ /= rows ** 2;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n // compute d eigenvectors\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n // return embedding\n return this.projection;\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { linspace } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KMeans\n */\nexport class KMeans {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMeans\n * @todo needs restructuring. \n * @param {Matrix} matrix \n * @param {Numbers} K \n * @param {Function} [metric = euclidean] \n * @param {Number} [seed = 1987]\n * @param {Boolean} [init = true]\n * @returns {KMeans}\n */\n constructor(matrix, K, metric = euclidean, seed=1987, init = true) {\n this._metric = metric;\n this._matrix = matrix;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_centroids = this._get_random_centroids(K);\n if (init) this.init(K, this._cluster_centroids);\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const clusters = this._clusters;\n const result = new Array(K).fill().map(() => new Array());\n clusters.forEach((c, i) => result[c].push(i));\n return result;\n }\n\n /**\n * @private\n * @param {Array} points \n * @param {Array} candidates \n */\n _furthest_point(points, candidates) {\n const A = this._matrix;\n const metric = this._metric;\n let i = points.length;\n let H = Heap.heapify(\n candidates, \n (d) => {\n const Ad = A.row(d)\n let sum = 0;\n for (let j = 0; j < i; ++j) {\n sum += metric(Ad, points[j])\n }\n return sum;\n }, \n \"max\"\n )\n return H.pop().element;\n }\n\n _get_random_centroids(K) {\n const N = this._N;\n const randomizer = this._randomizer;\n const A = this._matrix;\n const cluster_centroids = new Array(K).fill()\n const indices = linspace(0, N - 1);\n const random_point = randomizer.random_int % (N - 1);\n cluster_centroids[0] = A.row(random_point);\n const init_points = [random_point];\n const sample_size = Math.floor((N - K) / K);// / K\n for (let i = 1; i < K; ++i) {\n // sampling + kmeans++ improvement?\n const sample = randomizer.choice(indices.filter(d => init_points.indexOf(d) == -1), sample_size);\n const furthest_point = this._furthest_point(cluster_centroids.slice(0, i), sample);\n init_points.push(furthest_point);\n cluster_centroids[i] = A.row(furthest_point);\n }\n return cluster_centroids;\n }\n\n _iteration(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const metric = this._metric;\n const clusters = this._clusters;\n let clusters_changed = false;\n // find nearest cluster centroid.\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i)\n let min_dist = Infinity;\n let min_cluster = null;\n for (let j = 0; j < K; ++j) {\n let d = metric(cluster_centroids[j], Ai);\n if (d < min_dist) {\n min_dist = d;\n min_cluster = j; \n }\n }\n if (clusters[i] !== min_cluster) {\n clusters_changed = true;\n }\n clusters[i] = min_cluster;\n }\n // update cluster centroid\n // reset cluster centroids to 0\n for (let i = 0; i < K; ++i) {\n const centroid = cluster_centroids[i];\n for (let j = 0; j < D; ++j) {\n centroid[j] = 0;\n }\n }\n // compute centroid\n this._compute_centroid(cluster_centroids);\n\n return { \n \"clusters_changed\": clusters_changed,\n \"cluster_centroids\": cluster_centroids\n };\n }\n\n _compute_centroid(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const clusters = this._clusters;\n const cluster_counter = new Array(K).fill(0);\n\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i);\n const ci = clusters[i];\n cluster_counter[ci]++;\n const centroid = cluster_centroids[ci];\n for (let j = 0; j < D; ++j) {\n centroid[j] += Ai[j];\n }\n }\n for (let i = 0; i < K; ++i) {\n const n = cluster_counter[i];\n cluster_centroids[i] = cluster_centroids[i].map(c => c / n);\n }\n \n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_centroids) {\n if (!K) K = this._K;\n if (!cluster_centroids) cluster_centroids = this._get_random_centroids(K);\n let clusters_changed = false;\n do {\n const iteration_result = this._iteration(cluster_centroids)\n cluster_centroids = iteration_result.cluster_centroids;\n clusters_changed = iteration_result.clusters_changed;\n } while (clusters_changed)\n }\n \n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LDA\n * @extends DR\n */\nexport class LDA extends DR {\n /**\n * Linear Discriminant Analysis.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LDA\n * @param {Matrix} X - The high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Array} parameters.labels - The labels / classes for each data point.\n * @param {number} [parameters.d = 2] - The dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://onlinelibrary.wiley.com/doi/10.1111/j.1469-1809.1936.tb02137.x}\n */\n constructor(X, parameters) {\n super(X, { labels: null, d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, cols] = X.shape;\n const { d, labels, eig_args } = this._parameters;\n if (labels === null || labels.length != rows) {\n throw new Error(\"LDA needs parameter label to every datapoint to work!\");\n }\n const unique_labels = {};\n let label_id = 0;\n labels.forEach((l, i) => {\n if (l in unique_labels) {\n unique_labels[l].count++;\n unique_labels[l].rows.push(X.row(i));\n } else {\n unique_labels[l] = {\n id: label_id++,\n count: 1,\n rows: [X.row(i)],\n };\n }\n });\n\n // create X_mean and vector means;\n const X_mean = X.mean;\n const V_mean = new Matrix(label_id, cols);\n for (const label in unique_labels) {\n const V = Matrix.from(unique_labels[label].rows);\n const v_mean = V.meanCols;\n for (let j = 0; j < cols; ++j) {\n V_mean.set_entry(unique_labels[label].id, j, v_mean[j]);\n }\n }\n // scatter_between\n let S_b = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j] - X_mean);\n const N = unique_labels[label].count;\n S_b = S_b.add(m.dot(m.transpose()).mult(N));\n }\n\n // scatter_within\n let S_w = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j]);\n const R = unique_labels[label].rows;\n for (let i = 0, n = unique_labels[label].count; i < n; ++i) {\n const row_v = new Matrix(cols, 1, (j, _) => R[i][j] - m.entry(j, 0));\n S_w = S_w.add(row_v.dot(row_v.transpose()));\n }\n }\n\n let { eigenvectors: V } = simultaneous_poweriteration(S_w.inverse().dot(S_b), d, eig_args);\n V = Matrix.from(V).transpose();\n this.Y = X.dot(V);\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { k_nearest_neighbors } from \"../matrix/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LLE\n * @extends DR\n */\nexport class LLE extends DR {\n /**\n * Locally Linear Embedding.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LLE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} neighbors - the label / class of each data point.\n * @param {Number} [d = 2] - the dimensionality of the projection.\n * @param {Function} [metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [seed = 1212] - the dimensionality of the projection.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2323}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const rows = this._N;\n const cols = this._D;\n const { neighbors, d, eig_args, metric } = this._parameters;\n const nN = k_nearest_neighbors(X, neighbors, metric);\n const O = new Matrix(neighbors, 1, 1);\n const W = new Matrix(rows, rows);\n\n for (let row = 0; row < rows; ++row) {\n const nN_row = nN[row];\n const Z = new Matrix(neighbors, cols, (i, j) => X.entry(nN_row[i].j, j) - X.entry(row, j));\n const C = Z.dot(Z.T);\n if (neighbors > cols) {\n const C_trace = neumair_sum(C.diag) / 1000;\n for (let j = 0; j < neighbors; ++j) {\n C.set_entry(j, j, C.entry(j, j) + C_trace);\n }\n }\n // reconstruct;\n let w = Matrix.solve_CG(C, O, this._randomizer);\n w = w.divide(w.sum);\n for (let j = 0; j < neighbors; ++j) {\n W.set_entry(row, nN_row[j].j, w.entry(j, 0));\n }\n }\n // comp embedding\n const I = new Matrix(rows, rows, \"identity\");\n const IW = I.sub(W);\n const M = IW.T.dot(IW);\n const { eigenvectors: V } = simultaneous_poweriteration(M.T.inverse(), d + 1, eig_args);\n this.Y = Matrix.from(V.slice(1, 1 + d)).T;\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\nimport { MDS } from \"./MDS.js\";\nimport { KMedoids } from \"../clustering/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\n/**\n * @class\n * @alias LSP\n * @extends DR\n */\nexport class LSP extends DR {\n /**\n * Least Squares Projection.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LSP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.neighbors = Math.max(Math.floor(N / 10), 2)] - number of neighbors to consider.\n * @param {Number} [parameters.control_points = Math.ceil(Math.sqrt(N))] - number of controlpoints\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {LSP}\n * @see {@link https://ieeexplore.ieee.org/document/4378370}\n * @todo accept precomputed distance matrix.\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, control_points: undefined, d: 2, metric: euclidean, seed: 1212 }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n this.parameter(\"control_points\", Math.min(parameters.control_points ?? Math.ceil(Math.sqrt(this._N)), this._N - 1));\n this._is_initialized = false;\n return this;\n }\n\n /**\n *\n * @param {DR} DR - method used for position control points.\n * @param {Object} DR_parameters - Object containing parameters for the DR method which projects the control points\n * @returns {LSP}\n */\n init(DR = MDS, DR_parameters = {}, KNN = BallTree) {\n if (this._is_initialized) return this;\n const X = this.X;\n const N = this._N;\n const K = this.parameter(\"neighbors\");\n const d = this.parameter(\"d\");\n const seed = this.parameter(\"seed\");\n const metric = this.parameter(\"metric\");\n DR_parameters = Object.assign({d, metric, seed }, DR_parameters);\n const nc = this.parameter(\"control_points\");\n const control_points = new KMedoids(X, nc, null, metric).get_clusters().medoids;\n const C = new Matrix(nc, N, \"zeros\");\n control_points.forEach((c_i, i) => {\n C.set_entry(i, c_i, 1);\n });\n const Y_C = new DR(Matrix.from(control_points.map((c_i) => X.row(c_i))), DR_parameters).transform();\n\n const XA = X.to2dArray;\n const knn = new KNN(XA, metric);\n const L = new Matrix(N, N, \"I\");\n const alpha = -1 / K;\n XA.forEach((x_i, i) => {\n for (const { index: j } of knn.search(x_i, K).iterate()) {\n if (i === j) continue;\n L.set_entry(i, j, alpha);\n }\n });\n const A = L.concat(C, \"vertical\");\n\n const z = new Matrix(N, d, \"zeros\");\n const b = z.concat(Y_C, \"vertical\");\n\n this._A = A;\n this._b = b;\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const A = this._A;\n const AT = A.T;\n const b = this._b;\n const ATA = AT.dot(A);\n const ATb = AT.dot(b);\n this.Y = Matrix.solve_CG(ATA, ATb, this._randomizer);\n return this.projection;\n }\n}\n","import { Matrix, k_nearest_neighbors } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LTSA\n * @extends DR\n */\nexport class LTSA extends DR {\n /**\n * Local Tangent Space Alignment\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LTSA\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link LTSA} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://epubs.siam.org/doi/abs/10.1137/S1064827502419154}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n if (this._D <= this.parameter(\"d\")) {\n throw new Error(`Dimensionality of X (D = ${this._D}) must be greater than the required dimensionality of the result (d = ${this.parameter(\"d\")})!`);\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, D] = X.shape;\n const { d, neighbors, metric, eig_args } = this._parameters;\n // 1.1 determine k nearest neighbors\n const nN = k_nearest_neighbors(X, neighbors, metric);\n // center matrix\n const O = new Matrix(D, D, \"center\");\n const B = new Matrix(rows, rows, 0);\n\n for (let row = 0; row < rows; ++row) {\n // 1.2 compute the d largest eigenvectors of the correlation matrix\n const I_i = [row, ...nN[row].map((n) => n.j)];\n let X_i = Matrix.from(I_i.map((n) => X.row(n)));\n // center X_i\n X_i = X_i.dot(O);\n // correlation matrix\n const C = X_i.dot(X_i.transpose());\n const { eigenvectors: g } = simultaneous_poweriteration(C, d, eig_args);\n //g.push(linspace(0, k).map(_ => 1 / Math.sqrt(k + 1)));\n const G_i_t = Matrix.from(g);\n // 2. Constructing alignment matrix\n const W_i = G_i_t.transpose()\n .dot(G_i_t)\n .add(1 / Math.sqrt(neighbors + 1));\n for (let i = 0; i < neighbors + 1; ++i) {\n for (let j = 0; j < neighbors + 1; ++j) {\n B.set_entry(I_i[i], I_i[j], B.entry(I_i[i], I_i[j]) - (i === j ? 1 : 0) + W_i.entry(i, j));\n }\n }\n }\n\n // 3. Aligning global coordinates\n const { eigenvectors: Y } = simultaneous_poweriteration(B, d + 1, eig_args);\n this.Y = Matrix.from(Y.slice(1)).transpose();\n\n // return embedding\n return this.projection;\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias OPTICS\n */\nexport class OPTICS {\n /**\n * **O**rdering **P**oints **T**o **I**dentify the **C**lustering **S**tructure.\n * @constructor\n * @memberof module:clustering\n * @alias OPTICS\n * @todo needs restructuring. \n * @param {Matrix} matrix - the data.\n * @param {Number} epsilon - the minimum distance which defines whether a point is a neighbor or not.\n * @param {Number} min_points - the minimum number of points which a point needs to create a cluster. (Should be higher than 1, else each point creates a cluster.)\n * @param {Function} [metric = euclidean] - the distance metric which defines the distance between two points of the {@link matrix}.\n * @returns {OPTICS}\n * @see {@link https://www.dbs.ifi.lmu.de/Publikationen/Papers/OPTICS.pdf}\n * @see {@link https://en.wikipedia.org/wiki/OPTICS_algorithm}\n */\n constructor(matrix, epsilon, min_points, metric = euclidean) {\n this._matrix = matrix;\n this._epsilon = epsilon;\n this._min_points = min_points;\n this._metric = metric;\n\n this._ordered_list = [];\n this._clusters = [];\n this._DB = new Array(matrix.shape[0]).fill();\n this.init();\n return this;\n }\n\n /**\n * Computes the clustering.\n */\n init() {\n const ordered_list = this._ordered_list;\n const matrix = this._matrix;\n const N = matrix.shape[0];\n const DB = this._DB;\n const clusters = this._clusters;\n let cluster_index = this._cluster_index = 0;\n\n for (let i = 0; i < N; ++i) {\n DB[i] = {\n \"element\": matrix.row(i),\n \"index\": i,\n \"reachability_distance\": undefined,\n \"processed\": false,\n }\n }\n for (const p of DB) {\n if (p.processed) continue;\n p.neighbors = this._get_neighbors(p);\n p.processed = true;\n clusters.push([p.index])\n cluster_index = clusters.length - 1;\n ordered_list.push(p);\n if (this._core_distance(p) != undefined) {\n const seeds = new Heap(null, d => d.reachability_distance, \"min\")\n this._update(p, seeds);\n this._expand_cluster(seeds, clusters[cluster_index]);\n }\n }\n return this;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Array} An array consisting of the {@link epsilon}-neighborhood of {@link p}.\n */\n _get_neighbors(p) {\n if (\"neighbors\" in p) return p.neighbors;\n const DB = this._DB;\n const metric = this._metric;\n const epsilon = this._epsilon;\n const neighbors = [];\n for (const q of DB) {\n if (q.index == p.index) continue;\n if (metric(p.element, q.element) < epsilon) {\n neighbors.push(q);\n }\n }\n return neighbors;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Number} The distance to the {@link min_points}-th nearest point of {@link p}, or undefined if the {@link epsilon}-neighborhood has fewer elements than {@link min_points}.\n */\n _core_distance(p) {\n const min_points = this._min_points;\n const metric = this._metric;\n if (p.neighbors && p.neighbors.length <= min_points) {\n return undefined;\n }\n return metric(p.element, p.neighbors[min_points].element);\n }\n\n /**\n * Updates the reachability distance of the points.\n * @private\n * @param {Object} p \n * @param {Heap} seeds \n */\n _update(p, seeds) {\n const metric = this._metric;\n const core_distance = this._core_distance(p);\n const neighbors = this._get_neighbors(p);//p.neighbors;\n for (const q of neighbors) {\n if (q.processed) continue;\n const new_reachability_distance = Math.max(core_distance, metric(p.element, q.element));\n //if (q.reachability_distance == undefined) { // q is not in seeds\n if (seeds.raw_data().findIndex(d => d.element == q) < 0) {\n q.reachability_distance = new_reachability_distance;\n seeds.push(q);\n } else { // q is in seeds\n if (new_reachability_distance < q.reachability_distance) {\n q.reachability_distance = new_reachability_distance;\n seeds = Heap.heapify(seeds.data(), d => d.reachability_distance, \"min\"); // seeds change key =/\n }\n }\n }\n }\n\n /**\n * Expands the {@link cluster} with points in {@link seeds}.\n * @private\n * @param {Heap} seeds \n * @param {Array} cluster \n */\n _expand_cluster(seeds, cluster) {\n const ordered_list = this._ordered_list;\n while (!seeds.empty) {\n const q = seeds.pop().element;\n q.neighbors = this._get_neighbors(q);\n q.processed = true;\n cluster.push(q.index);\n ordered_list.push(q);\n if (this._core_distance(q) != undefined) {\n this._update(q, seeds);\n this._expand_cluster(seeds, cluster);\n }\n }\n }\n\n /**\n * Returns an array of clusters.\n * @returns {Array} Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters() {\n const clusters = [];\n const outliers = [];\n const min_points = this._min_points;\n for (const cluster of this._clusters) {\n if (cluster.length < min_points) {\n outliers.push(...cluster);\n } else {\n clusters.push(cluster);\n }\n }\n clusters.push(outliers);\n return clusters;\n }\n\n /**\n * @returns {Array} Returns an array, where the ith entry defines the cluster affirmation of the ith point of {@link matrix}. (-1 stands for outlier)\n */\n get_cluster_affirmation() {\n const N = this._matrix.shape[0];\n const result = new Array(N).fill();\n const clusters = this.get_clusters();\n for (let i = 0, n = clusters.length; i < n; ++i) {\n const cluster = clusters[i]\n for (const index of cluster) {\n result[index] = (i < n - 1) ? i : -1;\n }\n }\n return result;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { PCA, MDS } from \"./index.js\";\nimport { distance_matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias SAMMON\n * @extends DR\n */\nexport class SAMMON extends DR {\n /**\n * SAMMON's Mapping\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias SAMMON\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {\"PCA\"|\"MDS\"|\"random\"} [parameters.init = \"random\"] - Either \"PCA\" or \"MDS\", with which SAMMON initialiates the projection. With \"random\" a random matrix gets used as starting point.\n * @param {Object} [parameters.init_parameters] - Parameters for the {@link init}-DR method.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {SAMMON}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { magic: 0.1, d: 2, metric: euclidean, seed: 1212, init_DR: \"random\", init_parameters: {} }, parameters);\n return this;\n }\n\n /**\n * initializes the projection.\n * @private\n */\n init() {\n const N = this.X.shape[0];\n const { d, metric, init_DR: init_DR, init_parameters: DR_parameters } = this._parameters;\n if (init_DR === \"random\") {\n const randomizer = this._randomizer;\n this.Y = new Matrix(N, d, () => randomizer.random);\n } else if ([\"PCA\", \"MDS\"].includes(init_DR)) {\n this.Y = Matrix.from(init_DR == \"PCA\" ? PCA.transform(this.X, DR_parameters) : MDS.transform(this.X, DR_parameters));\n } else {\n throw new Error('init_DR needs to be either \"random\" or a DR method!')\n }\n this.distance_matrix = metric == \"precomputed\" ? Matrix.from(this.X) : distance_matrix(this.X, metric);\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Matrix|Array} - The projection of {@link X}.\n */\n transform(max_iter = 200) {\n if (!this._is_initialized) this.init();\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n }\n return this.projection;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Generator} - A generator yielding the intermediate steps of the projection of {@link X}.\n */\n *generator(max_iter = 200) {\n if (!this._is_initialized) this.init();\n\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n yield this.projection;\n }\n\n return this.projection;\n }\n\n _step() {\n const MAGIC = this.parameter(\"magic\");\n const D = this.distance_matrix;\n const N = this.X.shape[0];\n const { d, metric } = this._parameters;\n let Y = this.Y;\n\n let G = new Matrix(N, d, 0);\n\n let sum = new Float64Array(d);\n for (let i = 0; i < N; ++i) {\n let e1 = new Float64Array(d);\n let e2 = new Float64Array(d);\n const Yi = Y.row(i);\n for (let j = 0; j < N; ++j) {\n if (i === j) continue;\n const Yj = Y.row(j);\n const delta = new Float64Array(d);\n for (let k = 0; k < d; ++k) {\n delta[k] = Yi[k] - Yj[k];\n }\n const dY = metric(Yi, Yj);\n const dX = D.entry(i, j);\n const dq = dX - dY;\n const dr = Math.max(dX * dY, 1e-2);\n for (let k = 0; k < d; ++k) {\n e1[k] += (delta[k] * dq) / dr;\n e2[k] += (dq - (Math.pow(delta[k], 2) * (1 + dq / dY)) / dY) / dr;\n }\n }\n for (let k = 0; k < d; ++k) {\n const val = Y.entry(i, k) + ((MAGIC * e1[k]) / Math.abs(e2[k]) || 0);\n G.set_entry(i, k, val);\n sum[k] += val;\n }\n }\n for (let k = 0; k < d; ++k) {\n sum[k] /= N;\n }\n\n for (let i = 0; i < N; ++i) {\n for (let k = 0; k < d; ++k) {\n Y.set_entry(i, k, G.entry(i, k) - sum[k]);\n }\n }\n return Y;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TSNE\n * @extends DR\n */\nexport class TSNE extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TSNE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.perplexity = 50] - perplexity.\n * @param {Number} [parameters.epsilon = 10] - learning parameter.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TSNE}\n */\n constructor(X, parameters) {\n super(X, { perplexity: 50, epsilon: 10, d: 2, metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._iter = 0;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => this._randomizer.random);\n return this;\n }\n\n /**\n *\n * @param {Matrix} distance_matrix - accepts a precomputed distance matrix\n * @returns {TSNE}\n */\n init() {\n // init\n const Htarget = Math.log(this.parameter(\"perplexity\"));\n const N = this._N;\n const D = this._D;\n const {metric} = this._parameters;\n const X = this.X;\n let Delta;\n if (metric ==\"precomputed\") {\n Delta = druid.Matrix.from(X);\n } else {\n Delta = new Matrix(N, N);\n for (let i = 0; i < N; ++i) {\n const X_i = X.row(i);\n for (let j = i + 1; j < N; ++j) {\n const distance = metric(X_i, X.row(j));\n Delta.set_entry(i, j, distance);\n Delta.set_entry(j, i, distance);\n }\n }\n }\n\n const P = new Matrix(N, N, \"zeros\");\n\n this._ystep = new Matrix(N, D, \"zeros\");\n this._gains = new Matrix(N, D, 1);\n\n // search for fitting sigma\n let prow = new Float64Array(N)\n const tol = 1e-4;\n const maxtries = 50;\n for (let i = 0; i < N; ++i) {\n let betamin = -Infinity;\n let betamax = Infinity;\n let beta = 1;\n let done = false;\n\n let num = 0;\n while (!done) {\n let psum = 0;\n for (let j = 0; j < N; ++j) {\n let pj = Math.exp(-Delta.entry(i, j) * beta);\n if (i === j) pj = 0;\n prow[j] = pj;\n psum += pj;\n }\n let Hhere = 0;\n for (let j = 0; j < N; ++j) {\n let pj = psum === 0 ? 0 : prow[j] / psum;\n prow[j] = pj;\n if (pj > 1e-7) {\n Hhere -= pj * Math.log(pj);\n }\n }\n if (Hhere > Htarget) {\n betamin = beta;\n beta = betamax === Infinity ? beta * 2 : (beta + betamax) / 2;\n } else {\n betamax = beta;\n beta = betamin === -Infinity ? beta / 2 : (beta + betamin) / 2;\n }\n ++num;\n if (Math.abs(Hhere - Htarget) < tol) done = true;\n if (num >= maxtries) done = true;\n }\n\n for (let j = 0; j < N; ++j) {\n P.set_entry(i, j, prow[j]);\n }\n }\n\n //compute probabilities\n const Pout = new Matrix(N, N, \"zeros\");\n const N2 = N * 2;\n for (let i = 0; i < N; ++i) {\n for (let j = i; j < N; ++j) {\n const p = Math.max((P.entry(i, j) + P.entry(j, i)) / N2, 1e-100);\n Pout.set_entry(i, j, p);\n Pout.set_entry(j, i, p);\n }\n }\n this._P = Pout;\n return this;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n transform(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n *generator(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * performs a optimization step\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const P = this._P;\n const ystep = this._ystep;\n const gains = this._gains;\n const N = this._N;\n const { d: dim, epsilon} = this._parameters;\n let Y = this.Y;\n\n //calc cost gradient;\n const pmul = iter < 100 ? 4 : 1;\n\n // compute Q dist (unnormalized)\n const Qu = new Matrix(N, N, \"zeros\");\n let qsum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dsum = 0;\n for (let d = 0; d < dim; ++d) {\n const dhere = Y.entry(i, d) - Y.entry(j, d);\n dsum += dhere * dhere;\n }\n const qu = 1 / (1 + dsum);\n Qu.set_entry(i, j, qu);\n Qu.set_entry(j, i, qu);\n qsum += 2 * qu;\n }\n }\n\n // normalize Q dist\n const Q = new Matrix(N, N, 0);\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n const val = Math.max(Qu.entry(i, j) / qsum, 1e-100);\n Q.set_entry(i, j, val);\n Q.set_entry(j, i, val);\n }\n }\n\n const grad = new Matrix(N, dim, \"zeros\");\n for (let i = 0; i < N; ++i) {\n for (let j = 0; j < N; ++j) {\n const premult = 4 * (pmul * P.entry(i, j) - Q.entry(i, j)) * Qu.entry(i, j);\n for (let d = 0; d < dim; ++d) {\n grad.set_entry(i, d, grad.entry(i, d) + premult * (Y.entry(i, d) - Y.entry(j, d)));\n }\n }\n }\n\n // perform gradient step\n let ymean = new Float64Array(dim);\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const gid = grad.entry(i, d);\n const sid = ystep.entry(i, d);\n const gainid = gains.entry(i, d);\n\n let newgain = Math.sign(gid) === Math.sign(sid) ? gainid * 0.8 : gainid + 0.2;\n if (newgain < 0.01) newgain = 0.01;\n gains.set_entry(i, d, newgain);\n\n const momval = iter < 250 ? 0.5 : 0.8;\n const newsid = momval * sid - epsilon * newgain * gid;\n ystep.set_entry(i, d, newsid);\n\n Y.set_entry(i, d, Y.entry(i, d) + newsid);\n ymean[d] += Y.entry(i, d);\n }\n }\n\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < 2; ++d) {\n Y.set_entry(i, d, Y.entry(i, d) - ymean[d] / N);\n }\n }\n\n return this.Y;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { DisjointSet } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias TopoMap\n * @memberof module:dimensionality_reduction\n * @extends DR\n */\nexport class TopoMap extends DR {\n /**\n * TopoMap: A 0-dimensional Homology Preserving Projection of High-Dimensional Data.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TopoMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TopoMap}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._distance_matrix = new Matrix(this._N, this._N, 0);\n return this;\n }\n\n /**\n * @private\n */\n __lazy_distance_matrix(i, j, metric) {\n const D = this._distance_matrix;\n const X = this.X;\n const D_ij = D.entry(i, j);\n if (D_ij === 0) {\n let dist = metric(X.row(i), X.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n return dist;\n }\n return D_ij;\n }\n\n /**\n * Computes the minimum spanning tree, using a given metric\n * @private\n * @param {Function} metric\n * @see {@link https://en.wikipedia.org/wiki/Kruskal%27s_algorithm}\n */\n _make_minimum_spanning_tree(metric = euclidean) {\n const N = this._N;\n const X = [...this.X];\n\n let disjoint_set = new DisjointSet(X);\n const F = [];\n let E = [];\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n E.push([i, j, this.__lazy_distance_matrix(i, j, metric)]);\n }\n }\n E = E.sort((a, b) => a[2] - b[2]);\n\n for (const [u, v, w] of E) {\n const set_u = disjoint_set.find(X[u]);\n const set_v = disjoint_set.find(X[v]);\n if (set_u !== set_v) {\n F.push([u, v, w]);\n disjoint_set.union(set_u, set_v);\n }\n }\n\n return F.sort((a, b) => a[2] - b[2]);\n }\n\n /**\n * initializes TopoMap. Sets all projcted points to zero, and computes a minimum spanning tree.\n */\n init() {\n const { metric} = this._parameters\n this.Y = new Matrix(this._N, 2, 0);\n this._Emst = this._make_minimum_spanning_tree(metric);\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Returns true if Point C is left of line AB.\n * @private\n * @param {Array} PointA - Point A of line AB\n * @param {Array} PointB - Point B of line AB\n * @param {Array} PointC - Point C\n * @returns {Boolean}\n */\n __hull_cross([ax, ay], [bx, by], [sx, sy]) {\n return (bx - ax) * (sy - ay) - (by - ay) * (sx - ax) <= 0;\n }\n\n /**\n * Computes the convex hull of the set of Points S\n * @private\n * @param {Array} S - Set of Points.\n * @see {@link https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain#JavaScript}\n * @returns {Array} convex hull of S. Starts at the bottom-most point and continues counter-clockwise.\n */\n __hull(S) {\n const points = S.sort(([x1, y1], [x2, y2]) => y1 - y2 || x1 - x2);\n const N = points.length;\n if (N <= 2) return points;\n\n const lower = [];\n for (let i = 0; i < N; ++i) {\n while (lower.length >= 2 && this.__hull_cross(lower[lower.length - 2], lower[lower.length - 1], points[i])) {\n lower.pop();\n }\n lower.push(points[i]);\n }\n const upper = [];\n for (let i = N - 1; i >= 0; --i) {\n while (upper.length >= 2 && this.__hull_cross(upper[upper.length - 2], upper[upper.length - 1], points[i])) {\n upper.pop();\n }\n upper.push(points[i]);\n }\n upper.pop();\n lower.pop();\n return lower.concat(upper);\n }\n\n /**\n * Finds the angle to rotate Point A and B to lie on a line parallel to the x-axis.\n * @private\n * @param {Array} PointA\n * @param {Array} PointB\n * @return {Object} Object containing the sinus- and cosinus-values for a rotation.\n */\n __findAngle([p1x, p1y], [p2x, p2y]) {\n const n = euclidean([p1x, p1y], [p2x, p2y]);\n if (n === 0)\n return {\n sin: 0,\n cos: 1,\n };\n const vec = [(p2x - p1x) / n, (p2y - p1y) / n];\n const cos = vec[0];\n let sin = Math.sqrt(1 - cos * cos);\n sin = vec[1] >= 0 ? -sin : sin;\n return {\n sin: sin,\n cos: cos,\n };\n }\n\n /**\n * @private\n * @param {Array} hull\n * @param {Array} p\n * @param {Bool} topEdge\n */\n __align_hull(hull, p, topEdge) {\n let v = -1;\n let d2;\n for (let i = 0; i < hull.length; ++i) {\n const d = euclidean(hull[i], p);\n if (v === -1) {\n d2 = d;\n v = i;\n } else {\n if (d2 > d) {\n d2 = d;\n v = i;\n }\n }\n }\n\n let v1;\n let v2;\n if (topEdge) {\n v1 = hull[v];\n v2 = hull[(v + 1) % hull.length];\n } else {\n if (v == 0) v = hull.length - 1;\n v1 = hull[v];\n v2 = hull[(v - 1) % hull.length];\n }\n\n const transformation = {\n tx: -hull[v][0],\n ty: -hull[v][1],\n };\n\n if (hull.length >= 2) {\n const { sin, cos } = this.__findAngle(v1, v2);\n transformation.sin = sin;\n transformation.cos = cos;\n } else {\n transformation.sin = 0;\n transformation.cos = 1;\n }\n\n return transformation;\n }\n\n /**\n * @private\n * @param {Array} Point - The point which should get transformed.\n * @param {Object} Transformation - contains the values for translation and rotation.\n */\n __transform([px, py], { tx, ty, sin, cos }) {\n let x = px + tx;\n let y = py + ty;\n let xx = x * cos - y * sin;\n let yy = x * sin + y * cos;\n return [xx, yy];\n }\n\n /**\n * Calls {@link __transform} for each point in Set C\n * @private\n * @param {Array} C - Set of points.\n * @param {Object} t - Transform object.\n * @param {Number} yOffset - value to offset set C.\n */\n __transform_component(C, t, yOffset) {\n const N = C.length;\n for (let i = 0; i < N; ++i) {\n const c = C[i];\n const [cx, cy] = this.__transform(c, t);\n c[0] = cx;\n c[1] = cy + yOffset;\n }\n }\n\n /**\n * @private\n * @param {Array} u - point u\n * @param {Array} v - point v\n * @param {Number} w - edge weight w\n */\n __align_components(u, v, w) {\n const points_u = [...u.__disjoint_set.children];\n const points_v = [...v.__disjoint_set.children];\n\n const hull_u = this.__hull(points_u);\n const hull_v = this.__hull(points_v);\n\n const t_u = this.__align_hull(hull_u, u, false);\n const t_v = this.__align_hull(hull_v, v, true);\n\n this.__transform_component(points_u, t_u, 0);\n this.__transform_component(points_v, t_v, w);\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality 2.\n */\n transform() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n }\n return this.projection;\n }\n\n *generator() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n yield this.projection;\n }\n return this.projection;\n }\n}\n","import { Matrix, linspace } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { PCA } from \"./PCA.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TriMap\n * @extends DR\n */\nexport class TriMap extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TriMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.weight_adj = 500] - scaling factor.\n * @param {Number} [parameters.c = 5] - number of triplets multiplier.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.tol = 1e-8] -\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TriMap}\n * @see {@link https://arxiv.org/pdf/1910.00204v1.pdf}\n * @see {@link https://github.com/eamid/trimap}\n */\n constructor(X, parameters) {\n super(X, { weight_adj: 500, c: 5, d: 2, metric: euclidean, tol: 1e-8, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n *\n * @param {Matrix} [pca = null] - Initial Embedding (if null then PCA gets used).\n * @param {KNN} [knn = null] - KNN Object (if null then BallTree gets used).\n */\n init(pca = null, knn = null) {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric, c } = this._parameters;\n this.n_inliers = 2 * c;\n this.n_outliers = 1 * c;\n this.n_random = 1 * c;\n this.Y = pca || new PCA(X, d).transform();\n this.knn = knn || new BallTree(X.to2dArray, metric);\n const { triplets, weights } = this._generate_triplets(this.n_inliers, this.n_outliers, this.n_random);\n this.triplets = triplets;\n this.weights = weights;\n this.lr = (1000 * N) / triplets.shape[0];\n this.C = Infinity;\n this.vel = new Matrix(N, d, 0);\n this.gain = new Matrix(N, d, 1);\n return this;\n }\n\n /**\n * Generates {@link n_inliers} x {@link n_outliers} x {@link n_random} triplets.\n * @param {Number} n_inliers\n * @param {Number} n_outliers\n * @param {Number} n_random\n */\n _generate_triplets(n_inliers, n_outliers, n_random) {\n const { metric, weight_adj } = this._parameters;\n const X = this.X;\n const N = X.shape[0];\n const knn = this.knn;\n const n_extra = Math.min(n_inliers + 20, N);\n const nbrs = new Matrix(N, n_extra);\n const knn_distances = new Matrix(N, n_extra);\n for (let i = 0; i < N; ++i) {\n knn.search(X.row(i), n_extra + 1)\n .raw_data()\n .filter((d) => d.value != 0)\n .sort((a, b) => a.value - b.value)\n .forEach((d, j) => {\n nbrs.set_entry(i, j, d.element.index);\n knn_distances.set_entry(i, j, d.value);\n });\n }\n // scale parameter\n const sig = new Float64Array(N);\n for (let i = 0; i < N; ++i) {\n sig[i] = Math.max((knn_distances.entry(i, 3) + knn_distances.entry(i, 4) + knn_distances.entry(i, 5) + knn_distances.entry(i, 6)) / 4, 1e-10);\n }\n\n const P = this._find_p(knn_distances, sig, nbrs);\n\n let triplets = this._sample_knn_triplets(P, nbrs, n_inliers, n_outliers);\n let n_triplets = triplets.shape[0];\n const outlier_distances = new Float64Array(n_triplets);\n for (let i = 0; i < n_triplets; ++i) {\n const j = triplets.entry(i, 0);\n const k = triplets.entry(i, 2);\n outlier_distances[i] = metric(X.row(j), X.row(k));\n }\n let weights = this._find_weights(triplets, P, nbrs, outlier_distances, sig);\n\n if (n_random > 0) {\n const { random_triplets, random_weights } = this._sample_random_triplets(X, n_random, sig);\n triplets = triplets.concat(random_triplets, \"vertical\");\n weights = Float64Array.from([...weights, ...random_weights]);\n }\n n_triplets = triplets.shape[0];\n let max_weight = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n if (isNaN(weights[i])) {\n weights[i] = 0;\n }\n if (max_weight < weights[i]) max_weight = weights[i];\n }\n let max_weight_2 = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight;\n weights[i] += 0.0001;\n weights[i] = Math.log(1 + weight_adj * weights[i]);\n if (max_weight_2 < weights[i]) max_weight_2 = weights[i];\n }\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight_2;\n }\n return {\n triplets: triplets,\n weights: weights,\n };\n }\n\n /**\n * Calculates the similarity matrix P\n * @private\n * @param {Matrix} knn_distances - matrix of pairwise knn distances\n * @param {Float64Array} sig - scaling factor for the distances\n * @param {Matrix} nbrs - nearest neighbors\n * @returns {Matrix} pairwise similarity matrix\n */\n _find_p(knn_distances, sig, nbrs) {\n const [N, n_neighbors] = knn_distances.shape;\n return new Matrix(N, n_neighbors, (i, j) => {\n return Math.exp(-(knn_distances.entry(i, j) ** 2 / sig[i] / sig[nbrs.entry(i, j)]));\n });\n }\n\n /**\n * Sample nearest neighbors triplets based on the similarity values given in P.\n * @private\n * @param {Matrix} P - Matrix of pairwise similarities between each point and its neighbors given in matrix nbrs.\n * @param {Matrix} nbrs - Nearest neighbors indices for each point. The similarity values are given in matrix {@link P}. Row i corresponds to the i-th point.\n * @param {Number} n_inliers - Number of inlier points.\n * @param {Number} n_outliers - Number of outlier points.\n *\n */\n _sample_knn_triplets(P, nbrs, n_inliers, n_outliers) {\n const N = nbrs.shape[0];\n const triplets = new Matrix(N * n_inliers * n_outliers, 3);\n for (let i = 0; i < N; ++i) {\n let n_i = i * n_inliers * n_outliers;\n const sort_indices = this.__argsort(P.row(i).map((d) => -d));\n for (let j = 0; j < n_inliers; ++j) {\n let n_j = j * n_outliers;\n const sim = nbrs.entry(i, sort_indices[j]);\n const samples = this._rejection_sample(n_outliers, N, sort_indices.slice(0, j + 1));\n for (let k = 0; k < n_outliers; ++k) {\n const index = n_i + n_j + k;\n const out = samples[k];\n triplets.set_entry(index, 0, i);\n triplets.set_entry(index, 1, sim);\n triplets.set_entry(index, 2, out);\n }\n }\n }\n return triplets;\n }\n\n /**\n * Should do the same as np.argsort()\n * @private\n * @param {Array} A\n */\n __argsort(A) {\n return A.map((d, i) => {\n return { d: d, i: i };\n })\n .sort((a, b) => a.d - b.d)\n .map((d) => d.i);\n }\n\n /**\n * Samples {@link n_samples} integers from a given interval [0, {@link max_int}] while rejection the values that are in the {@link rejects}.\n * @private\n * @param {*} n_samples\n * @param {*} max_int\n * @param {*} rejects\n */\n _rejection_sample(n_samples, max_int, rejects) {\n const randomizer = this._randomizer;\n const interval = linspace(0, max_int - 1).filter((d) => rejects.indexOf(d) < 0);\n return randomizer.choice(interval, Math.min(n_samples, interval.length - 2));\n }\n\n /**\n * Calculates the weights for the sampled nearest neighbors triplets\n * @private\n * @param {Matrix} triplets - Sampled Triplets.\n * @param {Matrix} P - Pairwise similarity matrix.\n * @param {Matrix} nbrs - nearest Neighbors\n * @param {Float64Array} outlier_distances - Matrix of pairwise outlier distances\n * @param {Float64Array} sig - scaling factor for the distances.\n */\n _find_weights(triplets, P, nbrs, outlier_distances, sig) {\n const n_triplets = triplets.shape[0];\n const weights = new Float64Array(n_triplets);\n for (let t = 0; t < n_triplets; ++t) {\n const i = triplets.entry(t, 0);\n const sim = nbrs.row(i).indexOf(triplets.entry(t, 1));\n const p_sim = P.entry(i, sim);\n let p_out = Math.exp(-(outlier_distances[t] ** 2 / (sig[i] * sig[triplets.entry(t, 2)])));\n if (p_out < 1e-20) p_out = 1e-20;\n weights[t] = p_sim / p_out;\n }\n return weights;\n }\n\n /**\n * Sample uniformly ranom triplets\n * @private\n * @param {Matrix} X - Data matrix.\n * @param {Number} n_random - Number of random triplets per point\n * @param {Float64Array} sig - Scaling factor for the distances\n */\n _sample_random_triplets(X, n_random, sig) {\n const metric = this.parameter(\"metric\");\n const randomizer = this._randomizer;\n const N = X.shape[0];\n const random_triplets = new Matrix(N * n_random, 3);\n const random_weights = new Float64Array(N * n_random);\n for (let i = 0; i < N; ++i) {\n const n_i = i * n_random;\n const indices = [...linspace(0, i - 1), ...linspace(i + 1, N - 1)];\n for (let j = 0; j < n_random; ++j) {\n let [sim, out] = randomizer.choice(indices, 2);\n let p_sim = Math.exp(-(metric(X.row(i), X.row(sim)) ** 2 / (sig[i] * sig[sim])));\n if (p_sim < 1e-20) p_sim = 1e-20;\n let p_out = Math.exp(-(metric(X.row(i), X.row(out)) ** 2 / (sig[i] * sig[out])));\n if (p_out < 1e-20) p_out = 1e-20;\n\n if (p_sim < p_out) {\n [sim, out] = [out, sim];\n [p_sim, p_out] = [p_out, p_sim];\n }\n const index = n_i + j;\n random_triplets.set_entry(index, 0, i);\n random_triplets.set_entry(index, 1, sim);\n random_triplets.set_entry(index, 2, out);\n random_weights[index] = p_sim / p_out;\n }\n }\n return {\n random_triplets: random_triplets,\n random_weights: random_weights,\n };\n }\n\n /**\n * Computes the gradient for updating the embedding.\n * @param {Matrix} Y - The embedding\n */\n _grad(Y) {\n const n_inliers = this.n_inliers;\n const n_outliers = this.n_outliers;\n const triplets = this.triplets;\n const weights = this.weights;\n const [N, dim] = Y.shape;\n const n_triplets = triplets.shape[0];\n const grad = new Matrix(N, dim, 0);\n let y_ij = new Float64Array(dim);\n let y_ik = new Float64Array(dim);\n let d_ij = 1;\n let d_ik = 1;\n let n_viol = 0;\n let loss = 0;\n const n_knn_triplets = N * n_inliers * n_outliers;\n\n for (let t = 0; t < n_triplets; ++t) {\n const [i, j, k] = triplets.row(t);\n // update y_ij, y_ik, d_ij, d_ik\n if (t % n_outliers == 0 || t >= n_knn_triplets) {\n d_ij = 1;\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_jd = Y.entry(j, d);\n const Y_kd = Y.entry(k, d);\n y_ij[d] = Y_id - Y_jd;\n y_ik[d] = Y_id - Y_kd;\n d_ij += y_ij[d] ** 2;\n d_ik += y_ik[d] ** 2;\n }\n // update y_ik and d_ik only\n } else {\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_kd = Y.entry(k, d);\n y_ik[d] = Y_id - Y_kd;\n d_ik += y_ik[d] ** 2;\n }\n }\n\n if (d_ij > d_ik) ++n_viol;\n loss += weights[t] / (1 + d_ik / d_ij);\n const w = (weights[t] / (d_ij + d_ik)) ** 2;\n for (let d = 0; d < dim; ++d) {\n const gs = y_ij[d] * d_ik * w;\n const go = y_ik[d] * d_ij * w;\n grad.set_entry(i, d, grad.entry(i, d) + gs - go);\n grad.set_entry(j, d, grad.entry(j, d) - gs);\n grad.set_entry(k, d, grad.entry(k, d) + go);\n }\n }\n return { grad, loss, n_viol };\n }\n\n /**\n *\n * @param {Number} max_iteration\n */\n transform(max_iteration = 400) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n }\n return this.projection;\n }\n\n /**\n * @param {Number} max_iteration\n * @yields {Matrix}\n * @returns {Matrix}\n */\n *generator(max_iteration = 800) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * Does the iteration step.\n * @private\n * @param {Number} iter\n */\n _next(iter) {\n const gamma = iter > 150 ? 0.5 : 0.3;\n const old_C = this.C;\n const vel = this.vel;\n const Y = this.Y.add(vel.mult(gamma));\n const { grad, loss, n_viol } = this._grad(Y);\n this.C = loss;\n this.Y = this._update_embedding(Y, iter, grad);\n this.lr *= old_C > loss + this._parameters.tol ? 1.01 : 0.9;\n return this.Y;\n }\n\n /**\n * Updates the embedding.\n * @private\n * @param {Matrix} Y\n * @param {Number} iter\n * @param {Matrix} grad\n */\n _update_embedding(Y, iter, grad) {\n const [N, dim] = Y.shape;\n const gamma = iter > 150 ? 0.9 : 0.5; // moment parameter\n const min_gain = 0.01;\n const gain = this.gain;\n const vel = this.vel;\n const lr = this.lr;\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const new_gain = Math.sign(vel.entry(i, d)) != Math.sign(grad.entry(i, d)) ? gain.entry(i, d) + 0.2 : Math.max(gain.entry(i, d) * 0.8, min_gain);\n gain.set_entry(i, d, new_gain);\n vel.set_entry(i, d, gamma * vel.entry(i, d) - lr * gain.entry(i, d) * grad.entry(i, d));\n Y.set_entry(i, d, Y.entry(i, d) + vel.entry(i, d));\n }\n }\n return Y;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean, euclidean_squared } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { linspace } from \"../matrix/index.js\";\nimport { powell } from \"../optimization/index.js\";\nimport { DR } from \"./DR.js\";\nimport { max } from \"../util/index.js\";\nimport { KNN } from \"../knn/index.js\";\n\n/**\n * @class\n * @alias UMAP\n * @extends DR\n */\nexport class UMAP extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias UMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.n_neighbors = 15] - size of the local neighborhood.\n * @param {Number} [parameters.local_connectivity = 1] - number of nearest neighbors connected in the local neighborhood.\n * @param {Number} [parameters.min_dist = 1] - controls how tightly points get packed together.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points in the high-dimensional space.\n * @param {Number} [parameters._spread = 1] - The effective scale of embedded points. (In combination with {@link parameters.min_dist})\n * @param {Number} [parameters._set_op_mix_ratio = 1] - Interpolate between union and intersection.\n * @param {Number} [parameters._repulsion_strength = 1] - Weighting applied to negative samples.\n * @param {Number} [parameters._negative_sample_rate = 5] - The number of negative samples per positive sample.\n * @param {Number} [parameters._n_epochs = 350] - The number of training epochs.\n * @param {Number} [parameter._initial_alpha = 1] - The initial learning rate for the optimization.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {UMAP}\n */\n constructor(X, parameters) {\n super(X, { n_neighbors: 15, local_connectivity: 1, min_dist: 1, d: 2, metric: euclidean, seed: 1212, _spread: 1, _set_op_mix_ratio: 1, _repulsion_strength: 1, _negative_sample_rate: 5, _n_epochs: 350, _initial_alpha: 1 }, parameters);\n [this._N, this._D] = this.X.shape;\n /* let n_neighbors = Math.min(this._N - 1, parameters.n_neighbors);\n this.parameter(\"n_neighbors\", n_neighbors);\n this.parameter(\"local_connectivity\", Math.min(this.parameter(\"local_connectivity\"), n_neighbors - 1)); */\n if (this.parameter(\"n_neighbors\") > this._N) {\n throw new Error(`Parameter n_neighbors (=${this.parameter(\"n_neighbors\")}) needs to be smaller than dataset size (N=${this._N})!`);\n }\n if (this.parameter(\"local_connectivity\") > this.parameter(\"n_neighbors\")) {\n throw new Error(`Parameter local_connectivity (=${this.parameter(\"local_connectivity\")}) needs to be smaller than parameter n_neighbors (=${this.parameter(\"n_neighbors\")})`);\n }\n this._iter = 0;\n const randomizer = this._randomizer;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => randomizer.random);\n return this;\n }\n\n /**\n * @private\n * @param {Number} spread\n * @param {Number} min_dist\n * @returns {Array}\n */\n _find_ab_params(spread, min_dist) {\n const curve = (x, a, b) => 1 / (1 + a * Math.pow(x, 2 * b));\n const xv = linspace(0, spread * 3, 300);\n const yv = linspace(0, spread * 3, 300);\n\n for (let i = 0, n = xv.length; i < n; ++i) {\n const xv_i = xv[i];\n yv[i] = xv_i < min_dist ? 1 : Math.exp(-(xv_i - min_dist) / spread);\n }\n\n const err = (p) => {\n const error = linspace(1, 300).map((_, i) => yv[i] - curve(xv[i], p[0], p[1]));\n return Math.sqrt(neumair_sum(error.map((e) => e * e)));\n };\n\n return powell(err, [1, 1]);\n }\n\n /**\n * @private\n * @param {Array} distances\n * @param {Array} sigmas\n * @param {Array} rhos\n * @returns {Array}\n */\n _compute_membership_strengths(distances, sigmas, rhos) {\n for (let i = 0, n = distances.length; i < n; ++i) {\n for (let j = 0, m = distances[i].length; j < m; ++j) {\n const v = distances[i][j].value - rhos[i];\n distances[i][j].value = v > 0 ? Math.exp(-v / sigmas[i]) : 1;\n }\n }\n return distances;\n }\n\n /**\n * @private\n * @param {KNN|BallTree} knn\n * @param {Number} k\n * @returns {Object}\n */\n _smooth_knn_dist(knn, k) {\n const SMOOTH_K_TOLERANCE = 1e-5;\n const MIN_K_DIST_SCALE = 1e-3;\n const n_iter = 64;\n const { local_connectivity, metric } = this._parameters;\n const target = Math.log2(k);\n const rhos = [];\n const sigmas = [];\n const X = this.X;\n const N = X.shape[0];\n //const distances = [...X].map(x_i => knn.search(x_i, k).raw_data().reverse());\n\n const distances = [];\n if (metric === \"precomputed\") {\n for (let i = 0; i < N; ++i) {\n distances.push(knn.search(i, k).reverse());\n }\n } else {\n for (const x_i of X) {\n distances.push(knn.search(x_i, k).raw_data().reverse());\n }\n }\n\n for (let i = 0; i < N; ++i) {\n let lo = 0;\n let hi = Infinity;\n let mid = 1;\n\n const search_result = distances[i];\n const non_zero_dist = search_result.filter((d) => d.value > 0);\n const non_zero_dist_length = non_zero_dist.length;\n if (non_zero_dist_length >= local_connectivity) {\n const index = Math.floor(local_connectivity);\n const interpolation = local_connectivity - index;\n if (index > 0) {\n rhos.push(non_zero_dist[index - 1]);\n if (interpolation > SMOOTH_K_TOLERANCE) {\n rhos[i].value += interpolation * (non_zero_dist[index].value - non_zero_dist[index - 1]);\n }\n } else {\n rhos[i].value = interpolation * non_zero_dist[0].value;\n }\n } else if (non_zero_dist_length > 0) {\n rhos[i] = non_zero_dist[non_zero_dist_length - 1].value;\n }\n for (let x = 0; x < n_iter; ++x) {\n let psum = 0;\n for (let j = 0; j < k; ++j) {\n const d = search_result[j].value - rhos[i];\n psum += d > 0 ? Math.exp(-(d / mid)) : 1;\n }\n if (Math.abs(psum - target) < SMOOTH_K_TOLERANCE) {\n break;\n }\n if (psum > target) {\n [hi, mid] = [mid, (lo + hi) / 2];\n } else {\n if (hi === Infinity) {\n [lo, mid] = [mid, mid * 2];\n } else {\n [lo, mid] = [mid, (lo + hi) / 2];\n }\n }\n }\n sigmas[i] = mid;\n\n const mean_ithd = search_result.reduce((a, b) => a + b.value, 0) / search_result.length;\n //let mean_d = null;\n if (rhos[i] > 0) {\n if (sigmas[i] < MIN_K_DIST_SCALE * mean_ithd) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_ithd;\n }\n } else {\n const mean_d = distances.reduce((acc, res) => acc + res.reduce((a, b) => a + b.value, 0) / res.length);\n if (sigmas[i] > MIN_K_DIST_SCALE * mean_d) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_d;\n }\n }\n }\n return {\n distances: distances,\n sigmas: sigmas,\n rhos: rhos,\n };\n }\n\n /**\n * @private\n * @param {Matrix} X\n * @param {Number} n_neighbors\n * @returns {Matrix}\n */\n _fuzzy_simplicial_set(X, n_neighbors) {\n const N = X.shape[0];\n const { metric, _set_op_mix_ratio } = this._parameters;\n const knn = metric === \"precomputed\" ? new KNN(X, \"precomputed\") : new BallTree(X.to2dArray, metric);\n let { distances, sigmas, rhos } = this._smooth_knn_dist(knn, n_neighbors);\n distances = this._compute_membership_strengths(distances, sigmas, rhos);\n const result = new Matrix(N, N, \"zeros\");\n for (let i = 0; i < N; ++i) {\n const distances_i = distances[i];\n for (let j = 0; j < distances_i.length; ++j) {\n result.set_entry(i, distances_i[j].element.index, distances_i[j].value);\n }\n }\n\n const transposed_result = result.T;\n const prod_matrix = result.mult(transposed_result);\n return result\n .add(transposed_result)\n .sub(prod_matrix)\n .mult(_set_op_mix_ratio)\n .add(prod_matrix.mult(1 - _set_op_mix_ratio));\n }\n\n /**\n * @private\n * @param {Number} n_epochs\n * @returns {Array}\n */\n _make_epochs_per_sample(n_epochs) {\n const weights = this._weights;\n const result = new Float32Array(weights.length).fill(-1);\n const weights_max = max(weights);\n const n_samples = weights.map((w) => n_epochs * (w / weights_max));\n for (let i = 0; i < result.length; ++i) if (n_samples[i] > 0) result[i] = Math.round(n_epochs / n_samples[i]);\n return result;\n }\n\n /**\n * @private\n * @param {Matrix} graph\n * @returns {Object}\n */\n _tocoo(graph) {\n const rows = [];\n const cols = [];\n const data = [];\n const [rows_n, cols_n] = graph.shape;\n for (let row = 0; row < rows_n; ++row) {\n for (let col = 0; col < cols_n; ++col) {\n const entry = graph.entry(row, col);\n if (entry !== 0) {\n rows.push(row);\n cols.push(col);\n data.push(entry);\n }\n }\n }\n return {\n rows: rows,\n cols: cols,\n data: data,\n };\n }\n\n /**\n * Computes all necessary\n * @returns {UMAP}\n */\n init() {\n const { _spread, min_dist, n_neighbors, _n_epochs, _negative_sample_rate } = this._parameters;\n const [a, b] = this._find_ab_params(_spread, min_dist);\n this._a = a;\n this._b = b;\n this._graph = this._fuzzy_simplicial_set(this.X, n_neighbors);\n const { rows, cols, data: weights } = this._tocoo(this._graph);\n this._head = rows;\n this._tail = cols;\n this._weights = weights;\n this._epochs_per_sample = this._make_epochs_per_sample(_n_epochs);\n this._epochs_per_negative_sample = this._epochs_per_sample.map((d) => d * _negative_sample_rate);\n this._epoch_of_next_sample = this._epochs_per_sample.slice();\n this._epoch_of_next_negative_sample = this._epochs_per_negative_sample.slice();\n return this;\n }\n\n graph() {\n this.check_init();\n return { cols: this._head, rows: this._tail, weights: this._weights };\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n transform(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n *generator(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * @private\n * @param {Number} x\n * @returns {Number}\n */\n _clip(x) {\n if (x > 4) return 4;\n if (x < -4) return -4;\n return x;\n }\n\n /**\n * performs the optimization step.\n * @private\n * @param {Matrix} head_embedding\n * @param {Matrix} tail_embedding\n * @param {Matrix} head\n * @param {Matrix} tail\n * @returns {Matrix}\n */\n _optimize_layout(head_embedding, tail_embedding, head, tail) {\n const randomizer = this._randomizer;\n const { _repulsion_strength, d: dim } = this._parameters;\n const { _alpha: alpha, _a: a, _b: b, _epochs_per_sample: epochs_per_sample, _epochs_per_negative_sample: epochs_per_negative_sample, _epoch_of_next_negative_sample: epoch_of_next_negative_sample, _epoch_of_next_sample: epoch_of_next_sample, _clip: clip } = this;\n const tail_length = tail.length;\n\n for (let i = 0, n = epochs_per_sample.length; i < n; ++i) {\n if (epoch_of_next_sample[i] <= this._iter) {\n const j = head[i];\n const k = tail[i];\n const current = head_embedding.row(j);\n const other = tail_embedding.row(k);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (-2 * a * b * Math.pow(dist, b - 1)) / (a * Math.pow(dist, b) + 1);\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(k, d, o);\n }\n epoch_of_next_sample[i] += epochs_per_sample[i];\n const n_neg_samples = (this._iter - epoch_of_next_negative_sample[i]) / epochs_per_negative_sample[i];\n for (let p = 0; p < n_neg_samples; ++p) {\n const k = randomizer.random_int % tail_length;\n const other = tail_embedding.row(tail[k]);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (2 * _repulsion_strength * b) / ((0.01 + dist) * (a * Math.pow(dist, b) + 1));\n } else if (j === k) {\n continue;\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(tail[k], d, o);\n }\n }\n epoch_of_next_negative_sample[i] += n_neg_samples * epochs_per_negative_sample[i];\n }\n }\n return head_embedding;\n }\n\n /**\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const Y = this.Y;\n const { _initial_alpha, _n_epochs } = this._parameters;\n this._alpha = _initial_alpha * (1 - iter / _n_epochs);\n this.Y = this._optimize_layout(Y, Y, this._head, this._tail);\n\n return this.Y;\n }\n}\n","/**\n * Computes the canberra distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias canberra\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} The canberra distance between {@link a} and {@link b}.\n * @see {@link https://en.wikipedia.org/wiki/Canberra_distance}\n */\nexport default function(a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += (Math.abs(a[i] - b[i]) / (Math.abs(a[i]) + Math.abs(b[i])))\n }\n return sum;\n}","/**\n * Computes the chebyshev distance (L) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias chebyshev\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the chebyshev distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let res = [];\n for (let i = 0; i < n; ++i) {\n res.push(Math.abs(a[i] - b[i]));\n }\n return Math.max(...res);\n}\n","/**\n * Computes the cosine distance (not similarity) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias cosine\n * @param {Array} a\n * @param {Array} b\n * @example\n * druid.cosine([1,0],[1,1]) == 0.7853981633974484 == π/4\n * @returns {Number} The cosine distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n let sum_a = 0;\n let sum_b = 0;\n for (let i = 0; i < n; ++i) {\n sum += a[i] * b[i];\n sum_a += a[i] * a[i];\n sum_b += b[i] * b[i];\n }\n return Math.acos(sum / (Math.sqrt(sum_a) * Math.sqrt(sum_b)));\n}\n","/**\n * Computes the hamming distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias hamming\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the hamming distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let disagree = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i];\n const y = b[i];\n disagree += x != y;\n }\n return disagree / n;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the inner product between two arrays of the same length.\n * @memberof module:linear_algebra\n * @alias inner_product\n * @param {Array|Float64Array} a - Array a\n * @param {Array|Float64Array} b - Array b\n * @returns The inner product between {@link a} and {@link b}\n */\nexport default function (a, b) {\n const N = a.length;\n if (N != b.length) {\n throw new Error(\"Array a and b must have the same length!\")\n }\n let sum = 0;\n for (let i = 0; i < N; ++i) {\n sum += a * b;\n }\n return sum;\n}\n","/**\n * Computes the jaccard distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias jaccard\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the jaccard distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_non_zero = 0;\n let num_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_non_zero += x || y;\n num_equal += x && y;\n }\n return (num_non_zero - num_equal) / num_non_zero;\n}\n","/**\n * Numerical stable summation with the Kahan summation algorithm.\n * @memberof module:numerical\n * @alias kahan_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n let y, t;\n\n for (let i = 0; i < n; ++i) {\n y = summands[i] - compensation;\n t = sum + y;\n compensation = t - sum - y;\n sum = t;\n }\n return sum;\n}\n","/**\n * Computes the manhattan distance (l1) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias manhattan\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the manhattan distance between {@link a} and {@link b}.\n */ \nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += Math.abs(a[i] - b[i]);\n }\n return sum;\n}\n","import { norm } from \"./index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Normalizes Vector {@link v}.\n * @memberof module:matrix\n * @alias normalize\n * @param {Array|Float64Array} v - Vector\n * @param {Function} metric \n * @returns {Array|Float64Array} - The normalized vector with length 1.\n */\nexport default function(v, metric = euclidean) {\n const v_norm = norm(v, metric);\n return v.map(value => value / v_norm);\n}","import { Matrix, norm } from \"../matrix/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} with householder transformations.\n * @memberof module:linear_algebra\n * @alias qr_householder\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections}\n * @see {@link http://mlwiki.org/index.php/Householder_Transformation}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, rows, \"I\");\n const R = A.clone();\n\n for (let j = 0; j < cols; ++j) {\n const x = Matrix.from(R.col(j).slice(j));\n const x_norm = norm(x);\n const x0 = x.entry(0, 0);\n const rho = -Math.sign(x0);\n const u1 = x0 - rho * x_norm;\n const u = x.divide(u1).set_entry(0, 0, 1);\n const beta = (-rho * u1) / x_norm;\n\n const u_outer_u = u.outer(u);\n const R_block = R.get_block(j, 0);\n const new_R = R_block.sub(u_outer_u.dot(R_block).mult(beta));\n const Q_block = Q.get_block(0, j);\n const new_Q = Q_block.sub(Q_block.dot(u_outer_u).mult(beta));\n R.set_block(j, 0, new_R);\n Q.set_block(0, j, new_Q);\n }\n return { R, Q };\n}\n","/**\n * Computes the Sokal-Michener distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias sokal_michener\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} the Sokal-Michener distance between {@link a} and {@link b}. \n */\nexport default function(a, b) {\n if (a.length != b.length) return undefined\n const n = a.length;\n let num_not_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_not_equal += x != y;\n }\n return (2 * num_not_equal) / (n + num_not_equal);\n}","/**\n * Computes the yule distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias yule\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the yule distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_true_true = 0;\n let num_true_false = 0;\n let num_false_true = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_true_true += x && y;\n num_true_false += x && !y;\n num_false_true += !x && x;\n }\n const num_false_false = n - num_true_true - num_true_false - num_false_true;\n return num_true_false == 0 || num_false_true == 0 ? 0 : (2 * num_true_false * num_false_true) / (num_true_true * num_false_false + num_true_false * num_false_true);\n}\n"],"names":["a","b","Math","sqrt","euclidean_squared","summands","n","length","sum","compensation","i","summand","t","abs","s","Array","x","y","neumair_sum","A","k","metric","euclidean","rows","shape","D","distance_matrix","nN","row","from","map","distance","col","j","sort","slice","Matrix","A_i","dist","set_entry","start","end","number","max","round","result","v","vector","cols","Error","Float64Array","Q","R","q","q_dot_v","q_","v_","v_norm","norm","seed","max_iterations","qr","qr_gramschmidt","tol","randomizer","Randomizer","random","oldQ","clone","QR","dot","values","eigenvalues","diag","eigenvectors","transpose","to2dArray","constructor","value","this","_rows","_cols","_data","static","type","isArray","m","_","data","subarray","iterate_rows","Symbol","iterator","set_row","offset","result_col","entry","T","inverse","B","h","i_max","max_val","Infinity","val","h_val","i_val","f","B_row_row","B_i_j","join","I","B_i","C","e","outer","l","concat","rows_A","cols_A","rows_B","cols_B","X","set_block","offset_row","offset_col","get_block","start_row","start_col","end_row","end_col","new_row","new_col","gather","row_indices","col_indices","N","row_index","col_index","_apply_array","_apply_rowwise_array","_apply_colwise_array","_apply","value_rows","value_cols","mult","divide","add","sub","push","asArray","min_row_col","min","mean","meanRows","meanCols","b_i","r","d","z","alpha","r_next","beta","L","U","LU","L_diag","U_diag","det","M","MT","MtM","MMt","V","Sigma","simultaneous_poweriteration","sigma","_seed","_N","_M","_MATRIX_A","_UPPER_MASK","_LOWER_MASK","_mt","_mti","Date","getTime","mt","mti","random_int","mag01","kk","N_M","M_N","choice","sample","index_list","linspace","random_index","splice","undefined","Heap","elements","accessor","comparator","heapify","_accessor","_container","_comparator","heap","container","element","floor","_heapify_down","_swap","index_a","index_b","_heapify_up","index","parentIndex","node","start_index","left","right","pop","item","first","iterate","toArray","raw_data","empty","DisjointSet","_list","Set","make_set","list","has","__disjoint_set","parent","children","size","find","union","node_x","node_y","forEach","BallTree","_Node","pivot","child1","child2","radius","_Leaf","points","_metric","_root","_construct","c","_greatest_spread","sorted_elements","p_index","p","spread","reduce","acc","current","search","_search","KNN","_elements","_D","distances","H","nearest_element_index","nearest_dist","Number","isInteger","res","DR","default_parameters","parameters","_parameters","Object","assign","seal","_type","_randomizer","_is_initialized","parameter","name","hasOwnProperty","para","transform","check_init","projection","generator","init","Y","async","args","PCA","super","eig_args","principal_components","means","X_cent","MDS","ai_","a_j","a__","_d_X","stress","d_X","d_Y","top_sum","bottom_sum","pow","x0","max_iter","pfx","fx","convergence","fxi","dx","Cluster","id","centroid","depth","_calculate_centroid","l_size","r_size","l_centroid","r_centroid","new_centroid","isLeaf","leaves","descendants","left_descendants","right_descendants","KMedoids","matrix","K","_matrix","_A","_K","_max_iter","log10","_distance_matrix","_clusters","fill","_cluster_medoids","_get_random_medoids","get_clusters","x_j","_nearest_medoid","index_nearest","medoids","finish","_iteration","cache","x_o","o","DeltaTD","xs","findIndex","d_j","distance_nearest","deltaTD","d_oj","_get_distance","d_n","distance_second","d_s","filter","x_i","d_ij","nearest","second","x_m","m1","m2","index_second","cluster_medoids","indices","ceil","TD","TD0","S","S_j","S_o","delta","_choose_distant_objects","a_index","b_index","max_dist","d_ai","d_bi","_col","old_dist","d_ab","y_i","linkage","_id","_linkage","root","do","clusters","_traverse","_n","d_min","_d_min","c_size","_c_size","Uint16Array","p_max","c1","D_i_min","c2","c1_cluster","c2_cluster","c1_cluster_indices","c2_cluster_indices","new_cluster","unshift","D_c1_j","D_c2_j","neighbors","kNearestNeighbors","G","other","_cluster_centroids","_get_random_centroids","_furthest_point","candidates","Ad","cluster_centroids","random_point","init_points","sample_size","indexOf","furthest_point","clusters_changed","Ai","min_dist","min_cluster","_compute_centroid","cluster_counter","ci","iteration_result","labels","unique_labels","label_id","count","X_mean","V_mean","label","v_mean","S_b","S_w","row_v","k_nearest_neighbors","O","W","nN_row","Z","C_trace","w","solve_CG","IW","control_points","DR_parameters","nc","c_i","Y_C","XA","knn","_b","AT","ATA","ATb","I_i","X_i","g","G_i_t","W_i","epsilon","min_points","_epsilon","_min_points","_ordered_list","_DB","ordered_list","DB","cluster_index","_cluster_index","reachability_distance","processed","_get_neighbors","_core_distance","seeds","_update","_expand_cluster","core_distance","new_reachability_distance","cluster","outliers","get_cluster_affirmation","magic","init_DR","init_parameters","includes","_step","MAGIC","e1","e2","Yi","Yj","dY","dX","dq","dr","perplexity","_iter","Htarget","log","Delta","druid","P","_ystep","_gains","prow","betamin","betamax","done","num","psum","pj","exp","Hhere","Pout","N2","_P","iterations","next","iter","ystep","gains","dim","pmul","Qu","qsum","dsum","dhere","qu","grad","premult","ymean","gid","sid","gainid","newgain","sign","newsid","__lazy_distance_matrix","D_ij","_make_minimum_spanning_tree","disjoint_set","F","E","u","set_u","set_v","_Emst","__hull_cross","ax","ay","bx","by","sx","sy","__hull","x1","y1","x2","y2","lower","upper","__findAngle","p1x","p1y","p2x","p2y","sin","cos","vec","__align_hull","hull","topEdge","d2","v1","v2","transformation","tx","ty","__transform","px","py","__transform_component","yOffset","cx","cy","__align_components","points_u","points_v","hull_u","hull_v","t_u","t_v","Emst","components","component_u","component_v","weight_adj","pca","n_inliers","n_outliers","n_random","triplets","weights","_generate_triplets","lr","vel","gain","n_extra","nbrs","knn_distances","sig","_find_p","_sample_knn_triplets","n_triplets","outlier_distances","_find_weights","random_triplets","random_weights","_sample_random_triplets","max_weight","isNaN","max_weight_2","n_neighbors","n_i","sort_indices","__argsort","n_j","sim","samples","_rejection_sample","out","n_samples","max_int","rejects","interval","p_sim","p_out","_grad","y_ij","y_ik","d_ik","n_viol","loss","n_knn_triplets","Y_id","Y_jd","Y_kd","gs","go","max_iteration","_next","gamma","old_C","_update_embedding","new_gain","local_connectivity","_spread","_set_op_mix_ratio","_repulsion_strength","_negative_sample_rate","_n_epochs","_initial_alpha","_find_ab_params","xv","yv","xv_i","powell","error","_compute_membership_strengths","sigmas","rhos","_smooth_knn_dist","SMOOTH_K_TOLERANCE","MIN_K_DIST_SCALE","target","log2","reverse","lo","hi","mid","search_result","non_zero_dist","non_zero_dist_length","interpolation","mean_ithd","mean_d","_fuzzy_simplicial_set","distances_i","transposed_result","prod_matrix","_make_epochs_per_sample","n_epochs","_weights","Float32Array","weights_max","_tocoo","graph","rows_n","cols_n","_a","_graph","_head","_tail","_epochs_per_sample","_epochs_per_negative_sample","_epoch_of_next_sample","_epoch_of_next_negative_sample","_clip","_optimize_layout","head_embedding","tail_embedding","head","tail","_alpha","epochs_per_sample","epochs_per_negative_sample","epoch_of_next_negative_sample","epoch_of_next_sample","clip","tail_length","grad_coeff","grad_d","n_neg_samples","sum_a","sum_b","acos","disagree","num_non_zero","num_equal","x_norm","rho","u1","u_outer_u","R_block","new_R","Q_block","new_Q","num_not_equal","num_true_true","num_true_false","num_false_true"],"mappings":";sPASe,WAAUA,EAAGC,GACxB,OAAOC,KAAKC,KAAKC,EAAkBJ,EAAGC,ICF3B,WAAUI,GACrB,IAAIC,EAAID,EAASE,OACbC,EAAM,EACNC,EAAe,EAEnB,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,IAAKI,EAAG,CACxB,IAAIC,EAAUN,EAASK,GACnBE,EAAIJ,EAAMG,EACVT,KAAKW,IAAIL,IAAQN,KAAKW,IAAIF,GAC1BF,GAAgBD,EAAMI,EAAID,EAE1BF,GAAgBE,EAAUC,EAAIJ,EAElCA,EAAMI,EAEV,OAAOJ,EAAMC,ECdF,WAAUT,EAAGC,GACxB,GAAID,EAAEO,QAAUN,EAAEM,OAAQ,OAC1B,IAAID,EAAIN,EAAEO,OACNO,EAAI,IAAIC,MAAMT,GAClB,IAAK,IAAII,EAAI,EAAGA,EAAIJ,IAAKI,EAAG,CACxB,IAAIM,EAAIhB,EAAEU,GACNO,EAAIhB,EAAES,GACVI,EAAEJ,IAAMM,EAAIC,IAAMD,EAAIC,GAE1B,OAAOC,EAAYJ,GCNR,WAAUK,EAAGC,EAAGC,EAASC,GACpC,MAAMC,EAAOJ,EAAEK,MAAM,GACrB,IAAIC,EAAc,eAAVJ,EAA0BF,EAAIO,EAAgBP,EAAGE,GACrDM,EAAK,IAAIZ,MAAMQ,GACnB,IAAK,IAAIK,EAAM,EAAGA,EAAML,IAAQK,EAC5BD,EAAGC,GAAOb,MAAMc,KAAKJ,EAAEG,IAAIA,IACtBE,KAAI,CAACC,EAAUC,KACL,CACHtB,EAAGkB,EACHK,EAAGD,EACHD,SAAUA,MAGjBG,MAAK,CAAClC,EAAGC,IAAMD,EAAE+B,SAAW9B,EAAE8B,WAC9BI,MAAM,EAAGf,EA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1F,EAAGytB,GAEtB,MAAO,CAAEtsB,EAAAA,EAAGD,EAAAA,qDCzBD,SAASnD,EAAGC,GACvB,GAAID,EAAEO,QAAUN,EAAEM,OAAQ,OAC1B,MAAMD,EAAIN,EAAEO,OACZ,IAAIovB,EAAgB,EACpB,IAAK,IAAIjvB,EAAI,EAAGA,EAAIJ,IAAKI,EAAG,CAGxBivB,GAFkB,GAAR3vB,EAAEU,KACM,GAART,EAAES,IAGhB,OAAQ,EAAIivB,GAAkBrvB,EAAIqvB,6BCTvB,SAAU3vB,EAAGC,GACxB,GAAID,EAAEO,QAAUN,EAAEM,OAAQ,OAC1B,MAAMD,EAAIN,EAAEO,OACZ,IAAIqvB,EAAgB,EAChBC,EAAiB,EACjBC,EAAiB,EACrB,IAAK,IAAIpvB,EAAI,EAAGA,EAAIJ,IAAKI,EAAG,CACxB,MAAMM,EAAY,GAARhB,EAAEU,GACNO,EAAY,GAARhB,EAAES,GACZkvB,GAAiB5uB,GAAKC,EACtB4uB,GAAkB7uB,IAAMC,EACxB6uB,IAAmB9uB,GAAKA,EAG5B,OAAyB,GAAlB6uB,GAAyC,GAAlBC,EAAsB,EAAK,EAAID,EAAiBC,GAAmBF,GADzEtvB,EAAIsvB,EAAgBC,EAAiBC,GACsED,EAAiBC"} \ No newline at end of file +{"version":3,"file":"druid.min.js","sources":["../metrics/euclidean.js","../numerical/neumair_sum.js","../metrics/euclidean_squared.js","../matrix/k_nearest_neighbors.js","../matrix/distance_matrix.js","../matrix/linspace.js","../matrix/norm.js","../linear_algebra/qr.js","../linear_algebra/simultaneous_poweriteration.js","../matrix/Matrix.js","../util/randomizer.js","../util/max.js","../util/min.js","../datastructure/Heap.js","../datastructure/DisjointSet.js","../knn/BallTree.js","../knn/KNN.js","../dimred/DR.js","../dimred/PCA.js","../dimred/MDS.js","../optimization/powell.js","../clustering/Hierarchical_Clustering.js","../clustering/KMedoids.js","../dimred/FASTMAP.js","../dimred/ISOMAP.js","../clustering/KMeans.js","../dimred/LDA.js","../dimred/LLE.js","../dimred/LSP.js","../dimred/LTSA.js","../clustering/OPTICS.js","../dimred/SAMMON.js","../dimred/TSNE.js","../dimred/TopoMap.js","../dimred/TriMap.js","../dimred/UMAP.js","../metrics/canberra.js","../metrics/chebyshev.js","../metrics/cosine.js","../metrics/hamming.js","../linear_algebra/inner_product.js","../metrics/jaccard.js","../numerical/kahan_sum.js","../metrics/manhattan.js","../matrix/normalize.js","../linear_algebra/qr_householder.js","../metrics/sokal_michener.js","../metrics/yule.js"],"sourcesContent":["import { euclidean_squared } from \"../metrics/index.js\";\n/**\n * Computes the euclidean distance (l2) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n return Math.sqrt(euclidean_squared(a, b));\n}\n","/**\n * Numerical stable summation with the Neumair summation algorithm.\n * @memberof module:numerical\n * @alias neumair_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm#Further_enhancements}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n\n for (let i = 0; i < n; ++i) {\n let summand = summands[i];\n let t = sum + summand;\n if (Math.abs(sum) >= Math.abs(summand)) {\n compensation += sum - t + summand;\n } else {\n compensation += summand - t + sum;\n }\n sum = t;\n }\n return sum + compensation;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n/**\n * Computes the squared euclidean distance (l22) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias euclidean_squared\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the squared euclidean distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let s = new Array(n);\n for (let i = 0; i < n; ++i) {\n let x = a[i];\n let y = b[i];\n s[i] = (x - y) * (x - y);\n }\n return neumair_sum(s);\n}\n","import { distance_matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Computes the k-nearest neighbors of each row of {@link A}.\n * @memberof module:matrix\n * @alias k_nearest_neigbhors\n * @param {Matrix} A - Either the data matrix, or a distance matrix.\n * @param {Number} k - The number of neighbors to compute.\n * @param {Function|\"precomputed\"} [metric=euclidean]\n * @returns {Array} -\n */\nexport default function (A, k, metric = euclidean) {\n const rows = A.shape[0];\n let D = metric == \"precomputed\" ? A : distance_matrix(A, metric);\n let nN = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n nN[row] = Array.from(D.row(row))\n .map((distance, col) => {\n return {\n i: row,\n j: col,\n distance: distance,\n };\n })\n .sort((a, b) => a.distance - b.distance)\n .slice(1, k + 1);\n }\n return nN;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"./index.js\";\n\n/**\n * Computes the distance matrix of datamatrix {@link A}.\n * @memberof module:matrix\n * @alias distance_matrix\n * @param {Matrix} A - Matrix.\n * @param {Function} [metric=euclidean] - The diistance metric.\n * @returns {Matrix} D - The distance matrix of {@link A}.\n */\nexport default function (A, metric = euclidean) {\n let n = A.shape[0];\n const D = new Matrix(n, n);\n for (let i = 0; i < n; ++i) {\n const A_i = A.row(i);\n for (let j = i + 1; j < n; ++j) {\n const dist = metric(A_i, A.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n }\n }\n return D;\n}\n","/**\n * Creates an Array containing {@link number} numbers from {@link start} to {@link end}.\n * If {@link number} = null.\n * @memberof module:matrix\n * @alias linspace\n * @param {Number} start - Start value.\n * @param {Number} end - End value.\n * @param {Number} [number = null] - Number of number between {@link start} and {@link end}.\n * @returns {Array} - An array with {@link number} entries, beginning at {@link start} ending at {@link end}.\n */\nexport default function (start, end, number = null) {\n if (!number) {\n number = Math.max(Math.round(end - start) + 1, 1);\n }\n if (number < 2) {\n return number === 1 ? [start] : [];\n }\n let result = new Array(number);\n number -= 1;\n for (let i = number; i >= 0; --i) {\n result[i] = (i * end + (number - i) * start) / number;\n }\n return result;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n//import { neumair_sum } from \"../numerical/index\";\n\n/**\n * Computes the norm of a vector, by computing its distance to **0**.\n * @memberof module:matrix\n * @alias norm\n * @param {Matrix|Array|Float64Array} v - Vector. \n * @param {Function} [metric = euclidean] - Which metric should be used to compute the norm.\n * @returns {Number} - The norm of {@link v}.\n */\nexport default function (v, metric = euclidean) {\n let vector = null;\n if (v instanceof Matrix) {\n let [rows, cols] = v.shape;\n if (rows === 1) vector = v.row(0);\n else if (cols === 1) vector = v.col(0);\n else throw new Error(\"Matrix must be 1d!\");\n } else {\n vector = v;\n }\n const n = vector.length;\n const zeros = Float64Array.from({ length: n }, () => 0);\n return metric(vector, zeros);\n}\n","import { Matrix, norm } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} using Gram-Schmidt process.\n * @memberof module:linear_algebra\n * @alias qr\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_the_Gram%E2%80%93Schmidt_process}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, cols, \"identity\");\n const R = new Matrix(cols, cols, 0);\n\n for (let j = 0; j < cols; ++j) {\n let v = A.col(j);\n for (let i = 0; i < j; ++i) {\n const q = Q.col(i);\n const q_dot_v = neumair_sum(q.map((q_, k) => q_ * v[k]));\n R.set_entry(i, j, q_dot_v);\n v = v.map((v_, k) => v_ - q_dot_v * q[k]);\n }\n const v_norm = norm(v, euclidean);\n for (let k = 0; k < rows; ++k) {\n Q.set_entry(k, j, v[k] / v_norm);\n }\n R.set_entry(j, j, v_norm);\n }\n return { R, Q };\n}\n","import { qr as qr_gramschmidt } from \"./index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { euclidean_squared } from \"../metrics/index.js\";\n\n/**\n * Computes the {@link k} biggest Eigenvectors and Eigenvalues from Matrix {@link A} with the QR-Algorithm.\n * @memberof module:linear_algebra\n * @alias simultaneous_poweriteration\n * @param {Matrix} A - The Matrix\n * @param {Number} k - The number of eigenvectors and eigenvalues to compute.\n * @param {Object} parameters - Object containing parameterization of the simultanious poweriteration method.\n * @param {Number} [parameters.max_iterations=100] - The number of maxiumum iterations the algorithm should run.\n * @param {Number|Randomizer} [parameters.seed=1212] - The seed value or a randomizer used in the algorithm.\n * @param {Function} [parameters.qr=qr_gramschmidt] - The QR technique to use.\n * @param {Number} [parameters.tol=1e-8] - Allowed error for stopping criteria\n * @returns {{eigenvalues: Array, eigenvectors: Array}} - The {@link k} biggest eigenvectors and eigenvalues of Matrix {@link A}.\n */\nexport default function (A, k = 2, {seed = 1212, max_iterations = 100, qr = qr_gramschmidt, tol = 1e-8} = {}) {\n const randomizer = seed instanceof Randomizer ? seed : new Randomizer(seed);\n if (!(A instanceof Matrix)) A = Matrix.from(A);\n const n = A.shape[0];\n let { Q, R } = qr(new Matrix(n, k, () => (randomizer.random - .5) * 2));\n while (max_iterations--) {\n const oldQ = Q.clone();\n const Z = A.dot(Q);\n const QR = qr(Z);\n Q = QR.Q;\n R = QR.R;\n const error = euclidean_squared(Q.values, oldQ.values);\n if (error < tol) {\n break;\n }\n }\n\n const eigenvalues = R.diag;\n const eigenvectors = Q.transpose().to2dArray;\n return { eigenvalues, eigenvectors };\n}\n","import { neumair_sum } from \"../numerical/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n/**\n * @class\n * @alias Matrix\n * @requires module:numerical/neumair_sum\n */\nexport class Matrix {\n /**\n * creates a new Matrix. Entries are stored in a Float64Array.\n * @constructor\n * @memberof module:matrix\n * @alias Matrix\n * @param {number} rows - The amount of rows of the matrix.\n * @param {number} cols - The amount of columns of the matrix.\n * @param {(function|string|number)} value=0 - Can be a function with row and col as parameters, a number, or \"zeros\", \"identity\" or \"I\", or \"center\".\n * - **function**: for each entry the function gets called with the parameters for the actual row and column.\n * - **string**: allowed are\n * - \"zero\", creates a zero matrix.\n * - \"identity\" or \"I\", creates an identity matrix.\n * - \"center\", creates an center matrix.\n * - **number**: create a matrix filled with the given value.\n * @example\n *\n * let A = new Matrix(10, 10, () => Math.random()); //creates a 10 times 10 random matrix.\n * let B = new Matrix(3, 3, \"I\"); // creates a 3 times 3 identity matrix.\n * @returns {Matrix} returns a {@link rows} times {@link cols} Matrix filled with {@link value}.\n */\n constructor(rows = null, cols = null, value = null) {\n this._rows = rows;\n this._cols = cols;\n this._data = null;\n if (rows && cols) {\n if (!value) {\n this._data = new Float64Array(rows * cols);\n return this;\n }\n if (typeof value === \"function\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n if (typeof value === \"string\") {\n if (value === \"zeros\") {\n return new Matrix(rows, cols, 0);\n }\n if (value === \"identity\" || value === \"I\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n this._data[row * cols + row] = 1;\n }\n return this;\n }\n if (value === \"center\" && rows == cols) {\n this._data = new Float64Array(rows * cols);\n value = (i, j) => (i === j ? 1 : 0) - 1 / rows;\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n }\n if (typeof value === \"number\") {\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value;\n }\n }\n return this;\n }\n }\n return this;\n }\n\n /**\n * Creates a Matrix out of {@link A}.\n * @param {(Matrix|Array|Float64Array|number)} A - The matrix, array, or number, which should converted to a Matrix.\n * @param {\"row\"|\"col\"|\"diag\"} [type = \"row\"] - If {@link A} is a Array or Float64Array, then type defines if it is a row- or a column vector.\n * @returns {Matrix}\n *\n * @example\n * let A = Matrix.from([[1, 0], [0, 1]]); //creates a two by two identity matrix.\n * let S = Matrix.from([1, 2, 3], \"diag\"); // creates a 3 by 3 matrix with 1, 2, 3 on its diagonal. [[1, 0, 0], [0, 2, 0], [0, 0, 3]]\n */\n static from(A, type = \"row\") {\n if (A instanceof Matrix) {\n return A.clone();\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let m = A.length;\n if (m === 0) throw new Error(\"Array is empty\");\n // 1d\n if (!Array.isArray(A[0]) && !(A[0] instanceof Float64Array)) {\n if (type === \"row\") {\n return new Matrix(1, m, (_, j) => A[j]);\n } else if (type === \"col\") {\n return new Matrix(m, 1, (i) => A[i]);\n } else if (type === \"diag\") {\n return new Matrix(m, m, (i, j) => (i == j ? A[i] : 0));\n } else {\n throw new Error(\"1d array has NaN entries\");\n }\n // 2d\n } else if (Array.isArray(A[0]) || A[0] instanceof Float64Array) {\n let n = A[0].length;\n for (let row = 0; row < m; ++row) {\n if (A[row].length !== n) {\n throw new Error(\"various array lengths\");\n }\n }\n return new Matrix(m, n, (i, j) => A[i][j]);\n }\n } else if (typeof A === \"number\") {\n return new Matrix(1, 1, A);\n } else {\n throw new Error(\"error\");\n }\n }\n\n /**\n * Returns the {@link row}th row from the Matrix.\n * @param {Number} row\n * @returns {Float64Array}\n */\n row(row) {\n const data = this.values;\n const cols = this._cols;\n return data.subarray(row * cols, (row + 1) * cols);\n }\n\n /**\n * Returns an generator yielding each row of the Matrix.\n * @yields {Float64Array}\n */\n *iterate_rows() {\n const cols = this._cols;\n const rows = this._rows;\n const data = this.values;\n for (let row = 0; row < rows; ++row) {\n yield data.subarray(row * cols, (row + 1) * cols);\n }\n }\n\n /**\n * Makes a {@link Matrix} object an iterable object.\n * @yields {Float64Array}\n */\n *[Symbol.iterator]() {\n for (const row of this.iterate_rows()) {\n yield row;\n }\n }\n\n /**\n * Sets the entries of {@link row}th row from the Matrix to the entries from {@link values}.\n * @param {int} row\n * @param {Array} values\n * @returns {Matrix}\n */\n set_row(row, values) {\n let cols = this._cols;\n if (Array.isArray(values) && values.length === cols) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values[col];\n }\n } else if (values instanceof Matrix && values.shape[1] === cols && values.shape[0] === 1) {\n let offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n this.values[offset + col] = values._data[col];\n }\n }\n return this;\n }\n\n /**\n * Returns the {@link col}th column from the Matrix.\n * @param {int} col\n * @returns {Array}\n */\n col(col) {\n let result_col = new Float64Array(this._rows);\n for (let row = 0; row < this._rows; ++row) {\n result_col[row] = this.values[row * this._cols + col];\n }\n return result_col;\n }\n\n /**\n * Returns the {@link col}th entry from the {@link row}th row of the Matrix.\n * @param {int} row\n * @param {int} col\n * @returns {float64}\n */\n entry(row, col) {\n return this.values[row * this._cols + col];\n }\n\n /**\n * Sets the {@link col}th entry from the {@link row}th row of the Matrix to the given {@link value}.\n * @param {int} row\n * @param {int} col\n * @param {float64} value\n * @returns {Matrix}\n */\n set_entry(row, col, value) {\n this.values[row * this._cols + col] = value;\n return this;\n }\n\n /**\n * Returns a new transposed Matrix.\n * @returns {Matrix}\n */\n transpose() {\n let B = new Matrix(this._cols, this._rows, (row, col) => this.entry(col, row));\n return B;\n }\n\n /**\n * Returns a new transposed Matrix. Short-form of {@function transpose}.\n * @returns {Matrix}\n */\n get T() {\n return this.transpose();\n }\n\n /**\n * Returns the inverse of the Matrix.\n * @returns {Matrix}\n */\n inverse() {\n const rows = this._rows;\n const cols = this._cols;\n let B = new Matrix(rows, 2 * cols, (i, j) => {\n if (j >= cols) {\n return i === j - cols ? 1 : 0;\n } else {\n return this.entry(i, j);\n }\n });\n let h = 0;\n let k = 0;\n while (h < rows && k < cols) {\n var i_max = 0;\n let max_val = -Infinity;\n for (let i = h; i < rows; ++i) {\n let val = Math.abs(B.entry(i, k));\n if (max_val < val) {\n i_max = i;\n max_val = val;\n }\n }\n if (B.entry(i_max, k) == 0) {\n k++;\n } else {\n // swap rows\n for (let j = 0; j < 2 * cols; ++j) {\n let h_val = B.entry(h, j);\n let i_val = B.entry(i_max, j);\n B.set_entry(h, j, h_val);\n B.set_entry(i_max, j, i_val);\n }\n for (let i = h + 1; i < rows; ++i) {\n let f = B.entry(i, k) / B.entry(h, k);\n B.set_entry(i, k, 0);\n for (let j = k + 1; j < 2 * cols; ++j) {\n B.set_entry(i, j, B.entry(i, j) - B.entry(h, j) * f);\n }\n }\n h++;\n k++;\n }\n }\n\n for (let row = 0; row < rows; ++row) {\n let f = B.entry(row, row);\n for (let col = row; col < 2 * cols; ++col) {\n B.set_entry(row, col, B.entry(row, col) / f);\n }\n }\n\n for (let row = rows - 1; row >= 0; --row) {\n let B_row_row = B.entry(row, row);\n for (let i = 0; i < row; i++) {\n let B_i_row = B.entry(i, row);\n let f = B_i_row / B_row_row;\n for (let j = i; j < 2 * cols; ++j) {\n let B_i_j = B.entry(i, j);\n let B_row_j = B.entry(row, j);\n B_i_j = B_i_j - B_row_j * f;\n B.set_entry(i, j, B_i_j);\n }\n }\n }\n\n return new Matrix(rows, cols, (i, j) => B.entry(i, j + cols));\n }\n\n /**\n * Returns the dot product. If {@link B} is an Array or Float64Array then an Array gets returned. If {@link B} is a Matrix then a Matrix gets returned.\n * @param {(Matrix|Array|Float64Array)} B the right side\n * @returns {(Matrix|Array)}\n */\n dot(B) {\n if (B instanceof Matrix) {\n let A = this;\n if (A.shape[1] !== B.shape[0]) {\n throw new Error(`A.dot(B): A is a ${A.shape.join(\" ⨯ \")}-Matrix, B is a ${B.shape.join(\" ⨯ \")}-Matrix: \n A has ${A.shape[1]} cols and B ${B.shape[0]} rows. \n Must be equal!`);\n }\n let I = A.shape[1];\n let C = new Matrix(A.shape[0], B.shape[1], (row, col) => {\n const A_i = A.row(row);\n const B_i = B.col(col);\n let sum = 0;\n for (let i = 0; i < I; ++i) {\n sum += A_i[i] * B_i[i];\n }\n return sum;\n });\n return C;\n } else if (Array.isArray(B) || B instanceof Float64Array) {\n let rows = this._rows;\n if (B.length !== rows) {\n throw new Error(`A.dot(B): A has ${rows} cols and B has ${B.length} rows. Must be equal!`);\n }\n let C = new Array(rows);\n for (let row = 0; row < rows; ++row) {\n C[row] = neumair_sum(this.row(row).map((e) => e * B[row]));\n }\n return C;\n } else {\n throw new Error(`B must be Matrix or Array`);\n }\n }\n\n /**\n * Computes the outer product from {@link this} and {@link B}.\n * @param {Matrix} B\n * @returns {Matrix}\n */\n outer(B) {\n let A = this;\n let l = A._data.length;\n let r = B._data.length;\n if (l != r) return undefined;\n let C = new Matrix();\n C.shape = [\n l,\n l,\n (i, j) => {\n if (i <= j) {\n return A._data[i] * B._data[j];\n } else {\n return C.entry(j, i);\n }\n },\n ];\n return C;\n }\n\n /**\n * Appends matrix {@link B} to the matrix.\n * @param {Matrix} B - matrix to append.\n * @param {\"horizontal\"|\"vertical\"|\"diag\"} [type = \"horizontal\"] - type of concatenation.\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 1], [1, 1]]); // 2 by 2 matrix filled with ones.\n * let B = Matrix.from([[2, 2], [2, 2]]); // 2 by 2 matrix filled with twos.\n *\n * A.concat(B, \"horizontal\"); // 2 by 4 matrix. [[1, 1, 2, 2], [1, 1, 2, 2]]\n * A.concat(B, \"vertical\"); // 4 by 2 matrix. [[1, 1], [1, 1], [2, 2], [2, 2]]\n * A.concat(B, \"diag\"); // 4 by 4 matrix. [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 2, 2], [0, 0, 2, 2]]\n */\n concat(B, type = \"horizontal\") {\n const A = this;\n const [rows_A, cols_A] = A.shape;\n const [rows_B, cols_B] = B.shape;\n if (type == \"horizontal\") {\n if (rows_A != rows_B) {\n throw new Error(`A.concat(B, \"horizontal\"): A and B need same number of rows, A has ${rows_A} rows, B has ${rows_B} rows.`);\n }\n const X = new Matrix(rows_A, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(0, cols_A, B);\n return X;\n } else if (type == \"vertical\") {\n if (cols_A != cols_B) {\n throw new Error(`A.concat(B, \"vertical\"): A and B need same number of columns, A has ${cols_A} columns, B has ${cols_B} columns.`);\n }\n const X = new Matrix(rows_A + rows_B, cols_A, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, 0, B);\n return X;\n } else if (type == \"diag\") {\n const X = new Matrix(rows_A + rows_B, cols_A + cols_B, \"zeros\");\n X.set_block(0, 0, A);\n X.set_block(rows_A, cols_A, B);\n return X;\n } else {\n throw new Error(`type must be \"horizontal\" or \"vertical\", but type is ${type}!`);\n }\n }\n\n /**\n * Writes the entries of B in A at an offset position given by {@link offset_row} and {@link offset_col}.\n * @param {int} offset_row\n * @param {int} offset_col\n * @param {Matrix} B\n * @returns {Matrix}\n */\n set_block(offset_row, offset_col, B) {\n let [rows, cols] = B.shape;\n for (let row = 0; row < rows; ++row) {\n if (row > this._rows) {\n continue;\n }\n for (let col = 0; col < cols; ++col) {\n if (col > this._cols) {\n continue;\n }\n this.set_entry(row + offset_row, col + offset_col, B.entry(row, col));\n }\n }\n return this;\n }\n\n /**\n * Extracts the entries from the {@link start_row}th row to the {@link end_row}th row, the {@link start_col}th column to the {@link end_col}th column of the matrix.\n * If {@link end_row} or {@link end_col} is empty, the respective value is set to {@link this.rows} or {@link this.cols}.\n * @param {Number} start_row\n * @param {Number} start_col\n * @param {Number} [end_row = null]\n * @param {Number} [end_col = null]\n * @returns {Matrix} Returns a end_row - start_row times end_col - start_col matrix, with respective entries from the matrix.\n * @example\n *\n * let A = Matrix.from([[1, 2, 3], [4, 5, 6], [7, 8, 9]]); // a 3 by 3 matrix.\n *\n * A.get_block(1, 1); // [[5, 6], [8, 9]]\n * A.get_block(0, 0, 1, 1); // [[1]]\n * A.get_block(1, 1, 2, 2); // [[5]]\n * A.get_block(0, 0, 2, 2); // [[1, 2], [4, 5]]\n */\n get_block(start_row, start_col, end_row = null, end_col = null) {\n const [rows, cols] = this.shape;\n end_row = end_row ?? rows;\n end_col = end_col ?? cols;\n if (end_row <= start_row || end_col <= start_col) {\n throw new Error(`\n end_row must be greater than start_row, and \n end_col must be greater than start_col, but\n end_row = ${end_row}, start_row = ${start_row}, end_col = ${end_col}, and start_col = ${start_col}!`);\n }\n const X = new Matrix(end_row - start_row, end_col - start_col, \"zeros\");\n for (let row = start_row, new_row = 0; row < end_row; ++row, ++new_row) {\n for (let col = start_col, new_col = 0; col < end_col; ++col, ++new_col) {\n X.set_entry(new_row, new_col, this.entry(row, col));\n }\n }\n return X;\n //return new Matrix(end_row - start_row, end_col - start_col, (i, j) => this.entry(i + start_row, j + start_col));\n }\n\n /**\n * Returns a new array gathering entries defined by the indices given by argument.\n * @param {Array} row_indices - Array consists of indices of rows for gathering entries of this matrix\n * @param {Array} col_indices - Array consists of indices of cols for gathering entries of this matrix\n * @returns {Matrix}\n */\n gather(row_indices, col_indices) {\n const N = row_indices.length;\n const D = col_indices.length;\n\n const R = new Matrix(N, D);\n for (let i = 0; i < N; ++i) {\n const row_index = row_indices[i];\n for (let j = 0; j < N; ++j) {\n const col_index = col_indices[j];\n R.set_entry(i, j, this.entry(row_index, col_index));\n }\n }\n\n return R;\n }\n\n /**\n * Applies a function to each entry of the matrix.\n * @private\n * @param {function} f function takes 2 parameters, the value of the actual entry and a value given by the function {@link v}. The result of {@link f} gets writen to the Matrix.\n * @param {function} v function takes 2 parameters for row and col, and returns a value witch should be applied to the colth entry of the rowth row of the matrix.\n */\n _apply_array(f, v) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], v(row, col));\n }\n }\n return this;\n }\n\n _apply_rowwise_array(values, f) {\n return this._apply_array(f, (_, j) => values[j]);\n }\n\n _apply_colwise_array(values, f) {\n const data = this.values;\n const [rows, cols] = this.shape;\n for (let row = 0; row < rows; ++row) {\n const offset = row * cols;\n for (let col = 0; col < cols; ++col) {\n const i = offset + col;\n data[i] = f(data[i], values[row]);\n }\n }\n return this;\n }\n\n _apply(value, f) {\n let data = this.values;\n if (value instanceof Matrix) {\n let [value_rows, value_cols] = value.shape;\n let [rows, cols] = this.shape;\n if (value_rows === 1) {\n if (cols !== value_cols) {\n throw new Error(`cols !== value_cols`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(0, col));\n }\n }\n } else if (value_cols === 1) {\n if (rows !== value_rows) {\n throw new Error(`rows !== value_rows`);\n }\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, 0));\n }\n }\n } else if (rows == value_rows && cols == value_cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value.entry(row, col));\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else if (Array.isArray(value)) {\n let rows = this._rows;\n let cols = this._cols;\n if (value.length === rows) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[row]);\n }\n }\n } else if (value.length === cols) {\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n data[row * cols + col] = f(data[row * cols + col], value[col]);\n }\n }\n } else {\n throw new Error(`error`);\n }\n } else {\n for (let i = 0, n = this._rows * this._cols; i < n; ++i) {\n data[i] = f(data[i], value);\n }\n }\n return this;\n }\n\n /**\n * Clones the Matrix.\n * @returns {Matrix}\n */\n clone() {\n let B = new Matrix();\n B._rows = this._rows;\n B._cols = this._cols;\n B._data = this.values.slice(0);\n return B;\n }\n\n /**\n * Entrywise multiplication with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.mult(2); // [[2, 4], [6, 8]];\n * A.mult(B); // [[1, 4], [9, 16]];\n */\n mult(value) {\n return this.clone()._apply(value, (a, b) => a * b);\n }\n\n /**\n * Entrywise division with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.divide(2); // [[0.5, 1], [1.5, 2]];\n * A.divide(B); // [[1, 1], [1, 1]];\n */\n divide(value) {\n return this.clone()._apply(value, (a, b) => a / b);\n }\n\n /**\n * Entrywise addition with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.add(2); // [[3, 4], [5, 6]];\n * A.add(B); // [[2, 4], [6, 8]];\n */\n add(value) {\n return this.clone()._apply(value, (a, b) => a + b);\n }\n\n /**\n * Entrywise subtraction with {@link value}.\n * @param {Matrix|Array|Number} value\n * @returns {Matrix}\n * @example\n *\n * let A = Matrix.from([[1, 2], [3, 4]]); // a 2 by 2 matrix.\n * let B = A.clone(); // B == A;\n *\n * A.sub(2); // [[-1, 0], [1, 2]];\n * A.sub(B); // [[0, 0], [0, 0]];\n */\n sub(value) {\n return this.clone()._apply(value, (a, b) => a - b);\n }\n\n /**\n * Returns the number of rows and columns of the Matrix.\n * @returns {Array} An Array in the form [rows, columns].\n */\n get shape() {\n return [this._rows, this._cols];\n }\n\n /**\n * Returns the matrix in the given shape with the given function which returns values for the entries of the matrix.\n * @param {Array} parameter - takes an Array in the form [rows, cols, value], where rows and cols are the number of rows and columns of the matrix, and value is a function which takes two parameters (row and col) which has to return a value for the colth entry of the rowth row.\n * @returns {Matrix}\n */\n set shape([rows, cols, value = () => 0]) {\n this._rows = rows;\n this._cols = cols;\n this._data = new Float64Array(rows * cols);\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < cols; ++col) {\n this._data[row * cols + col] = value(row, col);\n }\n }\n return this;\n }\n\n /**\n * Returns the Matrix as a Array of Float64Arrays.\n * @returns {Array}\n */\n get to2dArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(row);\n }\n return result;\n }\n\n /**\n * Returns the Matrix as a Array of Arrays.\n * @returns {Array}\n */\n get asArray() {\n const result = [];\n for (const row of this.iterate_rows()) {\n result.push(Array.from(row));\n }\n return result;\n }\n\n /**\n * Returns the diagonal of the Matrix.\n * @returns {Float64Array}\n */\n get diag() {\n const rows = this._rows;\n const cols = this._cols;\n const min_row_col = Math.min(rows, cols);\n let result = new Float64Array(min_row_col);\n for (let i = 0; i < min_row_col; ++i) {\n result[i] = this.entry(i, i);\n }\n return result;\n }\n\n /**\n * Returns the mean of all entries of the Matrix.\n * @returns {Number}\n */\n get mean() {\n const sum = this.sum;\n const n = this._rows * this._cols;\n return sum / n;\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Number}\n */\n get sum() {\n const data = this.values;\n return neumair_sum(data);\n }\n\n /**\n * Returns the sum oof all entries of the Matrix.\n * @returns {Float64Array}\n */\n get values() {\n const data = this._data;\n return data;\n }\n\n /**\n * Returns the mean of each row of the matrix.\n * @returns {Float64Array}\n */\n get meanRows() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: rows });\n for (let row = 0; row < rows; ++row) {\n result[row] = 0;\n for (let col = 0; col < cols; ++col) {\n result[row] += data[row * cols + col];\n }\n result[row] /= cols;\n }\n return result;\n }\n\n /** Returns the mean of each column of the matrix.\n * @returns {Float64Array}\n */\n get meanCols() {\n const data = this.values;\n const rows = this._rows;\n const cols = this._cols;\n const result = Float64Array.from({ length: cols });\n for (let col = 0; col < cols; ++col) {\n result[col] = 0;\n for (let row = 0; row < rows; ++row) {\n result[col] += data[row * cols + col];\n }\n result[col] /= rows;\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b} using the conjugate gradient method. Returns the result x.\n * @param {Matrix} A - Matrix\n * @param {Matrix} b - Matrix\n * @param {Randomizer} [randomizer=null]\n * @param {Number} [tol=1e-3]\n * @returns {Matrix}\n */\n static solve_CG(A, b, randomizer, tol = 1e-3) {\n if (randomizer === null) {\n randomizer = new Randomizer();\n }\n const rows = A.shape[0];\n const cols = b.shape[1];\n let result = new Matrix(rows, 0);\n for (let i = 0; i < cols; ++i) {\n const b_i = Matrix.from(b.col(i)).T;\n let x = new Matrix(rows, 1, () => randomizer.random);\n let r = b_i.sub(A.dot(x));\n let d = r.clone();\n do {\n const z = A.dot(d);\n const alpha = r.T.dot(r).entry(0, 0) / d.T.dot(z).entry(0, 0);\n x = x.add(d.mult(alpha));\n const r_next = r.sub(z.mult(alpha));\n const beta = r_next.T.dot(r_next).entry(0, 0) / r.T.dot(r).entry(0, 0);\n d = r_next.add(d.mult(beta));\n r = r_next;\n } while (Math.abs(r.mean) > tol);\n result = result.concat(x, \"horizontal\");\n }\n return result;\n }\n\n /**\n * Solves the equation {@link A}x = {@link b}. Returns the result x.\n * @param {Matrix} A - Matrix or LU Decomposition\n * @param {Matrix} b - Matrix\n * @returns {Matrix}\n */\n static solve(A, b) {\n let { L: L, U: U } = \"L\" in A && \"U\" in A ? A : Matrix.LU(A);\n let rows = L.shape[0];\n let x = b.clone();\n\n // forward\n for (let row = 0; row < rows; ++row) {\n for (let col = 0; col < row - 1; ++col) {\n x.set_entry(0, row, x.entry(0, row) - L.entry(row, col) * x.entry(1, col));\n }\n x.set_entry(0, row, x.entry(0, row) / L.entry(row, row));\n }\n\n // backward\n for (let row = rows - 1; row >= 0; --row) {\n for (let col = rows - 1; col > row; --col) {\n x.set_entry(0, row, x.entry(0, row) - U.entry(row, col) * x.entry(0, col));\n }\n x.set_entry(0, row, x.entry(0, row) / U.entry(row, row));\n }\n\n return x;\n }\n\n /**\n * {@link L}{@link U} decomposition of the Matrix {@link A}. Creates two matrices, so that the dot product LU equals A.\n * @param {Matrix} A\n * @returns {{L: Matrix, U: Matrix}} result - Returns the left triangle matrix {@link L} and the upper triangle matrix {@link U}.\n */\n static LU(A) {\n const rows = A.shape[0];\n const L = new Matrix(rows, rows, \"zeros\");\n const U = new Matrix(rows, rows, \"identity\");\n\n for (let j = 0; j < rows; ++j) {\n for (let i = j; i < rows; ++i) {\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(i, k) * U.entry(k, j);\n }\n L.set_entry(i, j, A.entry(i, j) - sum);\n }\n for (let i = j; i < rows; ++i) {\n if (L.entry(j, j) === 0) {\n return undefined;\n }\n let sum = 0;\n for (let k = 0; k < j; ++k) {\n sum += L.entry(j, k) * U.entry(k, i);\n }\n U.set_entry(j, i, (A.entry(j, i) - sum) / L.entry(j, j));\n }\n }\n\n return { L: L, U: U };\n }\n\n /**\n * Computes the determinante of {@link A}, by using the LU decomposition of {@link A}.\n * @param {Matrix} A\n * @returns {Number} det - Returns the determinate of the Matrix {@link A}.\n */\n static det(A) {\n const rows = A.shape[0];\n const { L, U } = Matrix.LU(A);\n const L_diag = L.diag;\n const U_diag = U.diag;\n let det = L_diag[0] * U_diag[0];\n for (let row = 1; row < rows; ++row) {\n det *= L_diag[row] * U_diag[row];\n }\n return det;\n }\n\n /**\n * Computes the {@link k} components of the SVD decomposition of the matrix {@link M}\n * @param {Matrix} M\n * @param {int} [k=2]\n * @returns {{U: Matrix, Sigma: Matrix, V: Matrix}}\n */\n static SVD(M, k = 2) {\n const MT = M.T;\n let MtM = MT.dot(M);\n let MMt = M.dot(MT);\n let { eigenvectors: V, eigenvalues: Sigma } = simultaneous_poweriteration(MtM, k);\n let { eigenvectors: U } = simultaneous_poweriteration(MMt, k);\n return { U: U, Sigma: Sigma.map((sigma) => Math.sqrt(sigma)), V: V };\n\n //Algorithm 1a: Householder reduction to bidiagonal form:\n /* const [m, n] = A.shape;\n let U = new Matrix(m, n, (i, j) => i == j ? 1 : 0);\n console.log(U.to2dArray)\n let V = new Matrix(n, m, (i, j) => i == j ? 1 : 0);\n console.log(V.to2dArray)\n let B = Matrix.bidiagonal(A.clone(), U, V);\n console.log(U,V,B)\n return { U: U, \"Sigma\": B, V: V }; */\n }\n}\n","import { linspace, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @memberof module:utils\n * @alias Randomizer\n */\nexport class Randomizer {\n /**\n * Mersenne Twister random number generator.\n * @constructor\n * @param {Number} [_seed=new Date().getTime()] - The seed for the random number generator. If _seed == null then the actual time gets used as seed.\n * @see https://github.com/bmurray7/mersenne-twister-examples/blob/master/javascript-mersenne-twister.js\n */\n constructor(_seed) {\n this._N = 624;\n this._M = 397;\n this._MATRIX_A = 0x9908b0df;\n this._UPPER_MASK = 0x80000000;\n this._LOWER_MASK = 0x7fffffff;\n this._mt = new Array(this._N);\n this._mti = this.N + 1;\n\n this.seed = _seed || new Date().getTime();\n return this;\n }\n\n set seed(_seed) {\n this._seed = _seed;\n let mt = this._mt;\n\n mt[0] = _seed >>> 0;\n for (this._mti = 1; this._mti < this._N; this._mti += 1) {\n let mti = this._mti;\n let s = mt[mti - 1] ^ (mt[mti - 1] >>> 30);\n mt[mti] = ((((s & 0xffff0000) >>> 16) * 1812433253) << 16) + (s & 0x0000ffff) * 1812433253 + mti;\n mt[mti] >>>= 0;\n }\n }\n\n /**\n * Returns the seed of the random number generator.\n * @returns {Number} - The seed.\n */\n get seed() {\n return this._seed;\n }\n\n /**\n * Returns a float between 0 and 1.\n * @returns {Number} - A random number between [0, 1]\n */\n get random() {\n return this.random_int * (1.0 / 4294967296.0);\n }\n\n /**\n * Returns an integer between 0 and MAX_INTEGER.\n * @returns {Integer} - A random integer.\n */\n get random_int() {\n let y,\n mag01 = new Array(0x0, this._MATRIX_A);\n if (this._mti >= this._N) {\n let kk;\n\n /* if (this._mti == this._N + 1) {\n this.seed = 5489;\n } */\n\n let N_M = this._N - this._M;\n let M_N = this._M - this._N;\n\n for (kk = 0; kk < N_M; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + this._M] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n for (; kk < this._N - 1; ++kk) {\n y = (this._mt[kk] & this._UPPER_MASK) | (this._mt[kk + 1] & this._LOWER_MASK);\n this._mt[kk] = this._mt[kk + M_N] ^ (y >>> 1) ^ mag01[y & 0x1];\n }\n\n y = (this._mt[this._N - 1] & this._UPPER_MASK) | (this._mt[0] & this._LOWER_MASK);\n this._mt[this._N - 1] = this._mt[this._M - 1] ^ (y >>> 1) ^ mag01[y & 0x1];\n\n this._mti = 0;\n }\n\n y = this._mt[(this._mti += 1)];\n y ^= y >>> 11;\n y ^= (y << 7) & 0x9d2c5680;\n y ^= (y << 15) & 0xefc60000;\n y ^= y >>> 18;\n\n return y >>> 0;\n }\n\n /**\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n choice(A, n) {\n if (A instanceof Matrix) {\n let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A.row(d));\n } else if (Array.isArray(A) || A instanceof Float64Array) {\n let rows = A.length;\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = this.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n return sample.map((d) => A[d]);\n }\n }\n\n /**\n * @static\n * Returns samples from an input Matrix or Array.\n * @param {Matrix|Array|Float64Array} A - The input Matrix or Array.\n * @param {Number} n - The number of samples.\n * @param {Number} seed - The seed for the random number generator.\n * @returns {Array} - A random selection form {@link A} of {@link n} samples.\n */\n static choice(A, n, seed = 1212) {\n const R = new Randomizer(seed);\n return R.choice(A, n);\n /* let rows = A.shape[0];\n if (n > rows) {\n throw new Error(\"n bigger than A!\");\n }\n let rand = new Randomizer(seed);\n let sample = new Array(n);\n let index_list = linspace(0, rows - 1);\n for (let i = 0, l = index_list.length; i < n; ++i, --l) {\n let random_index = rand.random_int % l;\n sample[i] = index_list.splice(random_index, 1)[0];\n }\n //return result;\n //return new Matrix(n, cols, (row, col) => A.entry(sample[row], col))\n return sample.map((d) => A.row(d)); */\n }\n}\n","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias max\n * @param {Array} values \n * @returns {Number}\n */\nexport default function (values) {\n let max;\n for (const value of values) {\n if (value != null && (max < value || (max === undefined && value >= value))) {\n max = value;\n }\n }\n return max;\n}","/**\n * Returns maximum in Array {@link values}.\n * @memberof module:utils\n * @alias min\n * @param {Array} values\n * @returns {Number}\n */\nexport default function (values) {\n let min;\n for (const value of values) {\n if (value != null && (min > value || (min === undefined && value <= value))) {\n min = value;\n }\n }\n return min;\n}","/**\n * @class\n * @alias Heap\n */\nexport class Heap {\n /**\n * A heap is a datastructure holding its elements in a specific way, so that the top element would be the first entry of an ordered list.\n * @constructor\n * @memberof module:datastructure\n * @alias Heap\n * @param {Array=} elements - Contains the elements for the Heap. {@link elements} can be null.\n * @param {Function} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(\"min\"|\"max\"|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n * @see {@link https://en.wikipedia.org/wiki/Binary_heap}\n */\n constructor(elements = null, accessor = d => d, comparator = \"min\") {\n if (elements) {\n return Heap.heapify(elements, accessor, comparator);\n } else {\n this._accessor = accessor;\n this._container = [];\n if (comparator == \"min\") {\n this._comparator = (a, b) => a < b;\n } else if (comparator == \"max\") {\n this._comparator = (a, b) => a > b;\n } else {\n this._comparator = comparator;\n }\n return this\n }\n }\n\n /**\n * Creates a Heap from an Array\n * @param {Array|Set} elements - Contains the elements for the Heap.\n * @param {Function=} [accessor = (d) => d] - Function returns the value of the element.\n * @param {(String=|Function)} [comparator = \"min\"] - Function returning true or false defining the wished order of the Heap, or String for predefined function. (\"min\" for a Min-Heap, \"max\" for a Max_heap)\n * @returns {Heap}\n */\n static heapify(elements, accessor = d => d, comparator = \"min\") {\n const heap = new Heap(null, accessor, comparator);\n const container = heap._container;\n for (const e of elements) {\n container.push({\n \"element\": e,\n \"value\": accessor(e),\n });\n }\n for (let i = Math.floor((elements.length / 2) - 1); i >= 0; --i) {\n heap._heapify_down(i);\n }\n return heap;\n }\n\n /**\n * Swaps elements of container array.\n * @private\n * @param {Number} index_a \n * @param {Number} index_b \n */\n _swap(index_a, index_b) {\n const container = this._container;\n [container[index_b], container[index_a]] = [container[index_a], container[index_b]];\n return;\n }\n\n /**\n * @private\n */\n _heapify_up() {\n const container = this._container;\n let index = container.length - 1;\n while (index > 0) {\n let parentIndex = Math.floor((index - 1) / 2);\n if (!this._comparator(container[index].value, container[parentIndex].value)) {\n break;\n } else {\n this._swap(parentIndex, index)\n index = parentIndex;\n }\n }\n }\n\n /**\n * Pushes the element to the heap.\n * @param {} element\n * @returns {Heap}\n */\n push(element) {\n const value = this._accessor(element);\n //const node = new Node(element, value);\n const node = {\"element\": element, \"value\": value};\n this._container.push(node);\n this._heapify_up();\n return this;\n }\n\n /**\n * @private\n * @param {Number} [start_index = 0] \n */\n _heapify_down(start_index=0) {\n const container = this._container;\n const comparator = this._comparator;\n const length = container.length;\n let left = 2 * start_index + 1;\n let right = 2 * start_index + 2;\n let index = start_index;\n if (index > length) throw \"index higher than length\"\n if (left < length && comparator(container[left].value, container[index].value)) {\n index = left;\n }\n if (right < length && comparator(container[right].value, container[index].value)) {\n index = right;\n }\n if (index !== start_index) {\n this._swap(start_index, index);\n this._heapify_down(index);\n }\n }\n\n /**\n * Removes and returns the top entry of the heap.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n pop() {\n const container = this._container;\n if (container.length === 0) {\n return null;\n } else if (container.length === 1) {\n return container.pop();\n }\n this._swap(0, container.length - 1);\n const item = container.pop();\n this._heapify_down();\n return item;\n }\n\n /**\n * Returns the top entry of the heap without removing it.\n * @returns {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n get first() {\n return this._container.length > 0 ? this._container[0] : null;\n }\n\n\n /**\n * Yields the raw data\n * @yields {Object} Object consists of the element and its value (computed by {@link accessor}).\n */\n * iterate() {\n for (let i = 0, n = this._container.length; i < n; ++i) {\n yield this._container[i].element;\n }\n }\n\n /**\n * Returns the heap as ordered array.\n * @returns {Array} Array consisting the elements ordered by {@link comparator}.\n */\n toArray() {\n return this.data()\n .sort((a,b) => this._comparator(a, b) ? -1 : 0)\n }\n\n /**\n * Returns elements of container array.\n * @returns {Array} Array consisting the elements.\n */\n data() {\n return this._container\n .map(d => d.element)\n }\n\n /**\n * Returns the container array.\n * @returns {Array} The container array.\n */\n raw_data() {\n return this._container;\n }\n\n /**\n * The size of the heap.\n * @returns {Number}\n */\n get length() {\n return this._container.length;\n }\n\n /**\n * Returns false if the the heap has entries, true if the heap has no entries.\n * @returns {Boolean}\n */\n get empty() {\n return this.length === 0;\n }\n}","/**\n * @class\n * @alias DisjointSet\n * @see {@link https://en.wikipedia.org/wiki/Disjoint-set_data_structure}\n */\nexport class DisjointSet {\n /**\n * @constructor\n * @alias DisjointSet\n * @memberof module:datastructure\n * @param {Array=} elements \n * @returns {DisjointSet}\n */\n constructor(elements = null) {\n this._list = new Set();\n if (elements) {\n for (const e of elements) {\n this.make_set(e);\n }\n }\n return this;\n }\n\n make_set(x) {\n const list = this._list;\n if (!list.has(x)) {\n list.add(x);\n x.__disjoint_set = {};\n x.__disjoint_set.parent = x;\n x.__disjoint_set.children = new Set([x]);\n x.__disjoint_set.size = 1;\n }\n return this;\n }\n\n find(x) {\n const list = this._list;\n if (list.has(x)) {\n if (x.__disjoint_set.parent !== x) {\n x.__disjoint_set.children.add(...x);\n x.__disjoint_set.parent = this.find(x.__disjoint_set.parent);\n return x.__disjoint_set.parent;\n } else {\n return x;\n }\n } else {\n return null;\n }\n }\n\n union(x, y) {\n let node_x = this.find(x);\n let node_y = this.find(y);\n\n if (node_x === node_y) return this;\n if (node_x.__disjoint_set.size < node_y.__disjoint_set.size) [node_x, node_y] = [node_y, node_x];\n\n node_y.__disjoint_set.parent = node_x;\n // keep track of children?\n node_y.__disjoint_set.children.forEach(node_x.__disjoint_set.children.add, node_x.__disjoint_set.children);\n node_x.__disjoint_set.size += node_y.__disjoint_set.size;\n\n return this;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n/**\n * @class\n * @alias BallTree\n */\nexport class BallTree {\n /**\n * Generates a BallTree with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias BallTree\n * @param {Array=} elements - Elements which should be added to the BallTree\n * @param {Function} [metric = euclidean] metric to use: (a, b) => distance\n * @see {@link https://en.wikipedia.org/wiki/Ball_tree}\n * @see {@link https://github.com/invisal/noobjs/blob/master/src/tree/BallTree.js}\n * @returns {BallTree}\n */\n constructor(elements = null, metric = euclidean) {\n this._Node = class {\n constructor(pivot, child1=null, child2=null, radius=null) {\n this.pivot = pivot;\n this.child1 = child1;\n this.child2 = child2;\n this.radius = radius;\n }\n }\n this._Leaf = class {\n constructor(points) {\n this.points = points;\n }\n }\n this._metric = metric;\n if (elements) {\n this.add(elements);\n }\n return this;\n }\n\n /**\n * \n * @param {Array<*>} elements - new elements.\n * @returns {BallTree}\n */\n add(elements) {\n elements = elements.map((element, index) => {\n return {index: index, element: element}\n })\n this._root = this._construct(elements);\n return this;\n }\n\n /**\n * @private\n * @param {Array<*>} elements \n * @returns {Node} root of balltree.\n */\n _construct(elements) {\n if (elements.length === 1) {\n return new this._Leaf(elements);\n } else {\n let c = this._greatest_spread(elements);\n let sorted_elements = elements.sort((a, b) => a.element[c] - b.element[c]);\n let n = sorted_elements.length;\n let p_index = Math.floor(n / 2);\n let p = elements[p_index];\n let L = sorted_elements.slice(0, p_index);\n let R = sorted_elements.slice(p_index, n);\n let radius = Math.max(...elements.map(d => this._metric(p.element, d.element)));\n let B\n if (L.length > 0 && R.length > 0) { \n B = new this._Node(p, this._construct(L), this._construct(R), radius);\n } else {\n B = new this._Leaf(elements);\n }\n return B;\n }\n }\n\n /**\n * @private\n * @param {Node} B \n * @returns {Number}\n */\n _greatest_spread(B) {\n let d = B[0].element.length;\n let start = new Array(d);\n\n for (let i = 0; i < d; ++i) {\n start[i] = [Infinity, -Infinity];\n }\n\n let spread = B.reduce((acc, current) => {\n for (let i = 0; i < d; ++i) {\n acc[i][0] = Math.min(acc[i][0], current.element[i]);\n acc[i][1] = Math.max(acc[i][1], current.element[i]);\n }\n return acc;\n }, start);\n spread = spread.map(d => d[1] - d[0]);\n \n let c = 0;\n for (let i = 0; i < d; ++i) {\n c = spread[i] > spread[c] ? i : c;\n }\n return c;\n }\n\n /**\n * \n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n return this._search(t, k, new Heap(null, d => this._metric(d.element, t), \"max\"), this._root);\n }\n\n /**\n * @private\n * @param {*} t - query element.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @param {Heap} Q - Heap consists of the currently found {@link k} nearest neighbors.\n * @param {Node|Leaf} B \n */\n _search(t, k, Q, B) {\n // B is Node\n if (Q.length >= k && B.pivot && B.radius && this._metric(t, B.pivot.element) - B.radius >= Q.first.value) {\n return Q;\n } \n if (B.child1) this._search(t, k, Q, B.child1);\n if (B.child2) this._search(t, k, Q, B.child2);\n \n // B is leaf\n if (B.points) {\n for (let i = 0, n = B.points.length; i < n; ++i) {\n let p = B.points[i];\n if (k > Q.length) {\n Q.push(p);\n } else {\n Q.push(p);\n Q.pop();\n }\n }\n }\n return Q;\n }\n}","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KNN\n */\nexport class KNN {\n /**\n * Generates a KNN list with given {@link elements}.\n * @constructor\n * @memberof module:knn\n * @alias KNN\n * @param {Array=} elements - Elements which should be added to the KNN list\n * @param {Function|\"precomputed\"} [metric = euclidean] metric is either precomputed or a function to use: (a, b) => distance\n * @returns {KNN}\n */\n constructor(elements=null, metric=euclidean) {\n this._metric = metric;\n this._elements = elements instanceof Matrix ? elements : Matrix.from(elements);\n const N = this._elements.shape[0];\n if (metric === \"precomputed\") {\n this._D = this._elements.clone();\n } else {\n this._D = distance_matrix(this._elements, metric);\n }\n this.KNN = [];\n for (let row = 0; row < N; ++row) {\n const distances = this._D.row(row);\n const H = new Heap(null, d => d.value, \"min\");\n for (let j = 0; j < N; ++j) {\n H.push({\n value: distances[j],\n index: j,\n });\n }\n this.KNN.push(H);\n }\n }\n\n /**\n * \n * @param {Array|Number} t - query element or index.\n * @param {Number} [k = 5] - number of nearest neighbors to return.\n * @returns {Heap} - Heap consists of the {@link k} nearest neighbors.\n */\n search(t, k = 5) {\n const metric = this._metric;\n const KNN = this.KNN;\n let H;\n if (Array.isArray(t)) {\n if (this._metric == \"precomputed\") {\n throw \"Search by query element is only possible when not using a precomputed distance matrix!\"\n } \n const elements = this._elements;\n const N = KNN.length;\n let nearest_element_index = null;\n let nearest_dist = Infinity;\n for (let i = 0; i < N; ++i) {\n const element = elements.row(i);\n const dist = metric(t, element);\n if (dist < nearest_dist) {\n nearest_element_index = i;\n nearest_dist = dist;\n }\n }\n H = KNN[nearest_element_index];\n } else if (Number.isInteger(t)) {\n H = KNN[t]\n }\n\n let result = []\n for (let i = 0; i < k; ++i) {\n result.push(H.pop())\n }\n result.forEach(res => H.push(res.element))\n return result\n } \n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Randomizer } from \"../util/index.js\";\n\n/**\n * @class\n * @alias DR\n * @borrows DR#parameter as DR#para\n * @borrows DR#parameter as DR#p\n */\nexport class DR {\n /**\n * Takes the default parameters and seals them, remembers the type of input {@link X}, and initializes the random number generator.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias DR\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed value for the random number generator.\n * @returns {DR}\n */\n constructor(X, default_parameters, parameters) {\n this._parameters = Object.assign(Object.seal(default_parameters), parameters);\n if (Array.isArray(X)) {\n this._type = \"array\";\n this.X = Matrix.from(X);\n } else if (X instanceof Matrix) {\n this._type = \"matrix\";\n this.X = X;\n } else {\n throw new Error(\"No valid type for X!\");\n }\n [this._N, this._D] = this.X.shape;\n this._randomizer = new Randomizer(this._parameters.seed);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * Set and get parameters\n * @param {String} name - name of the parameter.\n * @param {any} [value = null] - value of the parameter to set.\n * @returns {DR|any} - On setting a parameter, this function returns the DR object. If value == null then return actual parameter value.\n * @example\n * const DR = new druid.TSNE(X, {d: 3}); // creates a new DR object, with parameter for d = 3.\n * DR.parameter(\"d\"); // returns 3,\n * DR.parameter(\"d\", 2); // sets parameter d to 2 and returns DR.\n */\n parameter(name, value = null) {\n if (!this._parameters.hasOwnProperty(name)) {\n throw new Error(`${name} is not a valid parameter!`);\n }\n if (value !== null) {\n this._parameters[name] = value;\n this._is_initialized = false;\n return this;\n } else {\n return this._parameters[name];\n }\n }\n\n para(name, value = null) {\n return this.parameter(name, value);\n }\n\n p(name, value = null) {\n return this.parameter(name, value);\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} - Returns the projection.\n */\n transform() {\n this.check_init();\n return this.projection;\n }\n\n /**\n * Computes the projection.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n *generator() {\n return this.transform();\n }\n\n /**\n * If the respective DR method has an init function, call it before transform.\n * @returns {DR}\n */\n check_init() {\n if (!this._is_initialized && typeof this.init === \"function\") {\n this.init();\n this._is_initialized = true;\n }\n return this;\n }\n\n /**\n * @returns {Matrix|Array} Returns the projection.\n */\n get projection() {\n if (this.hasOwnProperty(\"Y\")) {\n this.check_init();\n return this._type === \"matrix\" ? this.Y : this.Y.to2dArray;\n } else {\n throw new Error(\"The dataset is not transformed yet!\");\n }\n }\n\n /**\n *\n * @param {...any} args - Arguments the transform method of the respective DR method takes.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Matrix|Array} - The dimensionality reduced dataset.\n */\n static transform(...args) {\n let dr = new this(...args);\n return dr.transform();\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Promise} - A promise yielding the dimensionality reduced dataset.\n */\n static async transform_async(...args) {\n return this.transform(...args);\n }\n\n /**\n * @static\n * @param {...any} args - Takes the same arguments of the constructor of the respective DR method.\n * @returns {Generator} - A generator yielding the intermediate steps of the dimensionality reduction method.\n */\n static *generator(...args) {\n const dr = new this(...args);\n const generator = dr.generator();\n for (const result of generator) {\n yield result;\n }\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias PCA\n * @augments DR\n */\nexport class PCA extends DR {\n /**\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias PCA\n * @param {Matrix|Array>} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @returns {PCA}\n */\n constructor(X, parameters) {\n super(X, { d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}. If parameter {@link A} is given, then project {@link A} with the principal components of {@link X}.\n * @param {null|Matrix|Array} [A = null] - If given, the data to project.\n * @returns {Matrix|Array} - The projected data.\n */\n transform(A = null) {\n const V = this.principal_components();\n if (A == null) {\n const X = this.X;\n this.Y = X.dot(V);\n return this.projection;\n } else if (Array.isArray(A)) {\n return Matrix.from(A).dot(V).asArray;\n } else if (A instanceof Matrix) {\n return A.dot(V);\n } else {\n throw new Error(\"No valid type for A!\");\n }\n }\n\n /**\n * Computes the {@link d} principal components of Matrix {@link X}.\n * @returns {Matrix}\n */\n principal_components() {\n if (this.V) {\n return this.V;\n }\n const { d, eig_args } = this._parameters;\n const X = this.X;\n const means = Matrix.from(X.meanCols);\n const X_cent = X.sub(means);\n const C = X_cent.transpose().dot(X_cent);\n const { eigenvectors: V } = simultaneous_poweriteration(C, d, eig_args);\n this.V = Matrix.from(V).transpose();\n return this.V;\n }\n\n static principal_components(X, parameters) {\n const dr = new this(X, parameters);\n return dr.principal_components();\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { distance_matrix, Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias MDS\n * @extends DR\n */\nexport class MDS extends DR {\n /**\n * Classical MDS.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias MDS\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality {@link d}.\n * @returns {Matrix|Array}\n */\n transform() {\n const X = this.X;\n const rows = X.shape[0];\n const { d, metric, eig_args } = this._parameters;\n const A = metric === \"precomputed\" ? X : distance_matrix(X, metric);\n const ai_ = A.meanCols;\n const a_j = A.meanRows;\n const a__ = A.mean;\n\n this._d_X = A;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n\n return this.projection;\n }\n\n /**\n * @returns {Number} - the stress of the projection.\n */\n stress() {\n const N = this.X.shape[0];\n const Y = this.Y;\n const d_X = this._d_X;\n const d_Y = new Matrix();\n d_Y.shape = [\n N,\n N,\n (i, j) => {\n return i < j ? euclidean(Y.row(i), Y.row(j)) : d_Y.entry(j, i);\n },\n ];\n let top_sum = 0;\n let bottom_sum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n top_sum += Math.pow(d_X.entry(i, j) - d_Y.entry(i, j), 2);\n bottom_sum += Math.pow(d_X.entry(i, j), 2);\n }\n }\n return Math.sqrt(top_sum / bottom_sum);\n }\n}\n","/**\n *\n * @memberof module:optimization\n * @alias powell\n * @param {Function} f\n * @param {Array} x0\n * @param {Number} [max_iter = 300]\n * @returns {Array}\n * @see http://optimization-js.github.io/optimization-js/optimization.js.html#line438\n */\nexport default function (f, x0, max_iter = 300) {\n const epsilon = 1e-2;\n const n = x0.length;\n let alpha = 1e-3;\n let pfx = 10000;\n let x = x0.slice();\n let fx = f(x);\n let convergence = false;\n\n while (max_iter-- >= 0 && !convergence) {\n convergence = true;\n for (let i = 0; i < n; ++i) {\n x[i] += 1e-6;\n let fxi = f(x);\n x[i] -= 1e-6;\n let dx = (fxi - fx) / 1e-6;\n if (Math.abs(dx) > epsilon) {\n convergence = false;\n }\n x[i] -= alpha * dx;\n fx = f(x);\n }\n alpha *= pfx >= fx ? 1.05 : 0.4;\n pfx = fx;\n }\n return x;\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\n/**\n * @class\n * @alias Hierarchical_Clustering\n */\nexport class Hierarchical_Clustering {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias Hierarchical_Clustering\n * @todo needs restructuring.\n * @param {Matrix} - Data or distance matrix if metric is 'precomputed'\n * @param {(\"single\"|\"complete\"|\"average\")} [linkage = \"complete\"]\n * @param {Function|\"precomputed\"} [metric = euclidean]\n * @returns {Hierarchical_Clustering}\n */\n constructor(matrix, linkage = \"complete\", metric = euclidean) {\n this._id = 0;\n this._matrix = matrix instanceof Matrix ? matrix : Matrix.from(matrix);\n this._metric = metric;\n this._linkage = linkage;\n if (metric === \"precomputed\" && this._matrix.shape[0] !== this._matrix.shape[1]) {\n throw new Error(\"If metric is 'precomputed', then matrix has to be square!\");\n }\n this.init();\n this.root = this.do();\n return this;\n }\n\n /**\n *\n * @param {Number} value - value where to cut the tree.\n * @param {(\"distance\"|\"depth\")} [type = \"distance\"] - type of value.\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters(value, type = \"distance\") {\n let clusters = [];\n let accessor;\n switch (type) {\n case \"distance\":\n accessor = (d) => d.dist;\n break;\n case \"depth\":\n accessor = (d) => d.depth;\n break;\n default:\n throw new Error(\"invalid type\");\n }\n this._traverse(this.root, accessor, value, clusters);\n return clusters;\n }\n\n /**\n * @private\n * @param {} node\n * @param {*} f\n * @param {*} value\n * @param {*} result\n */\n _traverse(node, f, value, result) {\n if (f(node) <= value) {\n result.push(node.leaves());\n } else {\n this._traverse(node.left, f, value, result);\n this._traverse(node.right, f, value, result);\n }\n }\n\n /**\n * computes the tree.\n */\n init() {\n const metric = this._metric;\n const A = this._matrix;\n const n = (this._n = A.shape[0]);\n const d_min = (this._d_min = new Float64Array(n));\n let distance_matrix;\n if (metric !== \"precomputed\") {\n distance_matrix = new Matrix(n, n, 0); //new Array(n);\n for (let i = 0; i < n; ++i) {\n d_min[i] = 0;\n //distance_matrix[i] = new Float64Array(n);\n for (let j = 0; j < n; ++j) {\n distance_matrix.set_entry(i, j, i === j ? Infinity : metric(A.row(i), A.row(j)));\n if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n } else {\n distance_matrix = this._matrix.clone();\n for (let i = 0; i < n; ++i) {\n for (let j = 0; j < n; ++j) {\n if (i === j) {\n distance_matrix.set_entry(i, j, Infinity);\n } else if (distance_matrix.entry(i, d_min[i]) > distance_matrix.entry(i, j)) {\n d_min[i] = j;\n }\n }\n }\n }\n this._distance_matrix = distance_matrix;\n const clusters = (this._clusters = new Array(n));\n const c_size = (this._c_size = new Uint16Array(n));\n for (let i = 0; i < n; ++i) {\n clusters[i] = [];\n clusters[i][0] = new Cluster(this._id++, null, null, 0, A.row(i), i, 1, 0);\n c_size[i] = 1;\n }\n return this;\n }\n\n /**\n * computes the tree.\n */\n do() {\n const n = this._n;\n const d_min = this._d_min;\n const D = this._distance_matrix;\n const clusters = this._clusters;\n const c_size = this._c_size;\n const linkage = this._linkage;\n let root = null;\n for (let p = 0, p_max = n - 1; p < p_max; ++p) {\n let c1 = 0;\n for (let i = 0; i < n; ++i) {\n let D_i_min = D.entry(i, d_min[i]);\n for (let j = i + 1; j < n; ++j) {\n if (D_i_min > D.entry(i, j)) {\n d_min[i] = j;\n D_i_min = D.entry(i, d_min[i]);\n }\n }\n }\n for (let i = 0; i < n; ++i) {\n if (D.entry(i, d_min[i]) < D.entry(c1, d_min[c1])) {\n c1 = i;\n }\n }\n let c2 = d_min[c1];\n let c1_cluster = clusters[c1][0];\n let c2_cluster = clusters[c2][0];\n let c1_cluster_indices = c1_cluster.isLeaf ? [c1_cluster.index] : c1_cluster.index;\n let c2_cluster_indices = c2_cluster.isLeaf ? [c2_cluster.index] : c2_cluster.index;\n let indices = c1_cluster_indices.concat(c2_cluster_indices);\n let new_cluster = new Cluster(this._id++, c1_cluster, c2_cluster, D.entry(c1, c2), null, indices);\n c1_cluster.parent = new_cluster;\n c2_cluster.parent = new_cluster;\n clusters[c1].unshift(new_cluster);\n c_size[c1] += c_size[c2];\n for (let j = 0; j < n; ++j) {\n const D_c1_j = D.entry(c1, j);\n const D_c2_j = D.entry(c2, j);\n let value;\n switch (linkage) {\n case \"single\":\n value = Math.min(D_c1_j, D_c2_j);\n break;\n case \"complete\":\n value = Math.max(D_c1_j, D_c2_j);\n break;\n case \"average\":\n value = (c_size[c1] * D_c1_j + c_size[c2] * D_c2_j) / (c_size[c1] + c_size[j]);\n break;\n }\n D.set_entry(j, c1, value);\n D.set_entry(c1, j, value);\n }\n\n D.set_entry(c1, c1, Infinity);\n for (let i = 0; i < n; ++i) {\n D.set_entry(i, c2, Infinity);\n D.set_entry(c2, i, Infinity);\n }\n\n /* for (let j = 0; j < n; ++j) {\n if (d_min[j] === c2) {\n d_min[j] = c1;\n }\n if (D.entry(c1, j) < D.entry(c1, d_min[c1])) {\n d_min[c1] = j;\n }\n } */\n root = new_cluster;\n }\n return root;\n }\n}\n\nclass Cluster {\n constructor(id, left, right, dist, centroid, index, size, depth) {\n this.id = id;\n this.left = left;\n this.right = right;\n this.dist = dist;\n this.index = index;\n this.size = size ?? left.size + right.size;\n this.depth = depth ?? 1 + Math.max(left.depth, right.depth);\n this.centroid = centroid ?? this._calculate_centroid(left, right);\n this.parent = null;\n return this;\n }\n\n _calculate_centroid(left, right) {\n const l_size = left.size;\n const r_size = right.size;\n const l_centroid = left.centroid;\n const r_centroid = right.centroid;\n const size = this.size;\n const n = left.centroid.length;\n const new_centroid = new Float64Array(n);\n for (let i = 0; i < n; ++i) {\n new_centroid[i] = (l_size * l_centroid[i] + r_size * r_centroid[i]) / size;\n }\n return new_centroid;\n }\n\n get isLeaf() {\n return this.depth === 0;\n }\n\n leaves() {\n if (this.isLeaf) return [this];\n const left = this.left;\n const right = this.right;\n return (left.isLeaf ? [left] : left.leaves()).concat(right.isLeaf ? [right] : right.leaves());\n }\n\n descendants() {\n if (this.isLeaf) return [this];\n const left_descendants = this.left.descendants();\n const right_descendants = this.right.descendants();\n return left_descendants.concat(right_descendants).concat([this]);\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { linspace, Matrix } from \"../matrix/index.js\";\nimport { min } from \"../util/index.js\";\n/**\n * @class\n * @alias KMedoids\n */\nexport class KMedoids {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMedoids\n * @todo needs restructuring. \n * @param {Matrix} matrix - data matrix\n * @param {Numbers} K - number of clusters\n * @param {number} [max_iter=null] - maximum number of iterations. Default is 10 * Math.log10(N)\n * @param {Function} [metric = euclidean] - metric defining the dissimilarity \n * @param {Number} [seed = 1212] - seed value for random number generator\n * @returns {KMedoids}\n * @see {@link https://link.springer.com/chapter/10.1007/978-3-030-32047-8_16} Faster k-Medoids Clustering: Improving the PAM, CLARA, and CLARANS Algorithms\n */\n constructor(matrix, K, max_iter=null, metric = euclidean, seed=1212) {\n this._metric = metric;\n this._matrix = matrix;\n this._A = this._matrix.to2dArray;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n this._max_iter = max_iter || 10 * Math.log10(N) \n this._distance_matrix = new Matrix(N, N, \"zeros\");\n /* for (let i = 1; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dist = metric(this._A[i], this._A[j]);\n this._distance_matrix.set_entry(i, j, dist);\n this._distance_matrix.set_entry(j, i, dist)\n }\n } */\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_medoids = this._get_random_medoids(K);\n //if (init) this.init(K, this._cluster_medoids);\n this._is_initialized = false;\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const A = this._A;\n if (!this._is_initialized) {\n this.init(K, this._cluster_medoids);\n }\n const result = new Array(K).fill().map(() => new Array());\n A.forEach((x_j, j) => {\n result[this._nearest_medoid(x_j, j).index_nearest].push(j);\n })\n result.medoids = this._cluster_medoids;\n return result;\n }\n\n async* generator() {\n const max_iter = this._max_iter;\n yield this.get_clusters()\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n yield this.get_clusters();\n } while (!finish && ++i < max_iter)\n }\n\n /**\n * Algorithm 1. FastPAM1: Improved SWAP algorithm\n */\n /* _iteration_1() {\n const A = this._A;\n const N = this._N;\n const K = this._K;\n const medoids = this._cluster_medoids;\n let DeltaTD = 0;\n let m0 = null;\n let x0 = null;\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const nearest_medoid = this._nearest_medoid(x_j, j);\n const d_j = nearest_medoid.distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n // disance to new medoid\n const d_oj = this._get_distance(o, j, x_o, x_j);\n const {\n \"index_nearest\": n,\n \"distance_nearest\": d_n,\n \"distance_second\": d_s,\n } = this._nearest_medoid(x_o, o); \n this._clusters[o] = n; // cached values\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change\n if (d_oj < d_n) { // reassignment check\n deltaTD.forEach((d_i, i) => {\n if (n !== i) {\n deltaTD[i] = d_i + d_oj - d_n; // update loss change\n }\n });\n }\n });\n // choose best medoid i;\n const i = deltaTD\n .map((d, i) => [d, i])\n .sort((d1, d2) => d1[0] - d2[0])[0][1];\n const deltaTD_i = deltaTD[i];\n // store\n if (deltaTD_i < DeltaTD) {\n DeltaTD = deltaTD_i;\n m0 = i;\n x0 = j;\n }\n }\n });\n\n if (DeltaTD >= 0) {\n return true // break loop if DeltaTD >= 0\n }\n // swap roles of medoid m and non-medoid x;\n medoids[m0] = x0;\n this._cluster_medoids = medoids;\n return false\n } */\n\n /** Algorithm 2. FastPAM2: SWAP with multiple candidates\n * \n */\n _iteration() {\n const A = this._A;\n const K = this._K;\n const medoids = this._cluster_medoids;\n const cache = A.map((x_o, o) => this._nearest_medoid(x_o, o));\n // empty best candidates array\n const DeltaTD = new Array(K).fill(0);\n const xs = new Array(K).fill(null);\n A.forEach((x_j, j) => {\n if (medoids.findIndex(m => m === j) < 0) {\n const d_j = cache[j].distance_nearest; // distance to current medoid\n const deltaTD = new Array(K).fill(-d_j); // change if making j a medoid\n A.forEach((x_o, o) => {\n if (j === o) return;\n const d_oj = this._get_distance(o, j, x_o, x_j); // distance to new medoid\n const {\"index_nearest\": n, \"distance_nearest\": d_n, \"distance_second\": d_s} = cache[o]; // cached\n deltaTD[n] += Math.min(d_oj, d_s) - d_n; // loss change for x_o\n // Reassignment check\n if (d_oj < d_n) { \n // update loss change\n for (let i = 0; i < K; ++i) {\n if (i !== n) deltaTD[i] += d_oj - d_n;\n }\n }\n });\n // remember best swap for i;\n deltaTD\n .map((d, i) => [d, i])\n .filter(([d, i]) => d < DeltaTD[i])\n .forEach(([d, i]) => {\n if (d < DeltaTD[i]) {\n DeltaTD[i] = d;\n xs[i] = j;\n }\n })\n }\n })\n // stop if no improvements were found\n if (min(DeltaTD) >= 0) return true; \n\n // execute all improvements\n while (min(DeltaTD) < 0) {\n // swap roles of medoid m_i and non_medoid xs_i\n const i = DeltaTD\n .map((d, i) => [d, i])\n .sort(([a], [b]) => a - b)[0][1];\n if (medoids.filter(m => m == xs[i]).length == 0) {\n medoids[i] = xs[i];\n }\n // disable the swap just performed\n DeltaTD[i] = 0; \n // recompute TD for remaining swap candidates\n DeltaTD\n .map((d_j, j) => [d_j, j])\n .filter(([d_j]) => d_j < 0)\n .forEach(([_, j]) => {\n const x_j = A[j];\n let sum = 0;\n A.forEach((x_o, o) => {\n if (medoids.findIndex(m => m != j && m == o) >= 0) return;\n if (i == j) return;\n if (cache[o].index_nearest === medoids[j])\n sum += (Math.min(this._get_distance(o, j, x_o, x_j), cache[o].distance_second) - cache[o].distance_nearest); \n else {\n sum += (Math.min(this._get_distance(o, j, x_o, x_j) - cache[o].distance_nearest, 0));\n }\n });\n DeltaTD[j] = sum;\n })\n }\n this._cluster_medoids = medoids;\n return false;\n }\n\n _get_distance(i, j, x_i=null, x_j=null) {\n if (i === j) return 0;\n const D = this._distance_matrix;\n const A = this._A;\n const metric = this._metric;\n let d_ij = D.entry(i, j);\n if (d_ij === 0) {\n d_ij = metric(x_i || A[i], x_j || A[j]);\n D.set_entry(i, j, d_ij);\n D.set_entry(j, i, d_ij);\n }\n return d_ij;\n }\n\n _nearest_medoid(x_j, j) {\n const medoids = this._cluster_medoids;\n const A = this._A;\n const [nearest, second] = medoids\n .map((m, i) => {\n const x_m = A[m]; \n return [this._get_distance(j, m, x_j, x_m), i];\n })\n .sort((m1, m2) => m1[0] - m2[0]);\n \n return { \n \"distance_nearest\": nearest[0], \n \"index_nearest\": nearest[1],\n \"distance_second\": second[0],\n \"index_second\": second[1],\n };\n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_medoids) {\n if (!K) K = this._K;\n if (!cluster_medoids) cluster_medoids = this._get_random_medoids(K);\n const max_iter = this._max_iter;\n let finish = false;\n let i = 0\n do {\n finish = this._iteration();\n } while (!finish && ++i < max_iter)\n return this;\n }\n\n /**\n * Algorithm 3. FastPAM LAB: Linear Approximate BUILD initialization.\n * @param {number} K - number of clusters\n * \n */\n _get_random_medoids(K) {\n const N = this._N;\n const A = this._A;\n const indices = linspace(0, N - 1);\n const randomizer = this._randomizer;\n const n = Math.min(N, 10 + Math.ceil(Math.sqrt(N)));\n const TD = new Array(n).fill(Infinity);\n const medoids = [];\n // first medoid\n let TD0 = Infinity;\n let S = randomizer.choice(indices, n);\n for (let j = 0; j < n; ++j) {\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const x_o = A[S[o]];\n TD[j] += this._get_distance(j, o, x_j, x_o);\n }\n if (TD[j] < TD0) {\n TD0 = TD[j]; // smallest distance sum\n medoids.push(S_j);\n }\n }\n // other medoids\n for (let i = 1; i < K; ++i) {\n let DeltaTD = Infinity;\n S = randomizer.choice(indices.filter(index => medoids.findIndex(d => d === index) < 0), n);\n for (let j = 0; j < n; ++j) {\n let deltaTD = 0;\n const S_j = S[j];\n const x_j = A[S_j];\n for (let o = 0; o < n; ++o) {\n if (o === j) continue;\n const S_o = S[o];\n const x_o = A[S_o];\n let delta = this._get_distance(S_j, S_o, x_j, x_o) - min(medoids.map(m => this._get_distance(S_o, m, x_o)));\n if (delta < 0) {\n deltaTD = deltaTD + delta;\n }\n }\n // best reduction\n if (deltaTD < DeltaTD) {\n DeltaTD = deltaTD;\n medoids.push(S_j);\n }\n }\n TD0 += DeltaTD;\n }\n return medoids.slice(0, K);\n }\n \n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n/**\n * @class\n * @alias FASTMAP\n * @extends DR\n */\nexport class FASTMAP extends DR {\n /**\n * FastMap: a fast algorithm for indexing, data-mining and visualization of traditional and multimedia datasets\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias FASTMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the dimensionality of the projection.\n * @returns {FASTMAP}\n * @see {@link https://doi.org/10.1145/223784.223812}\n */\n constructor(X, parameters) {\n super(X, { d: 2, metric: euclidean, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n * Chooses two points which are the most distant in the actual projection.\n * @private\n * @param {Function} dist\n * @returns {Array} An array consisting of first index, second index, and distance between the two points.\n */\n _choose_distant_objects(dist) {\n const X = this.X;\n const N = X.shape[0];\n let a_index = (this._randomizer.random_int % N) - 1;\n let b_index = null;\n let max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n if (d_ai > max_dist) {\n max_dist = d_ai;\n b_index = i;\n }\n }\n max_dist = -Infinity;\n for (let i = 0; i < N; ++i) {\n const d_bi = dist(b_index, i);\n if (d_bi > max_dist) {\n max_dist = d_bi;\n a_index = i;\n }\n }\n return [a_index, b_index, max_dist];\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} The {@link d}-dimensional projection of the data matrix {@link X}.\n */\n transform() {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric } = this._parameters;\n const Y = new Matrix(N, d, 0);\n let dist = (a, b) => metric(X.row(a), X.row(b));\n\n for (let _col = 0; _col < d; ++_col) {\n let old_dist = dist;\n // choose pivot objects\n const [a_index, b_index, d_ab] = this._choose_distant_objects(dist);\n if (d_ab !== 0) {\n // project the objects on the line (O_a, O_b)\n for (let i = 0; i < N; ++i) {\n const d_ai = dist(a_index, i);\n const d_bi = dist(b_index, i);\n const y_i = (d_ai ** 2 + d_ab ** 2 - d_bi ** 2) / (2 * d_ab);\n Y.set_entry(i, _col, y_i);\n }\n // consider the projections of the objects on a\n // hyperplane perpendicluar to the line (a, b);\n // the distance function D'() between two\n // projections is given by Eq.4\n dist = (a, b) => Math.sqrt(old_dist(a, b) ** 2 - (Y.entry(a, _col) - Y.entry(b, _col)) ** 2);\n }\n }\n // return embedding.\n this.Y = Y;\n return this.projection;\n }\n}\n","import { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { Matrix } from \"../matrix/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { DR } from \"./DR.js\";\nimport euclidean from \"../metrics/euclidean.js\";\n\n/**\n * @class\n * @alias ISOMAP\n * @extends DR\n */\nexport class ISOMAP extends DR {\n /**\n * Isometric feature mapping (ISOMAP).\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias ISOMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link ISOMAP} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2319}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(this._parameters.neighbors ?? Math.max(Math.floor(this.X.shape[0] / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const X = this.X;\n const rows = this._N;\n const { d, metric, eig_args, neighbors } = this._parameters;\n // TODO: make knn extern and parameter for constructor or transform?\n const D = new Matrix();\n D.shape = [rows, rows, (i, j) => (i <= j ? metric(X.row(i), X.row(j)) : D.entry(j, i))];\n const kNearestNeighbors = [];\n for (let i = 0; i < rows; ++i) {\n const row = [];\n for (let j = 0; j < rows; ++j) {\n row.push({\n index: j,\n distance: D.entry(i, j),\n });\n }\n const H = new Heap(row, (d) => d.distance, \"min\");\n kNearestNeighbors.push(H.toArray().slice(1, neighbors + 1));\n }\n\n /*D = dijkstra(kNearestNeighbors);*/\n // compute shortest paths\n // TODO: make extern\n /** @see {@link https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm} */\n const G = new Matrix(rows, rows, (i, j) => {\n const other = kNearestNeighbors[i].find((n) => n.index === j);\n return other ? other.distance : Infinity;\n });\n\n for (let i = 0; i < rows; ++i) {\n for (let j = 0; j < rows; ++j) {\n for (let k = 0; k < rows; ++k) {\n G.set_entry(i, j, Math.min(G.entry(i, j), G.entry(i, k) + G.entry(k, j)));\n }\n }\n }\n\n let ai_ = new Float64Array(rows);\n let a_j = new Float64Array(rows);\n let a__ = 0;\n const A = new Matrix(rows, rows, (i, j) => {\n let val = G.entry(i, j);\n val = val === Infinity ? 0 : val;\n ai_[i] += val;\n a_j[j] += val;\n a__ += val;\n return val;\n });\n\n ai_ = ai_.map((v) => v / rows);\n a_j = a_j.map((v) => v / rows);\n a__ /= rows ** 2;\n const B = new Matrix(rows, rows, (i, j) => A.entry(i, j) - ai_[i] - a_j[j] + a__);\n\n // compute d eigenvectors\n const { eigenvectors: V } = simultaneous_poweriteration(B, d, eig_args);\n this.Y = Matrix.from(V).transpose();\n // return embedding\n return this.projection;\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Randomizer } from \"../util/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\nimport { linspace } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias KMeans\n */\nexport class KMeans {\n /**\n * @constructor\n * @memberof module:clustering\n * @alias KMeans\n * @todo needs restructuring. \n * @param {Matrix} matrix \n * @param {Numbers} K \n * @param {Function} [metric = euclidean] \n * @param {Number} [seed = 1987]\n * @param {Boolean} [init = true]\n * @returns {KMeans}\n */\n constructor(matrix, K, metric = euclidean, seed=1987, init = true) {\n this._metric = metric;\n this._matrix = matrix;\n this._K = K;\n const [N, D] = matrix.shape;\n this._N = N;\n this._D = D;\n if (K > N) K = N;\n this._randomizer = new Randomizer(seed);\n this._clusters = new Array(N).fill(undefined);\n this._cluster_centroids = this._get_random_centroids(K);\n if (init) this.init(K, this._cluster_centroids);\n return this;\n }\n\n /**\n * @returns {Array} - Array of clusters with the indices of the rows in given {@link matrix}. \n */\n get_clusters() {\n const K = this._K;\n const clusters = this._clusters;\n const result = new Array(K).fill().map(() => new Array());\n clusters.forEach((c, i) => result[c].push(i));\n return result;\n }\n\n /**\n * @private\n * @param {Array} points \n * @param {Array} candidates \n */\n _furthest_point(points, candidates) {\n const A = this._matrix;\n const metric = this._metric;\n let i = points.length;\n let H = Heap.heapify(\n candidates, \n (d) => {\n const Ad = A.row(d)\n let sum = 0;\n for (let j = 0; j < i; ++j) {\n sum += metric(Ad, points[j])\n }\n return sum;\n }, \n \"max\"\n )\n return H.pop().element;\n }\n\n _get_random_centroids(K) {\n const N = this._N;\n const randomizer = this._randomizer;\n const A = this._matrix;\n const cluster_centroids = new Array(K).fill()\n const indices = linspace(0, N - 1);\n const random_point = randomizer.random_int % (N - 1);\n cluster_centroids[0] = A.row(random_point);\n const init_points = [random_point];\n const sample_size = Math.floor((N - K) / K);// / K\n for (let i = 1; i < K; ++i) {\n // sampling + kmeans++ improvement?\n const sample = randomizer.choice(indices.filter(d => init_points.indexOf(d) == -1), sample_size);\n const furthest_point = this._furthest_point(cluster_centroids.slice(0, i), sample);\n init_points.push(furthest_point);\n cluster_centroids[i] = A.row(furthest_point);\n }\n return cluster_centroids;\n }\n\n _iteration(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const metric = this._metric;\n const clusters = this._clusters;\n let clusters_changed = false;\n // find nearest cluster centroid.\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i)\n let min_dist = Infinity;\n let min_cluster = null;\n for (let j = 0; j < K; ++j) {\n let d = metric(cluster_centroids[j], Ai);\n if (d < min_dist) {\n min_dist = d;\n min_cluster = j; \n }\n }\n if (clusters[i] !== min_cluster) {\n clusters_changed = true;\n }\n clusters[i] = min_cluster;\n }\n // update cluster centroid\n // reset cluster centroids to 0\n for (let i = 0; i < K; ++i) {\n const centroid = cluster_centroids[i];\n for (let j = 0; j < D; ++j) {\n centroid[j] = 0;\n }\n }\n // compute centroid\n this._compute_centroid(cluster_centroids);\n\n return { \n \"clusters_changed\": clusters_changed,\n \"cluster_centroids\": cluster_centroids\n };\n }\n\n _compute_centroid(cluster_centroids) {\n const K = cluster_centroids.length;\n const N = this._N;\n const D = this._D;\n const A = this._matrix;\n const clusters = this._clusters;\n const cluster_counter = new Array(K).fill(0);\n\n for (let i = 0; i < N; ++i) {\n const Ai = A.row(i);\n const ci = clusters[i];\n cluster_counter[ci]++;\n const centroid = cluster_centroids[ci];\n for (let j = 0; j < D; ++j) {\n centroid[j] += Ai[j];\n }\n }\n for (let i = 0; i < K; ++i) {\n const n = cluster_counter[i];\n cluster_centroids[i] = cluster_centroids[i].map(c => c / n);\n }\n \n }\n\n /**\n * Computes {@link K} clusters out of the {@link matrix}.\n * @param {Number} K - number of clusters.\n */\n init(K, cluster_centroids) {\n if (!K) K = this._K;\n if (!cluster_centroids) cluster_centroids = this._get_random_centroids(K);\n let clusters_changed = false;\n do {\n const iteration_result = this._iteration(cluster_centroids)\n cluster_centroids = iteration_result.cluster_centroids;\n clusters_changed = iteration_result.clusters_changed;\n } while (clusters_changed)\n }\n \n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LDA\n * @extends DR\n */\nexport class LDA extends DR {\n /**\n * Linear Discriminant Analysis.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LDA\n * @param {Matrix} X - The high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Array} parameters.labels - The labels / classes for each data point.\n * @param {number} [parameters.d = 2] - The dimensionality of the projection.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://onlinelibrary.wiley.com/doi/10.1111/j.1469-1809.1936.tb02137.x}\n */\n constructor(X, parameters) {\n super(X, { labels: null, d: 2, seed: 1212, eig_args: {} }, parameters);\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, cols] = X.shape;\n const { d, labels, eig_args } = this._parameters;\n if (labels === null || labels.length != rows) {\n throw new Error(\"LDA needs parameter label to every datapoint to work!\");\n }\n const unique_labels = {};\n let label_id = 0;\n labels.forEach((l, i) => {\n if (l in unique_labels) {\n unique_labels[l].count++;\n unique_labels[l].rows.push(X.row(i));\n } else {\n unique_labels[l] = {\n id: label_id++,\n count: 1,\n rows: [X.row(i)],\n };\n }\n });\n\n // create X_mean and vector means;\n const X_mean = X.mean;\n const V_mean = new Matrix(label_id, cols);\n for (const label in unique_labels) {\n const V = Matrix.from(unique_labels[label].rows);\n const v_mean = V.meanCols;\n for (let j = 0; j < cols; ++j) {\n V_mean.set_entry(unique_labels[label].id, j, v_mean[j]);\n }\n }\n // scatter_between\n let S_b = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j] - X_mean);\n const N = unique_labels[label].count;\n S_b = S_b.add(m.dot(m.transpose()).mult(N));\n }\n\n // scatter_within\n let S_w = new Matrix(cols, cols);\n for (const label in unique_labels) {\n const v = V_mean.row(unique_labels[label].id);\n const m = new Matrix(cols, 1, (j) => v[j]);\n const R = unique_labels[label].rows;\n for (let i = 0, n = unique_labels[label].count; i < n; ++i) {\n const row_v = new Matrix(cols, 1, (j, _) => R[i][j] - m.entry(j, 0));\n S_w = S_w.add(row_v.dot(row_v.transpose()));\n }\n }\n\n let { eigenvectors: V } = simultaneous_poweriteration(S_w.inverse().dot(S_b), d, eig_args);\n V = Matrix.from(V).transpose();\n this.Y = X.dot(V);\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { k_nearest_neighbors } from \"../matrix/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LLE\n * @extends DR\n */\nexport class LLE extends DR {\n /**\n * Locally Linear Embedding.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LLE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} neighbors - the label / class of each data point.\n * @param {Number} [d = 2] - the dimensionality of the projection.\n * @param {Function} [metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [seed = 1212] - the dimensionality of the projection.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://doi.org/10.1126/science.290.5500.2323}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const rows = this._N;\n const cols = this._D;\n const { neighbors, d, eig_args, metric } = this._parameters;\n const nN = k_nearest_neighbors(X, neighbors, metric);\n const O = new Matrix(neighbors, 1, 1);\n const W = new Matrix(rows, rows);\n\n for (let row = 0; row < rows; ++row) {\n const nN_row = nN[row];\n const Z = new Matrix(neighbors, cols, (i, j) => X.entry(nN_row[i].j, j) - X.entry(row, j));\n const C = Z.dot(Z.T);\n if (neighbors > cols) {\n const C_trace = neumair_sum(C.diag) / 1000;\n for (let j = 0; j < neighbors; ++j) {\n C.set_entry(j, j, C.entry(j, j) + C_trace);\n }\n }\n // reconstruct;\n let w = Matrix.solve_CG(C, O, this._randomizer);\n w = w.divide(w.sum);\n for (let j = 0; j < neighbors; ++j) {\n W.set_entry(row, nN_row[j].j, w.entry(j, 0));\n }\n }\n // comp embedding\n const I = new Matrix(rows, rows, \"identity\");\n const IW = I.sub(W);\n const M = IW.T.dot(IW);\n const { eigenvectors: V } = simultaneous_poweriteration(M.T.inverse(), d + 1, eig_args);\n this.Y = Matrix.from(V.slice(1, 1 + d)).T;\n\n // return embedding\n return this.projection;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { DR } from \"./DR.js\";\nimport { MDS } from \"./MDS.js\";\nimport { KMedoids } from \"../clustering/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\n/**\n * @class\n * @alias LSP\n * @extends DR\n */\nexport class LSP extends DR {\n /**\n * Least Squares Projection.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LSP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.neighbors = Math.max(Math.floor(N / 10), 2)] - number of neighbors to consider.\n * @param {Number} [parameters.control_points = Math.ceil(Math.sqrt(N))] - number of controlpoints\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {LSP}\n * @see {@link https://ieeexplore.ieee.org/document/4378370}\n * @todo accept precomputed distance matrix.\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, control_points: undefined, d: 2, metric: euclidean, seed: 1212 }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n this.parameter(\"control_points\", Math.min(parameters.control_points ?? Math.ceil(Math.sqrt(this._N)), this._N - 1));\n this._is_initialized = false;\n return this;\n }\n\n /**\n *\n * @param {DR} DR - method used for position control points.\n * @param {Object} DR_parameters - Object containing parameters for the DR method which projects the control points\n * @returns {LSP}\n */\n init(DR = MDS, DR_parameters = {}, KNN = BallTree) {\n if (this._is_initialized) return this;\n const X = this.X;\n const N = this._N;\n const K = this.parameter(\"neighbors\");\n const d = this.parameter(\"d\");\n const seed = this.parameter(\"seed\");\n const metric = this.parameter(\"metric\");\n DR_parameters = Object.assign({d, metric, seed }, DR_parameters);\n const nc = this.parameter(\"control_points\");\n const control_points = new KMedoids(X, nc, null, metric).get_clusters().medoids;\n const C = new Matrix(nc, N, \"zeros\");\n control_points.forEach((c_i, i) => {\n C.set_entry(i, c_i, 1);\n });\n const Y_C = new DR(Matrix.from(control_points.map((c_i) => X.row(c_i))), DR_parameters).transform();\n\n const XA = X.to2dArray;\n const knn = new KNN(XA, metric);\n const L = new Matrix(N, N, \"I\");\n const alpha = -1 / K;\n XA.forEach((x_i, i) => {\n for (const { index: j } of knn.search(x_i, K).iterate()) {\n if (i === j) continue;\n L.set_entry(i, j, alpha);\n }\n });\n const A = L.concat(C, \"vertical\");\n\n const z = new Matrix(N, d, \"zeros\");\n const b = z.concat(Y_C, \"vertical\");\n\n this._A = A;\n this._b = b;\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Computes the projection.\n * @returns {Matrix} Returns the projection.\n */\n transform() {\n this.check_init();\n const A = this._A;\n const AT = A.T;\n const b = this._b;\n const ATA = AT.dot(A);\n const ATb = AT.dot(b);\n this.Y = Matrix.solve_CG(ATA, ATb, this._randomizer);\n return this.projection;\n }\n}\n","import { Matrix, k_nearest_neighbors } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { simultaneous_poweriteration } from \"../linear_algebra/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias LTSA\n * @extends DR\n */\nexport class LTSA extends DR {\n /**\n * Local Tangent Space Alignment\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias LTSA\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} parameters.neighbors - the number of neighbors {@link LTSA} should use to project the data.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @param {Number} [parameters.eig_args] - Parameters for the eigendecomposition algorithm.\n * @see {@link https://epubs.siam.org/doi/abs/10.1137/S1064827502419154}\n */\n constructor(X, parameters) {\n super(X, { neighbors: undefined, d: 2, metric: euclidean, seed: 1212, eig_args: {} }, parameters);\n this.parameter(\"neighbors\", Math.min(parameters.neighbors ?? Math.max(Math.floor(this._N / 10), 2), this._N - 1));\n if (!this._parameters.eig_args.hasOwnProperty(\"seed\")) {\n this._parameters.eig_args.seed = this._randomizer;\n }\n if (this._D <= this.parameter(\"d\")) {\n throw new Error(`Dimensionality of X (D = ${this._D}) must be greater than the required dimensionality of the result (d = ${this.parameter(\"d\")})!`);\n }\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality {@link d}.\n */\n transform() {\n const X = this.X;\n const [rows, D] = X.shape;\n const { d, neighbors, metric, eig_args } = this._parameters;\n // 1.1 determine k nearest neighbors\n const nN = k_nearest_neighbors(X, neighbors, metric);\n // center matrix\n const O = new Matrix(D, D, \"center\");\n const B = new Matrix(rows, rows, 0);\n\n for (let row = 0; row < rows; ++row) {\n // 1.2 compute the d largest eigenvectors of the correlation matrix\n const I_i = [row, ...nN[row].map((n) => n.j)];\n let X_i = Matrix.from(I_i.map((n) => X.row(n)));\n // center X_i\n X_i = X_i.dot(O);\n // correlation matrix\n const C = X_i.dot(X_i.transpose());\n const { eigenvectors: g } = simultaneous_poweriteration(C, d, eig_args);\n //g.push(linspace(0, k).map(_ => 1 / Math.sqrt(k + 1)));\n const G_i_t = Matrix.from(g);\n // 2. Constructing alignment matrix\n const W_i = G_i_t.transpose()\n .dot(G_i_t)\n .add(1 / Math.sqrt(neighbors + 1));\n for (let i = 0; i < neighbors + 1; ++i) {\n for (let j = 0; j < neighbors + 1; ++j) {\n B.set_entry(I_i[i], I_i[j], B.entry(I_i[i], I_i[j]) - (i === j ? 1 : 0) + W_i.entry(i, j));\n }\n }\n }\n\n // 3. Aligning global coordinates\n const { eigenvectors: Y } = simultaneous_poweriteration(B, d + 1, eig_args);\n this.Y = Matrix.from(Y.slice(1)).transpose();\n\n // return embedding\n return this.projection;\n }\n}\n","import { euclidean } from \"../metrics/index.js\";\nimport { Heap } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias OPTICS\n */\nexport class OPTICS {\n /**\n * **O**rdering **P**oints **T**o **I**dentify the **C**lustering **S**tructure.\n * @constructor\n * @memberof module:clustering\n * @alias OPTICS\n * @todo needs restructuring. \n * @param {Matrix} matrix - the data.\n * @param {Number} epsilon - the minimum distance which defines whether a point is a neighbor or not.\n * @param {Number} min_points - the minimum number of points which a point needs to create a cluster. (Should be higher than 1, else each point creates a cluster.)\n * @param {Function} [metric = euclidean] - the distance metric which defines the distance between two points of the {@link matrix}.\n * @returns {OPTICS}\n * @see {@link https://www.dbs.ifi.lmu.de/Publikationen/Papers/OPTICS.pdf}\n * @see {@link https://en.wikipedia.org/wiki/OPTICS_algorithm}\n */\n constructor(matrix, epsilon, min_points, metric = euclidean) {\n this._matrix = matrix;\n this._epsilon = epsilon;\n this._min_points = min_points;\n this._metric = metric;\n\n this._ordered_list = [];\n this._clusters = [];\n this._DB = new Array(matrix.shape[0]).fill();\n this.init();\n return this;\n }\n\n /**\n * Computes the clustering.\n */\n init() {\n const ordered_list = this._ordered_list;\n const matrix = this._matrix;\n const N = matrix.shape[0];\n const DB = this._DB;\n const clusters = this._clusters;\n let cluster_index = this._cluster_index = 0;\n\n for (let i = 0; i < N; ++i) {\n DB[i] = {\n \"element\": matrix.row(i),\n \"index\": i,\n \"reachability_distance\": undefined,\n \"processed\": false,\n }\n }\n for (const p of DB) {\n if (p.processed) continue;\n p.neighbors = this._get_neighbors(p);\n p.processed = true;\n clusters.push([p.index])\n cluster_index = clusters.length - 1;\n ordered_list.push(p);\n if (this._core_distance(p) != undefined) {\n const seeds = new Heap(null, d => d.reachability_distance, \"min\")\n this._update(p, seeds);\n this._expand_cluster(seeds, clusters[cluster_index]);\n }\n }\n return this;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Array} An array consisting of the {@link epsilon}-neighborhood of {@link p}.\n */\n _get_neighbors(p) {\n if (\"neighbors\" in p) return p.neighbors;\n const DB = this._DB;\n const metric = this._metric;\n const epsilon = this._epsilon;\n const neighbors = [];\n for (const q of DB) {\n if (q.index == p.index) continue;\n if (metric(p.element, q.element) < epsilon) {\n neighbors.push(q);\n }\n }\n return neighbors;\n }\n\n /**\n * \n * @private\n * @param {Object} p - a point of {@link matrix}.\n * @returns {Number} The distance to the {@link min_points}-th nearest point of {@link p}, or undefined if the {@link epsilon}-neighborhood has fewer elements than {@link min_points}.\n */\n _core_distance(p) {\n const min_points = this._min_points;\n const metric = this._metric;\n if (p.neighbors && p.neighbors.length <= min_points) {\n return undefined;\n }\n return metric(p.element, p.neighbors[min_points].element);\n }\n\n /**\n * Updates the reachability distance of the points.\n * @private\n * @param {Object} p \n * @param {Heap} seeds \n */\n _update(p, seeds) {\n const metric = this._metric;\n const core_distance = this._core_distance(p);\n const neighbors = this._get_neighbors(p);//p.neighbors;\n for (const q of neighbors) {\n if (q.processed) continue;\n const new_reachability_distance = Math.max(core_distance, metric(p.element, q.element));\n //if (q.reachability_distance == undefined) { // q is not in seeds\n if (seeds.raw_data().findIndex(d => d.element == q) < 0) {\n q.reachability_distance = new_reachability_distance;\n seeds.push(q);\n } else { // q is in seeds\n if (new_reachability_distance < q.reachability_distance) {\n q.reachability_distance = new_reachability_distance;\n seeds = Heap.heapify(seeds.data(), d => d.reachability_distance, \"min\"); // seeds change key =/\n }\n }\n }\n }\n\n /**\n * Expands the {@link cluster} with points in {@link seeds}.\n * @private\n * @param {Heap} seeds \n * @param {Array} cluster \n */\n _expand_cluster(seeds, cluster) {\n const ordered_list = this._ordered_list;\n while (!seeds.empty) {\n const q = seeds.pop().element;\n q.neighbors = this._get_neighbors(q);\n q.processed = true;\n cluster.push(q.index);\n ordered_list.push(q);\n if (this._core_distance(q) != undefined) {\n this._update(q, seeds);\n this._expand_cluster(seeds, cluster);\n }\n }\n }\n\n /**\n * Returns an array of clusters.\n * @returns {Array} Array of clusters with the indices of the rows in given {@link matrix}.\n */\n get_clusters() {\n const clusters = [];\n const outliers = [];\n const min_points = this._min_points;\n for (const cluster of this._clusters) {\n if (cluster.length < min_points) {\n outliers.push(...cluster);\n } else {\n clusters.push(cluster);\n }\n }\n clusters.push(outliers);\n return clusters;\n }\n\n /**\n * @returns {Array} Returns an array, where the ith entry defines the cluster affirmation of the ith point of {@link matrix}. (-1 stands for outlier)\n */\n get_cluster_affirmation() {\n const N = this._matrix.shape[0];\n const result = new Array(N).fill();\n const clusters = this.get_clusters();\n for (let i = 0, n = clusters.length; i < n; ++i) {\n const cluster = clusters[i]\n for (const index of cluster) {\n result[index] = (i < n - 1) ? i : -1;\n }\n }\n return result;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { PCA, MDS } from \"./index.js\";\nimport { distance_matrix } from \"../matrix/index.js\";\n\n/**\n * @class\n * @alias SAMMON\n * @extends DR\n */\nexport class SAMMON extends DR {\n /**\n * SAMMON's Mapping\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias SAMMON\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {\"PCA\"|\"MDS\"|\"random\"} [parameters.init = \"random\"] - Either \"PCA\" or \"MDS\", with which SAMMON initialiates the projection. With \"random\" a random matrix gets used as starting point.\n * @param {Object} [parameters.init_parameters] - Parameters for the {@link init}-DR method.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {SAMMON}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { magic: 0.1, d: 2, metric: euclidean, seed: 1212, init_DR: \"random\", init_parameters: {} }, parameters);\n return this;\n }\n\n /**\n * initializes the projection.\n * @private\n */\n init() {\n const N = this.X.shape[0];\n const { d, metric, init_DR: init_DR, init_parameters: DR_parameters } = this._parameters;\n if (init_DR === \"random\") {\n const randomizer = this._randomizer;\n this.Y = new Matrix(N, d, () => randomizer.random);\n } else if ([\"PCA\", \"MDS\"].includes(init_DR)) {\n this.Y = Matrix.from(init_DR == \"PCA\" ? PCA.transform(this.X, DR_parameters) : MDS.transform(this.X, DR_parameters));\n } else {\n throw new Error('init_DR needs to be either \"random\" or a DR method!')\n }\n this.distance_matrix = metric == \"precomputed\" ? Matrix.from(this.X) : distance_matrix(this.X, metric);\n return this;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Matrix|Array} - The projection of {@link X}.\n */\n transform(max_iter = 200) {\n if (!this._is_initialized) this.init();\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n }\n return this.projection;\n }\n\n /**\n * Transforms the inputdata {@link X} to dimenionality 2.\n * @param {Number} [max_iter=200] - Maximum number of iteration steps.\n * @returns {Generator} - A generator yielding the intermediate steps of the projection of {@link X}.\n */\n *generator(max_iter = 200) {\n if (!this._is_initialized) this.init();\n\n for (let j = 0; j < max_iter; ++j) {\n this._step();\n yield this.projection;\n }\n\n return this.projection;\n }\n\n _step() {\n const MAGIC = this.parameter(\"magic\");\n const D = this.distance_matrix;\n const N = this.X.shape[0];\n const { d, metric } = this._parameters;\n let Y = this.Y;\n\n let G = new Matrix(N, d, 0);\n\n let sum = new Float64Array(d);\n for (let i = 0; i < N; ++i) {\n let e1 = new Float64Array(d);\n let e2 = new Float64Array(d);\n const Yi = Y.row(i);\n for (let j = 0; j < N; ++j) {\n if (i === j) continue;\n const Yj = Y.row(j);\n const delta = new Float64Array(d);\n for (let k = 0; k < d; ++k) {\n delta[k] = Yi[k] - Yj[k];\n }\n const dY = metric(Yi, Yj);\n const dX = D.entry(i, j);\n const dq = dX - dY;\n const dr = Math.max(dX * dY, 1e-2);\n for (let k = 0; k < d; ++k) {\n e1[k] += (delta[k] * dq) / dr;\n e2[k] += (dq - (Math.pow(delta[k], 2) * (1 + dq / dY)) / dY) / dr;\n }\n }\n for (let k = 0; k < d; ++k) {\n const val = Y.entry(i, k) + ((MAGIC * e1[k]) / Math.abs(e2[k]) || 0);\n G.set_entry(i, k, val);\n sum[k] += val;\n }\n }\n for (let k = 0; k < d; ++k) {\n sum[k] /= N;\n }\n\n for (let i = 0; i < N; ++i) {\n for (let k = 0; k < d; ++k) {\n Y.set_entry(i, k, G.entry(i, k) - sum[k]);\n }\n }\n return Y;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TSNE\n * @extends DR\n */\nexport class TSNE extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TSNE\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.perplexity = 50] - perplexity.\n * @param {Number} [parameters.epsilon = 10] - learning parameter.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function|\"precomputed\"} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TSNE}\n */\n constructor(X, parameters) {\n super(X, { perplexity: 50, epsilon: 10, d: 2, metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._iter = 0;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => this._randomizer.random);\n return this;\n }\n\n /**\n *\n * @param {Matrix} distance_matrix - accepts a precomputed distance matrix\n * @returns {TSNE}\n */\n init() {\n // init\n const Htarget = Math.log(this.parameter(\"perplexity\"));\n const N = this._N;\n const D = this._D;\n const {metric} = this._parameters;\n const X = this.X;\n let Delta;\n if (metric ==\"precomputed\") {\n Delta = druid.Matrix.from(X);\n } else {\n Delta = new Matrix(N, N);\n for (let i = 0; i < N; ++i) {\n const X_i = X.row(i);\n for (let j = i + 1; j < N; ++j) {\n const distance = metric(X_i, X.row(j));\n Delta.set_entry(i, j, distance);\n Delta.set_entry(j, i, distance);\n }\n }\n }\n\n const P = new Matrix(N, N, \"zeros\");\n\n this._ystep = new Matrix(N, D, \"zeros\");\n this._gains = new Matrix(N, D, 1);\n\n // search for fitting sigma\n let prow = new Float64Array(N)\n const tol = 1e-4;\n const maxtries = 50;\n for (let i = 0; i < N; ++i) {\n let betamin = -Infinity;\n let betamax = Infinity;\n let beta = 1;\n let done = false;\n\n let num = 0;\n while (!done) {\n let psum = 0;\n for (let j = 0; j < N; ++j) {\n let pj = Math.exp(-Delta.entry(i, j) * beta);\n if (i === j) pj = 0;\n prow[j] = pj;\n psum += pj;\n }\n let Hhere = 0;\n for (let j = 0; j < N; ++j) {\n let pj = psum === 0 ? 0 : prow[j] / psum;\n prow[j] = pj;\n if (pj > 1e-7) {\n Hhere -= pj * Math.log(pj);\n }\n }\n if (Hhere > Htarget) {\n betamin = beta;\n beta = betamax === Infinity ? beta * 2 : (beta + betamax) / 2;\n } else {\n betamax = beta;\n beta = betamin === -Infinity ? beta / 2 : (beta + betamin) / 2;\n }\n ++num;\n if (Math.abs(Hhere - Htarget) < tol) done = true;\n if (num >= maxtries) done = true;\n }\n\n for (let j = 0; j < N; ++j) {\n P.set_entry(i, j, prow[j]);\n }\n }\n\n //compute probabilities\n const Pout = new Matrix(N, N, \"zeros\");\n const N2 = N * 2;\n for (let i = 0; i < N; ++i) {\n for (let j = i; j < N; ++j) {\n const p = Math.max((P.entry(i, j) + P.entry(j, i)) / N2, 1e-100);\n Pout.set_entry(i, j, p);\n Pout.set_entry(j, i, p);\n }\n }\n this._P = Pout;\n return this;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n transform(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=500] - number of iterations.\n * @yields {Matrix|Array} - the projection.\n */\n *generator(iterations = 500) {\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * performs a optimization step\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const P = this._P;\n const ystep = this._ystep;\n const gains = this._gains;\n const N = this._N;\n const { d: dim, epsilon} = this._parameters;\n let Y = this.Y;\n\n //calc cost gradient;\n const pmul = iter < 100 ? 4 : 1;\n\n // compute Q dist (unnormalized)\n const Qu = new Matrix(N, N, \"zeros\");\n let qsum = 0;\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n let dsum = 0;\n for (let d = 0; d < dim; ++d) {\n const dhere = Y.entry(i, d) - Y.entry(j, d);\n dsum += dhere * dhere;\n }\n const qu = 1 / (1 + dsum);\n Qu.set_entry(i, j, qu);\n Qu.set_entry(j, i, qu);\n qsum += 2 * qu;\n }\n }\n\n // normalize Q dist\n const Q = new Matrix(N, N, 0);\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n const val = Math.max(Qu.entry(i, j) / qsum, 1e-100);\n Q.set_entry(i, j, val);\n Q.set_entry(j, i, val);\n }\n }\n\n const grad = new Matrix(N, dim, \"zeros\");\n for (let i = 0; i < N; ++i) {\n for (let j = 0; j < N; ++j) {\n const premult = 4 * (pmul * P.entry(i, j) - Q.entry(i, j)) * Qu.entry(i, j);\n for (let d = 0; d < dim; ++d) {\n grad.set_entry(i, d, grad.entry(i, d) + premult * (Y.entry(i, d) - Y.entry(j, d)));\n }\n }\n }\n\n // perform gradient step\n let ymean = new Float64Array(dim);\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const gid = grad.entry(i, d);\n const sid = ystep.entry(i, d);\n const gainid = gains.entry(i, d);\n\n let newgain = Math.sign(gid) === Math.sign(sid) ? gainid * 0.8 : gainid + 0.2;\n if (newgain < 0.01) newgain = 0.01;\n gains.set_entry(i, d, newgain);\n\n const momval = iter < 250 ? 0.5 : 0.8;\n const newsid = momval * sid - epsilon * newgain * gid;\n ystep.set_entry(i, d, newsid);\n\n Y.set_entry(i, d, Y.entry(i, d) + newsid);\n ymean[d] += Y.entry(i, d);\n }\n }\n\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < 2; ++d) {\n Y.set_entry(i, d, Y.entry(i, d) - ymean[d] / N);\n }\n }\n\n return this.Y;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { DR } from \"./DR.js\";\nimport { DisjointSet } from \"../datastructure/index.js\";\n\n/**\n * @class\n * @alias TopoMap\n * @memberof module:dimensionality_reduction\n * @extends DR\n */\nexport class TopoMap extends DR {\n /**\n * TopoMap: A 0-dimensional Homology Preserving Projection of High-Dimensional Data.\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TopoMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TopoMap}\n * @see {@link https://arxiv.org/pdf/2009.01512.pdf}\n */\n constructor(X, parameters) {\n super(X, { metric: euclidean, seed: 1212 }, parameters);\n [this._N, this._D] = this.X.shape;\n this._distance_matrix = new Matrix(this._N, this._N, 0);\n return this;\n }\n\n /**\n * @private\n */\n __lazy_distance_matrix(i, j, metric) {\n const D = this._distance_matrix;\n const X = this.X;\n const D_ij = D.entry(i, j);\n if (D_ij === 0) {\n let dist = metric(X.row(i), X.row(j));\n D.set_entry(i, j, dist);\n D.set_entry(j, i, dist);\n return dist;\n }\n return D_ij;\n }\n\n /**\n * Computes the minimum spanning tree, using a given metric\n * @private\n * @param {Function} metric\n * @see {@link https://en.wikipedia.org/wiki/Kruskal%27s_algorithm}\n */\n _make_minimum_spanning_tree(metric = euclidean) {\n const N = this._N;\n const X = [...this.X];\n\n let disjoint_set = new DisjointSet(X);\n const F = [];\n let E = [];\n for (let i = 0; i < N; ++i) {\n for (let j = i + 1; j < N; ++j) {\n E.push([i, j, this.__lazy_distance_matrix(i, j, metric)]);\n }\n }\n E = E.sort((a, b) => a[2] - b[2]);\n\n for (const [u, v, w] of E) {\n const set_u = disjoint_set.find(X[u]);\n const set_v = disjoint_set.find(X[v]);\n if (set_u !== set_v) {\n F.push([u, v, w]);\n disjoint_set.union(set_u, set_v);\n }\n }\n\n return F.sort((a, b) => a[2] - b[2]);\n }\n\n /**\n * initializes TopoMap. Sets all projcted points to zero, and computes a minimum spanning tree.\n */\n init() {\n const { metric} = this._parameters\n this.Y = new Matrix(this._N, 2, 0);\n this._Emst = this._make_minimum_spanning_tree(metric);\n this._is_initialized = true;\n return this;\n }\n\n /**\n * Returns true if Point C is left of line AB.\n * @private\n * @param {Array} PointA - Point A of line AB\n * @param {Array} PointB - Point B of line AB\n * @param {Array} PointC - Point C\n * @returns {Boolean}\n */\n __hull_cross([ax, ay], [bx, by], [sx, sy]) {\n return (bx - ax) * (sy - ay) - (by - ay) * (sx - ax) <= 0;\n }\n\n /**\n * Computes the convex hull of the set of Points S\n * @private\n * @param {Array} S - Set of Points.\n * @see {@link https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain#JavaScript}\n * @returns {Array} convex hull of S. Starts at the bottom-most point and continues counter-clockwise.\n */\n __hull(S) {\n const points = S.sort(([x1, y1], [x2, y2]) => y1 - y2 || x1 - x2);\n const N = points.length;\n if (N <= 2) return points;\n\n const lower = [];\n for (let i = 0; i < N; ++i) {\n while (lower.length >= 2 && this.__hull_cross(lower[lower.length - 2], lower[lower.length - 1], points[i])) {\n lower.pop();\n }\n lower.push(points[i]);\n }\n const upper = [];\n for (let i = N - 1; i >= 0; --i) {\n while (upper.length >= 2 && this.__hull_cross(upper[upper.length - 2], upper[upper.length - 1], points[i])) {\n upper.pop();\n }\n upper.push(points[i]);\n }\n upper.pop();\n lower.pop();\n return lower.concat(upper);\n }\n\n /**\n * Finds the angle to rotate Point A and B to lie on a line parallel to the x-axis.\n * @private\n * @param {Array} PointA\n * @param {Array} PointB\n * @return {Object} Object containing the sinus- and cosinus-values for a rotation.\n */\n __findAngle([p1x, p1y], [p2x, p2y]) {\n const n = euclidean([p1x, p1y], [p2x, p2y]);\n if (n === 0)\n return {\n sin: 0,\n cos: 1,\n };\n const vec = [(p2x - p1x) / n, (p2y - p1y) / n];\n const cos = vec[0];\n let sin = Math.sqrt(1 - cos * cos);\n sin = vec[1] >= 0 ? -sin : sin;\n return {\n sin: sin,\n cos: cos,\n };\n }\n\n /**\n * @private\n * @param {Array} hull\n * @param {Array} p\n * @param {Bool} topEdge\n */\n __align_hull(hull, p, topEdge) {\n let v = -1;\n let d2;\n for (let i = 0; i < hull.length; ++i) {\n const d = euclidean(hull[i], p);\n if (v === -1) {\n d2 = d;\n v = i;\n } else {\n if (d2 > d) {\n d2 = d;\n v = i;\n }\n }\n }\n\n let v1;\n let v2;\n if (topEdge) {\n v1 = hull[v];\n v2 = hull[(v + 1) % hull.length];\n } else {\n if (v == 0) v = hull.length - 1;\n v1 = hull[v];\n v2 = hull[(v - 1) % hull.length];\n }\n\n const transformation = {\n tx: -hull[v][0],\n ty: -hull[v][1],\n };\n\n if (hull.length >= 2) {\n const { sin, cos } = this.__findAngle(v1, v2);\n transformation.sin = sin;\n transformation.cos = cos;\n } else {\n transformation.sin = 0;\n transformation.cos = 1;\n }\n\n return transformation;\n }\n\n /**\n * @private\n * @param {Array} Point - The point which should get transformed.\n * @param {Object} Transformation - contains the values for translation and rotation.\n */\n __transform([px, py], { tx, ty, sin, cos }) {\n let x = px + tx;\n let y = py + ty;\n let xx = x * cos - y * sin;\n let yy = x * sin + y * cos;\n return [xx, yy];\n }\n\n /**\n * Calls {@link __transform} for each point in Set C\n * @private\n * @param {Array} C - Set of points.\n * @param {Object} t - Transform object.\n * @param {Number} yOffset - value to offset set C.\n */\n __transform_component(C, t, yOffset) {\n const N = C.length;\n for (let i = 0; i < N; ++i) {\n const c = C[i];\n const [cx, cy] = this.__transform(c, t);\n c[0] = cx;\n c[1] = cy + yOffset;\n }\n }\n\n /**\n * @private\n * @param {Array} u - point u\n * @param {Array} v - point v\n * @param {Number} w - edge weight w\n */\n __align_components(u, v, w) {\n const points_u = [...u.__disjoint_set.children];\n const points_v = [...v.__disjoint_set.children];\n\n const hull_u = this.__hull(points_u);\n const hull_v = this.__hull(points_v);\n\n const t_u = this.__align_hull(hull_u, u, false);\n const t_v = this.__align_hull(hull_v, v, true);\n\n this.__transform_component(points_u, t_u, 0);\n this.__transform_component(points_v, t_v, w);\n }\n\n /**\n * Transforms the inputdata {@link X} to dimensionality 2.\n */\n transform() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n }\n return this.projection;\n }\n\n *generator() {\n if (!this._is_initialized) this.init();\n const Emst = this._Emst;\n const Y = this.Y.to2dArray;\n const components = new DisjointSet(\n Y.map((y, i) => {\n y.i = i;\n return y;\n })\n );\n\n for (const [u, v, w] of Emst) {\n const component_u = components.find(Y[u]);\n const component_v = components.find(Y[v]);\n if (component_u === component_v) continue;\n this.__align_components(component_u, component_v, w);\n components.union(component_u, component_v);\n yield this.projection;\n }\n return this.projection;\n }\n}\n","import { Matrix, linspace } from \"../matrix/index.js\";\nimport { euclidean } from \"../metrics/index.js\";\nimport { PCA } from \"./PCA.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { DR } from \"./DR.js\";\n\n/**\n * @class\n * @alias TriMap\n * @extends DR\n */\nexport class TriMap extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias TriMap\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.weight_adj = 500] - scaling factor.\n * @param {Number} [parameters.c = 5] - number of triplets multiplier.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Number} [parameters.tol = 1e-8] -\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {TriMap}\n * @see {@link https://arxiv.org/pdf/1910.00204v1.pdf}\n * @see {@link https://github.com/eamid/trimap}\n */\n constructor(X, parameters) {\n super(X, { weight_adj: 500, c: 5, d: 2, metric: euclidean, tol: 1e-8, seed: 1212 }, parameters);\n return this;\n }\n\n /**\n *\n * @param {Matrix} [pca = null] - Initial Embedding (if null then PCA gets used).\n * @param {KNN} [knn = null] - KNN Object (if null then BallTree gets used).\n */\n init(pca = null, knn = null) {\n const X = this.X;\n const N = X.shape[0];\n const { d, metric, c } = this._parameters;\n this.n_inliers = 2 * c;\n this.n_outliers = 1 * c;\n this.n_random = 1 * c;\n this.Y = pca || new PCA(X, d).transform();\n this.knn = knn || new BallTree(X.to2dArray, metric);\n const { triplets, weights } = this._generate_triplets(this.n_inliers, this.n_outliers, this.n_random);\n this.triplets = triplets;\n this.weights = weights;\n this.lr = (1000 * N) / triplets.shape[0];\n this.C = Infinity;\n this.vel = new Matrix(N, d, 0);\n this.gain = new Matrix(N, d, 1);\n return this;\n }\n\n /**\n * Generates {@link n_inliers} x {@link n_outliers} x {@link n_random} triplets.\n * @param {Number} n_inliers\n * @param {Number} n_outliers\n * @param {Number} n_random\n */\n _generate_triplets(n_inliers, n_outliers, n_random) {\n const { metric, weight_adj } = this._parameters;\n const X = this.X;\n const N = X.shape[0];\n const knn = this.knn;\n const n_extra = Math.min(n_inliers + 20, N);\n const nbrs = new Matrix(N, n_extra);\n const knn_distances = new Matrix(N, n_extra);\n for (let i = 0; i < N; ++i) {\n knn.search(X.row(i), n_extra + 1)\n .raw_data()\n .filter((d) => d.value != 0)\n .sort((a, b) => a.value - b.value)\n .forEach((d, j) => {\n nbrs.set_entry(i, j, d.element.index);\n knn_distances.set_entry(i, j, d.value);\n });\n }\n // scale parameter\n const sig = new Float64Array(N);\n for (let i = 0; i < N; ++i) {\n sig[i] = Math.max((knn_distances.entry(i, 3) + knn_distances.entry(i, 4) + knn_distances.entry(i, 5) + knn_distances.entry(i, 6)) / 4, 1e-10);\n }\n\n const P = this._find_p(knn_distances, sig, nbrs);\n\n let triplets = this._sample_knn_triplets(P, nbrs, n_inliers, n_outliers);\n let n_triplets = triplets.shape[0];\n const outlier_distances = new Float64Array(n_triplets);\n for (let i = 0; i < n_triplets; ++i) {\n const j = triplets.entry(i, 0);\n const k = triplets.entry(i, 2);\n outlier_distances[i] = metric(X.row(j), X.row(k));\n }\n let weights = this._find_weights(triplets, P, nbrs, outlier_distances, sig);\n\n if (n_random > 0) {\n const { random_triplets, random_weights } = this._sample_random_triplets(X, n_random, sig);\n triplets = triplets.concat(random_triplets, \"vertical\");\n weights = Float64Array.from([...weights, ...random_weights]);\n }\n n_triplets = triplets.shape[0];\n let max_weight = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n if (isNaN(weights[i])) {\n weights[i] = 0;\n }\n if (max_weight < weights[i]) max_weight = weights[i];\n }\n let max_weight_2 = -Infinity;\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight;\n weights[i] += 0.0001;\n weights[i] = Math.log(1 + weight_adj * weights[i]);\n if (max_weight_2 < weights[i]) max_weight_2 = weights[i];\n }\n for (let i = 0; i < n_triplets; ++i) {\n weights[i] /= max_weight_2;\n }\n return {\n triplets: triplets,\n weights: weights,\n };\n }\n\n /**\n * Calculates the similarity matrix P\n * @private\n * @param {Matrix} knn_distances - matrix of pairwise knn distances\n * @param {Float64Array} sig - scaling factor for the distances\n * @param {Matrix} nbrs - nearest neighbors\n * @returns {Matrix} pairwise similarity matrix\n */\n _find_p(knn_distances, sig, nbrs) {\n const [N, n_neighbors] = knn_distances.shape;\n return new Matrix(N, n_neighbors, (i, j) => {\n return Math.exp(-(knn_distances.entry(i, j) ** 2 / sig[i] / sig[nbrs.entry(i, j)]));\n });\n }\n\n /**\n * Sample nearest neighbors triplets based on the similarity values given in P.\n * @private\n * @param {Matrix} P - Matrix of pairwise similarities between each point and its neighbors given in matrix nbrs.\n * @param {Matrix} nbrs - Nearest neighbors indices for each point. The similarity values are given in matrix {@link P}. Row i corresponds to the i-th point.\n * @param {Number} n_inliers - Number of inlier points.\n * @param {Number} n_outliers - Number of outlier points.\n *\n */\n _sample_knn_triplets(P, nbrs, n_inliers, n_outliers) {\n const N = nbrs.shape[0];\n const triplets = new Matrix(N * n_inliers * n_outliers, 3);\n for (let i = 0; i < N; ++i) {\n let n_i = i * n_inliers * n_outliers;\n const sort_indices = this.__argsort(P.row(i).map((d) => -d));\n for (let j = 0; j < n_inliers; ++j) {\n let n_j = j * n_outliers;\n const sim = nbrs.entry(i, sort_indices[j]);\n const samples = this._rejection_sample(n_outliers, N, sort_indices.slice(0, j + 1));\n for (let k = 0; k < n_outliers; ++k) {\n const index = n_i + n_j + k;\n const out = samples[k];\n triplets.set_entry(index, 0, i);\n triplets.set_entry(index, 1, sim);\n triplets.set_entry(index, 2, out);\n }\n }\n }\n return triplets;\n }\n\n /**\n * Should do the same as np.argsort()\n * @private\n * @param {Array} A\n */\n __argsort(A) {\n return A.map((d, i) => {\n return { d: d, i: i };\n })\n .sort((a, b) => a.d - b.d)\n .map((d) => d.i);\n }\n\n /**\n * Samples {@link n_samples} integers from a given interval [0, {@link max_int}] while rejection the values that are in the {@link rejects}.\n * @private\n * @param {*} n_samples\n * @param {*} max_int\n * @param {*} rejects\n */\n _rejection_sample(n_samples, max_int, rejects) {\n const randomizer = this._randomizer;\n const interval = linspace(0, max_int - 1).filter((d) => rejects.indexOf(d) < 0);\n return randomizer.choice(interval, Math.min(n_samples, interval.length - 2));\n }\n\n /**\n * Calculates the weights for the sampled nearest neighbors triplets\n * @private\n * @param {Matrix} triplets - Sampled Triplets.\n * @param {Matrix} P - Pairwise similarity matrix.\n * @param {Matrix} nbrs - nearest Neighbors\n * @param {Float64Array} outlier_distances - Matrix of pairwise outlier distances\n * @param {Float64Array} sig - scaling factor for the distances.\n */\n _find_weights(triplets, P, nbrs, outlier_distances, sig) {\n const n_triplets = triplets.shape[0];\n const weights = new Float64Array(n_triplets);\n for (let t = 0; t < n_triplets; ++t) {\n const i = triplets.entry(t, 0);\n const sim = nbrs.row(i).indexOf(triplets.entry(t, 1));\n const p_sim = P.entry(i, sim);\n let p_out = Math.exp(-(outlier_distances[t] ** 2 / (sig[i] * sig[triplets.entry(t, 2)])));\n if (p_out < 1e-20) p_out = 1e-20;\n weights[t] = p_sim / p_out;\n }\n return weights;\n }\n\n /**\n * Sample uniformly ranom triplets\n * @private\n * @param {Matrix} X - Data matrix.\n * @param {Number} n_random - Number of random triplets per point\n * @param {Float64Array} sig - Scaling factor for the distances\n */\n _sample_random_triplets(X, n_random, sig) {\n const metric = this.parameter(\"metric\");\n const randomizer = this._randomizer;\n const N = X.shape[0];\n const random_triplets = new Matrix(N * n_random, 3);\n const random_weights = new Float64Array(N * n_random);\n for (let i = 0; i < N; ++i) {\n const n_i = i * n_random;\n const indices = [...linspace(0, i - 1), ...linspace(i + 1, N - 1)];\n for (let j = 0; j < n_random; ++j) {\n let [sim, out] = randomizer.choice(indices, 2);\n let p_sim = Math.exp(-(metric(X.row(i), X.row(sim)) ** 2 / (sig[i] * sig[sim])));\n if (p_sim < 1e-20) p_sim = 1e-20;\n let p_out = Math.exp(-(metric(X.row(i), X.row(out)) ** 2 / (sig[i] * sig[out])));\n if (p_out < 1e-20) p_out = 1e-20;\n\n if (p_sim < p_out) {\n [sim, out] = [out, sim];\n [p_sim, p_out] = [p_out, p_sim];\n }\n const index = n_i + j;\n random_triplets.set_entry(index, 0, i);\n random_triplets.set_entry(index, 1, sim);\n random_triplets.set_entry(index, 2, out);\n random_weights[index] = p_sim / p_out;\n }\n }\n return {\n random_triplets: random_triplets,\n random_weights: random_weights,\n };\n }\n\n /**\n * Computes the gradient for updating the embedding.\n * @param {Matrix} Y - The embedding\n */\n _grad(Y) {\n const n_inliers = this.n_inliers;\n const n_outliers = this.n_outliers;\n const triplets = this.triplets;\n const weights = this.weights;\n const [N, dim] = Y.shape;\n const n_triplets = triplets.shape[0];\n const grad = new Matrix(N, dim, 0);\n let y_ij = new Float64Array(dim);\n let y_ik = new Float64Array(dim);\n let d_ij = 1;\n let d_ik = 1;\n let n_viol = 0;\n let loss = 0;\n const n_knn_triplets = N * n_inliers * n_outliers;\n\n for (let t = 0; t < n_triplets; ++t) {\n const [i, j, k] = triplets.row(t);\n // update y_ij, y_ik, d_ij, d_ik\n if (t % n_outliers == 0 || t >= n_knn_triplets) {\n d_ij = 1;\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_jd = Y.entry(j, d);\n const Y_kd = Y.entry(k, d);\n y_ij[d] = Y_id - Y_jd;\n y_ik[d] = Y_id - Y_kd;\n d_ij += y_ij[d] ** 2;\n d_ik += y_ik[d] ** 2;\n }\n // update y_ik and d_ik only\n } else {\n d_ik = 1;\n for (let d = 0; d < dim; ++d) {\n const Y_id = Y.entry(i, d);\n const Y_kd = Y.entry(k, d);\n y_ik[d] = Y_id - Y_kd;\n d_ik += y_ik[d] ** 2;\n }\n }\n\n if (d_ij > d_ik) ++n_viol;\n loss += weights[t] / (1 + d_ik / d_ij);\n const w = (weights[t] / (d_ij + d_ik)) ** 2;\n for (let d = 0; d < dim; ++d) {\n const gs = y_ij[d] * d_ik * w;\n const go = y_ik[d] * d_ij * w;\n grad.set_entry(i, d, grad.entry(i, d) + gs - go);\n grad.set_entry(j, d, grad.entry(j, d) - gs);\n grad.set_entry(k, d, grad.entry(k, d) + go);\n }\n }\n return { grad, loss, n_viol };\n }\n\n /**\n *\n * @param {Number} max_iteration\n */\n transform(max_iteration = 400) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n }\n return this.projection;\n }\n\n /**\n * @param {Number} max_iteration\n * @yields {Matrix}\n * @returns {Matrix}\n */\n *generator(max_iteration = 800) {\n this.check_init();\n for (let iter = 0; iter < max_iteration; ++iter) {\n this._next(iter);\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * Does the iteration step.\n * @private\n * @param {Number} iter\n */\n _next(iter) {\n const gamma = iter > 150 ? 0.5 : 0.3;\n const old_C = this.C;\n const vel = this.vel;\n const Y = this.Y.add(vel.mult(gamma));\n const { grad, loss, n_viol } = this._grad(Y);\n this.C = loss;\n this.Y = this._update_embedding(Y, iter, grad);\n this.lr *= old_C > loss + this._parameters.tol ? 1.01 : 0.9;\n return this.Y;\n }\n\n /**\n * Updates the embedding.\n * @private\n * @param {Matrix} Y\n * @param {Number} iter\n * @param {Matrix} grad\n */\n _update_embedding(Y, iter, grad) {\n const [N, dim] = Y.shape;\n const gamma = iter > 150 ? 0.9 : 0.5; // moment parameter\n const min_gain = 0.01;\n const gain = this.gain;\n const vel = this.vel;\n const lr = this.lr;\n for (let i = 0; i < N; ++i) {\n for (let d = 0; d < dim; ++d) {\n const new_gain = Math.sign(vel.entry(i, d)) != Math.sign(grad.entry(i, d)) ? gain.entry(i, d) + 0.2 : Math.max(gain.entry(i, d) * 0.8, min_gain);\n gain.set_entry(i, d, new_gain);\n vel.set_entry(i, d, gamma * vel.entry(i, d) - lr * gain.entry(i, d) * grad.entry(i, d));\n Y.set_entry(i, d, Y.entry(i, d) + vel.entry(i, d));\n }\n }\n return Y;\n }\n}\n","import { Matrix } from \"../matrix/index.js\";\nimport { euclidean, euclidean_squared } from \"../metrics/index.js\";\nimport { BallTree } from \"../knn/index.js\";\nimport { neumair_sum } from \"../numerical/index.js\";\nimport { linspace } from \"../matrix/index.js\";\nimport { powell } from \"../optimization/index.js\";\nimport { DR } from \"./DR.js\";\nimport { max } from \"../util/index.js\";\nimport { KNN } from \"../knn/index.js\";\n\n/**\n * @class\n * @alias UMAP\n * @extends DR\n */\nexport class UMAP extends DR {\n /**\n *\n * @constructor\n * @memberof module:dimensionality_reduction\n * @alias UMAP\n * @param {Matrix} X - the high-dimensional data.\n * @param {Object} parameters - Object containing parameterization of the DR method.\n * @param {Number} [parameters.n_neighbors = 15] - size of the local neighborhood.\n * @param {Number} [parameters.local_connectivity = 1] - number of nearest neighbors connected in the local neighborhood.\n * @param {Number} [parameters.min_dist = 1] - controls how tightly points get packed together.\n * @param {Number} [parameters.d = 2] - the dimensionality of the projection.\n * @param {Function} [parameters.metric = euclidean] - the metric which defines the distance between two points in the high-dimensional space.\n * @param {Number} [parameters._spread = 1] - The effective scale of embedded points. (In combination with {@link parameters.min_dist})\n * @param {Number} [parameters._set_op_mix_ratio = 1] - Interpolate between union and intersection.\n * @param {Number} [parameters._repulsion_strength = 1] - Weighting applied to negative samples.\n * @param {Number} [parameters._negative_sample_rate = 5] - The number of negative samples per positive sample.\n * @param {Number} [parameters._n_epochs = 350] - The number of training epochs.\n * @param {Number} [parameter._initial_alpha = 1] - The initial learning rate for the optimization.\n * @param {Number} [parameters.seed = 1212] - the seed for the random number generator.\n * @returns {UMAP}\n */\n constructor(X, parameters) {\n super(X, { n_neighbors: 15, local_connectivity: 1, min_dist: 1, d: 2, metric: euclidean, seed: 1212, _spread: 1, _set_op_mix_ratio: 1, _repulsion_strength: 1, _negative_sample_rate: 5, _n_epochs: 350, _initial_alpha: 1 }, parameters);\n [this._N, this._D] = this.X.shape;\n /* let n_neighbors = Math.min(this._N - 1, parameters.n_neighbors);\n this.parameter(\"n_neighbors\", n_neighbors);\n this.parameter(\"local_connectivity\", Math.min(this.parameter(\"local_connectivity\"), n_neighbors - 1)); */\n if (this.parameter(\"n_neighbors\") > this._N) {\n throw new Error(`Parameter n_neighbors (=${this.parameter(\"n_neighbors\")}) needs to be smaller than dataset size (N=${this._N})!`);\n }\n if (this.parameter(\"local_connectivity\") > this.parameter(\"n_neighbors\")) {\n throw new Error(`Parameter local_connectivity (=${this.parameter(\"local_connectivity\")}) needs to be smaller than parameter n_neighbors (=${this.parameter(\"n_neighbors\")})`);\n }\n this._iter = 0;\n const randomizer = this._randomizer;\n this.Y = new Matrix(this._N, this.parameter(\"d\"), () => randomizer.random);\n return this;\n }\n\n /**\n * @private\n * @param {Number} spread\n * @param {Number} min_dist\n * @returns {Array}\n */\n _find_ab_params(spread, min_dist) {\n const curve = (x, a, b) => 1 / (1 + a * Math.pow(x, 2 * b));\n const xv = linspace(0, spread * 3, 300);\n const yv = linspace(0, spread * 3, 300);\n\n for (let i = 0, n = xv.length; i < n; ++i) {\n const xv_i = xv[i];\n yv[i] = xv_i < min_dist ? 1 : Math.exp(-(xv_i - min_dist) / spread);\n }\n\n const err = (p) => {\n const error = linspace(1, 300).map((_, i) => yv[i] - curve(xv[i], p[0], p[1]));\n return Math.sqrt(neumair_sum(error.map((e) => e * e)));\n };\n\n return powell(err, [1, 1]);\n }\n\n /**\n * @private\n * @param {Array} distances\n * @param {Array} sigmas\n * @param {Array} rhos\n * @returns {Array}\n */\n _compute_membership_strengths(distances, sigmas, rhos) {\n for (let i = 0, n = distances.length; i < n; ++i) {\n for (let j = 0, m = distances[i].length; j < m; ++j) {\n const v = distances[i][j].value - rhos[i];\n distances[i][j].value = v > 0 ? Math.exp(-v / sigmas[i]) : 1;\n }\n }\n return distances;\n }\n\n /**\n * @private\n * @param {KNN|BallTree} knn\n * @param {Number} k\n * @returns {Object}\n */\n _smooth_knn_dist(knn, k) {\n const SMOOTH_K_TOLERANCE = 1e-5;\n const MIN_K_DIST_SCALE = 1e-3;\n const n_iter = 64;\n const { local_connectivity, metric } = this._parameters;\n const target = Math.log2(k);\n const rhos = [];\n const sigmas = [];\n const X = this.X;\n const N = X.shape[0];\n //const distances = [...X].map(x_i => knn.search(x_i, k).raw_data().reverse());\n\n const distances = [];\n if (metric === \"precomputed\") {\n for (let i = 0; i < N; ++i) {\n distances.push(knn.search(i, k).reverse());\n }\n } else {\n for (const x_i of X) {\n distances.push(knn.search(x_i, k).raw_data().reverse());\n }\n }\n\n for (let i = 0; i < N; ++i) {\n let lo = 0;\n let hi = Infinity;\n let mid = 1;\n\n const search_result = distances[i];\n const non_zero_dist = search_result.filter((d) => d.value > 0);\n const non_zero_dist_length = non_zero_dist.length;\n if (non_zero_dist_length >= local_connectivity) {\n const index = Math.floor(local_connectivity);\n const interpolation = local_connectivity - index;\n if (index > 0) {\n rhos.push(non_zero_dist[index - 1]);\n if (interpolation > SMOOTH_K_TOLERANCE) {\n rhos[i].value += interpolation * (non_zero_dist[index].value - non_zero_dist[index - 1]);\n }\n } else {\n rhos[i].value = interpolation * non_zero_dist[0].value;\n }\n } else if (non_zero_dist_length > 0) {\n rhos[i] = non_zero_dist[non_zero_dist_length - 1].value;\n }\n for (let x = 0; x < n_iter; ++x) {\n let psum = 0;\n for (let j = 0; j < k; ++j) {\n const d = search_result[j].value - rhos[i];\n psum += d > 0 ? Math.exp(-(d / mid)) : 1;\n }\n if (Math.abs(psum - target) < SMOOTH_K_TOLERANCE) {\n break;\n }\n if (psum > target) {\n [hi, mid] = [mid, (lo + hi) / 2];\n } else {\n if (hi === Infinity) {\n [lo, mid] = [mid, mid * 2];\n } else {\n [lo, mid] = [mid, (lo + hi) / 2];\n }\n }\n }\n sigmas[i] = mid;\n\n const mean_ithd = search_result.reduce((a, b) => a + b.value, 0) / search_result.length;\n //let mean_d = null;\n if (rhos[i] > 0) {\n if (sigmas[i] < MIN_K_DIST_SCALE * mean_ithd) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_ithd;\n }\n } else {\n const mean_d = distances.reduce((acc, res) => acc + res.reduce((a, b) => a + b.value, 0) / res.length);\n if (sigmas[i] > MIN_K_DIST_SCALE * mean_d) {\n sigmas[i] = MIN_K_DIST_SCALE * mean_d;\n }\n }\n }\n return {\n distances: distances,\n sigmas: sigmas,\n rhos: rhos,\n };\n }\n\n /**\n * @private\n * @param {Matrix} X\n * @param {Number} n_neighbors\n * @returns {Matrix}\n */\n _fuzzy_simplicial_set(X, n_neighbors) {\n const N = X.shape[0];\n const { metric, _set_op_mix_ratio } = this._parameters;\n const knn = metric === \"precomputed\" ? new KNN(X, \"precomputed\") : new BallTree(X.to2dArray, metric);\n let { distances, sigmas, rhos } = this._smooth_knn_dist(knn, n_neighbors);\n distances = this._compute_membership_strengths(distances, sigmas, rhos);\n const result = new Matrix(N, N, \"zeros\");\n for (let i = 0; i < N; ++i) {\n const distances_i = distances[i];\n for (let j = 0; j < distances_i.length; ++j) {\n result.set_entry(i, distances_i[j].element.index, distances_i[j].value);\n }\n }\n\n const transposed_result = result.T;\n const prod_matrix = result.mult(transposed_result);\n return result\n .add(transposed_result)\n .sub(prod_matrix)\n .mult(_set_op_mix_ratio)\n .add(prod_matrix.mult(1 - _set_op_mix_ratio));\n }\n\n /**\n * @private\n * @param {Number} n_epochs\n * @returns {Array}\n */\n _make_epochs_per_sample(n_epochs) {\n const weights = this._weights;\n const result = new Float32Array(weights.length).fill(-1);\n const weights_max = max(weights);\n const n_samples = weights.map((w) => n_epochs * (w / weights_max));\n for (let i = 0; i < result.length; ++i) if (n_samples[i] > 0) result[i] = Math.round(n_epochs / n_samples[i]);\n return result;\n }\n\n /**\n * @private\n * @param {Matrix} graph\n * @returns {Object}\n */\n _tocoo(graph) {\n const rows = [];\n const cols = [];\n const data = [];\n const [rows_n, cols_n] = graph.shape;\n for (let row = 0; row < rows_n; ++row) {\n for (let col = 0; col < cols_n; ++col) {\n const entry = graph.entry(row, col);\n if (entry !== 0) {\n rows.push(row);\n cols.push(col);\n data.push(entry);\n }\n }\n }\n return {\n rows: rows,\n cols: cols,\n data: data,\n };\n }\n\n /**\n * Computes all necessary\n * @returns {UMAP}\n */\n init() {\n const { _spread, min_dist, n_neighbors, _n_epochs, _negative_sample_rate } = this._parameters;\n const [a, b] = this._find_ab_params(_spread, min_dist);\n this._a = a;\n this._b = b;\n this._graph = this._fuzzy_simplicial_set(this.X, n_neighbors);\n const { rows, cols, data: weights } = this._tocoo(this._graph);\n this._head = rows;\n this._tail = cols;\n this._weights = weights;\n this._epochs_per_sample = this._make_epochs_per_sample(_n_epochs);\n this._epochs_per_negative_sample = this._epochs_per_sample.map((d) => d * _negative_sample_rate);\n this._epoch_of_next_sample = this._epochs_per_sample.slice();\n this._epoch_of_next_negative_sample = this._epochs_per_negative_sample.slice();\n return this;\n }\n\n graph() {\n this.check_init();\n return { cols: this._head, rows: this._tail, weights: this._weights };\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n transform(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n }\n return this.projection;\n }\n\n /**\n *\n * @param {Number} [iterations=350] - number of iterations.\n * @returns {Matrix|Array}\n */\n *generator(iterations = 350) {\n if (this.parameter(\"_n_epochs\") != iterations) {\n this.parameter(\"_n_epochs\", iterations);\n this.init();\n }\n this.check_init();\n for (let i = 0; i < iterations; ++i) {\n this.next();\n yield this.projection;\n }\n return this.projection;\n }\n\n /**\n * @private\n * @param {Number} x\n * @returns {Number}\n */\n _clip(x) {\n if (x > 4) return 4;\n if (x < -4) return -4;\n return x;\n }\n\n /**\n * performs the optimization step.\n * @private\n * @param {Matrix} head_embedding\n * @param {Matrix} tail_embedding\n * @param {Matrix} head\n * @param {Matrix} tail\n * @returns {Matrix}\n */\n _optimize_layout(head_embedding, tail_embedding, head, tail) {\n const randomizer = this._randomizer;\n const { _repulsion_strength, d: dim } = this._parameters;\n const { _alpha: alpha, _a: a, _b: b, _epochs_per_sample: epochs_per_sample, _epochs_per_negative_sample: epochs_per_negative_sample, _epoch_of_next_negative_sample: epoch_of_next_negative_sample, _epoch_of_next_sample: epoch_of_next_sample, _clip: clip } = this;\n const tail_length = tail.length;\n\n for (let i = 0, n = epochs_per_sample.length; i < n; ++i) {\n if (epoch_of_next_sample[i] <= this._iter) {\n const j = head[i];\n const k = tail[i];\n const current = head_embedding.row(j);\n const other = tail_embedding.row(k);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (-2 * a * b * Math.pow(dist, b - 1)) / (a * Math.pow(dist, b) + 1);\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(k, d, o);\n }\n epoch_of_next_sample[i] += epochs_per_sample[i];\n const n_neg_samples = (this._iter - epoch_of_next_negative_sample[i]) / epochs_per_negative_sample[i];\n for (let p = 0; p < n_neg_samples; ++p) {\n const k = randomizer.random_int % tail_length;\n const other = tail_embedding.row(tail[k]);\n const dist = euclidean_squared(current, other);\n let grad_coeff = 0;\n if (dist > 0) {\n grad_coeff = (2 * _repulsion_strength * b) / ((0.01 + dist) * (a * Math.pow(dist, b) + 1));\n } else if (j === k) {\n continue;\n }\n for (let d = 0; d < dim; ++d) {\n const grad_d = clip(grad_coeff * (current[d] - other[d])) * alpha;\n const c = current[d] + grad_d;\n const o = other[d] - grad_d;\n current[d] = c;\n other[d] = o;\n head_embedding.set_entry(j, d, c);\n tail_embedding.set_entry(tail[k], d, o);\n }\n }\n epoch_of_next_negative_sample[i] += n_neg_samples * epochs_per_negative_sample[i];\n }\n }\n return head_embedding;\n }\n\n /**\n * @private\n * @returns {Matrix}\n */\n next() {\n const iter = ++this._iter;\n const Y = this.Y;\n const { _initial_alpha, _n_epochs } = this._parameters;\n this._alpha = _initial_alpha * (1 - iter / _n_epochs);\n this.Y = this._optimize_layout(Y, Y, this._head, this._tail);\n\n return this.Y;\n }\n}\n","/**\n * Computes the canberra distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias canberra\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} The canberra distance between {@link a} and {@link b}.\n * @see {@link https://en.wikipedia.org/wiki/Canberra_distance}\n */\nexport default function(a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += (Math.abs(a[i] - b[i]) / (Math.abs(a[i]) + Math.abs(b[i])))\n }\n return sum;\n}","/**\n * Computes the chebyshev distance (L) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias chebyshev\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the chebyshev distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let res = [];\n for (let i = 0; i < n; ++i) {\n res.push(Math.abs(a[i] - b[i]));\n }\n return Math.max(...res);\n}\n","/**\n * Computes the cosine distance (not similarity) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias cosine\n * @param {Array} a\n * @param {Array} b\n * @example\n * druid.cosine([1,0],[1,1]) == 0.7853981633974484 == π/4\n * @returns {Number} The cosine distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length !== b.length) return undefined;\n let n = a.length;\n let sum = 0;\n let sum_a = 0;\n let sum_b = 0;\n for (let i = 0; i < n; ++i) {\n sum += a[i] * b[i];\n sum_a += a[i] * a[i];\n sum_b += b[i] * b[i];\n }\n return Math.acos(sum / (Math.sqrt(sum_a) * Math.sqrt(sum_b)));\n}\n","/**\n * Computes the hamming distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias hamming\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the hamming distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let disagree = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i];\n const y = b[i];\n disagree += x != y;\n }\n return disagree / n;\n}\n","import { neumair_sum } from \"../numerical/index.js\";\n\n/**\n * Computes the inner product between two arrays of the same length.\n * @memberof module:linear_algebra\n * @alias inner_product\n * @param {Array|Float64Array} a - Array a\n * @param {Array|Float64Array} b - Array b\n * @returns The inner product between {@link a} and {@link b}\n */\nexport default function (a, b) {\n const N = a.length;\n if (N != b.length) {\n throw new Error(\"Array a and b must have the same length!\")\n }\n let sum = 0;\n for (let i = 0; i < N; ++i) {\n sum += a * b;\n }\n return sum;\n}\n","/**\n * Computes the jaccard distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias jaccard\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the jaccard distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_non_zero = 0;\n let num_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_non_zero += x || y;\n num_equal += x && y;\n }\n return (num_non_zero - num_equal) / num_non_zero;\n}\n","/**\n * Numerical stable summation with the Kahan summation algorithm.\n * @memberof module:numerical\n * @alias kahan_sum\n * @param {Array} summands - Array of values to sum up.\n * @returns {number} The sum.\n * @see {@link https://en.wikipedia.org/wiki/Kahan_summation_algorithm}\n */\nexport default function (summands) {\n let n = summands.length;\n let sum = 0;\n let compensation = 0;\n let y, t;\n\n for (let i = 0; i < n; ++i) {\n y = summands[i] - compensation;\n t = sum + y;\n compensation = t - sum - y;\n sum = t;\n }\n return sum;\n}\n","/**\n * Computes the manhattan distance (l1) between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias manhattan\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the manhattan distance between {@link a} and {@link b}.\n */ \nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n let n = a.length;\n let sum = 0;\n for (let i = 0; i < n; ++i) {\n sum += Math.abs(a[i] - b[i]);\n }\n return sum;\n}\n","import { norm } from \"./index.js\";\nimport { euclidean } from \"../metrics/index.js\";\n\n/**\n * Normalizes Vector {@link v}.\n * @memberof module:matrix\n * @alias normalize\n * @param {Array|Float64Array} v - Vector\n * @param {Function} metric \n * @returns {Array|Float64Array} - The normalized vector with length 1.\n */\nexport default function(v, metric = euclidean) {\n const v_norm = norm(v, metric);\n return v.map(value => value / v_norm);\n}","import { Matrix, norm } from \"../matrix/index.js\";\n\n/**\n * Computes the QR Decomposition of the Matrix {@link A} with householder transformations.\n * @memberof module:linear_algebra\n * @alias qr_householder\n * @param {Matrix} A\n * @returns {{R: Matrix, Q: Matrix}}\n * @see {@link https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections}\n * @see {@link http://mlwiki.org/index.php/Householder_Transformation}\n */\nexport default function (A) {\n const [rows, cols] = A.shape;\n const Q = new Matrix(rows, rows, \"I\");\n const R = A.clone();\n\n for (let j = 0; j < cols; ++j) {\n const x = Matrix.from(R.col(j).slice(j));\n const x_norm = norm(x);\n const x0 = x.entry(0, 0);\n const rho = -Math.sign(x0);\n const u1 = x0 - rho * x_norm;\n const u = x.divide(u1).set_entry(0, 0, 1);\n const beta = (-rho * u1) / x_norm;\n\n const u_outer_u = u.outer(u);\n const R_block = R.get_block(j, 0);\n const new_R = R_block.sub(u_outer_u.dot(R_block).mult(beta));\n const Q_block = Q.get_block(0, j);\n const new_Q = Q_block.sub(Q_block.dot(u_outer_u).mult(beta));\n R.set_block(j, 0, new_R);\n Q.set_block(0, j, new_Q);\n }\n return { R, Q };\n}\n","/**\n * Computes the Sokal-Michener distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias sokal_michener\n * @param {Array} a \n * @param {Array} b \n * @returns {Number} the Sokal-Michener distance between {@link a} and {@link b}. \n */\nexport default function(a, b) {\n if (a.length != b.length) return undefined\n const n = a.length;\n let num_not_equal = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_not_equal += x != y;\n }\n return (2 * num_not_equal) / (n + num_not_equal);\n}","/**\n * Computes the yule distance between {@link a} and {@link b}.\n * @memberof module:metrics\n * @alias yule\n * @param {Array} a\n * @param {Array} b\n * @returns {Number} the yule distance between {@link a} and {@link b}.\n */\nexport default function (a, b) {\n if (a.length != b.length) return undefined;\n const n = a.length;\n let num_true_true = 0;\n let num_true_false = 0;\n let num_false_true = 0;\n for (let i = 0; i < n; ++i) {\n const x = a[i] != 0;\n const y = b[i] != 0;\n num_true_true += x && y;\n num_true_false += x && !y;\n num_false_true += !x && x;\n }\n const num_false_false = n - num_true_true - num_true_false - num_false_true;\n return num_true_false == 0 || num_false_true == 0 ? 0 : (2 * num_true_false * num_false_true) / (num_true_true * num_false_false + num_true_false * num_false_true);\n}\n"],"names":["a","b","Math","sqrt","euclidean_squared","summands","n","length","sum","compensation","i","summand","t","abs","s","Array","x","y","neumair_sum","A","k","metric","euclidean","rows","shape","D","distance_matrix","nN","row","from","map","distance","col","j","sort","slice","Matrix","A_i","dist","set_entry","start","end","number","max","round","result","v","vector","cols","Error","Float64Array","Q","R","q","q_dot_v","q_","v_","v_norm","norm","seed","max_iterations","qr","qr_gramschmidt","tol","randomizer","Randomizer","random","oldQ","clone","QR","dot","values","eigenvalues","diag","eigenvectors","transpose","to2dArray","constructor","value","this","_rows","_cols","_data","static","type","isArray","m","_","data","subarray","iterate_rows","Symbol","iterator","set_row","offset","result_col","entry","T","inverse","B","h","i_max","max_val","Infinity","val","h_val","i_val","f","B_row_row","B_i_j","join","I","B_i","C","e","outer","l","concat","rows_A","cols_A","rows_B","cols_B","X","set_block","offset_row","offset_col","get_block","start_row","start_col","end_row","end_col","new_row","new_col","gather","row_indices","col_indices","N","row_index","col_index","_apply_array","_apply_rowwise_array","_apply_colwise_array","_apply","value_rows","value_cols","mult","divide","add","sub","push","asArray","min_row_col","min","mean","meanRows","meanCols","b_i","r","d","z","alpha","r_next","beta","L","U","LU","L_diag","U_diag","det","M","MT","MtM","MMt","V","Sigma","simultaneous_poweriteration","sigma","_seed","_N","_M","_MATRIX_A","_UPPER_MASK","_LOWER_MASK","_mt","_mti","Date","getTime","mt","mti","random_int","mag01","kk","N_M","M_N","choice","sample","index_list","linspace","random_index","splice","undefined","Heap","elements","accessor","comparator","heapify","_accessor","_container","_comparator","heap","container","element","floor","_heapify_down","_swap","index_a","index_b","_heapify_up","index","parentIndex","node","start_index","left","right","pop","item","first","iterate","toArray","raw_data","empty","DisjointSet","_list","Set","make_set","list","has","__disjoint_set","parent","children","size","find","union","node_x","node_y","forEach","BallTree","_Node","pivot","child1","child2","radius","_Leaf","points","_metric","_root","_construct","c","_greatest_spread","sorted_elements","p_index","p","spread","reduce","acc","current","search","_search","KNN","_elements","_D","distances","H","nearest_element_index","nearest_dist","Number","isInteger","res","DR","default_parameters","parameters","_parameters","Object","assign","seal","_type","_randomizer","_is_initialized","parameter","name","hasOwnProperty","para","transform","check_init","projection","generator","init","Y","async","args","PCA","super","eig_args","principal_components","means","X_cent","MDS","ai_","a_j","a__","_d_X","stress","d_X","d_Y","top_sum","bottom_sum","pow","x0","max_iter","pfx","fx","convergence","fxi","dx","Cluster","id","centroid","depth","_calculate_centroid","l_size","r_size","l_centroid","r_centroid","new_centroid","isLeaf","leaves","descendants","left_descendants","right_descendants","KMedoids","matrix","K","_matrix","_A","_K","_max_iter","log10","_distance_matrix","_clusters","fill","_cluster_medoids","_get_random_medoids","get_clusters","x_j","_nearest_medoid","index_nearest","medoids","finish","_iteration","cache","x_o","o","DeltaTD","xs","findIndex","d_j","distance_nearest","deltaTD","d_oj","_get_distance","d_n","distance_second","d_s","filter","x_i","d_ij","nearest","second","x_m","m1","m2","index_second","cluster_medoids","indices","ceil","TD","TD0","S","S_j","S_o","delta","_choose_distant_objects","a_index","b_index","max_dist","d_ai","d_bi","_col","old_dist","d_ab","y_i","linkage","_id","_linkage","root","do","clusters","_traverse","_n","d_min","_d_min","c_size","_c_size","Uint16Array","p_max","c1","D_i_min","c2","c1_cluster","c2_cluster","c1_cluster_indices","c2_cluster_indices","new_cluster","unshift","D_c1_j","D_c2_j","neighbors","kNearestNeighbors","G","other","_cluster_centroids","_get_random_centroids","_furthest_point","candidates","Ad","cluster_centroids","random_point","init_points","sample_size","indexOf","furthest_point","clusters_changed","Ai","min_dist","min_cluster","_compute_centroid","cluster_counter","ci","iteration_result","labels","unique_labels","label_id","count","X_mean","V_mean","label","v_mean","S_b","S_w","row_v","k_nearest_neighbors","O","W","nN_row","Z","C_trace","w","solve_CG","IW","control_points","DR_parameters","nc","c_i","Y_C","XA","knn","_b","AT","ATA","ATb","I_i","X_i","g","G_i_t","W_i","epsilon","min_points","_epsilon","_min_points","_ordered_list","_DB","ordered_list","DB","cluster_index","_cluster_index","reachability_distance","processed","_get_neighbors","_core_distance","seeds","_update","_expand_cluster","core_distance","new_reachability_distance","cluster","outliers","get_cluster_affirmation","magic","init_DR","init_parameters","includes","_step","MAGIC","e1","e2","Yi","Yj","dY","dX","dq","dr","perplexity","_iter","Htarget","log","Delta","druid","P","_ystep","_gains","prow","betamin","betamax","done","num","psum","pj","exp","Hhere","Pout","N2","_P","iterations","next","iter","ystep","gains","dim","pmul","Qu","qsum","dsum","dhere","qu","grad","premult","ymean","gid","sid","gainid","newgain","sign","newsid","__lazy_distance_matrix","D_ij","_make_minimum_spanning_tree","disjoint_set","F","E","u","set_u","set_v","_Emst","__hull_cross","ax","ay","bx","by","sx","sy","__hull","x1","y1","x2","y2","lower","upper","__findAngle","p1x","p1y","p2x","p2y","sin","cos","vec","__align_hull","hull","topEdge","d2","v1","v2","transformation","tx","ty","__transform","px","py","__transform_component","yOffset","cx","cy","__align_components","points_u","points_v","hull_u","hull_v","t_u","t_v","Emst","components","component_u","component_v","weight_adj","pca","n_inliers","n_outliers","n_random","triplets","weights","_generate_triplets","lr","vel","gain","n_extra","nbrs","knn_distances","sig","_find_p","_sample_knn_triplets","n_triplets","outlier_distances","_find_weights","random_triplets","random_weights","_sample_random_triplets","max_weight","isNaN","max_weight_2","n_neighbors","n_i","sort_indices","__argsort","n_j","sim","samples","_rejection_sample","out","n_samples","max_int","rejects","interval","p_sim","p_out","_grad","y_ij","y_ik","d_ik","n_viol","loss","n_knn_triplets","Y_id","Y_jd","Y_kd","gs","go","max_iteration","_next","gamma","old_C","_update_embedding","new_gain","local_connectivity","_spread","_set_op_mix_ratio","_repulsion_strength","_negative_sample_rate","_n_epochs","_initial_alpha","_find_ab_params","xv","yv","xv_i","powell","error","_compute_membership_strengths","sigmas","rhos","_smooth_knn_dist","SMOOTH_K_TOLERANCE","MIN_K_DIST_SCALE","target","log2","reverse","lo","hi","mid","search_result","non_zero_dist","non_zero_dist_length","interpolation","mean_ithd","mean_d","_fuzzy_simplicial_set","distances_i","transposed_result","prod_matrix","_make_epochs_per_sample","n_epochs","_weights","Float32Array","weights_max","_tocoo","graph","rows_n","cols_n","_a","_graph","_head","_tail","_epochs_per_sample","_epochs_per_negative_sample","_epoch_of_next_sample","_epoch_of_next_negative_sample","_clip","_optimize_layout","head_embedding","tail_embedding","head","tail","_alpha","epochs_per_sample","epochs_per_negative_sample","epoch_of_next_negative_sample","epoch_of_next_sample","clip","tail_length","grad_coeff","grad_d","n_neg_samples","sum_a","sum_b","acos","disagree","num_non_zero","num_equal","x_norm","rho","u1","u_outer_u","R_block","new_R","Q_block","new_Q","num_not_equal","num_true_true","num_true_false","num_false_true"],"mappings":";sPASe,WAAUA,EAAGC,GACxB,OAAOC,KAAKC,KAAKC,EAAkBJ,EAAGC,ICF3B,WAAUI,GACrB,IAAIC,EAAID,EAASE,OACbC,EAAM,EACNC,EAAe,EAEnB,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,IAAKI,EAAG,CACxB,IAAIC,EAAUN,EAASK,GACnBE,EAAIJ,EAAMG,EACVT,KAAKW,IAAIL,IAAQN,KAAKW,IAAIF,GAC1BF,GAAgBD,EAAMI,EAAID,EAE1BF,GAAgBE,EAAUC,EAAIJ,EAElCA,EAAMI,EAEV,OAAOJ,EAAMC,ECdF,WAAUT,EAAGC,GACxB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AAEU,GACNO,EAAY,GAARhB,EAAES,GACZkvB,GAAiB5uB,GAAKC,EACtB4uB,GAAkB7uB,IAAMC,EACxB6uB,IAAmB9uB,GAAKA,EAG5B,OAAyB,GAAlB6uB,GAAyC,GAAlBC,EAAsB,EAAK,EAAID,EAAiBC,GAAmBF,GADzEtvB,EAAIsvB,EAAgBC,EAAiBC,GACsED,EAAiBC"} \ No newline at end of file diff --git a/docs/BallTree.html b/docs/BallTree.html index 8297ccd..868f836 100644 --- a/docs/BallTree.html +++ b/docs/BallTree.html @@ -83,7 +83,7 @@ diff --git a/docs/DR.html b/docs/DR.html index c88aed6..43d9aac 100644 --- a/docs/DR.html +++ b/docs/DR.html @@ -83,7 +83,7 @@ diff --git a/docs/DisjointSet.html b/docs/DisjointSet.html index 622a224..2a95a91 100644 --- a/docs/DisjointSet.html +++ b/docs/DisjointSet.html @@ -83,7 +83,7 @@ diff --git a/docs/FASTMAP.html b/docs/FASTMAP.html index c205ad6..e0e187b 100644 --- a/docs/FASTMAP.html +++ b/docs/FASTMAP.html @@ -83,7 +83,7 @@ diff --git a/docs/HIPP.html b/docs/HIPP.html index b54f958..f140316 100644 --- a/docs/HIPP.html +++ b/docs/HIPP.html @@ -83,7 +83,7 @@ diff --git a/docs/HNSW.html b/docs/HNSW.html index 4734ba1..cdf8e83 100644 --- a/docs/HNSW.html +++ b/docs/HNSW.html @@ -83,7 +83,7 @@ diff --git a/docs/Heap.html b/docs/Heap.html index 9499477..25d72f6 100644 --- a/docs/Heap.html +++ b/docs/Heap.html @@ -83,7 +83,7 @@ diff --git a/docs/Hierarchical_Clustering.html b/docs/Hierarchical_Clustering.html index 3d4a1fa..6b2759c 100644 --- a/docs/Hierarchical_Clustering.html +++ b/docs/Hierarchical_Clustering.html @@ -83,7 +83,7 @@ diff --git a/docs/ISOMAP.html b/docs/ISOMAP.html index 423d3d2..9f4c134 100644 --- a/docs/ISOMAP.html +++ b/docs/ISOMAP.html @@ -83,7 +83,7 @@ diff --git a/docs/KMeans.html b/docs/KMeans.html index 2732752..b3df892 100644 --- a/docs/KMeans.html +++ b/docs/KMeans.html @@ -83,7 +83,7 @@ diff --git a/docs/KMedoids.html b/docs/KMedoids.html index d25fc74..6509886 100644 --- a/docs/KMedoids.html +++ b/docs/KMedoids.html @@ -83,7 +83,7 @@ diff --git a/docs/KNN.html b/docs/KNN.html index 870dbf9..a3aa769 100644 --- a/docs/KNN.html +++ b/docs/KNN.html @@ -83,7 +83,7 @@ diff --git a/docs/LDA.html b/docs/LDA.html index 3f27382..5662d7d 100644 --- a/docs/LDA.html +++ b/docs/LDA.html @@ -83,7 +83,7 @@ diff --git a/docs/LLE.html b/docs/LLE.html index 8ec6a7e..6ae3c0d 100644 --- a/docs/LLE.html +++ b/docs/LLE.html @@ -83,7 +83,7 @@ diff --git a/docs/LSP.html b/docs/LSP.html index fa6ca7d..e8879fd 100644 --- a/docs/LSP.html +++ b/docs/LSP.html @@ -83,7 +83,7 @@ diff --git a/docs/LTSA.html b/docs/LTSA.html index fa44e7c..ee70e15 100644 --- a/docs/LTSA.html +++ b/docs/LTSA.html @@ -83,7 +83,7 @@ diff --git a/docs/MDS.html b/docs/MDS.html index ca9ab52..c1d992d 100644 --- a/docs/MDS.html +++ b/docs/MDS.html @@ -83,7 +83,7 @@ diff --git a/docs/Matrix.html b/docs/Matrix.html index 2966c72..4353dcb 100644 --- a/docs/Matrix.html +++ b/docs/Matrix.html @@ -83,7 +83,7 @@ diff --git a/docs/NNDescent.html b/docs/NNDescent.html index 768880e..3b37b79 100644 --- a/docs/NNDescent.html +++ b/docs/NNDescent.html @@ -83,7 +83,7 @@ diff --git a/docs/OAP.html b/docs/OAP.html index b667428..04184ef 100644 --- a/docs/OAP.html +++ b/docs/OAP.html @@ -83,7 +83,7 @@ diff --git a/docs/OPTICS.html b/docs/OPTICS.html index 8efad7a..720d155 100644 --- a/docs/OPTICS.html +++ b/docs/OPTICS.html @@ -83,7 +83,7 @@ diff --git a/docs/PCA.html b/docs/PCA.html index 3b66dca..44491f0 100644 --- a/docs/PCA.html +++ b/docs/PCA.html @@ -83,7 +83,7 @@ diff --git a/docs/Randomizer.html b/docs/Randomizer.html index cd1e3db..cfd3e01 100644 --- a/docs/Randomizer.html +++ b/docs/Randomizer.html @@ -83,7 +83,7 @@ diff --git a/docs/SAMMON.html b/docs/SAMMON.html index 6ef8d93..b0cbf04 100644 --- a/docs/SAMMON.html +++ b/docs/SAMMON.html @@ -83,7 +83,7 @@ diff --git a/docs/TSNE.html b/docs/TSNE.html index ce4c37d..15a1167 100644 --- a/docs/TSNE.html +++ b/docs/TSNE.html @@ -83,7 +83,7 @@ diff --git a/docs/TopoMap.html b/docs/TopoMap.html index 118e7a9..aab423d 100644 --- a/docs/TopoMap.html +++ b/docs/TopoMap.html @@ -83,7 +83,7 @@ diff --git a/docs/TriMap.html b/docs/TriMap.html index 25db274..c18b531 100644 --- a/docs/TriMap.html +++ b/docs/TriMap.html @@ -83,7 +83,7 @@ diff --git a/docs/UMAP.html b/docs/UMAP.html index 7f4e98e..e6221eb 100644 --- a/docs/UMAP.html +++ b/docs/UMAP.html @@ -83,7 +83,7 @@ diff --git a/docs/XMeans.html b/docs/XMeans.html index db00a33..b5bb5d9 100644 --- a/docs/XMeans.html +++ b/docs/XMeans.html @@ -83,7 +83,7 @@ diff --git a/docs/clustering_Hierarchical_Clustering.js.html b/docs/clustering_Hierarchical_Clustering.js.html index d87b96f..bfa8f73 100644 --- a/docs/clustering_Hierarchical_Clustering.js.html +++ b/docs/clustering_Hierarchical_Clustering.js.html @@ -83,7 +83,7 @@ diff --git a/docs/clustering_KMeans.js.html b/docs/clustering_KMeans.js.html index a3698ab..fe9faf9 100644 --- a/docs/clustering_KMeans.js.html +++ b/docs/clustering_KMeans.js.html @@ -83,7 +83,7 @@ diff --git a/docs/clustering_KMedoids.js.html b/docs/clustering_KMedoids.js.html index fb306d6..6217238 100644 --- a/docs/clustering_KMedoids.js.html +++ b/docs/clustering_KMedoids.js.html @@ -83,7 +83,7 @@ diff --git a/docs/clustering_OPTICS.js.html b/docs/clustering_OPTICS.js.html index 7db1dac..6aaebb6 100644 --- a/docs/clustering_OPTICS.js.html +++ b/docs/clustering_OPTICS.js.html @@ -83,7 +83,7 @@ diff --git a/docs/clustering_XMeans.js.html b/docs/clustering_XMeans.js.html index 10d1fc6..08af052 100644 --- a/docs/clustering_XMeans.js.html +++ b/docs/clustering_XMeans.js.html @@ -83,7 +83,7 @@ diff --git a/docs/clustering_index.js.html b/docs/clustering_index.js.html index cbc2cb3..1c17441 100644 --- a/docs/clustering_index.js.html +++ b/docs/clustering_index.js.html @@ -83,7 +83,7 @@ diff --git a/docs/datastructure_DisjointSet.js.html b/docs/datastructure_DisjointSet.js.html index 5af3a5c..16c19ff 100644 --- a/docs/datastructure_DisjointSet.js.html +++ b/docs/datastructure_DisjointSet.js.html @@ -83,7 +83,7 @@ diff --git a/docs/datastructure_Heap.js.html b/docs/datastructure_Heap.js.html index 4efefc0..1dcc931 100644 --- a/docs/datastructure_Heap.js.html +++ b/docs/datastructure_Heap.js.html @@ -83,7 +83,7 @@ diff --git a/docs/datastructure_index.js.html b/docs/datastructure_index.js.html index 52ff93c..ac9d7ec 100644 --- a/docs/datastructure_index.js.html +++ b/docs/datastructure_index.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_DR.js.html b/docs/dimred_DR.js.html index c6eff68..1b1e839 100644 --- a/docs/dimred_DR.js.html +++ b/docs/dimred_DR.js.html @@ -83,7 +83,7 @@ @@ -163,7 +163,7 @@

if (!this._parameters.hasOwnProperty(name)) { throw new Error(`${name} is not a valid parameter!`); } - if (value) { + if (value !== null) { this._parameters[name] = value; this._is_initialized = false; return this; diff --git a/docs/dimred_FASTMAP.js.html b/docs/dimred_FASTMAP.js.html index abf353c..f9a78b3 100644 --- a/docs/dimred_FASTMAP.js.html +++ b/docs/dimred_FASTMAP.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_HIPP.js.html b/docs/dimred_HIPP.js.html index 973fd29..f09e693 100644 --- a/docs/dimred_HIPP.js.html +++ b/docs/dimred_HIPP.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_ISOMAP.js.html b/docs/dimred_ISOMAP.js.html index 08a05bd..1b46755 100644 --- a/docs/dimred_ISOMAP.js.html +++ b/docs/dimred_ISOMAP.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_LDA.js.html b/docs/dimred_LDA.js.html index 548bfcd..871001e 100644 --- a/docs/dimred_LDA.js.html +++ b/docs/dimred_LDA.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_LLE.js.html b/docs/dimred_LLE.js.html index f8de957..4b2fc77 100644 --- a/docs/dimred_LLE.js.html +++ b/docs/dimred_LLE.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_LSP.js.html b/docs/dimred_LSP.js.html index c43d9e9..5cafbd5 100644 --- a/docs/dimred_LSP.js.html +++ b/docs/dimred_LSP.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_LTSA.js.html b/docs/dimred_LTSA.js.html index c9d1f90..fc12a02 100644 --- a/docs/dimred_LTSA.js.html +++ b/docs/dimred_LTSA.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_MDS.js.html b/docs/dimred_MDS.js.html index 25179a3..da5a9b2 100644 --- a/docs/dimred_MDS.js.html +++ b/docs/dimred_MDS.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_OAP.js.html b/docs/dimred_OAP.js.html index 29ace56..e243f0f 100644 --- a/docs/dimred_OAP.js.html +++ b/docs/dimred_OAP.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_PCA.js.html b/docs/dimred_PCA.js.html index 8746dfb..9938018 100644 --- a/docs/dimred_PCA.js.html +++ b/docs/dimred_PCA.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_SAMMON.js.html b/docs/dimred_SAMMON.js.html index 55adc16..c177f6b 100644 --- a/docs/dimred_SAMMON.js.html +++ b/docs/dimred_SAMMON.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_TSNE.js.html b/docs/dimred_TSNE.js.html index 59827ba..dc9362b 100644 --- a/docs/dimred_TSNE.js.html +++ b/docs/dimred_TSNE.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_TopoMap.js.html b/docs/dimred_TopoMap.js.html index f46d397..fabf987 100644 --- a/docs/dimred_TopoMap.js.html +++ b/docs/dimred_TopoMap.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_TriMap.js.html b/docs/dimred_TriMap.js.html index 0a39e21..cd280ad 100644 --- a/docs/dimred_TriMap.js.html +++ b/docs/dimred_TriMap.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_UMAP.js.html b/docs/dimred_UMAP.js.html index fb85c2a..4fea180 100644 --- a/docs/dimred_UMAP.js.html +++ b/docs/dimred_UMAP.js.html @@ -83,7 +83,7 @@ diff --git a/docs/dimred_index.js.html b/docs/dimred_index.js.html index d85497d..7acbd1a 100644 --- a/docs/dimred_index.js.html +++ b/docs/dimred_index.js.html @@ -83,7 +83,7 @@ diff --git a/docs/global.html b/docs/global.html index b54a12a..5d56184 100644 --- a/docs/global.html +++ b/docs/global.html @@ -83,7 +83,7 @@ diff --git a/docs/index.html b/docs/index.html index ddfc987..102bb21 100644 --- a/docs/index.html +++ b/docs/index.html @@ -83,7 +83,7 @@ diff --git a/docs/knn_BallTree.js.html b/docs/knn_BallTree.js.html index 4fc7511..27859f8 100644 --- a/docs/knn_BallTree.js.html +++ b/docs/knn_BallTree.js.html @@ -83,7 +83,7 @@ diff --git a/docs/knn_HNSW.js.html b/docs/knn_HNSW.js.html index 53d9131..01c6152 100644 --- a/docs/knn_HNSW.js.html +++ b/docs/knn_HNSW.js.html @@ -83,7 +83,7 @@ diff --git a/docs/knn_KNN.js.html b/docs/knn_KNN.js.html index b5d29bc..09eff1b 100644 --- a/docs/knn_KNN.js.html +++ b/docs/knn_KNN.js.html @@ -83,7 +83,7 @@ diff --git a/docs/knn_NNDescent.js.html b/docs/knn_NNDescent.js.html index 364b7cb..e5c3ed8 100644 --- a/docs/knn_NNDescent.js.html +++ b/docs/knn_NNDescent.js.html @@ -83,7 +83,7 @@ diff --git a/docs/knn_dijkstra.js.html b/docs/knn_dijkstra.js.html index c207b4b..253cbb8 100644 --- a/docs/knn_dijkstra.js.html +++ b/docs/knn_dijkstra.js.html @@ -83,7 +83,7 @@ diff --git a/docs/knn_index.js.html b/docs/knn_index.js.html index 9097100..648de58 100644 --- a/docs/knn_index.js.html +++ b/docs/knn_index.js.html @@ -83,7 +83,7 @@ diff --git a/docs/linear_algebra_index.js.html b/docs/linear_algebra_index.js.html index 96d7138..92db22f 100644 --- a/docs/linear_algebra_index.js.html +++ b/docs/linear_algebra_index.js.html @@ -83,7 +83,7 @@ diff --git a/docs/linear_algebra_inner_product.js.html b/docs/linear_algebra_inner_product.js.html index 704860b..13c4123 100644 --- a/docs/linear_algebra_inner_product.js.html +++ b/docs/linear_algebra_inner_product.js.html @@ -83,7 +83,7 @@ diff --git a/docs/linear_algebra_poweriteration_m.js.html b/docs/linear_algebra_poweriteration_m.js.html index 99a541b..070c682 100644 --- a/docs/linear_algebra_poweriteration_m.js.html +++ b/docs/linear_algebra_poweriteration_m.js.html @@ -83,7 +83,7 @@ diff --git a/docs/linear_algebra_poweriteration_n.js.html b/docs/linear_algebra_poweriteration_n.js.html index d6b547e..290276e 100644 --- a/docs/linear_algebra_poweriteration_n.js.html +++ b/docs/linear_algebra_poweriteration_n.js.html @@ -83,7 +83,7 @@ diff --git a/docs/linear_algebra_qr.js.html b/docs/linear_algebra_qr.js.html index 97f6d43..dd183b8 100644 --- a/docs/linear_algebra_qr.js.html +++ b/docs/linear_algebra_qr.js.html @@ -83,7 +83,7 @@ diff --git a/docs/linear_algebra_qr_givens.js.html b/docs/linear_algebra_qr_givens.js.html index 3dd1a3e..adc9f53 100644 --- a/docs/linear_algebra_qr_givens.js.html +++ b/docs/linear_algebra_qr_givens.js.html @@ -83,7 +83,7 @@ diff --git a/docs/linear_algebra_qr_householder.js.html b/docs/linear_algebra_qr_householder.js.html index 0150d8f..d59c08f 100644 --- a/docs/linear_algebra_qr_householder.js.html +++ b/docs/linear_algebra_qr_householder.js.html @@ -83,7 +83,7 @@ diff --git a/docs/linear_algebra_sapi.js.html b/docs/linear_algebra_sapi.js.html index 41fcd9c..9b7821f 100644 --- a/docs/linear_algebra_sapi.js.html +++ b/docs/linear_algebra_sapi.js.html @@ -83,7 +83,7 @@ diff --git a/docs/linear_algebra_simultaneous_poweriteration.js.html b/docs/linear_algebra_simultaneous_poweriteration.js.html index 913849b..147c6b4 100644 --- a/docs/linear_algebra_simultaneous_poweriteration.js.html +++ b/docs/linear_algebra_simultaneous_poweriteration.js.html @@ -83,7 +83,7 @@ diff --git a/docs/linear_algebra_svrg.js.html b/docs/linear_algebra_svrg.js.html index 95c6ce7..e7e4bc5 100644 --- a/docs/linear_algebra_svrg.js.html +++ b/docs/linear_algebra_svrg.js.html @@ -83,7 +83,7 @@ diff --git a/docs/matrix_Matrix.js.html b/docs/matrix_Matrix.js.html index 07527f4..2c646ee 100644 --- a/docs/matrix_Matrix.js.html +++ b/docs/matrix_Matrix.js.html @@ -83,7 +83,7 @@ diff --git a/docs/matrix_distance_matrix.js.html b/docs/matrix_distance_matrix.js.html index 4ce356c..b3c5277 100644 --- a/docs/matrix_distance_matrix.js.html +++ b/docs/matrix_distance_matrix.js.html @@ -83,7 +83,7 @@ diff --git a/docs/matrix_index.js.html b/docs/matrix_index.js.html index 9941c0e..7a324b2 100644 --- a/docs/matrix_index.js.html +++ b/docs/matrix_index.js.html @@ -83,7 +83,7 @@ diff --git a/docs/matrix_k_nearest_neighbors.js.html b/docs/matrix_k_nearest_neighbors.js.html index 3e0c997..5d58769 100644 --- a/docs/matrix_k_nearest_neighbors.js.html +++ b/docs/matrix_k_nearest_neighbors.js.html @@ -83,7 +83,7 @@ diff --git a/docs/matrix_linspace.js.html b/docs/matrix_linspace.js.html index 7aea265..327e29e 100644 --- a/docs/matrix_linspace.js.html +++ b/docs/matrix_linspace.js.html @@ -83,7 +83,7 @@ diff --git a/docs/matrix_norm.js.html b/docs/matrix_norm.js.html index ffc4b3a..3324091 100644 --- a/docs/matrix_norm.js.html +++ b/docs/matrix_norm.js.html @@ -83,7 +83,7 @@ diff --git a/docs/matrix_normalize.js.html b/docs/matrix_normalize.js.html index c5abac4..bb336d3 100644 --- a/docs/matrix_normalize.js.html +++ b/docs/matrix_normalize.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_canberra.js.html b/docs/metrics_canberra.js.html index bc19ce7..0f11c78 100644 --- a/docs/metrics_canberra.js.html +++ b/docs/metrics_canberra.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_chebyshev.js.html b/docs/metrics_chebyshev.js.html index d7b0ad2..381b2cd 100644 --- a/docs/metrics_chebyshev.js.html +++ b/docs/metrics_chebyshev.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_cosine.js.html b/docs/metrics_cosine.js.html index 1bfda91..ee534c8 100644 --- a/docs/metrics_cosine.js.html +++ b/docs/metrics_cosine.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_euclidean.js.html b/docs/metrics_euclidean.js.html index 9f6bdf1..a5b3f33 100644 --- a/docs/metrics_euclidean.js.html +++ b/docs/metrics_euclidean.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_euclidean_squared.js.html b/docs/metrics_euclidean_squared.js.html index 0e41146..7e734fc 100644 --- a/docs/metrics_euclidean_squared.js.html +++ b/docs/metrics_euclidean_squared.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_hamming.js.html b/docs/metrics_hamming.js.html index eb3eaca..25ad0c9 100644 --- a/docs/metrics_hamming.js.html +++ b/docs/metrics_hamming.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_index.js.html b/docs/metrics_index.js.html index 56e7062..5e2d30f 100644 --- a/docs/metrics_index.js.html +++ b/docs/metrics_index.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_jaccard.js.html b/docs/metrics_jaccard.js.html index a7ea8ee..1814b3e 100644 --- a/docs/metrics_jaccard.js.html +++ b/docs/metrics_jaccard.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_manhattan.js.html b/docs/metrics_manhattan.js.html index 795151c..5fe41b1 100644 --- a/docs/metrics_manhattan.js.html +++ b/docs/metrics_manhattan.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_sokal_michener.js.html b/docs/metrics_sokal_michener.js.html index 51df569..fa2cf38 100644 --- a/docs/metrics_sokal_michener.js.html +++ b/docs/metrics_sokal_michener.js.html @@ -83,7 +83,7 @@ diff --git a/docs/metrics_yule.js.html b/docs/metrics_yule.js.html index a2499b0..be1c1cb 100644 --- a/docs/metrics_yule.js.html +++ b/docs/metrics_yule.js.html @@ -83,7 +83,7 @@ diff --git a/docs/module-clustering.html b/docs/module-clustering.html index 98dde37..19818a3 100644 --- a/docs/module-clustering.html +++ b/docs/module-clustering.html @@ -83,7 +83,7 @@ diff --git a/docs/module-datastructure.html b/docs/module-datastructure.html index 88b7825..b3d1640 100644 --- a/docs/module-datastructure.html +++ b/docs/module-datastructure.html @@ -83,7 +83,7 @@ diff --git a/docs/module-dimensionality_reduction.html b/docs/module-dimensionality_reduction.html index 82b3cd5..dbc19bc 100644 --- a/docs/module-dimensionality_reduction.html +++ b/docs/module-dimensionality_reduction.html @@ -83,7 +83,7 @@ diff --git a/docs/module-knn.html b/docs/module-knn.html index 5e76904..8513a14 100644 --- a/docs/module-knn.html +++ b/docs/module-knn.html @@ -83,7 +83,7 @@ diff --git a/docs/module-linear_algebra.html b/docs/module-linear_algebra.html index b7cf501..2d6307e 100644 --- a/docs/module-linear_algebra.html +++ b/docs/module-linear_algebra.html @@ -83,7 +83,7 @@ diff --git a/docs/module-matrix.html b/docs/module-matrix.html index eebdf3c..b84ffd5 100644 --- a/docs/module-matrix.html +++ b/docs/module-matrix.html @@ -83,7 +83,7 @@ diff --git a/docs/module-metrics.html b/docs/module-metrics.html index 293c8e9..1ab13b9 100644 --- a/docs/module-metrics.html +++ b/docs/module-metrics.html @@ -83,7 +83,7 @@ diff --git a/docs/module-numerical.html b/docs/module-numerical.html index ab5e3c1..fc79b29 100644 --- a/docs/module-numerical.html +++ b/docs/module-numerical.html @@ -83,7 +83,7 @@ diff --git a/docs/module-optimization.html b/docs/module-optimization.html index 56600d4..0401738 100644 --- a/docs/module-optimization.html +++ b/docs/module-optimization.html @@ -83,7 +83,7 @@ diff --git a/docs/module-utils.html b/docs/module-utils.html index eefb5b8..9eaffe7 100644 --- a/docs/module-utils.html +++ b/docs/module-utils.html @@ -83,7 +83,7 @@ diff --git a/docs/numerical_index.js.html b/docs/numerical_index.js.html index c658da4..18a9b41 100644 --- a/docs/numerical_index.js.html +++ b/docs/numerical_index.js.html @@ -83,7 +83,7 @@ diff --git a/docs/numerical_kahan_sum.js.html b/docs/numerical_kahan_sum.js.html index 272ddec..9ee3608 100644 --- a/docs/numerical_kahan_sum.js.html +++ b/docs/numerical_kahan_sum.js.html @@ -83,7 +83,7 @@ diff --git a/docs/numerical_neumair_sum.js.html b/docs/numerical_neumair_sum.js.html index f66fdfc..83c2119 100644 --- a/docs/numerical_neumair_sum.js.html +++ b/docs/numerical_neumair_sum.js.html @@ -83,7 +83,7 @@ diff --git a/docs/optimization_index.js.html b/docs/optimization_index.js.html index 0995c33..912fe12 100644 --- a/docs/optimization_index.js.html +++ b/docs/optimization_index.js.html @@ -83,7 +83,7 @@ diff --git a/docs/optimization_powell.js.html b/docs/optimization_powell.js.html index 24b0c08..9494a97 100644 --- a/docs/optimization_powell.js.html +++ b/docs/optimization_powell.js.html @@ -83,7 +83,7 @@ diff --git a/docs/util_index.js.html b/docs/util_index.js.html index 9efcc2a..a88b587 100644 --- a/docs/util_index.js.html +++ b/docs/util_index.js.html @@ -83,7 +83,7 @@ diff --git a/docs/util_max.js.html b/docs/util_max.js.html index e745892..7e43e01 100644 --- a/docs/util_max.js.html +++ b/docs/util_max.js.html @@ -83,7 +83,7 @@ diff --git a/docs/util_min.js.html b/docs/util_min.js.html index d1d8090..c3822f3 100644 --- a/docs/util_min.js.html +++ b/docs/util_min.js.html @@ -83,7 +83,7 @@ diff --git a/docs/util_randomizer.js.html b/docs/util_randomizer.js.html index afe31cf..76cf500 100644 --- a/docs/util_randomizer.js.html +++ b/docs/util_randomizer.js.html @@ -83,7 +83,7 @@