@numero-uno-jpn/rstats 1.8.0 → 1.10.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.
- package/CHANGELOG.md +28 -0
- package/README.ja.md +7 -6
- package/README.md +6 -5
- package/dist/chunks/chunk-3QUOB47N.js +2 -0
- package/dist/chunks/{chunk-73IRLCTF.js → chunk-5PVS6TF2.js} +2 -2
- package/dist/chunks/chunk-6BDTLUNM.js +2 -0
- package/dist/chunks/{chunk-YD4U3QZ3.js → chunk-6U2ICRN3.js} +1 -1
- package/dist/chunks/chunk-6Y7OKIIM.js +2 -0
- package/dist/chunks/chunk-AQ7H4RJH.js +2 -0
- package/dist/chunks/{chunk-3DO726WZ.js → chunk-CN5D6ITZ.js} +2 -2
- package/dist/chunks/{chunk-V7ECXPWY.js → chunk-DC2FP6ZH.js} +2 -2
- package/dist/chunks/{chunk-IJST2ZGT.js → chunk-EDHAQHB7.js} +1 -1
- package/dist/chunks/chunk-F232C4SB.js +3 -0
- package/dist/chunks/{chunk-7ODUCEGX.js → chunk-F3WMBL5R.js} +2 -2
- package/dist/chunks/{chunk-QQHF5T2A.js → chunk-F5K2UXKW.js} +1 -1
- package/dist/chunks/{chunk-YT62DNDS.js → chunk-GYLFMAD6.js} +2 -2
- package/dist/chunks/{chunk-JXJDCQYE.js → chunk-IFFGJN5L.js} +2 -2
- package/dist/chunks/{chunk-TUL6UFLQ.js → chunk-ISNGTKVZ.js} +2 -2
- package/dist/chunks/chunk-JPQEOHZG.js +2 -0
- package/dist/chunks/{chunk-2ZQ2TSZS.js → chunk-JRMISESC.js} +2 -2
- package/dist/chunks/{chunk-LZB43TUL.js → chunk-K25FNCFH.js} +2 -2
- package/dist/chunks/{chunk-D3LKPD4H.js → chunk-KGDCQ2RV.js} +2 -2
- package/dist/chunks/{chunk-TYMC2D5I.js → chunk-LQWAHXHZ.js} +2 -2
- package/dist/chunks/{chunk-TQM6KGKT.js → chunk-MBQJWNPX.js} +2 -2
- package/dist/chunks/chunk-MULNGWZY.js +2 -0
- package/dist/chunks/{chunk-2X6PE6JF.js → chunk-MVIBJA2I.js} +2 -2
- package/dist/chunks/chunk-NAUAW5TO.js +2 -0
- package/dist/chunks/{chunk-RWZ6ICYN.js → chunk-NMVFSSEZ.js} +2 -2
- package/dist/chunks/{chunk-45HUI3M4.js → chunk-NNJGXB5K.js} +2 -2
- package/dist/chunks/{chunk-52RWDNO6.js → chunk-OQFZKQVT.js} +2 -2
- package/dist/chunks/chunk-OXYMJNVJ.js +2 -0
- package/dist/chunks/chunk-PJ73WRSA.js +2 -0
- package/dist/chunks/chunk-R5BXUEH3.js +2 -0
- package/dist/chunks/chunk-RPEFV4FR.js +2 -0
- package/dist/chunks/chunk-T3XFVWOW.js +2 -0
- package/dist/chunks/{chunk-GRTQ7FYQ.js → chunk-Y5M7NEJ5.js} +2 -2
- package/dist/chunks/chunk-Y7SXBQZY.js +2 -0
- package/dist/chunks/chunk-YCBQQHCB.js +2 -0
- package/dist/chunks/{chunk-JIAFWEED.js → chunk-YGKM6PIJ.js} +2 -2
- package/dist/chunks/{chunk-DG2RTNIR.js → chunk-ZUHBIFAJ.js} +2 -2
- package/dist/descriptive.js +2 -2
- package/dist/distributions.js +2 -2
- package/dist/entries/multivariate.d.ts +7 -0
- package/dist/entries/multivariate.js +8 -0
- package/dist/entries/tests.d.ts +3 -1
- package/dist/entries/tests.js +3 -1
- package/dist/htest/grubbs.d.ts +68 -0
- package/dist/htest/grubbs.js +151 -0
- package/dist/htest/multipleComparisons.d.ts +21 -0
- package/dist/htest/multipleComparisons.js +47 -0
- package/dist/htest/rankTests.d.ts +35 -0
- package/dist/htest/rankTests.js +89 -1
- package/dist/internal/summary.js +8 -2
- package/dist/linalg/symmetricLeading.d.ts +8 -0
- package/dist/linalg/symmetricLeading.js +231 -0
- package/dist/linalg.js +2 -2
- package/dist/mixed.js +2 -2
- package/dist/multivariate/cancor.d.ts +55 -0
- package/dist/multivariate/cancor.js +167 -0
- package/dist/multivariate/cmdscale.d.ts +40 -0
- package/dist/multivariate/cmdscale.js +171 -0
- package/dist/multivariate/dist.d.ts +63 -0
- package/dist/multivariate/dist.js +218 -0
- package/dist/multivariate/hclust.d.ts +58 -0
- package/dist/multivariate/hclust.js +264 -0
- package/dist/multivariate/kmeans.d.ts +58 -0
- package/dist/multivariate/kmeans.js +392 -0
- package/dist/multivariate/lda.d.ts +146 -0
- package/dist/multivariate/lda.js +325 -0
- package/dist/multivariate/manova.d.ts +106 -0
- package/dist/multivariate/manova.js +303 -0
- package/dist/multivariate.js +2 -0
- package/dist/numerics.js +2 -2
- package/dist/regression.js +2 -2
- package/dist/rstats.js +16 -16
- package/dist/special.js +2 -2
- package/dist/tests.js +15 -15
- package/llms.txt +4 -1
- package/package.json +6 -1
- package/dist/chunks/chunk-53OM63EU.js +0 -2
- package/dist/chunks/chunk-ANZUXEMH.js +0 -3
- package/dist/chunks/chunk-BHQGMZTI.js +0 -2
- package/dist/chunks/chunk-HXYH5ZMB.js +0 -2
- package/dist/chunks/chunk-HYJ4MIZE.js +0 -2
- package/dist/chunks/chunk-MLNWWGGE.js +0 -2
- package/dist/chunks/chunk-VB6PVRSN.js +0 -2
- package/dist/chunks/chunk-Y4KNH43T.js +0 -2
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
2
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
3
|
+
const HCLUST_KEYS = ["method", "members"];
|
|
4
|
+
const CUTREE_KEYS = ["k", "h"];
|
|
5
|
+
const METHODS = ["ward.D", "ward.D2", "single", "complete", "average", "mcquitty", "median", "centroid"];
|
|
6
|
+
function resolveMethod(input) {
|
|
7
|
+
const raw = input ?? "complete";
|
|
8
|
+
if (raw === "ward")
|
|
9
|
+
return { method: "ward.D", warning: ['The "ward" method has been renamed to "ward.D"; note new "ward.D2"'] };
|
|
10
|
+
if (METHODS.includes(raw))
|
|
11
|
+
return { method: raw, warning: [] };
|
|
12
|
+
const matches = METHODS.filter((m) => m.startsWith(raw));
|
|
13
|
+
if (matches.length !== 1)
|
|
14
|
+
throw new RangeError("invalid clustering method");
|
|
15
|
+
return { method: matches[0], warning: [] };
|
|
16
|
+
}
|
|
17
|
+
function index(n, a, b) { return a * n + b; }
|
|
18
|
+
function updateDistance(method, dAB, dAC, dBC, a, b, c) {
|
|
19
|
+
const n = a + b + c;
|
|
20
|
+
if (method === "single")
|
|
21
|
+
return Math.min(dAC, dBC);
|
|
22
|
+
if (method === "complete")
|
|
23
|
+
return Math.max(dAC, dBC);
|
|
24
|
+
if (method === "average")
|
|
25
|
+
return (a * dAC + b * dBC) / (a + b);
|
|
26
|
+
if (method === "mcquitty")
|
|
27
|
+
return (dAC + dBC) / 2;
|
|
28
|
+
if (method === "ward.D")
|
|
29
|
+
return ((a + c) * dAC + (b + c) * dBC - c * dAB) / n;
|
|
30
|
+
if (method === "ward.D2") {
|
|
31
|
+
const scale = Math.max(Math.abs(dAB), Math.abs(dAC), Math.abs(dBC));
|
|
32
|
+
if (scale === 0)
|
|
33
|
+
return 0;
|
|
34
|
+
const ab = dAB / scale, ac = dAC / scale, bc = dBC / scale;
|
|
35
|
+
const v = ((a + c) * ac * ac + (b + c) * bc * bc - c * ab * ab) / n;
|
|
36
|
+
return Math.sqrt(Math.max(0, v)) * scale;
|
|
37
|
+
}
|
|
38
|
+
if (method === "median")
|
|
39
|
+
return (dAC + dBC) / 2 - dAB / 4;
|
|
40
|
+
const ab = a + b;
|
|
41
|
+
return (a * dAC + b * dBC) / ab - (a * b * dAB) / (ab * ab);
|
|
42
|
+
}
|
|
43
|
+
function encode(node, n) { return node < n ? -(node + 1) : node - n + 1; }
|
|
44
|
+
/**
|
|
45
|
+
* Hierarchical agglomerative clustering of a dissimilarity structure by one of eight linkage methods.
|
|
46
|
+
* Equivalent to R's `hclust()`.
|
|
47
|
+
* @category Multivariate analysis
|
|
48
|
+
*/
|
|
49
|
+
export function hclust(d, options = {}) {
|
|
50
|
+
checkOptions(options, HCLUST_KEYS, "hclust"); // generated: option-keys.mjs
|
|
51
|
+
if (!d || typeof d !== "object" || !Array.isArray(d.values) || !Number.isInteger(d.size)) {
|
|
52
|
+
throw new TypeError("d must be a dist object; use asDist() for a square matrix");
|
|
53
|
+
}
|
|
54
|
+
const n = d.size;
|
|
55
|
+
if (n < 2)
|
|
56
|
+
throw new RangeError("must have n >= 2 objects to cluster");
|
|
57
|
+
if (d.values.length !== n * (n - 1) / 2)
|
|
58
|
+
throw new RangeError("invalid dissimilarity object");
|
|
59
|
+
if (d.values.some((v) => !Number.isFinite(v)))
|
|
60
|
+
throw new RangeError("dissimilarities must be finite");
|
|
61
|
+
if (options.members !== undefined && (options.members.length !== n || options.members.some((v) => !Number.isFinite(v) || v <= 0))) {
|
|
62
|
+
throw new RangeError("invalid length or values of members");
|
|
63
|
+
}
|
|
64
|
+
const resolved = resolveMethod(options.method);
|
|
65
|
+
const method = resolved.method;
|
|
66
|
+
const capacity = n;
|
|
67
|
+
const distances = new Float64Array(capacity * capacity);
|
|
68
|
+
let p = 0;
|
|
69
|
+
for (let j = 0; j < n - 1; j++) {
|
|
70
|
+
for (let i = j + 1; i < n; i++) {
|
|
71
|
+
const v = d.values[p++];
|
|
72
|
+
distances[index(n, i, j)] = v;
|
|
73
|
+
distances[index(n, j, i)] = v;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const active = new Uint8Array(n);
|
|
77
|
+
active.fill(1);
|
|
78
|
+
const rank = new Int32Array(n);
|
|
79
|
+
const node = new Int32Array(n);
|
|
80
|
+
const sizes = new Float64Array(n);
|
|
81
|
+
const minLeaf = new Int32Array(n);
|
|
82
|
+
for (let i = 0; i < n; i++) {
|
|
83
|
+
rank[i] = i;
|
|
84
|
+
node[i] = i;
|
|
85
|
+
sizes[i] = options.members?.[i] ?? 1;
|
|
86
|
+
minLeaf[i] = i;
|
|
87
|
+
}
|
|
88
|
+
const merge = new Array(n - 1);
|
|
89
|
+
const height = new Array(n - 1);
|
|
90
|
+
const nnc = n > 200;
|
|
91
|
+
let chain = [];
|
|
92
|
+
for (let step = 0; step < n - 1; step++) {
|
|
93
|
+
let a = -1, b = -1, best = Infinity;
|
|
94
|
+
if (!nnc) {
|
|
95
|
+
let bestLo = Infinity, bestHi = Infinity;
|
|
96
|
+
for (let i = 0; i < n; i++)
|
|
97
|
+
if (active[i]) {
|
|
98
|
+
for (let j = i + 1; j < n; j++)
|
|
99
|
+
if (active[j]) {
|
|
100
|
+
const value = distances[index(n, i, j)];
|
|
101
|
+
const lo = Math.min(minLeaf[i], minLeaf[j]);
|
|
102
|
+
const hi = Math.max(minLeaf[i], minLeaf[j]);
|
|
103
|
+
if (value < best || (value === best && (lo < bestLo || (lo === bestLo && hi < bestHi)))) {
|
|
104
|
+
best = value;
|
|
105
|
+
a = i;
|
|
106
|
+
b = j;
|
|
107
|
+
bestLo = lo;
|
|
108
|
+
bestHi = hi;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
if (chain.length === 0) {
|
|
115
|
+
let first = -1, firstRank = Infinity;
|
|
116
|
+
for (let i = 0; i < n; i++)
|
|
117
|
+
if (active[i] && rank[i] < firstRank) {
|
|
118
|
+
first = i;
|
|
119
|
+
firstRank = rank[i];
|
|
120
|
+
}
|
|
121
|
+
chain.push(first);
|
|
122
|
+
}
|
|
123
|
+
while (true) {
|
|
124
|
+
const last = chain[chain.length - 1];
|
|
125
|
+
let nearest = -1, nearestDistance = Infinity, nearestLeaf = Infinity;
|
|
126
|
+
for (let j = 0; j < n; j++)
|
|
127
|
+
if (active[j] && j !== last) {
|
|
128
|
+
const value = distances[index(n, last, j)];
|
|
129
|
+
if (value < nearestDistance || (value === nearestDistance && minLeaf[j] < nearestLeaf)) {
|
|
130
|
+
nearest = j;
|
|
131
|
+
nearestDistance = value;
|
|
132
|
+
nearestLeaf = minLeaf[j];
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (chain.length > 1 && nearest === chain[chain.length - 2]) {
|
|
136
|
+
a = last;
|
|
137
|
+
b = nearest;
|
|
138
|
+
best = nearestDistance;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
chain.push(nearest);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (a < 0 || b < 0)
|
|
145
|
+
throw new Error("unable to find a finite pair of clusters");
|
|
146
|
+
if (rank[a] > rank[b])
|
|
147
|
+
[a, b] = [b, a];
|
|
148
|
+
const nodeA = node[a], nodeB = node[b];
|
|
149
|
+
merge[step] = [encode(nodeA, n), encode(nodeB, n)];
|
|
150
|
+
height[step] = best;
|
|
151
|
+
const sizeA = sizes[a], sizeB = sizes[b];
|
|
152
|
+
const newNode = n + step;
|
|
153
|
+
for (let c = 0; c < n; c++)
|
|
154
|
+
if (active[c] && c !== a && c !== b) {
|
|
155
|
+
const oldA = distances[index(n, a, c)];
|
|
156
|
+
const oldB = distances[index(n, b, c)];
|
|
157
|
+
const value = updateDistance(method, best, oldA, oldB, sizeA, sizeB, sizes[c]);
|
|
158
|
+
distances[index(n, a, c)] = value;
|
|
159
|
+
distances[index(n, c, a)] = value;
|
|
160
|
+
}
|
|
161
|
+
active[b] = 0;
|
|
162
|
+
node[a] = newNode;
|
|
163
|
+
sizes[a] = sizeA + sizeB;
|
|
164
|
+
minLeaf[a] = Math.min(minLeaf[a], minLeaf[b]);
|
|
165
|
+
rank[a] = n + step;
|
|
166
|
+
if (nnc) {
|
|
167
|
+
// The prefix still describes the same nearest-neighbor path: only the last two
|
|
168
|
+
// clusters were merged, so resume from the preceding cluster instead of
|
|
169
|
+
// rebuilding the path from its first active leaf after every merge.
|
|
170
|
+
chain.length -= 2;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
chain = [];
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const order = [];
|
|
177
|
+
const left = new Int32Array(n * 2 - 1);
|
|
178
|
+
const right = new Int32Array(n * 2 - 1);
|
|
179
|
+
for (let i = 0; i < n - 1; i++) {
|
|
180
|
+
const l = merge[i][0], r = merge[i][1];
|
|
181
|
+
left[n + i] = l < 0 ? -l - 1 : n + l - 1;
|
|
182
|
+
right[n + i] = r < 0 ? -r - 1 : n + r - 1;
|
|
183
|
+
}
|
|
184
|
+
const stack = [2 * n - 2];
|
|
185
|
+
while (stack.length) {
|
|
186
|
+
const current = stack.pop();
|
|
187
|
+
if (current < n)
|
|
188
|
+
order.push(current + 1);
|
|
189
|
+
else {
|
|
190
|
+
stack.push(right[current]);
|
|
191
|
+
stack.push(left[current]);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return { merge, height, order, labels: d.labels === null ? null : [...d.labels], method,
|
|
195
|
+
distMethod: d.method, warnings: resolved.warning };
|
|
196
|
+
}
|
|
197
|
+
/** Cut a hierarchical clustering tree by cluster count or merge height. */
|
|
198
|
+
/**
|
|
199
|
+
* Cuts a hierarchical clustering tree into groups, by number of groups or by height.
|
|
200
|
+
* Equivalent to R's `cutree()`.
|
|
201
|
+
* @category Multivariate analysis
|
|
202
|
+
*/
|
|
203
|
+
export function cutree(tree, options = {}) {
|
|
204
|
+
checkOptions(options, CUTREE_KEYS, "cutree"); // generated: option-keys.mjs
|
|
205
|
+
const n = tree.order.length;
|
|
206
|
+
if (options.k === undefined && options.h === undefined)
|
|
207
|
+
throw new RangeError("either 'k' or 'h' must be specified");
|
|
208
|
+
const byK = options.k !== undefined;
|
|
209
|
+
const requested = byK ? options.k : options.h;
|
|
210
|
+
const values = Array.isArray(requested) ? [...requested] : [requested];
|
|
211
|
+
if (values.some((v) => !Number.isFinite(v)))
|
|
212
|
+
throw new RangeError("k and h must be finite");
|
|
213
|
+
if (!byK && tree.height.some((v, i) => i > 0 && v < tree.height[i - 1])) {
|
|
214
|
+
throw new RangeError("the 'height' component of 'tree' is not sorted (increasingly)");
|
|
215
|
+
}
|
|
216
|
+
const columns = values.map((v) => {
|
|
217
|
+
let merges = 0;
|
|
218
|
+
if (byK) {
|
|
219
|
+
const k = Math.trunc(v);
|
|
220
|
+
if (k < 1 || k > n)
|
|
221
|
+
throw new RangeError(`elements of 'k' must be between 1 and ${n}`);
|
|
222
|
+
merges = n - k;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
while (merges < n - 1 && tree.height[merges] <= v)
|
|
226
|
+
merges++;
|
|
227
|
+
}
|
|
228
|
+
const parent = new Int32Array(2 * n - 1);
|
|
229
|
+
for (let i = 0; i < parent.length; i++)
|
|
230
|
+
parent[i] = i;
|
|
231
|
+
const find = (x) => {
|
|
232
|
+
let root = x;
|
|
233
|
+
while (parent[root] !== root)
|
|
234
|
+
root = parent[root];
|
|
235
|
+
while (parent[x] !== x) {
|
|
236
|
+
const next = parent[x];
|
|
237
|
+
parent[x] = root;
|
|
238
|
+
x = next;
|
|
239
|
+
}
|
|
240
|
+
return root;
|
|
241
|
+
};
|
|
242
|
+
for (let i = 0; i < merges; i++) {
|
|
243
|
+
const pair = tree.merge[i];
|
|
244
|
+
const root = n + i;
|
|
245
|
+
const l = pair[0] < 0 ? -pair[0] - 1 : n + pair[0] - 1;
|
|
246
|
+
const r = pair[1] < 0 ? -pair[1] - 1 : n + pair[1] - 1;
|
|
247
|
+
parent[find(l)] = root;
|
|
248
|
+
parent[find(r)] = root;
|
|
249
|
+
}
|
|
250
|
+
const labels = [];
|
|
251
|
+
const map = new Map();
|
|
252
|
+
for (let i = 0; i < n; i++) {
|
|
253
|
+
const root = find(i);
|
|
254
|
+
if (!map.has(root))
|
|
255
|
+
map.set(root, map.size + 1);
|
|
256
|
+
labels.push(map.get(root));
|
|
257
|
+
}
|
|
258
|
+
return labels;
|
|
259
|
+
});
|
|
260
|
+
const matrix = Array.isArray(requested);
|
|
261
|
+
return { values: matrix ? columns[0]?.map((_, i) => columns.map((col) => col[i])) ?? [] : columns[0] ?? [],
|
|
262
|
+
names: matrix || tree.labels === null ? null : [...tree.labels],
|
|
263
|
+
...(matrix ? { rows: tree.labels === null ? null : [...tree.labels], columns: values.map(String) } : {}) };
|
|
264
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/** @category Multivariate analysis */
|
|
2
|
+
export interface KmeansOptions {
|
|
3
|
+
/** Clustering algorithm; a unique prefix is accepted. */
|
|
4
|
+
algorithm?: "Hartigan-Wong" | "Lloyd" | "Forgy" | "MacQueen" | string;
|
|
5
|
+
/** Maximum number of algorithm iterations (R's iter.max). */
|
|
6
|
+
iterMax?: number;
|
|
7
|
+
/** Number of random initial starts when centers is a count. */
|
|
8
|
+
nstart?: number;
|
|
9
|
+
}
|
|
10
|
+
/** @category Multivariate analysis */
|
|
11
|
+
export interface KmeansInputTable {
|
|
12
|
+
/** Optional observation names, one per row. */
|
|
13
|
+
rows: string[] | null;
|
|
14
|
+
/** Optional variable names, one per column. */
|
|
15
|
+
cols: string[] | null;
|
|
16
|
+
/** Numeric observations arranged by row. */
|
|
17
|
+
values: readonly (readonly number[])[];
|
|
18
|
+
}
|
|
19
|
+
/** @category Multivariate analysis */
|
|
20
|
+
export interface KmeansTable {
|
|
21
|
+
/** Cluster labels corresponding to the rows of the center matrix. */
|
|
22
|
+
rows: string[];
|
|
23
|
+
/** Variable names, or null when the input had no column names. */
|
|
24
|
+
cols: string[] | null;
|
|
25
|
+
/** Cluster centers arranged by row. */
|
|
26
|
+
values: number[][];
|
|
27
|
+
}
|
|
28
|
+
/** @category Multivariate analysis */
|
|
29
|
+
export interface KmeansFit {
|
|
30
|
+
/** 1-based cluster assignment for each observation. */
|
|
31
|
+
cluster: number[];
|
|
32
|
+
/** Observation names, present when the input supplied row names. */
|
|
33
|
+
names?: string[];
|
|
34
|
+
/** Matrix of final cluster centers. */
|
|
35
|
+
centers: KmeansTable;
|
|
36
|
+
/** Total sum of squares around the overall sample mean. */
|
|
37
|
+
totss: number;
|
|
38
|
+
/** Within-cluster sums of squares, one per cluster. */
|
|
39
|
+
withinss: number[];
|
|
40
|
+
/** Sum of all within-cluster sums of squares. */
|
|
41
|
+
totWithinss: number;
|
|
42
|
+
/** Between-cluster sum of squares (totss minus totWithinss). */
|
|
43
|
+
betweenss: number;
|
|
44
|
+
/** Number of observations assigned to each cluster. */
|
|
45
|
+
size: number[];
|
|
46
|
+
/** Number of iterations reported by the selected algorithm. */
|
|
47
|
+
iter: number;
|
|
48
|
+
/** Hartigan-Wong fault code, or null for algorithms without one. */
|
|
49
|
+
ifault: number | null;
|
|
50
|
+
/** Warnings produced during clustering. */
|
|
51
|
+
warnings: string[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* K-means clustering by the Hartigan-Wong, Lloyd, Forgy or MacQueen algorithm.
|
|
55
|
+
* Equivalent to R's `kmeans()`.
|
|
56
|
+
* @category Multivariate analysis
|
|
57
|
+
*/
|
|
58
|
+
export declare function kmeans(x: readonly unknown[] | readonly (readonly unknown[])[] | Record<string, ArrayLike<unknown>> | KmeansInputTable, centersInput: number | readonly number[] | readonly (readonly number[])[], options?: KmeansOptions): KmeansFit;
|