@numero-uno-jpn/rstats 0.15.3 → 0.16.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 +166 -0
- package/README.ja.md +40 -33
- package/README.md +36 -28
- package/dist/chunks/chunk-2D2IQWUQ.js +2 -0
- package/dist/chunks/chunk-5UQCRBAG.js +2 -0
- package/dist/chunks/chunk-6CSTWA5E.js +2 -0
- package/dist/chunks/chunk-72Y3HZID.js +2 -0
- package/dist/chunks/chunk-BG2KLEHM.js +2 -0
- package/dist/chunks/chunk-CMEKBNHQ.js +2 -0
- package/dist/chunks/chunk-FLJNSXSW.js +2 -0
- package/dist/chunks/chunk-GM53LWSR.js +2 -0
- package/dist/chunks/chunk-JBCA56ZS.js +3 -0
- package/dist/chunks/chunk-K3RJAD2T.js +2 -0
- package/dist/chunks/chunk-KAZRWIB5.js +2 -0
- package/dist/chunks/chunk-KBVVIMXX.js +3 -0
- package/dist/chunks/chunk-N3SIFCZX.js +2 -0
- package/dist/chunks/chunk-QNNL7AZ3.js +2 -0
- package/dist/chunks/chunk-SC6CV4Z3.js +2 -0
- package/dist/chunks/chunk-SYWOBOTR.js +2 -0
- package/dist/chunks/chunk-URIO5LY5.js +2 -0
- package/dist/chunks/chunk-VTUGG2SV.js +2 -0
- package/dist/chunks/chunk-W26LRYOJ.js +2 -0
- package/dist/chunks/chunk-XHETEYVC.js +2 -0
- package/dist/chunks/{chunk-VLUL2HFW.js → chunk-YRZWONZB.js} +1 -1
- package/dist/chunks/chunk-ZGABZMWX.js +2 -0
- package/dist/data/grouping.js +20 -5
- package/dist/descriptive/basic.js +90 -8
- package/dist/descriptive/cov.js +12 -4
- package/dist/descriptive/dataFrames.d.ts +4 -2
- package/dist/descriptive/dataFrames.js +56 -18
- package/dist/descriptive/factanal.js +16 -7
- package/dist/descriptive/hist.d.ts +8 -5
- package/dist/descriptive/hist.js +71 -31
- package/dist/descriptive/missing.js +3 -1
- package/dist/descriptive/moments.js +72 -19
- package/dist/descriptive/omega.d.ts +1 -1
- package/dist/descriptive/omega.js +68 -9
- package/dist/descriptive/pivot.d.ts +21 -9
- package/dist/descriptive/pivot.js +161 -35
- package/dist/descriptive/quantile.js +2 -1
- package/dist/descriptive/rank.js +4 -1
- package/dist/descriptive/table.d.ts +3 -2
- package/dist/descriptive/table.js +24 -9
- package/dist/descriptive.js +2 -2
- package/dist/distributions/arcsine.js +19 -2
- package/dist/distributions/beta.js +24 -4
- package/dist/distributions/binomial.js +37 -14
- package/dist/distributions/bvnorm.js +11 -2
- package/dist/distributions/cauchy.js +12 -4
- package/dist/distributions/chisq.js +7 -3
- package/dist/distributions/exponential.js +5 -0
- package/dist/distributions/f.js +32 -17
- package/dist/distributions/gamma.js +27 -3
- package/dist/distributions/geometric.js +49 -13
- package/dist/distributions/hypergeometric.d.ts +5 -1
- package/dist/distributions/hypergeometric.js +93 -6
- package/dist/distributions/invgamma.js +2 -1
- package/dist/distributions/laplace.js +27 -6
- package/dist/distributions/logistic.js +4 -1
- package/dist/distributions/lognormal.js +8 -2
- package/dist/distributions/multinomial.js +54 -11
- package/dist/distributions/nbeta.js +62 -11
- package/dist/distributions/nchisq.js +30 -6
- package/dist/distributions/negbinomial.js +94 -17
- package/dist/distributions/normal.js +9 -4
- package/dist/distributions/nt.js +392 -17
- package/dist/distributions/pareto.js +4 -1
- package/dist/distributions/poisson.js +28 -3
- package/dist/distributions/signrank.js +7 -4
- package/dist/distributions/summary.js +450 -60
- package/dist/distributions/triangular.js +10 -5
- package/dist/distributions/tukey.js +5 -2
- package/dist/distributions/weibull.js +10 -0
- package/dist/distributions/wilcox.d.ts +9 -3
- package/dist/distributions/wilcox.js +155 -26
- package/dist/distributions.js +2 -2
- package/dist/htest/agreement.d.ts +3 -2
- package/dist/htest/agreement.js +76 -14
- package/dist/htest/ansariTest.d.ts +6 -1
- package/dist/htest/ansariTest.js +75 -8
- package/dist/htest/aov.d.ts +1 -1
- package/dist/htest/aov.js +48 -34
- package/dist/htest/binomTest.d.ts +5 -0
- package/dist/htest/binomTest.js +41 -17
- package/dist/htest/brunnerMunzelTest.d.ts +4 -3
- package/dist/htest/brunnerMunzelTest.js +7 -5
- package/dist/htest/chisqTest.d.ts +2 -1
- package/dist/htest/chisqTest.js +130 -43
- package/dist/htest/cor.d.ts +2 -1
- package/dist/htest/cor.js +17 -19
- package/dist/htest/core/ansari.d.ts +9 -0
- package/dist/htest/core/ansari.js +21 -1
- package/dist/htest/core/kolmogorov.d.ts +25 -0
- package/dist/htest/core/kolmogorov.js +123 -0
- package/dist/htest/core/mantelhaen.js +6 -4
- package/dist/htest/core/shapiro.d.ts +1 -1
- package/dist/htest/core/shapiro.js +5 -1
- package/dist/htest/dunnett.js +14 -5
- package/dist/htest/effectSize.d.ts +2 -0
- package/dist/htest/effectSize.js +91 -29
- package/dist/htest/fisherTest.d.ts +2 -2
- package/dist/htest/fisherTest.js +36 -18
- package/dist/htest/groups.d.ts +7 -0
- package/dist/htest/groups.js +21 -4
- package/dist/htest/ksTest.d.ts +3 -1
- package/dist/htest/ksTest.js +23 -2
- package/dist/htest/leveneTest.js +19 -3
- package/dist/htest/mantelhaenTest.js +125 -25
- package/dist/htest/mcnemarTest.js +32 -11
- package/dist/htest/multipleComparisons.d.ts +8 -1
- package/dist/htest/multipleComparisons.js +44 -21
- package/dist/htest/normalityTests.js +44 -10
- package/dist/htest/onewayTest.js +96 -5
- package/dist/htest/pAdjust.d.ts +3 -2
- package/dist/htest/pAdjust.js +38 -6
- package/dist/htest/pairwise.d.ts +1 -1
- package/dist/htest/pairwise.js +17 -15
- package/dist/htest/poissonTest.d.ts +1 -1
- package/dist/htest/poissonTest.js +111 -59
- package/dist/htest/polycor.js +27 -7
- package/dist/htest/power.d.ts +11 -1
- package/dist/htest/power.js +112 -8
- package/dist/htest/propTest.js +21 -4
- package/dist/htest/pwr.js +121 -24
- package/dist/htest/rankTests.js +29 -5
- package/dist/htest/tTest.js +44 -21
- package/dist/htest/trendTests.d.ts +7 -3
- package/dist/htest/trendTests.js +114 -20
- package/dist/htest/types.d.ts +5 -0
- package/dist/htest/types.js +7 -0
- package/dist/htest/varTest.js +45 -14
- package/dist/htest/wilcoxTest.js +114 -21
- package/dist/integrate/quadpack.js +27 -5
- package/dist/internal/covmat.d.ts +5 -0
- package/dist/internal/covmat.js +20 -0
- package/dist/internal/ddexp.d.ts +15 -1
- package/dist/internal/ddexp.js +59 -6
- package/dist/internal/discrete.d.ts +14 -0
- package/dist/internal/discrete.js +78 -5
- package/dist/internal/extremes.d.ts +9 -0
- package/dist/internal/extremes.js +24 -0
- package/dist/internal/fround.js +13 -4
- package/dist/internal/integer.d.ts +9 -0
- package/dist/internal/integer.js +12 -0
- package/dist/internal/invert.js +15 -2
- package/dist/internal/scaledInverse.d.ts +10 -0
- package/dist/internal/scaledInverse.js +22 -0
- package/dist/internal/seq.js +15 -2
- package/dist/internal/summary.d.ts +90 -0
- package/dist/internal/summary.js +458 -39
- package/dist/internal/uniroot.d.ts +7 -0
- package/dist/internal/uniroot.js +28 -3
- package/dist/linalg/basic.d.ts +3 -1
- package/dist/linalg/basic.js +51 -7
- package/dist/linalg/chol.js +4 -1
- package/dist/linalg/dot.d.ts +29 -0
- package/dist/linalg/dot.js +132 -0
- package/dist/linalg/eigen.d.ts +6 -1
- package/dist/linalg/eigen.js +71 -14
- package/dist/linalg/expm.d.ts +3 -2
- package/dist/linalg/expm.js +109 -15
- package/dist/linalg/kappa.js +58 -10
- package/dist/linalg/lu.d.ts +2 -1
- package/dist/linalg/lu.js +35 -5
- package/dist/linalg/matrix.d.ts +14 -0
- package/dist/linalg/matrix.js +24 -0
- package/dist/linalg/ops.js +60 -13
- package/dist/linalg/qr.d.ts +2 -1
- package/dist/linalg/qr.js +91 -23
- package/dist/linalg/schur.js +11 -3
- package/dist/linalg/solve.d.ts +6 -1
- package/dist/linalg/solve.js +147 -26
- package/dist/linalg/svd.d.ts +9 -2
- package/dist/linalg/svd.js +29 -11
- package/dist/linalg.js +2 -2
- package/dist/mixed.js +4 -4
- package/dist/models/anovaSequential.d.ts +16 -1
- package/dist/models/anovaSequential.js +124 -25
- package/dist/models/aovEz.js +140 -30
- package/dist/models/aovStrata.js +55 -22
- package/dist/models/carAnova.d.ts +1 -1
- package/dist/models/carAnova.js +83 -32
- package/dist/models/coxph.js +148 -66
- package/dist/models/estimable.d.ts +15 -0
- package/dist/models/estimable.js +68 -0
- package/dist/models/formula.d.ts +1 -1
- package/dist/models/formula.js +26 -8
- package/dist/models/glm.d.ts +35 -5
- package/dist/models/glm.js +398 -55
- package/dist/models/glmAnova.js +84 -13
- package/dist/models/glmConfint.d.ts +1 -1
- package/dist/models/glmConfint.js +115 -27
- package/dist/models/glmFamily.d.ts +10 -0
- package/dist/models/glmFamily.js +244 -40
- package/dist/models/lm.d.ts +12 -1
- package/dist/models/lm.js +235 -36
- package/dist/models/lmer.d.ts +20 -1
- package/dist/models/lmer.js +109 -27
- package/dist/models/lmerAnova.js +37 -4
- package/dist/models/lmerHypotheses.d.ts +6 -2
- package/dist/models/lmerHypotheses.js +14 -2
- package/dist/models/lmerTest.d.ts +9 -2
- package/dist/models/lmerTest.js +64 -19
- package/dist/models/mauchly.d.ts +4 -1
- package/dist/models/mauchly.js +34 -13
- package/dist/models/mixedStructure.js +6 -0
- package/dist/models/modelFrame.js +8 -2
- package/dist/models/modelMatrix.d.ts +3 -1
- package/dist/models/modelMatrix.js +40 -15
- package/dist/models/scaledTables.d.ts +8 -0
- package/dist/models/scaledTables.js +6 -0
- package/dist/models/survival.d.ts +6 -1
- package/dist/models/survival.js +67 -27
- package/dist/models/tiedTimes.d.ts +2 -0
- package/dist/models/tiedTimes.js +34 -0
- package/dist/numerics/deriv.d.ts +1 -1
- package/dist/numerics/deriv.js +64 -8
- package/dist/numerics/integrate.d.ts +9 -1
- package/dist/numerics/integrate.js +103 -16
- package/dist/numerics/interp.d.ts +8 -2
- package/dist/numerics/interp.js +352 -50
- package/dist/numerics/ode.js +55 -1
- package/dist/numerics.js +2 -2
- package/dist/optim/localmin.js +4 -0
- package/dist/optim/optim.d.ts +3 -1
- package/dist/optim/optim.js +80 -8
- package/dist/random/beta.js +53 -4
- package/dist/random/binomial.d.ts +14 -3
- package/dist/random/binomial.js +59 -24
- package/dist/random/continuous.js +33 -5
- package/dist/random/extra.js +42 -9
- package/dist/random/gamma.d.ts +4 -1
- package/dist/random/gamma.js +36 -8
- package/dist/random/hyper.js +9 -6
- package/dist/random/mt.js +17 -2
- package/dist/random/poisson.js +26 -3
- package/dist/random/r2dtable.d.ts +8 -1
- package/dist/random/r2dtable.js +24 -3
- package/dist/random/rank.d.ts +2 -0
- package/dist/random/rank.js +44 -4
- package/dist/random/sample.d.ts +12 -2
- package/dist/random/sample.js +57 -20
- package/dist/random/streams.js +4 -2
- package/dist/rstats.js +14 -14
- package/dist/special/besselIK.d.ts +12 -0
- package/dist/special/besselIK.js +168 -23
- package/dist/special/besselJY.d.ts +11 -1
- package/dist/special/besselJY.js +127 -19
- package/dist/special/besselSeries.d.ts +27 -0
- package/dist/special/besselSeries.js +45 -2
- package/dist/special/beta.js +4 -1
- package/dist/special/choose.js +17 -8
- package/dist/special/dd.js +122 -18
- package/dist/special/extra.js +14 -2
- package/dist/special/gamma.js +11 -2
- package/dist/special/incbet.js +30 -4
- package/dist/special/incbetTemme.d.ts +7 -0
- package/dist/special/incbetTemme.js +45 -12
- package/dist/special/loader.d.ts +1 -1
- package/dist/special/loader.js +117 -20
- package/dist/special/log1pmx.js +4 -0
- package/dist/special.js +2 -2
- package/dist/tests.js +11 -11
- package/llms.txt +12 -6
- package/package.json +1 -1
- package/dist/chunks/chunk-3THFTB36.js +0 -2
- package/dist/chunks/chunk-3TSWYE5L.js +0 -2
- package/dist/chunks/chunk-3WPU6LGK.js +0 -2
- package/dist/chunks/chunk-5ITR67MB.js +0 -2
- package/dist/chunks/chunk-5NRFU6F6.js +0 -2
- package/dist/chunks/chunk-E2LCSVQV.js +0 -2
- package/dist/chunks/chunk-FCNVTIPJ.js +0 -2
- package/dist/chunks/chunk-FKAKALOZ.js +0 -2
- package/dist/chunks/chunk-HD73UKPT.js +0 -2
- package/dist/chunks/chunk-IUULP3LE.js +0 -2
- package/dist/chunks/chunk-JQG3YQOC.js +0 -2
- package/dist/chunks/chunk-KT66SB7R.js +0 -2
- package/dist/chunks/chunk-MAUAOQG3.js +0 -2
- package/dist/chunks/chunk-MDYE7QP2.js +0 -2
- package/dist/chunks/chunk-NM3Z2UBQ.js +0 -2
- package/dist/chunks/chunk-PMJI5QO6.js +0 -3
- package/dist/chunks/chunk-UF7KOTHF.js +0 -3
- package/dist/chunks/chunk-UOE57JGT.js +0 -2
- package/dist/chunks/chunk-USPEBXSR.js +0 -2
- package/dist/chunks/chunk-ZIX7NYQF.js +0 -2
package/dist/internal/invert.js
CHANGED
|
@@ -145,8 +145,11 @@ export function invertContinuous(problem) {
|
|
|
145
145
|
}
|
|
146
146
|
if (!(xl > 0 && xh > xl && Number.isFinite(xh)))
|
|
147
147
|
return x0;
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
// halved on the bit patterns of the doubles (positive x: ordered as integers), so that any bracket shrinks to
|
|
149
|
+
// adjacent doubles within 64 steps; halving the values took 64 steps per factor 2^64 of width, and a bracket 1e55
|
|
150
|
+
// times wider than the answer ended far from it (qgamma(0.75, 1e145) was 151 ulps below the right 1e145)
|
|
151
|
+
for (let k = 0; k < 70; k++) {
|
|
152
|
+
const mid = bitMidpoint(xl, xh);
|
|
150
153
|
if (mid <= xl || mid >= xh)
|
|
151
154
|
break;
|
|
152
155
|
const r = evaluate(mid)[1];
|
|
@@ -162,6 +165,16 @@ export function invertContinuous(problem) {
|
|
|
162
165
|
return Math.abs(evaluate(xl)[1]) < Math.abs(evaluate(xh)[1]) ? xl : xh;
|
|
163
166
|
}
|
|
164
167
|
}
|
|
168
|
+
const bitView = new DataView(new ArrayBuffer(8));
|
|
169
|
+
/** The double halfway between positive finite a < b in the order of the doubles (the mean of their bit patterns) */
|
|
170
|
+
function bitMidpoint(a, b) {
|
|
171
|
+
bitView.setFloat64(0, a);
|
|
172
|
+
const ia = bitView.getBigUint64(0);
|
|
173
|
+
bitView.setFloat64(0, b);
|
|
174
|
+
const ib = bitView.getBigUint64(0);
|
|
175
|
+
bitView.setBigUint64(0, (ia + ib) / 2n);
|
|
176
|
+
return bitView.getFloat64(0);
|
|
177
|
+
}
|
|
165
178
|
/** Midpoint of the bracketing interval. If an end is infinite, expand outward from the current value */
|
|
166
179
|
function midpoint(lo, hi, x) {
|
|
167
180
|
if (Number.isFinite(lo) && Number.isFinite(hi))
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (R'R)^-1 of an upper triangular R as inv_jk 2^(-e_j - e_k): the columns of R divided by 2^e_j first (exact). The
|
|
3
|
+
* inverse of R itself overflowed for columns of 1e-200 (and underflowed for 1e200), so standard errors were Infinity
|
|
4
|
+
* or 0 though they scale with the column (R's too). e_j is the exponent of the largest |R_ij| of a column outside
|
|
5
|
+
* [2^-400, 2^400], else 0, which leaves the computation as before
|
|
6
|
+
*/
|
|
7
|
+
export declare function chol2invColumns(R: readonly (readonly number[])[]): {
|
|
8
|
+
inv: number[][];
|
|
9
|
+
e: number[];
|
|
10
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// (R'R)^-1 of a triangular factor whose columns may be far from 1 (review 64).
|
|
2
|
+
import { chol2inv } from "../linalg/chol.js";
|
|
3
|
+
import { ldexp } from "./summary.js";
|
|
4
|
+
/**
|
|
5
|
+
* (R'R)^-1 of an upper triangular R as inv_jk 2^(-e_j - e_k): the columns of R divided by 2^e_j first (exact). The
|
|
6
|
+
* inverse of R itself overflowed for columns of 1e-200 (and underflowed for 1e200), so standard errors were Infinity
|
|
7
|
+
* or 0 though they scale with the column (R's too). e_j is the exponent of the largest |R_ij| of a column outside
|
|
8
|
+
* [2^-400, 2^400], else 0, which leaves the computation as before
|
|
9
|
+
*/
|
|
10
|
+
export function chol2invColumns(R) {
|
|
11
|
+
const p = R.length;
|
|
12
|
+
const e = new Array(p).fill(0);
|
|
13
|
+
for (let j = 0; j < p; j++) {
|
|
14
|
+
let top = 0;
|
|
15
|
+
for (let i = 0; i <= j; i++)
|
|
16
|
+
top = Math.max(top, Math.abs(R[i][j]));
|
|
17
|
+
if (top > 0 && Number.isFinite(top) && (top < 2 ** -400 || top > 2 ** 400))
|
|
18
|
+
e[j] = Math.floor(Math.log2(top));
|
|
19
|
+
}
|
|
20
|
+
const Rs = e.every((v) => v === 0) ? R.map((r) => r.slice()) : R.map((r) => r.map((v, j) => ldexp(v, -e[j])));
|
|
21
|
+
return { inv: chol2inv(Rs), e };
|
|
22
|
+
}
|
package/dist/internal/seq.js
CHANGED
|
@@ -4,10 +4,23 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export function seqLength(from, to, n) {
|
|
6
6
|
const len = Math.ceil(n);
|
|
7
|
+
// (a length that is not finite or rounds up to a negative number was an empty array; issue #98)
|
|
8
|
+
if (!Number.isFinite(n) || len < 0)
|
|
9
|
+
throw new RangeError("'length.out' must be a non-negative number");
|
|
7
10
|
if (len === 1)
|
|
8
11
|
return [from];
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
let out;
|
|
13
|
+
if (Number.isFinite(to - from) || !Number.isFinite(from) || !Number.isFinite(to)) {
|
|
14
|
+
const by = (to - from) / (len - 1);
|
|
15
|
+
out = Array.from({ length: len }, (_, i) => from + i * by);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
// finite ends whose difference overflows: in half coordinates, doubled (seqLength(-1e308, 1e308, 3) was NaN,
|
|
19
|
+
// Infinity, 1e308; R's seq gives -1e308, 0, 1e308)
|
|
20
|
+
const h = from / 2;
|
|
21
|
+
const by = (to / 2 - h) / (len - 1);
|
|
22
|
+
out = Array.from({ length: len }, (_, i) => 2 * (h + i * by));
|
|
23
|
+
}
|
|
11
24
|
if (len > 0)
|
|
12
25
|
out[len - 1] = to;
|
|
13
26
|
return out;
|
|
@@ -14,13 +14,77 @@ export declare function wideSumAdd(acc: WideSum, v: number, n: number): void;
|
|
|
14
14
|
export declare function wideSumValue(acc: WideSum): number;
|
|
15
15
|
/** v 2^k for an integer k, in two steps so that 2^k itself does not overflow or underflow */
|
|
16
16
|
export declare function ldexp(v: number, k: number): number;
|
|
17
|
+
/** v 2^k for any integer k (beyond the +-2046 of ldexp), in steps of at most 2^1000 */
|
|
18
|
+
export declare function ldexpWide(v: number, k: number): number;
|
|
17
19
|
/** Mean as double-double. x contains no NaN and has length >= 1 */
|
|
18
20
|
export declare function meanDD(x: readonly number[]): DD;
|
|
19
21
|
export declare function mean(x: readonly number[]): number;
|
|
20
22
|
/** Unbiased variance. NaN for length below 2 (R's var gives NA) */
|
|
21
23
|
export declare function variance(x: readonly number[]): number;
|
|
24
|
+
/**
|
|
25
|
+
* Sample standard deviation from the scaled deviations: sqrt(sum d^2 / (n - 1)) in the coordinates 2^-k, times 2^k.
|
|
26
|
+
* The same bits as sqrt(variance(x)) where the variance is a normal number (the square root of 4^k y is 2^k sqrt(y)),
|
|
27
|
+
* and the right value where it overflows or underflows (sd of c(-1e308, -1e308, -1e308, -1e308, 1.5e308) is 1.118e308
|
|
28
|
+
* while its variance is 1.25e616). x contains no NaN
|
|
29
|
+
*/
|
|
30
|
+
export declare function standardDeviation(x: readonly number[]): number;
|
|
22
31
|
/** Unbiased covariance. x and y have the same length and contain no NaN */
|
|
23
32
|
export declare function covariance(x: readonly number[], y: readonly number[]): number;
|
|
33
|
+
/**
|
|
34
|
+
* The deviations from the mean of x scaled by 2^-k (the scaling first, see the rules above), in double-double, with k
|
|
35
|
+
* and the scaled mean. undefined when x has an infinite value (the mean is not finite)
|
|
36
|
+
*/
|
|
37
|
+
export declare function centered(x: readonly number[]): {
|
|
38
|
+
d: DD[];
|
|
39
|
+
k: number;
|
|
40
|
+
mean: DD;
|
|
41
|
+
} | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* (x - mean) / sd, from the scaled deviations (no overflow or underflow at any scale). NaN values when the standard
|
|
44
|
+
* deviation is 0 or x has fewer than 2 values or an infinite one
|
|
45
|
+
*/
|
|
46
|
+
export declare function standardize(x: readonly number[]): number[];
|
|
47
|
+
/**
|
|
48
|
+
* Moments of groups on one common scale 2^-k (see the rules above): per group the size, mean, within sum of squares
|
|
49
|
+
* and variance (NaN below 2 values), the grand mean, the between and pooled within sums of squares (accumulated in
|
|
50
|
+
* double-double), and the scaled values. Means are scaled back by 2^k, sums of squares and variances by 2^2k
|
|
51
|
+
*/
|
|
52
|
+
export interface GroupMoments {
|
|
53
|
+
k: number;
|
|
54
|
+
groups: number[][];
|
|
55
|
+
n: number[];
|
|
56
|
+
mean: number[];
|
|
57
|
+
ss: number[];
|
|
58
|
+
variance: number[];
|
|
59
|
+
grandMean: number;
|
|
60
|
+
ssBetween: number;
|
|
61
|
+
ssWithin: number;
|
|
62
|
+
}
|
|
63
|
+
export declare function groupMoments(groups: readonly (readonly number[])[]): GroupMoments;
|
|
64
|
+
/** x - y for paired values, both scaled by one 2^-k first (so the differences cannot overflow), with k */
|
|
65
|
+
export declare function pairedDifferences(x: readonly number[], y: readonly number[]): {
|
|
66
|
+
d: number[];
|
|
67
|
+
k: number;
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Satterthwaite's degrees of freedom (sum w)^2 / sum(w^2 / df) of a sum of independent variance estimates w with
|
|
71
|
+
* degrees of freedom df. The w are scaled by a power of 2 first (no rounding), so the squares neither overflow nor
|
|
72
|
+
* underflow when the w do not; the ratio does not depend on the units of the data. The form of irr's icc (the same
|
|
73
|
+
* order of operations); tTest, cohensD and gamesHowellTest use R's forms below and this only where those are not finite
|
|
74
|
+
*/
|
|
75
|
+
export declare function satterthwaiteDf(w: readonly number[], df: readonly number[]): number;
|
|
76
|
+
/**
|
|
77
|
+
* Welch's degrees of freedom in the form of R's t.test and effectsize: se^4 / sum(se_i^4 / df_i) with se_i = sqrt(w_i)
|
|
78
|
+
* and se = sqrt(sum se_i^2), on the w scaled by an even power of 2 (exact, also through sqrt, so the same bits as R
|
|
79
|
+
* wherever R's terms are in range, and no overflow). {@link satterthwaiteDf} where that is not finite and positive
|
|
80
|
+
* (revision of review 2)
|
|
81
|
+
*/
|
|
82
|
+
export declare function satterthwaiteDfSe(w: readonly number[], df: readonly number[]): number;
|
|
83
|
+
/**
|
|
84
|
+
* Welch's degrees of freedom in the form of PMCMRplus's gamesHowellTest: A^2 / sum(s2_i^2 / (n_i^2 (n_i - 1))) with
|
|
85
|
+
* A = sum s2_i / n_i, for the group variances s2 and sizes n, scaled as {@link satterthwaiteDfSe} (revision of review 2)
|
|
86
|
+
*/
|
|
87
|
+
export declare function satterthwaiteDfPM(s2: readonly number[], n: readonly number[]): number;
|
|
24
88
|
/**
|
|
25
89
|
* Sum (accumulated in double-double without overflow, then rounded; ±Infinity beyond the double range). With
|
|
26
90
|
* infinite or NaN values, as in double arithmetic
|
|
@@ -37,3 +101,29 @@ export declare function tieCounts(x: readonly number[]): number[];
|
|
|
37
101
|
export declare function dropNaN(x: readonly number[]): number[];
|
|
38
102
|
/** Keep only the pairs where neither x nor y is NaN (R's complete.cases) */
|
|
39
103
|
export declare function completePairs(x: readonly number[], y: readonly number[]): [number[], number[]];
|
|
104
|
+
/**
|
|
105
|
+
* d^2 / e, as for a Pearson chi-squared term. When d^2 overflows (or loses precision below the normal range) although
|
|
106
|
+
* the quotient is representable, it is formed as (d / sqrt(e))^2 instead
|
|
107
|
+
*/
|
|
108
|
+
export declare function squareOver(d: number, e: number): number;
|
|
109
|
+
/**
|
|
110
|
+
* a b / n, as for an expected count from two margins. When the product overflows, underflows or is subnormal (with a
|
|
111
|
+
* and b not 0), the three are scaled to [1, 2) by powers of 2 and the exponents added back at the end
|
|
112
|
+
*/
|
|
113
|
+
export declare function productOver(a: number, b: number, n: number): number;
|
|
114
|
+
/**
|
|
115
|
+
* Data scaled by a power of 2, 2^-k, so that the largest finite absolute value is in [1, 2) (k = 0 when there is
|
|
116
|
+
* none). The scaling adds no rounding error, so statistics that do not depend on the units (t, F, chi-squared,
|
|
117
|
+
* ratios of variances, degrees of freedom) come out as from the original data, but their squares and variances
|
|
118
|
+
* can no longer overflow or underflow. Quantities with units are multiplied back by 2^k (see ldexp)
|
|
119
|
+
*/
|
|
120
|
+
export declare function scaleToUnit(groups: readonly (readonly number[])[]): {
|
|
121
|
+
groups: number[][];
|
|
122
|
+
k: number;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Euclidean norm sqrt(sum x_i^2): the plain sum where it is in range (so the value is unchanged there), otherwise from
|
|
126
|
+
* the values divided by the largest |x_i| (as BLAS's dnrm2), so that squares of values around 1e200 or 1e-200 neither
|
|
127
|
+
* overflow nor underflow
|
|
128
|
+
*/
|
|
129
|
+
export declare function norm2(x: readonly number[]): number;
|