@ac-kit/math-stats 0.4.0 → 0.6.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 +229 -0
- package/README.md +106 -0
- package/dist/_assert-probability.d.ts.map +1 -1
- package/dist/_assert-probability.js +2 -1
- package/dist/_assert-probability.js.map +1 -1
- package/dist/_histogram-rules.d.ts +15 -0
- package/dist/_histogram-rules.d.ts.map +1 -0
- package/dist/_histogram-rules.js +208 -0
- package/dist/_histogram-rules.js.map +1 -0
- package/dist/_satterthwaite.d.ts +13 -0
- package/dist/_satterthwaite.d.ts.map +1 -0
- package/dist/_satterthwaite.js +25 -0
- package/dist/_satterthwaite.js.map +1 -0
- package/dist/adjust-p-values.d.ts +41 -0
- package/dist/adjust-p-values.d.ts.map +1 -0
- package/dist/adjust-p-values.js +75 -0
- package/dist/adjust-p-values.js.map +1 -0
- package/dist/ashman-d.d.ts +25 -0
- package/dist/ashman-d.d.ts.map +1 -0
- package/dist/ashman-d.js +24 -0
- package/dist/ashman-d.js.map +1 -0
- package/dist/beta-distribution.d.ts.map +1 -1
- package/dist/beta-distribution.js +3 -2
- package/dist/beta-distribution.js.map +1 -1
- package/dist/bimodality-coefficient.d.ts +32 -0
- package/dist/bimodality-coefficient.d.ts.map +1 -0
- package/dist/bimodality-coefficient.js +63 -0
- package/dist/bimodality-coefficient.js.map +1 -0
- package/dist/binomial-distribution.d.ts.map +1 -1
- package/dist/binomial-distribution.js +2 -1
- package/dist/binomial-distribution.js.map +1 -1
- package/dist/chi-squared-distribution.d.ts.map +1 -1
- package/dist/chi-squared-distribution.js +2 -1
- package/dist/chi-squared-distribution.js.map +1 -1
- package/dist/chi-squared-test.js +2 -2
- package/dist/chi-squared-test.js.map +1 -1
- package/dist/combine-independent-estimates.d.ts +53 -0
- package/dist/combine-independent-estimates.d.ts.map +1 -0
- package/dist/combine-independent-estimates.js +71 -0
- package/dist/combine-independent-estimates.js.map +1 -0
- package/dist/confidence-interval.d.ts.map +1 -1
- package/dist/confidence-interval.js +2 -1
- package/dist/confidence-interval.js.map +1 -1
- package/dist/exponential-distribution.d.ts.map +1 -1
- package/dist/exponential-distribution.js +2 -1
- package/dist/exponential-distribution.js.map +1 -1
- package/dist/f-distribution.d.ts.map +1 -1
- package/dist/f-distribution.js +3 -2
- package/dist/f-distribution.js.map +1 -1
- package/dist/gamma-distribution.d.ts.map +1 -1
- package/dist/gamma-distribution.js +3 -2
- package/dist/gamma-distribution.js.map +1 -1
- package/dist/geometric-distribution.d.ts.map +1 -1
- package/dist/geometric-distribution.js +2 -1
- package/dist/geometric-distribution.js.map +1 -1
- package/dist/hartigan-dip.d.ts +65 -0
- package/dist/hartigan-dip.d.ts.map +1 -0
- package/dist/hartigan-dip.js +273 -0
- package/dist/hartigan-dip.js.map +1 -0
- package/dist/hierarchical-cluster.d.ts.map +1 -1
- package/dist/hierarchical-cluster.js +10 -5
- package/dist/hierarchical-cluster.js.map +1 -1
- package/dist/histogram-edges.d.ts +92 -0
- package/dist/histogram-edges.d.ts.map +1 -0
- package/dist/histogram-edges.js +325 -0
- package/dist/histogram-edges.js.map +1 -0
- package/dist/histogram.d.ts +80 -4
- package/dist/histogram.d.ts.map +1 -1
- package/dist/histogram.js +86 -9
- package/dist/histogram.js.map +1 -1
- package/dist/hypergeometric-distribution.js +2 -2
- package/dist/hypergeometric-distribution.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/kmeans.d.ts.map +1 -1
- package/dist/kmeans.js +12 -7
- package/dist/kmeans.js.map +1 -1
- package/dist/kmedoids.js +2 -1
- package/dist/kmedoids.js.map +1 -1
- package/dist/log-normal-distribution.d.ts.map +1 -1
- package/dist/log-normal-distribution.js +2 -1
- package/dist/log-normal-distribution.js.map +1 -1
- package/dist/negative-binomial-distribution.d.ts.map +1 -1
- package/dist/negative-binomial-distribution.js +3 -2
- package/dist/negative-binomial-distribution.js.map +1 -1
- package/dist/normal-distribution.d.ts.map +1 -1
- package/dist/normal-distribution.js +2 -1
- package/dist/normal-distribution.js.map +1 -1
- package/dist/normal-quantile.d.ts.map +1 -1
- package/dist/normal-quantile.js +2 -1
- package/dist/normal-quantile.js.map +1 -1
- package/dist/poisson-distribution.d.ts.map +1 -1
- package/dist/poisson-distribution.js +2 -1
- package/dist/poisson-distribution.js.map +1 -1
- package/dist/quantile.d.ts +26 -2
- package/dist/quantile.d.ts.map +1 -1
- package/dist/quantile.js +69 -9
- package/dist/quantile.js.map +1 -1
- package/dist/random-effects.d.ts +56 -9
- package/dist/random-effects.d.ts.map +1 -1
- package/dist/random-effects.js +59 -12
- package/dist/random-effects.js.map +1 -1
- package/dist/regression.d.ts +26 -2
- package/dist/regression.d.ts.map +1 -1
- package/dist/regression.js +175 -12
- package/dist/regression.js.map +1 -1
- package/dist/running-statistics.d.ts +103 -0
- package/dist/running-statistics.d.ts.map +1 -0
- package/dist/running-statistics.js +283 -0
- package/dist/running-statistics.js.map +1 -0
- package/dist/satterthwaite-degrees-of-freedom.d.ts +44 -0
- package/dist/satterthwaite-degrees-of-freedom.d.ts.map +1 -0
- package/dist/satterthwaite-degrees-of-freedom.js +41 -0
- package/dist/satterthwaite-degrees-of-freedom.js.map +1 -0
- package/dist/sliding-median.d.ts +1 -2
- package/dist/sliding-median.d.ts.map +1 -1
- package/dist/sliding-median.js +28 -24
- package/dist/sliding-median.js.map +1 -1
- package/dist/student-t-distribution.d.ts.map +1 -1
- package/dist/student-t-distribution.js +2 -1
- package/dist/student-t-distribution.js.map +1 -1
- package/dist/two-cluster-split.d.ts +34 -0
- package/dist/two-cluster-split.d.ts.map +1 -0
- package/dist/two-cluster-split.js +78 -0
- package/dist/two-cluster-split.js.map +1 -0
- package/dist/variance-of-sample-median.d.ts +40 -0
- package/dist/variance-of-sample-median.d.ts.map +1 -0
- package/dist/variance-of-sample-median.js +162 -0
- package/dist/variance-of-sample-median.js.map +1 -0
- package/dist/welch-t-statistic.d.ts.map +1 -1
- package/dist/welch-t-statistic.js +7 -3
- package/dist/welch-t-statistic.js.map +1 -1
- package/package.json +9 -8
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Count, mean, variance, minimum and maximum of numbers added one at a time,
|
|
3
|
+
* without keeping them: one pass, constant memory, and mergeable, so partitions
|
|
4
|
+
* of a data set (the groups of a column, the chunks of a stream) combine
|
|
5
|
+
* exactly as if added to one accumulator.
|
|
6
|
+
*
|
|
7
|
+
* The variance is Welford's update (1962), `delta = x − mean; mean += delta /
|
|
8
|
+
* n; m2 += delta · (x − mean)`, merged by Chan, Golub and LeVeque's pairwise
|
|
9
|
+
* rule (`m2 = m2ₐ + m2_b + delta² · nₐ · n_b / n`). The textbook `E[X²] −
|
|
10
|
+
* E[X]²` subtracts two nearly equal numbers when the mean dwarfs the spread
|
|
11
|
+
* (`1e9 + 0.1`), and loses every significant digit; here `m2` only ever
|
|
12
|
+
* accumulates non-negative terms of deviations from the running mean, so there
|
|
13
|
+
* is no cancellation. The updates work on offsets from the first number (a
|
|
14
|
+
* shifted Welford), which stay exact when the numbers cluster far from 0 where
|
|
15
|
+
* a plain running mean would round at their size (`1e12 + 0.3`): the relative
|
|
16
|
+
* error is about `n · ε` whatever the offset. Two passes with exact summation
|
|
17
|
+
* (`sampleVariance`) are a little more accurate still, but need the data twice;
|
|
18
|
+
* choose that when the values are in an array, and this when they are not, or
|
|
19
|
+
* when they come in parts.
|
|
20
|
+
*
|
|
21
|
+
* `NaN` is a missing value and is ignored, so a column with gaps adds as is. An
|
|
22
|
+
* infinite value makes the mean and variance `NaN`; the extremes stay exact.
|
|
23
|
+
* Deviations are not rescaled, so values near `Number.MAX_VALUE` overflow the
|
|
24
|
+
* variance (use `sampleVariance` there).
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* const statistics = new RunningStatistics();
|
|
28
|
+
* statistics.addIndexed(column, rows, groupStart, groupEnd);
|
|
29
|
+
* statistics.sampleStandardDeviation;
|
|
30
|
+
*/
|
|
31
|
+
export declare class RunningStatistics {
|
|
32
|
+
private readonly single_;
|
|
33
|
+
private readonly state_;
|
|
34
|
+
/** How many numbers were added (`NaN` excluded). */
|
|
35
|
+
get count(): number;
|
|
36
|
+
/** The arithmetic mean, or `NaN` when nothing was added. */
|
|
37
|
+
get mean(): number;
|
|
38
|
+
/** The smallest number, or `NaN` when nothing was added. */
|
|
39
|
+
get min(): number;
|
|
40
|
+
/** The largest number, or `NaN` when nothing was added. */
|
|
41
|
+
get max(): number;
|
|
42
|
+
/**
|
|
43
|
+
* The variance with Bessel's correction, or `NaN` for fewer than two numbers
|
|
44
|
+
* (where the function `sampleVariance` answers `0`).
|
|
45
|
+
*/
|
|
46
|
+
get sampleVariance(): number;
|
|
47
|
+
/** The variance of the numbers as a whole population, `NaN` when none. */
|
|
48
|
+
get populationVariance(): number;
|
|
49
|
+
get sampleStandardDeviation(): number;
|
|
50
|
+
get populationStandardDeviation(): number;
|
|
51
|
+
/** Writes {@link mean} to `target[index]`, without allocating. */
|
|
52
|
+
writeMean(target: Float64Array | number[], index: number): void;
|
|
53
|
+
/** Writes {@link min} to `target[index]`, without allocating. */
|
|
54
|
+
writeMin(target: Float64Array | number[], index: number): void;
|
|
55
|
+
/** Writes {@link max} to `target[index]`, without allocating. */
|
|
56
|
+
writeMax(target: Float64Array | number[], index: number): void;
|
|
57
|
+
/** Writes {@link sampleVariance} to `target[index]`, without allocating. */
|
|
58
|
+
writeSampleVariance(target: Float64Array | number[], index: number): void;
|
|
59
|
+
/** Writes {@link populationVariance} to `target[index]`, without allocating. */
|
|
60
|
+
writePopulationVariance(target: Float64Array | number[], index: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* Writes {@link sampleStandardDeviation} to `target[index]`, without
|
|
63
|
+
* allocating.
|
|
64
|
+
*/
|
|
65
|
+
writeSampleStandardDeviation(target: Float64Array | number[], index: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Writes {@link populationStandardDeviation} to `target[index]`, without
|
|
68
|
+
* allocating.
|
|
69
|
+
*/
|
|
70
|
+
writePopulationStandardDeviation(target: Float64Array | number[], index: number): void;
|
|
71
|
+
private computeMean_;
|
|
72
|
+
private computeSampleVariance_;
|
|
73
|
+
private computePopulationVariance_;
|
|
74
|
+
private put_;
|
|
75
|
+
/** Adds one number; `NaN` is ignored. O(1). */
|
|
76
|
+
add(value: number): this;
|
|
77
|
+
/**
|
|
78
|
+
* Adds `values[from … to)`, without copying them. O(to − from).
|
|
79
|
+
*
|
|
80
|
+
* @param values Not modified.
|
|
81
|
+
* @param from First position. Default `0`.
|
|
82
|
+
* @param to End position, excluded. Default `values.length`.
|
|
83
|
+
*/
|
|
84
|
+
addRange(values: ArrayLike<number>, from?: number, to?: number): this;
|
|
85
|
+
/**
|
|
86
|
+
* Adds `values[indices[from]]`, …, `values[indices[to − 1]]`: the rows of one
|
|
87
|
+
* group of a column, in a grouping's index array, without copying them. O(to
|
|
88
|
+
* − from).
|
|
89
|
+
*
|
|
90
|
+
* @param values Not modified.
|
|
91
|
+
* @param indices Positions in `values`.
|
|
92
|
+
* @param from First position in `indices`. Default `0`.
|
|
93
|
+
* @param to End position in `indices`, excluded. Default `indices.length`.
|
|
94
|
+
*/
|
|
95
|
+
addIndexed(values: ArrayLike<number>, indices: ArrayLike<number>, from?: number, to?: number): this;
|
|
96
|
+
private foldRange_;
|
|
97
|
+
private foldIndexed_;
|
|
98
|
+
/** Adds everything `other` holds, as if its numbers had been added here. O(1). */
|
|
99
|
+
merge(other: RunningStatistics): this;
|
|
100
|
+
/** Forgets everything, to reuse the accumulator. O(1), no allocation. */
|
|
101
|
+
reset(): this;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=running-statistics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"running-statistics.d.ts","sourceRoot":"","sources":["../src/running-statistics.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;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C/B,MAAM,EAAE,YAAY,GAAG,MAAM,EAAE,EAC/B,KAAK,EAAE,MAAM,GACX,IAAI,CAIN;IAED,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,sBAAsB;IAM9B,OAAO,CAAC,0BAA0B;IASlC,OAAO,CAAC,IAAI;IASZ,+CAA+C;IAC/C,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAIvB;IAED;;;;;;OAMG;IACH,QAAQ,CACP,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,IAAI,SAAI,EACR,EAAE,GAAE,MAAsB,GACxB,IAAI,CAEN;IAED;;;;;;;;;OASG;IACH,UAAU,CACT,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,EAC1B,IAAI,SAAI,EACR,EAAE,GAAE,MAAuB,GACzB,IAAI,CAEN;IAKD,OAAO,CAAC,UAAU;IA+BlB,OAAO,CAAC,YAAY;IAgCpB,kFAAkF;IAClF,KAAK,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAuBpC;IAED,yEAAyE;IACzE,KAAK,IAAI,IAAI,CASZ;CACD"}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// Slots of the state. SHIFT_ is the first number: every update works on offsets
|
|
2
|
+
// from it, which are small and exact (Sterbenz) when the numbers cluster far
|
|
3
|
+
// from 0, so the running mean keeps all its digits where it would round at the
|
|
4
|
+
// size of the numbers.
|
|
5
|
+
const COUNT_ = 0;
|
|
6
|
+
const MEAN_ = 1;
|
|
7
|
+
const M2_ = 2;
|
|
8
|
+
const SHIFT_ = 3;
|
|
9
|
+
const MIN_ = 4;
|
|
10
|
+
const MAX_ = 5;
|
|
11
|
+
/**
|
|
12
|
+
* Count, mean, variance, minimum and maximum of numbers added one at a time,
|
|
13
|
+
* without keeping them: one pass, constant memory, and mergeable, so partitions
|
|
14
|
+
* of a data set (the groups of a column, the chunks of a stream) combine
|
|
15
|
+
* exactly as if added to one accumulator.
|
|
16
|
+
*
|
|
17
|
+
* The variance is Welford's update (1962), `delta = x − mean; mean += delta /
|
|
18
|
+
* n; m2 += delta · (x − mean)`, merged by Chan, Golub and LeVeque's pairwise
|
|
19
|
+
* rule (`m2 = m2ₐ + m2_b + delta² · nₐ · n_b / n`). The textbook `E[X²] −
|
|
20
|
+
* E[X]²` subtracts two nearly equal numbers when the mean dwarfs the spread
|
|
21
|
+
* (`1e9 + 0.1`), and loses every significant digit; here `m2` only ever
|
|
22
|
+
* accumulates non-negative terms of deviations from the running mean, so there
|
|
23
|
+
* is no cancellation. The updates work on offsets from the first number (a
|
|
24
|
+
* shifted Welford), which stay exact when the numbers cluster far from 0 where
|
|
25
|
+
* a plain running mean would round at their size (`1e12 + 0.3`): the relative
|
|
26
|
+
* error is about `n · ε` whatever the offset. Two passes with exact summation
|
|
27
|
+
* (`sampleVariance`) are a little more accurate still, but need the data twice;
|
|
28
|
+
* choose that when the values are in an array, and this when they are not, or
|
|
29
|
+
* when they come in parts.
|
|
30
|
+
*
|
|
31
|
+
* `NaN` is a missing value and is ignored, so a column with gaps adds as is. An
|
|
32
|
+
* infinite value makes the mean and variance `NaN`; the extremes stay exact.
|
|
33
|
+
* Deviations are not rescaled, so values near `Number.MAX_VALUE` overflow the
|
|
34
|
+
* variance (use `sampleVariance` there).
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const statistics = new RunningStatistics();
|
|
38
|
+
* statistics.addIndexed(column, rows, groupStart, groupEnd);
|
|
39
|
+
* statistics.sampleStandardDeviation;
|
|
40
|
+
*/
|
|
41
|
+
export class RunningStatistics {
|
|
42
|
+
single_ = new Float64Array(1);
|
|
43
|
+
// All state in one typed array: a double kept in an object field is a box, and
|
|
44
|
+
// updating it allocated per number added to a fresh accumulator.
|
|
45
|
+
state_ = Float64Array.of(0, 0, 0, 0, Number.NaN, Number.NaN);
|
|
46
|
+
/** How many numbers were added (`NaN` excluded). */
|
|
47
|
+
get count() {
|
|
48
|
+
return this.state_[COUNT_];
|
|
49
|
+
}
|
|
50
|
+
/** The arithmetic mean, or `NaN` when nothing was added. */
|
|
51
|
+
get mean() {
|
|
52
|
+
this.computeMean_();
|
|
53
|
+
return this.single_[0];
|
|
54
|
+
}
|
|
55
|
+
/** The smallest number, or `NaN` when nothing was added. */
|
|
56
|
+
get min() {
|
|
57
|
+
return this.state_[MIN_];
|
|
58
|
+
}
|
|
59
|
+
/** The largest number, or `NaN` when nothing was added. */
|
|
60
|
+
get max() {
|
|
61
|
+
return this.state_[MAX_];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The variance with Bessel's correction, or `NaN` for fewer than two numbers
|
|
65
|
+
* (where the function `sampleVariance` answers `0`).
|
|
66
|
+
*/
|
|
67
|
+
get sampleVariance() {
|
|
68
|
+
this.computeSampleVariance_();
|
|
69
|
+
return this.single_[0];
|
|
70
|
+
}
|
|
71
|
+
/** The variance of the numbers as a whole population, `NaN` when none. */
|
|
72
|
+
get populationVariance() {
|
|
73
|
+
this.computePopulationVariance_();
|
|
74
|
+
return this.single_[0];
|
|
75
|
+
}
|
|
76
|
+
get sampleStandardDeviation() {
|
|
77
|
+
this.computeSampleVariance_();
|
|
78
|
+
return Math.sqrt(this.single_[0]);
|
|
79
|
+
}
|
|
80
|
+
get populationStandardDeviation() {
|
|
81
|
+
this.computePopulationVariance_();
|
|
82
|
+
return Math.sqrt(this.single_[0]);
|
|
83
|
+
}
|
|
84
|
+
// The writers below put a statistic in `target[index]`, which allocates
|
|
85
|
+
// nothing: a double returned by a call the engine does not inline (a getter
|
|
86
|
+
// read from a large loop, past its inlining budget) is boxed, one written to
|
|
87
|
+
// an array is not. One accumulator can so fill an output column group by
|
|
88
|
+
// group. Each computes into `single_`, then `put_` stores it.
|
|
89
|
+
/** Writes {@link mean} to `target[index]`, without allocating. */
|
|
90
|
+
writeMean(target, index) {
|
|
91
|
+
this.computeMean_();
|
|
92
|
+
this.put_(target, index);
|
|
93
|
+
}
|
|
94
|
+
/** Writes {@link min} to `target[index]`, without allocating. */
|
|
95
|
+
writeMin(target, index) {
|
|
96
|
+
this.single_[0] = this.state_[MIN_];
|
|
97
|
+
this.put_(target, index);
|
|
98
|
+
}
|
|
99
|
+
/** Writes {@link max} to `target[index]`, without allocating. */
|
|
100
|
+
writeMax(target, index) {
|
|
101
|
+
this.single_[0] = this.state_[MAX_];
|
|
102
|
+
this.put_(target, index);
|
|
103
|
+
}
|
|
104
|
+
/** Writes {@link sampleVariance} to `target[index]`, without allocating. */
|
|
105
|
+
writeSampleVariance(target, index) {
|
|
106
|
+
this.computeSampleVariance_();
|
|
107
|
+
this.put_(target, index);
|
|
108
|
+
}
|
|
109
|
+
/** Writes {@link populationVariance} to `target[index]`, without allocating. */
|
|
110
|
+
writePopulationVariance(target, index) {
|
|
111
|
+
this.computePopulationVariance_();
|
|
112
|
+
this.put_(target, index);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Writes {@link sampleStandardDeviation} to `target[index]`, without
|
|
116
|
+
* allocating.
|
|
117
|
+
*/
|
|
118
|
+
writeSampleStandardDeviation(target, index) {
|
|
119
|
+
this.computeSampleVariance_();
|
|
120
|
+
this.single_[0] = Math.sqrt(this.single_[0]);
|
|
121
|
+
this.put_(target, index);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Writes {@link populationStandardDeviation} to `target[index]`, without
|
|
125
|
+
* allocating.
|
|
126
|
+
*/
|
|
127
|
+
writePopulationStandardDeviation(target, index) {
|
|
128
|
+
this.computePopulationVariance_();
|
|
129
|
+
this.single_[0] = Math.sqrt(this.single_[0]);
|
|
130
|
+
this.put_(target, index);
|
|
131
|
+
}
|
|
132
|
+
computeMean_() {
|
|
133
|
+
const state = this.state_;
|
|
134
|
+
this.single_[0] =
|
|
135
|
+
state[COUNT_] === 0 ? Number.NaN : state[SHIFT_] + state[MEAN_];
|
|
136
|
+
}
|
|
137
|
+
computeSampleVariance_() {
|
|
138
|
+
const state = this.state_;
|
|
139
|
+
this.single_[0] =
|
|
140
|
+
state[COUNT_] < 2 ? Number.NaN : state[M2_] / (state[COUNT_] - 1);
|
|
141
|
+
}
|
|
142
|
+
computePopulationVariance_() {
|
|
143
|
+
const state = this.state_;
|
|
144
|
+
this.single_[0] =
|
|
145
|
+
state[COUNT_] === 0 ? Number.NaN : state[M2_] / state[COUNT_];
|
|
146
|
+
}
|
|
147
|
+
// One store site per kind of target: a site that has seen both a typed and a
|
|
148
|
+
// plain array (one whose elements kind changed under it, above all) boxes the
|
|
149
|
+
// double for its generic path even when it then writes a `Float64Array`.
|
|
150
|
+
put_(target, index) {
|
|
151
|
+
const value = this.single_[0];
|
|
152
|
+
if (target instanceof Float64Array) {
|
|
153
|
+
target[index] = value;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
target[index] = value;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/** Adds one number; `NaN` is ignored. O(1). */
|
|
160
|
+
add(value) {
|
|
161
|
+
const single = this.single_;
|
|
162
|
+
single[0] = value;
|
|
163
|
+
return this.foldRange_(single, 0, 1);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Adds `values[from … to)`, without copying them. O(to − from).
|
|
167
|
+
*
|
|
168
|
+
* @param values Not modified.
|
|
169
|
+
* @param from First position. Default `0`.
|
|
170
|
+
* @param to End position, excluded. Default `values.length`.
|
|
171
|
+
*/
|
|
172
|
+
addRange(values, from = 0, to = values.length) {
|
|
173
|
+
return this.foldRange_(values, from, to);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Adds `values[indices[from]]`, …, `values[indices[to − 1]]`: the rows of one
|
|
177
|
+
* group of a column, in a grouping's index array, without copying them. O(to
|
|
178
|
+
* − from).
|
|
179
|
+
*
|
|
180
|
+
* @param values Not modified.
|
|
181
|
+
* @param indices Positions in `values`.
|
|
182
|
+
* @param from First position in `indices`. Default `0`.
|
|
183
|
+
* @param to End position in `indices`, excluded. Default `indices.length`.
|
|
184
|
+
*/
|
|
185
|
+
addIndexed(values, indices, from = 0, to = indices.length) {
|
|
186
|
+
return this.foldIndexed_(values, indices, from, to);
|
|
187
|
+
}
|
|
188
|
+
// One loop per way of reading the numbers, each keeping clean type feedback. The
|
|
189
|
+
// state is updated in its typed array rather than in locals: a loop-carried
|
|
190
|
+
// double that is not unboxed is allocated afresh, about once per few numbers.
|
|
191
|
+
foldRange_(values, from, to) {
|
|
192
|
+
const state = this.state_;
|
|
193
|
+
for (let position = from; position < to; position++) {
|
|
194
|
+
const value = values[position];
|
|
195
|
+
if (value !== value) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const count = state[COUNT_] + 1;
|
|
199
|
+
state[COUNT_] = count;
|
|
200
|
+
if (count === 1) {
|
|
201
|
+
state[SHIFT_] = value;
|
|
202
|
+
state[MIN_] = value;
|
|
203
|
+
state[MAX_] = value;
|
|
204
|
+
}
|
|
205
|
+
else if (value < state[MIN_]) {
|
|
206
|
+
state[MIN_] = value;
|
|
207
|
+
}
|
|
208
|
+
else if (value > state[MAX_]) {
|
|
209
|
+
state[MAX_] = value;
|
|
210
|
+
}
|
|
211
|
+
const offset = value - state[SHIFT_];
|
|
212
|
+
const delta = offset - state[MEAN_];
|
|
213
|
+
const mean = state[MEAN_] + delta / count;
|
|
214
|
+
state[MEAN_] = mean;
|
|
215
|
+
state[M2_] = state[M2_] + delta * (offset - mean);
|
|
216
|
+
}
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
foldIndexed_(values, indices, from, to) {
|
|
220
|
+
const state = this.state_;
|
|
221
|
+
for (let position = from; position < to; position++) {
|
|
222
|
+
const value = values[indices[position]];
|
|
223
|
+
if (value !== value) {
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const count = state[COUNT_] + 1;
|
|
227
|
+
state[COUNT_] = count;
|
|
228
|
+
if (count === 1) {
|
|
229
|
+
state[SHIFT_] = value;
|
|
230
|
+
state[MIN_] = value;
|
|
231
|
+
state[MAX_] = value;
|
|
232
|
+
}
|
|
233
|
+
else if (value < state[MIN_]) {
|
|
234
|
+
state[MIN_] = value;
|
|
235
|
+
}
|
|
236
|
+
else if (value > state[MAX_]) {
|
|
237
|
+
state[MAX_] = value;
|
|
238
|
+
}
|
|
239
|
+
const offset = value - state[SHIFT_];
|
|
240
|
+
const delta = offset - state[MEAN_];
|
|
241
|
+
const mean = state[MEAN_] + delta / count;
|
|
242
|
+
state[MEAN_] = mean;
|
|
243
|
+
state[M2_] = state[M2_] + delta * (offset - mean);
|
|
244
|
+
}
|
|
245
|
+
return this;
|
|
246
|
+
}
|
|
247
|
+
/** Adds everything `other` holds, as if its numbers had been added here. O(1). */
|
|
248
|
+
merge(other) {
|
|
249
|
+
const state = this.state_;
|
|
250
|
+
const theirs = other.state_;
|
|
251
|
+
if (theirs[COUNT_] === 0) {
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
254
|
+
if (state[COUNT_] === 0) {
|
|
255
|
+
state.set(theirs);
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
const ours = state[COUNT_];
|
|
259
|
+
const count = ours + theirs[COUNT_];
|
|
260
|
+
const delta = theirs[SHIFT_] - state[SHIFT_] + (theirs[MEAN_] - state[MEAN_]);
|
|
261
|
+
state[M2_] =
|
|
262
|
+
state[M2_] +
|
|
263
|
+
theirs[M2_] +
|
|
264
|
+
(delta * delta * ours * theirs[COUNT_]) / count;
|
|
265
|
+
state[MEAN_] = state[MEAN_] + (delta * theirs[COUNT_]) / count;
|
|
266
|
+
state[COUNT_] = count;
|
|
267
|
+
state[MIN_] = Math.min(state[MIN_], theirs[MIN_]);
|
|
268
|
+
state[MAX_] = Math.max(state[MAX_], theirs[MAX_]);
|
|
269
|
+
return this;
|
|
270
|
+
}
|
|
271
|
+
/** Forgets everything, to reuse the accumulator. O(1), no allocation. */
|
|
272
|
+
reset() {
|
|
273
|
+
const state = this.state_;
|
|
274
|
+
state[COUNT_] = 0;
|
|
275
|
+
state[MEAN_] = 0;
|
|
276
|
+
state[M2_] = 0;
|
|
277
|
+
state[SHIFT_] = 0;
|
|
278
|
+
state[MIN_] = Number.NaN;
|
|
279
|
+
state[MAX_] = Number.NaN;
|
|
280
|
+
return this;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
//# sourceMappingURL=running-statistics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"running-statistics.js","sourceRoot":"","sources":["../src/running-statistics.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,6EAA6E;AAC7E,+EAA+E;AAC/E,uBAAuB;AACvB,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,KAAK,GAAG,CAAC,CAAC;AAChB,MAAM,GAAG,GAAG,CAAC,CAAC;AACd,MAAM,MAAM,GAAG,CAAC,CAAC;AACjB,MAAM,IAAI,GAAG,CAAC,CAAC;AACf,MAAM,IAAI,GAAG,CAAC,CAAC;AAEf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,iBAAiB;IACZ,OAAO,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;IAC/C,+EAA+E;IAC/E,iEAAiE;IAChD,MAAM,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAE9E,oDAAoD;IACpD,IAAI,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAE,CAAC;IAC7B,CAAC;IAED,4DAA4D;IAC5D,IAAI,IAAI;QACP,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC;IACzB,CAAC;IAED,4DAA4D;IAC5D,IAAI,GAAG;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAE,CAAC;IAC3B,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CAAC;QACrE,KAAK,CAAC,GAAG,CAAC;YACT,KAAK,CAAC,GAAG,CAAE;gBACX,MAAM,CAAC,GAAG,CAAE;gBACZ,CAAC,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,CAAE,CAAC,GAAG,KAAK,CAAC;QAClD,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAE,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAE,CAAC,GAAG,KAAK,CAAC;QACjE,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAE,EAAE,MAAM,CAAC,IAAI,CAAE,CAAC,CAAC;QACpD,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAE,EAAE,MAAM,CAAC,IAAI,CAAE,CAAC,CAAC;QACpD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,yEAAyE;IACzE,KAAK;QACJ,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAClB,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjB,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACf,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;QACzB,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;QACzB,OAAO,IAAI,CAAC;IACb,CAAC;CACD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One term of a sum of independent variance estimates: the term's estimated
|
|
3
|
+
* variance and the degrees of freedom it was estimated with.
|
|
4
|
+
*/
|
|
5
|
+
export type VarianceComponent = {
|
|
6
|
+
/**
|
|
7
|
+
* The term's contribution to the summed variance — for a mean, the sample
|
|
8
|
+
* variance divided by the sample size, not the sample variance itself. Finite
|
|
9
|
+
* and non-negative.
|
|
10
|
+
*/
|
|
11
|
+
readonly variance: number;
|
|
12
|
+
/**
|
|
13
|
+
* Degrees of freedom of that estimate, `n − 1` for a sample variance.
|
|
14
|
+
* Positive; need not be an integer. `Infinity` marks a variance known
|
|
15
|
+
* exactly, which adds to the sum without adding uncertainty.
|
|
16
|
+
*/
|
|
17
|
+
readonly degreesOfFreedom: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Welch–Satterthwaite effective degrees of freedom of a sum of independent
|
|
21
|
+
* variance estimates: `ν = (Σ Vᵢ)² / Σ (Vᵢ² / νᵢ)`.
|
|
22
|
+
*
|
|
23
|
+
* The sum of estimated variances is not exactly a scaled chi-squared variable;
|
|
24
|
+
* this is the degrees of freedom of the chi-squared it is approximated by, so a
|
|
25
|
+
* statistic divided by `√Σ Vᵢ` can be referred to Student's t with `ν`. It is
|
|
26
|
+
* what Welch's unequal-variance t-test uses (with two components), and what an
|
|
27
|
+
* unpaired difference of two pooled estimates uses. Over the components with a
|
|
28
|
+
* non-zero variance, the result lies between the smallest `νᵢ` and `Σ νᵢ`.
|
|
29
|
+
* Variances anywhere in the double range, up to `Number.MAX_VALUE`, give a
|
|
30
|
+
* finite, accurate result.
|
|
31
|
+
*
|
|
32
|
+
* O(n) in the number of components.
|
|
33
|
+
*
|
|
34
|
+
* @param components The terms of the sum, at least one. Not modified.
|
|
35
|
+
* @returns The effective degrees of freedom; `Infinity` when every term with a
|
|
36
|
+
* non-zero variance is known exactly; `NaN` when every variance is zero,
|
|
37
|
+
* since a sum with no spread says nothing about how its spread was
|
|
38
|
+
* estimated.
|
|
39
|
+
* @throws {RangeError} When `components` is empty, when a variance is negative,
|
|
40
|
+
* `NaN` or infinite, or when a degrees of freedom is not positive (or is
|
|
41
|
+
* `NaN`).
|
|
42
|
+
*/
|
|
43
|
+
export declare function satterthwaiteDegreesOfFreedom(components: readonly VarianceComponent[]): number;
|
|
44
|
+
//# sourceMappingURL=satterthwaite-degrees-of-freedom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"satterthwaite-degrees-of-freedom.d.ts","sourceRoot":"","sources":["../src/satterthwaite-degrees-of-freedom.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CAClC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,6BAA6B,CAC5C,UAAU,EAAE,SAAS,iBAAiB,EAAE,GACtC,MAAM,CAsBR"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describeValue } from "@ac-kit/core";
|
|
2
|
+
import { satterthwaite_ } from "./_satterthwaite.js";
|
|
3
|
+
/**
|
|
4
|
+
* Welch–Satterthwaite effective degrees of freedom of a sum of independent
|
|
5
|
+
* variance estimates: `ν = (Σ Vᵢ)² / Σ (Vᵢ² / νᵢ)`.
|
|
6
|
+
*
|
|
7
|
+
* The sum of estimated variances is not exactly a scaled chi-squared variable;
|
|
8
|
+
* this is the degrees of freedom of the chi-squared it is approximated by, so a
|
|
9
|
+
* statistic divided by `√Σ Vᵢ` can be referred to Student's t with `ν`. It is
|
|
10
|
+
* what Welch's unequal-variance t-test uses (with two components), and what an
|
|
11
|
+
* unpaired difference of two pooled estimates uses. Over the components with a
|
|
12
|
+
* non-zero variance, the result lies between the smallest `νᵢ` and `Σ νᵢ`.
|
|
13
|
+
* Variances anywhere in the double range, up to `Number.MAX_VALUE`, give a
|
|
14
|
+
* finite, accurate result.
|
|
15
|
+
*
|
|
16
|
+
* O(n) in the number of components.
|
|
17
|
+
*
|
|
18
|
+
* @param components The terms of the sum, at least one. Not modified.
|
|
19
|
+
* @returns The effective degrees of freedom; `Infinity` when every term with a
|
|
20
|
+
* non-zero variance is known exactly; `NaN` when every variance is zero,
|
|
21
|
+
* since a sum with no spread says nothing about how its spread was
|
|
22
|
+
* estimated.
|
|
23
|
+
* @throws {RangeError} When `components` is empty, when a variance is negative,
|
|
24
|
+
* `NaN` or infinite, or when a degrees of freedom is not positive (or is
|
|
25
|
+
* `NaN`).
|
|
26
|
+
*/
|
|
27
|
+
export function satterthwaiteDegreesOfFreedom(components) {
|
|
28
|
+
if (components.length === 0) {
|
|
29
|
+
throw new RangeError("satterthwaiteDegreesOfFreedom: at least one component is required");
|
|
30
|
+
}
|
|
31
|
+
for (const { variance, degreesOfFreedom } of components) {
|
|
32
|
+
if (!(variance >= 0 && variance < Number.POSITIVE_INFINITY)) {
|
|
33
|
+
throw new RangeError(`satterthwaiteDegreesOfFreedom: every variance must be finite and non-negative, got ${describeValue(variance)}`);
|
|
34
|
+
}
|
|
35
|
+
if (!(degreesOfFreedom > 0)) {
|
|
36
|
+
throw new RangeError(`satterthwaiteDegreesOfFreedom: every degrees of freedom must be positive, got ${describeValue(degreesOfFreedom)}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return satterthwaite_(components);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=satterthwaite-degrees-of-freedom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"satterthwaite-degrees-of-freedom.js","sourceRoot":"","sources":["../src/satterthwaite-degrees-of-freedom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAsBrD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,6BAA6B,CAC5C,UAAwC;IAExC,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,UAAU,CACnB,mEAAmE,CACnE,CAAC;IACH,CAAC;IAED,KAAK,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,UAAU,EAAE,CAAC;QACzD,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,IAAI,QAAQ,GAAG,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,UAAU,CACnB,sFAAsF,aAAa,CAAC,QAAQ,CAAC,EAAE,CAC/G,CAAC;QACH,CAAC;QAED,IAAI,CAAC,CAAC,gBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,UAAU,CACnB,iFAAiF,aAAa,CAAC,gBAAgB,CAAC,EAAE,CAClH,CAAC;QACH,CAAC;IACF,CAAC;IAED,OAAO,cAAc,CAAC,UAAU,CAAC,CAAC;AACnC,CAAC"}
|
package/dist/sliding-median.d.ts
CHANGED
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
export declare class SlidingMedian {
|
|
15
15
|
readonly windowLength: number;
|
|
16
16
|
private readonly arrival_;
|
|
17
|
+
private readonly arrivalValues_;
|
|
17
18
|
private readonly sorted_;
|
|
18
19
|
private readonly probe_;
|
|
19
|
-
private count_;
|
|
20
|
-
private oldest_;
|
|
21
20
|
/** @throws {RangeError} If `windowLength` is not a positive integer. */
|
|
22
21
|
constructor(windowLength: number);
|
|
23
22
|
/** Number of values currently held, at most {@link windowLength}. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliding-median.d.ts","sourceRoot":"","sources":["../src/sliding-median.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sliding-median.d.ts","sourceRoot":"","sources":["../src/sliding-median.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,qBAAa,aAAa;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAG9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA2C;IACpE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAe;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuB;IAE9C,wEAAwE;IACxE,YAAY,YAAY,EAAE,MAAM,EAc/B;IAED,qEAAqE;IACrE,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGxB;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAwBlD;IAED;;;;;;;OAOG;IACH,MAAM,IAAI,MAAM,CAUf;IAED;;;;;;OAMG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG3B;IAED;;;;;;OAMG;IACH,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAUlE;IAED,2BAA2B;IAC3B,KAAK,IAAI,IAAI,CAEZ;IAED,6EAA6E;IAC7E,OAAO,CAAC,WAAW;CAgBnB"}
|
package/dist/sliding-median.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { describeValue } from "@ac-kit/core";
|
|
2
|
+
import { TypedColumnRing } from "@ac-kit/data";
|
|
1
3
|
/**
|
|
2
4
|
* Exact median of the last `windowLength` values pushed.
|
|
3
5
|
*
|
|
@@ -13,23 +15,27 @@
|
|
|
13
15
|
*/
|
|
14
16
|
export class SlidingMedian {
|
|
15
17
|
windowLength;
|
|
18
|
+
// The values in arrival order: one column, `windowLength` rows.
|
|
16
19
|
arrival_;
|
|
20
|
+
arrivalValues_;
|
|
17
21
|
sorted_;
|
|
18
22
|
probe_ = new Float64Array(1);
|
|
19
|
-
count_ = 0;
|
|
20
|
-
oldest_ = 0;
|
|
21
23
|
/** @throws {RangeError} If `windowLength` is not a positive integer. */
|
|
22
24
|
constructor(windowLength) {
|
|
23
25
|
if (!Number.isInteger(windowLength) || windowLength < 1) {
|
|
24
|
-
throw new RangeError(`windowLength must be a positive integer, got ${windowLength}`);
|
|
26
|
+
throw new RangeError(`windowLength must be a positive integer, got ${describeValue(windowLength)}`);
|
|
25
27
|
}
|
|
26
28
|
this.windowLength = windowLength;
|
|
27
|
-
this.arrival_ = new Float64Array
|
|
29
|
+
this.arrival_ = new TypedColumnRing(Float64Array, {
|
|
30
|
+
columnCount: 1,
|
|
31
|
+
capacity: windowLength,
|
|
32
|
+
});
|
|
33
|
+
this.arrivalValues_ = this.arrival_.column(0);
|
|
28
34
|
this.sorted_ = new Float64Array(windowLength);
|
|
29
35
|
}
|
|
30
36
|
/** Number of values currently held, at most {@link windowLength}. */
|
|
31
37
|
get length() {
|
|
32
|
-
return this.
|
|
38
|
+
return this.arrival_.length;
|
|
33
39
|
}
|
|
34
40
|
/**
|
|
35
41
|
* Adds `value`, dropping the oldest one once the window is full.
|
|
@@ -56,22 +62,20 @@ export class SlidingMedian {
|
|
|
56
62
|
}
|
|
57
63
|
const sorted = this.sorted_;
|
|
58
64
|
const probe = this.probe_;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
this.arrival_[(this.oldest_ + this.count_) % this.windowLength] = value;
|
|
65
|
+
const arrival = this.arrival_;
|
|
66
|
+
let held = arrival.length;
|
|
67
|
+
if (arrival.isFull) {
|
|
68
|
+
probe[0] = this.arrivalValues_[arrival.slotAt(0)];
|
|
69
|
+
const from = this.lowerBound_(held);
|
|
70
|
+
sorted.copyWithin(from, from + 1, held);
|
|
71
|
+
held--;
|
|
69
72
|
}
|
|
73
|
+
// Once full, the new row takes the slot of the oldest.
|
|
74
|
+
this.arrivalValues_[arrival.pushSlot()] = value;
|
|
70
75
|
probe[0] = value;
|
|
71
|
-
const at = this.lowerBound_(
|
|
72
|
-
sorted.copyWithin(at + 1, at,
|
|
76
|
+
const at = this.lowerBound_(held);
|
|
77
|
+
sorted.copyWithin(at + 1, at, held);
|
|
73
78
|
sorted[at] = value;
|
|
74
|
-
this.count_++;
|
|
75
79
|
}
|
|
76
80
|
/**
|
|
77
81
|
* The median of the values held: the middle one, or the mean of the two
|
|
@@ -82,7 +86,7 @@ export class SlidingMedian {
|
|
|
82
86
|
* {@link selectInto} instead.
|
|
83
87
|
*/
|
|
84
88
|
median() {
|
|
85
|
-
const count = this.
|
|
89
|
+
const count = this.arrival_.length;
|
|
86
90
|
if (count === 0) {
|
|
87
91
|
return Number.NaN;
|
|
88
92
|
}
|
|
@@ -111,15 +115,15 @@ export class SlidingMedian {
|
|
|
111
115
|
*/
|
|
112
116
|
selectInto(output, index, rank) {
|
|
113
117
|
assertIndex_(output, index);
|
|
114
|
-
|
|
115
|
-
|
|
118
|
+
const count = this.arrival_.length;
|
|
119
|
+
if (!Number.isInteger(rank) || rank < 0 || rank >= count) {
|
|
120
|
+
throw new RangeError(`rank must be an integer in [0, ${count}), got ${describeValue(rank)}`);
|
|
116
121
|
}
|
|
117
122
|
output[index] = this.sorted_[rank];
|
|
118
123
|
}
|
|
119
124
|
/** Forgets every value. */
|
|
120
125
|
reset() {
|
|
121
|
-
this.
|
|
122
|
-
this.oldest_ = 0;
|
|
126
|
+
this.arrival_.clear();
|
|
123
127
|
}
|
|
124
128
|
/** First index in the sorted prefix whose value is not below `probe_[0]`. */
|
|
125
129
|
lowerBound_(count) {
|
|
@@ -141,7 +145,7 @@ export class SlidingMedian {
|
|
|
141
145
|
}
|
|
142
146
|
function assertIndex_(array, index) {
|
|
143
147
|
if (!Number.isInteger(index) || index < 0 || index >= array.length) {
|
|
144
|
-
throw new RangeError(`index must be an integer in [0, ${array.length}), got ${index}`);
|
|
148
|
+
throw new RangeError(`index must be an integer in [0, ${array.length}), got ${describeValue(index)}`);
|
|
145
149
|
}
|
|
146
150
|
}
|
|
147
151
|
//# sourceMappingURL=sliding-median.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sliding-median.js","sourceRoot":"","sources":["../src/sliding-median.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAa;IAChB,YAAY,CAAS;
|
|
1
|
+
{"version":3,"file":"sliding-median.js","sourceRoot":"","sources":["../src/sliding-median.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,aAAa;IAChB,YAAY,CAAS;IAE9B,gEAAgE;IAC/C,QAAQ,CAA2C;IACnD,cAAc,CAAe;IAC7B,OAAO,CAAe;IACtB,MAAM,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;IAE9C,wEAAwE;IACxE,YAAY,YAAoB;QAC/B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACzD,MAAM,IAAI,UAAU,CACnB,gDAAgD,aAAa,CAAC,YAAY,CAAC,EAAE,CAC7E,CAAC;QACH,CAAC;QAED,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,YAAY,EAAE;YACjD,WAAW,EAAE,CAAC;YACd,QAAQ,EAAE,YAAY;SACtB,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,qEAAqE;IACrE,IAAI,MAAM;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED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