@numero-uno-jpn/rstats 0.15.3 → 0.17.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 +294 -0
- package/README.ja.md +68 -35
- package/README.md +65 -30
- package/dist/chunks/chunk-2C33MXSW.js +3 -0
- package/dist/chunks/chunk-34S5SQY6.js +2 -0
- package/dist/chunks/chunk-4WE3OO62.js +2 -0
- package/dist/chunks/chunk-5AYHCITP.js +2 -0
- package/dist/chunks/chunk-6JJQL6HL.js +2 -0
- package/dist/chunks/chunk-C7V2FH6L.js +3 -0
- package/dist/chunks/chunk-CZI7KUO3.js +2 -0
- package/dist/chunks/chunk-DXI5N2ET.js +2 -0
- package/dist/chunks/chunk-FY3FVOBM.js +2 -0
- package/dist/chunks/chunk-H3WVPZDL.js +2 -0
- package/dist/chunks/chunk-LHUIJQHY.js +2 -0
- package/dist/chunks/chunk-LV3W2F7N.js +2 -0
- package/dist/chunks/chunk-M4ITG7YR.js +2 -0
- package/dist/chunks/chunk-NSYZTS26.js +2 -0
- package/dist/chunks/chunk-ONY5CISH.js +2 -0
- package/dist/chunks/chunk-RFE7MVP7.js +2 -0
- package/dist/chunks/chunk-SE7V2KLO.js +2 -0
- package/dist/chunks/chunk-THIGHOKK.js +2 -0
- package/dist/chunks/chunk-TNMJPQPV.js +2 -0
- package/dist/chunks/chunk-WM7VFXTV.js +2 -0
- package/dist/chunks/chunk-WMDYDTVQ.js +2 -0
- package/dist/chunks/chunk-XLSFJTTK.js +2 -0
- package/dist/chunks/chunk-Z37NELOS.js +2 -0
- package/dist/chunks/chunk-ZFQWB222.js +2 -0
- package/dist/data/grouping.js +26 -7
- package/dist/descriptive/basic.js +110 -8
- package/dist/descriptive/cov.js +23 -4
- package/dist/descriptive/dataFrames.d.ts +4 -2
- package/dist/descriptive/dataFrames.js +69 -23
- package/dist/descriptive/factanal.d.ts +2 -0
- package/dist/descriptive/factanal.js +26 -9
- package/dist/descriptive/hist.d.ts +8 -5
- package/dist/descriptive/hist.js +77 -31
- package/dist/descriptive/missing.js +3 -1
- package/dist/descriptive/moments.js +86 -19
- package/dist/descriptive/omega.d.ts +1 -1
- package/dist/descriptive/omega.js +74 -10
- package/dist/descriptive/pivot.d.ts +25 -10
- package/dist/descriptive/pivot.js +182 -42
- package/dist/descriptive/quantile.js +10 -1
- package/dist/descriptive/rank.js +8 -1
- package/dist/descriptive/table.d.ts +23 -3
- package/dist/descriptive/table.js +36 -21
- package/dist/descriptive.js +2 -2
- package/dist/distributions/arcsine.js +27 -2
- package/dist/distributions/beta.js +33 -4
- package/dist/distributions/binomial.js +46 -14
- package/dist/distributions/bvnorm.js +11 -2
- package/dist/distributions/cauchy.js +21 -4
- package/dist/distributions/chisq.js +16 -3
- package/dist/distributions/exponential.js +14 -0
- package/dist/distributions/f.js +41 -17
- package/dist/distributions/gamma.js +35 -3
- package/dist/distributions/geometric.js +58 -13
- package/dist/distributions/hypergeometric.d.ts +5 -1
- package/dist/distributions/hypergeometric.js +101 -6
- package/dist/distributions/invgamma.js +10 -1
- package/dist/distributions/kumaraswamy.js +9 -0
- package/dist/distributions/laplace.js +36 -6
- package/dist/distributions/logistic.js +13 -1
- package/dist/distributions/lognormal.js +16 -2
- package/dist/distributions/multinomial.js +58 -11
- package/dist/distributions/nbeta.js +62 -11
- package/dist/distributions/nchisq.js +30 -6
- package/dist/distributions/negbinomial.js +102 -17
- package/dist/distributions/normal.js +17 -4
- package/dist/distributions/nt.js +392 -17
- package/dist/distributions/pareto.js +12 -1
- package/dist/distributions/poisson.js +37 -3
- package/dist/distributions/signrank.js +16 -4
- package/dist/distributions/summary.d.ts +2 -1
- package/dist/distributions/summary.js +481 -61
- package/dist/distributions/t.js +9 -0
- package/dist/distributions/triangular.js +19 -5
- package/dist/distributions/tukey.js +11 -2
- package/dist/distributions/uniform.js +8 -0
- package/dist/distributions/weibull.js +18 -0
- package/dist/distributions/wilcox.d.ts +9 -3
- package/dist/distributions/wilcox.js +164 -26
- package/dist/distributions.js +2 -2
- package/dist/entries/descriptive.d.ts +3 -1
- package/dist/entries/descriptive.js +1 -1
- package/dist/entries/distributions.d.ts +1 -0
- package/dist/entries/distributions.js +2 -0
- package/dist/entries/linalg.d.ts +3 -1
- package/dist/entries/mixed.d.ts +3 -0
- package/dist/entries/mixed.js +2 -0
- package/dist/entries/numerics.d.ts +2 -1
- package/dist/entries/tests.d.ts +8 -5
- package/dist/entries/tests.js +3 -1
- package/dist/htest/agreement.d.ts +16 -2
- package/dist/htest/agreement.js +122 -21
- package/dist/htest/ansariTest.d.ts +8 -2
- package/dist/htest/ansariTest.js +116 -18
- package/dist/htest/aov.d.ts +29 -23
- package/dist/htest/aov.js +90 -47
- package/dist/htest/binomTest.d.ts +5 -0
- package/dist/htest/binomTest.js +47 -17
- package/dist/htest/brunnerMunzelTest.d.ts +4 -3
- package/dist/htest/brunnerMunzelTest.js +12 -5
- package/dist/htest/chisqTest.d.ts +5 -2
- package/dist/htest/chisqTest.js +151 -46
- package/dist/htest/cor.d.ts +9 -2
- package/dist/htest/cor.js +57 -26
- 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/core/simulate.d.ts +6 -0
- package/dist/htest/core/simulate.js +20 -0
- package/dist/htest/dunnett.js +14 -5
- package/dist/htest/effectSize.d.ts +5 -0
- package/dist/htest/effectSize.js +117 -35
- package/dist/htest/fisherTest.d.ts +4 -3
- package/dist/htest/fisherTest.js +88 -24
- package/dist/htest/groups.d.ts +7 -0
- package/dist/htest/groups.js +21 -4
- package/dist/htest/ksTest.d.ts +7 -1
- package/dist/htest/ksTest.js +36 -6
- package/dist/htest/leveneTest.d.ts +2 -0
- package/dist/htest/leveneTest.js +28 -6
- package/dist/htest/mantelhaenTest.js +132 -25
- package/dist/htest/mcnemarTest.js +40 -11
- package/dist/htest/multipleComparisons.d.ts +24 -26
- package/dist/htest/multipleComparisons.js +70 -64
- package/dist/htest/normalityTests.js +54 -14
- package/dist/htest/onewayTest.js +106 -5
- package/dist/htest/pAdjust.d.ts +3 -2
- package/dist/htest/pAdjust.js +42 -6
- package/dist/htest/pairwise.d.ts +3 -1
- package/dist/htest/pairwise.js +46 -21
- package/dist/htest/poissonTest.d.ts +1 -1
- package/dist/htest/poissonTest.js +117 -59
- package/dist/htest/polycor.js +47 -17
- package/dist/htest/power.d.ts +15 -1
- package/dist/htest/power.js +128 -10
- package/dist/htest/propTest.d.ts +3 -0
- package/dist/htest/propTest.js +44 -6
- package/dist/htest/pwr.d.ts +38 -1
- package/dist/htest/pwr.js +159 -39
- package/dist/htest/rankTests.js +36 -6
- package/dist/htest/tTest.d.ts +2 -0
- package/dist/htest/tTest.js +53 -21
- package/dist/htest/testFormula.js +11 -11
- package/dist/htest/trendTests.d.ts +28 -4
- package/dist/htest/trendTests.js +124 -35
- package/dist/htest/types.d.ts +7 -0
- package/dist/htest/types.js +7 -0
- package/dist/htest/varTest.js +52 -14
- package/dist/htest/wilcoxTest.js +164 -29
- package/dist/integrate/quadpack.js +27 -5
- package/dist/internal/checkOptions.d.ts +11 -0
- package/dist/internal/checkOptions.js +31 -0
- 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/optionalArgs.d.ts +12 -0
- package/dist/internal/optionalArgs.js +46 -0
- 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/internal/warnings.d.ts +66 -0
- package/dist/internal/warnings.js +122 -0
- package/dist/linalg/basic.d.ts +3 -1
- package/dist/linalg/basic.js +58 -7
- package/dist/linalg/chol.js +10 -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 +75 -14
- package/dist/linalg/expm.d.ts +3 -2
- package/dist/linalg/expm.js +113 -15
- package/dist/linalg/kappa.js +64 -10
- package/dist/linalg/lu.d.ts +2 -1
- package/dist/linalg/lu.js +40 -5
- package/dist/linalg/matrix.d.ts +14 -0
- package/dist/linalg/matrix.js +24 -0
- package/dist/linalg/norm.js +4 -0
- package/dist/linalg/ops.d.ts +27 -2
- package/dist/linalg/ops.js +74 -26
- package/dist/linalg/qr.d.ts +2 -1
- package/dist/linalg/qr.js +105 -23
- package/dist/linalg/schur.js +11 -3
- package/dist/linalg/solve.d.ts +6 -1
- package/dist/linalg/solve.js +156 -26
- package/dist/linalg/svd.d.ts +9 -2
- package/dist/linalg/svd.js +33 -11
- package/dist/linalg.js +2 -2
- package/dist/mixed.js +4 -4
- package/dist/models/anovaSequential.d.ts +32 -2
- package/dist/models/anovaSequential.js +170 -28
- package/dist/models/aovEz.js +154 -39
- package/dist/models/aovStrata.js +68 -24
- package/dist/models/carAnova.d.ts +1 -1
- package/dist/models/carAnova.js +78 -33
- package/dist/models/coxph.d.ts +6 -0
- package/dist/models/coxph.js +166 -69
- 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 +57 -7
- package/dist/models/glm.js +427 -74
- package/dist/models/glmAnova.js +90 -14
- package/dist/models/glmConfint.d.ts +1 -1
- package/dist/models/glmConfint.js +121 -29
- package/dist/models/glmFamily.d.ts +11 -6
- package/dist/models/glmFamily.js +247 -62
- package/dist/models/lm.d.ts +12 -1
- package/dist/models/lm.js +246 -37
- package/dist/models/lmer.d.ts +31 -7
- package/dist/models/lmer.js +129 -42
- package/dist/models/lmerAnova.d.ts +3 -3
- package/dist/models/lmerAnova.js +47 -9
- package/dist/models/lmerHypotheses.d.ts +6 -2
- package/dist/models/lmerHypotheses.js +14 -2
- package/dist/models/lmerTest.d.ts +13 -6
- package/dist/models/lmerTest.js +82 -29
- package/dist/models/mauchly.d.ts +6 -1
- package/dist/models/mauchly.js +41 -15
- package/dist/models/mixedStructure.js +6 -0
- package/dist/models/modelFrame.js +10 -4
- package/dist/models/modelMatrix.d.ts +3 -1
- package/dist/models/modelMatrix.js +47 -17
- package/dist/models/scaledTables.d.ts +8 -0
- package/dist/models/scaledTables.js +6 -0
- package/dist/models/survival.d.ts +12 -1
- package/dist/models/survival.js +75 -28
- 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 +72 -8
- package/dist/numerics/integrate.d.ts +9 -1
- package/dist/numerics/integrate.js +111 -16
- package/dist/numerics/interp.d.ts +40 -9
- package/dist/numerics/interp.js +375 -55
- package/dist/numerics/ode.js +59 -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 +97 -10
- package/dist/random/beta.js +58 -4
- package/dist/random/binomial.d.ts +14 -3
- package/dist/random/binomial.js +59 -24
- package/dist/random/continuous.js +50 -5
- package/dist/random/extra.js +55 -9
- package/dist/random/gamma.d.ts +4 -1
- package/dist/random/gamma.js +47 -8
- package/dist/random/hyper.js +9 -6
- package/dist/random/mt.js +17 -2
- package/dist/random/poisson.js +31 -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/rng.js +4 -0
- package/dist/random/sample.d.ts +12 -2
- package/dist/random/sample.js +63 -20
- package/dist/random/streams.js +4 -2
- package/dist/rstats.js +17 -14
- package/dist/special/besselIK.d.ts +12 -0
- package/dist/special/besselIK.js +175 -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 +24 -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/psigamma.js +7 -0
- package/dist/special.js +2 -2
- package/dist/tests.js +15 -11
- package/llms.txt +15 -6
- package/package.json +19 -10
- 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-VLUL2HFW.js +0 -3
- package/dist/chunks/chunk-ZIX7NYQF.js +0 -2
|
@@ -7,8 +7,15 @@ import { d0, dt0, dt1, quantileBoundaries } from "../internal/dpq.js";
|
|
|
7
7
|
import { discreteQuantile } from "../internal/discrete.js";
|
|
8
8
|
import { gammaInc } from "../special/igam.js";
|
|
9
9
|
import { dpoisRaw } from "../special/loader.js";
|
|
10
|
+
import { logAddExp, logSubExp } from "../internal/ddexp.js";
|
|
10
11
|
import { qnorm } from "./normal.js";
|
|
11
|
-
import { nonInt } from "../internal/integer.js";
|
|
12
|
+
import { countAtMost, nonInt } from "../internal/integer.js";
|
|
13
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
14
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
15
|
+
const DPOIS_KEYS = ["log"];
|
|
16
|
+
const PPOIS_KEYS = ["lowerTail", "logP"];
|
|
17
|
+
const QPOIS_KEYS = ["lowerTail", "logP"];
|
|
18
|
+
// Generated by `node scripts/option-keys.mjs --write` (end)
|
|
12
19
|
/** Whether x is not an integer (relative tolerance 1e-9 as in R; see src/internal/integer.ts) */
|
|
13
20
|
export const nonInteger = nonInt;
|
|
14
21
|
export function dpois1(x, lambda, log) {
|
|
@@ -33,7 +40,30 @@ export function ppois1(q, lambda, lowerTail, logP) {
|
|
|
33
40
|
return dt1(lowerTail, logP);
|
|
34
41
|
if (!Number.isFinite(q))
|
|
35
42
|
return dt1(lowerTail, logP);
|
|
36
|
-
const x =
|
|
43
|
+
const x = countAtMost(q);
|
|
44
|
+
if (x + 1 - x === 1)
|
|
45
|
+
return gammaInc(x + 1, lambda, !lowerTail, logP);
|
|
46
|
+
// Beyond 2^53, x + 1 rounds (to x, or up to x + 2) and Q(x + 1, lambda) became Q(x, lambda): ppois(1e16, 1e16) was 0.4999999987, below
|
|
47
|
+
// 1/2 (R: 0.5000000027), and qpois(0.5, 1e16) 2 above the median 1e16. Without x + 1:
|
|
48
|
+
// P[X <= x] = Q(x, lambda) + dpois(x, lambda), P[X > x] = P(x, lambda) - dpois(x, lambda)
|
|
49
|
+
let v;
|
|
50
|
+
let term;
|
|
51
|
+
if (!logP) {
|
|
52
|
+
const t = gammaInc(x, lambda, !lowerTail, false);
|
|
53
|
+
term = dpoisRaw(x, lambda, false);
|
|
54
|
+
v = lowerTail ? t + term : t - term;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const lt = gammaInc(x, lambda, !lowerTail, true);
|
|
58
|
+
term = dpoisRaw(x, lambda, true);
|
|
59
|
+
v = lowerTail ? logAddExp(lt, term) : logSubExp(lt, term);
|
|
60
|
+
}
|
|
61
|
+
if (Number.isNaN(term))
|
|
62
|
+
return NaN;
|
|
63
|
+
// The upper tail as a difference: where dpois is not resolved against it (deep tails, where both logs round to the
|
|
64
|
+
// same value), one unit of x is below the resolution of the result, and the rounded x + 1 serves (round 55)
|
|
65
|
+
if (lowerTail || (logP ? Number.isFinite(v) : v > 0))
|
|
66
|
+
return v;
|
|
37
67
|
return gammaInc(x + 1, lambda, !lowerTail, logP);
|
|
38
68
|
}
|
|
39
69
|
export function qpois1(p, lambda, lowerTail, logP) {
|
|
@@ -54,7 +84,8 @@ export function qpois1(p, lambda, lowerTail, logP) {
|
|
|
54
84
|
p,
|
|
55
85
|
lowerTail,
|
|
56
86
|
logP,
|
|
57
|
-
|
|
87
|
+
// (through ppois1, which also holds beyond 2^53 where y + 1 rounds to y)
|
|
88
|
+
cdf: (y, l, lg) => ppois1(y, lambda, l, lg),
|
|
58
89
|
y0: Number.isFinite(y0) ? y0 : lambda,
|
|
59
90
|
lo: 0,
|
|
60
91
|
hi: Infinity,
|
|
@@ -77,6 +108,7 @@ export function qpois1(p, lambda, lowerTail, logP) {
|
|
|
77
108
|
* @category Distributions
|
|
78
109
|
*/
|
|
79
110
|
export function dpois(x, lambda, options = {}) {
|
|
111
|
+
checkOptions(options, DPOIS_KEYS, "dpois"); // generated: option-keys.mjs
|
|
80
112
|
const log = options.log ?? false;
|
|
81
113
|
return vectorize(x, (v) => dpois1(v, lambda, log));
|
|
82
114
|
}
|
|
@@ -97,6 +129,7 @@ export function dpois(x, lambda, options = {}) {
|
|
|
97
129
|
* @category Distributions
|
|
98
130
|
*/
|
|
99
131
|
export function ppois(q, lambda, options = {}) {
|
|
132
|
+
checkOptions(options, PPOIS_KEYS, "ppois"); // generated: option-keys.mjs
|
|
100
133
|
const { lowerTail = true, logP = false } = options;
|
|
101
134
|
return vectorize(q, (v) => ppois1(v, lambda, lowerTail, logP));
|
|
102
135
|
}
|
|
@@ -117,6 +150,7 @@ export function ppois(q, lambda, options = {}) {
|
|
|
117
150
|
* @category Distributions
|
|
118
151
|
*/
|
|
119
152
|
export function qpois(p, lambda, options = {}) {
|
|
153
|
+
checkOptions(options, QPOIS_KEYS, "qpois"); // generated: option-keys.mjs
|
|
120
154
|
const { lowerTail = true, logP = false } = options;
|
|
121
155
|
return vectorize(p, (v) => qpois1(v, lambda, lowerTail, logP));
|
|
122
156
|
}
|
|
@@ -8,8 +8,14 @@
|
|
|
8
8
|
import { vectorize } from "../internal/vectorize.js";
|
|
9
9
|
import { d0, dt0, dt1, quantileBoundaries } from "../internal/dpq.js";
|
|
10
10
|
import { discreteQuantile } from "../internal/discrete.js";
|
|
11
|
-
import { nonInt, roundHalfEven } from "../internal/integer.js";
|
|
11
|
+
import { countAtMost, nonInt, roundHalfEven } from "../internal/integer.js";
|
|
12
12
|
import { qnorm } from "./normal.js";
|
|
13
|
+
// Generated by `node scripts/option-keys.mjs --write` from the option types; do not edit (begin)
|
|
14
|
+
import { checkOptions } from "../internal/checkOptions.js";
|
|
15
|
+
const DSIGNRANK_KEYS = ["log"];
|
|
16
|
+
const PSIGNRANK_KEYS = ["lowerTail", "logP"];
|
|
17
|
+
const QSIGNRANK_KEYS = ["lowerTail", "logP"];
|
|
18
|
+
// Generated by `node scripts/option-keys.mjs --write` (end)
|
|
13
19
|
/** Threshold at which counts are multiplied by 2^-SCALE_STEP to keep them from growing too large */
|
|
14
20
|
const SCALE_LIMIT = 2 ** 900;
|
|
15
21
|
const SCALE_STEP = -900;
|
|
@@ -152,7 +158,9 @@ function signrankN(n) {
|
|
|
152
158
|
if (!Number.isFinite(n))
|
|
153
159
|
return NaN;
|
|
154
160
|
n = roundHalfEven(n);
|
|
155
|
-
|
|
161
|
+
// The statistic ranges over 0..n(n + 1)/2: beyond 2^53 its values are not all doubles (NaN, as wilcox), and the
|
|
162
|
+
// rounded n(n + 1)/2 was taken as the end of the support. n(n + 1)/2 <= 2^53 exactly when n < 2^27
|
|
163
|
+
return n <= 0 || n >= 2 ** 27 ? NaN : n;
|
|
156
164
|
}
|
|
157
165
|
export function dsignrank1(x, n, log) {
|
|
158
166
|
if (Number.isNaN(x) || Number.isNaN(n))
|
|
@@ -193,8 +201,9 @@ export function psignrank1(q, n, lowerTail, logP) {
|
|
|
193
201
|
n = signrankN(n);
|
|
194
202
|
if (Number.isNaN(n))
|
|
195
203
|
return NaN;
|
|
196
|
-
// R rounds q + 1e-7 to the nearest integer (psignrank(3.6, 5) is P[V <= 4])
|
|
197
|
-
|
|
204
|
+
// R rounds q + 1e-7 to the nearest integer (psignrank(3.6, 5) is P[V <= 4], although V <= 3.6 is V <= 3). The
|
|
205
|
+
// largest count not above q, as the other discrete distribution functions (#145, #146)
|
|
206
|
+
const x = countAtMost(q);
|
|
198
207
|
const total = (n * (n + 1)) / 2;
|
|
199
208
|
if (x < 0)
|
|
200
209
|
return dt0(lowerTail, logP);
|
|
@@ -244,6 +253,7 @@ export function qsignrank1(p, n, lowerTail, logP) {
|
|
|
244
253
|
* @category Distributions
|
|
245
254
|
*/
|
|
246
255
|
export function dsignrank(x, n, options = {}) {
|
|
256
|
+
checkOptions(options, DSIGNRANK_KEYS, "dsignrank"); // generated: option-keys.mjs
|
|
247
257
|
const log = options.log ?? false;
|
|
248
258
|
return vectorize(x, (v) => dsignrank1(v, n, log));
|
|
249
259
|
}
|
|
@@ -266,6 +276,7 @@ export function dsignrank(x, n, options = {}) {
|
|
|
266
276
|
* @category Distributions
|
|
267
277
|
*/
|
|
268
278
|
export function psignrank(q, n, options = {}) {
|
|
279
|
+
checkOptions(options, PSIGNRANK_KEYS, "psignrank"); // generated: option-keys.mjs
|
|
269
280
|
const { lowerTail = true, logP = false } = options;
|
|
270
281
|
return vectorize(q, (v) => psignrank1(v, n, lowerTail, logP));
|
|
271
282
|
}
|
|
@@ -288,6 +299,7 @@ export function psignrank(q, n, options = {}) {
|
|
|
288
299
|
* @category Distributions
|
|
289
300
|
*/
|
|
290
301
|
export function qsignrank(p, n, options = {}) {
|
|
302
|
+
checkOptions(options, QSIGNRANK_KEYS, "qsignrank"); // generated: option-keys.mjs
|
|
291
303
|
const { lowerTail = true, logP = false } = options;
|
|
292
304
|
return vectorize(p, (v) => qsignrank1(v, n, lowerTail, logP));
|
|
293
305
|
}
|
|
@@ -28,7 +28,8 @@ export type DistName = "norm" | "lnorm" | "unif" | "exp" | "gamma" | "chisq" | "
|
|
|
28
28
|
/**
|
|
29
29
|
* Mean, variance, standard deviation, median, mode, skewness and excess kurtosis of a distribution, given by the
|
|
30
30
|
* name of its d/p/q/r functions and their parameters (with the same names and defaults; `gamma` takes `rate` or
|
|
31
|
-
* `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout.
|
|
31
|
+
* `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout. The distributions are the central
|
|
32
|
+
* ones: `ncp` of `chisq`, `beta`, `t` and `f` is not taken (an unknown key, a RangeError).
|
|
32
33
|
* Not an R function. R has no function for these summaries; the R references are closed forms checked against
|
|
33
34
|
* numerical moments.
|
|
34
35
|
*
|