@numero-uno-jpn/rstats 0.5.0 → 0.7.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 +125 -0
- package/README.ja.md +36 -20
- package/README.md +34 -18
- package/THIRD_PARTY_NOTICES.md +25 -5
- package/dist/chunks/chunk-6R7YDHA2.js +2 -0
- package/dist/chunks/chunk-AFKYWGKN.js +2 -0
- package/dist/chunks/chunk-ANYGLFT4.js +2 -0
- package/dist/chunks/chunk-BI5RSUZ2.js +2 -0
- package/dist/chunks/chunk-J3SNI7KY.js +2 -0
- package/dist/chunks/chunk-JCZAB6C5.js +2 -0
- package/dist/chunks/chunk-MVG5LUZU.js +2 -0
- package/dist/chunks/chunk-PTPPP4TI.js +2 -0
- package/dist/chunks/chunk-QNQJA6KZ.js +2 -0
- package/dist/chunks/chunk-SXSJXDD3.js +2 -0
- package/dist/chunks/chunk-UIOAWLAN.js +2 -0
- package/dist/chunks/chunk-XYXHHF5L.js +2 -0
- package/dist/chunks/chunk-YKN6OGJL.js +2 -0
- package/dist/chunks/chunk-ZW52Z3GY.js +2 -0
- package/dist/chunks/chunk-ZYA4ISAT.js +2 -0
- package/dist/descriptive/basic.d.ts +73 -0
- package/dist/descriptive/basic.js +256 -0
- package/dist/descriptive/cov.d.ts +39 -0
- package/dist/descriptive/cov.js +105 -0
- package/dist/descriptive/hist.d.ts +64 -0
- package/dist/descriptive/hist.js +304 -0
- package/dist/descriptive/moments.d.ts +63 -0
- package/dist/descriptive/moments.js +158 -0
- package/dist/descriptive/quantile.d.ts +50 -0
- package/dist/descriptive/quantile.js +131 -0
- package/dist/descriptive/rank.d.ts +23 -0
- package/dist/descriptive/rank.js +72 -0
- package/dist/descriptive/table.d.ts +54 -0
- package/dist/descriptive/table.js +160 -0
- package/dist/descriptive.js +2 -0
- package/dist/distributions/arcsine.d.ts +24 -0
- package/dist/distributions/arcsine.js +73 -0
- package/dist/distributions/invgamma.d.ts +29 -0
- package/dist/distributions/invgamma.js +85 -0
- package/dist/distributions/kumaraswamy.d.ts +17 -0
- package/dist/distributions/kumaraswamy.js +96 -0
- package/dist/distributions/laplace.d.ts +23 -0
- package/dist/distributions/laplace.js +69 -0
- package/dist/distributions/multinomial.d.ts +24 -0
- package/dist/distributions/multinomial.js +70 -0
- package/dist/distributions/nbeta.js +28 -10
- package/dist/distributions/nchisq.js +20 -3
- package/dist/distributions/pareto.d.ts +23 -0
- package/dist/distributions/pareto.js +76 -0
- package/dist/distributions/summary.d.ts +25 -0
- package/dist/distributions/summary.js +289 -0
- package/dist/distributions/triangular.d.ts +25 -0
- package/dist/distributions/triangular.js +87 -0
- package/dist/distributions.js +2 -0
- package/dist/entries/descriptive.d.ts +7 -0
- package/dist/entries/descriptive.js +8 -0
- package/dist/entries/distributions.d.ts +42 -0
- package/dist/entries/distributions.js +42 -0
- package/dist/entries/linalg.d.ts +11 -0
- package/dist/entries/linalg.js +11 -0
- package/dist/entries/numerics.d.ts +8 -0
- package/dist/entries/numerics.js +6 -0
- package/dist/entries/special.d.ts +10 -0
- package/dist/entries/special.js +10 -0
- package/dist/entries/tests.d.ts +21 -0
- package/dist/entries/tests.js +20 -0
- package/dist/htest/ansariTest.d.ts +30 -0
- package/dist/htest/ansariTest.js +253 -0
- package/dist/htest/aov.d.ts +85 -0
- package/dist/htest/aov.js +178 -0
- package/dist/htest/binomTest.d.ts +36 -0
- package/dist/htest/binomTest.js +121 -0
- package/dist/htest/chisqTest.d.ts +34 -2
- package/dist/htest/chisqTest.js +140 -37
- package/dist/htest/cor.d.ts +14 -0
- package/dist/htest/cor.js +4 -3
- package/dist/htest/core/ansari.d.ts +25 -0
- package/dist/htest/core/ansari.js +186 -0
- package/dist/htest/core/kolmogorov.d.ts +26 -0
- package/dist/htest/core/kolmogorov.js +221 -0
- package/dist/htest/core/mantelhaen.d.ts +26 -0
- package/dist/htest/core/mantelhaen.js +145 -0
- package/dist/htest/core/shapiro.d.ts +24 -0
- package/dist/htest/core/shapiro.js +142 -0
- package/dist/htest/core/simulate.d.ts +2 -0
- package/dist/htest/core/simulate.js +16 -0
- package/dist/htest/core/smirnov.d.ts +20 -0
- package/dist/htest/core/smirnov.js +75 -0
- package/dist/htest/fisherTest.d.ts +12 -1
- package/dist/htest/fisherTest.js +187 -127
- package/dist/htest/groups.d.ts +20 -0
- package/dist/htest/groups.js +62 -0
- package/dist/htest/ksTest.d.ts +31 -0
- package/dist/htest/ksTest.js +106 -0
- package/dist/htest/mantelhaenTest.d.ts +26 -0
- package/dist/htest/mantelhaenTest.js +196 -0
- package/dist/htest/mcnemarTest.d.ts +26 -0
- package/dist/htest/mcnemarTest.js +99 -0
- package/dist/htest/onewayTest.d.ts +26 -0
- package/dist/htest/onewayTest.js +97 -0
- package/dist/htest/pairwise.d.ts +64 -0
- package/dist/htest/pairwise.js +152 -0
- package/dist/htest/poissonTest.d.ts +35 -0
- package/dist/htest/poissonTest.js +170 -0
- package/dist/htest/propTest.d.ts +37 -0
- package/dist/htest/propTest.js +164 -0
- package/dist/htest/rankTests.d.ts +52 -0
- package/dist/htest/rankTests.js +234 -0
- package/dist/htest/types.d.ts +2 -0
- package/dist/htest/types.js +6 -0
- package/dist/htest/varTest.d.ts +48 -0
- package/dist/htest/varTest.js +118 -0
- package/dist/htest/wilcoxTest.js +136 -174
- package/dist/index.d.ts +6 -50
- package/dist/index.js +8 -50
- package/dist/integrate/quadpack.d.ts +29 -0
- package/dist/integrate/quadpack.js +525 -0
- package/dist/internal/seq.d.ts +5 -0
- package/dist/internal/seq.js +14 -0
- package/dist/internal/uniroot.js +10 -71
- package/dist/linalg/lu.d.ts +45 -0
- package/dist/linalg/lu.js +88 -0
- package/dist/linalg/ops.d.ts +90 -0
- package/dist/linalg/ops.js +320 -0
- package/dist/linalg.js +2 -0
- package/dist/models/lm.d.ts +98 -0
- package/dist/models/lm.js +187 -0
- package/dist/numerics/deriv.d.ts +37 -0
- package/dist/numerics/deriv.js +150 -0
- package/dist/numerics/integrate.d.ts +91 -0
- package/dist/numerics/integrate.js +264 -0
- package/dist/numerics/interp.d.ts +103 -0
- package/dist/numerics/interp.js +581 -0
- package/dist/numerics/ode.d.ts +23 -0
- package/dist/numerics/ode.js +59 -0
- package/dist/numerics.js +2 -0
- package/dist/optim/localmin.d.ts +16 -0
- package/dist/optim/localmin.js +97 -0
- package/dist/random/beta.js +1 -1
- package/dist/random/binomial.js +1 -1
- package/dist/random/continuous.js +1 -1
- package/dist/random/extra.d.ts +33 -0
- package/dist/random/extra.js +62 -0
- package/dist/random/gamma.js +1 -1
- package/dist/random/hyper.js +1 -1
- package/dist/random/mt.js +0 -1
- package/dist/random/poisson.js +0 -1
- package/dist/random/r2dtable.d.ts +26 -0
- package/dist/random/r2dtable.js +153 -0
- package/dist/random/rank.js +1 -1
- package/dist/random/rng.js +1 -1
- package/dist/random/sample.js +1 -1
- package/dist/rstats.js +3 -2
- package/dist/special/besselIK.d.ts +38 -0
- package/dist/special/besselIK.js +315 -0
- package/dist/special/besselJY.d.ts +32 -0
- package/dist/special/besselJY.js +508 -0
- package/dist/special/besselSeries.d.ts +8 -0
- package/dist/special/besselSeries.js +24 -0
- package/dist/special/beta.js +22 -5
- package/dist/special/choose.d.ts +75 -0
- package/dist/special/choose.js +233 -0
- package/dist/special/erf.d.ts +28 -2
- package/dist/special/erf.js +37 -10
- package/dist/special/extra.d.ts +47 -0
- package/dist/special/extra.js +220 -0
- package/dist/special/igam.d.ts +4 -0
- package/dist/special/igam.js +57 -2
- package/dist/special/incbet.js +77 -22
- package/dist/special/lgammaDiff.d.ts +7 -0
- package/dist/special/lgammaDiff.js +16 -3
- package/dist/special/log1p.d.ts +53 -0
- package/dist/special/log1p.js +93 -0
- package/dist/special/psigamma.d.ts +48 -0
- package/dist/special/psigamma.js +318 -0
- package/dist/special/rCompatible.d.ts +8 -0
- package/dist/special/rCompatible.js +1 -0
- package/dist/special.js +2 -0
- package/dist/tests.js +3 -0
- package/package.json +26 -1
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
// Summaries of a distribution: mean, variance, standard deviation, median, mode, skewness and excess kurtosis.
|
|
2
|
+
//
|
|
3
|
+
// Written for rStats.js from the textbook closed forms (no ported code). Conventions: a moment that does not exist
|
|
4
|
+
// is NaN (the Cauchy mean; the variance when the mean is infinite), an infinite one is Infinity (the variance of t
|
|
5
|
+
// with 1 < df <= 2, the mean of a Pareto with a <= 1); the skewness and kurtosis of the heavy-tailed invgamma,
|
|
6
|
+
// pareto and F distributions are NaN where they are undefined. The median is q(0.5) (for a discrete distribution
|
|
7
|
+
// the smallest x with F(x) >= 1/2). The mode is the maximum of the density: NaN when it is not unique (uniform,
|
|
8
|
+
// beta(1, 1), beta with both shapes below 1, arcsine), the larger of two adjacent maxima of a discrete
|
|
9
|
+
// distribution, and the end point where the density diverges (gamma with shape < 1).
|
|
10
|
+
import { dqagie, dqagse } from "../integrate/quadpack.js";
|
|
11
|
+
import { ddAdd, ddMul, ddSub } from "../special/dd.js";
|
|
12
|
+
import { gamma as gammaFn } from "../special/gamma.js";
|
|
13
|
+
import { lbeta } from "../special/beta.js";
|
|
14
|
+
import { qgamma } from "./gamma.js";
|
|
15
|
+
import { qchisq } from "./chisq.js";
|
|
16
|
+
import { qbeta } from "./beta.js";
|
|
17
|
+
import { qf } from "./f.js";
|
|
18
|
+
import { dweibull1, qweibull } from "./weibull.js";
|
|
19
|
+
import { qbinom } from "./binomial.js";
|
|
20
|
+
import { qpois } from "./poisson.js";
|
|
21
|
+
import { qgeom } from "./geometric.js";
|
|
22
|
+
import { qnbinom } from "./negbinomial.js";
|
|
23
|
+
import { qhyper } from "./hypergeometric.js";
|
|
24
|
+
import { qinvgamma } from "./invgamma.js";
|
|
25
|
+
import { dkumar1, pkumar1, qkumar, qkumar1 } from "./kumaraswamy.js";
|
|
26
|
+
import { qtriang } from "./triangular.js";
|
|
27
|
+
import { qarcsine } from "./arcsine.js";
|
|
28
|
+
const NAN = { mean: NaN, variance: NaN, sd: NaN, median: NaN, mode: NaN, skewness: NaN, kurtosis: NaN };
|
|
29
|
+
function make(mean, variance, median, mode, skewness, kurtosis) {
|
|
30
|
+
return { mean, variance, sd: Math.sqrt(variance), median, mode, skewness, kurtosis };
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Variance, skewness and excess kurtosis from the central moments E[(X - mean)^n], integrated numerically from the
|
|
34
|
+
* density on each side of the mean (no cancellation inside either part): the textbook route through the raw moments
|
|
35
|
+
* cancels badly when the spread is small against the mean (Weibull with a large shape loses 9 digits of the kurtosis
|
|
36
|
+
* that way)
|
|
37
|
+
*/
|
|
38
|
+
function shape(f, mean, lower, upper) {
|
|
39
|
+
return central((t) => t, f, mean, mean, lower, upper);
|
|
40
|
+
}
|
|
41
|
+
/** shape() over t: x(t) with weight w(t), the integral split at t = split where x = mean */
|
|
42
|
+
function central(x, w, mean, split, lower, upper) {
|
|
43
|
+
const tol = 50 * Number.EPSILON;
|
|
44
|
+
const c = [2, 3, 4].map((n) => {
|
|
45
|
+
const g = (t) => (x(t) - mean) ** n * w(t);
|
|
46
|
+
const left = dqagse(g, lower, split, 0, tol, 200).result;
|
|
47
|
+
const right = upper === Infinity ? dqagie(g, split, 1, 0, tol, 200).result : dqagse(g, split, upper, 0, tol, 200).result;
|
|
48
|
+
return left + right;
|
|
49
|
+
});
|
|
50
|
+
const v = c[0];
|
|
51
|
+
return { variance: v, skewness: c[1] / v ** 1.5, kurtosis: c[2] / (v * v) - 3 };
|
|
52
|
+
}
|
|
53
|
+
/** floor(a b) of the exact product (a b rounded to double may cross an integer) */
|
|
54
|
+
function floorProduct(a, b) {
|
|
55
|
+
const [h, l] = ddMul([a, 0], [b, 0]);
|
|
56
|
+
const f = Math.floor(h);
|
|
57
|
+
return h === f && l < 0 ? f - 1 : f;
|
|
58
|
+
}
|
|
59
|
+
/** Whether a b <= c exactly (a, b, c doubles) */
|
|
60
|
+
function productAtMost(a, b, c) {
|
|
61
|
+
const d = ddSub(ddMul(a, [b, 0]), [c, 0]);
|
|
62
|
+
return d[0] + d[1] <= 0;
|
|
63
|
+
}
|
|
64
|
+
const has = (o, k) => o[k] !== undefined;
|
|
65
|
+
/**
|
|
66
|
+
* Mean, variance, standard deviation, median, mode, skewness and excess kurtosis of a distribution, given by the
|
|
67
|
+
* name of its d/p/q/r functions and their parameters (with the same names and defaults; `gamma` takes `rate` or
|
|
68
|
+
* `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* distSummary("gamma", { shape: 2.5, rate: 2 }); // { mean: 1.25, variance: 0.625, ..., mode: 0.75, kurtosis: 2.4 }
|
|
73
|
+
* distSummary("binom", { size: 9, prob: 0.5 }).mode; // 5 (4 and 5 are equally likely: the larger)
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export function distSummary(distribution, params = {}) {
|
|
77
|
+
const P = params;
|
|
78
|
+
switch (distribution) {
|
|
79
|
+
case "norm": {
|
|
80
|
+
const { mean = 0, sd = 1 } = P;
|
|
81
|
+
if (!(Number.isFinite(mean) && sd > 0 && Number.isFinite(sd)))
|
|
82
|
+
return NAN;
|
|
83
|
+
return make(mean, sd * sd, mean, mean, 0, 0);
|
|
84
|
+
}
|
|
85
|
+
case "lnorm": {
|
|
86
|
+
const { meanlog = 0, sdlog = 1 } = P;
|
|
87
|
+
if (!(Number.isFinite(meanlog) && sdlog > 0 && Number.isFinite(sdlog)))
|
|
88
|
+
return NAN;
|
|
89
|
+
const s2 = sdlog * sdlog;
|
|
90
|
+
const em1 = Math.expm1(s2);
|
|
91
|
+
const w = Math.exp(s2);
|
|
92
|
+
return make(Math.exp(meanlog + s2 / 2), em1 * Math.exp(2 * meanlog + s2), Math.exp(meanlog), Math.exp(meanlog - s2), (w + 2) * Math.sqrt(em1),
|
|
93
|
+
// w^4 + 2 w^3 + 3 w^2 - 6 with w = 1 + em1, expanded in em1 (the w form cancels for small sdlog)
|
|
94
|
+
em1 * (16 + em1 * (15 + em1 * (6 + em1))));
|
|
95
|
+
}
|
|
96
|
+
case "unif": {
|
|
97
|
+
const { min = 0, max = 1 } = P;
|
|
98
|
+
if (!(Number.isFinite(min) && Number.isFinite(max) && min < max))
|
|
99
|
+
return NAN;
|
|
100
|
+
const m = min + (max - min) / 2;
|
|
101
|
+
return make(m, (max - min) ** 2 / 12, m, NaN, 0, -1.2);
|
|
102
|
+
}
|
|
103
|
+
case "exp": {
|
|
104
|
+
const { rate = 1 } = P;
|
|
105
|
+
if (!(rate > 0 && Number.isFinite(rate)))
|
|
106
|
+
return NAN;
|
|
107
|
+
return make(1 / rate, 1 / (rate * rate), Math.LN2 / rate, 0, 2, 6);
|
|
108
|
+
}
|
|
109
|
+
case "gamma": {
|
|
110
|
+
const k = P.shape ?? NaN;
|
|
111
|
+
const scale = has(P, "scale") ? P.scale : 1 / (P.rate ?? 1);
|
|
112
|
+
if (!(k > 0 && Number.isFinite(k) && scale > 0 && Number.isFinite(scale)))
|
|
113
|
+
return NAN;
|
|
114
|
+
return make(k * scale, k * scale * scale, qgamma(0.5, k, { scale }), k >= 1 ? (k - 1) * scale : 0, 2 / Math.sqrt(k), 6 / k);
|
|
115
|
+
}
|
|
116
|
+
case "chisq": {
|
|
117
|
+
const df = P.df ?? NaN;
|
|
118
|
+
if (!(df > 0 && Number.isFinite(df)))
|
|
119
|
+
return NAN;
|
|
120
|
+
return make(df, 2 * df, qchisq(0.5, df), Math.max(df - 2, 0), Math.sqrt(8 / df), 12 / df);
|
|
121
|
+
}
|
|
122
|
+
case "beta": {
|
|
123
|
+
const a = P.shape1 ?? NaN;
|
|
124
|
+
const b = P.shape2 ?? NaN;
|
|
125
|
+
if (!(a > 0 && b > 0 && Number.isFinite(a) && Number.isFinite(b)))
|
|
126
|
+
return NAN;
|
|
127
|
+
const s = a + b;
|
|
128
|
+
let mode;
|
|
129
|
+
if (a > 1 && b > 1)
|
|
130
|
+
mode = (a - 1) / (s - 2);
|
|
131
|
+
else if ((a === 1 && b === 1) || (a < 1 && b < 1))
|
|
132
|
+
mode = NaN;
|
|
133
|
+
else
|
|
134
|
+
mode = a <= 1 && b >= 1 ? 0 : 1;
|
|
135
|
+
return make(a / s, (a * b) / (s * s * (s + 1)), qbeta(0.5, a, b), mode, (2 * (b - a) * Math.sqrt(s + 1)) / ((s + 2) * Math.sqrt(a * b)), (6 * ((a - b) ** 2 * (s + 1) - a * b * (s + 2))) / (a * b * (s + 2) * (s + 3)));
|
|
136
|
+
}
|
|
137
|
+
case "t": {
|
|
138
|
+
const df = P.df ?? NaN;
|
|
139
|
+
if (!(df > 0))
|
|
140
|
+
return NAN;
|
|
141
|
+
const variance = df > 2 ? (df === Infinity ? 1 : df / (df - 2)) : df > 1 ? Infinity : NaN;
|
|
142
|
+
const kurtosis = df > 4 ? (df === Infinity ? 0 : 6 / (df - 4)) : df > 2 ? Infinity : NaN;
|
|
143
|
+
return make(df > 1 ? 0 : NaN, variance, 0, 0, df > 3 ? 0 : NaN, kurtosis);
|
|
144
|
+
}
|
|
145
|
+
case "f": {
|
|
146
|
+
const d1 = P.df1 ?? NaN;
|
|
147
|
+
const d2 = P.df2 ?? NaN;
|
|
148
|
+
if (!(d1 > 0 && d2 > 0 && Number.isFinite(d1) && Number.isFinite(d2)))
|
|
149
|
+
return NAN;
|
|
150
|
+
const mean = d2 > 2 ? d2 / (d2 - 2) : NaN;
|
|
151
|
+
const variance = d2 > 4 ? (2 * d2 * d2 * (d1 + d2 - 2)) / (d1 * (d2 - 2) ** 2 * (d2 - 4)) : d2 > 2 ? Infinity : NaN;
|
|
152
|
+
const skewness = d2 > 6 ? ((2 * d1 + d2 - 2) * Math.sqrt(8 * (d2 - 4))) / ((d2 - 6) * Math.sqrt(d1 * (d1 + d2 - 2))) : NaN;
|
|
153
|
+
const kurtosis = d2 > 8
|
|
154
|
+
? (12 * (d1 * (5 * d2 - 22) * (d1 + d2 - 2) + (d2 - 4) * (d2 - 2) ** 2)) / (d1 * (d2 - 6) * (d2 - 8) * (d1 + d2 - 2))
|
|
155
|
+
: NaN;
|
|
156
|
+
return make(mean, variance, qf(0.5, d1, d2), d1 > 2 ? ((d1 - 2) / d1) * (d2 / (d2 + 2)) : 0, skewness, kurtosis);
|
|
157
|
+
}
|
|
158
|
+
case "cauchy": {
|
|
159
|
+
const { location = 0, scale = 1 } = P;
|
|
160
|
+
if (!(Number.isFinite(location) && scale > 0 && Number.isFinite(scale)))
|
|
161
|
+
return NAN;
|
|
162
|
+
return make(NaN, NaN, location, location, NaN, NaN);
|
|
163
|
+
}
|
|
164
|
+
case "weibull": {
|
|
165
|
+
const k = P.shape ?? NaN;
|
|
166
|
+
const lam = P.scale ?? 1;
|
|
167
|
+
if (!(k > 0 && Number.isFinite(k) && lam > 0 && Number.isFinite(lam)))
|
|
168
|
+
return NAN;
|
|
169
|
+
const mean = gammaFn(1 + 1 / k);
|
|
170
|
+
const s = shape((x) => dweibull1(x, k, 1, false), mean, 0, Infinity);
|
|
171
|
+
return make(lam * mean, lam * lam * s.variance, qweibull(0.5, k, { scale: lam }), k > 1 ? lam * Math.pow((k - 1) / k, 1 / k) : 0, s.skewness, s.kurtosis);
|
|
172
|
+
}
|
|
173
|
+
case "logis": {
|
|
174
|
+
const { location = 0, scale = 1 } = P;
|
|
175
|
+
if (!(Number.isFinite(location) && scale > 0 && Number.isFinite(scale)))
|
|
176
|
+
return NAN;
|
|
177
|
+
return make(location, (scale * scale * Math.PI * Math.PI) / 3, location, location, 0, 1.2);
|
|
178
|
+
}
|
|
179
|
+
case "binom": {
|
|
180
|
+
const n = P.size ?? NaN;
|
|
181
|
+
const p = P.prob ?? NaN;
|
|
182
|
+
if (!(Number.isInteger(n) && n >= 0 && p >= 0 && p <= 1))
|
|
183
|
+
return NAN;
|
|
184
|
+
const q = 1 - p;
|
|
185
|
+
// P(x) >= P(x - 1) exactly when x <= (n + 1) p
|
|
186
|
+
return make(n * p, n * p * q, qbinom(0.5, n, p), Math.min(n, floorProduct(n + 1, p)), (q - p) / Math.sqrt(n * p * q), (1 - 6 * p * q) / (n * p * q));
|
|
187
|
+
}
|
|
188
|
+
case "pois": {
|
|
189
|
+
const lambda = P.lambda ?? NaN;
|
|
190
|
+
if (!(lambda > 0 && Number.isFinite(lambda)))
|
|
191
|
+
return NAN;
|
|
192
|
+
return make(lambda, lambda, qpois(0.5, lambda), Math.floor(lambda), 1 / Math.sqrt(lambda), 1 / lambda);
|
|
193
|
+
}
|
|
194
|
+
case "geom": {
|
|
195
|
+
const p = P.prob ?? NaN;
|
|
196
|
+
if (!(p > 0 && p <= 1))
|
|
197
|
+
return NAN;
|
|
198
|
+
const q = 1 - p;
|
|
199
|
+
return make(q / p, q / (p * p), qgeom(0.5, p), 0, (2 - p) / Math.sqrt(q), 6 + (p * p) / q);
|
|
200
|
+
}
|
|
201
|
+
case "nbinom": {
|
|
202
|
+
const r = P.size ?? NaN;
|
|
203
|
+
if (!(r > 0 && Number.isFinite(r)))
|
|
204
|
+
return NAN;
|
|
205
|
+
const p = has(P, "mu") ? r / (r + P.mu) : (P.prob ?? NaN);
|
|
206
|
+
if (!(p > 0 && p <= 1))
|
|
207
|
+
return NAN;
|
|
208
|
+
const q = 1 - p;
|
|
209
|
+
const opts = has(P, "mu") ? { mu: P.mu } : { prob: p };
|
|
210
|
+
// P(x) >= P(x - 1) exactly when x p <= (r - 1)(1 - p), i.e. (x + r - 1) p <= r - 1 (with mu: x r <= (r - 1) mu)
|
|
211
|
+
const ok = (x) => has(P, "mu") ? productAtMost([x, 0], r, (r - 1) * P.mu) : productAtMost(ddAdd([r - 1, 0], [x, 0]), p, r - 1);
|
|
212
|
+
let mode = 0;
|
|
213
|
+
if (r > 1) {
|
|
214
|
+
mode = Math.max(0, Math.floor(((r - 1) * q) / p) - 1);
|
|
215
|
+
while (ok(mode + 1))
|
|
216
|
+
mode++;
|
|
217
|
+
while (mode > 0 && !ok(mode))
|
|
218
|
+
mode--;
|
|
219
|
+
}
|
|
220
|
+
return make((r * q) / p, (r * q) / (p * p), qnbinom(0.5, r, opts), mode, (2 - p) / Math.sqrt(r * q), 6 / r + (p * p) / (r * q));
|
|
221
|
+
}
|
|
222
|
+
case "hyper": {
|
|
223
|
+
const m = P.m ?? NaN;
|
|
224
|
+
const n = P.n ?? NaN;
|
|
225
|
+
const k = P.k ?? NaN;
|
|
226
|
+
if (!([m, n, k].every((v) => Number.isInteger(v) && v >= 0) && k <= m + n))
|
|
227
|
+
return NAN;
|
|
228
|
+
const N = m + n;
|
|
229
|
+
const mo = Math.floor(((k + 1) * (m + 1)) / (N + 2));
|
|
230
|
+
const kurt = ((N - 1) * N * N * (N * (N + 1) - 6 * m * n - 6 * k * (N - k)) + 6 * k * m * n * (N - k) * (5 * N - 6)) /
|
|
231
|
+
(k * m * n * (N - k) * (N - 2) * (N - 3));
|
|
232
|
+
return make((k * m) / N, (((k * m) / N) * (n / N) * (N - k)) / (N - 1), qhyper(0.5, m, n, k), mo, ((N - 2 * m) * Math.sqrt(N - 1) * (N - 2 * k)) / (Math.sqrt(k * m * n * (N - k)) * (N - 2)), kurt);
|
|
233
|
+
}
|
|
234
|
+
case "invgamma": {
|
|
235
|
+
const a = P.alpha ?? NaN;
|
|
236
|
+
const b = P.beta ?? 1;
|
|
237
|
+
if (!(a > 0 && Number.isFinite(a) && b > 0 && Number.isFinite(b)))
|
|
238
|
+
return NAN;
|
|
239
|
+
return make(a > 1 ? b / (a - 1) : Infinity, a > 2 ? (b * b) / ((a - 1) ** 2 * (a - 2)) : a > 1 ? Infinity : NaN, qinvgamma(0.5, a, { beta: b }), b / (a + 1), a > 3 ? (4 * Math.sqrt(a - 2)) / (a - 3) : NaN, a > 4 ? (30 * a - 66) / ((a - 3) * (a - 4)) : NaN);
|
|
240
|
+
}
|
|
241
|
+
case "kumar": {
|
|
242
|
+
const a = P.a ?? NaN;
|
|
243
|
+
const b = P.b ?? NaN;
|
|
244
|
+
if (!(a > 0 && b > 0 && Number.isFinite(a) && Number.isFinite(b)))
|
|
245
|
+
return NAN;
|
|
246
|
+
// mean b B(1 + 1/a, b)
|
|
247
|
+
const mean = b * Math.exp(lbeta(1 + 1 / a, b));
|
|
248
|
+
// over the density, or over u = F(x) when the density diverges at 1 (b < 1: there the quantile is smooth)
|
|
249
|
+
const s = b < 1
|
|
250
|
+
? central((u) => qkumar1(u, a, b, true, false), () => 1, mean, pkumar1(mean, a, b, true, false), 0, 1)
|
|
251
|
+
: shape((x) => dkumar1(x, a, b, false), mean, 0, 1);
|
|
252
|
+
let mode;
|
|
253
|
+
if (a >= 1 && b >= 1)
|
|
254
|
+
mode = a === 1 && b === 1 ? NaN : Math.pow((a - 1) / (a * b - 1), 1 / a);
|
|
255
|
+
else if (a < 1 && b < 1)
|
|
256
|
+
mode = NaN;
|
|
257
|
+
else
|
|
258
|
+
mode = a < 1 ? 0 : 1;
|
|
259
|
+
return make(mean, s.variance, qkumar(0.5, a, b), mode, s.skewness, s.kurtosis);
|
|
260
|
+
}
|
|
261
|
+
case "pareto": {
|
|
262
|
+
const { a = 1, b = 1 } = P;
|
|
263
|
+
if (!(a > 0 && Number.isFinite(a) && b > 0 && Number.isFinite(b)))
|
|
264
|
+
return NAN;
|
|
265
|
+
return make(a > 1 ? (a * b) / (a - 1) : Infinity, a > 2 ? (b * b * a) / ((a - 1) ** 2 * (a - 2)) : a > 1 ? Infinity : NaN, b * Math.pow(2, 1 / a), b, a > 3 ? ((2 * (1 + a)) / (a - 3)) * Math.sqrt((a - 2) / a) : NaN, a > 4 ? (6 * (a ** 3 + a * a - 6 * a - 2)) / (a * (a - 3) * (a - 4)) : NaN);
|
|
266
|
+
}
|
|
267
|
+
case "triang": {
|
|
268
|
+
const { a = -1, b = 1 } = P;
|
|
269
|
+
const c = P.c ?? (a + b) / 2;
|
|
270
|
+
if (!(Number.isFinite(a) && Number.isFinite(b) && a < b && a <= c && c <= b))
|
|
271
|
+
return NAN;
|
|
272
|
+
const q = a * a + b * b + c * c - a * b - a * c - b * c;
|
|
273
|
+
return make((a + b + c) / 3, q / 18, qtriang(0.5, { a, b, c }), c, (Math.SQRT2 * (a + b - 2 * c) * (2 * a - b - c) * (a - 2 * b + c)) / (5 * q ** 1.5), -0.6);
|
|
274
|
+
}
|
|
275
|
+
case "laplace": {
|
|
276
|
+
const { mu = 0, sigma = 1 } = P;
|
|
277
|
+
if (!(Number.isFinite(mu) && sigma > 0 && Number.isFinite(sigma)))
|
|
278
|
+
return NAN;
|
|
279
|
+
return make(mu, 2 * sigma * sigma, mu, mu, 0, 3);
|
|
280
|
+
}
|
|
281
|
+
case "arcsine": {
|
|
282
|
+
const { a = 0, b = 1 } = P;
|
|
283
|
+
if (!(Number.isFinite(a) && Number.isFinite(b) && a < b))
|
|
284
|
+
return NAN;
|
|
285
|
+
return make(a + (b - a) / 2, (b - a) ** 2 / 8, qarcsine(0.5, { a, b }), NaN, 0, -1.5);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
throw new RangeError(`unknown distribution '${String(distribution)}'`);
|
|
289
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Vectorizable, type VectorResult } from "../internal/vectorize.js";
|
|
2
|
+
import { type DensityOptions, type TailOptions } from "../internal/dpq.js";
|
|
3
|
+
/** Limits and mode of the triangular distribution. */
|
|
4
|
+
export interface TriangParams {
|
|
5
|
+
/** Minimum. Default `-1`. */
|
|
6
|
+
a?: number;
|
|
7
|
+
/** Maximum. Default `1`. */
|
|
8
|
+
b?: number;
|
|
9
|
+
/** Mode. Default `(a + b) / 2`. */
|
|
10
|
+
c?: number;
|
|
11
|
+
}
|
|
12
|
+
export declare function dtriang1(x: number, a: number, b: number, c: number, log: boolean): number;
|
|
13
|
+
export declare function ptriang1(q: number, a: number, b: number, c: number, lowerTail: boolean, logP: boolean): number;
|
|
14
|
+
export declare function qtriang1(p: number, a: number, b: number, c: number, lowerTail: boolean, logP: boolean): number;
|
|
15
|
+
/**
|
|
16
|
+
* Density of the triangular distribution. Equivalent to `extraDistr::dtriang(x, a = -1, b = 1, c = (a + b)/2, log = FALSE)`.
|
|
17
|
+
*
|
|
18
|
+
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
19
|
+
* @param options - `a`, `b` and `c` (see {@link TriangParams}) and `log` (see {@link DensityOptions}).
|
|
20
|
+
*/
|
|
21
|
+
export declare function dtriang<T extends Vectorizable>(x: T, options?: TriangParams & DensityOptions): VectorResult<T>;
|
|
22
|
+
/** Distribution function of the triangular distribution. Equivalent to `extraDistr::ptriang(q, a, b, c, lower.tail, log.p)`. */
|
|
23
|
+
export declare function ptriang<T extends Vectorizable>(q: T, options?: TriangParams & TailOptions): VectorResult<T>;
|
|
24
|
+
/** Quantile function of the triangular distribution. Equivalent to `extraDistr::qtriang(p, a, b, c, lower.tail, log.p)`. */
|
|
25
|
+
export declare function qtriang<T extends Vectorizable>(p: T, options?: TriangParams & TailOptions): VectorResult<T>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// Triangular distribution dtriang / ptriang / qtriang (extraDistr's names: minimum a, maximum b, mode c).
|
|
2
|
+
//
|
|
3
|
+
// Written for rStats.js (no ported code). With w = b - a:
|
|
4
|
+
// f(x) = 2 (x - a) / (w (c - a)) left of c, 2 (b - x) / (w (b - c)) right of it;
|
|
5
|
+
// P[X <= x] = (x - a)^2 / (w (c - a)) left of c, P[X > x] = (b - x)^2 / (w (b - c)) right of it.
|
|
6
|
+
// Each tail is computed from its own end, and the quantile from the tail it falls in.
|
|
7
|
+
import { vectorize } from "../internal/vectorize.js";
|
|
8
|
+
import { d0, dt0, dt1, quantileBoundaries } from "../internal/dpq.js";
|
|
9
|
+
const valid = (a, b, c) => Number.isFinite(a) && Number.isFinite(b) && a < b && a <= c && c <= b;
|
|
10
|
+
export function dtriang1(x, a, b, c, log) {
|
|
11
|
+
if (Number.isNaN(x) || !valid(a, b, c))
|
|
12
|
+
return NaN;
|
|
13
|
+
if (x < a || x > b)
|
|
14
|
+
return d0(log);
|
|
15
|
+
const w = b - a;
|
|
16
|
+
if (x === c)
|
|
17
|
+
return log ? Math.log(2 / w) : 2 / w;
|
|
18
|
+
// the density is (2 / w) (1 - r), r the fraction of the way from the mode to the end on x's side; near the mode
|
|
19
|
+
// 1 - r from r (x - c is exact there), elsewhere from the distance to the end
|
|
20
|
+
const r = x < c ? (c - x) / (c - a) : (x - c) / (b - c);
|
|
21
|
+
if (r < 0.5)
|
|
22
|
+
return log ? Math.log(2 / w) + Math.log1p(-r) : (2 / w) * (1 - r);
|
|
23
|
+
const d = x < c ? (2 * (x - a)) / (w * (c - a)) : (2 * (b - x)) / (w * (b - c));
|
|
24
|
+
return log ? Math.log(d) : d;
|
|
25
|
+
}
|
|
26
|
+
export function ptriang1(q, a, b, c, lowerTail, logP) {
|
|
27
|
+
if (Number.isNaN(q) || !valid(a, b, c))
|
|
28
|
+
return NaN;
|
|
29
|
+
if (q <= a)
|
|
30
|
+
return dt0(lowerTail, logP);
|
|
31
|
+
if (q >= b)
|
|
32
|
+
return dt1(lowerTail, logP);
|
|
33
|
+
const w = b - a;
|
|
34
|
+
// the far tail as a sum of positive terms: 1 - (q - a)^2 / (w (c - a)) = (b - c) / w + (c - q)(q + c - 2a) / (w (c - a))
|
|
35
|
+
let lower;
|
|
36
|
+
let upper;
|
|
37
|
+
if (q <= c) {
|
|
38
|
+
lower = ((q - a) * (q - a)) / (w * (c - a));
|
|
39
|
+
upper = (b - c) / w + ((c - q) * (q - a + (c - a))) / (w * (c - a));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
upper = ((b - q) * (b - q)) / (w * (b - c));
|
|
43
|
+
lower = (c - a) / w + ((q - c) * (b - q + (b - c))) / (w * (b - c));
|
|
44
|
+
}
|
|
45
|
+
const v = lowerTail ? lower : upper;
|
|
46
|
+
if (!logP)
|
|
47
|
+
return v;
|
|
48
|
+
// the log of a probability above 1/2 from the other tail
|
|
49
|
+
return v > 0.5 ? Math.log1p(-(lowerTail ? upper : lower)) : Math.log(v);
|
|
50
|
+
}
|
|
51
|
+
export function qtriang1(p, a, b, c, lowerTail, logP) {
|
|
52
|
+
if (Number.isNaN(p) || !valid(a, b, c))
|
|
53
|
+
return NaN;
|
|
54
|
+
const bd = quantileBoundaries(p, a, b, lowerTail, logP);
|
|
55
|
+
if (bd !== undefined)
|
|
56
|
+
return bd;
|
|
57
|
+
const w = b - a;
|
|
58
|
+
const pv = logP ? Math.exp(p) : p;
|
|
59
|
+
const lower = lowerTail ? pv : logP ? -Math.expm1(p) : 1 - p;
|
|
60
|
+
const upper = lowerTail ? (logP ? -Math.expm1(p) : 1 - p) : pv;
|
|
61
|
+
if (lower <= (c - a) / w)
|
|
62
|
+
return a + Math.sqrt(lower * w * (c - a));
|
|
63
|
+
return b - Math.sqrt(upper * w * (b - c));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Density of the triangular distribution. Equivalent to `extraDistr::dtriang(x, a = -1, b = 1, c = (a + b)/2, log = FALSE)`.
|
|
67
|
+
*
|
|
68
|
+
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
69
|
+
* @param options - `a`, `b` and `c` (see {@link TriangParams}) and `log` (see {@link DensityOptions}).
|
|
70
|
+
*/
|
|
71
|
+
export function dtriang(x, options = {}) {
|
|
72
|
+
const { a = -1, b = 1, log = false } = options;
|
|
73
|
+
const c = options.c ?? (a + b) / 2;
|
|
74
|
+
return vectorize(x, (v) => dtriang1(v, a, b, c, log));
|
|
75
|
+
}
|
|
76
|
+
/** Distribution function of the triangular distribution. Equivalent to `extraDistr::ptriang(q, a, b, c, lower.tail, log.p)`. */
|
|
77
|
+
export function ptriang(q, options = {}) {
|
|
78
|
+
const { a = -1, b = 1, lowerTail = true, logP = false } = options;
|
|
79
|
+
const c = options.c ?? (a + b) / 2;
|
|
80
|
+
return vectorize(q, (v) => ptriang1(v, a, b, c, lowerTail, logP));
|
|
81
|
+
}
|
|
82
|
+
/** Quantile function of the triangular distribution. Equivalent to `extraDistr::qtriang(p, a, b, c, lower.tail, log.p)`. */
|
|
83
|
+
export function qtriang(p, options = {}) {
|
|
84
|
+
const { a = -1, b = 1, lowerTail = true, logP = false } = options;
|
|
85
|
+
const c = options.c ?? (a + b) / 2;
|
|
86
|
+
return vectorize(p, (v) => qtriang1(v, a, b, c, lowerTail, logP));
|
|
87
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! rStats.js 0.7.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
|
|
2
|
+
import{A as sr,D as he,E as de,F as dt,I as an,J as ge,K as ye,L as Nr,O as Fe,P as qe,Q as Ie,T as we,U as ve,V as ke,W as Re,X as Ae,Y as Ge,Z as Ue,a as Pr,aa as je,b as Z,c as Qt,d as it,e as fe,f as se,g as er,h as tn,i as rn,j as nn,k as en,m as on,n as un,o as ae,p as Ne,q as ir,t as ce,u as me,v as or,w as ur,x as fr,y as pe,z as le}from"./chunks/chunk-6R7YDHA2.js";import{a as g,b as mn,c as De,d as pn,e as _e,f as Qe,g as Oe,h as Be,i as Xe,j as Ce}from"./chunks/chunk-AFKYWGKN.js";import{a as F,b as S,c as M,d as y,e as Jr,h as sn,m as Me,n as be,o as xe,p as Se,q as Ee,r as Le,s as b,t as cn,u as ut,v as K}from"./chunks/chunk-PTPPP4TI.js";import{a as cr,b as Nn}from"./chunks/chunk-ZYA4ISAT.js";import{a as ar,b as L,c as Mt,d as D,e as _,f as Ot,g as ot}from"./chunks/chunk-BI5RSUZ2.js";import{a as ht}from"./chunks/chunk-YKN6OGJL.js";import{C as fn,d as _t,e as m,f as ue,g as lt,h as et,l as Wr,s as z,u as Zr}from"./chunks/chunk-ANYGLFT4.js";import{b as C,d as O,f as nt,g as J,h as Dt,i as j,k as V}from"./chunks/chunk-ZW52Z3GY.js";function Ve(r,n,i={}){let{log:t=!1,ncp:e}=i;return e!==void 0?m(r,o=>tn(o,n,e,t)):m(r,o=>Z(o,n/2,2,t))}function ze(r,n,i={}){let{lowerTail:t=!0,logP:e=!1,ncp:o}=i;return o!==void 0?m(r,u=>rn(u,n,o,t,e)):m(r,u=>Qt(u,n/2,2,t,e))}function mr(r,n,i={}){let{lowerTail:t=!0,logP:e=!1,ncp:o}=i;return o!==void 0?m(r,u=>nn(u,n,o,t,e)):m(r,u=>it(u,n/2,2,t,e))}function Ke(r,n,i={}){let t=i.log??!1,e=n.length;if(r.length!==e)throw new RangeError("x and prob must have the same length");if(n.some(a=>!Number.isFinite(a)||a<0))throw new RangeError("probabilities must be finite and non-negative");if(!n.some(a=>a>0))throw new RangeError("probabilities must not all be 0");if(r.some(a=>!(a>=0)||!Number.isFinite(a)||a!==Math.round(a)))throw new RangeError("x must be non-negative integers");let o=r.reduce((a,c)=>a+c,0);if(i.size!==void 0&&i.size!==o)throw new RangeError("size must equal the sum of x");for(let a=0;a<e;a++)if(n[a]===0&&r[a]>0)return t?-1/0:0;let u=new Array(e+1).fill([0,0]),f=new Array(e+1).fill(0);for(let a=e-1;a>=0;a--)u[a]=O(u[a+1],[n[a],0]),f[a]=f[a+1]+r[a];let s=0,N=1;for(let a=0;a<e;a++){if(n[a]===0)continue;let c=u[a+1];if(c[0]===0)break;let p=j([n[a],0],u[a]),l=j(c,u[a]),h=r[a],d=f[a+1];t?s+=z(h,d,p,l,!0):N*=z(h,d,p,l,!1)}return t?s:N}function pr(r,n){return Number.isFinite(n-r)?1:.5}function Te(r,n,i,t){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(!(i>n))return NaN;if(r<n||r>i)return M(t);let e=pr(n,i),o=i*e-n*e;return t?-Math.log(o)+Math.log(e):e/o}function Ye(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(i<n||!Number.isFinite(n)||!Number.isFinite(i))return NaN;if(r>=i)return S(t,e);if(r<=n)return F(t,e);let o=pr(n,i),u=i*o-n*o,f=t?(r*o-n*o)/u:(i*o-r*o)/u;return e?Math.log(f):f}function $e(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(i<n||!Number.isFinite(n)||!Number.isFinite(i))return NaN;let o=y(r,n,i,t,e);if(Number.isNaN(o))return NaN;if(i===n)return n;if(o!==void 0)return o;let u;return e?u=t?Math.exp(r):-Math.expm1(r):u=t?r:.5-r+.5,pr(n,i)!==1?(1-u)*n+u*i:n+u*(i-n)}function He(r,n={}){let{min:i=0,max:t=1,log:e=!1}=n;return m(r,o=>Te(o,i,t,e))}function Je(r,n={}){let{min:i=0,max:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>Ye(u,i,t,e,o))}function We(r,n={}){let{min:i=0,max:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>$e(u,i,t,e,o))}function Ze(r,n,i){if(Number.isNaN(r)||Number.isNaN(n))return NaN;if(n<0||n===1/0)return NaN;if(r<0)return M(i);let t=Mt(n,r);return Number.isNaN(t[0])?NaN:i?Math.log(n)-t[0]-t[1]:n*D(t)}function Pe(r,n,i){if(!n)return i?-r[0]-r[1]:D(r);let t=r[0]+r[1];return i?Ot(r):-Math.expm1(-t)}function ti(r,n,i,t){if(Number.isNaN(r)||Number.isNaN(n))return NaN;if(n<0)return NaN;if(r<=0)return F(i,t);let e=Mt(n,r);return Number.isNaN(e[0])?NaN:e[0]===1/0?S(i,t):Pe(e,i,t)}function ri(r,n,i,t){if(Number.isNaN(r)||Number.isNaN(n))return NaN;if(n<0)return NaN;let e=y(r,0,1/0,i,t);if(Number.isNaN(e)||e===0)return e;let o;return t?o=i?_(r):r:o=i?Math.log1p(-r):Math.log(r),-o/n}function ni(r,n={}){let{rate:i=1,log:t=!1}=n;return m(r,e=>Ze(e,i,t))}function ei(r,n={}){let{rate:i=1,lowerTail:t=!0,logP:e=!1}=n;return m(r,o=>ti(o,i,t,e))}function ii(r,n={}){let{rate:i=1,lowerTail:t=!0,logP:e=!1}=n;return m(r,o=>ri(o,i,t,e))}var oi=.9189385332046728,ui=.3989422804014327;function hn(r,n,i){let t=nt(V([r,0]),[n,0]);if(i===1)return t;let e=t[0]/i;return Number.isFinite(e)&&Math.abs(e)<1e300?j(t,[i,0]):[e,0]}function Bt(r){if(Math.abs(r[0])>1e150)return[r[0]*r[0]/2,0];let n=J(r,r);return[n[0]/2,n[1]/2]}function fi(r,n){if(r[0]>-Math.SQRT2){if(r[0]<Math.SQRT2)return lt(r[0]+r[1],{logP:n});let i=ln(r[0],[r[0],r[1]],!1);return n?Math.log1p(-i):1-i}return ln(-r[0],[-r[0],-r[1]],n)}function ln(r,n,i){let t=.5*_t(r*Math.SQRT1_2),e=Bt(n);return i?Math.log(t)-e[0]-e[1]:t*D(e)}var lr=2.5066282746310007;function si(r,n,i,t){let e=i?r:-r,o,u=(f,s,N)=>-s[0]-N[0]+(-s[1]-N[1])+Math.log(f);if(e<=-Math.SQRT2){let f=.5*_t(-e*Math.SQRT1_2),s=t?[n,0]:V([n,0]);o=-u(f,Bt([-e,0]),s)*lr*f}else if(e>=Math.SQRT2){let f=.5*_t(e*Math.SQRT1_2),s=t?-Math.expm1(n):1-n;o=u(f,Bt([e,0]),V([s,0]))*lr*f}else{let f=lt(e),s=Math.exp(-e*e/2)/lr;o=((t?Math.exp(n):n)-f)/s}return Number.isFinite(o)?C(r,i?o:-o):[r,0]}function ai(r,n,i,t){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(i<0)return NaN;if(r<=0)return M(t);if(i===0)return Math.log(r)===n?1/0:M(t);if(!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(i)){let u=(Math.log(r)-n)/i;return Number.isNaN(u)?NaN:M(t)}let e=hn(r,n,i),o=Bt(e);return t?-(oi+o[0]+o[1]+Math.log(i)+Math.log(r)):ui*D(o)/i/r}function Ni(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(i<0)return NaN;if(r<=0)return F(t,e);if(i===0||!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(i))return lt(Math.log(r),{mean:n,sd:i,lowerTail:t,logP:e});let o=hn(r,n,i);return fi(t?o:[-o[0],-o[1]],e)}function ci(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;let o=et(r,{lowerTail:t,logP:e});if(!Number.isFinite(o)||!(i>0)||!Number.isFinite(i)||!Number.isFinite(n))return Math.exp(et(r,{mean:n,sd:i,lowerTail:t,logP:e}));let u=si(o,r,t,e),f=O(O(Mt(i,u[0]),[i*u[1],0]),[n,0]);return Math.exp(f[0])*(1+f[1])}function mi(r,n={}){let{meanlog:i=0,sdlog:t=1,log:e=!1}=n;return m(r,o=>ai(o,i,t,e))}function pi(r,n={}){let{meanlog:i=0,sdlog:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>Ni(u,i,t,e,o))}function li(r,n={}){let{meanlog:i=0,sdlog:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>ci(u,i,t,e,o))}function hi(r,n,i,t){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(!(i>0))return NaN;let e=L(r,n,i);if(Number.isNaN(e[0]))return NaN;let o=e[0]<0?[-e[0],-e[1]]:[e[0],e[1]],u=D(o);return t?-o[0]-o[1]-Math.log(i)-2*Math.log1p(u):u/(i*(1+u)*(1+u))}function di(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(!(i>0))return NaN;let o=L(r,n,i);if(Number.isNaN(o[0]))return NaN;let u=o[0]<0?[-o[0],-o[1]]:[o[0],o[1]],f=D(u);return t===o[0]>=0?e?-Math.log1p(f):1/(1+f):e?-u[0]-u[1]-Math.log1p(f):f/(1+f)}function Mi(r,n){return n?r-_(r):r<.25?Math.log(r/(1-r)):Math.log1p((2*r-1)/(1-r))}function bi(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;let o=y(r,-1/0,1/0,t,e);if(o!==void 0)return o;if(i<0)return NaN;if(i===0)return n;let u=Mi(r,e);return ot(n,i,t?u:-u)}function xi(r,n={}){let{location:i=0,scale:t=1,log:e=!1}=n;return m(r,o=>hi(o,i,t,e))}function gi(r,n={}){let{location:i=0,scale:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>di(u,i,t,e,o))}function yi(r,n={}){let{location:i=0,scale:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>bi(u,i,t,e,o))}var hr=1.1447298858494002;function Fi(r,n,i,t){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(!(i>0))return NaN;let e=(r-n)/i;if(Number.isNaN(e))return NaN;let o=Math.abs(e);if(o<=1)return t?-(hr+Math.log(i))-Math.log1p(e*e):1/(Math.PI*i*(1+e*e));let u=1/o;return t?-(hr+Math.log(i))-2*Math.log(o)-Math.log1p(u*u):u/(Math.PI*i)*(u/(1+u*u))}function qi(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(!(i>0))return NaN;let o=r-n;if(Number.isNaN(o))return NaN;if(!(Math.abs(o)>i)){let N=o/i,a=.5+Math.atan(t?N:-N)/Math.PI;return e?Math.log(a):a}let u=i/Math.abs(o),f=Math.atan(u)/Math.PI;return t===o<0?e?u<1e-150?Math.log(i)-Math.log(Math.abs(o))-hr:Math.log(f):f:e?Math.log1p(-f):1-f}var Ii=1e-200,wi=-460;function dn(r,n,i){if(!i)return r/n/Math.PI;let t=Math.exp(-n/2);return t*(r/Math.PI)*t}function Xt(r){return r<=.25?-1/Math.tan(Math.PI*r):-Math.tan(Math.PI*(.5-r))}function vi(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(e?r>0:r<0||r>1)return NaN;if(!(i>0)||!Number.isFinite(i))return i===0?n:NaN;let o;if(e)if(r===0)o=1/0;else if(r===-1/0)o=-1/0;else{if(r<wi)return n+(t?-1:1)*dn(i,r,!0);o=r<-Math.LN2?Xt(Math.exp(r)):-Xt(-Math.expm1(r))}else if(r===0)o=-1/0;else if(r===1)o=1/0;else{if(r<Ii)return n+(t?-1:1)*dn(i,r,!1);o=r<=.5?Xt(r):-Xt(1-r)}return ot(n,i,t?o:-o)}function ki(r,n={}){let{location:i=0,scale:t=1,log:e=!1}=n;return m(r,o=>Fi(o,i,t,e))}function Ri(r,n={}){let{location:i=0,scale:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>qi(u,i,t,e,o))}function Ai(r,n={}){let{location:i=0,scale:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>vi(u,i,t,e,o))}function dr(r,n){return r===1?1:Math.pow(r,n)}function Mn(r,n){return V(n===1?[r,0]:L(r,0,n))}function bn(...r){return r.every(Number.isFinite)}function Mr(r,n,i,t){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(!(n>0)||!(i>0))return NaN;if(r<0||r===1/0)return M(t);if(r===0&&n<1)return 1/0;if(!bn(n,i)){let f=dr(r/i,n-1),s=f*(r/i);return t?-s+Math.log(n*f/i):n*f*Math.exp(-s)/i}if(r===0)return n>1?M(t):t?-Math.log(i):1/i;let e=Mn(r,i),o=ar(Dt(e,n));if(o[0]===1/0)return M(t);let u=nt(n===1?[0,0]:Dt(e,n-1),o);return t?Math.log(n/i)+u[0]+u[1]:n/i*Math.exp(u[0])*(1+u[1])}function Si(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(!(n>0)||!(i>0))return NaN;if(r<=0)return F(t,e);let o;if(bn(r,n,i))o=ar(Dt(Mn(r,i),n));else if(o=[dr(r/i,n),0],Number.isNaN(o[0]))return NaN;if(!t)return e?-o[0]-o[1]:D(o);let u=o[0]+o[1];return e?Ot(o):-Math.expm1(-u)}function Ei(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(!(n>0)||!(i>0))return NaN;let o=y(r,0,1/0,t,e);if(o!==void 0)return o;let u;return e?u=t?_(r):r:u=t?Math.log1p(-r):Math.log(r),i*dr(-u,1/n)}function Li(r,n,i={}){let{scale:t=1,log:e=!1}=i;return m(r,o=>Mr(o,n,t,e))}function Di(r,n,i={}){let{scale:t=1,lowerTail:e=!0,logP:o=!1}=i;return m(r,u=>Si(u,n,t,e,o))}function br(r,n,i={}){let{scale:t=1,lowerTail:e=!0,logP:o=!1}=i;return m(r,u=>Ei(u,n,t,e,o))}function Ct(r){return r<=.5?{pd:[r,0],qd:C(1,-r)}:{pd:C(1,-(1-r)),qd:[1-r,0]}}function gr(r){return!(r>0)||r>1}function _i(r,n,i){if(Number.isNaN(r)||Number.isNaN(n))return NaN;if(gr(n))return NaN;if(ht(r)||r<0||!Number.isFinite(r))return M(i);let t=Math.round(r),{pd:e,qd:o}=Ct(n),u=z(0,t,e,o,i);return i?Math.log(n)+u:n*u}function xr(r,n,i){let{pd:t,qd:e}=Ct(n);return z(0,r+1,t,e,i)}function Qi(r,n,i,t){if(!i)return xr(r,n,t);let e=xr(r,n,!0);return t?e<-Math.LN2?Math.log1p(-xr(r,n,!1)):Math.log(-Math.expm1(e)):-Math.expm1(e)}function Oi(r,n,i,t){return Number.isNaN(r)||Number.isNaN(n)?NaN:gr(n)?NaN:r<0?F(i,t):!Number.isFinite(r)||n===1?S(i,t):Qi(Math.floor(r+1e-7),n,i,t)}function Bi(r,n,i,t){if(Number.isNaN(r)||Number.isNaN(n))return NaN;if(gr(n))return NaN;let e=y(r,0,1/0,i,t);if(Number.isNaN(e))return NaN;if(n===1)return 0;if(e!==void 0)return e;let o;return t?o=i?_(r):r:o=i?Math.log1p(-r):Math.log(r),Math.max(0,Math.ceil(o/Math.log1p(-n)-1-1e-12))}function Xi(r,n,i={}){let t=i.log??!1;return m(r,e=>_i(e,n,t))}function Ci(r,n,i={}){let{lowerTail:t=!0,logP:e=!1}=i;return m(r,o=>Oi(o,n,t,e))}function yr(r,n,i={}){let{lowerTail:t=!0,logP:e=!1}=i;return m(r,o=>Bi(o,n,t,e))}function Fr(r,n){let i=C(r,n);return{size:r,pd:j([r,0],i),qd:j([n,0],i)}}function qr(r,n){return{size:r,...Ct(n)}}function Ir(r,n,i){let{size:t,pd:e,qd:o}=n,u=z(t,r,e,o,i);if(r===0)return u;let f=t/(t+r);return i?u+Math.log(f):u*f}function bt(r,n,i,t){let e=Gi(r,n);return e!==void 0?i?t?Math.log1p(-e):1-e:t?Math.log(e):e:sn(n.size,r+1,n.pd,n.qd,i,t)}function Gi(r,n){let{size:i,pd:t,qd:e}=n,o=e[0]+e[1],u=t[0]+t[1];if(!(i<=1)||!(o>=.95)||u<1e-4)return;let f=r+1,s=i,N=z(f,s,e,t,!1)*s/(f+s);if(!(N>1e-290))return;let a=C(f,s),c=[1,0],p=[1,0];for(let l=0;l<1e6;l++){let h=j(O(a,[l,0]),[f+1+l,0]);if(c=J(J(c,h),e),p=O(p,c),c[0]<1e-18*p[0]){let d=N*(p[0]+p[1]);return d<=.5?d:void 0}}}function xn(r,n,i,t){let e=n.pd[0]+n.pd[1],o=1/e,u=(n.qd[0]+n.qd[1])*o,f=n.size*u,s=Math.sqrt(n.size*u*o),N=(o+u)/s,a;if(e<.05)a=it(r,n.size,1,i,t)/Math.log1p(e/(n.qd[0]+n.qd[1]));else{let p=et(r,{lowerTail:i,logP:t});a=f+s*(p+N*(p*p-1)/6)}let c=Number.isFinite(a)?Math.max(a,0):Number.isFinite(f)?f:0;return c>1e4&&(c=Ui(c,r,n,i,t)),en({p:r,lowerTail:i,logP:t,cdf:(p,l,h)=>bt(p,n,l,h),y0:c,lo:0,hi:1/0})}function Ui(r,n,i,t,e){let o=Number.EPSILON,u=n;e?u=t?n*(1+2*o):n*(1-2*o):t?u=n*(1-8*o):1-n>32*o&&(u=n*(1+8*o));let f=e?u:Math.log(u),s=f<=-Math.LN2?t:!t,N=f<=-Math.LN2?f:e?Math.log(-Math.expm1(u)):Math.log1p(-u),a=r,c=bt(a,i,s,!0)-N,p=NaN,l=NaN;for(let h=0;h<8&&c!==0;h++){let d;if(Number.isNaN(p)||c===l){let k=(s?1:-1)*Math.exp(Ir(a,i,!0)-(c+N));d=a-c/k}else d=a-c*(a-p)/(c-l);if(!Number.isFinite(d)||d<=0)break;if(Math.abs(d-a)<.5)return d;p=a,l=c,a=d,c=bt(a,i,s,!0)-N}return a}function ji(r,n,i,t){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(n<0||!(i>0)||i>1)return NaN;if(ht(r)||r<0||!Number.isFinite(r))return M(t);let e=Math.round(r);return n===0||i===1?e===0?t?0:1:M(t):n===1/0?M(t):Ir(e,qr(n,i),t)}function Vi(r,n,i,t,e){return Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i)?NaN:n<0||!(i>0)||i>1||n===1/0?NaN:r<0?F(t,e):n===0||i===1||!Number.isFinite(r)?S(t,e):bt(Math.floor(r+1e-7),qr(n,i),t,e)}function zi(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(n<0||i<0||i>1)return NaN;if(i===1||n===0)return 0;if(i===0)return NaN;let o=y(r,0,1/0,t,e);return o!==void 0?o:n===1/0?1/0:xn(r,qr(n,i),t,e)}function Ki(r,n,i,t){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(n<0||i<0)return NaN;if(ht(r)||r<0||!Number.isFinite(r))return M(t);let e=Math.round(r);return n===0?e===0?t?0:1:i===0?NaN:M(t):i===1/0?M(t):n===1/0?Zr(e,i,t):i===0?e===0?t?0:1:M(t):Ir(e,Fr(n,i),t)}function Ti(r,n,i,t,e){return Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i)?NaN:n<0||i<0||i===1/0?NaN:r<0?F(t,e):n===0||i===0||!Number.isFinite(r)?S(t,e):n===1/0?on(r,i,t,e):bt(Math.floor(r+1e-7),Fr(n,i),t,e)}function Yi(r,n,i,t,e){if(Number.isNaN(r)||Number.isNaN(n)||Number.isNaN(i))return NaN;if(n===1/0)return un(r,i,t,e);if(n===0||i===0)return 0;if(n<0||i<0)return NaN;if(i===1/0)return y(r,0,1/0,t,e)??NaN;let o=y(r,0,1/0,t,e);return o!==void 0?o:xn(r,Fr(n,i),t,e)}function wr(r){let{prob:n,mu:i}=r;if(n!==void 0&&i!==void 0)throw new TypeError("specify exactly one of prob and mu");if(n!==void 0)return{kind:"prob",v:n};if(i!==void 0)return{kind:"mu",v:i};throw new TypeError("specify exactly one of prob and mu")}function $i(r,n,i){let t=i.log??!1,e=wr(i);return e.kind==="prob"?m(r,o=>ji(o,n,e.v,t)):m(r,o=>Ki(o,n,e.v,t))}function Hi(r,n,i){let{lowerTail:t=!0,logP:e=!1}=i,o=wr(i);return o.kind==="prob"?m(r,u=>Vi(u,n,o.v,t,e)):m(r,u=>Ti(u,n,o.v,t,e))}function vr(r,n,i){let{lowerTail:t=!0,logP:e=!1}=i,o=wr(i);return o.kind==="prob"?m(r,u=>zi(u,n,o.v,t,e)):m(r,u=>Yi(u,n,o.v,t,e))}var kr=(r,n)=>r>0&&n>0&&Number.isFinite(n);function Ji(r,n,i,t){if(Number.isNaN(r)||!kr(n,i))return NaN;if(r<=0||r===1/0)return M(t);if(n===1/0)return NaN;let[e,o]=L(i,0,r);if(e===1/0)return M(t);let u=Number.isFinite(o)?(n/e-1)*o:0;return t?Z(e,n,1,!0)+Math.log(e)-Math.log(r)+u:Z(e,n,1,!1)*e/r*(1+u)}function Wi(r,n,i,t,e){if(Number.isNaN(r)||!kr(n,i))return NaN;if(r<=0)return F(t,e);if(r===1/0||n===1/0)return S(t,e);let[o,u]=L(i,0,r),f=Qt(o,n,1,!t,e);if(!(u!==0&&Number.isFinite(u)&&Number.isFinite(o)))return f;let s=t?-1:1;if(!e)return f+s*Z(o,n,1,!1)*u;let N=s*Math.exp(Z(o,n,1,!0)-f)*u;return Number.isFinite(N)?f+N:f}function Zi(r,n,i,t,e){if(Number.isNaN(r)||!kr(n,i))return NaN;let o=y(r,0,1/0,t,e);return o!==void 0?o:n===1/0?0:i/it(r,n,1,!t,e)}function Pi(r,n,i={}){let{beta:t=1,log:e=!1}=i;return m(r,o=>Ji(o,n,t,e))}function to(r,n,i={}){let{beta:t=1,lowerTail:e=!0,logP:o=!1}=i;return m(r,u=>Wi(u,n,t,e,o))}function Rr(r,n,i={}){let{beta:t=1,lowerTail:e=!0,logP:o=!1}=i;return m(r,u=>Zi(u,n,t,e,o))}var Sr=(r,n)=>r>0&&n>0&&Number.isFinite(n);function gn(r,n){let i=Math.pow(r,n);return i<.5?Math.log1p(-i):Math.log(-Math.expm1(n*Math.log(r)))}function Ar(r,n,i){let t=Math.pow(r,n);if(t>=.5)return Math.pow(-Math.expm1(n*Math.log(r)),i);let e=1-t,o=1-e-t;return Math.pow(e,i)*(1+i*o/e)}var ro=(r,n)=>r===0?0:r*Math.log(n);function Er(r,n,i,t){if(Number.isNaN(r)||!Sr(n,i))return NaN;if(r<0||r>1)return M(t);if(n===1/0)return r===1?1/0:M(t);let e=r===1?-1/0:gn(r,n),o=Math.log(n)+Math.log(i)+ro(n-1,r)+(i===1?0:(i-1)*e);if(t)return o;let u=Math.pow(r,n),f=n*i*(n===1?1:u>1e-290?u/r:Math.pow(r,n-1))*(i===1||r===0?1:Ar(r,n,i-1));return f>22250738585072014e-324&&f<1/0?f:Math.exp(o)}function Lr(r,n,i,t,e){if(Number.isNaN(r)||!Sr(n,i))return NaN;if(r<=0)return F(t,e);if(r>=1)return S(t,e);if(n===1/0)return F(t,e);let o=i*gn(r,n);if(!t)return e?o:Ar(r,n,i);if(!e)return-Math.expm1(o);let u=Math.pow(r,n);return u<1e-20?Math.log(i)+n*Math.log(r)+Math.log1p(-(i-1)*u/2):o<-Math.LN2?Math.log1p(-Ar(r,n,i)):_(o)}function xt(r,n,i,t,e){if(Number.isNaN(r)||!Sr(n,i))return NaN;let o=y(r,0,1,t,e);if(o!==void 0)return o;if(n===1/0)return 1;let u=t?e?_(r):Math.log1p(-r):e?r:Math.log(r);return Math.pow(-Math.expm1(u/i),1/n)}function no(r,n,i,t={}){let{log:e=!1}=t;return m(r,o=>Er(o,n,i,e))}function eo(r,n,i,t={}){let{lowerTail:e=!0,logP:o=!1}=t;return m(r,u=>Lr(u,n,i,e,o))}function Dr(r,n,i,t={}){let{lowerTail:e=!0,logP:o=!1}=t;return m(r,u=>xt(u,n,i,e,o))}var _r=(r,n)=>r>0&&n>0&&Number.isFinite(n);function io(r,n,i,t){if(Number.isNaN(r)||!_r(n,i))return NaN;if(r<i||r===1/0)return M(t);if(n===1/0)return r===i?1/0:M(t);let[e,o]=L(r,0,i),u=Number.isFinite(o)?o/e:0;if(t)return Math.log(n/i)-(n+1)*(Math.log(e)+u);let f=n/i*Math.pow(e,-n)/e;return f>0&&f<1/0?f*(1-(n+1)*u):Math.exp(Math.log(n/i)-(n+1)*(Math.log(e)+u))}function oo(r,n,i,t,e){if(Number.isNaN(r)||!_r(n,i))return NaN;if(r<=i)return F(t,e);if(r===1/0||n===1/0)return S(t,e);let[o,u]=L(r,0,i),f=Number.isFinite(u)?u/o:0,s=-n*(Math.log(o)+f);if(!t){if(e)return s;let N=Math.pow(o,-n);return N>0?N*(1-n*f):Math.exp(s)}return e?s<-Math.LN2?Math.log1p(-Math.pow(o,-n)*(1-n*f)):_(s):-Math.expm1(s)}function Qr(r,n,i,t,e){if(Number.isNaN(r)||!_r(n,i))return NaN;let o=y(r,i,1/0,t,e);if(o!==void 0)return o;if(n===1/0)return i;let u=t?e?_(r):Math.log1p(-r):e?r:Math.log(r);return i*Math.exp(-u/n)}function uo(r,n={}){let{a:i=1,b:t=1,log:e=!1}=n;return m(r,o=>io(o,i,t,e))}function fo(r,n={}){let{a:i=1,b:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>oo(u,i,t,e,o))}function so(r,n={}){let{a:i=1,b:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>Qr(u,i,t,e,o))}var Or=(r,n,i)=>Number.isFinite(r)&&Number.isFinite(n)&&r<n&&r<=i&&i<=n;function ao(r,n,i,t,e){if(Number.isNaN(r)||!Or(n,i,t))return NaN;if(r<n||r>i)return M(e);let o=i-n;if(r===t)return e?Math.log(2/o):2/o;let u=r<t?(t-r)/(t-n):(r-t)/(i-t);if(u<.5)return e?Math.log(2/o)+Math.log1p(-u):2/o*(1-u);let f=r<t?2*(r-n)/(o*(t-n)):2*(i-r)/(o*(i-t));return e?Math.log(f):f}function No(r,n,i,t,e,o){if(Number.isNaN(r)||!Or(n,i,t))return NaN;if(r<=n)return F(e,o);if(r>=i)return S(e,o);let u=i-n,f,s;r<=t?(f=(r-n)*(r-n)/(u*(t-n)),s=(i-t)/u+(t-r)*(r-n+(t-n))/(u*(t-n))):(s=(i-r)*(i-r)/(u*(i-t)),f=(t-n)/u+(r-t)*(i-r+(i-t))/(u*(i-t)));let N=e?f:s;return o?N>.5?Math.log1p(-(e?s:f)):Math.log(N):N}function co(r,n,i,t,e,o){if(Number.isNaN(r)||!Or(n,i,t))return NaN;let u=y(r,n,i,e,o);if(u!==void 0)return u;let f=i-n,s=o?Math.exp(r):r,N=e?s:o?-Math.expm1(r):1-r,a=e?o?-Math.expm1(r):1-r:s;return N<=(t-n)/f?n+Math.sqrt(N*f*(t-n)):i-Math.sqrt(a*f*(i-t))}function mo(r,n={}){let{a:i=-1,b:t=1,log:e=!1}=n,o=n.c??(i+t)/2;return m(r,u=>ao(u,i,t,o,e))}function po(r,n={}){let{a:i=-1,b:t=1,lowerTail:e=!0,logP:o=!1}=n,u=n.c??(i+t)/2;return m(r,f=>No(f,i,t,u,e,o))}function Br(r,n={}){let{a:i=-1,b:t=1,lowerTail:e=!0,logP:o=!1}=n,u=n.c??(i+t)/2;return m(r,f=>co(f,i,t,u,e,o))}var Xr=(r,n)=>!Number.isNaN(r)&&n>0&&Number.isFinite(n);function lo(r,n,i,t){if(Number.isNaN(r)||!Xr(n,i))return NaN;if(!Number.isFinite(n))return t?-1/0:0;let e=L(r,n,i),o=e[0]<0?[-e[0],-e[1]]:[e[0],e[1]];return t?-o[0]-o[1]-Math.log(2*i):D(o)/(2*i)}function ho(r,n,i,t,e){if(Number.isNaN(r)||!Xr(n,i))return NaN;if(!Number.isFinite(n)){let s=n===1/0?0:1,N=t?s:1-s;return e?Math.log(N):N}let o=L(r,n,i),u=o[0]<0?[-o[0],-o[1]]:[o[0],o[1]],f=D(u)/2;return t===o[0]<0?e?-u[0]-u[1]-Math.LN2:f:e?Math.log1p(-f):1-f}function Mo(r,n,i,t,e){if(Number.isNaN(r)||!Xr(n,i))return NaN;let o=y(r,-1/0,1/0,t,e);if(o!==void 0)return o;if(!Number.isFinite(n))return n;let{lower:u,logTarget:f,linearTarget:s}=Jr(r,t,e),N=s!==void 0?Math.log(2*s):Math.LN2+f;return ot(n,i,u?N:-N)}function bo(r,n={}){let{mu:i=0,sigma:t=1,log:e=!1}=n;return m(r,o=>lo(o,i,t,e))}function xo(r,n={}){let{mu:i=0,sigma:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>ho(u,i,t,e,o))}function go(r,n={}){let{mu:i=0,sigma:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>Mo(u,i,t,e,o))}var Cr=(r,n)=>Number.isFinite(r)&&Number.isFinite(n)&&r<n;function yo(r,n,i,t){if(Number.isNaN(r)||!Cr(n,i))return NaN;if(r<n||r>i)return M(t);if(r===n||r===i)return 1/0;if(!t)return 1/(Math.PI*Math.sqrt(r-n)*Math.sqrt(i-r));let e=O(V(C(r,-n)),V(C(i,-r)));return-yn[0]-.5*e[0]-(yn[1]+.5*e[1])}var yn=[1.1447298858494002,10265951162707826e-33];function Fo(r,n,i,t,e){if(Number.isNaN(r)||!Cr(n,i))return NaN;if(r<=n)return F(t,e);if(r>=i)return S(t,e);let o=i-n;return r-n<=i-r?ur((r-n)/o,.5,.5,t,e):ur((i-r)/o,.5,.5,!t,e)}function Gr(r,n,i,t,e){if(Number.isNaN(r)||!Cr(n,i))return NaN;let o=y(r,n,i,t,e);if(o!==void 0)return o;let u=fr(r,.5,.5,t,e);return u<=.5?n+(i-n)*u:i-(i-n)*fr(r,.5,.5,!t,e)}function qo(r,n={}){let{a:i=0,b:t=1,log:e=!1}=n;return m(r,o=>yo(o,i,t,e))}function Io(r,n={}){let{a:i=0,b:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>Fo(u,i,t,e,o))}function Ur(r,n={}){let{a:i=0,b:t=1,lowerTail:e=!0,logP:o=!1}=n;return m(r,u=>Gr(u,i,t,e,o))}var q={mean:NaN,variance:NaN,sd:NaN,median:NaN,mode:NaN,skewness:NaN,kurtosis:NaN};function w(r,n,i,t,e,o){return{mean:r,variance:n,sd:Math.sqrt(n),median:i,mode:t,skewness:e,kurtosis:o}}function Fn(r,n,i,t){return In(e=>e,r,n,n,i,t)}function In(r,n,i,t,e,o){let u=50*Number.EPSILON,f=[2,3,4].map(N=>{let a=l=>(r(l)-i)**N*n(l),c=cr(a,e,t,0,u,200).result,p=o===1/0?Nn(a,t,1,0,u,200).result:cr(a,t,o,0,u,200).result;return c+p}),s=f[0];return{variance:s,skewness:f[1]/s**1.5,kurtosis:f[2]/(s*s)-3}}function wo(r,n){let[i,t]=J([r,0],[n,0]),e=Math.floor(i);return i===e&&t<0?e-1:e}function qn(r,n,i){let t=nt(J(r,[n,0]),[i,0]);return t[0]+t[1]<=0}var Gt=(r,n)=>r[n]!==void 0;function vo(r,n={}){let i=n;switch(r){case"norm":{let{mean:t=0,sd:e=1}=i;return Number.isFinite(t)&&e>0&&Number.isFinite(e)?w(t,e*e,t,t,0,0):q}case"lnorm":{let{meanlog:t=0,sdlog:e=1}=i;if(!(Number.isFinite(t)&&e>0&&Number.isFinite(e)))return q;let o=e*e,u=Math.expm1(o),f=Math.exp(o);return w(Math.exp(t+o/2),u*Math.exp(2*t+o),Math.exp(t),Math.exp(t-o),(f+2)*Math.sqrt(u),u*(16+u*(15+u*(6+u))))}case"unif":{let{min:t=0,max:e=1}=i;if(!(Number.isFinite(t)&&Number.isFinite(e)&&t<e))return q;let o=t+(e-t)/2;return w(o,(e-t)**2/12,o,NaN,0,-1.2)}case"exp":{let{rate:t=1}=i;return t>0&&Number.isFinite(t)?w(1/t,1/(t*t),Math.LN2/t,0,2,6):q}case"gamma":{let t=i.shape??NaN,e=Gt(i,"scale")?i.scale:1/(i.rate??1);return t>0&&Number.isFinite(t)&&e>0&&Number.isFinite(e)?w(t*e,t*e*e,er(.5,t,{scale:e}),t>=1?(t-1)*e:0,2/Math.sqrt(t),6/t):q}case"chisq":{let t=i.df??NaN;return t>0&&Number.isFinite(t)?w(t,2*t,mr(.5,t),Math.max(t-2,0),Math.sqrt(8/t),12/t):q}case"beta":{let t=i.shape1??NaN,e=i.shape2??NaN;if(!(t>0&&e>0&&Number.isFinite(t)&&Number.isFinite(e)))return q;let o=t+e,u;return t>1&&e>1?u=(t-1)/(o-2):t===1&&e===1||t<1&&e<1?u=NaN:u=t<=1&&e>=1?0:1,w(t/o,t*e/(o*o*(o+1)),sr(.5,t,e),u,2*(e-t)*Math.sqrt(o+1)/((o+2)*Math.sqrt(t*e)),6*((t-e)**2*(o+1)-t*e*(o+2))/(t*e*(o+2)*(o+3)))}case"t":{let t=i.df??NaN;if(!(t>0))return q;let e=t>2?t===1/0?1:t/(t-2):t>1?1/0:NaN,o=t>4?t===1/0?0:6/(t-4):t>2?1/0:NaN;return w(t>1?0:NaN,e,0,0,t>3?0:NaN,o)}case"f":{let t=i.df1??NaN,e=i.df2??NaN;if(!(t>0&&e>0&&Number.isFinite(t)&&Number.isFinite(e)))return q;let o=e>2?e/(e-2):NaN,u=e>4?2*e*e*(t+e-2)/(t*(e-2)**2*(e-4)):e>2?1/0:NaN,f=e>6?(2*t+e-2)*Math.sqrt(8*(e-4))/((e-6)*Math.sqrt(t*(t+e-2))):NaN,s=e>8?12*(t*(5*e-22)*(t+e-2)+(e-4)*(e-2)**2)/(t*(e-6)*(e-8)*(t+e-2)):NaN;return w(o,u,or(.5,t,e),t>2?(t-2)/t*(e/(e+2)):0,f,s)}case"cauchy":{let{location:t=0,scale:e=1}=i;return Number.isFinite(t)&&e>0&&Number.isFinite(e)?w(NaN,NaN,t,t,NaN,NaN):q}case"weibull":{let t=i.shape??NaN,e=i.scale??1;if(!(t>0&&Number.isFinite(t)&&e>0&&Number.isFinite(e)))return q;let o=Wr(1+1/t),u=Fn(f=>Mr(f,t,1,!1),o,0,1/0);return w(e*o,e*e*u.variance,br(.5,t,{scale:e}),t>1?e*Math.pow((t-1)/t,1/t):0,u.skewness,u.kurtosis)}case"logis":{let{location:t=0,scale:e=1}=i;return Number.isFinite(t)&&e>0&&Number.isFinite(e)?w(t,e*e*Math.PI*Math.PI/3,t,t,0,1.2):q}case"binom":{let t=i.size??NaN,e=i.prob??NaN;if(!(Number.isInteger(t)&&t>=0&&e>=0&&e<=1))return q;let o=1-e;return w(t*e,t*e*o,dt(.5,t,e),Math.min(t,wo(t+1,e)),(o-e)/Math.sqrt(t*e*o),(1-6*e*o)/(t*e*o))}case"pois":{let t=i.lambda??NaN;return t>0&&Number.isFinite(t)?w(t,t,ir(.5,t),Math.floor(t),1/Math.sqrt(t),1/t):q}case"geom":{let t=i.prob??NaN;if(!(t>0&&t<=1))return q;let e=1-t;return w(e/t,e/(t*t),yr(.5,t),0,(2-t)/Math.sqrt(e),6+t*t/e)}case"nbinom":{let t=i.size??NaN;if(!(t>0&&Number.isFinite(t)))return q;let e=Gt(i,"mu")?t/(t+i.mu):i.prob??NaN;if(!(e>0&&e<=1))return q;let o=1-e,u=Gt(i,"mu")?{mu:i.mu}:{prob:e},f=N=>Gt(i,"mu")?qn([N,0],t,(t-1)*i.mu):qn(O([t-1,0],[N,0]),e,t-1),s=0;if(t>1){for(s=Math.max(0,Math.floor((t-1)*o/e)-1);f(s+1);)s++;for(;s>0&&!f(s);)s--}return w(t*o/e,t*o/(e*e),vr(.5,t,u),s,(2-e)/Math.sqrt(t*o),6/t+e*e/(t*o))}case"hyper":{let t=i.m??NaN,e=i.n??NaN,o=i.k??NaN;if(!([t,e,o].every(N=>Number.isInteger(N)&&N>=0)&&o<=t+e))return q;let u=t+e,f=Math.floor((o+1)*(t+1)/(u+2)),s=((u-1)*u*u*(u*(u+1)-6*t*e-6*o*(u-o))+6*o*t*e*(u-o)*(5*u-6))/(o*t*e*(u-o)*(u-2)*(u-3));return w(o*t/u,o*t/u*(e/u)*(u-o)/(u-1),Nr(.5,t,e,o),f,(u-2*t)*Math.sqrt(u-1)*(u-2*o)/(Math.sqrt(o*t*e*(u-o))*(u-2)),s)}case"invgamma":{let t=i.alpha??NaN,e=i.beta??1;return t>0&&Number.isFinite(t)&&e>0&&Number.isFinite(e)?w(t>1?e/(t-1):1/0,t>2?e*e/((t-1)**2*(t-2)):t>1?1/0:NaN,Rr(.5,t,{beta:e}),e/(t+1),t>3?4*Math.sqrt(t-2)/(t-3):NaN,t>4?(30*t-66)/((t-3)*(t-4)):NaN):q}case"kumar":{let t=i.a??NaN,e=i.b??NaN;if(!(t>0&&e>0&&Number.isFinite(t)&&Number.isFinite(e)))return q;let o=e*Math.exp(fn(1+1/t,e)),u=e<1?In(s=>xt(s,t,e,!0,!1),()=>1,o,Lr(o,t,e,!0,!1),0,1):Fn(s=>Er(s,t,e,!1),o,0,1),f;return t>=1&&e>=1?f=t===1&&e===1?NaN:Math.pow((t-1)/(t*e-1),1/t):t<1&&e<1?f=NaN:f=t<1?0:1,w(o,u.variance,Dr(.5,t,e),f,u.skewness,u.kurtosis)}case"pareto":{let{a:t=1,b:e=1}=i;return t>0&&Number.isFinite(t)&&e>0&&Number.isFinite(e)?w(t>1?t*e/(t-1):1/0,t>2?e*e*t/((t-1)**2*(t-2)):t>1?1/0:NaN,e*Math.pow(2,1/t),e,t>3?2*(1+t)/(t-3)*Math.sqrt((t-2)/t):NaN,t>4?6*(t**3+t*t-6*t-2)/(t*(t-3)*(t-4)):NaN):q}case"triang":{let{a:t=-1,b:e=1}=i,o=i.c??(t+e)/2;if(!(Number.isFinite(t)&&Number.isFinite(e)&&t<e&&t<=o&&o<=e))return q;let u=t*t+e*e+o*o-t*e-t*o-e*o;return w((t+e+o)/3,u/18,Br(.5,{a:t,b:e,c:o}),o,Math.SQRT2*(t+e-2*o)*(2*t-e-o)*(t-2*e+o)/(5*u**1.5),-.6)}case"laplace":{let{mu:t=0,sigma:e=1}=i;return Number.isFinite(t)&&e>0&&Number.isFinite(e)?w(t,2*e*e,t,t,0,3):q}case"arcsine":{let{a:t=0,b:e=1}=i;return Number.isFinite(t)&&Number.isFinite(e)&&t<e?w(t+(e-t)/2,(e-t)**2/8,Ur(.5,{a:t,b:e}),NaN,0,-1.5):q}}throw new RangeError(`unknown distribution '${String(r)}'`)}var ko=-.5,Ro=.3333333,Ao=-.2500068,So=.2000118,Eo=-.1661269,Lo=.1421878,Do=-.1384794,_o=.125006,Qo=1/7,Oo=1/12,Bo=1/24,wn=.3989422804014327,Xo=[1,1,2,6,24,120,720,5040,40320,362880],T=0,vn=0,kn=new Float64Array(36),Ut=0,Rn=0,jr=0,jt=0,An=0,gt=0,Sn=0,En=0,Ln=0,ft=0,yt=0,Dn=0,_n=0,Qn=0,On=0,Ft=0;function st(r){if(!Number.isFinite(r)||r<0)return NaN;if(r<=0)return 0;let n=r>=10,i=!1;if(!(n&&r===Ut))if(n)i=!0,Ut=r,gt=Math.sqrt(r),Sn=6*r*r,Ln=Math.floor(r-1.1484);else for(r!==Ut&&(Ut=r,vn=Math.max(1,Math.trunc(r)),T=0,jt=An=jr=Math.exp(-r));;){let l=b();if(l<=An)return 0;if(T>0){let h=l>.458?Math.min(T,vn):1;for(let d=h;d<=T;d++)if(l<=kn[d])return d;if(T===35)continue}T++;for(let h=T;h<=35;h++)if(jr*=r/h,jt+=jr,kn[h]=jt,l<=jt)return T=h,h;T=35}let t=-1,e=0,o=0,u=0,f=r+gt*ut();if(f>=0&&(t=Math.floor(f),t>=Ln||(e=t,o=r-e,u=b(),Sn*u>=o*o*o)))return t;(i||r!==Rn)&&(Rn=r,En=wn/gt,ft=Bo/r,yt=.3*ft*ft,Ft=Qo*ft*yt,On=yt-15*Ft,Qn=ft-6*yt+45*Ft,_n=1-ft+3*yt-15*Ft,Dn=.1069/r);let s=0,N=0,a=0,c=0,p=()=>{if(t<10)s=-r,N=Math.pow(r,t)/Xo[t];else{let d=Oo/e;d=d*(1-4.8*d*d);let k=o/e;Math.abs(k)<=.25?s=e*k*k*(((((((_o*k+Do)*k+Lo)*k+Eo)*k+So)*k+Ao)*k+Ro)*k+ko)-d:s=e*Math.log(1+k)-o-d,N=wn/Math.sqrt(e)}let l=(.5-o)/gt,h=l*l;a=-.5*h,c=En*(((Ft*h+On)*h+Qn)*h+_n)};if(f>=0&&(p(),c-u*c<=N*Math.exp(s-a)))return t;for(;;){let l=K();u=2*b()-1;let h=1.8+(u>=0?l:-l);if(h>-.6744&&(t=Math.floor(r+gt*h),e=t,o=r-e,p(),Dn*Math.abs(u)<=N*Math.exp(s+l)-c*Math.exp(a+l)))break}return t}function Co(r,n){return g(r,()=>st(n))}function Go(r,n){return g(r,()=>!Number.isFinite(n)||n<=0||n>1?NaN:st(K()*((1-n)/n)))}function Uo(r,n,i){let{prob:t,mu:e}=i;if(t===void 0==(e===void 0))throw new TypeError("specify exactly one of prob and mu");let o=Number.isFinite(n)?n:Number.MAX_VALUE/2;if(e!==void 0)return g(r,()=>!Number.isFinite(e)||Number.isNaN(n)||n<=0||e<0?NaN:e===0?0:st(Y(o,e/o)));let u=t;return g(r,()=>!Number.isFinite(u)||Number.isNaN(n)||n<=0||u<=0||u>1?NaN:u===1?0:st(Y(o,(1-u)/u)))}var jo=5.656854,Vo=.36787944117144233,zo=.04166669,Ko=.02083148,To=.00801191,Yo=.00144121,$o=-7388e-8,Ho=24511e-8,Jo=2424e-7,Wo=.3333333,Zo=-.250003,Po=.2000062,tu=-.1662921,ru=.1423657,nu=-.1367177,eu=.1233795,Bn=0,Xn=0,Q=0,at=0,Cn=0,Vr=0,qt=0,It=0,Vt=0;function Gn(r){let n=r/(Q+Q);return Math.abs(n)<=.25?Vr+.5*r*r*((((((eu*n+nu)*n+ru)*n+tu)*n+Po)*n+Zo)*n+Wo)*n:Vr-Q*r+.25*r*r+(at+at)*Math.log(1+n)}function Y(r,n){if(Number.isNaN(r)||Number.isNaN(n))return NaN;if(r<=0||n<=0)return n===0||r===0?0:NaN;if(!Number.isFinite(r)||!Number.isFinite(n))return 1/0;if(r<1){let u=1+Vo*r,f;for(;;){let s=u*b();if(s>=1){if(f=-Math.log((u-s)/r),K()>=(1-r)*Math.log(f))break}else if(f=Math.exp(Math.log(s)/r),K()>=f)break}return n*f}r!==Bn&&(Bn=r,at=r-.5,Q=Math.sqrt(at),Cn=jo-Q*12);let i=ut(),t=Q+.5*i,e=t*t;if(i>=0)return n*e;let o=b();if(Cn*o<=i*i*i)return n*e;if(r!==Xn){Xn=r;let u=1/r;Vr=((((((Jo*u+Ho)*u+$o)*u+Yo)*u+To)*u+Ko)*u+zo)*u,r<=3.686?(qt=.463+Q+.178*at,It=1.235,Vt=.195/Q-.079+.16*Q):r<=13.022?(qt=1.654+.0076*at,It=1.68/Q+.275,Vt=.062/Q+.024):(qt=1.77,It=.75,Vt=.1515/Q)}if(t>0){let u=Gn(i);if(Math.log(1-o)<=u)return n*e}for(;;){let u=K();if(o=b(),o=o+o-1,i=o<0?qt-It*u:qt+It*u,i>=-.71874483771719){let f=Gn(i);if(f>0){let s=Math.expm1(f);if(Vt*Math.abs(o)<=s*Math.exp(u-.5*i*i))break}}}return t=Q+.5*i,n*t*t}function iu(r,n,i={}){let t=Pr(i);return g(r,()=>Y(n,t))}function wt(r){return!Number.isFinite(r)||r<0?NaN:Y(r/2,2)}function ou(r,n){if(!Number.isFinite(r)||!Number.isFinite(n)||r<0||n<0)return NaN;if(n===0)return r===0?0:Y(r/2,2);let i=st(n/2);return i>0&&(i=wt(2*i)),r>0&&(i+=Y(r/2,2)),i}function P(r,n,i={}){let{ncp:t}=i;return t===void 0?g(r,()=>wt(n)):g(r,()=>ou(n,t))}function uu(r,n,i={}){let{ncp:t}=i;if(t===void 0)return g(r,()=>Number.isNaN(n)||n<=0?NaN:Number.isFinite(n)?ut()/Math.sqrt(wt(n)/n):ut());if(Number.isNaN(t))return g(r,()=>NaN);let e=g(r,()=>pn(t,1)),o=P(r,n);return e.map((u,f)=>u/Math.sqrt(o[f]/n))}function fu(r,n,i,t={}){let{ncp:e}=t;if(e===void 0)return g(r,()=>{if(Number.isNaN(n)||Number.isNaN(i)||n<=0||i<=0)return NaN;let f=Number.isFinite(n)?wt(n)/n:1,s=Number.isFinite(i)?wt(i)/i:1;return f/s});let o=P(r,n,{ncp:e}),u=P(r,i);return o.map((f,s)=>f/n/(u[s]/i))}var su=1024*Math.LN2,vt=0,Un=0,zr=0,jn=0,Vn=0,zn=-1,Kn=-1;function Kr(r,n){let i=vt*Math.log(r/(1-r));if(i<=su){let t=n*Math.exp(i);return Number.isFinite(t)||(t=Number.MAX_VALUE),[i,t]}return[i,Number.MAX_VALUE]}function au(r,n){if(Number.isNaN(r)||Number.isNaN(n)||r<0||n<0)return NaN;if(!Number.isFinite(r)&&!Number.isFinite(n))return .5;if(r===0&&n===0)return b()<.5?0:1;if(!Number.isFinite(r)||n===0)return 1;if(!Number.isFinite(n)||r===0)return 0;let i=zn===r&&Kn===n;i||(zn=r,Kn=n);let t=Math.min(r,n),e=Math.max(r,n),o=t+e,u,f;if(t<=1){for(i||(vt=1/t,zr=1+e-t,jn=zr*(.0138889+.0416667*t)/(e*vt-.777778),Vn=.25+(.5+.25/zr)*t);;){let a=b(),c=b(),p;if(a<.5){let l=a*c;if(p=a*l,.25*c+p-l>=jn)continue}else{if(p=a*a*c,p<=.25){[u,f]=Kr(a,e);break}if(p>=Vn)continue}if([u,f]=Kr(a,e),o*(Math.log(o/(t+f))+u)-1.3862944>=Math.log(p))break}return r===t?t/(t+f):f/(t+f)}i||(vt=Math.sqrt((o-2)/(2*t*e-o)),Un=t+1/vt);let s,N;do{let a=b(),c=b();[u,f]=Kr(a,t);let p=a*a*c;s=Un*u-1.3862944;let l=t+s-f;if(l+2.609438>=5*p||(N=Math.log(p),l>N))break}while(s+o*Math.log(o/(e+f))<N);return r!==t?e/(e+f):f/(e+f)}function Nu(r,n,i,t={}){let{ncp:e}=t;if(e===void 0)return g(r,()=>au(n,i));let o=P(r,2*n,{ncp:e}),u=P(r,2*i);return o.map((f,s)=>f/(f+u[s]))}var cu=2147483647,tt=0,kt=0,Nt=0,W=0,zt=0,Kt=0,Tn=0,Yn=0,Rt=0,Tt=0,Yt=0,ct=0,$t=0,Tr=-1,$n=-1,B=0;function Ht(r){let n=r*r;return(13860-(462-(132-(99-140/n)/n)/n)/n)/r/166320}function Jt(r,n){if(!Number.isFinite(r))return NaN;let i=Math.round(r);if(i!==r)return NaN;if(!Number.isFinite(n)||i<0||n<0||n>1)return NaN;if(i===0||n===0)return 0;if(n===1)return i;if(i>=cu)return dt(b(),i,n,{lowerTail:!1});let t=i,e=Math.min(n,1-n),o=1-e,u=t*e,f=e/o,s=f*(t+1),N;if(n!==Tr||t!==$n)if(Tr=n,$n=t,u<30)Yn=mn(o,t),N=!0;else{N=!1,kt=u+e,B=Math.trunc(kt),Nt=u*o,W=Math.trunc(2.195*Math.sqrt(Nt)-4.6*o)+.5,ct=B+.5,Rt=ct-W,$t=ct+W,tt=.134+20.5/(15.3+B);let c=(kt-Rt)/(kt-Rt*e);Tt=c*(1+.5*c),c=($t-kt)/($t*o),Yt=c*(1+.5*c),zt=W*(1+tt+tt),Kt=zt+tt/Tt,Tn=Kt+tt/Yt}else N=u<30;let a;if(N)t:for(;;){a=0;let c=Yn,p=b();for(;;){if(p<c)break t;if(a>110)break;p-=c,a++,c*=s/a-f}}else for(;;){let c=b()*Tn,p=b();if(c<=W){a=Math.trunc(ct-W*p+c);break}if(c<=zt){let h=Rt+(c-W)/tt;if(p=p*tt+1-Math.abs(ct-h)/W,p>1||p<=0)continue;a=Math.trunc(h)}else if(c>Kt){if(a=Math.trunc($t-Math.log(p)/Yt),a>t)continue;p=p*(c-Kt)*Yt}else{if(a=Math.trunc(Rt+Math.log(p)/Tt),a<0)continue;p=p*(c-zt)*Tt}let l=Math.abs(a-B);if(l<=20||l>=Nt/2-1){let h=1;if(B<a)for(let d=B+1;d<=a;d++)h*=s/d-f;else if(B>a)for(let d=a+1;d<=B;d++)h/=s/d-f;if(p<=h)break}else{let h=l/Nt*((l*(l/3+.625)+.1666666666666)/Nt+.5),d=-l*l/(2*Nt),k=Math.log(p);if(k<d-h)break;if(k<=d+h){let rt=a+1,mt=B+1,pt=t+1-B,H=t-a+1;if(k<=ct*Math.log(mt/rt)+(t-B+.5)*Math.log(pt/H)+(a-B)*Math.log(H*e/(rt*o))+Ht(mt)+Ht(pt)+Ht(rt)+Ht(H))break}}}return Tr>.5&&(a=t-a),a}function mu(r,n,i){return g(r,()=>Jt(n,i))}function pu(r,n,i){if(!Number.isFinite(n)||n<0||Math.round(n)!==n)throw new RangeError("size must be a non-negative integer");let t=0;for(let f of i){if(!Number.isFinite(f)||f<0)throw new RangeError("prob must contain non-negative finite numbers");t+=f}if(t===0)throw new RangeError("prob must contain at least one positive value");let e=i.map(f=>f/t),o=e.length,u=()=>{let f=new Array(o).fill(0),s=n,N=1;for(let a=0;a<o-1;a++){if(e[a]){let c=e[a]/N;f[a]=c<1?Jt(s,c):s,s-=f[a]}if(s<=0)return f;N-=e[a]}return f[o-1]=s,f};if(!Number.isFinite(r)||r<0)throw new RangeError("n must be a non-negative finite number");return Array.from({length:Math.trunc(r)},u)}function lu(r,n){return g(r,()=>{if(Number.isNaN(n))return NaN;let i=Math.round(n);if(i<0)return NaN;if(i===0)return 0;let t=0;for(let e=1;e<=i;e++)t+=e*Math.floor(b()+.5);return t})}function hu(r,n,i){return g(r,()=>{if(Number.isNaN(n)||Number.isNaN(i))return NaN;let t=Math.round(n),e=Math.round(i);if(t<0||e<0)return NaN;if(t===0||e===0)return 0;let o=t+e,u=new Int32Array(o);for(let s=0;s<o;s++)u[s]=s;let f=0;for(let s=0;s<e;s++){let N=cn(o);f+=u[N],u[N]=u[--o]}return f-e*(e-1)/2})}var Yr=2147483647,du=.9189385332046728,Mu=.0078,bu=.0034,xu=1e25,gu=57.564627324851145,yu=[0,0,.6931471805599453,1.791759469228055,3.1780538303479458,4.787491742782046,6.579251212010101,8.525161361065415];function I(r){if(r<0)return 0;if(r<=7)return yu[r];let n=r,i=n*n;return(n+.5)*Math.log(n)-n+du+(.0833333333333333-.00277777777777778/i)/n}var Hn=-1,Jn=-1,Wn=-1,E=0,At=0,St=0,x=0,A=0,v=0,$=0,Zn=0,rr=0,Et=0,G=0,U=0,Pn=0,te=0,Wt=0,Zt=0,Pt=0,tr=0,re=0;function Fu(r,n,i){if(!Number.isFinite(r)||!Number.isFinite(n)||!Number.isFinite(i))return NaN;if(r=Math.round(r),n=Math.round(n),i=Math.round(i),r<0||n<0||i<0||i>r+n)return NaN;if(r>=Yr||n>=Yr||i>=Yr)return i===1?Jt(i,r/(r+n)):an(b(),r,n,i,!1,!1);let t=r,e=n,o=i,u,f;t!==Jn||e!==Wn?(u=!0,f=!0):o!==Hn?(u=!1,f=!0):(u=!1,f=!1),u&&(Jn=t,Wn=e,$=t+e,t<=e?(A=t,v=e):(A=e,v=t)),f&&(Hn=o,x=o+o>=$?Math.trunc($-o):o),(u||f)&&(E=Math.trunc((x+1)*(A+1)/($+2)),At=Math.max(0,x-v),St=Math.min(A,x));let s;if(At===St)s=St;else if(E-At<10){if(u||f){let N;x<v?N=I(v)+I(A+v-x)-I(v-x)-I(A+v):N=I(A)+I(x)-I(x-v)-I(A+v),Zn=Math.exp(N+gu)}t:for(;;){s=At;let N=b()*xu,a=Zn;for(;N>a;)if(N-=a,a*=(A-s)*(x-s),s++,a=a/s/(v-x+s),s>St)continue t;break}}else{if(u||f){let a=Math.sqrt(($-x)*x*A*v/($-1)/$/$);Et=Math.trunc(1.5*a)+.5,G=E-Et+.5,U=E+Et+.5,rr=I(E)+I(A-E)+I(x-E)+I(v-x+E),Pn=Math.exp(rr-I(Math.trunc(G))-I(Math.trunc(A-G))-I(Math.trunc(x-G))-I(Math.trunc(v-x+G))),te=Math.exp(rr-I(Math.trunc(U-1))-I(Math.trunc(A-U+1))-I(Math.trunc(x-U+1))-I(Math.trunc(v-x+U-1))),Wt=-Math.log(G*(v-x+G)/(A-G+1)/(x-G+1)),Zt=-Math.log((A-U+1)*(x-U+1)/U/(v-x+U)),Pt=Et+Et,tr=Pt+Pn/Wt,re=tr+te/Zt}let N=0;for(;;){let a=b()*re,c=b();if(++N>=1e4)return NaN;if(a<Pt)s=Math.trunc(G+a);else if(a<=tr){if(s=Math.trunc(G+Math.log(c)/Wt),s<At)continue;c=c*(a-Pt)*Wt}else{if(s=Math.trunc(U-Math.log(c)/Zt),s>St)continue;c=c*(a-tr)*Zt}if(qu(s,c))break}}return o+o>=$?s=t>e?o-e+s:t-s:t>e&&(s=o-s),s}function qu(r,n){if(E<100||r<=50){let X=1;if(E<r)for(let R=E+1;R<=r;R++)X=X*(A-R+1)*(x-R+1)/(v-x+R)/R;else if(E>r)for(let R=r+1;R<=E;R++)X=X*R*(v-x+R)/(A-R+1)/(x-R+1);return n<=X}let i=r,t=i+1,e=i-E,o=A-i+1,u=x-i+1,f=v-x+t,s=-e/t,N=e/o,a=e/u,c=-e/f,p=o*u/(t*f)-1,l=p<0?1+p:1,h=p*(1+p*(-.5+p/3)),d=h-.25*(p*p*p*p)/l,k=E+.5,rt=A-E+.5,mt=x-E+.5,pt=v-x+k,H=X=>X*(1+X*(-.5+X/3)),$r=i*h-E*d+bu+k*H(s)+rt*H(N)+mt*H(a)+pt*H(c),nr=Math.log(n);if(nr>$r)return!1;let Lt=(X,R)=>{let Hr=X*(R*R*R*R);return R<0?Hr/(1+R):Hr},ne=Lt(k,s),ee=Lt(rt,N),ie=Lt(mt,a),oe=Lt(pt,c);return nr<$r-.25*(ne+ee+ie+oe)+(i+E)*(d-h)-Mu?!0:nr<=rr-I(r)-I(A-r)-I(x-r)-I(v-x+r)}function Iu(r,n,i,t){return g(r,()=>Fu(n,i,t))}function wu(r,n,i={}){let{beta:t=1}=i;return g(r,()=>n>0&&t>0&&Number.isFinite(n)&&Number.isFinite(t)?1/Y(n,1/t):NaN)}function vu(r,n,i){return g(r,()=>n>0&&i>0&&Number.isFinite(n)&&Number.isFinite(i)?xt(1-b(),n,i,!0,!1):NaN)}function ku(r,n={}){let{a:i=1,b:t=1}=n;return g(r,()=>i>0&&t>0&&Number.isFinite(i)&&Number.isFinite(t)?Qr(1-b(),i,t,!0,!1):NaN)}function Ru(r,n={}){let{a:i=-1,b:t=1}=n,e=n.c??(i+t)/2;return g(r,()=>{if(!(Number.isFinite(i)&&Number.isFinite(t)&&i<t&&i<=e&&e<=t))return NaN;let o=b(),u=b(),f=(e-i)/(t-i);return i+(t-i)*((1-f)*Math.min(o,u)+f*Math.max(o,u))})}function Au(r,n={}){let{mu:i=0,sigma:t=1}=n;return g(r,()=>{if(!(Number.isFinite(i)&&t>0&&Number.isFinite(t)))return NaN;let e=K(),o=b()>.5?1:-1;return i+t*o*e})}function Su(r,n={}){let{a:i=0,b:t=1}=n;return g(r,()=>Number.isFinite(i)&&Number.isFinite(t)&&i<t?Gr(b(),i,t,!0,!1):NaN)}export{qo as darcsine,pe as dbeta,he as dbinom,ki as dcauchy,Ve as dchisq,ni as dexp,ce as df,fe as dgamma,Xi as dgeom,ge as dhyper,Pi as dinvgamma,vo as distSummary,no as dkumar,bo as dlaplace,mi as dlnorm,xi as dlogis,Ke as dmultinom,$i as dnbinom,ue as dnorm,uo as dpareto,ae as dpois,Fe as dsignrank,Me as dt,mo as dtriang,He as dunif,Li as dweibull,we as dwilcox,Ee as getRandomSeed,Io as parcsine,le as pbeta,de as pbinom,Ri as pcauchy,ze as pchisq,ei as pexp,me as pf,se as pgamma,Ci as pgeom,ye as phyper,to as pinvgamma,eo as pkumar,xo as plaplace,pi as plnorm,gi as plogis,Hi as pnbinom,lt as pnorm,fo as ppareto,Ne as ppois,qe as psignrank,be as pt,po as ptriang,Re as ptukey,Je as punif,Di as pweibull,ve as pwilcox,Ur as qarcsine,sr as qbeta,dt as qbinom,Ai as qcauchy,mr as qchisq,ii as qexp,or as qf,er as qgamma,yr as qgeom,Nr as qhyper,Rr as qinvgamma,Dr as qkumar,go as qlaplace,li as qlnorm,yi as qlogis,vr as qnbinom,et as qnorm,so as qpareto,ir as qpois,Ie as qsignrank,xe as qt,Br as qtriang,Ae as qtukey,We as qunif,br as qweibull,ke as qwilcox,je as r2dtable,Su as rarcsine,Nu as rbeta,mu as rbinom,Xe as rcauchy,P as rchisq,Qe as rexp,fu as rf,iu as rgamma,Go as rgeom,Iu as rhyper,wu as rinvgamma,vu as rkumar,Au as rlaplace,Oe as rlnorm,Be as rlogis,pu as rmultinom,Uo as rnbinom,_e as rnorm,ku as rpareto,Co as rpois,lu as rsignrank,uu as rt,Ru as rtriang,De as runif,Ce as rweibull,hu as rwilcox,Ue as sample,Ge as sampleInt,Le as setRandomSeed,Se as setSeed};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { sum, prod, mean, weightedMean, variance, sd, median, range, cumsum, cumprod, cummax, cummin, diff, type NaRmOptions, type MeanOptions, type DiffOptions, } from "../descriptive/basic.js";
|
|
2
|
+
export { quantile, IQR, fivenum, mad, type QuantileOptions, type MadOptions } from "../descriptive/quantile.js";
|
|
3
|
+
export { rank, type RankOptions, type TiesMethod } from "../descriptive/rank.js";
|
|
4
|
+
export { cov, cor, type CovOptions, type CorUse } from "../descriptive/cov.js";
|
|
5
|
+
export { tabulate, table, unique, cut, findInterval, type TableOptions, type CutOptions, type FindIntervalOptions } from "../descriptive/table.js";
|
|
6
|
+
export { hist, pretty, ecdf, type HistOptions, type HistResult, type PrettyOptions } from "../descriptive/hist.js";
|
|
7
|
+
export { skewness, kurtosis, geometricMean, modes, meanAD, cv, scale, type MomentOptions, type MeanADOptions, type CvOptions, type ScaleOptions, } from "../descriptive/moments.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Descriptive statistics (rStats.js/descriptive): R's summaries of vectors and matrices, with naRm for missing values
|
|
2
|
+
export { sum, prod, mean, weightedMean, variance, sd, median, range, cumsum, cumprod, cummax, cummin, diff, } from "../descriptive/basic.js";
|
|
3
|
+
export { quantile, IQR, fivenum, mad } from "../descriptive/quantile.js";
|
|
4
|
+
export { rank } from "../descriptive/rank.js";
|
|
5
|
+
export { cov, cor } from "../descriptive/cov.js";
|
|
6
|
+
export { tabulate, table, unique, cut, findInterval } from "../descriptive/table.js";
|
|
7
|
+
export { hist, pretty, ecdf } from "../descriptive/hist.js";
|
|
8
|
+
export { skewness, kurtosis, geometricMean, modes, meanAD, cv, scale, } from "../descriptive/moments.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export { dnorm, pnorm, qnorm, type NormalOptions } from "../distributions/normal.js";
|
|
2
|
+
export { dgamma, pgamma, qgamma, type GammaParams } from "../distributions/gamma.js";
|
|
3
|
+
export { dchisq, pchisq, qchisq } from "../distributions/chisq.js";
|
|
4
|
+
export { dpois, ppois, qpois } from "../distributions/poisson.js";
|
|
5
|
+
export { dbeta, pbeta, qbeta } from "../distributions/beta.js";
|
|
6
|
+
export { dbinom, pbinom, qbinom } from "../distributions/binomial.js";
|
|
7
|
+
export { dmultinom, type MultinomialOptions } from "../distributions/multinomial.js";
|
|
8
|
+
export { dt, pt, qt } from "../distributions/t.js";
|
|
9
|
+
export { df, pf, qf } from "../distributions/f.js";
|
|
10
|
+
export { dunif, punif, qunif, type UniformParams } from "../distributions/uniform.js";
|
|
11
|
+
export { dexp, pexp, qexp, type ExponentialParams } from "../distributions/exponential.js";
|
|
12
|
+
export { dlnorm, plnorm, qlnorm, type LognormalParams } from "../distributions/lognormal.js";
|
|
13
|
+
export { dlogis, plogis, qlogis, type LocationScaleParams } from "../distributions/logistic.js";
|
|
14
|
+
export { dcauchy, pcauchy, qcauchy } from "../distributions/cauchy.js";
|
|
15
|
+
export { dweibull, pweibull, qweibull, type WeibullParams } from "../distributions/weibull.js";
|
|
16
|
+
export { dgeom, pgeom, qgeom } from "../distributions/geometric.js";
|
|
17
|
+
export { dnbinom, pnbinom, qnbinom, type NegBinomialParams } from "../distributions/negbinomial.js";
|
|
18
|
+
export { dhyper, phyper, qhyper } from "../distributions/hypergeometric.js";
|
|
19
|
+
export { dsignrank, psignrank, qsignrank } from "../distributions/signrank.js";
|
|
20
|
+
export { dwilcox, pwilcox, qwilcox } from "../distributions/wilcox.js";
|
|
21
|
+
export { ptukey, qtukey, type TukeyOptions } from "../distributions/tukey.js";
|
|
22
|
+
export { dinvgamma, pinvgamma, qinvgamma, type InvgammaParams } from "../distributions/invgamma.js";
|
|
23
|
+
export { dkumar, pkumar, qkumar } from "../distributions/kumaraswamy.js";
|
|
24
|
+
export { dpareto, ppareto, qpareto, type ParetoParams } from "../distributions/pareto.js";
|
|
25
|
+
export { dtriang, ptriang, qtriang, type TriangParams } from "../distributions/triangular.js";
|
|
26
|
+
export { dlaplace, plaplace, qlaplace, type LaplaceParams } from "../distributions/laplace.js";
|
|
27
|
+
export { darcsine, parcsine, qarcsine, type ArcsineParams } from "../distributions/arcsine.js";
|
|
28
|
+
export { distSummary, type DistName, type DistSummary } from "../distributions/summary.js";
|
|
29
|
+
export type { DensityOptions, TailOptions } from "../internal/dpq.js";
|
|
30
|
+
export type { NoncentralOption } from "../internal/noncentral.js";
|
|
31
|
+
export type { Vectorizable, VectorResult } from "../internal/vectorize.js";
|
|
32
|
+
export { setSeed, getRandomSeed, setRandomSeed } from "../random/rng.js";
|
|
33
|
+
export { runif, rnorm, rexp, rlnorm, rlogis, rcauchy, rweibull } from "../random/continuous.js";
|
|
34
|
+
export { rgamma, rchisq, rt, rf } from "../random/gamma.js";
|
|
35
|
+
export { rbeta } from "../random/beta.js";
|
|
36
|
+
export { rpois, rgeom, rnbinom } from "../random/poisson.js";
|
|
37
|
+
export { rbinom, rmultinom } from "../random/binomial.js";
|
|
38
|
+
export { rsignrank, rwilcox } from "../random/rank.js";
|
|
39
|
+
export { sample, sampleInt, type SampleOptions } from "../random/sample.js";
|
|
40
|
+
export { rhyper } from "../random/hyper.js";
|
|
41
|
+
export { r2dtable } from "../random/r2dtable.js";
|
|
42
|
+
export { rinvgamma, rkumar, rpareto, rtriang, rlaplace, rarcsine } from "../random/extra.js";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Probability distributions and random numbers (rStats.js/distributions): d/p/q/r functions with R's names
|
|
2
|
+
export { dnorm, pnorm, qnorm } from "../distributions/normal.js";
|
|
3
|
+
export { dgamma, pgamma, qgamma } from "../distributions/gamma.js";
|
|
4
|
+
export { dchisq, pchisq, qchisq } from "../distributions/chisq.js";
|
|
5
|
+
export { dpois, ppois, qpois } from "../distributions/poisson.js";
|
|
6
|
+
export { dbeta, pbeta, qbeta } from "../distributions/beta.js";
|
|
7
|
+
export { dbinom, pbinom, qbinom } from "../distributions/binomial.js";
|
|
8
|
+
export { dmultinom } from "../distributions/multinomial.js";
|
|
9
|
+
export { dt, pt, qt } from "../distributions/t.js";
|
|
10
|
+
export { df, pf, qf } from "../distributions/f.js";
|
|
11
|
+
export { dunif, punif, qunif } from "../distributions/uniform.js";
|
|
12
|
+
export { dexp, pexp, qexp } from "../distributions/exponential.js";
|
|
13
|
+
export { dlnorm, plnorm, qlnorm } from "../distributions/lognormal.js";
|
|
14
|
+
export { dlogis, plogis, qlogis } from "../distributions/logistic.js";
|
|
15
|
+
export { dcauchy, pcauchy, qcauchy } from "../distributions/cauchy.js";
|
|
16
|
+
export { dweibull, pweibull, qweibull } from "../distributions/weibull.js";
|
|
17
|
+
export { dgeom, pgeom, qgeom } from "../distributions/geometric.js";
|
|
18
|
+
export { dnbinom, pnbinom, qnbinom } from "../distributions/negbinomial.js";
|
|
19
|
+
export { dhyper, phyper, qhyper } from "../distributions/hypergeometric.js";
|
|
20
|
+
export { dsignrank, psignrank, qsignrank } from "../distributions/signrank.js";
|
|
21
|
+
export { dwilcox, pwilcox, qwilcox } from "../distributions/wilcox.js";
|
|
22
|
+
export { ptukey, qtukey } from "../distributions/tukey.js";
|
|
23
|
+
// Distributions outside base R (extraDistr's names and parameters; arcsine as beta(1/2, 1/2) on (a, b))
|
|
24
|
+
export { dinvgamma, pinvgamma, qinvgamma } from "../distributions/invgamma.js";
|
|
25
|
+
export { dkumar, pkumar, qkumar } from "../distributions/kumaraswamy.js";
|
|
26
|
+
export { dpareto, ppareto, qpareto } from "../distributions/pareto.js";
|
|
27
|
+
export { dtriang, ptriang, qtriang } from "../distributions/triangular.js";
|
|
28
|
+
export { dlaplace, plaplace, qlaplace } from "../distributions/laplace.js";
|
|
29
|
+
export { darcsine, parcsine, qarcsine } from "../distributions/arcsine.js";
|
|
30
|
+
export { distSummary } from "../distributions/summary.js";
|
|
31
|
+
// Random numbers (same streams as R's set.seed)
|
|
32
|
+
export { setSeed, getRandomSeed, setRandomSeed } from "../random/rng.js";
|
|
33
|
+
export { runif, rnorm, rexp, rlnorm, rlogis, rcauchy, rweibull } from "../random/continuous.js";
|
|
34
|
+
export { rgamma, rchisq, rt, rf } from "../random/gamma.js";
|
|
35
|
+
export { rbeta } from "../random/beta.js";
|
|
36
|
+
export { rpois, rgeom, rnbinom } from "../random/poisson.js";
|
|
37
|
+
export { rbinom, rmultinom } from "../random/binomial.js";
|
|
38
|
+
export { rsignrank, rwilcox } from "../random/rank.js";
|
|
39
|
+
export { sample, sampleInt } from "../random/sample.js";
|
|
40
|
+
export { rhyper } from "../random/hyper.js";
|
|
41
|
+
export { r2dtable } from "../random/r2dtable.js";
|
|
42
|
+
export { rinvgamma, rkumar, rpareto, rtriang, rlaplace, rarcsine } from "../random/extra.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { crossprod, tcrossprod, backsolve, forwardsolve, type BacksolveOptions } from "../linalg/basic.js";
|
|
2
|
+
export { norm, type NormOptions, type NormType } from "../linalg/norm.js";
|
|
3
|
+
export { chol, chol2inv, type CholOptions, type CholPivotResult, type Chol2InvOptions } from "../linalg/chol.js";
|
|
4
|
+
export { qr, qrQ, qrR, qrX, qrCoef, qrQy, qrQty, qrResid, qrFitted, qrSolve, type QR, type QROptions, type QRQOptions } from "../linalg/qr.js";
|
|
5
|
+
export { solve, det, determinant, rcond, type SolveOptions, type Determinant, type RcondOptions } from "../linalg/solve.js";
|
|
6
|
+
export { svd, type SvdOptions, type SvdResult } from "../linalg/svd.js";
|
|
7
|
+
export { kappa, ginv, type KappaOptions } from "../linalg/kappa.js";
|
|
8
|
+
export { eigen, type EigenOptions, type EigenResult } from "../linalg/eigen.js";
|
|
9
|
+
export type { MatrixInput, VectorOrMatrix } from "../linalg/matrix.js";
|
|
10
|
+
export { matMul, add, subtract, multiply, divide, outer, t, diag, cbind, rbind, matrix, kronecker, seq, type Operand, type DiagOptions, type MatrixOptions, type SeqOptions, } from "../linalg/ops.js";
|
|
11
|
+
export { lu, prcomp, type LuResult, type PrcompOptions, type PrcompResult } from "../linalg/lu.js";
|