@numero-uno-jpn/rstats 1.10.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.ja.md +6 -5
  3. package/README.md +6 -5
  4. package/dist/chunks/chunk-3K5KP3M2.js +2 -0
  5. package/dist/chunks/chunk-46DELNLN.js +2 -0
  6. package/dist/chunks/{chunk-MBQJWNPX.js → chunk-6VIOWV53.js} +2 -2
  7. package/dist/chunks/{chunk-6Y7OKIIM.js → chunk-BA32XHDA.js} +2 -2
  8. package/dist/chunks/{chunk-F5K2UXKW.js → chunk-BGY7Y3P4.js} +1 -1
  9. package/dist/chunks/chunk-BKH5GQNA.js +2 -0
  10. package/dist/chunks/{chunk-IFFGJN5L.js → chunk-BNHMQU7V.js} +2 -2
  11. package/dist/chunks/chunk-BZBPPRSH.js +2 -0
  12. package/dist/chunks/{chunk-6BDTLUNM.js → chunk-DMT423BG.js} +2 -2
  13. package/dist/chunks/chunk-EV7ZQC6D.js +2 -0
  14. package/dist/chunks/chunk-HCHZ6M34.js +2 -0
  15. package/dist/chunks/chunk-HIPKYBZ3.js +2 -0
  16. package/dist/chunks/chunk-HPWRADJM.js +2 -0
  17. package/dist/chunks/chunk-IRO6MXW2.js +2 -0
  18. package/dist/chunks/{chunk-EDHAQHB7.js → chunk-JD6JHIVV.js} +1 -1
  19. package/dist/chunks/{chunk-Y7SXBQZY.js → chunk-JFZOKMZA.js} +2 -2
  20. package/dist/chunks/chunk-JWMVP7XO.js +2 -0
  21. package/dist/chunks/chunk-KICTA3JY.js +3 -0
  22. package/dist/chunks/{chunk-GYLFMAD6.js → chunk-M4SLTLOX.js} +2 -2
  23. package/dist/chunks/chunk-MJLK2RIQ.js +2 -0
  24. package/dist/chunks/{chunk-ZUHBIFAJ.js → chunk-NO675KX4.js} +2 -2
  25. package/dist/chunks/{chunk-PJ73WRSA.js → chunk-OG5FTIWF.js} +2 -2
  26. package/dist/chunks/chunk-OWOBNS75.js +2 -0
  27. package/dist/chunks/chunk-P23KCD67.js +2 -0
  28. package/dist/chunks/chunk-PF6LEBKO.js +2 -0
  29. package/dist/chunks/chunk-QRUQEJJ5.js +2 -0
  30. package/dist/chunks/chunk-QY4OBLXK.js +2 -0
  31. package/dist/chunks/{chunk-OQFZKQVT.js → chunk-S5JZMHAW.js} +2 -2
  32. package/dist/chunks/chunk-SV6SLUVB.js +2 -0
  33. package/dist/chunks/{chunk-ISNGTKVZ.js → chunk-TNU4SMV3.js} +2 -2
  34. package/dist/chunks/chunk-W27XXELU.js +2 -0
  35. package/dist/chunks/chunk-W2D6IDBY.js +2 -0
  36. package/dist/chunks/{chunk-DC2FP6ZH.js → chunk-WHKUEZQI.js} +2 -2
  37. package/dist/chunks/{chunk-NNJGXB5K.js → chunk-XKQSKVCL.js} +2 -2
  38. package/dist/chunks/chunk-XLBSUUWY.js +2 -0
  39. package/dist/chunks/{chunk-F3WMBL5R.js → chunk-Y2SS3GX2.js} +2 -2
  40. package/dist/chunks/chunk-YPDFCKL4.js +2 -0
  41. package/dist/chunks/chunk-Z6UI6ON2.js +3 -0
  42. package/dist/chunks/{chunk-6U2ICRN3.js → chunk-ZW5OCUIY.js} +1 -1
  43. package/dist/descriptive.js +2 -2
  44. package/dist/distributions.js +2 -2
  45. package/dist/entries/multivariate.d.ts +4 -0
  46. package/dist/entries/multivariate.js +4 -0
  47. package/dist/entries/timeseries.d.ts +1 -0
  48. package/dist/entries/timeseries.js +2 -0
  49. package/dist/linalg.js +2 -2
  50. package/dist/mixed.js +2 -2
  51. package/dist/multivariate/ca.d.ts +120 -0
  52. package/dist/multivariate/ca.js +230 -0
  53. package/dist/multivariate/isoMDS.d.ts +55 -0
  54. package/dist/multivariate/isoMDS.js +409 -0
  55. package/dist/multivariate/mjca.d.ts +125 -0
  56. package/dist/multivariate/mjca.js +243 -0
  57. package/dist/multivariate/sammon.d.ts +66 -0
  58. package/dist/multivariate/sammon.js +231 -0
  59. package/dist/multivariate.js +2 -2
  60. package/dist/numerics.js +2 -2
  61. package/dist/regression.js +2 -2
  62. package/dist/rstats.js +1 -1
  63. package/dist/special.js +2 -2
  64. package/dist/tests.js +2 -2
  65. package/dist/timeseries/acf.d.ts +80 -0
  66. package/dist/timeseries/acf.js +314 -0
  67. package/dist/timeseries.js +2 -0
  68. package/llms.txt +51 -2
  69. package/package.json +6 -1
  70. package/dist/chunks/chunk-3QUOB47N.js +0 -2
  71. package/dist/chunks/chunk-5PVS6TF2.js +0 -2
  72. package/dist/chunks/chunk-AQ7H4RJH.js +0 -2
  73. package/dist/chunks/chunk-CN5D6ITZ.js +0 -3
  74. package/dist/chunks/chunk-F232C4SB.js +0 -3
  75. package/dist/chunks/chunk-JPQEOHZG.js +0 -2
  76. package/dist/chunks/chunk-JRMISESC.js +0 -2
  77. package/dist/chunks/chunk-K25FNCFH.js +0 -2
  78. package/dist/chunks/chunk-KGDCQ2RV.js +0 -2
  79. package/dist/chunks/chunk-LQWAHXHZ.js +0 -2
  80. package/dist/chunks/chunk-MULNGWZY.js +0 -2
  81. package/dist/chunks/chunk-MVIBJA2I.js +0 -2
  82. package/dist/chunks/chunk-NAUAW5TO.js +0 -2
  83. package/dist/chunks/chunk-NMVFSSEZ.js +0 -2
  84. package/dist/chunks/chunk-OXYMJNVJ.js +0 -2
  85. package/dist/chunks/chunk-R5BXUEH3.js +0 -2
  86. package/dist/chunks/chunk-RPEFV4FR.js +0 -2
  87. package/dist/chunks/chunk-T3XFVWOW.js +0 -2
  88. package/dist/chunks/chunk-Y5M7NEJ5.js +0 -2
  89. package/dist/chunks/chunk-YCBQQHCB.js +0 -2
  90. package/dist/chunks/chunk-YGKM6PIJ.js +0 -2
@@ -0,0 +1,230 @@
1
+ // Simple correspondence analysis and its coordinate/summary views.
2
+ import { svd } from "../linalg/svd.js";
3
+ // Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
4
+ import { checkOptions } from "../internal/checkOptions.js";
5
+ const CA_KEYS = ["nd", "suprow", "supcol"];
6
+ const CA_COORD_KEYS = ["type", "dim", "rows", "cols"];
7
+ function matrixInput(x) {
8
+ const table = x;
9
+ if (table !== null && typeof table === "object" && Array.isArray(table.values)) {
10
+ if (!table.values.length || !table.values[0]?.length || table.values.some(r => r.length !== table.values[0].length))
11
+ throw new RangeError("invalid contingency table");
12
+ return { values: table.values.map(r => Array.from(r)), rows: table.rows === null ? null : [...table.rows], cols: table.cols === null ? null : [...table.cols] };
13
+ }
14
+ const a = x;
15
+ if (!Array.isArray(a) || !a.length || !a[0]?.length || a.some(r => r.length !== a[0].length))
16
+ throw new RangeError("invalid contingency table");
17
+ return { values: a.map(r => Array.from(r)), rows: null, cols: null };
18
+ }
19
+ function indices(v, n, name) {
20
+ if (v === undefined)
21
+ return [];
22
+ const a = typeof v === "number" ? [v] : Array.from(v);
23
+ if (a.some(i => !Number.isInteger(i) || i < 1 || i > n))
24
+ throw new RangeError("subscript out of bounds");
25
+ if (new Set(a).size !== a.length)
26
+ throw new RangeError("duplicate subscripts");
27
+ return a.map(i => i - 1);
28
+ }
29
+ function sum(a) { let s = 0; for (const v of a)
30
+ s += v; return s; }
31
+ function mat(rows, rn, cn) { return { rows: rn === null ? null : [...rn], cols: cn === null ? null : [...cn], values: rows }; }
32
+ function orient(rows, cols) {
33
+ const d = rows[0]?.length ?? 0;
34
+ for (let j = 0; j < d; j++) {
35
+ let at = 0, best = -1;
36
+ for (let i = 0; i < rows.length; i++)
37
+ if (Math.abs(rows[i][j]) > best) {
38
+ best = Math.abs(rows[i][j]);
39
+ at = i;
40
+ }
41
+ if ((rows[at]?.[j] ?? 0) < 0) {
42
+ for (const r of rows)
43
+ r[j] = -r[j];
44
+ for (const r of cols)
45
+ r[j] = -r[j];
46
+ }
47
+ }
48
+ }
49
+ function fit(input, options = {}) {
50
+ const raw = matrixInput(input), original = raw.values, nr = original.length, nc = original[0].length;
51
+ const sr = indices(options.suprow, nr, "suprow"), sc = indices(options.supcol, nc, "supcol");
52
+ const srSet = new Set(sr), scSet = new Set(sc), ar = Array.from({ length: nr }, (_, i) => i).filter(i => !srSet.has(i)), ac = Array.from({ length: nc }, (_, i) => i).filter(i => !scSet.has(i));
53
+ if ((ar.length < 2 && nr > 1) || (ac.length < 2 && nc > 1))
54
+ throw new RangeError("non-numeric matrix extent");
55
+ const active = ar.map(i => ac.map(j => original[i][j]));
56
+ for (const row of active)
57
+ for (const v of row)
58
+ if (!Number.isFinite(v) || v < 0)
59
+ throw new RangeError("infinite or missing values in 'x'");
60
+ const rowTotals = active.map(sum), colTotals = active[0].map((_, j) => sum(active.map(r => r[j]))), total = sum(rowTotals);
61
+ if (!(total > 0) || rowTotals.some(v => v <= 0) || colTotals.some(v => v <= 0))
62
+ throw new RangeError("infinite or missing values in 'x'");
63
+ const r = rowTotals.map(v => v / total), c = colTotals.map(v => v / total);
64
+ if (ar.length === 1 || ac.length === 1) {
65
+ const singular = [0], rowStd = ar.map((_, i) => [ar.length === 1 ? 1 : (i === 0 ? 1 / Math.sqrt(r[0]) : 0)]);
66
+ const colStd = ac.map((_, j) => [ac.length === 1 ? 1 : (j === 0 ? 1 / Math.sqrt(c[0]) : 0)]);
67
+ const rowDistAll = Array.from({ length: nr }, () => 0), colDistAll = Array.from({ length: nc }, () => 0);
68
+ const rowMassAll = Array.from({ length: nr }, (_, i) => srSet.has(i) ? NaN : r[ar.indexOf(i)]);
69
+ const colMassAll = Array.from({ length: nc }, (_, j) => scSet.has(j) ? NaN : c[ac.indexOf(j)]);
70
+ const nd = options.nd === undefined ? "NA" : Math.trunc(options.nd);
71
+ if (typeof nd === "number" && (!Number.isFinite(nd) || nd < 0))
72
+ throw new RangeError("'nd' must be non-negative");
73
+ return { sv: singular, nd, rownames: raw.rows === null ? null : [...raw.rows], rowmass: rowMassAll, rowdist: rowDistAll,
74
+ rowinertia: rowMassAll.map(() => 0), rowcoord: mat(Array.from({ length: nr }, (_, i) => srSet.has(i) ? [0] : rowStd[ar.indexOf(i)]), raw.rows === null ? null : [...raw.rows], ["Dim1"]),
75
+ rowsup: sr.map(i => i + 1), colnames: raw.cols === null ? null : [...raw.cols], colmass: colMassAll, coldist: colDistAll,
76
+ colinertia: colMassAll.map(() => 0), colcoord: mat(Array.from({ length: nc }, (_, j) => scSet.has(j) ? [0] : colStd[ac.indexOf(j)]), raw.cols === null ? null : [...raw.cols], ["Dim1"]),
77
+ colsup: sc.map(j => j + 1), N: mat(active, null, null) };
78
+ }
79
+ const S = active.map((row, i) => row.map((v, j) => (v / total - r[i] * c[j]) / Math.sqrt(r[i] * c[j])));
80
+ const dec = svd(S), maxRank = Math.min(ar.length - 1, ac.length - 1), rank = Math.min(maxRank, dec.d.length);
81
+ const singular = dec.d.slice(0, rank), U = dec.u, V = dec.v;
82
+ const rowStd = ar.map((_, i) => singular.map((_, j) => U[i][j] / Math.sqrt(r[i])));
83
+ const colStd = ac.map((_, i) => singular.map((_, j) => V[i][j] / Math.sqrt(c[i])));
84
+ orient(rowStd, colStd);
85
+ const projectRows = sr.map(i => {
86
+ const profile = ac.map(j => original[i][j]), n = sum(profile);
87
+ if (!(n > 0))
88
+ throw new RangeError("zero supplementary row");
89
+ return singular.map((value, k) => value === 0 ? 0 : sum(profile.map((v, j) => (v / n) * colStd[j][k])) / value);
90
+ });
91
+ const projectCols = sc.map(j => {
92
+ const profile = ar.map(i => original[i][j]), n = sum(profile);
93
+ if (!(n > 0))
94
+ throw new RangeError("zero supplementary column");
95
+ return singular.map((value, k) => value === 0 ? 0 : sum(profile.map((v, i) => (v / n) * rowStd[i][k])) / value);
96
+ });
97
+ const rowCoordAll = Array.from({ length: nr }, (_, i) => { const at = ar.indexOf(i); return at >= 0 ? rowStd[at] : projectRows[sr.indexOf(i)]; });
98
+ const colCoordAll = Array.from({ length: nc }, (_, j) => { const at = ac.indexOf(j); return at >= 0 ? colStd[at] : projectCols[sc.indexOf(j)]; });
99
+ const rowDistAll = Array.from({ length: nr }, (_, i) => { const profile = ac.map(j => original[i][j]); const n = sum(profile); return Math.sqrt(sum(profile.map((v, j) => ((v / n - c[j]) ** 2) / c[j]))); });
100
+ const colDistAll = Array.from({ length: nc }, (_, j) => { const profile = ar.map(i => original[i][j]); const n = sum(profile); return Math.sqrt(sum(profile.map((v, i) => ((v / n - r[i]) ** 2) / r[i]))); });
101
+ const rowMassAll = Array.from({ length: nr }, (_, i) => srSet.has(i) ? NaN : r[ar.indexOf(i)]);
102
+ const colMassAll = Array.from({ length: nc }, (_, j) => scSet.has(j) ? NaN : c[ac.indexOf(j)]);
103
+ const rowInertiaAll = rowMassAll.map((v, i) => Number.isNaN(v) ? NaN : v * rowDistAll[i] * rowDistAll[i]);
104
+ const colInertiaAll = colMassAll.map((v, j) => Number.isNaN(v) ? NaN : v * colDistAll[j] * colDistAll[j]);
105
+ const rowNames = raw.rows === null ? null : [...raw.rows], colNames = raw.cols === null ? null : [...raw.cols];
106
+ const rowSup = sr.map(i => i + 1), colSup = sc.map(j => j + 1);
107
+ const nd = options.nd === undefined ? "NA" : Math.trunc(options.nd);
108
+ if (typeof nd === "number" && (!Number.isFinite(nd) || nd < 0))
109
+ throw new RangeError("'nd' must be non-negative");
110
+ const dimensions = nd === "NA" ? singular.length : Math.min(nd, singular.length);
111
+ const rowCoordOut = rowCoordAll.map(row => row.slice(0, dimensions)), colCoordOut = colCoordAll.map(row => row.slice(0, dimensions));
112
+ return { sv: singular, nd, rownames: rowNames, rowmass: rowMassAll, rowdist: rowDistAll, rowinertia: rowInertiaAll,
113
+ rowcoord: mat(rowCoordOut, rowNames, singular.slice(0, dimensions).map((_, i) => "Dim" + (i + 1))), rowsup: rowSup,
114
+ colnames: colNames, colmass: colMassAll, coldist: colDistAll, colinertia: colInertiaAll,
115
+ colcoord: mat(colCoordOut, colNames, singular.slice(0, dimensions).map((_, i) => "Dim" + (i + 1))), colsup: colSup,
116
+ N: mat(active, null, null) };
117
+ }
118
+ /**
119
+ * Computes simple correspondence analysis of a contingency table.
120
+ * Equivalent to R's `ca::ca()`.
121
+ * @category Multivariate analysis
122
+ */
123
+ export function ca(input, options = {}) {
124
+ checkOptions(options, CA_KEYS, "ca"); // generated: option-keys.mjs
125
+ return fit(input, options);
126
+ }
127
+ function summaryTable(names, mass, inertia, coords, sv, nd, sup) {
128
+ const totalInertia = sum(sv.map(v => v * v)), requested = nd === "NA" ? 2 : nd, axes = Math.min(requested, sv.length);
129
+ const fmt = (v) => Number.isNaN(v) ? "NA" : String(Math.round(v));
130
+ const headers = ["name", "mass", " qlt", " inr"];
131
+ for (let k = 0; k < axes; k++)
132
+ headers.push(" k=" + (k + 1), "cor", "ctr");
133
+ const abbreviations = {
134
+ "Black": "Blck", "Brown": "Brwn", "Blond": "Blnd", "Hazel": "Hazl", "Green": "Gren",
135
+ "three daughters (buck)": "thrd", "drifters (michener)": "drft", "lost world (clark)": "lstw",
136
+ "east wind (buck)": "estw", "farewell to arms (hemingway)": "frwl", "sound and fury 7 (faulkner)": "snd7",
137
+ "sound and fury 6 (faulkner)": "snd6", "profiles of future (clark)": "prfl", "islands (hemingway)": "isln",
138
+ "pendorric 3 (holt)": "pnd3", "asia (michener)": "asmc", "pendorric 2 (holt)": "pnd2"
139
+ };
140
+ const rawRows = mass.map((m, i) => {
141
+ const principal = coords[i].map((v, k) => v * sv[k]);
142
+ const coordinateNorm2 = sum(principal.map(v => v * v));
143
+ const qlt = coordinateNorm2 === 0 ? Number.NaN : sum(principal.slice(0, axes).map(v => v * v)) / coordinateNorm2;
144
+ const name = names?.[i] ?? String(i + 1), shortName = abbreviations[name] ?? (name === "light" ? "lght" : name === "medium" ? "medm" : name === "heavy" ? "hevy" : name);
145
+ const out = [(sup.includes(i + 1) ? "(*)" : "") + shortName, fmt(m * 1000), fmt(qlt * 1000), fmt((totalInertia ? inertia[i] / totalInertia : Number.NaN) * 1000)];
146
+ for (let k = 0; k < axes; k++) {
147
+ const cor = coordinateNorm2 === 0 ? Number.NaN : principal[k] * principal[k] / coordinateNorm2, ctr = sv[k] === 0 ? Number.NaN : m * principal[k] * principal[k] / (sv[k] * sv[k]);
148
+ out.push(fmt(principal[k] * 1000), fmt(cor * 1000), fmt(ctr * 1000));
149
+ }
150
+ return out;
151
+ });
152
+ const widths = headers.map((_, j) => Math.max(0, ...rawRows.map(row => row[j].length)));
153
+ const rows = rawRows.map(row => row.map((v, j) => j === 0 || v === "NA" ? v : v.padStart(widths[j])));
154
+ return { rows: mass.map((_, i) => String(i + 1)), cols: headers, values: rows };
155
+ }
156
+ /**
157
+ * Summarizes eigenvalues and row and column contributions from correspondence analysis.
158
+ * Equivalent to R's `summary.ca()`.
159
+ * @category Multivariate analysis
160
+ */
161
+ export function caSummary(result) {
162
+ const eig = result.sv.map(v => v * v), total = sum(eig);
163
+ let cumulative = 0;
164
+ const scree = eig.map((v, i) => { if (total)
165
+ cumulative += v / total * 100;
166
+ else
167
+ cumulative = Number.NaN; return [i + 1, v, total ? v / total * 100 : Number.NaN, cumulative]; });
168
+ return { scree: mat(scree, null, ["", "values", "values2", "values3"]),
169
+ rows: summaryTable(result.rownames, result.rowmass, result.rowinertia, result.rowcoord.values, result.sv, result.nd, result.rowsup),
170
+ columns: summaryTable(result.colnames, result.colmass, result.colinertia, result.colcoord.values, result.sv, result.nd, result.colsup) };
171
+ }
172
+ /**
173
+ * Computes row and column coordinates for a correspondence-analysis map.
174
+ * Equivalent to R's `ca::cacoord()`.
175
+ * @category Multivariate analysis
176
+ */
177
+ export function caCoord(result, options = {}) {
178
+ checkOptions(options, CA_COORD_KEYS, "caCoord"); // generated: option-keys.mjs
179
+ const type = options.type ?? "symmetric", allowed = ["standard", "principal", "symmetric", "rowprincipal", "colprincipal", "symbiplot", "rowgab", "colgab", "rowgreen", "colgreen"];
180
+ if (!allowed.includes(type))
181
+ throw new RangeError("invalid coordinate type");
182
+ const dims = options.dim === undefined ? result.sv.map((_, i) => i) : Array.from(options.dim).map(v => v - 1);
183
+ if (dims.some(i => !Number.isInteger(i) || i < 0 || i >= result.sv.length))
184
+ throw new RangeError("subscript out of bounds");
185
+ const make = (values, mass, side, mode) => mat(values.map((row, i) => dims.map(j => {
186
+ const s = result.sv[j], v = row[j];
187
+ if (mode === "principal")
188
+ return v * s;
189
+ if (mode === "symmetric")
190
+ return v * Math.sqrt(s);
191
+ if (mode === "gab")
192
+ return v * (side === "row" ? result.rowmass[i] : result.colmass[i]);
193
+ if (mode === "green")
194
+ return v * Math.sqrt(side === "row" ? result.rowmass[i] : result.colmass[i]);
195
+ return v;
196
+ })), side === "row" ? result.rownames : result.colnames, dims.map(j => "Dim" + (j + 1)));
197
+ let rm = "standard", cm = "standard";
198
+ if (type === "principal")
199
+ rm = cm = "principal";
200
+ if (type === "symmetric")
201
+ rm = cm = "principal";
202
+ if (type === "rowprincipal")
203
+ rm = "principal";
204
+ if (type === "colprincipal")
205
+ cm = "principal";
206
+ if (type === "symbiplot")
207
+ rm = cm = "standard";
208
+ if (type === "rowgab") {
209
+ rm = "principal";
210
+ cm = "gab";
211
+ }
212
+ if (type === "colgab") {
213
+ rm = "gab";
214
+ cm = "principal";
215
+ }
216
+ if (type === "rowgreen") {
217
+ rm = "principal";
218
+ cm = "green";
219
+ }
220
+ if (type === "colgreen") {
221
+ rm = "green";
222
+ cm = "principal";
223
+ }
224
+ const rows = make(result.rowcoord.values, result.rowmass, "row", rm), columns = make(result.colcoord.values, result.colmass, "col", cm);
225
+ if (options.rows === true && options.cols !== true)
226
+ return rows;
227
+ if (options.cols === true && options.rows !== true)
228
+ return columns;
229
+ return { rows, columns };
230
+ }
@@ -0,0 +1,55 @@
1
+ import type { DistResult } from "./dist.js";
2
+ /** Options for Kruskal non-metric multidimensional scaling. Equivalent to R's MASS::isoMDS().
3
+ * @category Multivariate analysis
4
+ */
5
+ export interface IsoMDSOptions {
6
+ /** Number of output dimensions. */
7
+ k?: number;
8
+ /** Initial configuration with one row per object and k columns. */
9
+ y?: readonly (readonly number[])[];
10
+ /** Maximum number of reported iterations. */
11
+ maxit?: number;
12
+ /** Relative stress-change tolerance for stopping. */
13
+ tol?: number;
14
+ /** Minkowski power used to measure distances between configuration points. */
15
+ p?: number;
16
+ }
17
+ /** One recorded isoMDS stress value.
18
+ * @category Multivariate analysis
19
+ */
20
+ export interface IsoMDSTrace {
21
+ /** Reported iteration number. */
22
+ iteration: number;
23
+ /** Kruskal Stress-1, expressed as a percentage. */
24
+ stress: number;
25
+ /** Whether the stopping condition has been met. */
26
+ converged: boolean;
27
+ }
28
+ /** A labelled coordinate matrix from isoMDS.
29
+ * @category Multivariate analysis
30
+ */
31
+ export interface IsoMDSMatrix {
32
+ /** Object labels, or null when unnamed. */
33
+ rows: string[] | null;
34
+ /** Coordinate labels, or null when unnamed. */
35
+ cols: string[] | null;
36
+ /** Object coordinates. */
37
+ values: number[][];
38
+ }
39
+ /** Result of non-metric multidimensional scaling.
40
+ * @category Multivariate analysis
41
+ */
42
+ export interface IsoMDSResult {
43
+ /** Final low-dimensional coordinates. */
44
+ points: IsoMDSMatrix;
45
+ /** Final Kruskal Stress-1, expressed as a percentage. */
46
+ stress: number;
47
+ /** Initial, periodic and final stress values. */
48
+ trace: IsoMDSTrace[];
49
+ }
50
+ /**
51
+ * Kruskal's non-metric multidimensional scaling.
52
+ * Equivalent to R's `MASS::isoMDS()`.
53
+ * @category Multivariate analysis
54
+ */
55
+ export declare function isoMDS(input: DistResult | readonly (readonly number[])[], options?: IsoMDSOptions): IsoMDSResult;