@numero-uno-jpn/rstats 0.7.0 → 0.8.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 +74 -0
- package/README.ja.md +17 -11
- package/README.md +17 -11
- package/THIRD_PARTY_NOTICES.md +30 -0
- package/dist/chunks/{chunk-ZYA4ISAT.js → chunk-32PRRONF.js} +1 -1
- package/dist/chunks/chunk-3I6EKGB6.js +2 -0
- package/dist/chunks/{chunk-BI5RSUZ2.js → chunk-EJRCDJ76.js} +2 -2
- package/dist/chunks/{chunk-JCZAB6C5.js → chunk-I3LAZE6C.js} +2 -2
- package/dist/chunks/chunk-JERGQKZM.js +2 -0
- package/dist/chunks/{chunk-UIOAWLAN.js → chunk-JVYV4633.js} +1 -1
- package/dist/chunks/chunk-LXMMKO26.js +2 -0
- package/dist/chunks/{chunk-YKN6OGJL.js → chunk-MJQLKEO5.js} +2 -2
- package/dist/chunks/{chunk-ZW52Z3GY.js → chunk-OHPHNE3O.js} +1 -1
- package/dist/chunks/{chunk-AFKYWGKN.js → chunk-RZ7SBJEG.js} +2 -2
- package/dist/chunks/{chunk-QNQJA6KZ.js → chunk-SPQC445Q.js} +2 -2
- package/dist/chunks/{chunk-SXSJXDD3.js → chunk-U633VFH3.js} +2 -2
- package/dist/chunks/{chunk-MVG5LUZU.js → chunk-VIPSPG3Y.js} +2 -2
- package/dist/chunks/{chunk-J3SNI7KY.js → chunk-XU4BGFZ6.js} +2 -2
- package/dist/chunks/{chunk-XYXHHF5L.js → chunk-YGWPU67I.js} +1 -1
- package/dist/descriptive.js +2 -2
- package/dist/distributions/beta.js +21 -5
- package/dist/distributions.js +2 -2
- package/dist/entries/distributions.d.ts +2 -1
- package/dist/entries/distributions.js +2 -1
- package/dist/entries/tests.d.ts +1 -0
- package/dist/entries/tests.js +1 -0
- package/dist/htest/brunnerMunzelTest.d.ts +28 -0
- package/dist/htest/brunnerMunzelTest.js +86 -0
- package/dist/linalg.js +2 -2
- package/dist/numerics.js +2 -2
- package/dist/random/lecuyer.d.ts +20 -0
- package/dist/random/lecuyer.js +71 -0
- package/dist/random/rng.d.ts +78 -11
- package/dist/random/rng.js +128 -26
- package/dist/random/sample.js +24 -7
- package/dist/random/streams.d.ts +34 -0
- package/dist/random/streams.js +75 -0
- package/dist/rstats.js +3 -3
- package/dist/special/igam.d.ts +1 -0
- package/dist/special/igam.js +1 -1
- package/dist/special/incbet.js +487 -6
- package/dist/special/incbetLargeA.d.ts +15 -0
- package/dist/special/incbetLargeA.js +200 -0
- package/dist/special/incbetTemme.d.ts +19 -0
- package/dist/special/incbetTemme.js +216 -0
- package/dist/special/loader.js +151 -118
- package/dist/special.js +2 -2
- package/dist/tests.js +3 -3
- package/package.json +1 -1
- package/dist/chunks/chunk-6R7YDHA2.js +0 -2
- package/dist/chunks/chunk-ANYGLFT4.js +0 -2
- package/dist/chunks/chunk-PTPPP4TI.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,80 @@ While the version is 0.x, a minor release (0.y.0) may contain breaking changes;
|
|
|
7
7
|
they are listed under **Breaking** for each release. From 1.0.0 the project follows
|
|
8
8
|
[Semantic Versioning](https://semver.org/).
|
|
9
9
|
|
|
10
|
+
## 0.8.0 - 2026-10-25
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `RNGkind({ kind, sampleKind })` (R's `RNGkind()`): the `"L'Ecuyer-CMRG"` generator (L'Ecuyer's
|
|
15
|
+
MRG32k3a) besides R's default Mersenne-Twister, and `sampleKind: "Rounding"`, the `sample` of R
|
|
16
|
+
before 3.6.0 (affects `sample`, `sampleInt` and `rwilcox`), with R's streams after the same seed.
|
|
17
|
+
As in R, changing the kind in the middle of a stream seeds the new generator from the next
|
|
18
|
+
uniform, and the call returns the previous kinds. R's `set.seed(seed, kind, sample.kind)` is
|
|
19
|
+
`RNGkind({ kind, sampleKind })` followed by `setSeed(seed)`.
|
|
20
|
+
- `nextRNGStream` and `nextRNGSubStream` (R's `parallel::nextRNGStream()` and
|
|
21
|
+
`nextRNGSubStream()`): the L'Ecuyer-CMRG state advanced by 2^127 or 2^76 steps, for independent
|
|
22
|
+
streams in parallel work.
|
|
23
|
+
- `getRandomSeed` and `setRandomSeed` handle every supported combination in R's `.Random.seed`
|
|
24
|
+
format (kind code `10403`, `403` with Rounding, `10407` for L'Ecuyer-CMRG with 6 seeds).
|
|
25
|
+
- `brunnerMunzelTest` (`lawstat::brunner.munzel.test()`): the Brunner-Munzel test for the relative
|
|
26
|
+
effect P(X < Y) + P(X = Y)/2 of two samples, with its interval. The interval is set with
|
|
27
|
+
`confLevel` (lawstat's `alpha = 1 - confLevel`); small p-values are computed from the upper tail
|
|
28
|
+
directly, where lawstat's 1 − P loses them. It adds 0.4 KB gzipped to everything (121.8 → 122.2
|
|
29
|
+
KB with the speed-up below).
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- `sampleInt` accepts n up to 4.5e15, as R (before: less than 2^31), when sampling with
|
|
34
|
+
replacement or with a size of at most n / 2 (`sampleInt(1e10, { size: 3 })`); weighted sampling and
|
|
35
|
+
sampling more than half without replacement still need n < 2^31. Uniform integers above 2^47 are
|
|
36
|
+
built from random bits without rounding.
|
|
37
|
+
- Bundle size: `setSeed` with `rnorm` is unchanged (1.7 KB gzipped); `sampleInt` grows from 1.9 to
|
|
38
|
+
2.1 KB and `getRandomSeed` with `setRandomSeed` from 1.0 to 1.5 KB (they read L'Ecuyer-CMRG
|
|
39
|
+
states). The new generator is only included with `RNGkind`, `setRandomSeed` or the stream
|
|
40
|
+
functions. Everything together grows from 119.6 to 120.9 KB.
|
|
41
|
+
|
|
42
|
+
- Speed: the incomplete beta function with both parameters large (ab/(a + b) >= 25, x near the
|
|
43
|
+
mean) uses Temme's uniform asymptotic expansion, in constant time (about 1 µs):
|
|
44
|
+
`pbeta(0.5, 1e6, 1e6)` becomes about 245 times faster and `pbinom(n/2, n, 0.5)` with n = 1e6
|
|
45
|
+
about 170 times. The continued fraction of the incomplete beta function runs without array
|
|
46
|
+
allocations (bit-identical results, about twice as fast), and Loader's deviance, `dbeta` and the
|
|
47
|
+
prefactors leave out double-double steps whose rounding an error bound shows to be negligible.
|
|
48
|
+
On typical inputs (`npm run bench`, Apple M1): `pbeta` 1.6, `dbeta` 2.0, `pt` 1.7, `dbinom` 2.1,
|
|
49
|
+
`pf` 1.7, `qbeta` 1.8 and `qgamma` 1.3 times faster (see [docs/performance.md](docs/performance.md)).
|
|
50
|
+
Accuracy is unchanged: all tests pass with the same tolerances, and new mpmath fixtures cover
|
|
51
|
+
the large-parameter region.
|
|
52
|
+
- Bundle size: the expansion and the allocation-free loop add about 3.6 KB gzipped to everything
|
|
53
|
+
that uses the incomplete beta function (`qbeta` 18.5 → 22.1 KB, `pt` and `qt` 25.5 → 29.4 KB,
|
|
54
|
+
`tTest` 16.7 → 20.3 KB, everything 115.4 → 119.6 KB).
|
|
55
|
+
- Speed: the incomplete beta function with one parameter large and the other small (a >= 15,
|
|
56
|
+
b <= 40, x in the bulk) uses DiDonato and Morris's asymptotic expansion (TOMS 708, eq. 9, in the
|
|
57
|
+
form of Boost.Math's `beta_small_b_large_a_series`) where it used the continued fraction, whose
|
|
58
|
+
length stops growing with a but which took 30 to 170 double-double steps there. This covers `pt`
|
|
59
|
+
and `pf` with large degrees of freedom, `pbeta(x, 1e6, 10)` and `pbinom` with x near 0 or n:
|
|
60
|
+
`pt(1.5, 1e6)` becomes 12 times faster, `pbeta(1 - b/(a + b), 1e10, 0.5)` 31 times,
|
|
61
|
+
`pf(3, 1, 1e5)` 14 times, `pbeta(1 - b/(a + b), 1e6, 10)` 1.4 times, and `pt` over t ~ N(0, 3²)
|
|
62
|
+
takes about the same time for every df from 1e5 to 1e15 (5 to 9 times faster); `qt`, `qbeta`,
|
|
63
|
+
`qf` and `qbinom` there become about 2 times faster (see [docs/performance.md](docs/performance.md)).
|
|
64
|
+
Its cases are within 1.2e-15 of mpmath and Rmpfr references, as the continued fraction was; new
|
|
65
|
+
mpmath fixtures cover a from 15 to 1e10 and b from 0.1 to 40.
|
|
66
|
+
- Bundle size: the expansion adds 0.8 to 1.1 KB gzipped (`pt` and `qt` 29.4 → 30.3 KB, `qbeta`
|
|
67
|
+
22.1 → 23.2 KB, `tTest` 20.3 → 21.4 KB, everything 120.9 → 121.8 KB).
|
|
68
|
+
|
|
69
|
+
### Fixed
|
|
70
|
+
|
|
71
|
+
- Weighted sampling with replacement by Walker's alias method (more than 200 likely candidates)
|
|
72
|
+
compares in the same way as R (t + u against q[t] + t), so that rounding cannot pick a different
|
|
73
|
+
candidate in rare cases.
|
|
74
|
+
- The log of the larger tail of the incomplete beta function for x (or 1 − x) in the subnormal
|
|
75
|
+
range: `pbeta(1e-308, 1, 1e8, lowerTail: false, logP: true)` was off by 4.7e-14, as R's value
|
|
76
|
+
still is (now 1.8e-15).
|
|
77
|
+
- `pt` and `pf` with degrees of freedom above about 1e21 (the continued fraction in the frame of the
|
|
78
|
+
large parameter, now replaced by the expansion for large a): `pt(0.001, 1e22, lowerTail: false)`
|
|
79
|
+
was 1.19 and `pt(0.01, 1e25)` off by 2.6e-4; with degrees of freedom from about 1e153 on, `pt` and
|
|
80
|
+
`pf` returned NaN (`pt(1, 1e160)`, `pf(2, 3, 1e160)`). `pt` now agrees with its normal limit to
|
|
81
|
+
5e-16 for |t| up to 31.6 (beyond, where the tail is below 1e-218, the NaN remains for df from
|
|
82
|
+
1e153 on).
|
|
83
|
+
|
|
10
84
|
## 0.7.0 - 2026-10-25
|
|
11
85
|
|
|
12
86
|
### Added
|
package/README.ja.md
CHANGED
|
@@ -16,7 +16,7 @@ JavaScript とブラウザで使える、R と互換の統計関数のライブ
|
|
|
16
16
|
- **どこでも動きます。** ESM のみで、依存パッケージはなく、Node 専用の API も使っていません。
|
|
17
17
|
tree-shaking が効きます (`pnorm` だけなら gzip で 1.2 KB)。
|
|
18
18
|
|
|
19
|
-
状態: **0.
|
|
19
|
+
状態: **0.8.0。** R の stats パッケージの数値計算の中心
|
|
20
20
|
(分布・記述統計・検定・線形モデル・特殊関数・数値計算・線形代数の基本) を、R と同じ結果でカバーすることを目指しています。残っている作業は
|
|
21
21
|
[ROADMAP.ja.md](ROADMAP.ja.md)、変更履歴は [CHANGELOG.md](CHANGELOG.md) (英語) にあります。
|
|
22
22
|
|
|
@@ -48,11 +48,17 @@ dbinom(3, 10, 0.2); // 0.20132659200000003
|
|
|
48
48
|
### `set.seed()` と同じ乱数
|
|
49
49
|
|
|
50
50
|
```ts
|
|
51
|
-
import { setSeed, rnorm,
|
|
51
|
+
import { setSeed, rnorm, RNGkind, getRandomSeed, setRandomSeed, nextRNGStream, runif } from "@numero-uno-jpn/rstats";
|
|
52
52
|
|
|
53
53
|
setSeed(42);
|
|
54
54
|
rnorm(3); // [1.3709584471466685, -0.5646981713960887, 0.3631284113373392]
|
|
55
55
|
// R: set.seed(42); rnorm(3) gives the same numbers (up to the last bit)
|
|
56
|
+
|
|
57
|
+
// R の既定以外の設定: RNGkind("L'Ecuyer-CMRG") と parallel::nextRNGStream、sample.kind = "Rounding"
|
|
58
|
+
RNGkind({ kind: "L'Ecuyer-CMRG" });
|
|
59
|
+
setSeed(1); // R: set.seed(1, kind = "L'Ecuyer-CMRG")
|
|
60
|
+
setRandomSeed(nextRNGStream(getRandomSeed())); // R: .Random.seed <- nextRNGStream(.Random.seed)
|
|
61
|
+
runif(2); // [0.31369782407981056, 0.9280126525616814]
|
|
56
62
|
```
|
|
57
63
|
|
|
58
64
|
R で `set.seed(42); rnorm(3)` とすると、最後のビットまで同じ数値になります。
|
|
@@ -93,9 +99,9 @@ eigen([[2, 1], [1, 3]]).values; // [3.618033988749895, 1.381966011250105]
|
|
|
93
99
|
|---|---|
|
|
94
100
|
| 特殊関数 | `gamma`, `lgamma`, `beta`, `lbeta`, `choose`, `lchoose`, `factorial`, `lfactorial`, `digamma`, `trigamma`, `psigamma`, `besselI`, `besselK`, `besselJ`, `besselY`。R にはない `erf`, `erfc`, `erfinv`, `erfcinv`, `gammainc`, `perm` と、R の C API (Rmath.h) の `log1pmx`, `lgamma1p`, `log1mexp`, `log1pexp` も |
|
|
95
101
|
| 分布 (d/p/q) | 正規、t、カイ二乗、F、ベータ、ガンマ、二項、ポアソン、一様、指数、対数正規、ロジスティック、コーシー、ワイブル、幾何、負の二項、超幾何、Wilcoxon の符号付き順位と順位和、スチューデント化された範囲 (`ptukey`, `qtukey`)、非心カイ二乗・t・F・ベータ (`ncp`)。多項分布の確率 (`dmultinom`)。逆ガンマ、Kumaraswamy、Pareto、三角、Laplace (extraDistr) と逆正弦。`distSummary` (平均・分散・標準偏差・中央値・最頻値・歪度・尖度) |
|
|
96
|
-
| 乱数 | `setSeed` (`set.seed`), `getRandomSeed`/`setRandomSeed` (`.Random.seed`), 26 個の `r*` 関数, `sample`, `sampleInt` (`sample.int`), `r2dtable` |
|
|
102
|
+
| 乱数 | `setSeed` (`set.seed`), `RNGkind` (Mersenne-Twister と L'Ecuyer-CMRG、`sample.kind` の Rejection と Rounding), `getRandomSeed`/`setRandomSeed` (`.Random.seed`), `nextRNGStream`/`nextRNGSubStream` (`parallel`), 26 個の `r*` 関数, `sample`, `sampleInt` (`sample.int`), `r2dtable` |
|
|
97
103
|
| 記述統計 | `sum`, `prod`, `mean`, `weightedMean` (`weighted.mean`), `variance` (`var`), `sd`, `median`, `range`, `cumsum`, `cumprod`, `cummax`, `cummin`, `diff`, `quantile`, `IQR`, `fivenum`, `mad`, `rank`, `cov`, `cor`, `tabulate`, `table`, `unique`, `cut`, `findInterval`, `pretty`, `hist`, `ecdf`, `scale`, `skewness`, `kurtosis`, `geometricMean`, `modes`, `meanAD`, `cv` |
|
|
98
|
-
| 検定 | `tTest`, `chisqTest`, `fisherTest`, `wilcoxTest`, `corTest`, `binomTest`, `poissonTest`, `propTest`, `mcnemarTest`, `varTest`, `bartlettTest`, `kruskalTest`, `friedmanTest`, `quadeTest`, `flignerTest`, `moodTest`, `onewayTest`, `shapiroTest`, `mantelhaenTest`, `ansariTest`, `ksTest`, `pairwiseTTest`, `pairwiseWilcoxTest`, `pairwisePropTest`, `aov`, `TukeyHSD`, `zTest`, `pAdjust` (`p.adjust`) |
|
|
104
|
+
| 検定 | `tTest`, `chisqTest`, `fisherTest`, `wilcoxTest`, `corTest`, `binomTest`, `poissonTest`, `propTest`, `mcnemarTest`, `varTest`, `bartlettTest`, `kruskalTest`, `friedmanTest`, `quadeTest`, `flignerTest`, `moodTest`, `onewayTest`, `shapiroTest`, `mantelhaenTest`, `ansariTest`, `ksTest`, `pairwiseTTest`, `pairwiseWilcoxTest`, `pairwisePropTest`, `aov`, `TukeyHSD`, `zTest`, `brunnerMunzelTest`, `pAdjust` (`p.adjust`) |
|
|
99
105
|
| 線形モデル | `lm` (行列で渡す形。`summary` の値も返す), `confint`, `predict` |
|
|
100
106
|
| 線形代数 | `matMul` (`%*%`), `add`, `subtract`, `multiply`, `divide`, `outer`, `t`, `diag`, `cbind`, `rbind`, `matrix`, `kronecker`, `seq`, `crossprod`, `tcrossprod`, `norm`, `backsolve`, `forwardsolve`, `chol`, `chol2inv`, `qr` と `qrQ`, `qrR`, `qrX`, `qrCoef`, `qrQy`, `qrQty`, `qrResid`, `qrFitted`, `qrSolve` (`qr.Q` …), `solve`, `det`, `determinant`, `rcond`, `kappa`, `svd`, `eigen`, `lu`, `prcomp`, `ginv` (MASS) |
|
|
101
107
|
| 数値計算 | `integrate`, `optimize`, `uniroot`, `approx`, `spline`, `splinefun`, `splinefunH`, `barylag`, `hermiteInterp`, `ode`, `grad`, `jacobian`, `hessian` |
|
|
@@ -136,9 +142,9 @@ double-double 演算で計算しているためです。詳しくは [docs/ja/ac
|
|
|
136
142
|
| `pnorm` | 1.2 KB |
|
|
137
143
|
| `setSeed`, `rnorm` | 1.7 KB |
|
|
138
144
|
| `solve` / `svd` / `eigen` | 1.7 / 2.0 / 3.7 KB |
|
|
139
|
-
| `wilcoxTest` / `fisherTest` / `tTest` | 8.6 / 15.
|
|
140
|
-
| `qbeta` / `pt` と `qt` |
|
|
141
|
-
| すべて |
|
|
145
|
+
| `wilcoxTest` / `fisherTest` / `tTest` | 8.6 / 15.6 / 21.4 KB |
|
|
146
|
+
| `qbeta` / `pt` と `qt` | 23.2 / 30.3 KB |
|
|
147
|
+
| すべて | 122.2 KB |
|
|
142
148
|
|
|
143
149
|
(`npm run size` で測れます。)
|
|
144
150
|
|
|
@@ -147,12 +153,12 @@ double-double 演算で計算しているためです。詳しくは [docs/ja/ac
|
|
|
147
153
|
`/descriptive`、`/numerics`、`/special` です。
|
|
148
154
|
|
|
149
155
|
バンドラを使わない場合は、1 ファイルにまとめたビルド `dist/rstats.js` (すべての関数を含む minify 済みの
|
|
150
|
-
ES モジュール、gzip で
|
|
156
|
+
ES モジュール、gzip で 119 KB) を jsDelivr から読み込めます。jsDelivr は、このリポジトリのリリースの
|
|
151
157
|
タグをそのまま配信します。
|
|
152
158
|
|
|
153
159
|
```html
|
|
154
160
|
<script type="module">
|
|
155
|
-
import { pnorm } from "https://cdn.jsdelivr.net/gh/numero-uno-jpn/rStats.js@v0.
|
|
161
|
+
import { pnorm } from "https://cdn.jsdelivr.net/gh/numero-uno-jpn/rStats.js@v0.8.0/dist/rstats.js";
|
|
156
162
|
console.log(pnorm(1.96)); // 0.9750021048517795
|
|
157
163
|
</script>
|
|
158
164
|
```
|
|
@@ -161,11 +167,11 @@ ES モジュール、gzip で 115 KB) を jsDelivr から読み込めます。js
|
|
|
161
167
|
`dist/tests.js`、`dist/linalg.js`、`dist/descriptive.js`、`dist/numerics.js`、`dist/special.js` は
|
|
162
168
|
上のサブパスと同じ関数を export し、共通のコードを `dist/chunks/` で共有します。そのため、2 つの分野を
|
|
163
169
|
読み込んでも共通部分は 1 回しか読み込まれません。chunk を含めた 1 分野の転送量は、gzip で 18 KB
|
|
164
|
-
(`numerics`) から
|
|
170
|
+
(`numerics`) から 91 KB (`tests`) です。
|
|
165
171
|
|
|
166
172
|
ビルド結果 (`dist/`) は main ブランチにはなく、リリースのタグにだけ入っています。npm を元にした CDN も
|
|
167
173
|
使えます。たとえば
|
|
168
|
-
`https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.
|
|
174
|
+
`https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.8.0/dist/rstats.js` や
|
|
169
175
|
`https://esm.sh/@numero-uno-jpn/rstats` です。
|
|
170
176
|
|
|
171
177
|
ブラウザ向けのビルドは、headless Chromium でテストしています。バンドラでまとめた場合と、
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ R-compatible statistical functions for JavaScript and the browser, written in Ty
|
|
|
14
14
|
- **Runs anywhere.** ESM only, no dependencies, no Node-specific APIs, tree-shakable
|
|
15
15
|
(`pnorm` alone is 1.2 KB gzipped).
|
|
16
16
|
|
|
17
|
-
Status: **0.
|
|
17
|
+
Status: **0.8.0.** The goal is to cover the numerical core of R's
|
|
18
18
|
`stats` package (distributions, descriptive statistics, hypothesis tests, linear models, special
|
|
19
19
|
functions, numerical methods and the basics of linear algebra) with R-compatible results; see [ROADMAP.md](ROADMAP.md) for what remains. See [CHANGELOG.md](CHANGELOG.md).
|
|
20
20
|
|
|
@@ -47,11 +47,17 @@ Distribution parameters are scalars.
|
|
|
47
47
|
### Random numbers that match `set.seed()`
|
|
48
48
|
|
|
49
49
|
```ts
|
|
50
|
-
import { setSeed, rnorm,
|
|
50
|
+
import { setSeed, rnorm, RNGkind, getRandomSeed, setRandomSeed, nextRNGStream, runif } from "@numero-uno-jpn/rstats";
|
|
51
51
|
|
|
52
52
|
setSeed(42);
|
|
53
53
|
rnorm(3); // [1.3709584471466685, -0.5646981713960887, 0.3631284113373392]
|
|
54
54
|
// R: set.seed(42); rnorm(3) gives the same numbers (up to the last bit)
|
|
55
|
+
|
|
56
|
+
// R's other settings: RNGkind("L'Ecuyer-CMRG") with parallel::nextRNGStream, sample.kind = "Rounding"
|
|
57
|
+
RNGkind({ kind: "L'Ecuyer-CMRG" });
|
|
58
|
+
setSeed(1); // R: set.seed(1, kind = "L'Ecuyer-CMRG")
|
|
59
|
+
setRandomSeed(nextRNGStream(getRandomSeed())); // R: .Random.seed <- nextRNGStream(.Random.seed)
|
|
60
|
+
runif(2); // [0.31369782407981056, 0.9280126525616814]
|
|
55
61
|
```
|
|
56
62
|
|
|
57
63
|
### Hypothesis tests
|
|
@@ -88,9 +94,9 @@ eigen([[2, 1], [1, 3]]).values; // [3.618033988749895, 1.381966011250105]
|
|
|
88
94
|
|---|---|
|
|
89
95
|
| Special functions | `gamma`, `lgamma`, `beta`, `lbeta`, `choose`, `lchoose`, `factorial`, `lfactorial`, `digamma`, `trigamma`, `psigamma`, `besselI`, `besselK`, `besselJ`, `besselY`; also `erf`, `erfc`, `erfinv`, `erfcinv`, `gammainc` and `perm`, which R lacks, and `log1pmx`, `lgamma1p`, `log1mexp`, `log1pexp` from R's C API (Rmath.h) |
|
|
90
96
|
| Distributions (d/p/q) | normal, t, chi-squared, F, beta, gamma, binomial, Poisson, uniform, exponential, log-normal, logistic, Cauchy, Weibull, geometric, negative binomial, hypergeometric, Wilcoxon signed rank and rank sum, studentized range (`ptukey`, `qtukey`), non-central chi-squared, t, F and beta (`ncp`); the multinomial probability (`dmultinom`); inverse gamma, Kumaraswamy, Pareto, triangular, Laplace (extraDistr) and arcsine; `distSummary` (mean, variance, sd, median, mode, skewness, kurtosis) |
|
|
91
|
-
| Random numbers | `setSeed` (`set.seed`), `getRandomSeed`/`setRandomSeed` (`.Random.seed`), 26 `r*` functions, `sample`, `sampleInt` (`sample.int`), `r2dtable` |
|
|
97
|
+
| Random numbers | `setSeed` (`set.seed`), `RNGkind` (Mersenne-Twister and L'Ecuyer-CMRG, `sample.kind` Rejection and Rounding), `getRandomSeed`/`setRandomSeed` (`.Random.seed`), `nextRNGStream`/`nextRNGSubStream` (`parallel`), 26 `r*` functions, `sample`, `sampleInt` (`sample.int`), `r2dtable` |
|
|
92
98
|
| Descriptive statistics | `sum`, `prod`, `mean`, `weightedMean` (`weighted.mean`), `variance` (`var`), `sd`, `median`, `range`, `cumsum`, `cumprod`, `cummax`, `cummin`, `diff`, `quantile`, `IQR`, `fivenum`, `mad`, `rank`, `cov`, `cor`, `tabulate`, `table`, `unique`, `cut`, `findInterval`, `pretty`, `hist`, `ecdf`, `scale`, `skewness`, `kurtosis`, `geometricMean`, `modes`, `meanAD`, `cv` |
|
|
93
|
-
| Hypothesis tests | `tTest`, `chisqTest`, `fisherTest`, `wilcoxTest`, `corTest`, `binomTest`, `poissonTest`, `propTest`, `mcnemarTest`, `varTest`, `bartlettTest`, `kruskalTest`, `friedmanTest`, `quadeTest`, `flignerTest`, `moodTest`, `onewayTest`, `shapiroTest`, `mantelhaenTest`, `ansariTest`, `ksTest`, `pairwiseTTest`, `pairwiseWilcoxTest`, `pairwisePropTest`, `aov`, `TukeyHSD`, `zTest`, `pAdjust` (`p.adjust`) |
|
|
99
|
+
| Hypothesis tests | `tTest`, `chisqTest`, `fisherTest`, `wilcoxTest`, `corTest`, `binomTest`, `poissonTest`, `propTest`, `mcnemarTest`, `varTest`, `bartlettTest`, `kruskalTest`, `friedmanTest`, `quadeTest`, `flignerTest`, `moodTest`, `onewayTest`, `shapiroTest`, `mantelhaenTest`, `ansariTest`, `ksTest`, `pairwiseTTest`, `pairwiseWilcoxTest`, `pairwisePropTest`, `aov`, `TukeyHSD`, `zTest`, `brunnerMunzelTest`, `pAdjust` (`p.adjust`) |
|
|
94
100
|
| Linear models | `lm` (matrix interface, with the `summary` quantities), `confint`, `predict` |
|
|
95
101
|
| Linear algebra | `matMul` (`%*%`), `add`, `subtract`, `multiply`, `divide`, `outer`, `t`, `diag`, `cbind`, `rbind`, `matrix`, `kronecker`, `seq`, `crossprod`, `tcrossprod`, `norm`, `backsolve`, `forwardsolve`, `chol`, `chol2inv`, `qr` with `qrQ`, `qrR`, `qrX`, `qrCoef`, `qrQy`, `qrQty`, `qrResid`, `qrFitted`, `qrSolve` (`qr.Q` …), `solve`, `det`, `determinant`, `rcond`, `kappa`, `svd`, `eigen`, `lu`, `prcomp`, `ginv` (MASS) |
|
|
96
102
|
| Numerical methods | `integrate`, `optimize`, `uniroot`, `approx`, `spline`, `splinefun`, `splinefunH`, `barylag`, `hermiteInterp`, `ode`, `grad`, `jacobian`, `hessian` |
|
|
@@ -130,9 +136,9 @@ removed. Approximate sizes after minification and gzip:
|
|
|
130
136
|
| `pnorm` | 1.2 KB |
|
|
131
137
|
| `setSeed`, `rnorm` | 1.7 KB |
|
|
132
138
|
| `solve` / `svd` / `eigen` | 1.7 / 2.0 / 3.7 KB |
|
|
133
|
-
| `wilcoxTest` / `fisherTest` / `tTest` | 8.6 / 15.
|
|
134
|
-
| `qbeta` / `pt` and `qt` |
|
|
135
|
-
| everything |
|
|
139
|
+
| `wilcoxTest` / `fisherTest` / `tTest` | 8.6 / 15.6 / 21.4 KB |
|
|
140
|
+
| `qbeta` / `pt` and `qt` | 23.2 / 30.3 KB |
|
|
141
|
+
| everything | 122.2 KB |
|
|
136
142
|
|
|
137
143
|
(`npm run size` measures these.)
|
|
138
144
|
|
|
@@ -141,11 +147,11 @@ Each area is also a subpath export, for importing one area without the rest:
|
|
|
141
147
|
`predict`), `/linalg`, `/descriptive`, `/numerics` and `/special`.
|
|
142
148
|
|
|
143
149
|
Without a bundler, load the single-file build `dist/rstats.js` (one minified ES module with every
|
|
144
|
-
function,
|
|
150
|
+
function, 119 KB gzipped) from jsDelivr, which serves each release tag of this repository:
|
|
145
151
|
|
|
146
152
|
```html
|
|
147
153
|
<script type="module">
|
|
148
|
-
import { pnorm } from "https://cdn.jsdelivr.net/gh/numero-uno-jpn/rStats.js@v0.
|
|
154
|
+
import { pnorm } from "https://cdn.jsdelivr.net/gh/numero-uno-jpn/rStats.js@v0.8.0/dist/rstats.js";
|
|
149
155
|
console.log(pnorm(1.96)); // 0.9750021048517795
|
|
150
156
|
</script>
|
|
151
157
|
```
|
|
@@ -154,11 +160,11 @@ A page that needs only some areas can load the per-area bundles instead: `dist/d
|
|
|
154
160
|
`dist/tests.js`, `dist/linalg.js`, `dist/descriptive.js`, `dist/numerics.js` and `dist/special.js`
|
|
155
161
|
export the same functions as the subpaths above, and share their common code through
|
|
156
162
|
`dist/chunks/`, so loading two areas does not load that code twice. With its chunks, one area
|
|
157
|
-
transfers 18 KB (`numerics`) to
|
|
163
|
+
transfers 18 KB (`numerics`) to 91 KB (`tests`) gzipped.
|
|
158
164
|
|
|
159
165
|
Release tags contain the build output (`dist/`), which is not on the main branch. npm-based CDNs
|
|
160
166
|
work as well, for example
|
|
161
|
-
`https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.
|
|
167
|
+
`https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.8.0/dist/rstats.js` or
|
|
162
168
|
`https://esm.sh/@numero-uno-jpn/rstats`.
|
|
163
169
|
|
|
164
170
|
The browser build is tested in headless Chromium, both bundled and as `dist/rstats.js` loaded as
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -106,6 +106,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
106
106
|
`detail/bessel_jy.hpp`, `detail/bessel_jy_series.hpp`, `detail/bessel_jy_asym.hpp` and the
|
|
107
107
|
dispatch in `bessel.hpp`, in `src/special/besselIK.ts` and `src/special/besselJY.ts`
|
|
108
108
|
(Copyright (c) 2006 Xiaogang Zhang, (c) 2007 John Maddock, (c) 2024 Matt Borland)
|
|
109
|
+
- Ported (Boost.Math commit 775c9e0): `beta_small_b_large_a_series` in
|
|
110
|
+
`include/boost/math/special_functions/beta.hpp` (DiDonato and Morris's asymptotic expansion for
|
|
111
|
+
large a and small b: the coefficients p_n and the upward recursion of J_n), in
|
|
112
|
+
`src/special/incbetLargeA.ts` ((C) Copyright John Maddock 2006)
|
|
109
113
|
|
|
110
114
|
```
|
|
111
115
|
Boost Software License - Version 1.0 - August 17th, 2003
|
|
@@ -315,3 +319,29 @@ they are listed so that readers can find the originals.
|
|
|
315
319
|
- QUADPACK (Piessens, de Doncker-Kapenga, Überhuber, Kahaner 1983): `dqagse` and `dqagie` (adaptive
|
|
316
320
|
Gauss–Kronrod quadrature with extrapolation), behind `integrate` — `src/integrate/quadpack.ts`,
|
|
317
321
|
ported from SciPy's C translation (see SciPy above)
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Published methods (implemented from the papers, no code copied)
|
|
326
|
+
|
|
327
|
+
Listed for attribution; no license terms apply to the methods themselves.
|
|
328
|
+
|
|
329
|
+
- P. L'Ecuyer, "Good parameters and implementations for combined multiple recursive random number
|
|
330
|
+
generators", Operations Research 47 (1999) 159–164: the MRG32k3a generator and its constants (R's
|
|
331
|
+
`RNGkind("L'Ecuyer-CMRG")`) — `src/random/lecuyer.ts`
|
|
332
|
+
- P. L'Ecuyer, R. Simard, E. J. Chen and W. D. Kelton, "An object-oriented random-number package with
|
|
333
|
+
many long streams and substreams", Operations Research 50 (2002) 1073–1075: the jump-ahead matrices for
|
|
334
|
+
streams (2^127 steps) and substreams (2^76 steps) — `src/random/streams.ts`
|
|
335
|
+
- E. Brunner and U. Munzel, "The nonparametric Behrens-Fisher problem: asymptotic theory and a small-sample
|
|
336
|
+
approximation", Biometrical Journal 42 (2000) 17–25: the Brunner-Munzel test (lawstat's
|
|
337
|
+
`brunner.munzel.test`) — `src/htest/brunnerMunzelTest.ts`
|
|
338
|
+
|
|
339
|
+
- N. M. Temme, "Incomplete Laplace integrals: uniform asymptotic expansion with application to the
|
|
340
|
+
incomplete beta function", SIAM J. Math. Anal. 18 (1987) 1638–1663, and Temme, "Special Functions: An
|
|
341
|
+
Introduction to the Classical Functions of Mathematical Physics" (Wiley, 1996), §11.3.3: the uniform
|
|
342
|
+
asymptotic expansion of the incomplete beta function for large a and b, with coefficients generated at run
|
|
343
|
+
time — `src/special/incbetTemme.ts`
|
|
344
|
+
- A. R. DiDonato and A. H. Morris, "Algorithm 708: Significant digit computation of the incomplete beta
|
|
345
|
+
function ratios", ACM Trans. Math. Software 18 (1992) 360–373, eq. 9 to 9.6 (the formulas only; the
|
|
346
|
+
TOMS 708 code is not used): the asymptotic expansion of the incomplete beta function for large a and
|
|
347
|
+
small b, with the complementary tail from the same expansion summed downwards — `src/special/incbetLargeA.ts`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! rStats.js 0.
|
|
1
|
+
/*! rStats.js 0.8.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
2
|
var q=2220446049250313e-31,b0=22250738585072014e-324,z=17976931348623157e292,v0=[.06667134430868814,.1494513491505806,.21908636251598204,.26926671930999635,.29552422471475287],f0=[.9956571630258081,.9739065285171717,.9301574913557082,.8650633666889845,.7808177265864169,.6794095682990244,.5627571346686047,.4333953941292472,.2943928627014602,.14887433898163122,0],I=[.011694638867371874,.032558162307964725,.054755896574351995,.07503967481091996,.0931254545836976,.10938715880229764,.12349197626206584,.13470921731147334,.14277593857706009,.14773910490133849,.1494455540029169];function h0(a,o,i,s,t){let r=Math.abs((a-o)*i);return t!==0&&r!==0&&(r=t*Math.min(1,Math.pow(200*r/t,1.5))),s>b0/(50*q)&&(r=Math.max(q*50*s,r)),r}function g0(a,o,i){let s=.5*(o+i),t=.5*(i-o),r=Math.abs(t),w=new Array(10),u=new Array(10),p=a(s),M=0,c=I[10]*p,b=Math.abs(c);for(let e=0;e<5;e++){let n=2*e+1,l=t*f0[n],h=a(s-l),v=a(s+l);w[n]=h,u[n]=v;let g=h+v;M+=v0[e]*g,c+=I[n]*g,b+=I[n]*(Math.abs(h)+Math.abs(v))}for(let e=0;e<5;e++){let n=2*e,l=t*f0[n],h=a(s-l),v=a(s+l);w[n]=h,u[n]=v;let g=h+v;c+=I[n]*g,b+=I[n]*(Math.abs(h)+Math.abs(v))}let A=c*.5,f=I[10]*Math.abs(p-A);for(let e=0;e<10;e++)f+=I[e]*(Math.abs(w[e]-A)+Math.abs(u[e]-A));return b*=r,f*=r,{result:c*t,abserr:h0(c,M,t,b,f),resabs:b,resasc:f}}var l0=[0,.1294849661688697,0,.27970539148927664,0,.3818300505051189,0,.4179591836734694],x0=[.9914553711208126,.9491079123427585,.8648644233597691,.7415311855993945,.5860872354676911,.4058451513773972,.20778495500789848,0],U=[.022935322010529224,.06309209262997856,.10479001032225019,.14065325971552592,.1690047266392679,.19035057806478542,.20443294007529889,.20948214108472782];function A0(a,o,i,s,t){let r=i>1?1:i,w=.5*(s+t),u=.5*(t-s),p=new Array(7),M=new Array(7),c=h=>{let v=o+r*(1-h)/h,g=a(v);return i===2&&(g+=a(-v)),g},b=c(w)/w/w,A=b*l0[7],f=b*U[7],e=Math.abs(f);for(let h=0;h<7;h++){let v=u*x0[h],g=w-v,W=w+v,m=c(g),x=c(W);m=m/g/g,x=x/W/W,p[h]=m,M[h]=x;let K=m+x;A+=l0[h]*K,f+=U[h]*K,e+=U[h]*(Math.abs(m)+Math.abs(x))}let n=f*.5,l=U[7]*Math.abs(b-n);for(let h=0;h<7;h++)l+=U[h]*(Math.abs(p[h]-n)+Math.abs(M[h]-n));return e*=u,l*=u,{result:f*u,abserr:h0(f,A,u,e,l),resabs:e,resasc:l}}function j0(a){let o=a.epstab,i=a.n;a.nres+=1;let s=z,t=o[a.n];if(a.n<2)return s=Math.max(s,5*q*Math.abs(t)),[t,s];let r=49;o[a.n+2]=o[a.n];let w=Math.trunc(a.n/2);o[a.n]=z;let u=a.n;for(let c=0;c<w;c++){let b=u-1,A=u-2,f=o[u+2],e=o[A],n=o[b],l=f,h=Math.abs(n),v=l-n,g=Math.abs(v),W=Math.max(Math.abs(l),h)*q,m=n-e,x=Math.abs(m),K=Math.max(h,Math.abs(e))*q;if(!(g>W||x>K))return t=f,s=g+x,s=Math.max(s,5*q*Math.abs(t)),[t,s];let k=o[u];o[u]=n;let j=n-k,F=Math.abs(j),_=Math.max(h,Math.abs(k))*q;if(F<=_||g<=W||x<=K){a.n=c+c;break}let L=1/j+1/v-1/m;if(!(Math.abs(L*n)>1e-4)){a.n=c+c;break}f=n+1/L,o[u]=f,u-=2;let X=g+Math.abs(f-l)+x;X>s||(s=X,t=f)}a.n===r&&(a.n=2*Math.trunc(r/2));let p=i%2;for(let c=0;c<=w;c++)o[2*c+p]=o[2*c+2+p];if(a.n!==i){let c=i-a.n;for(let b=0;b<=a.n;b++)o[b]=o[c],c++}let M=a.res3la;return a.nres<4?(M[a.nres-1]=t,s=z):(s=Math.abs(t-M[2])+Math.abs(t-M[1])+Math.abs(t-M[0]),M[0]=M[1],M[1]=M[2],M[2]=t),s=Math.max(s,5*q*Math.abs(t)),[t,s]}function y0(a,o,i,s,t,r){if(o<=2){t[0]=0,t[1]=1;let e=t[r];return[e,s[e],r]}let w=s[i];for(;r>0&&w>s[t[r-1]];)t[r]=t[r-1],r-=1;let u=o>Math.trunc(a/2)+2?a-o+2:o-1,p=s[o-1],M=u-1,c=r+1,b=c,A=!1;if(c<=M)for(b=c;b<=M;b++){if(w>=s[t[b]]){A=!0;break}t[b-1]=t[b]}if(!A)t[M]=i,t[u]=o-1;else{t[b-1]=i;let e=M;for(let n=b;n<=M&&!(p<s[t[e]]);n++)t[e+1]=t[e],e--;p<s[t[e]]?t[e+1]=o-1:t[b]=o-1}let f=t[r];return[f,s[f],r]}function M0(a,o,i,s,t,r,w,u){let p=new Float64Array(r+1),M=new Float64Array(r+1),c=new Float64Array(r+1),b=new Float64Array(r+1),A=new Int32Array(r+1),f=0,e=0,n=0,l=0;if(p[0]=o,M[0]=i,s<=0&&t<Math.max(50*q,5e-29))return{result:0,abserr:0,neval:0,ier:6,last:0};let h=a(o,i);n=h.result,l=h.abserr;let v=h.resabs,g=h.resasc,W=Math.abs(n),m=Math.max(s,t*W);if(e=1,c[0]=n,b[0]=l,A[0]=0,l<=100*q*v&&l>m&&(f=2),r===1&&(f=1),f!==0||l<=m&&l!==g||l===0)return{result:n,abserr:l,neval:u(e),ier:f,last:e};let x={epstab:new Float64Array(52),res3la:new Float64Array(3),n:1,nres:0};x.epstab[0]=n;let K=l,k=0,j=n,F=l;l=z;let _=0,L=0,E=!1,X=!1,B=0,t0=0,R=0,s0=0,C=0,O=0,D=0,e0=0,u0=W>=(1-50*q)*v?1:-1,a0=!1,y=1;for(y=1;y<r;y++){e=y+1;let d=p[k],H=.5*(p[k]+M[k]),J=H,S=M[k],i0=K,T=a(d,H),V=a(J,S),Y=T.result,N=T.abserr,k0=T.resasc,Z=V.result,P=V.abserr,w0=V.resasc,$=Y+Z,Q=N+P;if(F=F+Q-K,j=j+$-c[k],k0!==N&&w0!==P&&(Math.abs(c[k]-$)>1e-5*Math.abs($)||Q<.99*K||(E?R++:t0++),y>9&&Q>K&&s0++),c[k]=Y,c[y]=Z,m=Math.max(s,t*Math.abs(j)),(t0+R>=10||s0>=20)&&(f=2),R>=5&&(B=3),e===r&&(f=1),Math.max(Math.abs(d),Math.abs(S))<=(1+100*q)*(Math.abs(J)+1e3*b0)&&(f=4),P>N?(p[k]=J,p[y]=d,M[y]=H,c[k]=Z,c[y]=Y,b[k]=P,b[y]=N):(p[y]=J,M[k]=H,M[y]=S,b[k]=N,b[y]=P),[k,K,_]=y0(r,e,k,b,A,_),F<=m){a0=!0;break}if(f!==0)break;if(y===1){C=w,O=F,D=m,x.epstab[1]=j;continue}if(X)continue;if(O-=i0,Math.abs(H-d)>C&&(O+=Q),!E){if(Math.abs(M[k]-p[k])>C)continue;E=!0,_=1}if(!(B===3||O<=D)){let p0=e>2+Math.trunc(r/2)?r+3-e:e,o0=!1;for(let c0=_;c0<p0;c0++){if(k=A[_],K=b[k],Math.abs(M[k]-p[k])>C){o0=!0;break}_++}if(o0)continue}x.n+=1,x.epstab[x.n]=j;let[n0,r0]=j0(x);if(L+=1,L>5&&l<.001*F&&(f=5),r0<l&&(L=0,l=r0,n=n0,e0=O,D=Math.max(s,t*Math.abs(n0)),l<=D)||(x.n===0&&(X=!0),f===5))break;k=A[0],K=b[k],_=0,E=!1,C*=.5,O=F}let G;if(a0||l===z?G=115:f+B===0?G=110:(B===3&&(l+=e0),f===0&&(f=3),n!==0&&j!==0?G=105:l>F?G=115:j===0?G=130:G=110),G===105&&(G=l/Math.abs(n)>F/Math.abs(j)?115:110),G===110)u0===-1&&Math.max(Math.abs(n),Math.abs(j))<=v*.01||(.01>n/j||n/j>100||F>Math.abs(j))&&(f=6);else if(G===115){n=0;for(let d=0;d<=y;d++)n+=c[d];l=F}return f>2&&(f-=1),{result:n,abserr:l,neval:u(e),ier:f,last:e}}function m0(a,o,i,s,t,r){return M0((w,u)=>g0(a,w,u),o,i,s,t,r,Math.abs(i-o)*.375,w=>42*w-21)}function K0(a,o,i,s,t,r){let w=i===2?0:o;return M0((u,p)=>A0(a,w,i,u,p),0,1,s,t,r,.375,u=>(30*u-15)*(i===2?2:1))}export{m0 as a,K0 as b};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! rStats.js 0.8.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 I3,b as T,c as d3,d as M,e as A3,f as Z,g as d,h as A,i as T1,j as S3,k as m}from"./chunk-OHPHNE3O.js";function _(e,t){let n=t[0];for(let o=1;o<t.length;o++)n=n*e+t[o];return n}function q(e,t){let n=e+t[0];for(let o=1;o<t.length;o++)n=n*e+t[o];return n}var P5=[2461969814735305e-25,.5641895648310689,7.463210564422699,48.63719709856814,196.5208329560771,526.4451949954773,934.5285271719576,1027.5518868951572,557.5353353693994],F5=[13.228195115474499,86.70721408859897,354.9377788878199,975.7085017432055,1823.9091668790973,2246.3376081871097,1656.6630919416134,557.5353408177277],R5=[.5641895835477551,1.275366707599781,5.019050422511805,6.160210979930536,7.4097426995044895,2.9788666537210022],L5=[2.2605286322011726,9.396035249380015,12.048953980809666,17.08144507475659,9.608968090632859,3.369076451000815],E5=[9.604973739870516,90.02601972038427,2232.005345946843,7003.325141128051,55592.30130103949],w5=[33.56171416475031,521.3579497801527,4594.323829709801,22629.000061389095,49267.39426086359],T5=709.782712893384,q5=.5641895835477563;function N1(e){if(Number.isNaN(e))return NaN;if(e<0)return-N1(-e);if(e>1)return 1-q1(e);let t=e*e;return e*_(t,E5)/q(t,w5)}function q1(e){if(Number.isNaN(e))return NaN;let t=Math.abs(e);if(t<1)return 1-N1(e);if(e<0)return 2-q1(t);let[n,o]=d3(t,t);if(n>T5+40)return 0;let r=v3(t)*(1-o);return n<700?Math.exp(-n)*r:Math.exp(700-n)*r*Math.exp(-700)}function G1(e){return Number.isNaN(e)?NaN:e<1?Math.exp(e*e)*(1-N1(e)):e>1e8?q5/e:v3(e)}function v3(e){return e<8?_(e,P5)/q(e,F5):_(e,R5)/q(e,L5)}var G5=[-59.96335010141079,98.00107541859997,-56.67628574690703,13.931260938727968,-1.2391658386738125],D5=[1.9544885833814176,4.676279128988815,86.36024213908905,-225.46268785411937,200.26021238006066,-82.03722561683334,15.90562251262117,-1.1833162112133],k5=[4.0554489230596245,31.525109459989388,57.16281922464213,44.08050738932008,14.684956192885803,2.1866330685079025,-.1402560791713545,-.03504246268278482,-.0008574567851546854],O5=[15.779988325646675,45.39076351288792,41.3172038254672,15.04253856929075,2.504649462083094,-.14218292285478779,-.03808064076915783,-.0009332594808954574],C5=[3.2377489177694603,6.915228890689842,3.9388102529247444,1.3330346081580755,.20148538954917908,.012371663481782003,.00030158155350823543,26580697468673755e-22,6239745391849833e-24],Q5=[6.02427039364742,3.6798356385616087,1.3770209948908132,.21623699359449663,.013420400608854318,.00032801446468212774,28924786474538068e-22,6790194080099813e-24],_3=.1353352832366127,z5=2.5066282746310007;function y3(e){let t=e-Math.log(e)/e,n=1/e,o=e<8?n*_(n,k5)/q(n,O5):n*_(n,C5)/q(n,Q5);return t-o}function D1(e){if(e===0)return-1/0;if(e===1)return 1/0;if(!(e>=0&&e<=1))return NaN;let t=e,n=!0;if(t>1-_3&&(t=1-t,n=!1),t>_3){t=t-.5;let r=t*t;return(t+t*(r*_(r,G5)/q(r,D5)))*z5}let o=y3(Math.sqrt(-2*Math.log(t)));return n?-o:o}function P3(e){if(e<-Number.MAX_VALUE)return-1/0;if(e<-2){let t=e>=-Number.MAX_VALUE*.5?Math.sqrt(-2*e):Math.SQRT2*Math.sqrt(-e);return-y3(t)}return e>-.14541345786885906?-D1(-Math.expm1(e)):D1(Math.exp(e))}function k1(e,t){return typeof e=="number"?t(e):e instanceof Float64Array?e.map(t):e.map(n=>t(n))}var O1=Math.SQRT1_2;function F3(e,t){let n=Math.floor(e*16)/16,o=e-n,r=n*n/2,s=t*Math.exp(-o*(e+n)/2);return r<=700?s*Math.exp(-r):s*Math.exp(700-r)*Math.exp(-700)}function E0(e){let t=-e;return t<Math.SQRT2?.5-.5*N1(t*O1):F3(t,.5*G1(t*O1))}function R3(e,t){if(!t)return e<=0?E0(e):1-E0(-e);if(e>-1)return Math.log1p(-E0(-e));let n=-e;return Math.log(.5*G1(n*O1))-n*n/2}function X5(e,t,n,o,r){if(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(n))return NaN;if(!Number.isFinite(e)&&t===e)return NaN;let s=o?r?-1/0:0:r?0:1,c=o?r?0:1:r?-1/0:0;if(n<0)return NaN;if(n===0)return e<t?s:c;let i=(e-t)/n;return Number.isFinite(i)?R3(o?i:-i,r):e<t?s:c}function B5(e,t,n,o,r){if(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(n))return NaN;let s=o?-1/0:1/0;if(r){if(e>0)return NaN;if(e===0)return-s;if(e===-1/0)return s}else{if(e<0||e>1)return NaN;if(e===0)return s;if(e===1)return-s}if(n<0)return NaN;if(n===0)return t;let c=r?V5(e):D1(e);return t+n*(o?c:-c)}var H5=.7978845608028654;function V5(e){let t=P3(e);if(!(e<-2048)||!Number.isFinite(t))return t;let n=H5/G1(-t*O1),o=(R3(t,!0)-e)/n;return Number.isFinite(o)?t-o:t}var j5=.9189385332046728,U5=.3989422804014327;function Y5(e,t,n,o){if(Number.isNaN(e)||Number.isNaN(t)||Number.isNaN(n))return NaN;if(n<0)return NaN;if(!Number.isFinite(n))return o?-1/0:0;if(!Number.isFinite(e)&&t===e)return NaN;if(n===0)return e===t?1/0:o?-1/0:0;let r=(e-t)/n;return Number.isFinite(r)?o?-(j5+.5*r*r+Math.log(n)):F3(Math.abs(r),U5/n):o?-1/0:0}function Y6(e,t={}){let{mean:n=0,sd:o=1,log:r=!1}=t;return k1(e,s=>Y5(s,n,o,r))}function K6(e,t={}){let{mean:n=0,sd:o=1,lowerTail:r=!0,logP:s=!1}=t;return k1(e,c=>X5(c,n,o,r,s))}function Z6(e,t={}){let{mean:n=0,sd:o=1,lowerTail:r=!0,logP:s=!1}=t;return k1(e,c=>B5(c,n,o,r,s))}var G=11102230246251565e-32;var O=171.6243769563027,p1=.9189385332046728,L3=1.1447298858494002;var w0=.5772156649015329;var K5=[.00016011952247675185,.0011913514700658638,.010421379756176158,.04763678004571372,.20744822764843598,.4942148268014971,1],Z5=[-23158187332412014e-21,.0005396055804933034,-.004456419138517973,.011813978522206043,.035823639860549865,-.23459179571824335,.0714304917030273,1];function q3(e){let t=1;e<0&&(e=-e,t=-1);let n=e%2;return n<.5?t*Math.sin(Math.PI*n):n>1.5?t*Math.sin(Math.PI*(n-2)):-t*Math.sin(Math.PI*(n-1))}function E3(e){if(e>=O)return 1/0;let t=e-1,n=M(A(m([t,0]),t),[-t+o6(t),0]);return Math.sqrt(2*Math.PI*t)*Math.exp(n[0])*(1+n[1])}function X(e){if(!Number.isFinite(e))return e>0?e:NaN;if(e===0)return NaN;let t=Math.abs(e);if(t>33){if(e<0){let o=Math.floor(t);if(o===t)return NaN;let r=o%2===0?-1:1,s=t-o;return s>.5&&(o+=1,s=t-o),s=t*q3(s),s===0?r*(1/0):r*Math.PI/(Math.abs(s)*E3(t))}return E3(e)}let n=1;for(;e>=3;)e-=1,n*=e;for(;e<0;){if(e>-1e-9)return w3(e,n);n/=e,e+=1}for(;e<2;){if(e<1e-9)return w3(e,n);n/=e,e+=1}return e===2?n:(e-=2,n*_(e,K5)/_(e,Z5))}function w3(e,t){return e===0?NaN:t/((1+w0*e)*e)}var J5=[.0008116141674705085,-.0005950619042843014,.0007936503404577169,-.002777777777300997,.08333333333333319],W5=[-1378.2515256912086,-38801.631513463784,-331612.9927388712,-1162370974927623e-9,-1.7217370082083966e6,-853555.6642457654],$5=[-351.81570143652345,-17064.210665188115,-220528.59055385445,-1.1393344436798252e6,-2.5325230717758294e6,-2.0188914143353277e6],x5=2556348e299;function e6(e){let t=(e-.5)*Math.log(e)-e+p1;if(e>1e8)return t;let n=1/(e*e);return t+((.0007936507936507937*n-.002777777777777778)*n+.08333333333333333)/e}function D(e){if(!Number.isFinite(e))return{value:e===-1/0?1/0:e,sign:1};if(e<-34){let o=-e,r=D(o).value,s=Math.floor(o);if(s===o)return{value:1/0,sign:1};let c=s%2===0?-1:1,i=o-s;return i>.5&&(s+=1,i=s-o),i=o*q3(i),i===0?{value:1/0,sign:1}:{value:L3-Math.log(i)-r,sign:c}}if(e<13){let o=1,r=0,s=e;for(;s>=3;)r-=1,s=e+r,o*=s;for(;s<2;){if(s===0)return{value:1/0,sign:1};o/=s,r+=1,s=e+r}let c=1;if(o<0&&(c=-1,o=-o),s===2)return{value:Math.log(o),sign:c};r-=2;let i=e+r;return{value:Math.log(o)+i*_(i,W5)/q(i,$5),sign:c}}if(e>x5)return{value:1/0,sign:1};if(e>=1e3)return{value:e6(e),sign:1};let t=(e-.5)*Math.log(e)-e+p1,n=1/(e*e);return{value:t+_(n,J5)/e,sign:1}}function o1(e){return Math.abs(e-1)<=.2?J(e-1):Math.abs(e-2)<=.2?J(e-2)+Math.log1p(e-2):D(e).value}var t6=[1.6449340668482264,1.2020569031595942,1.0823232337111381,1.03692775514337,1.0173430619844492,1.008349277381923,1.0040773561979444,1.0020083928260821,1.000994575127818,1.0004941886041194,1.000246086553308,1.0001227133475785,1.0000612481350588,1.000030588236307,1.0000152822594086,1.0000076371976379,1.000003817293265,1.0000019082127165,1.0000009539620338,1.0000004769329869,1.0000002384505027,1.000000119219926,1.000000059608189,1.0000000298035034,1.0000000149015549,1.0000000074507118,1.000000003725334,1.0000000018626598,1.0000000009313275,1.0000000004656628,1.000000000232831,1.0000000001164155,1.0000000000582077,1.0000000000291038,1.000000000014552,1.000000000007276,1.000000000003638,1.000000000001819,1.0000000000009095,1.0000000000004547];function T3(e){if(e===0)return 0;let t=-w0*e,n=-e;for(let o=2;o<42;o++){n*=-e;let r=t6[o-2]*n/o;if(t+=r,Math.abs(r)<G*Math.abs(t))break}return t}function J(e){return Math.abs(e)<=.2?T3(e):Math.abs(e-1)<=.2?Math.log(e)+T3(e-1):o1(e+1)}var n6=[1/12,-1/360,1/1260,-1/1680,1/1188,-691/360360,1/156];function o6(e){let t=1/(e*e),n=0,o=1/e;for(let r of n6)n+=r*o,o*=t;return n}var G3=[1/12,-1/360,1/1260,-1/1680,1/1188,-691/360360,1/156];function D3(e,t){let n=T0(e,t);return n[0]+n[1]}function T0(e,t){if(e===0)return[0,0];let n=0,o=t;for(;o<=15;)n-=Math.log1p(e/o),o+=1;let r=Math.log1p(e/o),s=e*Math.log(o+e),c=Math.abs(s)>2&&Number.isFinite(s)&&e<1e300?A(m(T(o,e)),e):[s,0],i=(o-.5)*r-e,u=1/o,l=1/(o*o);for(let a=0;a<G3.length;a++){let f=2*a+1;i+=G3[a]*u*Math.expm1(-f*r),u*=l}return M(c,[n+i,0])}var k3=22250738585072014e-324,D0=1.8378770664093456,r6=[.15342640972002736,.08106146679532726,.05481412105191765,.0413406959554093,.03316287351993629,.02767792568499834,.023746163656297496,.020790672103765093,.018488450532673187,.016644691189821193,.015134973221917378,.013876128823070748,.012810465242920227,.01189670994589177,.011104559758206917,.010411265261972096,.009799416126158804,.009255462182712733,.008768700134139386,.00833056343336287,.00793411456431402,.007573675487951841,.007244554301320383,.00694284010720953,.006665247032707682,.006408994188004207,.006171712263039458,.0059513701127588475,.0057462165130101155,.005554733551962801],C1=1/12,Q1=1/360,q0=1/1260,O3=1/1680,s6=1/1188,c6=691/360360,i6=1/156;function C3(e){let t=1/(e*e);return e>500?(C1-Q1*t)/e:e>80?(C1-(Q1-q0*t)*t)/e:e>35?(C1-(Q1-(q0-O3*t)*t)*t)/e:(C1-(Q1-(q0-(O3-(s6-(c6-i6*t)*t)*t)*t)*t)*t)/e}function S(e){if(e>15)return C3(e);let t=2*e;if(t===Math.floor(t)&&t>=1)return r6[t-1];if(e<1)return J(e)-(e+.5)*Math.log(e)+e-p1;let n=0,o=e;for(;o<=15;)n+=(o+.5)*Math.log1p(1/o)-1,o+=1;return n+C3(o)}var u6=.12;function B(e,t){if(!I3())return f6(e,t);let n=-t[0],o=-t[1],r=e+n,s=r-e,c=e-(r-s)+(n-s),i=0+o,u=i-0,l=0-(i-u)+(o-u),a=c+i,f=r+a,g=a-(f-r)+l,v=f+g,y=g-(v-f),b=v,R=y;if(Math.abs(b)<.1*(e+t[0])){let H=e+t[0],W=H-e,g1=e-(H-W)+(t[0]-W),Q=0+t[1],r1=Q-0,I1=0-(Q-r1)+(t[1]-r1),Q0=g1+Q,j1=H+Q0,z0=Q0-(j1-H)+I1,F=j1+z0,X0=z0-(F-j1),V=b/F,U1=F*V,B0=134217729*F,Y1=B0-(B0-F),H0=F-Y1,V0=134217729*V,K1=V0-(V0-V),j0=V-K1,U0=Y1*K1-U1+Y1*j0+H0*K1+H0*j0+X0*V,Y0=U1+U0,o5=U0-(Y0-U1),K0=-Y0,Z0=-o5,d1=b+K0,J0=d1-b,r5=b-(d1-J0)+(K0-J0),Z1=R+Z0,W0=Z1-R,s5=R-(Z1-W0)+(Z0-W0),$0=r5+Z1,J1=d1+$0,x0=$0-(J1-d1)+s5,s1=J1+x0,W1=x0-(s1-J1),j=s1/F,$1=F*j,e2=134217729*F,x1=e2-(e2-F),t2=F-x1,n2=134217729*j,e0=n2-(n2-j),o2=j-e0,r2=x1*e0-$1+x1*o2+t2*e0+t2*o2+X0*j,s2=$1+r2,c5=r2-(s2-$1),c2=-s2,i2=-c5,A1=s1+c2,u2=A1-s1,i5=s1-(A1-u2)+(c2-u2),t0=W1+i2,f2=t0-W1,u5=W1-(t0-f2)+(i2-f2),a2=i5+t0,n0=A1+a2,l2=a2-(n0-A1)+u5,h2=n0+l2,y6=l2-(h2-n0),M2=h2/F,S1=V+j,o0=j-(S1-V),v1=S1+M2,m2=v1-S1,f5=S1-(v1-m2)+(M2-m2),r0=o0+0,N2=r0-o0,a5=o0-(r0-N2)+(0-N2),p2=f5+r0,s0=v1+p2,b2=p2-(s0-v1)+a5,g2=s0+b2,l5=b2-(g2-s0),h=g2,_1=l5,c0=b*h,I2=134217729*b,i0=I2-(I2-b),d2=b-i0,A2=134217729*h,u0=A2-(A2-h),S2=h-u0,v2=i0*u0-c0+i0*S2+d2*u0+d2*S2+(b*_1+R*h),_2=c0+v2,h5=v2-(_2-c0),L=_2,k=h5;if(Math.abs(e*h*h*h)<=u6){let $=h*h,U=2*e*h*$,x=U/3;for(let t1=2;t1<1e3;t1++){U*=$;let n1=U/(2*t1+1);if(x+=n1,Math.abs(n1)<=2**-60*L)break}let z=L+x,f1=z-L,y1=L-(z-f1)+(x-f1),Y=k+0,a1=Y-k,O2=k-(Y-a1)+(0-a1),l1=y1+Y,e1=z+l1,I=l1-(e1-z)+O2,w=e1+I,h1=I-(w-e1);return[w,h1]}let c1=2*e,f0=h*c1,y2=134217729*h,a0=y2-(y2-h),P2=h-a0,F2=134217729*c1,l0=F2-(F2-c1),R2=c1-l0,L2=a0*l0-f0+a0*R2+P2*l0+P2*R2+_1*c1,E2=f0+L2,M5=L2-(E2-f0),E=E2,i1=M5,h0=h*h,w2=134217729*h,M0=w2-(w2-h),T2=h-M0,q2=134217729*h,m0=q2-(q2-h),G2=h-m0,D2=M0*m0-h0+M0*G2+T2*m0+T2*G2+(h*_1+_1*h),k2=h0+D2,m5=D2-(k2-h0),u1=k2,N5=m5;for(let $=1;$<1e3;$++){let U=E*u1,x=134217729*E,z=x-(x-E),f1=E-z,y1=134217729*u1,Y=y1-(y1-u1),a1=u1-Y,l1=z*Y-U+z*a1+f1*Y+f1*a1+(E*N5+i1*u1),e1=U+l1,C2=l1-(e1-U);E=e1,i1=C2;let I=2*$+1,w=E/I,h1=I*w,t1=134217729*I,n1=t1-(t1-I),Q2=I-n1,z2=134217729*w,N0=z2-(z2-w),X2=w-N0,B2=n1*N0-h1+n1*X2+Q2*N0+Q2*X2+0*w,H2=h1+B2,p5=B2-(H2-h1),V2=-H2,j2=-p5,P1=E+V2,U2=P1-E,b5=E-(P1-U2)+(V2-U2),p0=i1+j2,Y2=p0-i1,g5=i1-(p0-Y2)+(j2-Y2),K2=b5+p0,b0=P1+K2,Z2=K2-(b0-P1)+g5,M1=b0+Z2,g0=Z2-(M1-b0),K=M1/I,I0=I*K,J2=134217729*I,d0=J2-(J2-I),W2=I-d0,$2=134217729*K,A0=$2-($2-K),x2=K-A0,e3=d0*A0-I0+d0*x2+W2*A0+W2*x2+0*K,t3=I0+e3,I5=e3-(t3-I0),n3=-t3,o3=-I5,F1=M1+n3,r3=F1-M1,d5=M1-(F1-r3)+(n3-r3),S0=g0+o3,s3=S0-g0,A5=g0-(S0-s3)+(o3-s3),c3=d5+S0,v0=F1+c3,i3=c3-(v0-F1)+A5,u3=v0+i3,G6=i3-(u3-v0),f3=u3/I,R1=w+K,_0=K-(R1-w),L1=R1+f3,a3=L1-R1,S5=R1-(L1-a3)+(f3-a3),y0=_0+0,l3=y0-_0,v5=_0-(y0-l3)+(0-l3),h3=S5+y0,P0=L1+h3,M3=h3-(P0-L1)+v5,E1=P0+M3,m3=M3-(E1-P0),w1=L+E1,N3=w1-L,_5=L-(w1-N3)+(E1-N3),F0=k+m3,p3=F0-k,y5=k-(F0-p3)+(m3-p3),b3=_5+F0,R0=w1+b3,g3=b3-(R0-w1)+y5,m1=R0+g3,L0=g3-(m1-R0);if(Math.abs(E1)<=1e-33*Math.abs(m1)||m1===L&&L0===k)return[m1,L0];L=m1,k=L0}return[L,k]}let P=e/t[0],C=P>1e-290&&P<1e290?m(T1([e,0],t)):Z(m([e,0]),m(t));return M(A(C,e),[-b,-R])}function f6(e,t){let n=Z([e,0],t);if(Math.abs(n[0])<.1*(e+t[0])){let s=T1(n,M([e,0],t)),c=d(n,s),i=A(s,2*e),u=d(s,s);for(let l=1;l<1e3;l++){i=d(i,u);let a=S3(i,2*l+1),f=M(c,a);if(Math.abs(a[0])<=1e-33*Math.abs(f[0])||f[0]===c[0]&&f[1]===c[1])return f;c=f}return c}let o=e/t[0],r=o>1e-290&&o<1e290?m(T1([e,0],t)):Z(m([e,0]),m(t));return M(A(r,e),A3(n))}function u4(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||t===0)return NaN;if(e===0)return t;let n=B(e,[t,0]);return n[0]+n[1]}function G0(e,t,n,o){if(t)return-e[0]-e[1]-.5*n();if(e[0]<700)return Math.exp(-e[0])*(1-e[1])/Math.sqrt(o());let r=o();return!Number.isFinite(r)||r===0?Math.exp(-e[0]-e[1]-.5*n()):Math.exp(700-e[0])*(1-e[1])/Math.sqrt(r)*Math.exp(-700)}function f4(e,t,n,o,r){let s=r?-1/0:0,c=r?0:1,i=T(e,t),u=i[0];if(n[0]===0)return e===0?c:s;if(o[0]===0)return t===0?c:s;if(e===0){if(u===0)return c;if(n[0]<.1){let p=M(B(u,d(i,o)),d(i,n));return r?-p[0]-p[1]:Math.exp(-p[0])*(1-p[1])}let a=m(o),f=d(i,a);return r?f[0]+f[1]:Math.exp(f[0])*(1+f[1])}if(t===0){if(o[0]<.1){let f=M(B(u,d(i,n)),d(i,o));return r?-f[0]-f[1]:Math.exp(-f[0])*(1-f[1])}let a=d(i,m(n));return r?a[0]+a[1]:Math.exp(a[0])*(1+a[1])}if(e<0||t<0)return s;let l=M(B(e,d(i,n)),B(t,d(i,o)));return l=M(l,T(S(e)+S(t),-S(u))),G0(l,r,()=>D0+Math.log(e)+Math.log(t)-Math.log(u),()=>2*Math.PI*e*(t/u))}function a4(e,t,n,o){let r=T(e,t),s=r[0],c=M(B(e,d(r,n)),B(t,d(r,o)));return c=M(c,T(S(e)+S(t),-S(s))),{e:c,logDenom:D0+Math.log(e)+Math.log(t)-Math.log(s)}}function b1(e,t,n){let o=Q3(e,t,n,!n);return n?o[0]:o[1]}function k0(e,t){return Q3(e,t,!0,!0)}function Q3(e,t,n,o){if(t===0)return e===0?[0,1]:[-1/0,0];if(!Number.isFinite(t)||e<0)return[-1/0,0];if(e<=t*k3)return[-t,o?Math.exp(-t):NaN];if(t<e*k3){if(!Number.isFinite(e))return[-1/0,0];let i=-t+e*Math.log(t)-J(e);return[i,o?Math.exp(i):NaN]}let r=M(B(e,[t,0]),[S(e),0]),s=()=>D0+Math.log(e),c=()=>2*Math.PI*e;return[n?G0(r,!0,s,c):NaN,o?G0(r,!1,s,c):NaN]}var z1=1e6;function B3(e,t){let{value:n,sign:o}=D(t),r=n;return r-=t*Math.log(e),r+=t*(1-t)/(2*e),r+=t*(1-t)*(1-2*t)/(12*e*e),r+=-t*t*(1-t)*(1-t)/(12*e*e*e),{value:r,sign:o}}function a6(e,t){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(e===1/0&&t>0||t===1/0&&e>0)return 0;if(e>0&&t>0&&Math.max(e,t)>15){let c=Math.min(e,t),i=Math.max(e,t);if(c<1){let l=T0(c,i);return X(c)*Math.exp(-l[0])*(1-l[1])}let u=i>=V3?j3(i,c):U3(e,t);return Math.exp(u[0])*(1+u[1])}let n=1;if(e<=0&&e===Math.floor(e))return z3(e,t);if(t<=0&&t===Math.floor(t))return z3(t,e);if(Math.abs(e)<Math.abs(t)&&([e,t]=[t,e]),Math.abs(e)>z1*Math.abs(t)&&e>z1){let c=B3(e,t);return c.sign*Math.exp(c.value)}let o=e+t;if(Math.abs(o)>O||Math.abs(e)>O||Math.abs(t)>O){let c=D(o);n*=c.sign;let i=D(t);n*=i.sign;let u=D(e);n*=u.sign;let l=u.value+(i.value-c.value);return n*Math.exp(l)}o=1/X(o);let r=X(e),s=X(t);return Number.isFinite(o)?Math.abs(Math.abs(r*o)-1)>Math.abs(Math.abs(s*o)-1)?s*o*r:r*o*s:n*(1/0)}function z3(e,t){return t===Math.floor(t)&&1-e-t>0?(t%2===0?1:-1)*a6(1-e-t,t):1/0}function l6(e,t){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(e===1/0&&t>0||t===1/0&&e>0)return-1/0;if(e>0&&t>0&&Number.isFinite(e)&&Number.isFinite(t)&&Math.max(e,t)>15){let c=Math.min(e,t),i=Math.max(e,t);if(c<1)return o1(c)-D3(c,i);let u=i>=V3?j3(i,c):U3(e,t);return u[0]+u[1]}if(e<=0&&e===Math.floor(e))return X3(e,t);if(t<=0&&t===Math.floor(t))return X3(t,e);if(Math.abs(e)<Math.abs(t)&&([e,t]=[t,e]),Math.abs(e)>z1*Math.abs(t)&&e>z1)return B3(e,t).value;let n=e+t;if(Math.abs(n)>O||Math.abs(e)>O||Math.abs(t)>O)return D(e).value+(D(t).value-D(n).value);n=1/X(n);let o=X(e),r=X(t);if(!Number.isFinite(n))return 1/0;let s=Math.abs(Math.abs(o*n)-1)>Math.abs(Math.abs(r*n)-1)?r*n*o:o*n*r;return Math.log(Math.abs(s))}function X3(e,t){return t===Math.floor(t)&&1-e-t>0?l6(1-e-t,t):1/0}var H3=[.9189385332046728,-38782941580672414e-33],V3=2**52;function j3(e,t){let n=A(Z(m([t,0]),m([e,0])),t),o=-.5*Math.log(t)-(e+t-.5)*Math.log1p(t/e)+(S(e)+S(t)-S(e+t));return M(M(n,H3),[o,0])}function U3(e,t){let n=T(e,t),o=A(m([e,0]),e-.5),r=A(m([t,0]),t-.5),s=h6(m(n),M(n,[-.5,0])),c=Z(M(o,r),s);return c=M(c,H3),M(c,T(S(e)+S(t),-S(n[0])))}function h6(e,t){return M(A(e,t[0]),A(e,t[1]))}function O0(e){if(Math.abs(e)<.5){let t=e,n=0;for(let o=2;o<500;o++){t*=-e;let r=t/o;if(n+=r,Math.abs(r)<G*Math.abs(n))break}return n}return Math.log1p(e)-e}var Y3=[[-.3333333333333333,.08333333333333333,-.014814814814814815,.0011574074074074073,.0003527336860670194,-.0001787551440329218,3919263178522438e-20,-21854485106799924e-22,-185406221071516e-20,8296711340953087e-22,-17665952736826078e-23,6707853543401498e-24,10261809784240309e-24,-4382036018453353e-24,914769958223679e-24,-2551419399494625e-26,-5830772132550426e-26,24361948020667415e-27,-50276692801141755e-28,11004392031956135e-29,33717632624009856e-29,-1392388722418162e-28,28534893807047445e-30,-5139111834242572e-31,-19752288294349442e-31],[-.001851851851851852,-.003472222222222222,.0026455026455026454,-.0009902263374485596,.00020576131687242798,-4018775720164609e-22,-18098550334489977e-21,764916091608111e-20,-16120900894563446e-22,4647127802807434e-24,1378633446915721e-22,-5752545603517705e-23,11951628599778148e-24,-17543241719747647e-27,-10091543710600413e-25,4162792991842583e-25,-856390702649298e-25,6067215101604758e-29,71624989648114856e-28,-2933186643771437e-27,5996696365683689e-28,-21671786527323313e-32,-4978339972369262e-29,20291628823713425e-30,-413125571381061e-29],[.004133597883597883,-.0026813271604938273,.0007716049382716049,20093878600823047e-22,-.00010736653226365161,52923448829120125e-21,-12760635188618728e-21,3423578734096138e-23,13721957309062932e-22,-6298992138380055e-22,14280614206064242e-23,-20477098421990866e-26,-1409252991086752e-23,6228974084922022e-24,-13670488396617112e-25,9428356159014678e-28,12872252400089318e-26,-55645956134363323e-27,1197593554636698e-26,-41689782251838634e-31,-10940640427884595e-28,4662239946390136e-28,-9905105763906907e-29,18931876768373515e-33,8859221872591127e-30],[.0006494341563786008,.00022947209362139917,-.0004691894943952557,.00026772063206283885,-7561801671883977e-20,-2396505113867297e-22,11082654115347302e-21,-56749528269915965e-22,14230900732435883e-22,-27861080291528143e-27,-16958404091930278e-23,8099464905388083e-23,-19111168485973655e-24,23928620439808118e-28,20620131815488797e-25,-9460496661855133e-25,21541049775774907e-26,-1388823336813903e-29,-21894761681963938e-27,9790998951171684e-27,-2178219188018096e-27,6208819573407901e-32,2126978363279737e-28,-9344688791517433e-29,2045367122678285e-29],[-.0008618882909167117,.0007840392217200666,-.0002990724803031902,-14638452578843418e-22,6641498215465122e-20,-3968365047179435e-20,11375726970678419e-21,2507497226237533e-25,-16954149536558305e-22,8907507532205309e-22,-2292934834000805e-22,2956794137544049e-26,28865829742708783e-24,-14189739437803219e-24,34463580499464896e-25,-23024517174528067e-29,-39409233028046403e-26,186023389685045e-24,-4356323005056618e-26,1278600101629623e-30,467927502665792e-26,-2149246470613483e-27,4908815614809652e-28,-633859148489156e-32,-5045332069080094e-29],[-.00033679855336635813,-6972813758365858e-20,.0002772753244959392,-.00019932570516188847,6797780477937208e-20,1419062920643967e-22,-13594048189768693e-21,8018470256334202e-21,-2291481176508095e-21,-3252473551298454e-25,34652846491085265e-23,-18447187191171344e-23,48240967037894184e-24,-17989466721743514e-30,-6306194500013523e-24,3162417628774568e-24,-7840924253697429e-25,5192679165254041e-30,9358944242306784e-26,-4513426216163278e-26,10799129993116828e-27,-3661886712685252e-32,-1210902069055155e-27,5680743584990564e-28,-13249659916340829e-29],[.0005313079364639922,-.0005921664373536939,.0002708782096718045,7902353232660328e-22,-8153969367561969e-20,561168275310625e-19,-18329116582843375e-21,-30796134506033047e-25,3465155368803609e-21,-20291327396058603e-22,5788792863149004e-22,2338630673826657e-28,-8828600746330484e-23,47435958880408125e-24,-12545415020710382e-24,8649648858010293e-29,16846058979264062e-25,-8575492823577594e-25,21598224929232125e-26,-7613230520476153e-31,-26639822008536144e-27,13065700536611057e-27,-31799163902367977e-28,4710976121367431e-33,36902800842763465e-29],[.00034436760689237765,5171790908260592e-20,-.00033493161081142234,.0002812695154763237,-.00010976582244684731,-12741009095484485e-23,27744451511563645e-21,-18263488805711332e-21,57876949497350525e-22,493875893393627e-24,-10595367014026043e-22,6166714376110408e-22,-17562973359060463e-23,-1297447328701544e-27,2695423606288966e-23,-14578352908731272e-24,3887645959386175e-24,-3881002251019412e-32,-5327994173877286e-25,27437977643314844e-26,-6995796092070568e-26,2589986387486848e-32,8856689099669639e-27,-4403168815871311e-27,10865561947091654e-28],[-.0006526239185953094,.0008394987206720873,-.000438297098541721,-6969091458420552e-22,.00016644846642067547,-.00012783517679769218,4629953263691304e-20,4557909867922708e-24,-10595271125805195e-21,6783342904865167e-21,-21075476666258803e-22,-17213731432817144e-27,3773587741611098e-22,-21867506700122867e-23,6220228804018927e-23,6597703826733e-28,-9590386497425686e-24,5213214492280807e-24,-13991589583935709e-25,5382058999060575e-31,19484714275467745e-26,-10127287556389682e-26,26077347197254926e-27,-5090418699993299e-33,-33721464474854593e-28],[-.0005967612901927463,-7204895416020011e-20,.0006782308837667328,-.0006401475260262758,.00027750107634328704,1819700838046515e-22,-8479507117068503e-20,6105192082501531e-20,-21073920183404862e-21,-8858589014125599e-25,45284535953805374e-22,-28427815022504407e-22,8708234177864641e-22,36886101871706966e-28,-1534469519070206e-22,8862466778790695e-23,-25184812301826817e-24,-10225912098215092e-30,3896947075815478e-24,-21267304792235634e-25,5737013552805138e-25,-1887749850169741e-34,-8093153869465787e-26,423827232834492e-25,-11002224534207727e-27],[.0013324454494800656,-.0019144384985654776,.0011089369134596636,99324041226423e-20,-.0005087450129309319,.00042735056665392886,-.000168588537679108,-81301893922785e-22,45284402370562144e-21,-3127053674781734e-20,1044986828530338e-20,48435226265680926e-27,-2148256587345626e-21,1329369701097492e-21,-4029569309210103e-22,-1756787766632329e-28,7014504316366825e-23,-4040787734999483e-23,11474026743371962e-24,39642746853563326e-34,-17804938269892715e-25,9748026254873165e-25,-26405338676507616e-26,5794875163403742e-33,3764774955354384e-26],[.001579727660730835,.00016251626278391583,-.0020633421035543276,.00213896861856891,-.0010108559391263003,-399127055299192e-21,.0003623502508476469,-.00028143901463712157,.00010449513336495887,212114184918303e-23,-25779417251947842e-21,17281818956040464e-21,-5641377387290428e-21,-11024320105776174e-27,11223224418895176e-22,-6869339637952674e-22,20653236975414888e-23,46714772409838506e-30,-35609886164949055e-24,20470855345905963e-24,-5809173863328336e-24,-1332821287582869e-31,9035460439133513e-25,-4959878251733084e-25,13481607129399748e-26],[-.004072512119514016,.00640336283380807,-.004041016108167662,-2183732802866233e-21,.002174044180125464,-.001970044051841889,.0008359546974796246,19445447567109655e-24,-.000257793871204217,.00019009987368139304,-6769649993743896e-20,-14440629666426571e-26,15712512518742267e-21,-10304008744776892e-21,3304517767401387e-21,7982976024232571e-28,-64097794149313e-20,38894624761300054e-23,-1161834764494887e-22,-2816808630596451e-30,19878012911297094e-24,-11407719956357511e-24,32355857064185554e-25,4175946829345594e-35,-5042311271810582e-25],[-.0059475779383993,-.0005401647678926045,.00879104135507679,-.009857631558785612,.005013469503102154,12807521786221875e-22,-.0020626019342754685,.0017109128573523059,-.000676953127141338,-6901154567656214e-24,.00018855128143995903,-.0001339521566349197,4626318303352804e-20,4003423061332135e-26,-10255652921494033e-21,6612086372797651e-21,-20913022027253007e-22,-20951775649603836e-29,3975602904199325e-22,-2395621197881589e-22,7118288338214586e-23,8925574873053455e-31,-12101547235064675e-24,6935061824833439e-24,-196614644538561e-23],[.01740202778752271,-.029527880945699123,.020045875571402798,70289515966903405e-22,-.012375421071343148,.011976293444235253,-.0054156038466518525,-6329089339641862e-23,.0018855118129005065,-.001473473274825001,.0005551581009770838,5240683441255066e-25,-.00014357913535784837,991812932249433e-19,-3346083474947831e-20,-3575583729109899e-27,71560851960630075e-22,-4551680262815553e-21,14236576649271474e-22,18803149082089665e-30,-2662340389892921e-22,15950642189595716e-23,-471875146738411e-22,-6510787295875518e-32,7979509102674624e-24],[.03024912416090589,.0024817436002649977,-.049939134373457025,.05991564300930787,-.03248320760162339,-5721296865210344e-21,.015085251778569354,-.013261324005088445,.0055515262632426145,3026318225703001e-23,-.0017229548406756724,.0012893570099929638,-.00046845138348319875,-1830259937893045e-25,.00011449739014822654,-7737856522124447e-20,25625836246985202e-21,10766165333192815e-28,-5324680928242262e-21,3349634863064464e-21,-10381253128684019e-22,-5608909920621128e-30,19150821930676592e-23,-11418365800203487e-23,33654425209171787e-24],[-.09905102088015905,.17954011706123485,-.12989606383463778,-31478872752284355e-21,.09051063527684813,-.0928288244111844,.04441211283987781,27779236316835886e-23,-.017229543805449696,.014182925050891573,-.005621416163374734,-239598509186381e-23,.0016029634366079909,-.0011606784674435774,.00041001337768153875,1836580075409066e-26,-958442565636559e-19,6364306233776471e-20,-2076250624489065e-20,-11806020912804483e-29,4213180823912065e-21,-2626224133701247e-21,8077062049493066e-22,6012591212363273e-31,-1472973737401884e-22],[-.19994542198219728,-.015056113040026424,.36470239469348487,-.4643519231173355,.26640934719197895,3403826602714719e-20,-.13784338709329624,.1276467178337056,-.056213828755200985,-1753150885483011e-22,.019235592956768112,-.015088821281095314,.005740185445135012,10622382710310225e-25,-.0015335082692563998,.0010819320643228215,-.0003737251019394566,-6617090972903199e-27,8426361738090962e-20,-5515070682748348e-20,1776953644834807e-20,3882792321020553e-29,-353513697488768e-20,2186583213004527e-21,-668128494476256e-21],[.7243860850402943,-1.3918010932653375,1.0654143352413967,.0001876173868950258,-.827055011761527,.8935243334782842,-.44971003995291337,-16107401567546651e-22,.1923559016527109,-.1659770216004261,.06888222268181433,13910091724608687e-24,-.02146911561508663,.016228980898865892,-.005979601617258426,-11287469112826745e-26,.0015167451119784856,-.00104786342935539,.0003553907288912642,8170432211180152e-28,-777730134424524e-19,5029141389700772e-20,-16035083867000518e-21,12469354315487606e-30,31369106244517616e-22],[1.6668949727276812,.1165462765994632,-3.3288393225018904,4.469232548286404,-2.6977693045875806,-.0002600667859891061,1.5389017615694538,-1.4937962361134611,.6888196463323315,13077482004552384e-22,-.2576296332559629,.21097676102125448,-.08371440835921988,-7792042888135476e-24,.0242679230648336,-.017813678334552312,.006397033038890006,4943080709048052e-26,-.0015554602758465635,.0010561196919903215,-.000352771844604729,9300233464502246e-29,7528585502655717e-20,-4818651556915635e-20,15227271505597605e-21],[-6.618829886137293,13.397985455142589,-10.789350606845145,-.0014352254537875018,9.23336945961898,-10.456552819547769,5.510552602903347,12024439690716742e-21,-2.5762961164755818,2.320744274538718,-1.0045728797216285,-10207833290021913e-23,.3397509217116947,-.2672051745075747,.10235252851562705,8432973048487163e-25,-.027998284958442594,.020066274144976814,-.007055436891508624,19402238183698188e-28,.0016562888105449611,-.0011082898580743682,.0003654545161310169,-5129003202697179e-26,-7634010369686903e-20],[-17.112706061976095,-1.1208044642899115,37.131966511885445,-52.29827102534896,33.058589696624615,.002479129897620022,-20.61089403411526,20.88672775145582,-10.045703956517752,-12238783449063012e-21,4.077013427422114,-3.473667358470195,1.4329352617312006,7135991441187971e-23,-.4479725715911561,.3411266608064446,-.12699786326594922,-2895367726908153e-25,.03312577627825986,-.023274087021036102,.008039999350364889,-1177805216235265e-24,-.001832162489107167,.0012108282933588664,-.0003947994124682252],[73.89033153567425,-156.80141270402274,132.2177542759164,.013692876877324546,-123.66496885920151,146.2068939106273,-80.36558772486535,-.00011259851148881298,40.77013219617994,-38.21034001327303,17.19522294277362,9351970795516835e-22,-6.271615990774704,5.116899907185264,-2.0319658112299095,-4950721558276154e-24,.596263972943326,-.44220765337238094,.16079998700166273,-24733786203223403e-24,-.040307574759979765,.02784905074709787,-.009475185899205422,6419922235909132e-21,.002125018077469946],[212.1683709838252,13.107863022633868,-496.9828593287175,731.215952669692,-482.1382172089085,-.028817248692894887,326.167203029471,-343.8934028008712,171.95193870816232,.00014038077378096157,-75.2594195897599,66.51969984520935,-28.447519748152462,-7613702615875392e-22,9.540223710530437,-7.517530111331138,2.894399756887196,-466121949995382e-21,-.8061514959879409,.5848300657063102,-.20845408972964957,.00014765818959305816,.05100043386375302,-.03306625214188366,.015109265210467774],[-989.5964309832236,2192.555536090523,-1928.3586782723355,-.15925738122215252,1956.9985945919857,-2407.2514765081555,1375.6149959336497,.0012920735237496668,-752.5941715948055,731.7166874220871,-341.37023466220063,-9985739026060805e-21,133.56313181291574,-112.76295161252794,46.31039609820446,-7923738713361476e-21,-14.510726927018647,11.111771248100563,-4.169081794527089,.0031008219800117806,1.1220095449981469,-.7605237992614992,.36262236505085255,.2216867741940747,.48683443692930506]];var V1=1e7,W3=20,B1=200,$3=.3,x3=4.5,m6=4503599627370496,X1=2220446049250313e-31;function Z3(e,t,n){let o=e5(e,t);return n?b1(e,t,!0)+Math.log(o):b1(e,t,!1)*o}function J3(e,t){let n=e5(e,t),o=k0(e,t);return[o[0]+Math.log(n),o[1]*n]}function e5(e,t){if(e>1e3&&t>.97*e)return p6(e,t);let n=e,o=1,r=1;for(let s=0;s<V1&&(n+=1,o*=t/n,r+=o,!(o<=G*r));s++);return r}var N6=2**-64;function p6(e,t){let n=1,o=0,r=1,s=0;for(let c=1;c<V1;c++){let i=e+c,u=i-e,l=e-(i-u)+(c-u),a=t/i,f=134217729*a,p=f-(f-a),g=a-p;f=134217729*i;let v=f-(f-i),y=i-v,b=a*i,R=p*v-b+p*y+g*v+g*y,P=(t-b-R-a*l)/i;f=134217729*n;let C=f-(f-n),H=n-C,W=n*a,g1=C*p-W+C*g+H*p+H*g+(n*P+o*a);n=W+g1,o=g1-(n-W);let Q=r+n,r1=Q-r,I1=r-(Q-r1)+(n-r1)+(s+o);if(r=Q+I1,s=I1-(r-Q),n*a<=N6*r*(1-a))break}return r+s}function b6(e,t,n){let o=t5(e,t);return n?Math.log(e)+b1(e,t,!0)+Math.log(o):e*b1(e,t,!1)*o}function g6(e,t){let n=t5(e,t),o=k0(e,t);return[Math.log(e)+o[0]+Math.log(n),e*o[1]*n]}function t5(e,t){let n=1-e,o=t+n+1,r=0,s=1,c=t,i=t+1,u=o*t,l=i/u;for(let a=0;a<V1;a++){r+=1,n+=1,o+=2;let f=n*r,p=i*o-s*f,g=u*o-c*f,v;if(g!==0){let y=p/g;v=Math.abs((l-y)/y),l=y}else v=1;if(s=i,i=p,c=u,u=g,Math.abs(p)>m6&&(s*=X1,i*=X1,c*=X1,u*=X1),v<=G)break}return l}function n5(e,t){let n=1,o=0;for(let i=1;i<V1;i++){n*=-t/i;let u=n/(e+i);if(o+=u,Math.abs(u)<=G*Math.abs(o))break}let r=Math.log(t),s=e*r-J(e);return-Math.expm1(s)-e*Math.exp(s)*o}function H1(e,t,n){let o=n?-1:1,r=t/e,s=(t-e)/e,c;r>1?c=Math.sqrt(-2*O0(s)):r<1?c=-Math.sqrt(-2*O0(s)):c=0;let i=.5*q1(o*c*Math.sqrt(e/2)),u=new Array(25).fill(0);u[0]=1;let l=0,a=0,f=1,p=1/0;for(let g=0;g<25;g++){let v=Y3[g],y=v[0];for(let P=1;P<25;P++){P>l&&(u[P]=c*u[P-1],l+=1);let C=v[P]*u[P];if(y+=C,Math.abs(C)<G*Math.abs(y))break}let b=y*f,R=Math.abs(b);if(R>p||(a+=b,R<G*Math.abs(a)))break;p=R,f/=e}return i+=o*Math.exp(-.5*e*c*c)*a/Math.sqrt(2*Math.PI*e),i}function C0(e,t,n){if(t>1.1)return t<e?{lower:!0,value:Z3(e,t,n)}:{lower:!1,value:b6(e,t,n)};if(t<=.5?-.4/Math.log(t)<e:t*1.1<e)return{lower:!0,value:Z3(e,t,n)};let r=n5(e,t);return{lower:!1,value:n?Math.log(r):r}}function I6(e,t){if(t>1.1){let[r,s]=t<e?J3(e,t):g6(e,t);return{lower:t<e,log:r,lin:s}}if(t<=.5?-.4/Math.log(t)<e:t*1.1<e){let[r,s]=J3(e,t);return{lower:!0,log:r,lin:s}}let o=n5(e,t);return{lower:!1,log:Math.log(o),lin:o}}function F4(e,t,n){if(Number.isNaN(e)||Number.isNaN(t))return[NaN,NaN];if(t<0||e<0)return[NaN,NaN];if(e===0)return t>0?n?[0,1]:[-1/0,0]:[NaN,NaN];if(t===0)return n?[-1/0,0]:[0,1];if(e===1/0)return t===1/0?[NaN,NaN]:n?[-1/0,0]:[0,1];if(t===1/0)return n?[0,1]:[-1/0,0];if(t>1e15*Math.max(e,1)){let s=(e-1)*Math.log(t)-t-o1(e)+Math.log1p((e-1)/t);return n?[Math.log1p(-Math.exp(s)),-Math.expm1(s)]:[s,Math.exp(s)]}let o=Math.abs(t-e)/e;if(e>W3&&e<B1&&o<$3||e>B1&&o<x3/Math.sqrt(e)){let s=H1(e,t,n);return[s>.5?Math.log1p(-H1(e,t,!n)):Math.log(s),s]}let r=I6(e,t);return r.lower===n?[r.log,r.lin]:[r.lin>0?Math.log1p(-r.lin):-Math.exp(r.log),1-r.lin]}function R4(e,t,n,o){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(t<0||e<0)return NaN;let r=o?-1/0:0,s=o?0:1;if(e===0)return t>0?n?s:r:NaN;if(t===0)return n?r:s;if(e===1/0)return t===1/0?NaN:n?r:s;if(t===1/0)return n?s:r;if(t>1e15*Math.max(e,1)){let u=(e-1)*Math.log(t)-t-o1(e)+Math.log1p((e-1)/t);return n?o?Math.log1p(-Math.exp(u)):-Math.expm1(u):o?u:Math.exp(u)}let c=Math.abs(t-e)/e;if(e>W3&&e<B1&&c<$3||e>B1&&c<x3/Math.sqrt(e)){let u=H1(e,t,n);return o?u>.5?Math.log1p(-H1(e,t,!n)):Math.log(u):u}if(o){let u=C0(e,t,!0);if(u.lower===n)return u.value;let l=C0(e,t,!1).value;return l>0?Math.log1p(-l):-Math.exp(u.value)}let i=C0(e,t,!1);return i.lower===n?i.value:1-i.value}export{_ as a,N1 as b,q1 as c,G1 as d,k1 as e,Y6 as f,K6 as g,Z6 as h,G as i,w0 as j,q3 as k,X as l,D as m,o1 as n,J as o,S as p,B as q,u4 as r,f4 as s,a4 as t,b1 as u,O0 as v,e5 as w,p6 as x,t5 as y,F4 as z,R4 as A,D3 as B,a6 as C,l6 as D,U3 as E};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! rStats.js 0.
|
|
2
|
-
import{a as N,b as M,c as x,d as f,f as h,g as a,h as b}from"./chunk-
|
|
1
|
+
/*! rStats.js 0.8.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 N,b as M,c as x,d as f,f as h,g as a,h as b}from"./chunk-OHPHNE3O.js";var l=[.6931471805599453,23190468138462996e-33];function E(t){let r=t[0];if(!N())return[Math.exp(r),0];if(Number.isNaN(r))return[NaN,0];if(r>709.8)return[1/0,0];if(r<-708)return[Math.exp(r)*(1+t[1]),0];let e=Math.round(r/l[0]),n=h(t,b(l,e)),i=1024;n=[n[0]/i,n[1]/i];let u=n,o=n;for(let s=2;s<20&&(u=a(u,n),u=[u[0]/s,u[1]/s],o=f(o,u),!(Math.abs(u[0])<1e-36));s++);for(let s=0;s<10;s++)o=a(o,f(o,[2,0]));let p=f(o,[1,0]),c=Math.trunc(e/2),d=2**c,m=2**(e-c);return[p[0]*d*m,p[1]*d*m]}function L(t,r,e){let n=t-r;if(!Number.isFinite(n))return[n/e,0];let i=r===0?[t,0]:M(t,-r);if(e===1)return i;let u=i[0]/e;if(!Number.isFinite(u)||u===0)return[u,0];let o=h(i,g(e,u)),p=(o[0]+o[1])/e;return M(u,p)}function g(t,r){let e=t*r;return!Number.isFinite(e)||Math.abs(t)>1e300||Math.abs(r)>1e300?[e,0]:x(t,r)}function D(t){return t[0]>708?Math.exp(700-t[0])*(1-t[1])*Math.exp(-700):Math.exp(-t[0])*(1-t[1])}function S(t){return t>-Math.LN2?Math.log(-Math.expm1(t)):Math.log1p(-Math.exp(t))}function k(t){return t[0]>Math.LN2?Math.log1p(-D(t)):Math.log(-Math.expm1(-(t[0]+t[1])))}function q(t,r,e){let n=g(r,e);if(!Number.isFinite(n[0])||!Number.isFinite(t))return t+n[0];let i=f(n,[t,0]);return i[0]+i[1]}export{E as a,L as b,g as c,D as d,S as e,k as f,q as g};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! rStats.js 0.
|
|
2
|
-
import{a as d,b as m,c as p}from"./chunk-
|
|
1
|
+
/*! rStats.js 0.8.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 d,b as m,c as p}from"./chunk-VIPSPG3Y.js";import{d as g,g as x}from"./chunk-OHPHNE3O.js";function c(s,r){let e=Array.from(s);return r?e.filter(t=>!Number.isNaN(t)):e.some(Number.isNaN)?void 0:e}function b(s){if(!s.every(Number.isFinite))return s.reduce((e,t)=>e+t,0);let r=[0,0];for(let e of s)r=g(r,[e,0]);return r[0]+r[1]}function D(s,r={}){let e=c(s,r.naRm);return e===void 0?NaN:b(e)}function F(s,r={}){let e=c(s,r.naRm);if(e===void 0)return NaN;if(!e.every(Number.isFinite)||e.includes(0))return e.reduce((o,u)=>o*u,1);let t=[1,0],n=0;for(let o of e){t=x(t,[o,0]);let u=Math.floor(Math.log2(Math.abs(t[0])));if(u>500||u<-500){let f=2**-u;t=[t[0]*f,t[1]*f],n+=u}}return v(t,n)}function I(s,r={}){let e=c(s,r.naRm);if(e===void 0)return NaN;let t=e.length;if(t===0)return NaN;let n=r.trim??0;if(Number.isNaN(n))throw new RangeError("'trim' must be numeric of length one");if(n>0&&t>0){if(n>=.5)return M(e);n=Math.max(n,0);let o=Math.floor(t*n),u=[...e].sort((f,a)=>f-a);return m(u.slice(o,t-o))}return m(e)}function O(s,r,e={}){let t=Array.from(s),n=Array.from(r);if(t.length!==n.length)throw new RangeError("'x' and 'w' must have the same length");if(e.naRm){let u=t.map(f=>!Number.isNaN(f));t=t.filter((f,a)=>u[a]),n=n.filter((f,a)=>u[a])}let o=[];for(let u=0;u<t.length;u++)n[u]!==0&&o.push(t[u]*n[u]);return b(o)/b(n)}function q(s,r={}){let e=c(s,r.naRm);return e===void 0?NaN:p(e)}function _(s,r={}){return Math.sqrt(q(s,r))}function M(s,r={}){let e=c(s,r.naRm);if(e===void 0)return NaN;let t=e.length;if(t===0)return NaN;let n=[...e].sort((u,f)=>u-f),o=Math.floor(t/2);return t%2===1?n[o]:d([n[o-1],n[o]])[0]}function j(s,r={}){let e=c(s,r.naRm);if(e===void 0)return[NaN,NaN];let t=1/0,n=-1/0;for(let o of e)o<t&&(t=o),o>n&&(n=o);return[t,n]}function S(s){let r=[],e=[0,0],t=0,n=!0;for(let o of Array.from(s))t+=o,n&&Number.isFinite(o)?(e=g(e,[o,0]),r.push(e[0]+e[1])):(n=!1,r.push(Number.isNaN(o)||Number.isNaN(t)?NaN:t));return r}function T(s){let r=[],e=[1,0],t=0,n;for(let o of Array.from(s)){if(n===void 0&&(!Number.isFinite(o)||o===0)&&(n=v(e,t)),n!==void 0){n*=o,r.push(n);continue}e=x(e,[o,0]);let u=Math.floor(Math.log2(Math.abs(e[0])));(u>500||u<-500)&&(e=[e[0]*2**-u,e[1]*2**-u],t+=u),r.push(v(e,t))}return r}function v(s,r){let e=s[0]+s[1];for(;r>0&&Number.isFinite(e);){let t=Math.min(r,1e3);e*=2**t,r-=t}for(;r<0&&e!==0;){let t=Math.max(r,-1e3);e*=2**t,r-=t}return e}function y(s,r){let e=[],t=NaN,n=!1;for(let o of Array.from(s)){if(n||Number.isNaN(o)){n=!0,e.push(NaN);continue}(e.length===0||r(o,t))&&(t=o),e.push(t)}return e}function z(s){return y(s,(r,e)=>r>e)}function B(s){return y(s,(r,e)=>r<e)}function C(s,r={}){let e=r.lag??1,t=r.differences??1;if(!(Number.isInteger(e)&&e>=1&&Number.isInteger(t)&&t>=1))throw new RangeError("'lag' and 'differences' must be integers >= 1");let n=Array.from(s);if(e*t>=n.length)return[];for(let o=0;o<t;o++){let u=[];for(let f=e;f<n.length;f++)u.push(n[f]-n[f-e]);n=u}return n}function R(s){let r=d(s),e=0,t=0,n=0;for(let o of s){let u=o-r[0]-r[1],f=u*u;e+=f,t+=f*u,n+=f*f}return[e,t,n]}function A(s){if(![1,2,3].includes(s))throw new RangeError("Invalid 'type' argument.")}function L(s,r={}){let e=r.type??3;A(e);let t=c(s,!0),n=t.length,[o,u]=R(t),f=Math.sqrt(n)*u/o**1.5;if(e===1)return f;if(e===2){if(n<3)throw new RangeError("Need at least 3 complete observations.");return f*Math.sqrt(n*(n-1))/(n-2)}return f*(1-1/n)**1.5}function P(s,r={}){let e=r.type??3;A(e);let t=c(s,!0),n=t.length,[o,,u]=R(t),f=n*u/(o*o);if(e===1)return f-3;if(e===2){if(n<4)throw new RangeError("Need at least 4 complete observations.");return((n+1)*(f-3)+6)*(n-1)/((n-2)*(n-3))}return f*(1-1/n)**2-3}function Q(s,r={}){let e=c(s,r.naRm);return e===void 0?NaN:e.some(t=>t<0)?NaN:e.includes(0)?0:Math.exp(m(e.map(Math.log)))}function U(s){let r=c(s,!0),e=new Map;for(let o of r)e.set(o===0?0:o,(e.get(o===0?0:o)??0)+1);let t=0;for(let o of e.values())t=Math.max(t,o);return t<=1?{value:[NaN],frequency:NaN}:{value:[...e.entries()].filter(([,o])=>o===t).map(([o])=>o).sort((o,u)=>o-u),frequency:t}}function V(s,r={}){let e=c(s,!0),t=r.center??"mean",n=t==="mean"?m(e):t==="median"?M(e):t;return m(e.map(o=>Math.abs(o-n)))}function W(s,r={}){let e=c(s,r.naRm);if(e===void 0)return NaN;let t=e.length,n=Math.sqrt(p(e))/m(e);return r.unbiased&&(n*=1-1/(4*(t-1))+n*n/t+1/(2*(t-1)**2)),n}function X(s,r={}){let e=s.length>0&&Array.isArray(s[0])?s.map(a=>[...a]):Array.from(s,a=>[a]),t=e[0]?.length??0,n=a=>e.map(l=>l[a]),o={scaled:e},u=r.center??!0;if(u!==!1){let a=u===!0?Array.from({length:t},(l,i)=>m(n(i).filter(N=>!Number.isNaN(N)))):[...u];if(a.length!==t)throw new RangeError("length of 'center' must equal the number of columns of 'x'");for(let l of e)for(let i=0;i<t;i++)l[i]=l[i]-a[i];o.center=a}let f=r.scale??!0;if(f!==!1){let a=f===!0?Array.from({length:t},(l,i)=>{let N=n(i).filter(h=>!Number.isNaN(h)),w=0;for(let h of N)w+=h*h;return Math.sqrt(w/Math.max(1,N.length-1))}):[...f];if(a.length!==t)throw new RangeError("length of 'scale' must equal the number of columns of 'x'");for(let l of e)for(let i=0;i<t;i++)l[i]=l[i]/a[i];o.scale=a}return o}export{c as a,D as b,F as c,I as d,O as e,q as f,_ as g,M as h,j as i,S as j,T as k,z as l,B as m,C as n,L as o,P as p,Q as q,U as r,V as s,W as t,X as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! rStats.js 0.8.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 v,b as I,c as x,d as L,e as q,f as U,g as Q,h as qt,i as Yn,j as Bt,u as J,v as Tn,w as bt}from"./chunk-LXMMKO26.js";import{a as H,b as D,c as gt}from"./chunk-MJQLKEO5.js";import{A as j,D as P,E as Zn,a as kt,e as b,g as pt,h as S,j as nn,l as Xn,n as Y,o as Rt,p as Ct,q as St,s as T,t as at,u as C,z as $n}from"./chunk-3I6EKGB6.js";import{b as w,c as $,d as F,e as ft,f as Vn,g as R,h as tn,i as _,j as dt,k as O}from"./chunk-OHPHNE3O.js";function be(n,t){let r=[.213623493715853,4.28342155967104,11.6616720288968,3.31125922108741],e=[.03611708101884203,1.27364489782223,6.40691597760039,6.61053765625462,1],i=n<.5?Math.sqrt(-2*Math.log(n)):Math.sqrt(-2*Math.log(t)),o=i-kt(i,r)/kt(i,e);return n<.5?-o:o}function ye(n,t,r,e){let i=1;if(r>=1){let o=t/(n+1);i+=o;for(let u=2;u<=r&&(o*=t/(n+u),i+=o,!(o<e));++u);}return i}function Pn(n,t){let r=(n-1)*Math.log(t),e=r*r,i=e*r,o=e*e,u=n*n,s=u*n,a=(n-1)*(1+r),c=(n-1)*(-(e/2)+(n-2)*r+(3*n-5)/2),f=(n-1)*(i/3-(3*n-5)*e/2+(u-6*n+7)*r+(11*u-46*n+47)/6),l=(n-1)*(-(o/4)+(11*n-17)*i/6+(-3*u+13*n-13)*e+(2*s-25*u+72*n-61)*r/2+(25*s-195*u+477*n-379)/12),N=t*t,h=N*t,m=N*N;return t+r+a/t+c/N+f/h+l/m}function rn(n,t,r){if(n===1)return r>.9?-Math.log1p(-t):-Math.log(r);if(n<1){let M=Xn(n),p=r*M;if(p>.6||p>=.45&&n>=.3){let d=p*r>1e-8&&r>1e-5?Math.pow(t*M*n,1/n):Math.exp(-r/n-nn);return d/(1-d/(n+1))}if(n<.3&&p>=.35){let d=Math.exp(-nn-p),y=d*Math.exp(d);return d*Math.exp(y)}if(p>.15||n>=.3){let d=-Math.log(p),y=d-(1-n)*Math.log(d);return d-(1-n)*Math.log(y)-Math.log(1+(1-n)/(1+y))}if(p>.1){let d=-Math.log(p),y=d-(1-n)*Math.log(d);return d-(1-n)*Math.log(y)-Math.log((y*y+2*(3-n)*y+(2-n)*(3-n))/(y*y+(5-n)*y+2))}return Pn(n,-Math.log(p))}let e=be(t,r),i=e*e,o=i*e,u=i*i,s=u*e,a=Math.sqrt(n),c=n+e*a+(i-1)/3;if(c+=(o-7*e)/(36*a),c-=(3*u+7*i-16)/(810*n),c+=(9*s+256*o-433*e)/(38880*n*a),n>=500&&Math.abs(1-c/n)<1e-6)return c;if(t>.5){if(c<3*n)return c;let M=Math.max(2,n*(n-1)),p=Math.log(r)+Y(n);if(p<-M*2.3)return Pn(n,-p);let d=-p+(n-1)*Math.log(c)-Math.log(1+(1-n)/(1+c));return-p+(n-1)*Math.log(d)-Math.log(1+(1-n)/(1+d))}let f=c,l=n+1,N=n+2;if(c<.15*l){let M=Math.log(t)+Y(l);f=Math.exp((M+c)/n),e=Math.log1p(f/l*(1+f/N)),f=Math.exp((M+f-e)/n),e=Math.log1p(f/l*(1+f/N)),f=Math.exp((M+f-e)/n),e=Math.log1p(f/l*(1+f/N*(1+f/(n+3)))),f=Math.exp((M+f-e)/n)}if(f<=.01*l||f>.7*l)return f;let h=Math.log(ye(n,f,100,1e-4)),m=Math.log(t)+Y(l);return f=Math.exp((m+f-h)/n),f*(1-(n*Math.log(f)-f-m+h)/(n-f))}function en(n){let{rate:t,scale:r}=n;if(t!==void 0&&r!==void 0){if(Math.abs(t*r-1)>=1e-15)throw new RangeError("rate and scale can both be given only when scale = 1 / rate");return r}return r!==void 0?r:t!==void 0?1/t:1}function Ie(n,t){if(t<1){let r=C(t,n,!0),e=t/n;return r+(Number.isFinite(e)?Math.log(e):Math.log(t)-Math.log(n))}return C(t-1,n,!0)}function ct(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(t<0||r<=0)return NaN;if(n<0)return x(e);if(t===0)return n===0?1/0:x(e);if(n===0)return t<1?1/0:t>1?x(e):e?-Math.log(r):1/r;if(t<1){let o=C(t,n/r,e);if(e){let u=t/n;return o+(Number.isFinite(u)?Math.log(u):Math.log(t)-Math.log(n))}return o*t/n}let i=C(t-1,n/r,e);return e?i-Math.log(r):i/r}function Wt(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(t<0||r<=0)return NaN;let o=n/r;return Number.isNaN(o)?o:t===0?o<=0?v(e,i):I(e,i):o<=0?v(e,i):j(t,o,e,i)}function ve(n,t,r,e){let{lower:i,logTarget:o,linearTarget:u}=q(n,r,e),s=j(t,Number.MIN_VALUE,i,!0);if(i?s>=o:s<=o)return 0;let a;if(t>1&&o<=-700){let c=S(o,{lowerTail:i,logP:!0}),f=1-1/(9*t)+c/Math.sqrt(9*t);a=f>0?t*f*f*f:t*.001}else if(o>-700){let c=Math.exp(o),f=-Math.expm1(o);a=i?rn(t,c,f):rn(t,f,c)}else if(i)a=Math.exp((o+Rt(t))/t);else{a=-o;for(let c=0;c<3;c++)a=-o-Y(t)+(t-1)*Math.log(a)}return U({logTarget:o,...u!==void 0&&{linearTarget:u},lower:i,cdf:(c,f)=>j(t,c,f,!1),cdfLog:(c,f)=>j(t,c,f,!0),cdfBoth:(c,f)=>$n(t,c,f),pdfLog:c=>Ie(c,t),dlogPdf:c=>(t-1)/c-1,x0:a,lo:0,hi:1/0,positive:!0})}function nt(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;let o=L(n,0,1/0,e,i);return o!==void 0?o:t<0||r<=0?NaN:t===0?0:ve(n,t,e,i)*r}function io(n,t,r={}){let e=en(r),i=r.log??!1;return b(n,o=>ct(o,t,e,i))}function oo(n,t,r={}){let e=en(r),{lowerTail:i=!0,logP:o=!1}=r;return b(n,u=>Wt(u,t,e,i,o))}function uo(n,t,r={}){let e=en(r),{lowerTail:i=!0,logP:o=!1}=r;return b(n,u=>nt(u,t,e,i,o))}var yt=8*Number.EPSILON,Jn=2*Number.EPSILON,xe=1e-290;function K(n){let{p:t,lowerTail:r,logP:e,cdf:i,lo:o,hi:u}=n,s;if(e||t<xe){let l;e?l=r?t*(1+Jn):t*(1-Jn):l=Math.log(t)+Math.log1p(r?-yt:yt),s=r?N=>i(N,!0,!0)>=l:N=>i(N,!1,!0)<=l}else{let l;if(r?l=t*(1-yt):l=1-t>4*yt?t*(1+yt):t,l>.5){let N=1-l;s=r?h=>i(h,!1,!1)<=N:h=>i(h,!0,!1)>=N}else s=r?N=>i(N,!0,!1)>=l:N=>i(N,!1,!1)<=l}let a=Math.round(n.y0);if(Number.isFinite(a)||(a=o),a=Math.min(Math.max(a,o),u),s(a)){let l=1,N=a-l;for(;N>=o&&s(N);)a=N,l*=2,N=a-l;if(N<o){if(a===o)return o;N=o-1}return zn(N,a,s)}let c=1,f=a+c;for(;f<=u&&!s(f);)a=f,c*=2,f=a+c;return f>u&&(f=u),zn(a,f,s)}function zn(n,t,r){for(;t-n>1;){let e=Math.floor(n+(t-n)/2);if(e===n||e===t)break;r(e)?t=e:n=e}return t}var Ot=H;function Fe(n,t,r){return Number.isNaN(n)||Number.isNaN(t)?NaN:t<0?NaN:Ot(n)?x(r):n<0||!Number.isFinite(n)?x(r):C(Math.round(n),t,r)}function Le(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t))return NaN;if(t<0)return NaN;if(n<0)return v(r,e);if(t===0)return I(r,e);if(!Number.isFinite(n))return I(r,e);let i=Math.floor(n+1e-7);return j(i+1,t,!r,e)}function Ee(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t))return NaN;if(!Number.isFinite(t)||t<0)return NaN;let i=L(n,0,1/0,r,e);if(i!==void 0)return t===0&&!Number.isNaN(i)?0:i;if(t===0)return 0;let o=Math.sqrt(t),u=S(n,{lowerTail:r,logP:e}),s=t+o*(u+(u*u-1)/(6*o));return K({p:n,lowerTail:r,logP:e,cdf:(a,c,f)=>j(a+1,t,!c,f),y0:Number.isFinite(s)?s:t,lo:0,hi:1/0})}function po(n,t,r={}){let e=r.log??!1;return b(n,i=>Fe(i,t,e))}function go(n,t,r={}){let{lowerTail:e=!0,logP:i=!1}=r;return b(n,o=>Le(o,t,e,i))}function bo(n,t,r={}){let{lowerTail:e=!0,logP:i=!1}=r;return b(n,o=>Ee(o,t,e,i))}var _e=1e-17,Ae=Math.log(_e),kn=2e7,un=500,on=2**un,It=2**-un,we=2**250,De=2**-250,sn=un*Math.LN2,Lt={h:0,l:0,k:0};function Z(n,t,r,e=!1){if(n===0)return Lt;if(!Number.isFinite(n))return{h:n,l:0,k:r};for(;Math.abs(n)>we;)n*=It,t*=It,r++;for(;Math.abs(n)<De;)n*=on,t*=on,r--;return e?{h:n,l:t,k:r,approx:e}:{h:n,l:t,k:r}}var Re=[346.5735902799727,-22599635089223323e-30];function Ht(n,t){if(n>1e-305||Number.isNaN(n))return Z(n,0,0);let r=t(),[e,i]=typeof r=="number"?[r,0]:r;if(e===-1/0)return Lt;if(Number.isNaN(e))return{h:NaN,l:0,k:0};let o=Math.round(e/sn),u=F([e,i],R(Re,[-o,0])),s=Math.exp(u[0]);return typeof r=="number"?Z(s,0,o,!0):Z(s,s*u[1],o)}function fn(n,t){if(n===0)return[-t,0];let r=22250738585072014e-324;if(n<=t*r||t<n*r||!Number.isFinite(n))return F(R(O([t,0]),[n,0]),[-t-Rt(n),0]);let e=F(St(n,[t,0]),[Ct(n),0]);return F([-e[0],-e[1]],[-.5*(Ce+Math.log(n)),0])}var Ce=1.8378770664093456;function z(n,t){return n.approx===!0&&xt(n)>-700?t():n}function rt(n,t){return vt(n,Z(t[0],t[1],0))}function Se(n,t){if(n.h===0)return Lt;let r=Z(t[0],t[1],0),e=_([n.h,n.l],[r.h,r.l]);return Z(e[0],e[1],n.k-r.k,n.approx)}function tr(n,t,r){let e=rt(n,t.ratio(r));return t.ratioK?{...e,k:e.k+t.ratioK}:e}function nr(n,t,r){let e=Se(n,t.ratio(r));return t.ratioK?{...e,k:e.k-t.ratioK}:e}function vt(n,t){if(n.h===0||t.h===0)return Lt;let r=R([n.h,n.l],[t.h,t.l]);return Z(r[0],r[1],n.k+t.k,n.approx===!0||t.approx===!0)}function Ut(n,t,r,e){for(let i=r;i<e&&n!==0;i++)n*=It,t*=It;return[n,t]}function rr(n,t){if(n.h===0)return t;if(t.h===0)return n;let r=Math.max(n.k,t.k),e=F(Ut(n.h,n.l,n.k,r),Ut(t.h,t.l,t.k,r));return Z(e[0],e[1],r)}function xt(n){return n.h===0?-1/0:Math.log(n.h)+n.l/n.h+n.k*sn}var Ft=class{s=0;c=0;k=0;add(t){if(t.h===0)return;if(this.s===0&&this.c===0){this.s=t.h,this.c=t.l,this.k=t.k;return}t.k>this.k&&([this.s,this.c]=Ut(this.s,this.c,this.k,t.k),this.k=t.k);let[r,e]=Ut(t.h,t.l,t.k,this.k);this.addNum(r),this.addNum(e)}addNum(t){let r=this.s+t;Math.abs(this.s)>=Math.abs(t)?this.c+=this.s-r+t:this.c+=t-r+this.s,this.s=r}get log(){let t=this.s+this.c;return Number.isNaN(t)?NaN:t>0?Math.log(t)+this.k*sn:-1/0}get linear(){let t=this.s+this.c;for(let r=0;r<this.k;r++)t*=on;for(let r=0;r>this.k&&t!==0;r--)t*=It;return t}value(t){return t?this.log:this.linear}divideBy(t){let r=Z(t,0,0);this.s/=r.h,this.c/=r.h,this.k-=r.k}};function qe(n){let t=Math.floor(n),r=1;for(;;){if(r*=n/(t+1),r/(1-n/(t+2))<3e-21)return t;t++}}function Be(n){let t=Math.floor(n),r=1;for(;t>0;){if(r*=t/n,r/(1-(t-1)/n)<3e-21)return t;t--}return 0}function jt(n,t,r){if(r===-1/0||!(n<t))return!1;let e=n-t;return n+e-Math.log(-Math.expm1(e))<=Ae+r}function et(n,t){return Ht(C(n,t,!1),()=>fn(n,t))}function G(n,t){return Ht(n.inc(t,!1),()=>n.incLogDD?n.incLogDD(t):n.inc(t,!0))}function lt(n,t,r,e){return(r?fr(n,t):ar(n,t)).value(e)}function er(n,t,r){let e=r?fr(n,t):ar(n,t);return{lin:e.linear,log:e.log}}function ir(n,t,r,e){return C(r,t,!0)+n.cdf(r,e,!0)}function or(n,t,r){for(;r-t>2;){let i=Math.floor(t+(r-t)/3),o=Math.ceil(r-(r-t)/3);n(i)<n(o)?t=i:r=o}let e=t;for(let i=t+1;i<=r;i++)n(i)>n(e)&&(e=i);return e}var We=60;function ur(n,t,r,e){let i=n(t)-We;for(let o=1;;o*=2){let u=t+r*o;if(r>0?u>=e:u<=e)return e;if(n(u)<i)return u}}var sr=3e3;function fr(n,t){let r=qe(n);if(r>sr){let a=c=>ir(t,n,c,!0);r=ur(a,or(a,0,r),1,r)}let e=Ht(t.cdf(r,!0,!1),()=>t.cdf(r,!0,!0)),i=et(r,n),o=r>0?G(t,r-1):Lt,u=new Ft,s=-1/0;for(let a=r;a>=0;a--){let c=vt(i,e),f=xt(c);if(u.add(c),jt(f,s,u.log)||(s=f,a===0))break;e=rr(e,o),i=z(rt(i,dt([a,0],n)),()=>et(a-1,n)),a>=2&&(o=o.h===0?G(t,a-2):z(nr(o,t,a-1),()=>G(t,a-2)))}return u}function ar(n,t){let r=Be(n),e=!1;for(;;){let i=Ht(t.cdf(r,!1,!1),()=>t.cdf(r,!1,!0)),o=et(r,n),u=G(t,r),s=new Ft,a=-1/0,c=-1;for(let f=r;f<r+kn;f++){let l=vt(o,i),N=xt(l);if(s.add(l),jt(N,a,s.log)||N===-1/0&&f>n+50&&f>r+50)break;if(!e&&f-r>=sr&&N>=a){let h=d=>ir(t,n,d,!1),m=h(f),M=f+1;for(let d=1;h(M)>=m;d*=2)M=f+d;let p=ur(h,or(h,f,M),-1,f);if(e=!0,p>f){c=p;break}}a=N,i=rr(i,u),o=z(rt(o,dt([n,0],f+1)),()=>et(f+1,n)),u=u.h===0?G(t,f+1):z(tr(u,t,f+1),()=>G(t,f+1))}if(c<0)return s;r=c}}function Gt(n,t,r,e,i,o){let u=Number.isFinite(e)?Math.max(0,Math.round(e)):0,s=new Ft,a=et(u,n),c=G(t,u),f=a,l=c,N=-1/0;for(let h=u;h<u+kn;h++){let m=rt(vt(f,l),[r(h),0]),M=xt(m);if(s.add(m),jt(M,N,s.log)||M===-1/0&&h>n+50&&h>u+50)break;N=M,f=z(rt(f,dt([n,0],h+1)),()=>et(h+1,n)),l=l.h===0?G(t,h+1):z(tr(l,t,h+1),()=>G(t,h+1))}f=a,l=c,N=-1/0;for(let h=u-1;h>=0;h--){f=z(rt(f,dt([h+1,0],n)),()=>et(h,n)),l=l.h===0?G(t,h):z(nr(l,t,h+1),()=>G(t,h));let m=rt(vt(f,l),[r(h),0]),M=xt(m);if(s.add(m),jt(M,N,s.log))break;N=M}return s.divideBy(i),s.value(o)}function Oe(n){return n<=.5?[[n,0],w(1,-n)]:[w(1,-(1-n)),[1-n,0]]}function mr(n,t,r,e){let[i,o]=Oe(n),{e:u}=at(t,r,i,o),s=t*r/(t+r);if(!e&&u[0]<700&&n>1e-290&&o[0]>1e-290){let l=Math.exp(-u[0])*(1-u[1])*Math.sqrt(s/(2*Math.PI));if(l>1e-290&&l<1e290){let N=R(i,o);return l/N[0]*(1-N[1]/N[0])}}let a=n>1e-290&&o[0]>1e-290?O(R(i,o)):F(O(i),O(o)),c=s>1e-290&&s<1e290?.5*Math.log(s/(2*Math.PI)):.5*(Math.log(t)+Math.log(r)-Math.log(t+r)-Math.log(2*Math.PI)),f=F(ft(F(u,a)),[c,0]);return e?f[0]+f[1]:Math.exp(f[0])*(1+f[1])}function Ue(n,t,r,e){return mr(n,r,e,!0)}function an(n,t,r,e){return Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)?NaN:t<0||r<0?NaN:n<0||n>1?x(e):t===0||r===0||!Number.isFinite(t)||!Number.isFinite(r)?t===0&&r===0?n===0||n===1?1/0:x(e):t===0||r/t===1/0?n===0?1/0:x(e):r===0||t/r===1/0?n===1?1/0:x(e):n===.5?1/0:x(e):n===0?t>1?x(e):t<1?1/0:e?Math.log(r):r:n===1?r>1?x(e):r<1?1/0:e?Math.log(t):t:mr(n,t,r,e)}function cn(n,t,r,e,i){return Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)?NaN:t<0||r<0?NaN:n>=1?I(e,i):t===0||r===0||!Number.isFinite(t)||!Number.isFinite(r)?t===0&&r===0?i?-Math.LN2:.5:t===0||r/t===1/0?I(e,i):r===0||t/r===1/0?v(e,i):n<.5?v(e,i):I(e,i):n<=0?v(e,i):Q(t,r,n,1-n,e,i)}function ln(n,t,r,e){if(!(n>1&&t>1))return;let i=S(e,{logP:!0}),o=r?-i:i,u=1/(2*n-1),s=1/(2*t-1),a=2/(u+s),c=(o*o-3)/6;if(!(a+c>0))return;let f=o*Math.sqrt(a+c)/a-(s-u)*(c+5/6-2/(3*a)),l=n/(n+t*Math.exp(2*f));return l>0&&l<1?l:void 0}function cr(n,t,r,e,i){let o=Q(n,t,Number.MIN_VALUE,1,r,!0);if(r?o>=e:o<=e)return 0;let u=.25,s=1/0;if(r){let a=(e+Math.log(n)+P(n,t))/n;s=Math.exp(Math.max(a,-745)),u=Math.min(s,.25)}if(!(s<.001)){let a=ln(n,t,r,e);a!==void 0&&a<.5&&(u=a)}return U({logTarget:e,...i!==void 0&&{linearTarget:i},lower:r,cdf:(a,c)=>Q(n,t,a,1-a,c,!1),cdfLog:(a,c)=>Q(n,t,a,1-a,c,!0),cdfBoth:(a,c)=>Bt(n,t,a,1-a,c),pdfLog:a=>Ue(a,1-a,n,t),dlogPdf:a=>(n-1)/a-(t-1)/(1-a),x0:u,lo:0,hi:.5,positive:!0})}function Qt(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(t<0||r<0)return NaN;let o=L(n,0,1,e,i);if(o!==void 0)return o;if(t===0||r===0||!Number.isFinite(t)||!Number.isFinite(r)){if(t===0&&r===0){let l=i?n:Math.log(n),N=e?l:Math.log1p(-Math.exp(l));return N<-Math.LN2?0:N>-Math.LN2?1:.5}return t===0||r/t===1/0?0:r===0||t/r===1/0?1:.5}let{lower:u,logTarget:s,linearTarget:a}=q(n,e,i),c=Q(t,r,.5,.5,u,!0);return(u?s<=c:s>=c)?cr(t,r,u,s,a):1-cr(r,t,!u,s,a)}function qo(n,t,r,e={}){let{log:i=!1,ncp:o}=e;return o!==void 0?b(n,u=>lr(u,t,r,o,i)):b(n,u=>an(u,t,r,i))}function Bo(n,t,r,e={}){let{lowerTail:i=!0,logP:o=!1,ncp:u}=e;return u!==void 0?b(n,s=>Nr(s,t,r,u,i,o)):b(n,s=>cn(s,t,r,i,o))}function Wo(n,t,r,e={}){let{lowerTail:i=!0,logP:o=!1,ncp:u}=e;return u!==void 0?b(n,s=>hr(s,t,r,u,i,o)):b(n,s=>Qt(s,t,r,i,o))}function dr(n,t){let r=t<1e-250,e=r?t*2**500:t;return{ratioK:r?-1:0,cdf:(i,o,u)=>j(n+i,t,o,u),inc:(i,o)=>{let[u,s]=Mr(n,i,t);return o?C(u,t,!0)+s:C(u,t,!1)*(1+s)},ratio:i=>_([e,0],w(n,i)),incLogDD:i=>{let[o,u]=Mr(n,i,t);return F(fn(o,t),[u,0])}}}function Mr(n,t,r){let[e,i]=w(n,t);return[e,i===0?0:i*(Math.log(r)-gt(e+1))]}function pr(n,t){return n>=0&&t>=0&&Number.isFinite(n)&&Number.isFinite(t)}function gr(n,t,r,e){let i=r/2;if(i*(n/2)>1e18){let s=je(n,t,r);return e?{lin:-Math.expm1(s),log:Math.log1p(-Math.exp(s))}:{lin:Math.exp(s),log:s}}let o=dr(t/2,Math.max(n/2,Number.MIN_VALUE)),u=er(i,o,e);if(u.lin>.5){let s;return{lin:u.lin,get log(){return s??=Math.log1p(-lt(i,o,!e,!1)),s}}}return u}function je(n,t,r){let e=.5-Math.sqrt(r/n)/2-(t-3)/(4*n);return yr(n,t,r,!0)-Math.log(e)}function Nn(n,t,r,e,i){let o=gr(n,t,r,e);return i?o.log:o.lin}function He(n,t){let r=NaN,e=!0,i={lin:NaN,log:NaN};return(o,u)=>((o!==r||u!==e)&&(i=gr(o,n,t,u),r=o,e=u),i)}function br(n,t,r,e){let i=t/2,o=n/2,u=r/2,s=(-(i-1)+Math.sqrt((i-1)*(i-1)+4*u*o))/2;return u*o>1e18?yr(n,t,r,e):Gt(u,dr(i,o),a=>i+a,s,n,e)}function yr(n,t,r,e){let i=t/2-1,o=Math.sqrt(r*n),u=4*i*i,s=1,a=1;for(let l=1;l<30&&(s*=-(u-(2*l-1)*(2*l-1))/(8*l*o),a+=s,!(Math.abs(s)<1e-17*Math.abs(a)));l++);let c=Math.sqrt(n)-Math.sqrt(r),f=-Math.LN2-c*c/2+i/2*Math.log(n/r)-.5*Math.log(2*Math.PI*o)+Math.log(a);return e?f:Math.exp(f)}function Ir(n,t,r,e){return Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)?NaN:pr(t,r)?r===0?ct(n,t/2,2,e):n<0||n===1/0?e?-1/0:0:n===0?t<2?1/0:t===2?e?-r/2-Math.LN2:Math.exp(-r/2)/2:e?-1/0:0:br(n,t,r,e):NaN}function vr(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(!pr(t,r))return NaN;if(n<0)return v(e,i);if(n===0){if(t>0)return v(e,i);let o=-r/2;return e?i?o:Math.exp(o):i?o<-Math.LN2?Math.log1p(-Math.exp(o)):Math.log(-Math.expm1(o)):-Math.expm1(o)}return r===0?n===1/0?I(e,i):j(t/2,Math.max(n/2,Number.MIN_VALUE),e,i):n===1/0?I(e,i):Nn(n,t,r,e,i)}function xr(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(!(t>=0&&r>=0&&Number.isFinite(t)))return NaN;let o=L(n,0,1/0,e,i);if(o!==void 0)return o;if(!Number.isFinite(r))return i&&Math.exp(n)===1?e?1/0:0:NaN;if(r===0)return nt(n,t/2,2,e,i);let{lower:u,logTarget:s,linearTarget:a}=q(n,e,i),c=He(t,r),f=Nn(Number.MIN_VALUE,t,r,u,!0);if(u?f>=s:f<=s)return 0;let l=(t+2*r)/(t+r),N=(t+r)*(t+r)/(t+2*r),h=l*nt(s,N/2,2,u,!0);(!(h>0)||!Number.isFinite(h))&&(h=t+r);let m=Math.max(h,t+r,1);for(let M=0;M<2e3;M++){let p=Nn(m,t,r,u,!0);if(u?p>=s:p<=s)break;m*=2}return U({logTarget:s,...a!==void 0&&{linearTarget:a},lower:u,cdf:(M,p)=>c(M,p).lin,cdfLog:(M,p)=>c(M,p).log,pdfLog:M=>br(M,t,r,!0),x0:Math.min(h,m),lo:0,hi:m,positive:!0})}function Lr(n,t,r,e){let i=w(n,t),o=r[0]<1e-250,u=o?[r[0]*2**500,r[1]*2**500]:r;return{ratioK:o?-1:0,cdf:(s,a,c)=>qt(n+s,t,r,e,a,c),inc:(s,a)=>{let[c,f]=Fr(n,t,s,r),l=t/(c+t);return a?T(c,t,r,e,!0)+Math.log(l)+f:T(c,t,r,e,!1)*l*(1+f)},ratio:s=>_(R(u,F(i,[s-1,0])),w(n,s)),incLogDD:s=>{let[a,c]=Fr(n,t,s,r);if(!(r[0]>1e-305&&e[0]>1e-305)){let N=Ge(a,t,r,e);return typeof N=="number"?N+c:F(N,[c,0])}let{e:f,logDenom:l}=at(a,t,r,e);return F([-f[0],-f[1]],[-.5*l+Math.log(t/(a+t))+c,0])}}}function Fr(n,t,r,e){let[i,o]=w(n,r);return o===0?[i,0]:[i,o*(Math.log(e[0])+e[1]/e[0]+gt(i+t)-gt(i+1))]}function Ge(n,t,r,e){if(!(r[0]>0&&e[0]>0))return-1/0;let i=F(tn(O(r),n),tn(O(e),t));return F(F(i,ft(Zn(n,t))),[-Math.log(n),0])}function mn(n){return n<=.5?[[n,0],w(1,-n)]:[w(1,-(1-n)),[1-n,0]]}function Mn(n,t,r,e,i,o,u){let s=Lr(n,t,e,i),a=r/2,c=lt(a,s,o,!1);return u?c>.5?Math.log1p(-lt(a,s,!o,!1)):c>=1e-280?Math.log(c):lt(a,s,o,!0):c}function Er(n,t,r,e,i,o,u){let s=r/2,a=e[0],c=s*a,f=n-1-c,l=(-f+Math.sqrt(Math.max(0,f*f+4*c*(n+t-1))))/2;return Gt(s,Lr(n,t,e,i),N=>n+N,l,o,u)}function dn(n,t,r){return n>0&&t>0&&Number.isFinite(n)&&Number.isFinite(t)&&r>=0&&Number.isFinite(r)}function _r(n,t,r,e,i){let[o,u]=mn(n),s=R(o,u);return Er(t,r,e,o,u,s[0]+s[1],i)}function lr(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(e))return NaN;if(!dn(t,r,e))return NaN;if(e===0)return an(n,t,r,i);if(n<0||n>1)return i?-1/0:0;let o=e/2;return n===0?t>1?i?-1/0:0:t<1?1/0:i?Math.log(r)-o:r*Math.exp(-o):n===1?r>1?i?-1/0:0:r<1?1/0:i?Math.log(t+o):t+o:_r(n,t,r,e,i)}function Nr(n,t,r,e,i,o){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(e))return NaN;if(n<=0)return v(i,o);if(n>=1)return I(i,o);if(!dn(t,r,e))return NaN;if(e===0)return cn(n,t,r,i,o);let[u,s]=mn(n);return Mn(t,r,e,u,s,i,o)}function hr(n,t,r,e,i,o){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(e))return NaN;if(!(t>0&&r>0&&e>=0))return NaN;let u=L(n,0,1,i,o);if(u!==void 0)return u;if(!dn(t,r,e))return NaN;if(e===0)return Qt(n,t,r,i,o);let{lower:s,logTarget:a,linearTarget:c}=q(n,i,o),f=(m,M,p)=>{let[d,y]=mn(m);return Mn(t,r,e,d,y,M,p)},l=f(Number.MIN_VALUE,s,!0);if(s?l>=a:l<=a)return 0;let N=f(1-Number.EPSILON/2,s,!0);if(s?N<a:N>a)return 1;let h=Qt(a,t+e/2,r,s,!0);return h>0&&h<1||(h=.5),U({logTarget:a,...c!==void 0&&{linearTarget:c},lower:s,cdf:(m,M)=>f(m,M,!1),cdfLog:(m,M)=>f(m,M,!0),pdfLog:m=>_r(m,t,r,e,!0),x0:h,lo:0,hi:1,positive:!0})}function Ar(n,t,r){let e=$(t,n);if(Number.isFinite(e[0])&&Number.isFinite(e[1])&&Math.abs(e[0])<1e290){let o=F(e,[r,0]);return[_(e,o),_([r,0],o)]}let i=r/t/n;return[w(1,-i),[i,0]]}function wr(n,t,r,e,i){if(t/r*n<1e-306){let s=t/2,a=-e/2+s*(Math.log(t/r)+Math.log(n))-P(s,r/2)-Math.log(n);return i?a:Math.exp(a)}let[o,u]=Ar(n,t,r);return Er(t/2,r/2,e,o,u,n,i)}function Dr(n,t,r,e,i,o){let u=t/2,s=-e/2+u*(Math.log(t/r)+Math.log(n))-Math.log(u)-P(u,r/2);return i?o?s:Math.exp(s):o?-Math.exp(s):-Math.expm1(s)}function Et(n,t,r,e,i,o){if(t/r*n<1e-306)return Dr(n,t,r,e,i,o);let[u,s]=Ar(n,t,r);return Mn(t/2,r/2,e,u,s,i,o)}function Rr(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(e))return NaN;if(!(t>0&&r>0&&e>=0))return NaN;if(n<0)return i?-1/0:0;if(!Number.isFinite(e))return NaN;if(t===1/0)return r===1/0?n===1?1/0:i?-1/0:0:n===0?NaN:Kt(n,t,r,i);if(r===1/0){let o=Ir(n*t,t,e,i);return i?o+Math.log(t):o*t}return n===1/0?NaN:n===0?t<2?1/0:t>2?i?-1/0:0:i?-e/2:Math.exp(-e/2):e===0?Kt(n,t,r,i):wr(n,t,r,e,i)}function Cr(n,t,r,e,i,o){return Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(e)?NaN:!(t>0&&r>0&&e>=0)||!Number.isFinite(e)?NaN:t===1/0&&r===1/0?NaN:n<=0?v(i,o):n===1/0?I(i,o):t===1/0?NaN:r===1/0?vr(n*t,t,e,i,o):t/r*n<1e-306?Dr(n,t,r,e,i,o):e===0?hn(n,t,r,i,o):Et(n,t,r,e,i,o)}function Sr(n,t,r,e,i,o){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(e))return NaN;if(!(t>0&&r>0&&e>=0)||!Number.isFinite(e))return NaN;let u=L(n,0,1/0,i,o);return u!==void 0?u:t===1/0?NaN:r===1/0?xr(n,t,e,i,o)/t:e===0?Vt(n,t,r,i,o):Qe(n,t,r,e,i,o)}function Qe(n,t,r,e,i,o){let{lower:u,logTarget:s,linearTarget:a}=q(n,i,o),c=Et(Number.MIN_VALUE,t,r,e,u,!0);if(u?c>=s:c<=s)return 0;let f=Et(Number.MAX_VALUE,t,r,e,u,!0);if(u?f<s:f>s)return 1/0;let l=(t+e)*(t+e)/(t+2*e),N=(t+e)/t*Vt(s,l,r,u,!0);return(!(N>0)||!Number.isFinite(N))&&(N=1),U({logTarget:s,...a!==void 0&&{linearTarget:a},lower:u,cdf:(h,m)=>Et(h,t,r,e,m,!1),cdfLog:(h,m)=>Et(h,t,r,e,m,!0),pdfLog:h=>wr(h,t,r,e,!0),x0:N,lo:0,hi:1/0,positive:!0})}function qr(n,t,r,e){let i=$(t,n),o,u;if(Number.isFinite(i[0])&&Number.isFinite(i[1])&&Math.abs(i[0])<1e290){let l=F(i,[r,0]);o=_(i,l),u=_([r,0],l)}else u=[r/t/n,0],o=[1,-u[0]];let s=o[0],a=u[0];if(t>=2){let l=t*a/2,N=T((t-2)/2,r/2,o,u,e);return e?Math.log(l)+N:l*N}let c=t/(r+t*n)*t*r/(2*(t+r)*s),f=T(t/2,r/2,o,u,e);return e?Math.log(c)+f:c*f}function Kt(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(t<=0||r<=0)return NaN;if(n<0)return x(e);if(n===0)return t>2?x(e):t===2?e?0:1:1/0;if(!Number.isFinite(t)&&!Number.isFinite(r))return n===1?1/0:x(e);if(!Number.isFinite(r))return ct(n,t/2,2/t,e);if(!Number.isFinite(t)){let i=ct(1/n,r/2,2/r,e);return e?i-2*Math.log(n):i/(n*n)}return Number.isFinite(n)?qr(n,t,r,e):t<2?NaN:x(e)}function pn(n,t,r,e,i){let o=$(t,n);if(Number.isFinite(o[0])&&Number.isFinite(o[1])&&Math.abs(o[0])<1e290){let s=F(o,[r,0]);return qt(t/2,r/2,_(o,s),_([r,0],s),e,i)}let u=r/t/n;return Q(t/2,r/2,1-u,u,e,i)}function Ke(n,t,r,e){let i=ln(n/2,t/2,r,e);if(i===void 0)return 1;let o=t*i/(n*(1-i));return o>0&&Number.isFinite(o)?o:1}function Ve(n,t,r,e){let i=$(t,n);if(Number.isFinite(i[0])&&Number.isFinite(i[1])&&Math.abs(i[0])<1e290){let u=F(i,[r,0]);return Yn(t/2,r/2,_(i,u),_([r,0],u),e)}let o=r/t/n;return Bt(t/2,r/2,1-o,o,e)}function hn(n,t,r,e,i){return Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)?NaN:t<=0||r<=0?NaN:n<=0?v(e,i):n===1/0?I(e,i):!Number.isFinite(t)&&!Number.isFinite(r)?n===1?i?-Math.LN2:.5:n<1?v(e,i):I(e,i):Number.isFinite(r)?Number.isFinite(t)?pn(n,t,r,e,i):Wt(r/n,r/2,2,!e,i):Wt(n*t,t/2,2,e,i)}function Vt(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(t<=0||r<=0)return NaN;let o=L(n,0,1/0,e,i);if(o!==void 0)return o;if(!Number.isFinite(t)&&!Number.isFinite(r))return 1;if(!Number.isFinite(r))return nt(n,t/2,2,e,i)/t;if(!Number.isFinite(t))return r/nt(n,r/2,2,!e,i);let{lower:u,logTarget:s,linearTarget:a}=q(n,e,i);return u&&(s+Math.log(t/2)+P(t/2,r/2))/(t/2)+Math.log(r/t)<-746?0:!u&&-(s+Math.log(r/2)+P(t/2,r/2))/(r/2)+Math.log(r/t)>709.78?1/0:U({logTarget:s,...a!==void 0&&{linearTarget:a},lower:u,cdf:(c,f)=>pn(c,t,r,f,!1),cdfLog:(c,f)=>pn(c,t,r,f,!0),cdfBoth:(c,f)=>Ve(c,t,r,f),pdfLog:c=>qr(c,t,r,!0),dlogPdf:c=>(t/2-1)/c-(t+r)/2*(t/(r+t*c)),x0:Ke(t,r,u,s),lo:0,hi:1/0,positive:!0})}function Mu(n,t,r,e={}){let{log:i=!1,ncp:o}=e;return o!==void 0?b(n,u=>Rr(u,t,r,o,i)):b(n,u=>Kt(u,t,r,i))}function du(n,t,r,e={}){let{lowerTail:i=!0,logP:o=!1,ncp:u}=e;return u!==void 0?b(n,s=>Cr(s,t,r,u,i,o)):b(n,s=>hn(s,t,r,i,o))}function pu(n,t,r,e={}){let{lowerTail:i=!0,logP:o=!1,ncp:u}=e;return u!==void 0?b(n,s=>Sr(s,t,r,u,i,o)):b(n,s=>Vt(s,t,r,i,o))}function gn(n,t){return Ot(n)||n<0||!Number.isFinite(n)||t<0||t>1}function Xe(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(gn(t,r))return NaN;if(Ot(n)||n<0||!Number.isFinite(n))return x(e);let i=Math.round(n),o=Math.round(t);if(i>o)return x(e);let u=r<=.5?[r,0]:w(1,-(1-r)),s=r<=.5?w(1,-r):[1-r,0];return T(i,o-i,u,s,e)}function Br(n,t,r,e,i){return Q(n+1,t-n,r,1-r,!e,i)}function $e(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(gn(t,r))return NaN;let o=Math.round(t);if(n<0)return v(e,i);let u=Math.floor(n+1e-7);return o<=u?I(e,i):r===0?I(e,i):r===1?v(e,i):Br(u,o,r,e,i)}function Ze(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(!Number.isFinite(t)||!Number.isFinite(r)||r<0||r>1||t<0)return NaN;let o=L(n,0,Ye(t),e,i);if(o!==void 0)return o;if(gn(t,r))return NaN;let u=Math.round(t);if(r===0||u===0)return 0;if(r===1)return u;let s=1-r,a=u*r,c=Math.sqrt(u*r*s),f=(s-r)/c,l=S(n,{lowerTail:e,logP:i}),N=a+c*(l+f*(l*l-1)/6);return K({p:n,lowerTail:e,logP:i,cdf:(h,m,M)=>h>=u?I(m,M):Br(h,u,r,m,M),y0:Number.isFinite(N)?N:a,lo:0,hi:u})}function _u(n,t,r,e={}){let i=e.log??!1;return b(n,o=>Xe(o,t,r,i))}function Au(n,t,r,e={}){let{lowerTail:i=!0,logP:o=!1}=e;return b(n,u=>$e(u,t,r,i,o))}function wu(n,t,r,e={}){let{lowerTail:i=!0,logP:o=!1}=e;return b(n,u=>Ze(u,t,r,i,o))}function Ye(n){let t=Math.round(n);return Math.abs(n%1)===.5&&t%2!==0?t-1:t}function bn(n,t,r,e){if(n===0&&t===0)return{e:[0,0],logDenom:0};if(n===0||t===0){let i=n+t,[o,u]=n===0?[e,r]:[r,e];return{e:u[0]<.1?F(St(i,R([i,0],o)),R([i,0],u)):ft(R([i,0],O(o))),logDenom:0}}return at(n,t,r,e)}function Ur(n,t,r,e){let i=t+r,o=_([e,0],[i,0]),u=_([i-e,0],[i,0]),s=bn(n,t-n,o,u),a=bn(e-n,r-e+n,o,u),c=bn(e,i-e,o,u);return{e:Vn(F(s.e,a.e),c.e),logDenom:s.logDenom+a.logDenom-c.logDenom}}function jr(n,t){let[r,e]=n.e,i=t*Math.exp(-.5*n.logDenom);return r<700?Math.exp(-r)*(1-e)*i:Math.exp(700-r)*(1-e)*i*Math.exp(-700)}function Hr(n){return-n.e[0]-n.e[1]-.5*n.logDenom}function Xt(n,t,r){return[Math.max(0,r-t),Math.min(r,n)]}function Te(n,t,r,e,i){if([n,t,r,e].some(Number.isNaN))return NaN;if(![t,r,e].every(Number.isFinite)||H(t)||H(r)||H(e))return NaN;if(t=D(t),r=D(r),e=D(e),t<0||r<0||e<0||e>t+r)return NaN;if(H(n))return x(i);n=D(n);let[o,u]=Xt(t,r,e);if(n<o||n>u)return x(i);if(e===0||e===t+r)return i?0:1;let s=Ur(n,t,r,e);return i?Hr(s):jr(s,1)}function Wr(n,t,r,e){return _($(n,t),$(r,e))}function Pe(n,t,r,e,i,o,u){let s=[1,0],a=[1,0],c=n;for(;!(i?c<=o:c>=u);){let f=i?Wr(c,r-e+c,t-c+1,e-c+1):Wr(t-c,e-c,c+1,r-e+c+1);s=R(s,f),a=F(a,s),c+=i?-1:1;let l=f[0];if(l<1&&s[0]*l/(1-l)<a[0]*2**-60)break}return a[0]+a[1]}function Gr(n,t,r,e,i,o){let[u,s]=Xt(t,r,e),a=t+r,c=n*a<e*t,f=Or(n,t,r,e,c,u,s);if(f.value>.5){let l=Or(n,t,r,e,!c,u,s);l.value<f.value&&(f=l,c=!c)}return c===i?o?f.value>1e-300?Math.log(f.value):Hr(f.form)+Math.log(f.sum):f.value:o?Math.log1p(-f.value):1-f.value}function Or(n,t,r,e,i,o,u){let s=i?n:n+1,a=Ur(s,t,r,e),c=Pe(s,t,r,e,i,o,u);return{form:a,sum:c,value:jr(a,c)}}function Qr(n,t,r){if([n,t,r].every(Number.isFinite)&&(n=D(n),t=D(t),r=D(r),!(n<0||t<0||r<0||r>n+t)))return[n,t,r]}function Je(n,t,r,e,i,o){if([n,t,r,e].some(Number.isNaN))return NaN;let u=Qr(t,r,e);if(u===void 0)return NaN;[t,r,e]=u;let s=Math.floor(n+1e-7),[a,c]=Xt(t,r,e);return s<a?v(i,o):s>=c?I(i,o):Gr(s,t,r,e,i,o)}function ze(n,t,r,e,i,o){if([n,t,r,e].some(Number.isNaN))return NaN;let u=Qr(t,r,e);if(u===void 0)return NaN;[t,r,e]=u;let[s,a]=Xt(t,r,e),c=L(n,s,a,i,o);if(c!==void 0)return c;if(s===a)return s;let f=t+r,l=e*t/f,N=Math.sqrt(e*t/f*(r/f)*(f-e)/Math.max(f-1,1)),h=S(n,{lowerTail:i,logP:o}),m=l+N*h;return K({p:n,lowerTail:i,logP:o,cdf:(M,p,d)=>M<s?v(p,d):M>=a?I(p,d):Gr(M,t,r,e,p,d),y0:Number.isFinite(m)?m:l,lo:s,hi:a})}function Uu(n,t,r,e,i={}){let o=i.log??!1;return b(n,u=>Te(u,t,r,e,o))}function ju(n,t,r,e,i={}){let{lowerTail:o=!0,logP:u=!1}=i;return b(n,s=>Je(s,t,r,e,o,u))}function Hu(n,t,r,e,i={}){let{lowerTail:o=!0,logP:u=!1}=i;return b(n,s=>ze(s,t,r,e,o,u))}var ke=2**900,Kr=-900,it=new Map,ti=2**21,$t=0,ni=2**25;function ri(n,t){if(t+1>ni)throw new RangeError(`signrank: n = ${n} needs too large a table (${t+1} entries)`);let r=new Float64Array(t+1);r[0]=1;let e=0,i=Math.min(n,t);for(let a=1;a<=i;a++){for(let c=t;c>=a;c--)r[c]+=r[c-a];if(r[Math.min(t,Math.floor(a*(a+1)/4))]>ke){let c=2**Kr;for(let f=0;f<=t;f++)r[f]*=c;e-=Kr}}let o=new Float64Array(t+1),u=0,s=0;for(let a=0;a<=t;a++){let c=r[a]-s,f=u+c;s=f-u-c,u=f,o[a]=u}return{n,len:t+1,count:r,cum:o,scale:e}}function yn(n,t){let r=it.get(n);if(r!==void 0&&r.len>t)return it.delete(n),it.set(n,r),r;let e=Math.floor(n*(n+1)/4),i=Math.min(e,Math.max(t,r===void 0?0:2*r.len)),o=ri(n,i);r!==void 0&&(it.delete(n),$t-=r.len),it.set(n,o),$t+=o.len;for(let[u,s]of it){if($t<=ti||u===n)break;it.delete(u),$t-=s.len}return o}function In(n,t,r){let e=t.scale-t.n,i=Math.trunc(e/2),o=n*2**i*2**(e-i);return r?o>=1e-300?Math.log(o):Math.log(n)+e*Math.LN2:o}function vn(n){return Number.isFinite(n)?(n=D(n),n<=0?NaN:n):NaN}function ei(n,t,r){if(Number.isNaN(n)||Number.isNaN(t))return NaN;if(t=vn(t),Number.isNaN(t))return NaN;if(H(n))return x(r);n=D(n);let e=t*(t+1)/2;if(n<0||n>e)return x(r);let i=Math.min(n,e-n),o=yn(t,i);return In(o.count[i],o,r)}function Vr(n,t,r,e){let i=t*(t+1)/2,o=n,u=i-n-1,s=r?o:u,a=r?u:o;if(s<=a){let l=yn(t,s);return In(l.cum[s],l,e)}let c=yn(t,a),f=In(c.cum[a],c,!1);return e?Math.log1p(-f):1-f}function ii(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t))return NaN;if(t=vn(t),Number.isNaN(t))return NaN;let i=D(n+1e-7),o=t*(t+1)/2;return i<0?v(r,e):i>=o?I(r,e):Vr(i,t,r,e)}function oi(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t))return NaN;if(t=vn(t),Number.isNaN(t))return NaN;let i=t*(t+1)/2,o=L(n,0,i,r,e);if(o!==void 0)return o;let u=i/2,s=Math.sqrt(t*(t+1)*(2*t+1)/24),a=u+s*S(n,{lowerTail:r,logP:e});return K({p:n,lowerTail:r,logP:e,cdf:(c,f,l)=>c<0?v(f,l):c>=i?I(f,l):Vr(c,t,f,l),y0:Number.isFinite(a)?a:u,lo:0,hi:i})}function Zu(n,t,r={}){let e=r.log??!1;return b(n,i=>ei(i,t,e))}function Yu(n,t,r={}){let{lowerTail:e=!0,logP:i=!1}=r;return b(n,o=>ii(o,t,e,i))}function Tu(n,t,r={}){let{lowerTail:e=!0,logP:i=!1}=r;return b(n,o=>oi(o,t,e,i))}var Tt=960,ui=2**25,Zt=134217729,ot=new Map,si=2**21,Yt=0;function fi(n,t,r){if(r+1>ui)throw new RangeError(`wilcox: m = ${n}, n = ${t} needs too large a table (${r+1} entries)`);let e=new Float64Array(r+1),i=new Float64Array(r+1);e[0]=2**Tt;for(let a=1;a<=n;a++){let c=Math.min(r,a*t),f=t+a,l=Zt*a,N=l-(l-a),h=a-N;l=Zt*f;let m=l-(l-f),M=f-m;for(let d=0;d<=c;d++){let y=e[d];if(y===0)continue;let g=y*a;l=Zt*y;let E=l-(l-y),V=y-E,B=E*N-g+E*h+V*N+V*h+i[d]*a,A=g/f,X=A*f;l=Zt*A;let W=l-(l-A),st=A-W,ge=W*m-X+W*M+st*m+st*M,Qn=(g-X-ge+B)/f,Kn=A+Qn;i[d]=Qn-(Kn-A),e[d]=Kn}let p=t+a;for(let d=c;d>=p;d--)Xr(e,i,d,d-p,-1);for(let d=a;d<=c;d++)Xr(e,i,d,d-a,1)}let o=new Float64Array(r+1),u=0,s=0;for(let a=0;a<=r;a++){let c=e[a],f=u+c,l=f-u,N=u-(f-l)+(c-l);N+=s+i[a],u=f+N,s=N-(u-f),o[a]=u}return{m:n,n:t,len:r+1,prob:e,cum:o}}function Xr(n,t,r,e,i){let o=n[r],u=i*n[e],s=o+u,a=s-o,c=o-(s-a)+(u-a);c+=t[r]+i*t[e];let f=s+c;t[r]=c-(f-s),n[r]=f}function xn(n,t,r){n>t&&([n,t]=[t,n]);let e=`${n},${t}`,i=ot.get(e);if(i!==void 0&&i.len>r)return ot.delete(e),ot.set(e,i),i;let o=Math.floor(n*t/2),u=Math.min(o,Math.max(r,i===void 0?0:2*i.len)),s=fi(n,t,u);i!==void 0&&(ot.delete(e),Yt-=i.len),ot.set(e,s),Yt+=s.len;for(let[a,c]of ot){if(Yt<=si||a===e)break;ot.delete(a),Yt-=c.len}return s}function Fn(n,t){let r=n*2**-(Tt/2)*2**-(Tt/2);return t?r>=1e-300?Math.log(r):Math.log(n)-Tt*Math.LN2:r}function Ln(n,t){if(!(!Number.isFinite(n)||!Number.isFinite(t)))return n=D(n),t=D(t),n<=0||t<=0?void 0:[n,t]}function ai(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;let i=Ln(t,r);if(i===void 0)return NaN;if([t,r]=i,H(n))return x(e);n=D(n);let o=t*r;if(n<0||n>o)return x(e);let u=Math.min(n,o-n);return Fn(xn(t,r,u).prob[u],e)}function $r(n,t,r,e,i){let o=t*r,u=e?n:o-n-1,s=e?o-n-1:n;if(u<=s)return Fn(xn(t,r,u).cum[u],i);let a=Fn(xn(t,r,s).cum[s],!1);return i?Math.log1p(-a):1-a}function ci(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;let o=Ln(t,r);if(o===void 0)return NaN;[t,r]=o;let u=Math.floor(n+1e-7);return u<0?v(e,i):u>=t*r?I(e,i):$r(u,t,r,e,i)}function li(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;let o=Ln(t,r);if(o===void 0)return NaN;[t,r]=o;let u=t*r,s=L(n,0,u,e,i);if(s!==void 0)return s;let a=u/2,c=Math.sqrt(u*(t+r+1)/12),f=a+c*S(n,{lowerTail:e,logP:i});return K({p:n,lowerTail:e,logP:i,cdf:(l,N,h)=>l<0?v(N,h):l>=u?I(N,h):$r(l,t,r,N,h),y0:Number.isFinite(f)?f:a,lo:0,hi:u})}function rs(n,t,r,e={}){let i=e.log??!1;return b(n,o=>ai(o,t,r,i))}function es(n,t,r,e={}){let{lowerTail:i=!0,logP:o=!1}=e;return b(n,u=>ci(u,t,r,i,o))}function is(n,t,r,e={}){let{lowerTail:i=!0,logP:o=!1}=e;return b(n,u=>li(u,t,r,i,o))}var tt=128,qn=Number.EPSILON,Bn=Float64Array.from({length:2*tt+1},(n,t)=>Math.cos(Math.PI*t/tt));function Ni(n){let t=new Float64Array(n+1);for(let r=0;r<=n;r++){let e=0;for(let i=0;i<=n;i+=2)e+=(i===0||i===n?.5:1)*Bn[i*r%(2*n)*(tt/n)]*2/(1-i*i);t[r]=(r===0||r===n?.5:1)*2*e/n}return t}var hi=new Map([16,32,64,128].map(n=>[n,Ni(n)]));function mi(n,t){let r=hi.get(t),e=tt/t,i=0,o=0;for(let s=0;s<=t;s++)i+=r[s]*n[s],o+=Math.abs(r[s]*n[s]);let u=0;for(let s=t-7;s<=t;s++){let a=.5*(n[0]+(s%2===0?n[t]:-n[t]));for(let c=1;c<t;c++)a+=n[c]*Bn[s*c%(2*t)*e];a*=2/t,s===t&&(a*=.5),u=Math.max(u,Math.abs(a))}return{integral:i,tail:u,scale:o}}var At=class{f;a;b;c;h;values=new Float64Array(tt+1);have=new Uint8Array(tt+1);N=0;integral=0;error=1/0;constructor(t,r,e){this.f=t,this.a=r,this.b=e,this.c=.5*(r+e),this.h=.5*(e-r)}advance(t){let r=tt/t,e=new Float64Array(t+1);for(let o=0;o<=t;o++){let u=o*r;this.have[u]||(this.values[u]=this.f(this.c+this.h*Bn[u]),this.have[u]=1),e[o]=this.values[u]}let i=mi(e,t);this.N=t,this.integral=i.integral*this.h,this.error=Math.max(i.tail*4/t,4*qn*i.scale)*Math.abs(this.h)}};function Jt(n,t,r){let e=[];for(let o=0;o+1<t.length;o++){let u=new At(n,t[o],t[o+1]);u.advance(16),e.push(u)}for(let o=0;o<40;o++){let u=0;for(let f of e)u+=f.integral;let s=r*Math.abs(u)/e.length,a=!0,c=[];for(let f of e){if(f.error<=s||f.error<=4*qn*Math.abs(f.integral)){c.push(f);continue}if(a=!1,f.N<tt)f.advance(2*f.N),c.push(f);else{let l=new At(n,f.a,f.c),N=new At(n,f.c,f.b);l.advance(16),N.advance(16),c.push(l,N)}}if(e=c,a)break}let i=0;for(let o of e)i+=o.integral;return i}function Yr(n,t,r){let e=Math.max(1,Math.ceil((t-n)/r));return Array.from({length:e+1},(i,o)=>o===e?t:n+(t-n)*o/e)}var Tr=2e-15,Pr=1e-16,Mi={lowerTail:!1},di={logP:!0},pi={lowerTail:!1,logP:!0},Dt=.9189385332046728,zt=n=>pt(n),ht=n=>pt(n,Mi),Wn=n=>pt(n,di),On=n=>pt(n,pi),gi=.3989422804014327;function mt(n){let t=Math.round(n*16)/16,r=n-t;return gi*Math.exp(-.5*t*t)*Math.exp(-.5*r*(n+t))}var An=[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],Jr=[.362683783378362,.31370664587788727,.22238103445337448,.10122853629037626];function bi(n,t){let r=n-.5*t,e=.5*t,i=0;for(let o=0;o<4;o++)i+=Jr[o]*(mt(r-e*An[o])+mt(r+e*An[o]));return i*e}function yi(n,t){let r=n-.5*t,e=.5*t,i=0;for(let o=0;o<4;o++){let u=e*An[o];i+=Jr[o]*(Math.exp(r*u-u*u/2)+Math.exp(-r*u-u*u/2))}return-Dt-r*r/2+Math.log(i*e)}var Un=(n,t)=>t*Math.max(1,Math.abs(n),Math.abs(n-t))<.5;function Mt(n,t){let r=n-t,e=r-n,i=n-(r-e)+(-t-e);return{ah:r,al:i}}function wt(n,t){return zt(n)+mt(n)*t}function Ii(n,t){return ht(n)-mt(n)*t}function zr(n,t){if(Un(n,t))return bi(n,t);let{ah:r,al:e}=Mt(n,t);return r>=0?Ii(r,e)-ht(n):n<=0?zt(n)-wt(r,e):1-wt(r,e)-ht(n)}function vi(n,t,r){if(n>0&&n-t<0&&!Un(n,t)){let{ah:i,al:o}=Mt(n,t);return Math.exp(r*Math.log1p(-(wt(i,o)+ht(n))))}let e=zr(n,t);return e>0?e**r:0}function xi(n,t){return n>0?Math.exp(t*Math.log1p(-ht(n))):zt(n)**t}function kr(n,t){let{ah:r,al:e}=Mt(n,t),i=Wn(r);return i+e*Math.exp(-Dt-r*r/2-i)}function Fi(n,t){let{ah:r,al:e}=Mt(n,t),i=On(r);return i-e*Math.exp(-Dt-r*r/2-i)}function te(n,t){if(Un(n,t))return yi(n,t);if(n-t>=0){let o=Fi(n,t);return o+Math.log(-Math.expm1(On(n)-o))}if(n<=0){let o=Wn(n);return o+Math.log(-Math.expm1(kr(n,t)-o))}let{ah:e,al:i}=Mt(n,t);return Math.log1p(-wt(e,i)-ht(n))}var ne=2,En=1e-18;function re(n,t,r){let e=Yr(t,r,ne),i=e.map(n),o=0;for(let N=1;N<i.length;N++)i[N]>i[o]&&(o=N);let u=i[o];if(!(u>0))return 0;let s=Math.max(o-1,0),a=Math.min(o+1,i.length-1);for(;s>0&&i[s]>u*En;)s--;for(;a<i.length-1&&i[a]>u*En;)a++;let c=u*En,f=e[s],l=e[a];if(i[s]<=c){let N=e[s+1];for(let h=0;h<2;h++){let m=.5*(f+N);n(m)<=c?f=m:N=m}}if(i[a]<=c){let N=e[a-1];for(let h=0;h<2;h++){let m=.5*(l+N);n(m)<=c?l=m:N=m}}return Jt(n,[f,l],Pr)}function ee(n,t,r){let e=Yr(t,r,ne),i=e.map(n),o=0;for(let g=1;g<i.length;g++)i[g]>i[o]&&(o=g);if(!(i[o]>-1/0))return-1/0;let u=e[Math.max(o-1,0)],s=e[Math.min(o+1,e.length-1)],a=(Math.sqrt(5)-1)/2,c=s-a*(s-u),f=u+a*(s-u),l=n(c),N=n(f);for(let g=0;g<80&&s-u>1e-12*Math.max(1,Math.abs(u));g++)l<N?(u=c,c=f,l=N,f=u+a*(s-u),N=n(f)):(s=f,f=c,N=l,c=s-a*(s-u),l=n(c));let h=l>N?c:f,m=Math.max(l,N);i[o]>m&&(h=e[o],m=i[o]);let M=g=>{let E=g<0?t:r,V=Math.max(1e-6,.001*(e[1]-e[0])),B=h;for(;;){let A=h+g*V;if(g<0?A<=E:A>=E)return E;if(n(A)<m-46){let X=A;for(let W=0;W<6;W++){let st=.5*(B+X);n(st)<m-46?X=st:B=st}return X}B=A,V*=2}},p=M(-1),d=M(1),y=[...new Set([p,h,d])].sort((g,E)=>g-E);return m+Math.log(Jt(g=>Math.exp(n(g)-m),y,Pr))}var jn=-10,Hn=10;function Li(n,t){return n<=0?0:t*re(r=>mt(r)*vi(r,n,t-1),jn,Hn)}function ie(n,t){if(n<=0)return 1;let r=o=>{let u=zt(o);if(u===0)return 0;let{ah:s,al:a}=Mt(o,n),c=wt(s,a),f=c<.5*u?-Math.expm1((t-1)*Math.log1p(-c/u)):-Math.expm1((t-1)*Math.log(zr(o,n)/u));return mt(o)*xi(o,t-1)*f};if(n>60)return 0;let[e,i]=oe(n);return t*re(r,e,i)}function oe(n){return n>40?[n/2-15,n/2+15]:[jn,n+Hn]}function ue(n,t){if(n>100)return-Math.exp(se(n,t));let r=e=>-Dt-e*e/2+(t-1)*te(e,n);return Math.log(t)+ee(r,jn,Hn)}function se(n,t){if(n>100)return Math.log(t*(t-1))+On(n/Math.SQRT2);let r=o=>{let u=Wn(o),s=kr(o,n)-u,a;return s<-40?a=Math.log(t-1)+s:s<-Math.LN2?a=Math.log(-Math.expm1((t-1)*Math.log1p(-Math.exp(s)))):a=Math.log(-Math.expm1((t-1)*(te(o,n)-u))),-Dt-o*o/2+(t-1)*u+a},[e,i]=oe(n);return Math.log(t)+ee(r,e,i)}function Ei(n,t){let r=-1/0;for(let e of t)r=Math.max(r,n(e));for(let e=0;e+1<t.length;e++)r=Math.max(r,n(.5*(t[e]+t[e+1])));if(r===-1/0)return-1/0;for(let e=0;e<4;e++){let i=r,o=Jt(u=>{let s=n(u);return s>i&&(i=s),Math.exp(s-r)},t,Tr);if(Number.isFinite(o)&&i-r<300)return r+Math.log(o);r=i}return NaN}var k=32,_i=1e-15,Nt=Math.log(.01),Gn=Math.log(20),fe=Math.log(40),ae=Float64Array.from({length:2*k+1},(n,t)=>Math.cos(Math.PI*t/k));function Ai(n,t){let r=new Float64Array(t+1);for(let e=0;e<=t;e++){let i=.5*(n[0]+(e%2===0?n[t]:-n[t]));for(let o=1;o<t;o++)i+=n[o]*ae[e*o%(2*t)];i*=2/t,(e===0||e===t)&&(i*=.5),r[e]=i}return r}function _n(n,t,r){let e=[],i=[[t,r,0]];for(;i.length>0;){let[o,u,s]=i.pop(),a=.5*(o+u),c=.5*(u-o),f=new Float64Array(k+1),l=1/0;for(let m=0;m<=k;m++)f[m]=n(a+c*ae[m]),l=Math.min(l,Math.max(1,Math.abs(f[m])));let N=Ai(f,k),h=0;for(let m=k-3;m<=k;m++)h=Math.max(h,Math.abs(N[m]));h<=_i*l||s>=14||!f.every(Number.isFinite)?e.push({a:o,b:u,coef:N}):i.push([a,u,s+1],[o,a,s+1])}return e.sort((o,u)=>o.a-u.a)}function wn(n,t){let r=0,e=n.length-1;for(;r<e;){let f=r+e+1>>1;n[f].a<=t?r=f:e=f-1}let{a:i,b:o,coef:u}=n[r],s=(2*t-i-o)/(o-i),a=0,c=0;for(let f=k;f>=1;f--){let l=2*s*a-c+u[f];c=a,a=l}return s*a-c+u[0]}var _t=new Map,wi=64,ce=Math.log(1e-10);function le(n){let t=_t.get(n);if(t!==void 0)return t;let r=i=>{let o=Li(i,n);return o>1e-290?Math.log(o):ue(i,n)},e=i=>{let o=Math.exp(i);return ie(o,n)*Ne(o)};return t={logW:_n(i=>r(Math.exp(i)),Nt,Gn),scaledWc:_n(e,Nt,fe),smallW:_n(i=>r(Math.exp(i))-(n-1)*i,ce,Nt)},_t.size>=wi&&_t.delete(_t.keys().next().value),_t.set(n,t),t}function Ne(n){let t=n*n,r=134217729*n,e=r-(r-n),i=n-e,o=e*e-t+2*e*i+i*i;return Math.exp(t/4)*(1+o/4)}function Di(n,t){let r=Math.log(n);if(r>=Gn)return 0;let e=le(t);return r>=Nt?wn(e.logW,r):wn(e.smallW,Math.max(r,ce))+(t-1)*r}function Dn(n,t){return Math.log(n)>=Gn?1:Math.exp(Di(n,t))}function Ri(n,t){let r=Math.log(n);return r>=Nt&&r<=fe?wn(le(t).scaledWc,r)/Ne(n):r<Nt?1-Dn(n,t):ie(n,t)}function Pt(n,t,r,e){if(!e){let o=Math.min(Dn(n,t),1);return r===1?o:o**r}let i=Math.min(Ri(n,t),1);return i<=.5?r===1?i:-Math.expm1(r*Math.log1p(-i)):1-Math.min(Dn(n,t),1)**r}function Rn(n,t,r,e){if(!e)return r*ue(n,t);let i=se(n,t);return r===1?i:Math.log(-Math.expm1(r*Math.log1p(-Math.exp(i))))}function Cn(n,t,r,e,i){if(r===1/0)return Pt(n,t,e,i);let o=r/2,u=Math.log(o),s=Ci(o);return Jt(c=>{let{d:f,s:l}=s(c);return f===0?0:f*Pt(n*l,t,e,i)},he(n,t,r,e,i).map(c=>c-u),Tr)}function Ci(n){let t=Ct(n),r=Math.sqrt(n/(2*Math.PI));return e=>{let i;if(Math.abs(e)<.5){let o=e*e/2;i=o;for(let u=3;u<60&&(o*=e/u,i+=o,!(Math.abs(o)<1e-17*i));u++);}else i=Math.expm1(e)-e;return{d:r*Math.exp(-t-n*i),s:Math.exp(.5*e)}}}function Si(n,t,r,e,i){if(r===1/0)return Rn(n,t,e,i);let o=r/2,u=Math.log(o),s=Y(o+1);return Ei(c=>{let f=Math.exp(c),l=f>1e-300?C(o,f,!0):o*c-f-s;return u+l+Rn(Math.exp(Math.log(n)+.5*(c-u)),t,e,i)},he(n,t,r,e,i,!0))}function he(n,t,r,e,i,o=!1){let u=r/2,s=u,a=Math.log(u);if(i){let g=2*Math.log(n)-Math.log(4*u);a-=g>30?g:Math.log1p(Math.exp(g))}else s=u+(t-1)*e/2,a=Math.log(s);let c=(g,E)=>[g-9/Math.sqrt(E)-41/E,g+9/Math.sqrt(E)+Math.log1p(41/E)],[f,l]=c(Math.log(u),u),[N,h]=c(a,s),m=o?Math.min(f,N):Math.max(Math.min(f,N),-740),M=Math.max(l,h),p=1/Math.sqrt(u),d=1/Math.sqrt(s),y=[m,Math.min(Math.log(u)-4*p,a-4*d),Math.max(Math.log(u)+4*p,a+4*d),M];return[...new Set(y.map(g=>Math.min(Math.max(g,m),M)))].sort((g,E)=>g-E)}function me(n,t,r){return n>=2&&t>=2&&r>=1&&Number.isFinite(n)&&Number.isFinite(r)&&!Number.isNaN(t)}function Sn(n,t,r,e,i,o){let u;return ut!==void 0&&ut.q===n&&ut.k===t&&ut.df===r&&ut.r===e?u=ut.tail:(u=qi(n,t,r,e,!i),ut={q:n,k:t,df:r,r:e,tail:u}),u.upper===!i?o?u.log:u.value:o?Math.log1p(-u.value):1-u.value}var ut;function qi(n,t,r,e,i){let o=i;r!==1/0&&Pt(n,t,e,o)>.5&&(o=!o);let u=Cn(n,t,r,e,o);if(u>.5){let s=Cn(n,t,r,e,!o);s<u&&(u=s,o=!o)}if(u<1e-290){let s=Si(n,t,r,e,o);return{upper:o,value:Math.exp(s),log:s}}return{upper:o,value:u,log:Math.log(u)}}function Bi(n,t,r,e,i,o){return[n,t,r,e].some(Number.isNaN)?NaN:me(t,r,e)?n<=0?v(i,o):n===1/0?I(i,o):Sn(n,t,r,e,i,o):NaN}function Wi(n,t,r,e,i,o){if([n,t,r,e].some(Number.isNaN))return NaN;if(!me(t,r,e))return NaN;let u=L(n,0,1/0,i,o);if(u!==void 0)return u;let{lower:s,logTarget:a,linearTarget:c}=q(n,i,o),f=N=>h=>{let m=Math.exp(h);if(c!==void 0&&c>1e-290){let p=N===1/0?Cn(m,t,N,e,!s):Sn(m,t,N,e,s,!1);if(p>0)return Math.log(p/c)}return(N===1/0?Oi(m,t,e,s):Sn(m,t,N,e,s,!0))-a},l=Zr(f(1/0),Math.log(3),s);return Math.exp(r===1/0?l:Zr(f(r),l,s))}function Oi(n,t,r,e){let i=Pt(n,t,r,!e);return i>1e-290?Math.log(i):Rn(n,t,r,!e)}function Zr(n,t,r){let e=t,i=n(e);if(i===0)return e;let o=i>0===r?-1:1,u=.05,s=e+o*u,a=n(s);for(let c=0;c<200&&Math.sign(a)===Math.sign(i)&&a!==0;c++)e=s,i=a,u*=2,s=e+o*u,a=n(s);return a===0?s:!Number.isFinite(a)||Math.sign(a)===Math.sign(i)?Number.isFinite(a)?s:e:Ui(n,e,s,i,a)}function Ui(n,t,r,e,i){let o=t,u=e,s=r-t,a=s;for(let c=0;c<100;c++){Math.sign(i)===Math.sign(u)&&(o=t,u=e,s=r-t,a=s),Math.abs(u)<Math.abs(i)&&(t=r,r=o,o=t,e=i,i=u,u=e);let f=2*qn*Math.abs(r)+1e-300,l=.5*(o-r);if(Math.abs(l)<=f||i===0)return r;if(Math.abs(a)>=f&&Math.abs(e)>Math.abs(i)){let N=i/e,h,m;if(t===o)h=2*l*N,m=1-N;else{let M=e/u,p=i/u;h=N*(2*l*M*(M-p)-(r-t)*(p-1)),m=(M-1)*(p-1)*(N-1)}h>0?m=-m:h=-h,2*h<Math.min(3*l*m-Math.abs(f*m),Math.abs(a*m))?(a=s,s=h/m):(s=l,a=l)}else s=l,a=l;t=r,e=i,r+=Math.abs(s)>f?s:l>0?f:-f,i=n(r)}return r}function ls(n,t,r,e={}){let{nranges:i=1,lowerTail:o=!0,logP:u=!1}=e;return b(n,s=>Bi(s,t,r,i,o,u))}function Ns(n,t,r,e={}){let{nranges:i=1,lowerTail:o=!0,logP:u=!1}=e;return b(n,s=>Wi(s,t,r,i,o,u))}function Ms(n,t={}){return Me(n,t).map(r=>r-1)}function Me(n,t){if(!Number.isFinite(n)||n<0||n>45e14)throw new RangeError("n must be a non-negative number up to 4.5e15");n=Math.trunc(n);let{replace:r=!1,prob:e}=t,i=t.size!==void 0,o=i?t.size:n;if(!Number.isFinite(o)||o<0)throw new RangeError("size must be a non-negative number");let u=Math.trunc(o);if(e!==void 0){if(n>=2**31)throw new RangeError("n must be less than 2^31 with prob");if(e.length!==n)throw new TypeError("prob must have length n");let f=ji(e,u,r);if(r){let l=0;for(let N=0;N<n;N++)n*f[N]>.1&&l++;return l>200?Ki(f,u):Gi(f,u)}if(u>n)throw new RangeError("cannot take a sample larger than the population when replace is false");return Qi(f,u)}if(!r&&u>n)throw new RangeError("cannot take a sample larger than the population when replace is false");if(!r&&n>1e7&&i&&u<=n/2){let f=new Set,l=[];for(;l.length<u;){let N=bt(n);f.has(N)||(f.add(N),l.push(N+1))}return l}let s=new Array(u);if(r||u<2){for(let f=0;f<u;f++)s[f]=bt(n)+1;return s}if(n>=2**31)throw new RangeError("n must be less than 2^31 to sample without replacement with size above n / 2");let a=new Int32Array(n);for(let f=0;f<n;f++)a[f]=f;let c=n;for(let f=0;f<u;f++){let l=bt(c);s[f]=a[l]+1,a[l]=a[--c]}return s}function ds(n,t={}){return Me(n.length,t).map(r=>n[r-1])}function ji(n,t,r){let e=0,i=0;for(let o of n){if(!Number.isFinite(o))throw new RangeError("prob contains NaN or infinite values");if(o<0)throw new RangeError("prob contains negative values");o>0&&(i++,e+=o)}if(i===0||!r&&t>i)throw new RangeError("too few positive probabilities");return Float64Array.from(n,o=>o/e)}function Hi(n,t){let r=n.length;if(r<=1)return;let e=a=>n[a-1],i=(r>>1)+1,o=r,u,s;for(;;){if(i>1)i=i-1,u=e(i),s=t[i-1];else if(u=e(o),s=t[o-1],n[o-1]=e(1),t[o-1]=t[0],--o===1){n[0]=u,t[0]=s;return}let a=i,c=i<<1;for(;c<=o;)c<o&&e(c)>e(c+1)&&++c,u>e(c)?(n[a-1]=e(c),t[a-1]=t[c-1],a=c,c+=c):c=o+1;n[a-1]=u,t[a-1]=s}}function de(n){let t=new Int32Array(n.length);for(let r=0;r<n.length;r++)t[r]=r+1;return Hi(n,t),t}function Gi(n,t){let r=Float64Array.from(n),e=r.length,i=de(r);for(let u=1;u<e;u++)r[u]+=r[u-1];let o=new Array(t);for(let u=0;u<t;u++){let s=J(),a=0;for(;a<e-1&&!(s<=r[a]);a++);o[u]=i[a]}return o}function Qi(n,t){let r=Float64Array.from(n),e=r.length,i=de(r),o=new Array(t),u=1;for(let s=0,a=e-1;s<t;s++,a--){let c=u*J(),f=0,l=0;for(;l<a&&(f+=r[l],!(c<=f));l++);o[s]=i[l],u-=r[l];for(let N=l;N<a;N++)r[N]=r[N+1],i[N]=i[N+1]}return o}function Ki(n,t){let r=n.length,e=new Float64Array(r),i=new Int32Array(r),o=new Int32Array(r),u=-1,s=r;for(let f=0;f<r;f++)e[f]=n[f]*r,e[f]<1?o[++u]=f:o[--s]=f;if(u>=0&&s<r)for(let f=0;f<r-1;f++){let l=o[f],N=o[s];if(i[l]=N,e[N]+=e[l]-1,e[N]<1&&s++,s>=r)break}let a=Tn(),c=new Array(t);for(let f=0;f<t;f++){let l,N;a?(N=J()*r,l=Math.trunc(N)):(l=bt(r),N=l+J()),c[f]=N<e[l]+l?l+1:i[l]+1}return c}function Vi(n){let t=new Float64Array(n+1);for(let r=2;r<=n;r++)t[r]=t[r-1]+Math.log(r);return t}function Xi(n,t,r,e){let i=n.length,o=t.length,u=Array.from(t),s=0;for(let c of n)s+=c;for(let c=0;c<i-1;c++){let f=n[c],l=s;s-=f;let N=0;for(;N<o-1;N++){let h=u[N],m=l;l-=h;let M=m-f,p=M-h;if(m===0){for(let g=N;g<o-1;g++)e[c+g*i]=0;f=0;break}let d=J(),y;t:for(;;){y=Math.floor(f*(h/m)+.5);let g=Math.exp(r[f]+r[M]+r[l]+r[h]-r[m]-r[y]-r[h-y]-r[f-y]-r[p+y]);if(g>=d)break;if(g===0)throw new Error(`r2dtable: probability underflow at cell [${c}, ${N}]`);let E=g,V=g,B=y,A=!1,X=!1;for(;!(A&&X);){if(!A){let W=(h-y)*(f-y);if(W===0)A=!0;else if(y++,g=g*W/(y*(p+y)),E+=g,E>=d)break t}do{let W=B*(p+B);if(W===0){X=!0;break}if(B--,V=V*W/((h-B)*(f-B)),E+=V,E>=d){y=B;break t}}while(A)}d=E*J()}e[c+N*i]=y,f-=y,u[N]=u[N]-y}e[c+(o-1)*i]=f}let a=t[o-1];for(let c=0;c<i-1;c++)a-=e[c+(o-1)*i];for(let c=0;c<o-1;c++)e[i-1+c*i]=u[c];e[i-1+(o-1)*i]=a}function pe(n,t){let r=Array.from(n,e=>Math.trunc(e));if(r.length<=1||r.some(e=>!(e>=0)||e>2147483647))throw new RangeError(`invalid argument '${t}'`);return r}function bs(n,t,r){let e=Math.trunc(n);if(!(e>=0))throw new RangeError("invalid argument 'n'");let i=pe(t,"r"),o=pe(r,"c"),u=i.reduce((f,l)=>f+l,0);if(u!==o.reduce((f,l)=>f+l,0))throw new RangeError("arguments 'r' and 'c' must have the same sums");let s=Vi(u),a=new Int32Array(i.length*o.length),c=[];for(let f=0;f<e;f++)Xi(i,o,s,a),c.push(i.map((l,N)=>o.map((h,m)=>a[N+m*i.length])));return c}export{en as a,ct as b,Wt as c,nt as d,io as e,oo as f,uo as g,Ir as h,vr as i,xr as j,K as k,Fe as l,Le as m,Ee as n,po as o,go as p,bo as q,hn as r,Vt as s,Mu as t,du as u,pu as v,cn as w,Qt as x,qo as y,Bo as z,Wo as A,Xe as B,$e as C,_u as D,Au as E,wu as F,Te as G,Je as H,ze as I,Uu as J,ju as K,Hu as L,ii as M,oi as N,Zu as O,Yu as P,Tu as Q,ci as R,li as S,rs as T,es as U,is as V,ls as W,Ns as X,Ms as Y,ds as Z,Vi as _,Xi as $,bs as aa};
|