@numero-uno-jpn/rstats 0.15.2 → 0.15.3

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/README.ja.md +8 -8
  3. package/README.md +8 -8
  4. package/dist/chunks/{chunk-PEYGUK32.js → chunk-3THFTB36.js} +2 -2
  5. package/dist/chunks/chunk-3TSWYE5L.js +2 -0
  6. package/dist/chunks/{chunk-IBPWRQIF.js → chunk-3WPU6LGK.js} +2 -2
  7. package/dist/chunks/{chunk-VWJ74UHC.js → chunk-5ITR67MB.js} +2 -2
  8. package/dist/chunks/chunk-5NRFU6F6.js +2 -0
  9. package/dist/chunks/{chunk-XNPU54NH.js → chunk-E2LCSVQV.js} +1 -1
  10. package/dist/chunks/chunk-FCNVTIPJ.js +2 -0
  11. package/dist/chunks/chunk-FKAKALOZ.js +2 -0
  12. package/dist/chunks/{chunk-HBMHR5SS.js → chunk-HD73UKPT.js} +2 -2
  13. package/dist/chunks/{chunk-4Z2XDWKV.js → chunk-IUULP3LE.js} +1 -1
  14. package/dist/chunks/{chunk-Q4PGYESP.js → chunk-JQG3YQOC.js} +2 -2
  15. package/dist/chunks/{chunk-LG74QY5U.js → chunk-KT66SB7R.js} +1 -1
  16. package/dist/chunks/{chunk-SREPSVTT.js → chunk-MAUAOQG3.js} +2 -2
  17. package/dist/chunks/{chunk-YVREYVI2.js → chunk-MDYE7QP2.js} +2 -2
  18. package/dist/chunks/{chunk-XPLDEK6D.js → chunk-NM3Z2UBQ.js} +2 -2
  19. package/dist/chunks/{chunk-AJBLCNZ7.js → chunk-PMJI5QO6.js} +2 -2
  20. package/dist/chunks/chunk-UF7KOTHF.js +3 -0
  21. package/dist/chunks/chunk-UOE57JGT.js +2 -0
  22. package/dist/chunks/{chunk-3WQCKGKP.js → chunk-USPEBXSR.js} +2 -2
  23. package/dist/chunks/{chunk-PWVQVJTP.js → chunk-VLUL2HFW.js} +1 -1
  24. package/dist/chunks/{chunk-YGT4P7EU.js → chunk-ZIX7NYQF.js} +1 -1
  25. package/dist/descriptive.js +2 -2
  26. package/dist/distributions/beta.js +11 -1
  27. package/dist/distributions/cauchy.js +76 -5
  28. package/dist/distributions/exponential.js +6 -1
  29. package/dist/distributions/f.js +41 -5
  30. package/dist/distributions/gamma.js +34 -3
  31. package/dist/distributions/geometric.js +4 -1
  32. package/dist/distributions/invgamma.js +4 -0
  33. package/dist/distributions/kumaraswamy.js +22 -4
  34. package/dist/distributions/laplace.js +5 -2
  35. package/dist/distributions/logistic.js +8 -2
  36. package/dist/distributions/lognormal.js +12 -1
  37. package/dist/distributions/nbeta.js +66 -24
  38. package/dist/distributions/nchisq.js +58 -11
  39. package/dist/distributions/negbinomial.js +6 -1
  40. package/dist/distributions/normal.js +26 -1
  41. package/dist/distributions/nt.d.ts +28 -3
  42. package/dist/distributions/nt.js +145 -19
  43. package/dist/distributions/pareto.js +5 -0
  44. package/dist/distributions/t.js +55 -3
  45. package/dist/distributions/triangular.js +35 -8
  46. package/dist/distributions/tukey.js +16 -0
  47. package/dist/distributions/uniform.js +2 -0
  48. package/dist/distributions/weibull.js +23 -3
  49. package/dist/distributions.js +2 -2
  50. package/dist/internal/ddexp.d.ts +8 -0
  51. package/dist/internal/ddexp.js +27 -0
  52. package/dist/internal/invert.d.ts +5 -0
  53. package/dist/internal/invert.js +10 -5
  54. package/dist/internal/noncentral.d.ts +7 -0
  55. package/dist/internal/noncentral.js +9 -0
  56. package/dist/internal/poissonMixture.js +29 -6
  57. package/dist/linalg.js +2 -2
  58. package/dist/mixed.js +2 -2
  59. package/dist/numerics.js +2 -2
  60. package/dist/rstats.js +14 -14
  61. package/dist/special/beta.js +7 -0
  62. package/dist/special/gamma.js +4 -0
  63. package/dist/special/igam.js +33 -6
  64. package/dist/special/incbet.js +70 -6
  65. package/dist/special/incbetLargeA.js +7 -2
  66. package/dist/special/incbetPrefactor.d.ts +5 -0
  67. package/dist/special/incbetPrefactor.js +14 -3
  68. package/dist/special/loader.js +70 -21
  69. package/dist/special.js +2 -2
  70. package/dist/tests.js +2 -2
  71. package/package.json +1 -1
  72. package/dist/chunks/chunk-2CUKVVRO.js +0 -2
  73. package/dist/chunks/chunk-D4F7GQAY.js +0 -2
  74. package/dist/chunks/chunk-EBQMGCQZ.js +0 -2
  75. package/dist/chunks/chunk-JLAH3X77.js +0 -2
  76. package/dist/chunks/chunk-RCAL4VHM.js +0 -3
  77. package/dist/chunks/chunk-UFT662QZ.js +0 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,120 @@ 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.15.3 - 2026-10-29
11
+
12
+ ### Fixed
13
+
14
+ - `qcauchy` returned ±Infinity for p between about 1.8e-309 and 5.6e-309 although the quantile is finite
15
+ (`qcauchy(2.2e-309, { lowerTail: false })` is now 1.4468631190172319e308): scale / p overflowed before the division
16
+ by π.
17
+ - `pt`, `dt` and `qt` at a huge df: from about 1.3e300 `dt` and `pt` were NaN (`pt(10, 1e305)`,
18
+ `dt(0, 1e305)`), and `qt` was off (`qt(1.31e-295, 7.19e301, { lowerTail: false })` was 36.72783758590317; now
19
+ 36.727901113286414, as R) or took a second. Above df = 1e200 the normal is used where t²/df < 1e-17, and the far tail
20
+ -(df/2) log1p(t²/df) beyond; likewise with `ncp`, where `pt(-4.05e269, 3.586e307, { ncp: 1 })` and `dt` were NaN
21
+ (R gives 0.5 for that `pt`; it is 0).
22
+ - `qt` and `dt` at a subnormal df: `qt(1e-5, 1e-310, { lowerTail: false })` was 4.26 although `pt` is 1/2 at every
23
+ finite t there (now Infinity, as at df = 1e-300 and in R), `dt(0, 5e-324)` was NaN; with `ncp`, `pt` and `dt` at
24
+ df = 5e-324 were NaN, and below df = 1e-308 tails of the order of df were 0, Infinity on the log scale or lost
25
+ digits (`pt(51.65, 2.6e-316, { ncp: 51.6 })` was 0, below its value at 49.77).
26
+ - `qt` near p = 1/2 for df between 1e-15 and about 1e-9 (`qt(0.499999999, 1e-10, { lowerTail: false })` was 0.59,
27
+ not 2425.8), and `qt(-1e100, 1e150, { logP: true })` (-1, not -1.4e50).
28
+ - `qt` with `ncp` at a tiny df and a large ncp: `qt(1e-300, 1e-300, { ncp: 1e4 })` was 1, where `pt` is 3.4e-298 (now
29
+ 2.463741370564455e-146; R gives 18961.5, with `pt(1, 1e-300, 1e4)` 0). The test for a t so near 0 that `pt` is
30
+ Φ(-δ) overflowed below df = 2e-300 with a large ncp, and at t = 0 it was NaN, so the solver's first step to 0 led
31
+ nowhere; the solver now starts from the gamma quantile where P[T <= t] is about Q(df/2, (df/2) δ²/t²) (at df = 1e-200
32
+ it took 50 ms). And `pt` with `ncp = 1e5` and `1e6` at a subnormal df was +Infinity on the log scale at some t
33
+ (`pt(1e-155, 1e-310, { ncp: 1e5, logP: true })`, now -2500000735.787591), where the peak of the integral was not
34
+ found.
35
+ - The gamma family, `chisq`, `invgamma`, `weibull` and `lnorm` at a huge parameter: from a shape, df, alpha or sdlog of
36
+ about 1e301 many calls were NaN (`pgamma(1.4e-284, 4.2e301, { rate: 0.0014, logP: true })`, now -5.643831101470294e304
37
+ as R; `pchisq(1e-300, 1e308)`, `dchisq(0.22, 5.3e306)`, `dweibull(1.9e-255, 6.6e306, { scale: 98.6 })`,
38
+ `pinvgamma(5.1e280, 2e304)`, `plnorm(2, { sdlog: 1e302 })`, `qlnorm(1e-30, { sdlog: 9.3e307 })`), where double-double
39
+ products of numbers above 1e300 overflowed in their splitting or an overflowed term met another in a sum; and
40
+ `dchisq(1e308, 1e308)` was 0, not 2.8209479177387811e-155 (2πx overflowed in the normalizing factor).
41
+ - The same functions at a subnormal parameter: `qchisq(0.5, 1e-310)` and `qgamma` at shapes below about 1e-307 were NaN
42
+ (now 0, as R); `pgamma(Inf, 892.4, { rate: 2.8e-316 })`, where 1/rate overflows, was NaN (now 1; R gives NaN) and
43
+ `qgamma` at such a rate NaN for a quantile below the normal range (now Infinity, as at other p, since `pgamma` is 0 at
44
+ every finite q there); and upper tails of the order of a shape below 1e-300 lost digits on the log scale
45
+ (`pgamma(1, 4.8e-316, { scale: 2.06, lowerTail: false, logP: true })` was 5e-9 off,
46
+ `pgamma(1e-310, 5e-324, { lowerTail: false, logP: true })` 3e-4), so that `dgamma` did not match their differences.
47
+ - The beta and F families at a huge parameter: from a shape of about 1e299 `pbeta` was NaN far from the mass
48
+ (`pbeta(1.5e-236, 9220.5, 2.6e301)`, now 1 as R; `pbeta(1e-307, 55.1, 6.3e307)`; and where b log(1 - x) is beyond the
49
+ doubles, `pbeta(0.998, 55.1, 6.3e307)` and `dbeta` there), where the double-double divisions and products of the
50
+ continued fraction overflowed in their splitting; `qbeta` was 0 after 0.8 s (`qbeta(5.9e-49, 9220.5, 2.6e301)`, now
51
+ 3.078354768366422e-298 as R) or did not return (`qbeta(8.7e-285, 1.3e304, 5.9)`, now 1; R does not converge);
52
+ `qf(1.9e-13, 0.0885, 6e302)` did not return (now the χ² limit 4.611344535319733e-287, where R gives
53
+ 4.6113445353195029e-287), and the noncentral `qf` far out took seconds (`qf(5.4e-11, 3.7e-313, 1249, { ncp: 1.7e243 })`
54
+ did not return; now Infinity, as R, from Chernoff bounds at the ends; from a df2 of about 1e40 the noncentral χ²
55
+ limit, where `qf(-385.8, 1.05, 1.1e264, { ncp: 1.7e262, logP: true })` did not return (R gives Inf)); `pf` with ncp
56
+ near the largest double was 0 in both tails (`pf(2.5e300, 1828, 0.165, { ncp: 3.7e307 })`; R gives NaN); and the
57
+ `nbinom` upper tail far out at prob near 1e-300 is no longer NaN (`pnbinom(1e303, 641, { prob: 9e-300, lowerTail: false
58
+ })`, 0).
59
+ - The beta and F families at a subnormal or tiny parameter: noncentral densities at a tiny ncp were NaN
60
+ (`dbeta(1.05e-231, 0.19, 141, { ncp: 1.4e-303 })`, `dchisq(1, 1, { ncp: 1e-310 })`, `df(2.9e-257, 0.0275, 3, { ncp:
61
+ 5e-324 })`; now the central density, which they equal to the double); the log of a beta tail of the order of a
62
+ shape below 1e-300 lost digits, so that `dbeta` did not match its differences (`pbeta(0.97, 0.13, 8.15e-322, { logP:
63
+ true })`, now -736.93155014878607; R gives -736.93128475074695); `pbeta(1 - 6e-14, 0.97, 4.7e-307, { lowerTail:
64
+ false })` was 1 - 5.5e-14 beside a lower tail of 1.4e-305 (now 1, as R); a subnormal `qbeta` was 5e-14 off
65
+ (`qbeta(3.8e-277, 27.9, 1.5e299)`, now 9.585930727509766e-309 as R); and `pf(2e-323, 0.0121, Inf)` was 0 (q df1
66
+ underflowed; now 0.01091389160021212, R gives 0).
67
+ - `qtukey` with nranges > 1 did not return where 1 - W underflows in the upper tail
68
+ (`qtukey(1.5e-287, 3, 4.7e10, { nranges: 2, lowerTail: false })`, now 51.31849500218445; R does not converge), as the
69
+ log of that tail was -Infinity (`ptukey(54.5, 3, Inf, { nranges: 2, lowerTail: false, logP: true })`, now
70
+ -744.6488312090673; R gives -Inf).
71
+ - `qcauchy` with `logP` at a subnormal scale lost digits (`qcauchy(-547.5, { location: 3.5e-180, scale: 9.1e-314,
72
+ logP: true })` was 7e-11 off; scale / π was subnormal), and was -Infinity from log p = -1420 on although the quantile
73
+ at the smallest scales is finite down to -1454.
74
+ - `qkumar` at a shape a below 1e-300 was NaN (`qkumar(4.8e-52, 9.9e-314, 2.5)`, now 0 as extraDistr); the log of the
75
+ lower tail of `pkumar` and `ppareto` at a subnormal shape lost digits (`pkumar(0.2, 0.42, 1.85e-317, { logP: true })`
76
+ was 2.5e-10 off, `ppareto(318.7, { a: 1.04e-317, logP: true })` 3e-11; extraDistr gives -Inf for both).
77
+ - `dnbinom(0, size)` from a size of about 1e299 was NaN (`dnbinom(0, 2.4e301, { prob: 1 - 2.3e-11 })`, now 0 and
78
+ -5.5037505412224715e290 on the log scale, as R).
79
+ - Noncentral χ²: from ncp = 2e290 at a tiny x, `pchisq` and `dchisq` were NaN (`pchisq(1e-308, 294, { ncp: 2.9e304
80
+ })`, now 0 as R; on the log scale -λ/2 to the double, where R's `dchisq` gives -1.02e307 instead of -1.45e304); at a
81
+ subnormal x with an odd last bit, the rounding of x/2 showed (2% at `pchisq(1.63e-322, 0.49, { ncp: 1 })`, 2e-6 in the
82
+ differences of `pchisq` against `dchisq(7.02e-315, 0.5, { ncp: 24.3 })`), and below x = 2.2e-308 the log Poisson
83
+ weights of the mixture took log Γ in double, so that `pchisq(2.1e-317, 1.2e-51, { ncp: 197 })` was 3.8e-15 above its
84
+ value at 5.3e-296 (likewise 1.4e-15 at x = 1e-307 and df = 1.1e-261). At a huge x and a tiny ncp `pchisq` and `dchisq`
85
+ were NaN (`dchisq(3e307, 0.5, { ncp: 2.2e-320 })`, `pchisq(4.2e301, 0.0115, { ncp: 1.5e-303 })`), and where x + ncp
86
+ is beyond the doubles they were wrong or NaN (`pchisq(1e308, 3.3e268, { ncp: 6.9e307 })` was 0.55, not 1, and NaN or
87
+ -Infinity above; `qchisq(-85.6, 3.3e268, { ncp: 6.9e307, logP: true })` was Infinity, not 6.939005443890441e307;
88
+ `dchisq(1.79e308, 3, { ncp: 1e308, log: true })` was -Infinity).
89
+ - `pcauchy` and `dcauchy` where q - location overflows: the smaller tail was 0 and the log density -Infinity
90
+ (`pcauchy(1.79e308, { location: -1.1e307, scale: 2.7e296, lowerTail: false })`, now 4.529328385253959e-13).
91
+ - `dnorm` at an sd below about 2.2e-309, where 1 / sd overflows, was NaN (`dnorm(4.85e-319, { sd: 1.7e-322 })`, now 0;
92
+ `dnorm(30 sd, { sd })` is now 8.772626419912559e125 there).
93
+ - `qtriang` with a subnormal width returned the mode where the tail's share of its part overflowed
94
+ (`qtriang(1.6e-8, { a: 0, b: 1.03e-316, c: 8.7e-317, lowerTail: false })`, now 1.02817096e-316).
95
+ - Quantile searches at a subnormal p: the residual F(x) / p overflowed, and the steps went astray
96
+ (`qgamma(7.2e-317, 3.3e126, { scale: 0.136, lowerTail: false })` was 8.2e146, 1e21 times the mean; now
97
+ 4.4838914172971214e125, as R).
98
+ - `pbeta` at a subnormal x and a shape above 1e300 was NaN (`pbeta(1.5e-323, 1.4e304, 0.5)`, now 0 as R, and
99
+ -1.0617460181147866e307 on the log scale; `pbeta(4.2e-310, 4.1e307, 1113)`, where a log x overflows, now 0).
100
+ - `pf` at a subnormal df1 was 1 in the upper tail from x = 1e301 on (`pf(1e301, 1.4e-312, 6.72, { lowerTail: false })`,
101
+ now 1.77365978354e-311), and `qf` there did not return (`qf(1.1e-322, 1.4e-312, 6.72, { lowerTail: false })`, now
102
+ Infinity as R); `qf` whose search stepped to Infinity, where `pf` was NaN, returned 1 after 5 s
103
+ (`qf(-735.2, 1.25e-305, 3.3e5, { lowerTail: false, logP: true })`, now 4.63214927370753e306); the noncentral `qf` at
104
+ a huge ncp took a second (`qf(3.97e-237, 364.4, 1.476, { ncp: 1.94e11 })`).
105
+ - `ptukey` at a subnormal q lost digits (3e-11 in the log at `ptukey(3.53e-316, 2, 486.9, { logP: true })`) and took
106
+ 20 to 50 ms a call, so that `qtukey(-726.9, 2, 486.9, { logP: true })` took 1.2 s: the lower tail is now scaled from
107
+ q = 2^-1000 by q^((k-1) r).
108
+ - `lgamma` at a subnormal argument was Infinity (`lgamma(5e-324)`, now 744.4400719213812 as R), and with it `lbeta`
109
+ (`lbeta(5e-324, 3)`); `lbeta(1e-310, 1e-310)` was NaN (now 714.494526008714 as R), `beta(1e-310, 1e-310)` NaN (now
110
+ Infinity; R gives NaN).
111
+ - Densities whose linear value passed through a subnormal intermediate lost digits: `dlaplace` and `dlogis` through
112
+ exp(-|z|) (`dlaplace(9.4863e-158, { mu: 9.4863e-158 + 4.5e-167, sigma: 6.04e-171 })` was 6e-4 off; extraDistr is
113
+ right there), `dlogis`, `dcauchy` and `dnorm` through a subnormal scale (`dnorm(-1.59e-321, { sd: 3e-323 })` 3e-4
114
+ off; `dcauchy(1e-10, { scale: 5e-324 })` was 0, now 1.5726597949504821e-304), `dnbinom` through size / (size + x) at
115
+ a subnormal size (`dnbinom(57, 3.94e-315, { prob: 0.125, log: true })` was 2.4e-8 off), and `dtriang` through a
116
+ subnormal ratio of lengths, as was the log of `ptriang` (extraDistr gives -Inf for it).
117
+ - Quantiles at a log p below -708: `qexp`, `qweibull` and `qkumar` took exp(p) on the subnormal grid
118
+ (`qexp(-720.6, { rate: 7.4e-258, logP: true })` was 4e-14 off, `qkumar(-744.24, 1.13, 0.124, { logP: true })` 17%;
119
+ extraDistr gives 0 for it).
120
+ - `pgeom` at a subnormal prob was 0 from x = 1e290 on (`pgeom(1e290, 5e-324)`, now 4.940656458412465e-34).
121
+ - Gamma and Poisson tails of a few subnormal ulps were 0 (`pchisq(150856.77, 172464.33)`, now 1e-323 as R; its log
122
+ was right): the factor x^a e^-x / Γ(a + 1) underflowed before the product with the series.
123
+
10
124
  ## 0.15.2 - 2026-10-28
11
125
 
12
126
  ### Fixed
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.15.2。** R の stats パッケージの数値計算の中心
19
+ 状態: **0.15.3。** R の stats パッケージの数値計算の中心
20
20
  (分布・記述統計・検定・線形モデル・特殊関数・数値計算・線形代数の基本) を、R と同じ結果でカバーすることを目指しています。残っている作業は
21
21
  [ROADMAP.ja.md](ROADMAP.ja.md)、変更履歴は [CHANGELOG.md](CHANGELOG.md) (英語) にあります。
22
22
 
@@ -251,11 +251,11 @@ double-double 演算で計算しているためです。詳しくは [docs/ja/ac
251
251
  | `pnorm` | 1.2 KB |
252
252
  | `setSeed`, `rnorm` | 1.7 KB |
253
253
  | `solve` / `svd` / `eigen` | 1.7 / 2.0 / 4.5 KB |
254
- | `wilcoxTest` / `fisherTest` / `tTest` | 12.8 / 15.8 / 26.7 KB |
255
- | `qbeta` / `pt` と `qt` | 40.4 / 33.0 KB |
256
- | `glm` と `glmSummary` / `glm` とそのすべての関数 | 29.1 / 41.5 KB |
257
- | `lmer` (`/mixed` から) / `lmerSummary`・`lmerContest`・`lmerAnova` も | 16.5 / 61.0 KB |
258
- | すべて (`/mixed` を除く) | 198.6 KB |
254
+ | `wilcoxTest` / `fisherTest` / `tTest` | 12.8 / 15.9 / 27.5 KB |
255
+ | `qbeta` / `pt` と `qt` | 41.4 / 35.9 KB |
256
+ | `glm` と `glmSummary` / `glm` とそのすべての関数 | 30.1 / 42.7 KB |
257
+ | `lmer` (`/mixed` から) / `lmerSummary`・`lmerContest`・`lmerAnova` も | 16.5 / 62.0 KB |
258
+ | すべて (`/mixed` を除く) | 201.9 KB |
259
259
 
260
260
  (`npm run size` で測れます。)
261
261
 
@@ -265,12 +265,12 @@ double-double 演算で計算しているためです。詳しくは [docs/ja/ac
265
265
  できません。メインの入口には含めていません)。
266
266
 
267
267
  バンドラを使わない場合は、1 ファイルにまとめたビルド `dist/rstats.js` (`/mixed` 以外のすべての関数を含む
268
- minify 済みの ES モジュール、gzip で 199 KB) を jsDelivr から読み込めます。jsDelivr は、npm のリリースを
268
+ minify 済みの ES モジュール、gzip で 202 KB) を jsDelivr から読み込めます。jsDelivr は、npm のリリースを
269
269
  そのまま配信します。
270
270
 
271
271
  ```html
272
272
  <script type="module">
273
- import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.15.2/dist/rstats.js";
273
+ import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.15.3/dist/rstats.js";
274
274
  console.log(pnorm(1.96)); // 0.9750021048517795
275
275
  </script>
276
276
  ```
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.15.2.** The goal is to cover the numerical core of R's
17
+ Status: **0.15.3.** 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
 
@@ -247,11 +247,11 @@ removed. Approximate sizes after minification and gzip:
247
247
  | `pnorm` | 1.2 KB |
248
248
  | `setSeed`, `rnorm` | 1.7 KB |
249
249
  | `solve` / `svd` / `eigen` | 1.7 / 2.0 / 4.5 KB |
250
- | `wilcoxTest` / `fisherTest` / `tTest` | 12.8 / 15.8 / 26.7 KB |
251
- | `qbeta` / `pt` and `qt` | 40.4 / 33.0 KB |
252
- | `glm` and `glmSummary` / `glm` with all its methods | 29.1 / 41.5 KB |
253
- | `lmer` (from `/mixed`) / with `lmerSummary`, `lmerContest`, `lmerAnova` | 16.5 / 61.0 KB |
254
- | everything (except `/mixed`) | 198.6 KB |
250
+ | `wilcoxTest` / `fisherTest` / `tTest` | 12.8 / 15.9 / 27.5 KB |
251
+ | `qbeta` / `pt` and `qt` | 41.4 / 35.9 KB |
252
+ | `glm` and `glmSummary` / `glm` with all its methods | 30.1 / 42.7 KB |
253
+ | `lmer` (from `/mixed`) / with `lmerSummary`, `lmerContest`, `lmerAnova` | 16.5 / 62.0 KB |
254
+ | everything (except `/mixed`) | 201.9 KB |
255
255
 
256
256
  (`npm run size` measures these.)
257
257
 
@@ -261,11 +261,11 @@ Each area is also a subpath export, for importing one area without the rest:
261
261
  (`lmer` and lmerTest's tests; this area is only available this way, not from the main entry point).
262
262
 
263
263
  Without a bundler, load the single-file build `dist/rstats.js` (one minified ES module with every
264
- function except those of `/mixed`, 199 KB gzipped) from jsDelivr, which serves each npm release:
264
+ function except those of `/mixed`, 202 KB gzipped) from jsDelivr, which serves each npm release:
265
265
 
266
266
  ```html
267
267
  <script type="module">
268
- import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.15.2/dist/rstats.js";
268
+ import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@0.15.3/dist/rstats.js";
269
269
  console.log(pnorm(1.96)); // 0.9750021048517795
270
270
  </script>
271
271
  ```
@@ -1,2 +1,2 @@
1
- /*! rStats.js 0.15.2 | 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{b as A}from"./chunk-PWVQVJTP.js";var h=r=>new SyntaxError(`invalid formula: ${r}`);function N(r,u){let o=[],s=0;for(;s<r.length;){let i=r[s];if(/\s/.test(i)){s++;continue}if(/[0-9]/.test(i)||i==="."&&/[0-9]/.test(r[s+1]??"")){let e=/^(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:[eE][+-]?[0-9]+)?/.exec(r.slice(s));o.push({kind:"num",text:e[0]}),s+=e[0].length;continue}if(/[A-Za-z.]/.test(i)){let e=/^[A-Za-z.][A-Za-z0-9._]*/.exec(r.slice(s));o.push({kind:"name",text:e[0]}),s+=e[0].length;continue}if(r.startsWith("%in%",s)){o.push({kind:"op",text:"%in%"}),s+=4;continue}if(u&&i==="|"){let e=r[s+1]==="|"?"||":"|";o.push({kind:"op",text:e}),s+=e.length;continue}if("~+-*/:^()".includes(i)){o.push({kind:"op",text:i}),s++;continue}throw h(`unexpected '${i}'`)}return o.push({kind:"end"}),o}var O={"|":.5,"||":.5,"+":1,"-":1,"*":2,"/":2,"%in%":3,":":4,"^":6},z=5;function B(r,u=!1,o=!1){if(typeof r!="string")throw new TypeError("the formula must be a string");let s=N(r,o),i=0,e=()=>s[i],n=()=>s[i++],c=(t,a)=>t.kind==="op"&&t.text===a;function f(){let t=n();if(t.kind==="name"){if(c(e(),"(")){if(t.text!=="Error"||!u)throw h(`function calls are not supported (${t.text})`);n();let a=l(0);if(!c(n(),")"))throw h("missing ')'");return{type:"Error",arg:a}}if(t.text===".")return{type:"dot"};if(/^\.[0-9]/.test(t.text))throw h(`unexpected '${t.text}'`);return{type:"var",name:t.text}}if(t.kind==="num")return{type:"num",value:Number(t.text),text:t.text};if(t.kind==="op"&&t.text==="("){let a=l(0);if(!c(n(),")"))throw h("missing ')'");return{type:"paren",arg:a}}if(t.kind==="op"&&(t.text==="-"||t.text==="+"))return{type:"unary",op:t.text,arg:l(z)};throw h(t.kind==="end"?"unexpected end of input":`unexpected '${t.kind==="op"?t.text:""}'`)}function l(t){let a=f();for(;;){let p=e();if(p.kind!=="op")break;let d=O[p.text];if(d===void 0||d<=t)break;n();let y=l(p.text==="^"?d-1:d);a=p.text==="|"||p.text==="||"?{type:"bar",double:p.text==="||",lhs:a,group:y}:{type:"binary",op:p.text,left:a,right:y}}return a}let m;if(!c(e(),"~")){let t=n();if(t.kind!=="name"||t.text==="."||!c(e(),"~"))throw h("the response must be a variable name followed by '~'");m=t.text}n();let x=l(0);if(e().kind!=="end")throw h("unexpected input after the formula");return{response:m,rhs:x}}function C(r){let u=[],o=e=>{if(e.type==="Error"){u.push(e.arg);return}if(e.type==="binary"&&e.op==="+"){let n=o(e.left),c=o(e.right);return n===void 0?c:c===void 0?n:{...e,left:n,right:c}}if(e.type==="binary"&&e.op==="-"){let n=o(e.left);return n===void 0?{type:"unary",op:"-",arg:e.right}:{...e,left:n}}return e},s=o(r),i=e=>{if(e.type==="Error")throw h("Error() must be a term of the right-hand side");e.type==="binary"?(i(e.left),i(e.right)):(e.type==="unary"||e.type==="paren")&&i(e.arg)};return s!==void 0&&i(s),u.forEach(i),{treatment:s,errors:u}}function F(r){let u=[],o=e=>{switch(e.type){case"bar":u.push(e);return;case"paren":{let n=o(e.arg);return n===void 0?void 0:{...e,arg:n}}case"binary":if(e.op==="+"){let n=o(e.left),c=o(e.right);return n===void 0?c:c===void 0?n:{...e,left:n,right:c}}if(e.op==="-"){let n=o(e.left);return n===void 0?{type:"unary",op:"-",arg:e.right}:{...e,left:n}}return e;default:return e}},s=o(r),i=e=>{if(e.type==="bar")throw h("a random-effects term (lhs | group) must be a term of the right-hand side");e.type==="binary"?(i(e.left),i(e.right)):(e.type==="unary"||e.type==="paren"||e.type==="Error")&&i(e.arg)};s!==void 0&&i(s);for(let e of u)i(e.lhs),i(e.group);return{fixed:s,bars:u}}var R=new Set(["+","-","*","%in%"]);function g(r){switch(r.type){case"var":return r.name;case"dot":return".";case"num":return A(r.value);case"binary":{let u=g(r.left),o=g(r.right);return R.has(r.op)?`${u} ${r.op} ${o}`:`${u}${r.op}${o}`}case"unary":return`${r.op}${g(r.arg)}`;case"paren":return`(${g(r.arg)})`;case"Error":return`Error(${g(r.arg)})`;case"bar":return`${g(r.lhs)} ${r.double?"||":"|"} ${g(r.group)}`}}function b(r,u,o){if(r!==void 0)switch(r.type){case"var":o.includes(r.name)||o.push(r.name);return;case"dot":for(let s of u)o.includes(s)||o.push(s);return;case"num":return;case"binary":b(r.left,u,o),r.op!=="^"&&b(r.right,u,o);return;case"unary":case"paren":case"Error":b(r.arg,u,o);return;case"bar":b(r.lhs,u,o),b(r.group,u,o)}}function I(r,u){let o=[];return b(r,u,o),o}var E=r=>r.join(",");function k(r){let u=new Set;return r.filter(o=>{let s=E(o);return u.has(s)?!1:(u.add(s),!0)})}var $=(r,u)=>[...new Set([...r,...u])].sort((o,s)=>o-s);function T(r,u,o){let s=!0,i=(n,c)=>{switch(n.type){case"var":return[[u(n.name)]];case"dot":return o.map(f=>[u(f)]);case"num":if(n.value===1)s=!c;else if(n.value===0)s=c;else throw h(`a number (${n.text}) is not a term`);return[];case"paren":return i(n.arg,c);case"Error":throw h("Error() must be a term of the right-hand side");case"bar":throw h("a random-effects term (lhs | group) must be a term of the right-hand side");case"unary":return n.op==="+"?i(n.arg,c):(i(n.arg,!c),[]);case"binary":{if(n.op==="^"){let t=i(n.left,c),a=n.right;for(;a.type==="paren";)a=a.arg;let p=a.type==="num"?Math.trunc(a.value):NaN;if(!(p>=2))throw new Error("invalid power in formula");let d=t;for(let y=1;y<p;y++){let w=[];for(let v of t)for(let S of d)w.push($(v,S));d=k(w)}return d}if(n.op==="-"){let t=i(n.left,c),a=new Set(i(n.right,!c).map(E));return t.filter(p=>!a.has(E(p)))}let f=i(n.left,c),l=i(n.right,c);if(f.length===0&&n.op!=="+")return[];let m=()=>{let t=[];for(let a of f)for(let p of l)t.push($(a,p));return t},x=t=>t.reduce((a,p)=>$(a,p),[]);switch(n.op){case"+":return k([...f,...l]);case":":return k(m());case"*":return k([...f,...l,...m()]);case"/":{let t=x(f);return k([...f,...l.map(a=>$(a,t))])}case"%in%":{let t=x(l);return k(f.map(a=>$(a,t)))}}}}throw h("unsupported expression")};return{terms:r===void 0?[]:i(r,!1),intercept:s}}function L(r,u,o=r.rhs){let{response:s}=r,i=u.filter(t=>t!==s),e=s===void 0?[]:[s];b(r.rhs,i,e);let c=T(o,t=>e.indexOf(t),i),f=c.terms.map((t,a)=>[t,a]).sort((t,a)=>t[0].length-a[0].length||t[1]-a[1]).map(([t])=>t),l=[],m=s===void 0?-1:f.findIndex(t=>t.length===1&&t[0]===0);m>=0&&(l.push("the response appeared on the right-hand side and was dropped"),l.push(`problem with term ${m+1} in model.matrix: no columns are assigned`));let x=e.map(()=>f.map(()=>0));return f.forEach((t,a)=>{for(let p of t){let d=t.filter(w=>w!==p),y=d.length===0||f.slice(0,a).some(w=>d.every(v=>w.includes(v)));x[p][a]=y?1:2}}),{variables:e,response:s===void 0?-1:0,terms:f,termLabels:f.map(t=>t.map(a=>e[a]).join(":")),order:f.map(t=>t.length),intercept:c.intercept,factors:x,responseTerm:m,warnings:l}}export{B as a,C as b,F as c,g as d,I as e,T as f,L as g};
1
+ /*! rStats.js 0.15.3 | 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{b as A}from"./chunk-VLUL2HFW.js";var h=r=>new SyntaxError(`invalid formula: ${r}`);function N(r,u){let o=[],s=0;for(;s<r.length;){let i=r[s];if(/\s/.test(i)){s++;continue}if(/[0-9]/.test(i)||i==="."&&/[0-9]/.test(r[s+1]??"")){let e=/^(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:[eE][+-]?[0-9]+)?/.exec(r.slice(s));o.push({kind:"num",text:e[0]}),s+=e[0].length;continue}if(/[A-Za-z.]/.test(i)){let e=/^[A-Za-z.][A-Za-z0-9._]*/.exec(r.slice(s));o.push({kind:"name",text:e[0]}),s+=e[0].length;continue}if(r.startsWith("%in%",s)){o.push({kind:"op",text:"%in%"}),s+=4;continue}if(u&&i==="|"){let e=r[s+1]==="|"?"||":"|";o.push({kind:"op",text:e}),s+=e.length;continue}if("~+-*/:^()".includes(i)){o.push({kind:"op",text:i}),s++;continue}throw h(`unexpected '${i}'`)}return o.push({kind:"end"}),o}var O={"|":.5,"||":.5,"+":1,"-":1,"*":2,"/":2,"%in%":3,":":4,"^":6},z=5;function B(r,u=!1,o=!1){if(typeof r!="string")throw new TypeError("the formula must be a string");let s=N(r,o),i=0,e=()=>s[i],n=()=>s[i++],c=(t,a)=>t.kind==="op"&&t.text===a;function f(){let t=n();if(t.kind==="name"){if(c(e(),"(")){if(t.text!=="Error"||!u)throw h(`function calls are not supported (${t.text})`);n();let a=l(0);if(!c(n(),")"))throw h("missing ')'");return{type:"Error",arg:a}}if(t.text===".")return{type:"dot"};if(/^\.[0-9]/.test(t.text))throw h(`unexpected '${t.text}'`);return{type:"var",name:t.text}}if(t.kind==="num")return{type:"num",value:Number(t.text),text:t.text};if(t.kind==="op"&&t.text==="("){let a=l(0);if(!c(n(),")"))throw h("missing ')'");return{type:"paren",arg:a}}if(t.kind==="op"&&(t.text==="-"||t.text==="+"))return{type:"unary",op:t.text,arg:l(z)};throw h(t.kind==="end"?"unexpected end of input":`unexpected '${t.kind==="op"?t.text:""}'`)}function l(t){let a=f();for(;;){let p=e();if(p.kind!=="op")break;let d=O[p.text];if(d===void 0||d<=t)break;n();let y=l(p.text==="^"?d-1:d);a=p.text==="|"||p.text==="||"?{type:"bar",double:p.text==="||",lhs:a,group:y}:{type:"binary",op:p.text,left:a,right:y}}return a}let m;if(!c(e(),"~")){let t=n();if(t.kind!=="name"||t.text==="."||!c(e(),"~"))throw h("the response must be a variable name followed by '~'");m=t.text}n();let x=l(0);if(e().kind!=="end")throw h("unexpected input after the formula");return{response:m,rhs:x}}function C(r){let u=[],o=e=>{if(e.type==="Error"){u.push(e.arg);return}if(e.type==="binary"&&e.op==="+"){let n=o(e.left),c=o(e.right);return n===void 0?c:c===void 0?n:{...e,left:n,right:c}}if(e.type==="binary"&&e.op==="-"){let n=o(e.left);return n===void 0?{type:"unary",op:"-",arg:e.right}:{...e,left:n}}return e},s=o(r),i=e=>{if(e.type==="Error")throw h("Error() must be a term of the right-hand side");e.type==="binary"?(i(e.left),i(e.right)):(e.type==="unary"||e.type==="paren")&&i(e.arg)};return s!==void 0&&i(s),u.forEach(i),{treatment:s,errors:u}}function F(r){let u=[],o=e=>{switch(e.type){case"bar":u.push(e);return;case"paren":{let n=o(e.arg);return n===void 0?void 0:{...e,arg:n}}case"binary":if(e.op==="+"){let n=o(e.left),c=o(e.right);return n===void 0?c:c===void 0?n:{...e,left:n,right:c}}if(e.op==="-"){let n=o(e.left);return n===void 0?{type:"unary",op:"-",arg:e.right}:{...e,left:n}}return e;default:return e}},s=o(r),i=e=>{if(e.type==="bar")throw h("a random-effects term (lhs | group) must be a term of the right-hand side");e.type==="binary"?(i(e.left),i(e.right)):(e.type==="unary"||e.type==="paren"||e.type==="Error")&&i(e.arg)};s!==void 0&&i(s);for(let e of u)i(e.lhs),i(e.group);return{fixed:s,bars:u}}var R=new Set(["+","-","*","%in%"]);function g(r){switch(r.type){case"var":return r.name;case"dot":return".";case"num":return A(r.value);case"binary":{let u=g(r.left),o=g(r.right);return R.has(r.op)?`${u} ${r.op} ${o}`:`${u}${r.op}${o}`}case"unary":return`${r.op}${g(r.arg)}`;case"paren":return`(${g(r.arg)})`;case"Error":return`Error(${g(r.arg)})`;case"bar":return`${g(r.lhs)} ${r.double?"||":"|"} ${g(r.group)}`}}function b(r,u,o){if(r!==void 0)switch(r.type){case"var":o.includes(r.name)||o.push(r.name);return;case"dot":for(let s of u)o.includes(s)||o.push(s);return;case"num":return;case"binary":b(r.left,u,o),r.op!=="^"&&b(r.right,u,o);return;case"unary":case"paren":case"Error":b(r.arg,u,o);return;case"bar":b(r.lhs,u,o),b(r.group,u,o)}}function I(r,u){let o=[];return b(r,u,o),o}var E=r=>r.join(",");function k(r){let u=new Set;return r.filter(o=>{let s=E(o);return u.has(s)?!1:(u.add(s),!0)})}var $=(r,u)=>[...new Set([...r,...u])].sort((o,s)=>o-s);function T(r,u,o){let s=!0,i=(n,c)=>{switch(n.type){case"var":return[[u(n.name)]];case"dot":return o.map(f=>[u(f)]);case"num":if(n.value===1)s=!c;else if(n.value===0)s=c;else throw h(`a number (${n.text}) is not a term`);return[];case"paren":return i(n.arg,c);case"Error":throw h("Error() must be a term of the right-hand side");case"bar":throw h("a random-effects term (lhs | group) must be a term of the right-hand side");case"unary":return n.op==="+"?i(n.arg,c):(i(n.arg,!c),[]);case"binary":{if(n.op==="^"){let t=i(n.left,c),a=n.right;for(;a.type==="paren";)a=a.arg;let p=a.type==="num"?Math.trunc(a.value):NaN;if(!(p>=2))throw new Error("invalid power in formula");let d=t;for(let y=1;y<p;y++){let w=[];for(let v of t)for(let S of d)w.push($(v,S));d=k(w)}return d}if(n.op==="-"){let t=i(n.left,c),a=new Set(i(n.right,!c).map(E));return t.filter(p=>!a.has(E(p)))}let f=i(n.left,c),l=i(n.right,c);if(f.length===0&&n.op!=="+")return[];let m=()=>{let t=[];for(let a of f)for(let p of l)t.push($(a,p));return t},x=t=>t.reduce((a,p)=>$(a,p),[]);switch(n.op){case"+":return k([...f,...l]);case":":return k(m());case"*":return k([...f,...l,...m()]);case"/":{let t=x(f);return k([...f,...l.map(a=>$(a,t))])}case"%in%":{let t=x(l);return k(f.map(a=>$(a,t)))}}}}throw h("unsupported expression")};return{terms:r===void 0?[]:i(r,!1),intercept:s}}function L(r,u,o=r.rhs){let{response:s}=r,i=u.filter(t=>t!==s),e=s===void 0?[]:[s];b(r.rhs,i,e);let c=T(o,t=>e.indexOf(t),i),f=c.terms.map((t,a)=>[t,a]).sort((t,a)=>t[0].length-a[0].length||t[1]-a[1]).map(([t])=>t),l=[],m=s===void 0?-1:f.findIndex(t=>t.length===1&&t[0]===0);m>=0&&(l.push("the response appeared on the right-hand side and was dropped"),l.push(`problem with term ${m+1} in model.matrix: no columns are assigned`));let x=e.map(()=>f.map(()=>0));return f.forEach((t,a)=>{for(let p of t){let d=t.filter(w=>w!==p),y=d.length===0||f.slice(0,a).some(w=>d.every(v=>w.includes(v)));x[p][a]=y?1:2}}),{variables:e,response:s===void 0?-1:0,terms:f,termLabels:f.map(t=>t.map(a=>e[a]).join(":")),order:f.map(t=>t.length),intercept:c.intercept,factors:x,responseTerm:m,warnings:l}}export{B as a,C as b,F as c,g as d,I as e,T as f,L as g};
@@ -0,0 +1,2 @@
1
+ /*! rStats.js 0.15.3 | 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 G1,b as S,c as k1,d as h,e as R3,f as A,g as E,h as b,i as O1,j as D3,k as m}from"./chunk-KT66SB7R.js";function v(e,t){let n=t[0];for(let o=1;o<t.length;o++)n=n*e+t[o];return n}function T(e,t){let n=e+t[0];for(let o=1;o<t.length;o++)n=n*e+t[o];return n}var Qe=[2461969814735305e-25,.5641895648310689,7.463210564422699,48.63719709856814,196.5208329560771,526.4451949954773,934.5285271719576,1027.5518868951572,557.5353353693994],ze=[13.228195115474499,86.70721408859897,354.9377788878199,975.7085017432055,1823.9091668790973,2246.3376081871097,1656.6630919416134,557.5353408177277],Be=[.5641895835477551,1.275366707599781,5.019050422511805,6.160210979930536,7.4097426995044895,2.9788666537210022],Xe=[2.2605286322011726,9.396035249380015,12.048953980809666,17.08144507475659,9.608968090632859,3.369076451000815],He=[9.604973739870516,90.02601972038427,2232.005345946843,7003.325141128051,55592.30130103949],Ue=[33.56171416475031,521.3579497801527,4594.323829709801,22629.000061389095,49267.39426086359],je=709.782712893384,Ve=.5641895835477563;function b1(e){if(Number.isNaN(e))return NaN;if(e<0)return-b1(-e);if(e>1)return 1-C1(e);let t=e*e;return e*v(t,He)/T(t,Ue)}function C1(e){if(Number.isNaN(e))return NaN;let t=Math.abs(e);if(t<1)return 1-b1(e);if(e<0)return 2-C1(t);let[n,o]=k1(t,t);if(n>je+40)return 0;let r=E3(t)*(1-o);return n<700?Math.exp(-n)*r:Math.exp(700-n)*r*Math.exp(-700)}function o1(e){return Number.isNaN(e)?NaN:e<1?Math.exp(e*e)*(1-b1(e)):e>1e8?Ve/e:E3(e)}function E3(e){return e<8?v(e,Qe)/T(e,ze):v(e,Be)/T(e,Xe)}var Ye=[-59.96335010141079,98.00107541859997,-56.67628574690703,13.931260938727968,-1.2391658386738125],Ke=[1.9544885833814176,4.676279128988815,86.36024213908905,-225.46268785411937,200.26021238006066,-82.03722561683334,15.90562251262117,-1.1833162112133],Ze=[4.0554489230596245,31.525109459989388,57.16281922464213,44.08050738932008,14.684956192885803,2.1866330685079025,-.1402560791713545,-.03504246268278482,-.0008574567851546854],Je=[15.779988325646675,45.39076351288792,41.3172038254672,15.04253856929075,2.504649462083094,-.14218292285478779,-.03808064076915783,-.0009332594808954574],We=[3.2377489177694603,6.915228890689842,3.9388102529247444,1.3330346081580755,.20148538954917908,.012371663481782003,.00030158155350823543,26580697468673755e-22,6239745391849833e-24],$e=[6.02427039364742,3.6798356385616087,1.3770209948908132,.21623699359449663,.013420400608854318,.00032801446468212774,28924786474538068e-22,6790194080099813e-24],T3=.1353352832366127,xe=2.5066282746310007;function q3(e){let t=e-Math.log(e)/e,n=1/e,o=e<8?n*v(n,Ze)/T(n,Je):n*v(n,We)/T(n,$e);return t-o}function Q1(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-T3&&(t=1-t,n=!1),t>T3){t=t-.5;let r=t*t;return(t+t*(r*v(r,Ye)/T(r,Ke)))*xe}let o=q3(Math.sqrt(-2*Math.log(t)));return n?-o:o}function w3(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-q3(t)}return e>-.14541345786885906?-Q1(-Math.expm1(e)):Q1(Math.exp(e))}function z1(e,t){return typeof e=="number"?t(e):e instanceof Float64Array?e.map(t):e.map(n=>t(n))}var B1=Math.SQRT1_2;function G3(e,t){if(e>1e10)return 0;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 O0(e){let t=-e;return t<Math.SQRT2?.5-.5*b1(t*B1):G3(t,.5*o1(t*B1))}function k3(e,t){if(!t)return e<=0?O0(e):1-O0(-e);if(e>-1)return Math.log1p(-O0(-e));let n=-e;return Math.log(.5*o1(n*B1))-n*n/2}function e5(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,i=o?r?0:1:r?-1/0:0;if(n<0)return NaN;if(n===0)return e<t?s:i;let c=(e-t)/n;return Number.isFinite(c)?k3(o?c:-c,r):e<t?s:i}function t5(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 i=r?o5(e):Q1(e);return t+n*(o?i:-i)}var n5=.7978845608028654;function o5(e){let t=w3(e);if(!(e<-2048)||!Number.isFinite(t))return t;let n=n5/o1(-t*B1),o=(k3(t,!0)-e)/n;return Number.isFinite(o)?t-o:t}var r5=.9189385332046728,O3=.3989422804014327;function s5(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;if(!Number.isFinite(r))return o?-1/0:0;if(o)return-(r5+.5*r*r+Math.log(n));let s=O3/n;return s<1/0?G3(Math.abs(r),s):i5(Math.abs(r),n)}function i5(e,t){if(e>1e10)return 0;let n=Math.floor(e*16)/16,o=e-n,r=n*n/2,s=O3/(t*2**600)*Math.exp(-o*(e+n)/2);if(r<=700)return s*Math.exp(-r)*2**600;if(r>1400)return s*Math.exp(1400-r)*Math.exp(-700)*2**600*Math.exp(-700);let i=s*Math.exp(700-r);return i>=1?i*Math.exp(-700)*2**600:i*2**600*Math.exp(-700)}function h6(e,t={}){let{mean:n=0,sd:o=1,log:r=!1}=t;return z1(e,s=>s5(s,n,o,r))}function M6(e,t={}){let{mean:n=0,sd:o=1,lowerTail:r=!0,logP:s=!1}=t;return z1(e,i=>e5(i,n,o,r,s))}function m6(e,t={}){let{mean:n=0,sd:o=1,lowerTail:r=!0,logP:s=!1}=t;return z1(e,i=>t5(i,n,o,r,s))}var _=11102230246251565e-32;var G=171.6243769563027,g1=.9189385332046728,C3=1.1447298858494002;var C0=.5772156649015329;var c5=[.00016011952247675185,.0011913514700658638,.010421379756176158,.04763678004571372,.20744822764843598,.4942148268014971,1],u5=[-23158187332412014e-21,.0005396055804933034,-.004456419138517973,.011813978522206043,.035823639860549865,-.23459179571824335,.0714304917030273,1];function X3(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 Q3(e){if(e>=G)return 1/0;let t=e-1,n=h(b(m([t,0]),t),[-t+N5(t),0]);return Math.sqrt(2*Math.PI*t)*Math.exp(n[0])*(1+n[1])}function z(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*X3(s),s===0?r*(1/0):r*Math.PI/(Math.abs(s)*Q3(t))}return Q3(e)}let n=1;for(;e>=3;)e-=1,n*=e;for(;e<0;){if(e>-1e-9)return z3(e,n);n/=e,e+=1}for(;e<2;){if(e<1e-9)return z3(e,n);n/=e,e+=1}return e===2?n:(e-=2,n*v(e,c5)/v(e,u5))}function z3(e,t){return e===0?NaN:t/((1+C0*e)*e)}var f5=[.0008116141674705085,-.0005950619042843014,.0007936503404577169,-.002777777777300997,.08333333333333319],a5=[-1378.2515256912086,-38801.631513463784,-331612.9927388712,-1162370974927623e-9,-1.7217370082083966e6,-853555.6642457654],l5=[-351.81570143652345,-17064.210665188115,-220528.59055385445,-1.1393344436798252e6,-2.5325230717758294e6,-2.0188914143353277e6],h5=2556348e299;function M5(e){let t=(e-.5)*Math.log(e)-e+g1;if(e>1e8)return t;let n=1/(e*e);return t+((.0007936507936507937*n-.002777777777777778)*n+.08333333333333333)/e}function q(e){if(!Number.isFinite(e))return{value:e===-1/0?1/0:e,sign:1};if(e<-34){let o=-e,r=q(o).value,s=Math.floor(o);if(s===o)return{value:1/0,sign:1};let i=s%2===0?-1:1,c=o-s;return c>.5&&(s+=1,c=s-o),c=o*X3(c),c===0?{value:1/0,sign:1}:{value:C3-Math.log(c)-r,sign:i}}if(e!==0&&Math.abs(e)<1e-300)return{value:-Math.log(Math.abs(e)),sign:e>0?1:-1};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 i=1;if(o<0&&(i=-1,o=-o),s===2)return{value:Math.log(o),sign:i};r-=2;let c=e+r;return{value:Math.log(o)+c*v(c,a5)/T(c,l5),sign:i}}if(e>h5)return{value:1/0,sign:1};if(e>=1e3)return{value:M5(e),sign:1};let t=(e-.5)*Math.log(e)-e+g1,n=1/(e*e);return{value:t+v(n,f5)/e,sign:1}}function k(e){return Math.abs(e-1)<=.2?Z(e-1):Math.abs(e-2)<=.2?Z(e-2)+Math.log1p(e-2):q(e).value}var m5=[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 B3(e){if(e===0)return 0;let t=-C0*e,n=-e;for(let o=2;o<42;o++){n*=-e;let r=m5[o-2]*n/o;if(t+=r,Math.abs(r)<_*Math.abs(t))break}return t}function Z(e){return Math.abs(e)<=.2?B3(e):Math.abs(e-1)<=.2?Math.log(e)+B3(e-1):k(e+1)}var p5=[1/12,-1/360,1/1260,-1/1680,1/1188,-691/360360,1/156];function N5(e){let t=1/(e*e),n=0,o=1/e;for(let r of p5)n+=r*o,o*=t;return n}var H3=[1/12,-1/360,1/1260,-1/1680,1/1188,-691/360360,1/156];function U3(e,t){let n=Q0(e,t);return n[0]+n[1]}function Q0(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),i=Math.abs(s)>2&&Number.isFinite(s)&&e<1e300?b(m(S(o,e)),e):[s,0],c=(o-.5)*r-e,u=1/o,a=1/(o*o);for(let l=0;l<H3.length;l++){let f=2*l+1;c+=H3[l]*u*Math.expm1(-f*r),u*=a}return h(i,[n+c,0])}var j3=22250738585072014e-324,X0=1.8378770664093456,b5=[.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],X1=1/12,H1=1/360,z0=1/1260,V3=1/1680,g5=1/1188,d5=691/360360,I5=1/156;function Y3(e){let t=1/(e*e);return e>500?(X1-H1*t)/e:e>80?(X1-(H1-z0*t)*t)/e:e>35?(X1-(H1-(z0-V3*t)*t)*t)/e:(X1-(H1-(z0-(V3-(g5-(d5-I5*t)*t)*t)*t)*t)*t)/e}function F(e){if(e>15)return Y3(e);let t=2*e;if(t===Math.floor(t)&&t>=1)return b5[t-1];if(e<1)return Z(e)-(e+.5)*Math.log(e)+e-g1;let n=0,o=e;for(;o<=15;)n+=(o+.5)*Math.log1p(1/o)-1,o+=1;return n+Y3(o)}var S5=.12;function r1(e,t){if(Math.max(e,t[0])>1e299&&Math.min(e,t[0])>1e-250)return H0(r1(e*2**-64,[t[0]*2**-64,t[1]*2**-64]));if(!G1())return A5(e,t);let n=-t[0],o=-t[1],r=e+n,s=r-e,i=e-(r-s)+(n-s),c=0+o,u=c-0,a=0-(c-u)+(o-u),l=i+c,f=r+l,g=l-(f-r)+a,P=f+g,O=g-(P-f),d=P,X=O;if(Math.abs(d)<.1*(e+t[0])){let H=e+t[0],W=H-e,S1=e-(H-W)+(t[0]-W),C=0+t[1],i1=C-0,A1=0-(C-i1)+(t[1]-i1),Z0=S1+C,$1=H+Z0,J0=Z0-($1-H)+A1,y=$1+J0,W0=J0-(y-$1),U=d/y,x1=y*U,$0=134217729*y,e0=$0-($0-y),x0=y-e0,e2=134217729*U,t0=e2-(e2-U),t2=U-t0,n2=e0*t0-x1+e0*t2+x0*t0+x0*t2+W0*U,o2=x1+n2,Ne=n2-(o2-x1),r2=-o2,s2=-Ne,v1=d+r2,i2=v1-d,be=d-(v1-i2)+(r2-i2),n0=X+s2,c2=n0-X,ge=X-(n0-c2)+(s2-c2),u2=be+n0,o0=v1+u2,f2=u2-(o0-v1)+ge,c1=o0+f2,r0=f2-(c1-o0),j=c1/y,s0=y*j,a2=134217729*y,i0=a2-(a2-y),l2=y-i0,h2=134217729*j,c0=h2-(h2-j),M2=j-c0,m2=i0*c0-s0+i0*M2+l2*c0+l2*M2+W0*j,p2=s0+m2,de=m2-(p2-s0),N2=-p2,b2=-de,y1=c1+N2,g2=y1-c1,Ie=c1-(y1-g2)+(N2-g2),u0=r0+b2,d2=u0-r0,Se=r0-(u0-d2)+(b2-d2),I2=Ie+u0,f0=y1+I2,S2=I2-(f0-y1)+Se,A2=f0+S2,U5=S2-(A2-f0),v2=A2/y,_1=U+j,a0=j-(_1-U),F1=_1+v2,y2=F1-_1,Ae=_1-(F1-y2)+(v2-y2),l0=a0+0,_2=l0-a0,ve=a0-(l0-_2)+(0-_2),F2=Ae+l0,h0=F1+F2,P2=F2-(h0-F1)+ve,L2=h0+P2,ye=P2-(L2-h0),M=L2,P1=ye,M0=d*M,R2=134217729*d,m0=R2-(R2-d),D2=d-m0,E2=134217729*M,p0=E2-(E2-M),T2=M-p0,q2=m0*p0-M0+m0*T2+D2*p0+D2*T2+(d*P1+X*M),w2=M0+q2,_e=q2-(w2-M0),L=w2,w=_e;if(Math.abs(e*M*M*M)<=S5){let $=M*M,V=2*e*M*$,x=V/3;for(let t1=2;t1<1e3;t1++){V*=$;let n1=V/(2*t1+1);if(x+=n1,Math.abs(n1)<=2**-60*L)break}let Q=L+x,l1=Q-L,L1=L-(Q-l1)+(x-l1),Y=w+0,h1=Y-w,Y2=w-(Y-h1)+(0-h1),M1=L1+Y,e1=Q+M1,I=M1-(e1-Q)+Y2,D=e1+I,m1=I-(D-e1);return[D,m1]}let u1=2*e,N0=M*u1,G2=134217729*M,b0=G2-(G2-M),k2=M-b0,O2=134217729*u1,g0=O2-(O2-u1),C2=u1-g0,Q2=b0*g0-N0+b0*C2+k2*g0+k2*C2+P1*u1,z2=N0+Q2,Fe=Q2-(z2-N0),R=z2,f1=Fe,d0=M*M,B2=134217729*M,I0=B2-(B2-M),X2=M-I0,H2=134217729*M,S0=H2-(H2-M),U2=M-S0,j2=I0*S0-d0+I0*U2+X2*S0+X2*U2+(M*P1+P1*M),V2=d0+j2,Pe=j2-(V2-d0),a1=V2,Le=Pe;for(let $=1;$<1e3;$++){let V=R*a1,x=134217729*R,Q=x-(x-R),l1=R-Q,L1=134217729*a1,Y=L1-(L1-a1),h1=a1-Y,M1=Q*Y-V+Q*h1+l1*Y+l1*h1+(R*Le+f1*a1),e1=V+M1,K2=M1-(e1-V);R=e1,f1=K2;let I=2*$+1,D=R/I,m1=I*D,t1=134217729*I,n1=t1-(t1-I),Z2=I-n1,J2=134217729*D,A0=J2-(J2-D),W2=D-A0,$2=n1*A0-m1+n1*W2+Z2*A0+Z2*W2+0*D,x2=m1+$2,Re=$2-(x2-m1),e3=-x2,t3=-Re,R1=R+e3,n3=R1-R,De=R-(R1-n3)+(e3-n3),v0=f1+t3,o3=v0-f1,Ee=f1-(v0-o3)+(t3-o3),r3=De+v0,y0=R1+r3,s3=r3-(y0-R1)+Ee,p1=y0+s3,_0=s3-(p1-y0),K=p1/I,F0=I*K,i3=134217729*I,P0=i3-(i3-I),c3=I-P0,u3=134217729*K,L0=u3-(u3-K),f3=K-L0,a3=P0*L0-F0+P0*f3+c3*L0+c3*f3+0*K,l3=F0+a3,Te=a3-(l3-F0),h3=-l3,M3=-Te,D1=p1+h3,m3=D1-p1,qe=p1-(D1-m3)+(h3-m3),R0=_0+M3,p3=R0-_0,we=_0-(R0-p3)+(M3-p3),N3=qe+R0,D0=D1+N3,b3=N3-(D0-D1)+we,g3=D0+b3,x5=b3-(g3-D0),d3=g3/I,E1=D+K,E0=K-(E1-D),T1=E1+d3,I3=T1-E1,Ge=E1-(T1-I3)+(d3-I3),T0=E0+0,S3=T0-E0,ke=E0-(T0-S3)+(0-S3),A3=Ge+T0,q0=T1+A3,v3=A3-(q0-T1)+ke,q1=q0+v3,y3=v3-(q1-q0),w1=L+q1,_3=w1-L,Oe=L-(w1-_3)+(q1-_3),w0=w+y3,F3=w0-w,Ce=w-(w0-F3)+(y3-F3),P3=Oe+w0,G0=w1+P3,L3=P3-(G0-w1)+Ce,N1=G0+L3,k0=L3-(N1-G0);if(Math.abs(q1)<=1e-33*Math.abs(N1)||N1===L&&k0===w)return[N1,k0];L=N1,w=k0}return[L,w]}let I1=e/t[0],s1=I1>1e-290&&I1<1e290&&Math.max(e,t[0])<1e300?m(O1([e,0],t)):A(m([e,0]),m(t));return K3(s1,e,[d,X])}function A5(e,t){let n=A([e,0],t);if(Math.abs(n[0])<.1*(e+t[0])){let s=O1(n,h([e,0],t)),i=E(n,s),c=b(s,2*e),u=E(s,s);for(let a=1;a<1e3;a++){c=E(c,u);let l=D3(c,2*a+1),f=h(i,l);if(Math.abs(l[0])<=1e-33*Math.abs(f[0])||f[0]===i[0]&&f[1]===i[1])return f;i=f}return i}let o=e/t[0],r=o>1e-290&&o<1e290&&Math.max(e,t[0])<1e300?m(O1([e,0],t)):A(m([e,0]),m(t));return K3(r,e,n)}function K3(e,t,n){return t<1e299?h(b(e,t),R3(n)):H0(h(b(e,t*2**-64),[-n[0]*2**-64,-n[1]*2**-64]))}function H0(e){let t=e[0]*18446744073709552e3;return Number.isFinite(t)?[t,e[1]*2**64]:[t,0]}function V1(e,t,n){let o=t[0]>1e299?5421010862427522e-35:1,r=E([t[0]*o,t[1]*o],n),s=[r[0]/o,r[1]/o];if(s[0]>=1e-290)return r1(e,s);let i=A(m([e,0]),h(m(t),m(n)));return h(b(i,e),S(t[0]*n[0],-e))}function P6(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||t===0)return NaN;if(e===0)return t;let n=r1(e,[t,0]);return n[0]+n[1]}function B0(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());if(e[0]>2e3)return 0;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 U1(e,t){return e[0]>1e299?H0(E([e[0]*2**-64,e[1]*2**-64],t)):E(e,t)}var j1=e=>e[0]<-2e3?0:Math.exp(e[0])*(1+e[1]);function L6(e,t,n,o,r){let s=r?-1/0:0,i=r?0:1,c=S(e,t),u=c[0];if(n[0]===0)return e===0?i:s;if(o[0]===0)return t===0?i:s;if(e===0){if(u===0)return i;if(n[0]<.1){let p=h(V1(u,c,o),U1(c,n));return r?-p[0]-p[1]:j1([-p[0],-p[1]])}let l=m(o),f=U1(c,l);return r?f[0]+f[1]:j1(f)}if(t===0){if(o[0]<.1){let f=h(V1(u,c,n),U1(c,o));return r?-f[0]-f[1]:j1([-f[0],-f[1]])}let l=U1(c,m(n));return r?l[0]+l[1]:j1(l)}if(e<0||t<0)return s;let a=Z3(e,t,c,n,o);return B0(a,r,()=>X0+Math.log(e)+Math.log(t)-Math.log(u),()=>2*Math.PI*e*(t/u))}function R6(e,t,n,o){let r=S(e,t),s=r[0];return{e:Z3(e,t,r,n,o),logDenom:X0+Math.log(e)+Math.log(t)-Math.log(s)}}function Z3(e,t,n,o,r){let s=V1(e,n,o),i=V1(t,n,r);return Number.isFinite(s[0]+i[0])?h(h(s,i),S(F(e)+F(t),-F(n[0]))):[1/0,0]}function J(e,t,n){let o=J3(e,t,n,!n);return n?o[0]:o[1]}function U0(e,t){return J3(e,t,!0,!0)}function J3(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*j3)return[-t,o?Math.exp(-t):NaN];if(t<e*j3){if(!Number.isFinite(e))return[-1/0,0];let a=Z(e),l=a===1/0?-1/0:-t+e*Math.log(t)-a;return[l,o?Math.exp(l):NaN]}let r=r1(e,[t,0]),s=r[0]===1/0?r:h(r,[F(e),0]),i=()=>X0+Math.log(e),c=e>2e307,u=c?()=>Math.PI/8*e:()=>2*Math.PI*e;return[n?B0(s,!0,i,u):NaN,o?B0(s,!1,i,u)/(c?4:1):NaN]}var Y1=1e6;function W3(e,t){let{value:n,sign:o}=q(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 k6(e,t){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(e<0||t<0)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 i=Math.min(e,t),c=Math.max(e,t);if(i<1){let a=Q0(i,c);return z(i)*Math.exp(-a[0])*(1-a[1])}let u=c>=x3?ee(c,i):te(e,t);return Math.exp(u[0])*(1+u[1])}let n=1;if(e===0||t===0||1/Math.min(e,t)===1/0)return 1/0;if(Math.abs(e)<Math.abs(t)&&([e,t]=[t,e]),Math.abs(e)>Y1*Math.abs(t)&&e>Y1){let i=W3(e,t);return i.sign*Math.exp(i.value)}let o=e+t;if(Math.abs(o)>G||Math.abs(e)>G||Math.abs(t)>G){let i=q(o);n*=i.sign;let c=q(t);n*=c.sign;let u=q(e);n*=u.sign;let a=u.value+(c.value-i.value);return n*Math.exp(a)}o=1/z(o);let r=z(e),s=z(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 O6(e,t){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(e<0||t<0)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 i=Math.min(e,t),c=Math.max(e,t);if(i<1)return k(i)-U3(i,c);let u=c>=x3?ee(c,i):te(e,t);return u[0]+u[1]}if(e===0||t===0)return 1/0;if(Math.min(e,t)<1e-300)return k(e)+k(t)-k(e+t);if(Math.abs(e)<Math.abs(t)&&([e,t]=[t,e]),Math.abs(e)>Y1*Math.abs(t)&&e>Y1)return W3(e,t).value;let n=e+t;if(Math.abs(n)>G||Math.abs(e)>G||Math.abs(t)>G)return q(e).value+(q(t).value-q(n).value);n=1/z(n);let o=z(e),r=z(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))}var $3=[.9189385332046728,-38782941580672414e-33],x3=2**52;function ee(e,t){let n=b(A(m([t,0]),m([e,0])),t),o=-.5*Math.log(t)-(e+t-.5)*Math.log1p(t/e)+(F(e)+F(t)-F(e+t));return h(h(n,$3),[o,0])}function te(e,t){let n=S(e,t),o=b(m([e,0]),e-.5),r=b(m([t,0]),t-.5),s=v5(m(n),h(n,[-.5,0])),i=A(h(o,r),s);return i=h(i,$3),h(i,S(F(e)+F(t),-F(n[0])))}function v5(e,t){return h(b(e,t[0]),b(e,t[1]))}function j0(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)<_*Math.abs(n))break}return n}return Math.log1p(e)-e}var ne=[[-.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 d1=1e7,_5=20,Y0=200,F5=.3,P5=4.5,L5=4503599627370496,K1=2220446049250313e-31,J1=2**-1022;function re(e,t,n){let o=ie(e,t);if(n)return J(e,t,!0)+Math.log(o);let r=J(e,t,!1);return r>=J1?r*o:Math.exp(J(e,t,!0)+Math.log(o))}function se(e,t){let n=ie(e,t),o=U0(e,t),r=o[0]+Math.log(n);return[r,o[1]>=J1?o[1]*n:Math.exp(r)]}function ie(e,t){if(e>1e3&&t>.97*e)return D5(e,t);let n=e,o=1,r=1;for(let s=0;s<d1&&(n+=1,o*=t/n,r+=o,!(o<=_*r));s++);return r}var R5=2**-64;function D5(e,t){let n=1,o=0,r=1,s=0;for(let i=1;i<d1;i++){let c=e+i,u=c-e,a=e-(c-u)+(i-u),l=t/c,f=134217729*l,p=f-(f-l),g=l-p;f=134217729*c;let P=f-(f-c),O=c-P,d=l*c,X=p*P-d+p*O+g*P+g*O,I1=(t-d-X-l*a)/c;f=134217729*n;let s1=f-(f-n),H=n-s1,W=n*l,S1=s1*p-W+s1*g+H*p+H*g+(n*I1+o*l);n=W+S1,o=S1-(n-W);let C=r+n,i1=C-r,A1=r-(C-i1)+(n-i1)+(s+o);if(r=C+A1,s=A1-(r-C),n*l<=R5*r*(1-l))break}return r+s}function E5(e,t,n){let o=ce(e,t);if(n)return Math.log(e)+J(e,t,!0)+Math.log(o);let r=J(e,t,!1);return r>=J1?e*r*o:Math.exp(Math.log(e)+J(e,t,!0)+Math.log(o))}function T5(e,t){let n=ce(e,t),o=U0(e,t),r=Math.log(e)+o[0]+Math.log(n);return[r,o[1]>=J1?e*o[1]*n:Math.exp(r)]}function ce(e,t){if(t>1e20)return q5(e,t);let n=1-e,o=t+n+1,r=0,s=1,i=t,c=t+1,u=o*t,a=c/u;for(let l=0;l<d1;l++){r+=1,n+=1,o+=2;let f=n*r,p=c*o-s*f,g=u*o-i*f,P;if(g!==0){let O=p/g;P=Math.abs((a-O)/O),a=O}else P=1;if(s=c,c=p,i=u,u=g,Math.abs(p)>L5&&(s*=K1,c*=K1,i*=K1,u*=K1),P<=_)break}return a}function q5(e,t){let o=t+1-e,r=1/1e-300,s=1/o,i=s;for(let c=1;c<d1;c++){let u=-c*(c-e);o+=2,s=u*s+o,Math.abs(s)<1e-300&&(s=1e-300),r=o+u/r,Math.abs(r)<1e-300&&(r=1e-300),s=1/s;let a=s*r;if(i*=a,Math.abs(a-1)<=_)break}return i}function ue(e,t){let n=1,o=0;for(let c=1;c<d1;c++){n*=-t/c;let u=n/(e+c);if(o+=u,Math.abs(u)<=_*Math.abs(o))break}let r=Math.log(t),s=e*r-Z(e);return-Math.expm1(s)-e*Math.exp(s)*o}function Z1(e,t,n){let o=n?-1:1,r=fe(e,t),s=.5*C1(o*r*Math.sqrt(e/2));return s+=o*Math.exp(-.5*e*r*r)*ae(e,r)/Math.sqrt(2*Math.PI*e),s}function fe(e,t){let n=t/e,o=(t-e)/e;return n>1?Math.sqrt(-2*j0(o)):n<1?-Math.sqrt(-2*j0(o)):0}function ae(e,t){let n=new Array(25).fill(0);n[0]=1;let o=0,r=0,s=1,i=1/0;for(let c=0;c<25;c++){let u=ne[c],a=u[0];for(let p=1;p<25;p++){p>o&&(n[p]=t*n[p-1],o+=1);let g=u[p]*n[p];if(a+=g,Math.abs(g)<_*Math.abs(a))break}let l=a*s,f=Math.abs(l);if(f>i||(r+=l,f<_*Math.abs(r)))break;i=f,s/=e}return r}function le(e,t){return e>_5&&e<Y0&&t<F5||e>Y0&&t<P5/Math.sqrt(e)}var he=1e299,Me=(e,t)=>e>Y0&&(t<.001||e>he);function w5(e,t){let n=r1(e,[t,0]),o=t>e?1:-1,r=fe(e,t),s=e>he&&Math.abs(r)>.1?1/((t-e)/e)-1/r:ae(e,r),i=.5*o1(Math.sqrt(n[0]+n[1]))+o*s/Math.sqrt(2*Math.PI*e);return[-n[0]-n[1]+Math.log(i),n[0]>2e3?0:Math.exp(-n[0])*(1-n[1])*i]}function me(e,t,n){let[o,r]=w5(e,t);return t>e!==n?[o,r]:[Math.log1p(-r),1-r]}function V0(e,t,n){if(t>1.1)return t<e?{lower:!0,value:re(e,t,n)}:{lower:!1,value:E5(e,t,n)};if(t<=.5?-.4/Math.log(t)<e:t*1.1<e)return{lower:!0,value:re(e,t,n)};let r=ue(e,t);return{lower:!1,value:n?Math.log(r):r}}function G5(e,t){if(t>1.1){let[r,s]=t<e?se(e,t):T5(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]=se(e,t);return{lower:!0,log:r,lin:s}}let o=ue(e,t);return{lower:!1,log:Math.log(o),lin:o}}var B=1e-300;function k5(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-k(e)+Math.log1p((e-1)/t);return n?[Math.log1p(-Math.exp(s)),-Math.expm1(s)]:[s,Math.exp(s)]}if(!n&&e<B){let[s,i]=k5(B,t,!1);return[s+Math.log(e/B),i*(e/B)]}let o=Math.abs(t-e)/e;if(le(e,o)){let s=Z1(e,t,n);return[s>.5?Math.log1p(-Z1(e,t,!n)):Math.log(s),s]}if(Me(e,o))return me(e,t,n);let r=G5(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 O5(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-k(e)+Math.log1p((e-1)/t);return n?o?Math.log1p(-Math.exp(u)):-Math.expm1(u):o?u:Math.exp(u)}if(!n&&e<B){let u=O5(B,t,!1,o);return o?u+Math.log(e/B):u*(e/B)}let i=Math.abs(t-e)/e;if(le(e,i)){let u=Z1(e,t,n);return o?u>.5?Math.log1p(-Z1(e,t,!n)):Math.log(u):u}if(Me(e,i))return me(e,t,n)[o?0:1];if(o){let u=V0(e,t,!0);if(u.lower===n)return u.value;let a=V0(e,t,!1).value;return a>0?Math.log1p(-a):-Math.exp(u.value)}let c=V0(e,t,!1);return c.lower===n?c.value:1-c.value}var W1=[.6931471805599453,23190468138462996e-33];function J6(e){let t=e[0];if(!G1())return[Math.exp(t),0];if(Number.isNaN(t))return[NaN,0];if(t>709.8)return[1/0,0];if(t<-708)return[Math.exp(t)*(1+e[1]),0];let n=Math.round(t/W1[0]),o=A(e,b(W1,n)),r=1024;o=[o[0]/r,o[1]/r];let s=o,i=o;for(let f=2;f<20&&(s=E(s,o),s=[s[0]/f,s[1]/f],i=h(i,s),!(Math.abs(s[0])<1e-36));f++);for(let f=0;f<10;f++)i=E(i,h(i,[2,0]));let c=h(i,[1,0]),u=Math.trunc(n/2),a=2**u,l=2**(n-u);return[c[0]*a*l,c[1]*a*l]}function W6(e,t,n){let o=e-t;if(!Number.isFinite(o))return[o/n,0];let r=t===0?[e,0]:S(e,-t);if(n===1)return r;let s=r[0]/n;return!Number.isFinite(s)||s===0?[s,0]:K0(r,n,s)}function K0(e,t,n){if(Math.abs(e[0])<2**-900){let i=4149515568880993e165,c=K0([e[0]*i,e[1]*i],t,n*i);return[c[0]/i,c[1]/i]}let o=pe(t,n);if(!Number.isFinite(o[0])){let i=9094947017729282e-28,c=K0([e[0]*i,e[1]*i],t,n*i);return[c[0]/i,c[1]/i]}let r=A(e,o),s=(r[0]+r[1])/t;return S(n,s)}function $6(e,t){return A(m([e,0]),m([t,0]))}function pe(e,t){let n=e*t;return!Number.isFinite(n)||Math.abs(e)>1e300||Math.abs(t)>1e300?[n,0]:k1(e,t)}function C5(e){return e[0]>708?Math.exp(700-e[0])*(1-e[1])*Math.exp(-700):Math.exp(-e[0])*(1-e[1])}function x6(e,t){if(!(e[0]<2e3)||t===1/0)return 0;let n=0,o=t;o<2**-1e3&&(o*=2**600,n=-600);let r=Math.floor(Math.log2(o));o*=2**-r,n+=r;let s=Math.round(e[0]/W1[0]),i=A(e,b(W1,s)),c=Math.exp(-i[0])*(1-i[1])/o,u=-s-n,a=Math.trunc(u/2);return c*2**a*2**(u-a)}function e4(e){return e>-Math.LN2?Math.log(-Math.expm1(e)):Math.log1p(-Math.exp(e))}function t4(e){return e[0]>Math.LN2?Math.log1p(-C5(e)):Math.log(-Math.expm1(-(e[0]+e[1])))}function n4(e,t,n){let o=pe(t,n);if(!Number.isFinite(o[0])||!Number.isFinite(e))return e+o[0];let r=h(o,[e,0]);return r[0]+r[1]}export{v as a,b1 as b,C1 as c,o1 as d,z1 as e,h6 as f,M6 as g,m6 as h,_ as i,C0 as j,X3 as k,z as l,q as m,k as n,Z as o,F as p,r1 as q,P6 as r,L6 as s,R6 as t,J as u,j0 as v,ie as w,D5 as x,ce as y,k5 as z,O5 as A,J6 as B,W6 as C,$6 as D,pe as E,C5 as F,x6 as G,e4 as H,t4 as I,n4 as J,U3 as K,Q0 as L,k6 as M,O6 as N,te as O};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 0.15.2 | 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{d as c,f as m,g,j as a}from"./chunk-LG74QY5U.js";function w(){return{s:[0,0],shift:0}}function F(t){return 32+Math.ceil(Math.log2(Math.max(t,1)))}function M(t,n,r){if(t.shift===0){let o=c(t.s,[n,0]);if(Number.isFinite(o[0])&&Number.isFinite(o[1])){t.s=o;return}t.shift=F(r);let e=2**-t.shift;t.s=[t.s[0]*e,t.s[1]*e]}t.s=c(t.s,[n*2**-t.shift,0])}function A(t){return d(t.s[0]+t.s[1],t.shift)}function d(t,n){let r=Math.trunc(n/2);return t*2**r*2**(n-r)}function S(t){let n=0;for(let r of t)Number.isFinite(r)||(n+=r);return n}function N(t){let n=t.length;if(!t.every(Number.isFinite))return[S(t)/n,0];let r=w();for(let s of t)M(r,s,n);if(r.shift!==0){let s=F(n),f=2**-s,h=N(t.map(l=>l*f));return[d(h[0],s),d(h[1],s)]}let o=r.s,e=a(o,n);if(!Number.isFinite(e[0]))return[o[0]/n,0];let i=[0,0];for(let s of t)i=c(i,m([s,0],e));return c(e,a(i,n))}function E(t){return t.length===0?NaN:N(t)[0]}function C(t){return D(t,t)}function D(t,n){let r=t.length;if(r<2)return NaN;let o=N(t),e=t===n?o:N(n);if(!Number.isFinite(o[0])||!Number.isFinite(e[0]))return NaN;let i=t.map(u=>m([u,0],o)),s=t===n?i:n.map(u=>m([u,0],e)),f=v(i),h=t===n?f:v(s),l=2**-f,b=2**-h,p=[0,0];for(let u=0;u<r;u++){let k=[i[u][0]*l,i[u][1]*l],y=[s[u][0]*b,s[u][1]*b];p=c(p,g(k,y))}return a(p,r-1)[0]*2**f*2**h}function v(t){let n=0;for(let r of t)n=Math.max(n,Math.abs(r[0]));return n===0||!Number.isFinite(n)?0:Math.max(-1022,Math.floor(Math.log2(n)))}function P(t){if(!t.every(Number.isFinite))return S(t);let n=w();for(let r of t)M(n,r,t.length);return A(n)}function T(t){let n=t.length,r=Array.from({length:n},(i,s)=>s);r.sort((i,s)=>t[i]-t[s]||i-s);let o=new Array(n),e=0;for(;e<n;){let i=e;for(;i+1<n&&t[r[i+1]]===t[r[e]];)i++;let s=(e+i+2)/2;for(let f=e;f<=i;f++)o[r[f]]=s;e=i+1}return o}function V(t){let n=[...t].sort((e,i)=>e-i),r=[],o=0;for(;o<n.length;){let e=o;for(;e+1<n.length&&n[e+1]===n[o];)e++;e>o&&r.push(e-o+1),o=e+1}return r}function _(t){return t.filter(n=>!Number.isNaN(n))}function q(t,n){if(t.length!==n.length)throw new TypeError("x and y must have the same length");let r=[],o=[];for(let e=0;e<t.length;e++)!Number.isNaN(t[e])&&!Number.isNaN(n[e])&&(r.push(t[e]),o.push(n[e]));return[r,o]}export{w as a,M as b,A as c,d,N as e,E as f,C as g,D as h,P as i,T as j,V as k,_ as l,q as m};
1
+ /*! rStats.js 0.15.3 | 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{d as c,f as m,g,j as a}from"./chunk-KT66SB7R.js";function w(){return{s:[0,0],shift:0}}function F(t){return 32+Math.ceil(Math.log2(Math.max(t,1)))}function M(t,n,r){if(t.shift===0){let o=c(t.s,[n,0]);if(Number.isFinite(o[0])&&Number.isFinite(o[1])){t.s=o;return}t.shift=F(r);let e=2**-t.shift;t.s=[t.s[0]*e,t.s[1]*e]}t.s=c(t.s,[n*2**-t.shift,0])}function A(t){return d(t.s[0]+t.s[1],t.shift)}function d(t,n){let r=Math.trunc(n/2);return t*2**r*2**(n-r)}function S(t){let n=0;for(let r of t)Number.isFinite(r)||(n+=r);return n}function N(t){let n=t.length;if(!t.every(Number.isFinite))return[S(t)/n,0];let r=w();for(let s of t)M(r,s,n);if(r.shift!==0){let s=F(n),f=2**-s,h=N(t.map(l=>l*f));return[d(h[0],s),d(h[1],s)]}let o=r.s,e=a(o,n);if(!Number.isFinite(e[0]))return[o[0]/n,0];let i=[0,0];for(let s of t)i=c(i,m([s,0],e));return c(e,a(i,n))}function E(t){return t.length===0?NaN:N(t)[0]}function C(t){return D(t,t)}function D(t,n){let r=t.length;if(r<2)return NaN;let o=N(t),e=t===n?o:N(n);if(!Number.isFinite(o[0])||!Number.isFinite(e[0]))return NaN;let i=t.map(u=>m([u,0],o)),s=t===n?i:n.map(u=>m([u,0],e)),f=v(i),h=t===n?f:v(s),l=2**-f,b=2**-h,p=[0,0];for(let u=0;u<r;u++){let k=[i[u][0]*l,i[u][1]*l],y=[s[u][0]*b,s[u][1]*b];p=c(p,g(k,y))}return a(p,r-1)[0]*2**f*2**h}function v(t){let n=0;for(let r of t)n=Math.max(n,Math.abs(r[0]));return n===0||!Number.isFinite(n)?0:Math.max(-1022,Math.floor(Math.log2(n)))}function P(t){if(!t.every(Number.isFinite))return S(t);let n=w();for(let r of t)M(n,r,t.length);return A(n)}function T(t){let n=t.length,r=Array.from({length:n},(i,s)=>s);r.sort((i,s)=>t[i]-t[s]||i-s);let o=new Array(n),e=0;for(;e<n;){let i=e;for(;i+1<n&&t[r[i+1]]===t[r[e]];)i++;let s=(e+i+2)/2;for(let f=e;f<=i;f++)o[r[f]]=s;e=i+1}return o}function V(t){let n=[...t].sort((e,i)=>e-i),r=[],o=0;for(;o<n.length;){let e=o;for(;e+1<n.length&&n[e+1]===n[o];)e++;e>o&&r.push(e-o+1),o=e+1}return r}function _(t){return t.filter(n=>!Number.isNaN(n))}function q(t,n){if(t.length!==n.length)throw new TypeError("x and y must have the same length");let r=[],o=[];for(let e=0;e<t.length;e++)!Number.isNaN(t[e])&&!Number.isNaN(n[e])&&(r.push(t[e]),o.push(n[e]));return[r,o]}export{w as a,M as b,A as c,d,N as e,E as f,C as g,D as h,P as i,T as j,V as k,_ as l,q as m};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 0.15.2 | 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{c as re}from"./chunk-3WQCKGKP.js";import{e as ne,h as se,j as X,k as I,m as oe}from"./chunk-IBPWRQIF.js";import{a as ae,g as ie}from"./chunk-PEYGUK32.js";import{o as B}from"./chunk-UFT662QZ.js";import{b as ce,c as S}from"./chunk-HBMHR5SS.js";import{b as Y}from"./chunk-PWVQVJTP.js";import{g as D,h as G}from"./chunk-2CUKVVRO.js";import{b as ee,c as te,d as V,f as q,g as C,i as W}from"./chunk-LG74QY5U.js";function j(e){if(e.kind==="factor")return ce(e);let t=[...new Set(e.values)].sort((s,o)=>s-o),n=[...new Set(t.map(Y))],r=new Map(n.map((s,o)=>[s,o]));return{levels:n,codes:e.values.map(s=>r.get(Y(s)))}}function A(e,t){if(e.kind!=="numeric")throw new TypeError(`'${t}' must be a numeric column`);return e.values}function R(e,t){let n=ae(e),r=ie(n,Object.keys(t));return{terms:r,rhsVariables:r.variables.slice(r.response===0?1:0)}}function fe(e){if(typeof e!="string")throw new TypeError("the formula must be a string");let t=e.indexOf("~");return t<0?void 0:{lhs:e.slice(0,t).trim(),rhs:e.slice(t+1)}}var Ae=/^Pair\s*\(\s*([A-Za-z.][A-Za-z0-9._]*)\s*,\s*([A-Za-z.][A-Za-z0-9._]*)\s*\)$/,F="'formula' missing or incorrect",le=(e,t)=>t.length===0&&e.terms.length===0&&e.intercept;function Ve(e,t,n){let r=fe(e),s=r===void 0?null:Ae.exec(r.lhs);if(s!==null){let{terms:m,rhsVariables:p}=R(`~${r.rhs}`,t);if(!n||!le(m,p))throw new Error(F);let w=S(t,[s[1],s[2]]);return{kind:"paired",x:A(w.variables[0],s[1]),y:A(w.variables[1],s[2])}}let{terms:o,rhsVariables:c}=R(e,t);if(o.response<0)throw new Error(F);let i=o.variables[0];if(n&&le(o,c))return{kind:"one",x:A(S(t,[i]).variables[0],i)};if(c.length!==1||o.terms.length!==1)throw new Error(F);let a=S(t,[i,c[0]],{dropUnusedLevels:!0}),l=A(a.variables[0],i),u=j(a.variables[1]);if(u.levels.length!==2)throw new Error("grouping factor must have exactly 2 levels");return{kind:"two",x:l.filter((m,p)=>u.codes[p]===0),y:l.filter((m,p)=>u.codes[p]===1),levels:[u.levels[0],u.levels[1]]}}function Ie(e,t){let n=Ve(e,t,!1);if(n.kind!=="two")throw new Error(F);return n}function je(e,t){let{terms:n,rhsVariables:r}=R(e,t);if(n.response<0)throw new Error(F);if(r.length!==1)throw new Error("'formula' should be of the form response ~ group");let s=n.variables[0],o=S(t,[s,r[0]],{dropUnusedLevels:!0});return{values:A(o.variables[0],s),group:j(o.variables[1])}}function ze(e,t){let n=t.levels.map(()=>[]);return e.forEach((r,s)=>n[t.codes[s]].push(r)),n}function Ue(e,t){let{terms:n,rhsVariables:r}=R(e,t);if(n.response<0||r.length===0)throw new Error(F);let s=n.variables[0],o=S(t,[s,...r],{dropUnusedLevels:!0}),c=o.variables.slice(1).map(j),i=o.rows.map((a,l)=>{let u=0,m=1;for(let p of c)u+=p.codes[l]*m,m*=p.levels.length;return u});return{values:A(o.variables[0],s),groups:i}}var ue="incorrect specification for 'formula'";function Ze(e,t){let n=fe(e),r=n?.rhs.split("|");if(n===void 0||n.lhs===""||r.length!==2)throw new Error(ue);let s=y=>{let{terms:E,rhsVariables:h}=R(y,t);if(h.length!==1||E.terms.length!==1)throw new Error(ue);return h[0]},{terms:o}=R(`${n.lhs} ~ 1`,t),c=o.variables[0],i=s(`~${r[0]}`),a=s(`~${r[1]}`),l=S(t,[c,i,a],{dropUnusedLevels:!0}),u=A(l.variables[0],c),m=j(l.variables[1]),p=j(l.variables[2]),w=p.levels.map(()=>m.levels.map(()=>NaN)),N=p.levels.map(()=>m.levels.map(()=>0));if(u.forEach((y,E)=>{let h=p.codes[E],g=m.codes[E];N[h][g]++,w[h][g]=y}),N.some(y=>y.some(E=>E!==1)))throw new Error("not an unreplicated complete block design");return w}function me(e,t){let{terms:n,rhsVariables:r}=R(e,t);if(n.response>=0)throw new Error("'formula' missing or invalid");if(r.length!==2)throw new Error("invalid formula");let s=S(t,r);return{x:A(s.variables[0],r[0]),y:A(s.variables[1],r[1])}}function he(e){if(e===void 0)return"two.sided";let n=["two.sided","less","greater"].filter(r=>r.startsWith(e));if(e.length===0||n.length!==1)throw new RangeError(`invalid alternative "${e}" (expected "two.sided", "less" or "greater")`);return n[0]}function pe(e){if(!(Number.isFinite(e)&&e>=0&&e<=1))throw new RangeError("confLevel must be a number between 0 and 1")}function Ge(e){if(!(Number.isFinite(e)&&e>0&&e<1))throw new RangeError("'conf.level' must be a single number between 0 and 1")}var Se=["pearson","kendall","spearman"];function Te(e){if(e===void 0)return"pearson";let t=Se.filter(n=>n.startsWith(e));if(e.length===0||t.length!==1)throw new RangeError(`invalid method "${e}"`);return t[0]}function de(e){if(!(e[0]>0))return[Math.sqrt(e[0]),0];let t=Math.sqrt(e[0]),n=q(e,te(t,t));return ee(t,n[0]/(2*t))}function we(e){let t=ne(e);if(!Number.isFinite(t[0]))return;let n=e.map(o=>q([o,0],t)),r=0;for(let o of n)r=Math.max(r,Math.abs(o[0]));if(r===0)return n;let s=2**-Math.max(-1022,Math.floor(Math.log2(r)));return n.map(o=>[o[0]*s,o[1]*s])}function H(e,t){let n=e.length;if(n<2)return[NaN,0];let r=we(e),s=we(t);if(r===void 0||s===void 0)return[NaN,0];let o=[0,0],c=[0,0],i=[0,0];for(let l=0;l<n;l++)o=V(o,C(r[l],s[l])),c=V(c,C(r[l],r[l])),i=V(i,C(s[l],s[l]));if(c[0]===0||i[0]===0)return[NaN,0];let a=W(o,C(de(c),de(i)));return a[0]>=1?[1,0]:a[0]<=-1?[-1,0]:a}function ge(e,t){let n=C(q([1,0],e),V([1,0],e));return Math.sqrt(t)*e[0]/Math.sqrt(n[0])}function De(e){return Math.abs(e[0])<.5?Math.atanh(e[0]):.5*Math.log(V([1,0],e)[0]/q([1,0],e)[0])}function Ne(e,t,n){return n==="less"?B(e,t,!0,!1):n==="greater"?B(e,t,!1,!1):2*Math.min(B(e,t,!0,!1),B(e,t,!1,!1))}function Re(e,t){return t==="less"?D(e):t==="greater"?D(e,{lowerTail:!1}):2*Math.min(D(e),D(e,{lowerTail:!1}))}function K(e,t){let n=e.length,r=0;for(let u=0;u<n;u++){let m=e[u],p=t[u];for(let w=u+1;w<n;w++){let N=(e[w]>m?1:0)-(e[w]<m?1:0),y=(t[w]>p?1:0)-(t[w]<p?1:0);r+=N*y}}let s=I(e),o=I(t),c=n*(n-1)/2,i=s.reduce((u,m)=>u+m*(m-1)/2,0),a=o.reduce((u,m)=>u+m*(m-1)/2,0),l=n<2||i===c||a===c?NaN:i===0&&a===0?r/c:r/Math.sqrt((c-i)*(c-a));return{s:r,tau:l,ties:s.length>0||o.length>0,tx:s,ty:o}}function be(e,t){let n=e*(e-1)/2;if(t<0)return 0;if(t>=n)return 1;let r=new Float64Array(t+1);r[0]=1;for(let o=2;o<=e;o++){let c=new Float64Array(t+1),i=0;for(let l=0;l<=t;l++)i+=r[l],c[l]=i;let a=new Float64Array(t+1);for(let l=0;l<=t;l++)a[l]=(c[l]-(l>=o?c[l-o]:0))/o;r=a}let s=0;for(let o=t;o>=0;o--)s+=r[o];return Math.min(1,s)}var ve=new Map;function Le(e){let t=ve.get(e);if(t!==void 0)return t;let n=e*(e*e-1)/3,r=1<<e,s=new Array(r);s[0]=new Float64Array(n+1),s[0][0]=1;let o=i=>{let a=0;for(;i;i&=i-1)a++;return a};for(let i=0;i<r;i++){let a=s[i];if(a===void 0)continue;let l=o(i);for(let u=0;u<e;u++){if(i&1<<u)continue;let m=(u-l)**2,p=i|1<<u,w=s[p]??=new Float64Array(n+1);for(let N=0;N+m<=n;N++)a[N]&&(w[N+m]+=a[N])}i!==r-1&&(s[i]=void 0)}let c=s[r-1];return ve.set(e,c),c}var x=[.2274,.2531,.1745,.0758,.1033,.3932,.0879,.0151,.0072,.0831,.0131,46e-5];function ye(e,t,n){let r=t;r%2!==0&&(r+=1);let s=1/e,o=(6*(r-1)*s/(e*e-1)-1)*Math.sqrt(1/s-1),c=o*o,a=o*s*(x[0]+s*(x[1]+x[2]*s)+c*(-x[3]+s*(x[4]+x[5]*s)-c*s*(x[6]+x[7]*s-c*(x[8]-x[9]*s+c*s*(x[10]-x[11]*c)))))/Math.exp(c/2),l=n?D(o)-a:a+D(o,{lowerTail:!1});return Math.min(1,Math.max(0,l))}function Me(e,t,n){let r=e*(e*e-1)/3;if(e<=9){let s=Le(e),o=1;for(let i=2;i<=e;i++)o*=i;let c=0;if(n)for(let i=Math.min(t,r);i>=0;i--)c+=s[i];else for(let i=r;i>=Math.max(t,0);i--)c+=s[i];return c/o}return n?t+1>r?1:t+1<=0?0:ye(e,t+1,!0):t<=0?1:t>r?0:ye(e,t,!1)}function _e(e,t,n={}){if(typeof e=="string"){let r=me(e,t);return _e(r.x,r.y,n)}return Ce(e,t,n)}function Ce(e,t,n){if(e.length!==t.length)throw new TypeError("x and y must have the same length");let r=he(n.alternative),s=Te(n.method),o=n.continuity??!1,[c,i]=oe(Array.from(e),Array.from(t)),a=c.length;if(s==="pearson"){let f=n.confLevel??.95;if(pe(f),a<3)throw new Error("not enough finite observations");let d=H(c,i),k=a-2,b=Number.isNaN(d[0])?NaN:ge(d,k),M={method:"Pearson's product-moment correlation",alternative:r,statistic:b,statisticName:"t",parameter:k,parameterName:"df",pValue:Ne(b,k,r),estimate:d[0],estimateNames:"cor",nullValue:0,nullValueName:"correlation"};if(a>3){let z=De(d),L=1/Math.sqrt(a-3),_=T=>Math.tanh(z+T),$;if(r==="less")$=[-1,_(L*G(f))];else if(r==="greater")$=[_(-L*G(f)),1];else{let T=L*G((1+f)/2);$=[_(-T),_(T)]}M.confInt=$,M.confLevel=f}return M}if(a<2)throw new Error("not enough finite observations");if(s==="kendall"){let f=K(c,i),d={method:"Kendall's rank correlation tau",alternative:r,estimate:f.tau,estimateNames:"tau",nullValue:0,nullValueName:"tau"};if(Number.isNaN(f.tau))return{...d,statistic:NaN,statisticName:"T",pValue:NaN};if((n.exact??a<50)&&!f.ties){let v=a*(a-1)/2,P=(f.s+v)/2,U=be(a,P),Z=be(a,v-P),Ee=r==="less"?U:r==="greater"?Z:Math.min(1,2*Math.min(U,Z));return{...d,statistic:P,statisticName:"T",pValue:Ee}}let b=(v,P)=>P.reduce((U,Z)=>U+v(Z),0),M=v=>v*(v-1),z=v=>v*(v-1)*(v-2),L=v=>v*(v-1)*(2*v+5),_=(a*(a-1)*(2*a+5)-b(L,f.tx)-b(L,f.ty))/18+b(z,f.tx)*b(z,f.ty)/(9*a*(a-1)*(a-2))+b(M,f.tx)*b(M,f.ty)/(2*a*(a-1)),T=(o?Math.sign(f.s)*(Math.abs(f.s)-1):f.s)/Math.sqrt(_);return{...d,statistic:T,statisticName:"z",pValue:Re(T,r)}}let l=X(c),u=X(i),m=H(l,u),p=a*a*a-a,w=p*(1-m[0])/6,N={method:"Spearman's rank correlation rho",alternative:r,statistic:w,statisticName:"S",estimate:m[0],estimateNames:"rho",nullValue:0,nullValueName:"rho"};if(Number.isNaN(m[0]))return{...N,pValue:NaN};let y=I(c).length>0||I(i).length>0;if((n.exact??a<=1290)&&!y&&a<=1290){let f=Math.round(w),d=Me(a,f,!0),k=Me(a,f,!1),b=r==="greater"?d:r==="less"?k:Math.min(1,2*Math.min(d,k));return{...N,pValue:b}}let h=m;if(o){let f=W([6,0],[p,0]);h=W(V(m,f),V([1,0],f)),Math.abs(h[0])>=1&&(h=[Math.sign(h[0]),0])}let g=ge(h,a-2);return{...N,pValue:Ne(g,a-2,r)}}function Fe(e,t){let n=e.length,r=new Array(n);if(t==="first"||t==="last"||t==="random"){let c=t==="random"?re(n):[],i=Array.from({length:n},(a,l)=>l);return i.sort((a,l)=>{let u=e[a]-e[l];return u!==0?u:t==="first"?a-l:t==="last"?l-a:c[a]-c[l]||a-l}),i.forEach((a,l)=>r[a]=l+1),r}let s=Array.from({length:n},(c,i)=>i).sort((c,i)=>e[c]-e[i]||c-i),o=0;for(;o<n;){let c=o;for(;c+1<n&&e[s[c+1]]===e[s[o]];)c++;let i=t==="average"?(o+c+2)/2:t==="min"?o+1:c+1;for(let a=o;a<=c;a++)r[s[a]]=i;o=c+1}return r}function J(e,t={}){let n=t.tiesMethod??"average";if(!["average","first","last","random","max","min"].includes(n))throw new RangeError(`invalid tiesMethod "${n}"`);let r=t.naLast??"last",s=Array.from(e),o=s.filter(m=>!Number.isNaN(m)),c=Fe(o,n),i=s.length-o.length,a=[],l=0,u=0;for(let m of s)Number.isNaN(m)?(u++,a.push(r==="keep"?NaN:r==="last"?o.length+u:u)):a.push(r==="first"?c[l++]+i:c[l++]);return a}var Oe=["pearson","kendall","spearman"],$e=["all.obs","complete.obs","pairwise.complete.obs","everything","na.or.complete"];function xe(e,t,n,r){if(e===void 0)return n;if(t.includes(e))return e;let s=t.filter(o=>o.startsWith(e));if(e.length===0||s.length!==1)throw new RangeError(`invalid '${r}' argument`);return s[0]}function O(e){return e.length>0&&Array.isArray(e[0])}function ke(e){if(!O(e))return[Array.from(e)];let t=e[0].length;return Array.from({length:t},(n,r)=>e.map(s=>s[r]))}function Q(e,t,n,r){let s=xe(n.method,Oe,"pearson","method"),o=xe(n.use,$e,"everything","use");if(t===void 0&&!O(e))throw new TypeError("supply both 'x' and 'y' or a matrix-like 'x'");let c=ke(e),i=t===void 0?c:ke(t),a=c[0]?.length??0;if(i.some(h=>h.length!==a))throw new RangeError("incompatible dimensions");let l=[...c,...i];if(o==="all.obs"&&l.some(h=>h.some(Number.isNaN)))throw new RangeError("missing observations in cov/cor");if(!r&&o==="pairwise.complete.obs"&&s!=="pearson")throw new RangeError("cannot handle 'pairwise.complete.obs'");let u;if((o==="complete.obs"||o==="na.or.complete")&&(u=Array.from({length:a},(h,g)=>l.every(f=>!Number.isNaN(f[g]))),!u.some(Boolean))){if(o==="complete.obs")throw new RangeError("no complete element pairs");return t===void 0||O(e)||O(t)?c.map(()=>i.map(()=>NaN)):NaN}let m=h=>{let g=u===void 0?h:h.filter((f,d)=>u[d]);return s==="spearman"&&o!=="pairwise.complete.obs"?J(g,{naLast:"keep"}):g},p=c.map(m),w=t===void 0?p:i.map(m),N=(h,g)=>{let f=h,d=g;if(o==="pairwise.complete.obs"){let k=h.map((b,M)=>!Number.isNaN(b)&&!Number.isNaN(g[M]));f=h.filter((b,M)=>k[M]),d=g.filter((b,M)=>k[M]),s==="spearman"&&(f=J(f),d=J(d))}else if(f.some(Number.isNaN)||d.some(Number.isNaN))return NaN;return f.length<2?NaN:s==="kendall"?r?K(f,d).tau:2*K(f,d).s:r?H(f,d)[0]:se(f,d)},y=p.map(h=>w.map(g=>N(h,g))),E=u===void 0?a:u.filter(Boolean).length;return r&&t===void 0&&o!=="pairwise.complete.obs"&&E>=2&&y.forEach((h,g)=>h[g]=1),t!==void 0&&!O(e)&&!O(t)?y[0][0]:y}function it(e,t,n={}){return t!==void 0&&!Array.isArray(t)&&!ArrayBuffer.isView(t)?Q(e,void 0,t,!1):Q(e,t,n,!1)}function ct(e,t,n={}){return t!==void 0&&!Array.isArray(t)&&!ArrayBuffer.isView(t)?Q(e,void 0,t,!0):Q(e,t,n,!0)}export{Ve as a,Ie as b,je as c,ze as d,Ue as e,Ze as f,he as g,pe as h,Ge as i,H as j,_e as k,J as l,it as m,ct as n};
1
+ /*! rStats.js 0.15.3 | 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{c as re}from"./chunk-USPEBXSR.js";import{e as ne,h as se,j as X,k as I,m as oe}from"./chunk-3WPU6LGK.js";import{a as ae,g as ie}from"./chunk-3THFTB36.js";import{x as B}from"./chunk-FCNVTIPJ.js";import{b as ce,c as S}from"./chunk-HD73UKPT.js";import{b as Y}from"./chunk-VLUL2HFW.js";import{g as D,h as G}from"./chunk-3TSWYE5L.js";import{b as ee,c as te,d as V,f as q,g as C,i as W}from"./chunk-KT66SB7R.js";function j(e){if(e.kind==="factor")return ce(e);let t=[...new Set(e.values)].sort((s,o)=>s-o),n=[...new Set(t.map(Y))],r=new Map(n.map((s,o)=>[s,o]));return{levels:n,codes:e.values.map(s=>r.get(Y(s)))}}function A(e,t){if(e.kind!=="numeric")throw new TypeError(`'${t}' must be a numeric column`);return e.values}function R(e,t){let n=ae(e),r=ie(n,Object.keys(t));return{terms:r,rhsVariables:r.variables.slice(r.response===0?1:0)}}function fe(e){if(typeof e!="string")throw new TypeError("the formula must be a string");let t=e.indexOf("~");return t<0?void 0:{lhs:e.slice(0,t).trim(),rhs:e.slice(t+1)}}var Ae=/^Pair\s*\(\s*([A-Za-z.][A-Za-z0-9._]*)\s*,\s*([A-Za-z.][A-Za-z0-9._]*)\s*\)$/,F="'formula' missing or incorrect",le=(e,t)=>t.length===0&&e.terms.length===0&&e.intercept;function Ve(e,t,n){let r=fe(e),s=r===void 0?null:Ae.exec(r.lhs);if(s!==null){let{terms:m,rhsVariables:p}=R(`~${r.rhs}`,t);if(!n||!le(m,p))throw new Error(F);let w=S(t,[s[1],s[2]]);return{kind:"paired",x:A(w.variables[0],s[1]),y:A(w.variables[1],s[2])}}let{terms:o,rhsVariables:c}=R(e,t);if(o.response<0)throw new Error(F);let i=o.variables[0];if(n&&le(o,c))return{kind:"one",x:A(S(t,[i]).variables[0],i)};if(c.length!==1||o.terms.length!==1)throw new Error(F);let a=S(t,[i,c[0]],{dropUnusedLevels:!0}),l=A(a.variables[0],i),u=j(a.variables[1]);if(u.levels.length!==2)throw new Error("grouping factor must have exactly 2 levels");return{kind:"two",x:l.filter((m,p)=>u.codes[p]===0),y:l.filter((m,p)=>u.codes[p]===1),levels:[u.levels[0],u.levels[1]]}}function Ie(e,t){let n=Ve(e,t,!1);if(n.kind!=="two")throw new Error(F);return n}function je(e,t){let{terms:n,rhsVariables:r}=R(e,t);if(n.response<0)throw new Error(F);if(r.length!==1)throw new Error("'formula' should be of the form response ~ group");let s=n.variables[0],o=S(t,[s,r[0]],{dropUnusedLevels:!0});return{values:A(o.variables[0],s),group:j(o.variables[1])}}function ze(e,t){let n=t.levels.map(()=>[]);return e.forEach((r,s)=>n[t.codes[s]].push(r)),n}function Ue(e,t){let{terms:n,rhsVariables:r}=R(e,t);if(n.response<0||r.length===0)throw new Error(F);let s=n.variables[0],o=S(t,[s,...r],{dropUnusedLevels:!0}),c=o.variables.slice(1).map(j),i=o.rows.map((a,l)=>{let u=0,m=1;for(let p of c)u+=p.codes[l]*m,m*=p.levels.length;return u});return{values:A(o.variables[0],s),groups:i}}var ue="incorrect specification for 'formula'";function Ze(e,t){let n=fe(e),r=n?.rhs.split("|");if(n===void 0||n.lhs===""||r.length!==2)throw new Error(ue);let s=y=>{let{terms:E,rhsVariables:h}=R(y,t);if(h.length!==1||E.terms.length!==1)throw new Error(ue);return h[0]},{terms:o}=R(`${n.lhs} ~ 1`,t),c=o.variables[0],i=s(`~${r[0]}`),a=s(`~${r[1]}`),l=S(t,[c,i,a],{dropUnusedLevels:!0}),u=A(l.variables[0],c),m=j(l.variables[1]),p=j(l.variables[2]),w=p.levels.map(()=>m.levels.map(()=>NaN)),N=p.levels.map(()=>m.levels.map(()=>0));if(u.forEach((y,E)=>{let h=p.codes[E],g=m.codes[E];N[h][g]++,w[h][g]=y}),N.some(y=>y.some(E=>E!==1)))throw new Error("not an unreplicated complete block design");return w}function me(e,t){let{terms:n,rhsVariables:r}=R(e,t);if(n.response>=0)throw new Error("'formula' missing or invalid");if(r.length!==2)throw new Error("invalid formula");let s=S(t,r);return{x:A(s.variables[0],r[0]),y:A(s.variables[1],r[1])}}function he(e){if(e===void 0)return"two.sided";let n=["two.sided","less","greater"].filter(r=>r.startsWith(e));if(e.length===0||n.length!==1)throw new RangeError(`invalid alternative "${e}" (expected "two.sided", "less" or "greater")`);return n[0]}function pe(e){if(!(Number.isFinite(e)&&e>=0&&e<=1))throw new RangeError("confLevel must be a number between 0 and 1")}function Ge(e){if(!(Number.isFinite(e)&&e>0&&e<1))throw new RangeError("'conf.level' must be a single number between 0 and 1")}var Se=["pearson","kendall","spearman"];function Te(e){if(e===void 0)return"pearson";let t=Se.filter(n=>n.startsWith(e));if(e.length===0||t.length!==1)throw new RangeError(`invalid method "${e}"`);return t[0]}function de(e){if(!(e[0]>0))return[Math.sqrt(e[0]),0];let t=Math.sqrt(e[0]),n=q(e,te(t,t));return ee(t,n[0]/(2*t))}function we(e){let t=ne(e);if(!Number.isFinite(t[0]))return;let n=e.map(o=>q([o,0],t)),r=0;for(let o of n)r=Math.max(r,Math.abs(o[0]));if(r===0)return n;let s=2**-Math.max(-1022,Math.floor(Math.log2(r)));return n.map(o=>[o[0]*s,o[1]*s])}function H(e,t){let n=e.length;if(n<2)return[NaN,0];let r=we(e),s=we(t);if(r===void 0||s===void 0)return[NaN,0];let o=[0,0],c=[0,0],i=[0,0];for(let l=0;l<n;l++)o=V(o,C(r[l],s[l])),c=V(c,C(r[l],r[l])),i=V(i,C(s[l],s[l]));if(c[0]===0||i[0]===0)return[NaN,0];let a=W(o,C(de(c),de(i)));return a[0]>=1?[1,0]:a[0]<=-1?[-1,0]:a}function ge(e,t){let n=C(q([1,0],e),V([1,0],e));return Math.sqrt(t)*e[0]/Math.sqrt(n[0])}function De(e){return Math.abs(e[0])<.5?Math.atanh(e[0]):.5*Math.log(V([1,0],e)[0]/q([1,0],e)[0])}function Ne(e,t,n){return n==="less"?B(e,t,!0,!1):n==="greater"?B(e,t,!1,!1):2*Math.min(B(e,t,!0,!1),B(e,t,!1,!1))}function Re(e,t){return t==="less"?D(e):t==="greater"?D(e,{lowerTail:!1}):2*Math.min(D(e),D(e,{lowerTail:!1}))}function K(e,t){let n=e.length,r=0;for(let u=0;u<n;u++){let m=e[u],p=t[u];for(let w=u+1;w<n;w++){let N=(e[w]>m?1:0)-(e[w]<m?1:0),y=(t[w]>p?1:0)-(t[w]<p?1:0);r+=N*y}}let s=I(e),o=I(t),c=n*(n-1)/2,i=s.reduce((u,m)=>u+m*(m-1)/2,0),a=o.reduce((u,m)=>u+m*(m-1)/2,0),l=n<2||i===c||a===c?NaN:i===0&&a===0?r/c:r/Math.sqrt((c-i)*(c-a));return{s:r,tau:l,ties:s.length>0||o.length>0,tx:s,ty:o}}function be(e,t){let n=e*(e-1)/2;if(t<0)return 0;if(t>=n)return 1;let r=new Float64Array(t+1);r[0]=1;for(let o=2;o<=e;o++){let c=new Float64Array(t+1),i=0;for(let l=0;l<=t;l++)i+=r[l],c[l]=i;let a=new Float64Array(t+1);for(let l=0;l<=t;l++)a[l]=(c[l]-(l>=o?c[l-o]:0))/o;r=a}let s=0;for(let o=t;o>=0;o--)s+=r[o];return Math.min(1,s)}var ve=new Map;function Le(e){let t=ve.get(e);if(t!==void 0)return t;let n=e*(e*e-1)/3,r=1<<e,s=new Array(r);s[0]=new Float64Array(n+1),s[0][0]=1;let o=i=>{let a=0;for(;i;i&=i-1)a++;return a};for(let i=0;i<r;i++){let a=s[i];if(a===void 0)continue;let l=o(i);for(let u=0;u<e;u++){if(i&1<<u)continue;let m=(u-l)**2,p=i|1<<u,w=s[p]??=new Float64Array(n+1);for(let N=0;N+m<=n;N++)a[N]&&(w[N+m]+=a[N])}i!==r-1&&(s[i]=void 0)}let c=s[r-1];return ve.set(e,c),c}var x=[.2274,.2531,.1745,.0758,.1033,.3932,.0879,.0151,.0072,.0831,.0131,46e-5];function ye(e,t,n){let r=t;r%2!==0&&(r+=1);let s=1/e,o=(6*(r-1)*s/(e*e-1)-1)*Math.sqrt(1/s-1),c=o*o,a=o*s*(x[0]+s*(x[1]+x[2]*s)+c*(-x[3]+s*(x[4]+x[5]*s)-c*s*(x[6]+x[7]*s-c*(x[8]-x[9]*s+c*s*(x[10]-x[11]*c)))))/Math.exp(c/2),l=n?D(o)-a:a+D(o,{lowerTail:!1});return Math.min(1,Math.max(0,l))}function Me(e,t,n){let r=e*(e*e-1)/3;if(e<=9){let s=Le(e),o=1;for(let i=2;i<=e;i++)o*=i;let c=0;if(n)for(let i=Math.min(t,r);i>=0;i--)c+=s[i];else for(let i=r;i>=Math.max(t,0);i--)c+=s[i];return c/o}return n?t+1>r?1:t+1<=0?0:ye(e,t+1,!0):t<=0?1:t>r?0:ye(e,t,!1)}function _e(e,t,n={}){if(typeof e=="string"){let r=me(e,t);return _e(r.x,r.y,n)}return Ce(e,t,n)}function Ce(e,t,n){if(e.length!==t.length)throw new TypeError("x and y must have the same length");let r=he(n.alternative),s=Te(n.method),o=n.continuity??!1,[c,i]=oe(Array.from(e),Array.from(t)),a=c.length;if(s==="pearson"){let f=n.confLevel??.95;if(pe(f),a<3)throw new Error("not enough finite observations");let d=H(c,i),k=a-2,b=Number.isNaN(d[0])?NaN:ge(d,k),M={method:"Pearson's product-moment correlation",alternative:r,statistic:b,statisticName:"t",parameter:k,parameterName:"df",pValue:Ne(b,k,r),estimate:d[0],estimateNames:"cor",nullValue:0,nullValueName:"correlation"};if(a>3){let z=De(d),L=1/Math.sqrt(a-3),_=T=>Math.tanh(z+T),$;if(r==="less")$=[-1,_(L*G(f))];else if(r==="greater")$=[_(-L*G(f)),1];else{let T=L*G((1+f)/2);$=[_(-T),_(T)]}M.confInt=$,M.confLevel=f}return M}if(a<2)throw new Error("not enough finite observations");if(s==="kendall"){let f=K(c,i),d={method:"Kendall's rank correlation tau",alternative:r,estimate:f.tau,estimateNames:"tau",nullValue:0,nullValueName:"tau"};if(Number.isNaN(f.tau))return{...d,statistic:NaN,statisticName:"T",pValue:NaN};if((n.exact??a<50)&&!f.ties){let v=a*(a-1)/2,P=(f.s+v)/2,U=be(a,P),Z=be(a,v-P),Ee=r==="less"?U:r==="greater"?Z:Math.min(1,2*Math.min(U,Z));return{...d,statistic:P,statisticName:"T",pValue:Ee}}let b=(v,P)=>P.reduce((U,Z)=>U+v(Z),0),M=v=>v*(v-1),z=v=>v*(v-1)*(v-2),L=v=>v*(v-1)*(2*v+5),_=(a*(a-1)*(2*a+5)-b(L,f.tx)-b(L,f.ty))/18+b(z,f.tx)*b(z,f.ty)/(9*a*(a-1)*(a-2))+b(M,f.tx)*b(M,f.ty)/(2*a*(a-1)),T=(o?Math.sign(f.s)*(Math.abs(f.s)-1):f.s)/Math.sqrt(_);return{...d,statistic:T,statisticName:"z",pValue:Re(T,r)}}let l=X(c),u=X(i),m=H(l,u),p=a*a*a-a,w=p*(1-m[0])/6,N={method:"Spearman's rank correlation rho",alternative:r,statistic:w,statisticName:"S",estimate:m[0],estimateNames:"rho",nullValue:0,nullValueName:"rho"};if(Number.isNaN(m[0]))return{...N,pValue:NaN};let y=I(c).length>0||I(i).length>0;if((n.exact??a<=1290)&&!y&&a<=1290){let f=Math.round(w),d=Me(a,f,!0),k=Me(a,f,!1),b=r==="greater"?d:r==="less"?k:Math.min(1,2*Math.min(d,k));return{...N,pValue:b}}let h=m;if(o){let f=W([6,0],[p,0]);h=W(V(m,f),V([1,0],f)),Math.abs(h[0])>=1&&(h=[Math.sign(h[0]),0])}let g=ge(h,a-2);return{...N,pValue:Ne(g,a-2,r)}}function Fe(e,t){let n=e.length,r=new Array(n);if(t==="first"||t==="last"||t==="random"){let c=t==="random"?re(n):[],i=Array.from({length:n},(a,l)=>l);return i.sort((a,l)=>{let u=e[a]-e[l];return u!==0?u:t==="first"?a-l:t==="last"?l-a:c[a]-c[l]||a-l}),i.forEach((a,l)=>r[a]=l+1),r}let s=Array.from({length:n},(c,i)=>i).sort((c,i)=>e[c]-e[i]||c-i),o=0;for(;o<n;){let c=o;for(;c+1<n&&e[s[c+1]]===e[s[o]];)c++;let i=t==="average"?(o+c+2)/2:t==="min"?o+1:c+1;for(let a=o;a<=c;a++)r[s[a]]=i;o=c+1}return r}function J(e,t={}){let n=t.tiesMethod??"average";if(!["average","first","last","random","max","min"].includes(n))throw new RangeError(`invalid tiesMethod "${n}"`);let r=t.naLast??"last",s=Array.from(e),o=s.filter(m=>!Number.isNaN(m)),c=Fe(o,n),i=s.length-o.length,a=[],l=0,u=0;for(let m of s)Number.isNaN(m)?(u++,a.push(r==="keep"?NaN:r==="last"?o.length+u:u)):a.push(r==="first"?c[l++]+i:c[l++]);return a}var Oe=["pearson","kendall","spearman"],$e=["all.obs","complete.obs","pairwise.complete.obs","everything","na.or.complete"];function xe(e,t,n,r){if(e===void 0)return n;if(t.includes(e))return e;let s=t.filter(o=>o.startsWith(e));if(e.length===0||s.length!==1)throw new RangeError(`invalid '${r}' argument`);return s[0]}function O(e){return e.length>0&&Array.isArray(e[0])}function ke(e){if(!O(e))return[Array.from(e)];let t=e[0].length;return Array.from({length:t},(n,r)=>e.map(s=>s[r]))}function Q(e,t,n,r){let s=xe(n.method,Oe,"pearson","method"),o=xe(n.use,$e,"everything","use");if(t===void 0&&!O(e))throw new TypeError("supply both 'x' and 'y' or a matrix-like 'x'");let c=ke(e),i=t===void 0?c:ke(t),a=c[0]?.length??0;if(i.some(h=>h.length!==a))throw new RangeError("incompatible dimensions");let l=[...c,...i];if(o==="all.obs"&&l.some(h=>h.some(Number.isNaN)))throw new RangeError("missing observations in cov/cor");if(!r&&o==="pairwise.complete.obs"&&s!=="pearson")throw new RangeError("cannot handle 'pairwise.complete.obs'");let u;if((o==="complete.obs"||o==="na.or.complete")&&(u=Array.from({length:a},(h,g)=>l.every(f=>!Number.isNaN(f[g]))),!u.some(Boolean))){if(o==="complete.obs")throw new RangeError("no complete element pairs");return t===void 0||O(e)||O(t)?c.map(()=>i.map(()=>NaN)):NaN}let m=h=>{let g=u===void 0?h:h.filter((f,d)=>u[d]);return s==="spearman"&&o!=="pairwise.complete.obs"?J(g,{naLast:"keep"}):g},p=c.map(m),w=t===void 0?p:i.map(m),N=(h,g)=>{let f=h,d=g;if(o==="pairwise.complete.obs"){let k=h.map((b,M)=>!Number.isNaN(b)&&!Number.isNaN(g[M]));f=h.filter((b,M)=>k[M]),d=g.filter((b,M)=>k[M]),s==="spearman"&&(f=J(f),d=J(d))}else if(f.some(Number.isNaN)||d.some(Number.isNaN))return NaN;return f.length<2?NaN:s==="kendall"?r?K(f,d).tau:2*K(f,d).s:r?H(f,d)[0]:se(f,d)},y=p.map(h=>w.map(g=>N(h,g))),E=u===void 0?a:u.filter(Boolean).length;return r&&t===void 0&&o!=="pairwise.complete.obs"&&E>=2&&y.forEach((h,g)=>h[g]=1),t!==void 0&&!O(e)&&!O(t)?y[0][0]:y}function it(e,t,n={}){return t!==void 0&&!Array.isArray(t)&&!ArrayBuffer.isView(t)?Q(e,void 0,t,!1):Q(e,t,n,!1)}function ct(e,t,n={}){return t!==void 0&&!Array.isArray(t)&&!ArrayBuffer.isView(t)?Q(e,void 0,t,!0):Q(e,t,n,!0)}export{Ve as a,Ie as b,je as c,ze as d,Ue as e,Ze as f,he as g,pe as h,Ge as i,H as j,_e as k,J as l,it as m,ct as n};
@@ -0,0 +1,2 @@
1
+ /*! rStats.js 0.15.3 | 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 U,b as S,c as q,d as G,e as $,f as J,h as P,i as qt,k as Xn,l as it,p as rn,r as Wn,s as K,t as ht,u as Yn,v as St,w as en}from"./chunk-FCNVTIPJ.js";import{a as Hn,c as lt}from"./chunk-FKAKALOZ.js";import{A as W,J as Qn,N as Y,O as Zn,e as _,h as T,n as Gn,o as V,p as Vn,q as Kn,s as w,t as xt,u as Z,v as ct}from"./chunk-3TSWYE5L.js";import{b as k,c as Q,d as I,e as et,f as vt,g as R,h as tn,i as B,j as nn,k as A}from"./chunk-KT66SB7R.js";var dt=8*Number.EPSILON,jn=2*Number.EPSILON,ue=1e-290;function Rt(n){let{p:t,lowerTail:r,logP:e,lo:i,hi:u}=n,o=!1,s=(M,l,d)=>{let y=n.cdf(M,l,d);return Number.isNaN(y)&&(o=!0),y},a;if(e||t<ue){let M;e?M=r?t*(1+jn):t*(1-jn):M=Math.log(t)+Math.log1p(r?-dt:dt),a=r?l=>s(l,!0,!0)>=M:l=>s(l,!1,!0)<=M}else{let M;if(r?M=t*(1-dt):M=1-t>4*dt?t*(1+dt):t,M>.5){let l=1-M;a=r?d=>s(d,!1,!1)<=l:d=>s(d,!0,!1)>=l}else a=r?l=>s(l,!0,!1)>=M:l=>s(l,!1,!1)<=M}let f=Math.round(n.y0);Number.isFinite(f)||(f=i),f=Math.min(Math.max(f,i),u);let c=Math.max(1,Math.abs(f)*Number.EPSILON);if(a(f)){let M=c,l=f-M;for(;l>=i&&a(l);)f=l,M*=2,l=f-M;if(o)return NaN;if(l<i){if(f===i)return i;l=i-1}let d=$n(l,f,a,()=>o);return o?NaN:d}if(o)return NaN;let h=c,N=f+h;for(;N<=u&&!a(N);){if(o)return NaN;if(f=N,h*=2,N=f+h,N===1/0)return u}N>u&&(N=u);let m=$n(f,N,a,()=>o);return o?NaN:m}function $n(n,t,r,e){for(;t-n>1&&!e();){let i=Math.floor(n+(t-n)/2);if(i===n||i===t)break;r(i)?t=i:n=i}return t}var Ut=Hn;function oe(n,t,r){return Number.isNaN(n)||Number.isNaN(t)?NaN:t<0?NaN:Ut(n)?q(r):n<0||!Number.isFinite(n)?q(r):Z(Math.round(n),t,r)}function se(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t))return NaN;if(t<0)return NaN;if(n<0)return U(r,e);if(t===0)return S(r,e);if(!Number.isFinite(n))return S(r,e);let i=Math.floor(n+1e-7);return W(i+1,t,!r,e)}function fe(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t))return NaN;if(!Number.isFinite(t)||t<0)return NaN;let i=G(n,0,1/0,r,e);if(i!==void 0)return t===0&&!Number.isNaN(i)?0:i;if(t===0)return 0;let u=Math.sqrt(t),o=T(n,{lowerTail:r,logP:e}),s=t+u*(o+(o*o-1)/(6*u));return Rt({p:n,lowerTail:r,logP:e,cdf:(a,f,c)=>W(a+1,t,!f,c),y0:Number.isFinite(s)?s:t,lo:0,hi:1/0})}function ci(n,t,r={}){let e=r.log??!1;return _(n,i=>oe(i,t,e))}function hi(n,t,r={}){let{lowerTail:e=!0,logP:i=!1}=r;return _(n,u=>se(u,t,e,i))}function Ni(n,t,r={}){let{lowerTail:e=!0,logP:i=!1}=r;return _(n,u=>fe(u,t,e,i))}var Ot=new DataView(new ArrayBuffer(8));function un(n){Ot.setFloat64(0,Math.abs(n));let t=Ot.getBigInt64(0);return n<0?-t:t}function It(n){Ot.setBigInt64(0,n<0n?-n:n);let t=Ot.getFloat64(0);return n<0n?-t:t}function Nt(n,t,r,e){let i=un(t),u=un(r),o=un(Math.min(Math.max(n,t),r));if(o>i&&o<u)if(e(It(o))){u=o;for(let s=1n;u-s>i;s*=2n){if(!e(It(u-s))){i=u-s;break}u-=s}}else{i=o;for(let s=1n;i+s<u;s*=2n){if(e(It(i+s))){u=i+s;break}i+=s}}for(;u-i>1n;){let s=i+(u-i)/2n;e(It(s))?u=s:i=s}return It(u)}function gt(n,t,r){let e=n*.999999999999,i=Math.min(n*(1+1e-12),t);return e<i&&!r(e)&&r(i)?Nt(n,e,i,r):void 0}var Jn=[.9914553711208126,.9491079123427585,.8648644233597691,.7415311855993945,.5860872354676911,.4058451513773972,.20778495500789848,0],zn=[.022935322010529224,.06309209262997856,.10479001032225019,.14065325971552592,.1690047266392679,.19035057806478542,.20443294007529889,.20948214108472782],Tn=[.1294849661688697,.27970539148927664,.3818300505051189,.4179591836734694];function pt(n=1e-15,t=4e3){return{tol:n,maxBisections:t,bisections:0}}function ut(n,t,r,e,i,u){let o=(t+r)/2,s=(r-t)/2,a=n(o),f=zn[7]*a,c=Tn[3]*a;for(let h=0;h<7;h++){let N=n(o-s*Jn[h])+n(o+s*Jn[h]);f+=zn[h]*N,h%2===1&&(c+=Tn[(h-1)/2]*N)}return f*=s,c*=s,Math.abs(f-c)<=u.tol*Math.max(Math.abs(f),e)||i>=40||!Number.isFinite(f)||++u.bisections>u.maxBisections?f:ut(n,t,o,e,i+1,u)+ut(n,o,r,e,i+1,u)}function yt(n,t){return n*Math.max(1,t)<1e-20}var ae=1e-17,ce=Math.log(ae),wn=2e7,cn=500,on=2**cn,Lt=2**-cn,he=2**250,Ne=2**-250,Gt=cn*Math.LN2,z={h:0,l:0,k:0};function j(n,t,r,e=!1){if(n===0)return z;if(!Number.isFinite(n))return{h:n,l:0,k:r};for(;Math.abs(n)>he;)n*=Lt,t*=Lt,r++;for(;Math.abs(n)<Ne;)n*=on,t*=on,r--;return e?{h:n,l:t,k:r,approx:e}:{h:n,l:t,k:r}}var Me=[346.5735902799727,-22599635089223323e-30];function Vt(n,t){if(n>1e-305||Number.isNaN(n))return j(n,0,0);let r=t(),[e,i]=typeof r=="number"?[r,0]:r;if(e===-1/0)return z;if(Number.isNaN(e))return{h:NaN,l:0,k:0};let u=Math.round(e/Gt);if(Math.abs(u)>2**50)return j(1,0,u,!0);let o=I([e,i],R(Me,[-u,0])),s=Math.exp(o[0]);return typeof r=="number"?j(s,0,u,!0):j(s,s*o[1],u)}function hn(n,t){if(n===0)return[-t,0];let r=22250738585072014e-324,e=n>=1&&n<=1e10;if(n<=t*r||t<n*r&&!e||!Number.isFinite(n))return I(R(A([t,0]),[n,0]),[-t-V(n),0]);let i=I(Kn(n,[t,0]),[Vn(n),0]);return I([-i[0],-i[1]],[-.5*(me+Math.log(n)),0])}var me=1.8378770664093456;function tt(n,t){return n.approx===!0&&le(n)>-700?t():n}function st(n,t){return bt(n,j(t[0],t[1],0))}function Nn(n,t){if(n.h===0)return z;let r=j(t[0],t[1],0),e=B([n.h,n.l],[r.h,r.l]);return j(e[0],e[1],n.k-r.k,n.approx)}function Pn(n,t,r){let e=st(n,t.ratio(r));return t.ratioK?{...e,k:e.k+t.ratioK}:e}function tr(n,t,r){let e=Nn(n,t.ratio(r));return t.ratioK?{...e,k:e.k-t.ratioK}:e}function bt(n,t){if(n.h===0||t.h===0)return z;let r=R([n.h,n.l],[t.h,t.l]);return j(r[0],r[1],n.k+t.k,n.approx===!0||t.approx===!0)}function Bt(n,t,r,e){if(e-r>=3)return[0,0];for(let i=r;i<e&&n!==0;i++)n*=Lt,t*=Lt;return[n,t]}function nr(n,t){if(n.h===0)return t;if(t.h===0)return n;let r=Math.max(n.k,t.k),e=I(Bt(n.h,n.l,n.k,r),Bt(t.h,t.l,t.k,r));return j(e[0],e[1],r)}function le(n){return n.h===0?-1/0:Math.log(n.h)+n.l/n.h+n.k*Gt}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]=Bt(this.s,this.c,this.k,t.k),this.k=t.k);let[r,e]=Bt(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 positive(){return this.s+this.c>0}get scaled(){return{h:this.s+this.c,l:0,k:this.k}}get log(){let t=this.s+this.c;return Number.isNaN(t)?NaN:t>0?Math.log(t)+this.k*Gt:-1/0}get linear(){let t=this.s+this.c;for(let r=0;r<Math.min(this.k,5);r++)t*=on;for(let r=0;r>Math.max(this.k,-5)&&t!==0;r--)t*=Lt;return t}value(t){return t?this.log:this.linear}divideBy(t){let r=j(t,0,0);this.s/=r.h,this.c/=r.h,this.k-=r.k}},rr=1e8;function de(n){if(n>rr)return er(n,1);let t=Math.floor(n),r=1;for(;;){if(r*=n/(t+1),r/(1-n/(t+2))<3e-21)return t;t++}}function Ie(n){if(n>rr)return er(n,-1);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 er(n,t){let r=Math.floor(n),e=Z(r,n,!0),i=s=>{let a=s+t;if(a<0)return!0;let f=t>0?n/(s+2):(s-1)/n;return Z(a,n,!0)-e-Math.log1p(-f)<Math.log(3e-21)},u=0,o=Math.ceil(10*Math.sqrt(n));for(;!i(r+t*o);)u=o,o*=2;for(let s=0;s<200&&o-u>1;s++){let a=Math.floor((u+o)/2);if(a<=u||a>=o)break;i(r+t*a)?o=a:u=a}return Math.max(0,r+t*o)}function Ct(n,t,r){let e=sn(n,t);return!(e<0)||!r.positive?!1:sn(n,r.scaled)+e-Math.log(-Math.expm1(e))<=ce}function sn(n,t){return n.h===0?t.h===0?NaN:-1/0:t.h===0?1/0:Math.log(n.h/t.h)+(n.l/n.h-t.l/t.h)+(n.k-t.k)*Gt}function ir(n,t,r){return t<1e290?st(n,nn([t,0],r)):Nn(st(n,[t,0]),[r,0])}function ur(n,t,r){return r>1e-290&&r<1e290?st(n,nn([t,0],r)):Nn(st(n,[t,0]),[r,0])}function ot(n,t){return Vt(Z(n,t,!1),()=>hn(n,t))}function X(n,t){return Vt(n.inc(t,!1),()=>n.incLogDD?n.incLogDD(t):n.inc(t,!0))}function or(n,t,r,e){return(r?fn(n,t):an(n,t)).value(e)}function Kt(n,t,r,e){let i=e,u=i?fn(n,t):an(n,t);if(u.linear>.5&&(i=!i,u=i?fn(n,t):an(n,t)),i===r)return{lin:u.linear,log:u.log};let o=u.linear;return{lin:1-o,log:Math.log1p(-o)}}function sr(n,t,r,e){return Z(r,t,!0)+n.cdf(r,e,!0)}function fr(n,t,r){for(let i=0;i<3e3&&r-t>2;i++){let u=Math.floor(t+(r-t)/3),o=Math.ceil(r-(r-t)/3);n(u)<n(o)?t=u:r=o}if(r-t>2)return Math.round((t+r)/2);let e=t;for(let i=t+1;i<=r;i++)n(i)>n(e)&&(e=i);return e}var ge=60;function ar(n,t,r,e){let i=n(t)-ge;for(let u=1;;u*=2){let o=t+r*u;if(r>0?o>=e:o<=e)return e;if(n(o)<i)return o}}var cr=3e3;function fn(n,t){let r=de(n);if(r>cr){let a=f=>sr(t,n,f,!0);r=ar(a,fr(a,0,r),1,r)}let e=Vt(t.cdf(r,!0,!1),()=>t.cdf(r,!0,!0)),i=ot(r,n),u=r>0?X(t,r-1):z,o=new Ft,s=z;for(let a=r;a>=0;a--){let f=bt(i,e);if(o.add(f),Ct(f,s,o)||Number.isNaN(f.h)||(s=f,a===0))break;e=nr(e,u),i=tt(ur(i,a,n),()=>ot(a-1,n)),a>=2&&(u=u.h===0?X(t,a-2):tt(tr(u,t,a-1),()=>X(t,a-2)))}return o}function an(n,t){let r=Ie(n),e=!1;for(;;){let i=Vt(t.cdf(r,!1,!1),()=>t.cdf(r,!1,!0)),u=ot(r,n),o=X(t,r),s=new Ft,a=z,f=-1;for(let c=r;c<r+wn;c++){let h=bt(u,i);if(s.add(h),Ct(h,a,s)||Number.isNaN(h.h)||h.h===0&&c>n+50&&c>r+50)break;if(!e&&c-r>=cr&&!(sn(h,a)<0)){let N=d=>sr(t,n,d,!1),m=N(c),M=c+1;for(let d=1;N(M)>=m&&d<2**60;d*=2)M=c+d;let l=ar(N,fr(N,c,M),-1,c);if(e=!0,l>c){f=l;break}}a=h,i=nr(i,o),u=tt(ir(u,n,c+1),()=>ot(c+1,n)),o=o.h===0?X(t,c+1):tt(Pn(o,t,c+1),()=>X(t,c+1))}if(f<0)return s;r=f}}function Qt(n,t,r,e,i,u){let o=Number.isFinite(e)&&n>0?Math.max(0,Math.round(e)):0,s=new Ft,a=ot(o,n),f=X(t,o),c=a,h=f,N=z;for(let m=o;m<o+wn;m++){let M=st(bt(c,h),[r(m),0]);if(s.add(M),Ct(M,N,s)||Number.isNaN(M.h)||M.h===0&&m>n+50&&m>o+50)break;N=M,c=tt(ir(c,n,m+1),()=>ot(m+1,n)),h=h.h===0?X(t,m+1):tt(Pn(h,t,m+1),()=>X(t,m+1))}c=a,h=f,N=z;for(let m=o-1;m>=0;m--){c=tt(ur(c,m+1,n),()=>ot(m,n)),h=h.h===0?X(t,m):tt(tr(h,t,m+1),()=>X(t,m));let M=st(bt(c,h),[r(m),0]);if(s.add(M),Ct(M,N,s)||Number.isNaN(M.h))break;N=M}return s.divideBy(i),s.value(u)}function lr(n){return n<=.5?[[n,0],k(1,-n)]:[k(1,-(1-n)),[1-n,0]]}function dr(n,t,r,e){let[i,u]=lr(n);if((t+r)*Math.min(i[0],u[0])<22250738585072014e-324){let h=ye(i,u,t,r);return e?h:Math.exp(h)}let{e:o}=xt(t,r,i,u);if(o[0]===1/0)return q(e);let s=t*r/(t+r);if(!e&&o[0]<700&&n>1e-290&&u[0]>1e-290){let h=Math.exp(-o[0])*(1-o[1])*Math.sqrt(s/(2*Math.PI));if(h>1e-290&&h<1e290){let N=R(i,u);return h/N[0]*(1-N[1]/N[0])}}let a=n>1e-290&&u[0]>1e-290?A(R(i,u)):I(A(i),A(u)),f=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)),c=I(et(I(o,a)),[f,0]);return e?c[0]+c[1]:Math.exp(c[0])*(1+c[1])}function pe(n,t,r){let[e,i]=lr(n),[u,o]=t===1?[r,i]:[t,e],s=I(A([u,0]),R(k(u,-1),A(o)));return s[0]+s[1]}function ye(n,t,r,e){let i=I(R(k(r,-1),A(n)),R(k(e,-1),A(t)));return i[0]+(i[1]-Y(r,e))}function Le(n,t,r,e){return n>0&&n<1?dr(n,r,e,!0):kt(n,r,e,!0)}function kt(n,t,r,e){return Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)?NaN:t<0||r<0?NaN:n<0||n>1?q(e):t===0||r===0||!Number.isFinite(t)||!Number.isFinite(r)?t===0&&r===0?n===0||n===1?1/0:q(e):t===0||r/t===1/0?n===0?1/0:q(e):r===0||t/r===1/0?n===1?1/0:q(e):n===.5?1/0:q(e):n===0?t>1?q(e):t<1?1/0:e?Math.log(r):r:n===1?r>1?q(e):r<1?1/0:e?Math.log(t):t:t===1&&r===1?e?0:1:e&&(t===1||r===1)?pe(n,t,r):dr(n,t,r,e)}function Mn(n,t,r,e,i){return Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)?NaN:t<0||r<0?NaN:n>=1?S(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?S(e,i):r===0||t/r===1/0?U(e,i):n<.5?U(e,i):S(e,i):n<=0?U(e,i):K(t,r,n,1-n,e,i)}function mn(n,t,r,e){if(!(n>1&&t>1))return;let i=T(e,{logP:!0}),u=r?-i:i,o=1/(2*n-1),s=1/(2*t-1),a=2/(o+s),f=(u*u-3)/6;if(!(a+f>0))return;let c=u*Math.sqrt(a+f)/a-(s-o)*(f+5/6-2/(3*a)),h=n/(n+t*Math.exp(2*c));return h>0&&h<1?h:void 0}function be(n,t,r,e){let i=Math.min(n,t),u=Math.max(n,t);if(!(.5*(Math.log(t)-Math.log(n)-Math.log(u)-Math.log1p(i/u))<Math.log(1e-15)))return;let s=h=>{let N=K(n,t,h,1-h,r,!0);return r?N>=e:N<=e},a=1/(1+t/n),f=a*(1-1e-13),c=a*(1+1e-13);if(!(s(f)||!s(c)))for(;;){let h=f+(c-f)/2;if(h===f||h===c)return c;s(h)?c=h:f=h}}function hr(n,t,r,e,i){let u=K(n,t,Number.MIN_VALUE,1,r,!0);if(r?u>=e:u<=e)return 0;let o=be(n,t,r,e);if(o!==void 0)return o;let s=.25,a=1/0;if(r){let f=(e+Math.log(n)+Y(n,t))/n;a=Math.exp(Math.max(f,-745)),s=Math.min(a,.25)}if(!(a<.001)){let f=mn(n,t,r,e);f!==void 0&&f<.5&&(s=f)}if(t>1e10&&t>1e10*n){let f=Xn(e,n,r,!0)/t;f>0&&f<.5&&(s=f)}return J({logTarget:e,...i!==void 0&&{linearTarget:i},lower:r,cdf:(f,c)=>K(n,t,f,1-f,c,!1),cdfLog:(f,c)=>K(n,t,f,1-f,c,!0),cdfBoth:(f,c)=>St(n,t,f,1-f,c),pdfLog:f=>Le(f,1-f,n,t),dlogPdf:f=>(n-1)/f-(t-1)/(1-f),x0:s,lo:0,hi:.5,positive:!0})}function Xt(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 u=G(n,0,1,e,i);if(u!==void 0)return u;if(t===0||r===0||!Number.isFinite(t)||!Number.isFinite(r)){if(t===0&&r===0){let m=i?n:Math.log(n),M=e?m:Math.log1p(-Math.exp(m));return M<-Math.LN2?0:M>-Math.LN2?1:.5}return t===0||r/t===1/0?0:r===0||t/r===1/0?1:.5}let{lower:o,logTarget:s,linearTarget:a}=$(n,e,i),f=K(t,r,.5,.5,o,!0);if(o?s<=f:s>=f)return hr(t,r,o,s,a);let h=2**-55,N=K(r,t,h,1-h,!o,!0);return(o?N<=s:N>=s)?1:1-hr(r,t,!o,s,a)}function vi(n,t,r,e={}){let{log:i=!1,ncp:u}=e;return u!==void 0?_(n,o=>Nr(o,t,r,u,i)):_(n,o=>kt(o,t,r,i))}function xi(n,t,r,e={}){let{lowerTail:i=!0,logP:u=!1,ncp:o}=e;return o!==void 0?_(n,s=>Mr(s,t,r,o,i,u)):_(n,s=>Mn(s,t,r,i,u))}function qi(n,t,r,e={}){let{lowerTail:i=!0,logP:u=!1,ncp:o}=e;return o!==void 0?_(n,s=>mr(s,t,r,o,i,u)):_(n,s=>Xt(s,t,r,i,u))}function pr(n,t){let r=t<1e-250,e=t>1e250,i=r?t*2**500:e?t*2**-500:t;return{ratioK:r?-1:e?1:0,cdf:(u,o,s)=>W(n+u,t,o,s),inc:(u,o)=>{let[s,a]=Ir(n,u,t);if(s<1e-8){let f=Fe(s,t);return o?f:Math.exp(f)}return o?Z(s,t,!0)+a:Z(s,t,!1)*(1+a)},ratio:u=>B([i,0],k(n,u)),incLogDD:u=>{let[o,s]=Ir(n,u,t);return o<1e-8?I([-t,0],[o*Math.log(t)-V(o),0]):I(hn(o,t),[s,0])}}}function Fe(n,t){return n*Math.log(t)-t-V(n)}function Ir(n,t,r){let[e,i]=k(n,t);return[e,i===0?0:i*(Math.log(r)-lt(e+1))]}function In(n,t){return n>=0&&t>=0&&Number.isFinite(n)&&Number.isFinite(t)}function Ht(n,t,r,e){let i=r/2,u=gn(t,_t(n,r));if(u!==void 0)return u==="hankel"?Ee(n,t,r,e):_r(n,t,r,e);let o=yr(n);if(o!==void 0){let a=2*(n/2),f=Math.expm1(t/2*o),c=Ht(a,t,r,!0);if(e)return{lin:c.lin*(1+f),log:c.log+t/2*o};let h=Ht(a,t,r,!1),N=c.lin*f/h.lin;return Number.isFinite(N)?{lin:h.lin-c.lin*f,log:h.log+Math.log1p(-N)}:h}let s=pr(t/2,Math.max(n/2,Number.MIN_VALUE));if(i>1e8&&!e){let a=or(i,s,!0,!1),f;return{lin:1-a,get log(){return f??=Math.log1p(-a),f}}}return Kt(i,s,e,n<t+r)}function yr(n){let t=2*(n/2);return t>0&&t!==n?Math.log1p((n-t)/t):void 0}function Lr(n,t,r,e,i){let u=Ht(n,t,r,e);return i?u.log:u.lin}function ke(n,t){let r=NaN,e=!0,i={lin:NaN,log:NaN};return(u,o)=>((u!==r||o!==e)&&(i=Ht(u,n,t,o),r=u,e=o),i)}function Dt(n,t,r,e){let i=t/2,u=Math.max(n/2,Number.MIN_VALUE),o=r/2,s=_t(n,r),a=gn(t,s);if(a==="hankel")return kr(n,t,r,e);if(a==="debye"){let h=Ln(n,t,r).logf;return e?h:Math.exp(h)}let f=yr(n);if(f!==void 0){let h=2*(n/2);return e?Dt(h,t,r,!0)+(i-1)*f:Dt(h,t,r,!1)*Math.exp((i-1)*f)}let c=i>1?s*s/2/(i-1+Math.hypot(i-1,s)):(-(i-1)+Math.hypot(i-1,s))/2;return Qt(o,pr(i,u),h=>i+h,c,n,e)}function _t(n,t){return Math.sqrt(t)*Math.sqrt(n)}var De=1e4,_e=1e6,Ae=1e4;function gn(n,t){let r=n/2-1;return t>De&&r*r<=t/100?"hankel":t>_e||r>Ae?"debye":void 0}function pn(n,t){return B(k(n,-t),I(ln(n),ln(t)))}function ln(n){if(n>1e300){let[i,u]=ln(n/4);return[2*i,2*u]}let t=Math.sqrt(n),[r,e]=Q(t,t);return[t,(n-r-e)/(2*t)]}function br(n){let[t,r]=Q(n[0],n[0]);return[t,r+2*n[0]*n[1]]}function Fr(n,t,r){return n/t>-.5?Math.log1p(n/t):.5*Math.log(r)-Math.log(t)}function kr(n,t,r,e,i){let u=t/2-1,o=_t(n,r),s=dn(u,o),a=Math.sqrt(r),f=i??pn(n,r),c=f[0]+f[1],[h,N]=br(f),m=-h/2,M=-Math.LN2-N/2+u*Fr(c,a,n)-yn-.5*Math.log(o)+Math.log(s);return e?m+M:m>-700?Math.exp(m)*Math.exp(M):Math.exp(m+M)}function dn(n,t){let r=4*n*n,e=1,i=1;for(let u=1;u<30&&(e*=-(r-(2*u-1)*(2*u-1))/(8*u*t),i+=e,!(Math.abs(e)<1e-17*Math.abs(i)));u++);return i}var yn=.9189385332046728;function Ee(n,t,r,e){let i=t/2-1,u=i+.5,o=Math.sqrt(r),s=Math.sqrt(n),a=pn(n,r),f=a[0]+a[1],c=r+4*u>=0?2*u/(Math.sqrt(r+4*u)+o):-o/2,h=f>=c,N=h?1:-1,m=Math.log(dn(i,s*o)),M=F=>{let x=N*F,C=Math.exp(-x*(2*f+x)/2+u*Math.log1p(x/s)+Math.log(dn(i,(s+x)*o))-m);return Number.isFinite(C)?C:0},l=F=>-N*(u/(s+N*F)-(f+N*F)),d=h?1/0:s,y=1/(1+Math.abs(l(0))),L=0,b=0,p=pt();for(let F=0;F<200&&L<d;F++){let x=Math.min(L+y,d);b+=ut(M,L,x,b,0,p);let C=l(x);if(C>0&&M(x)<=1e-17*C*b)break;L=x,y*=2}let[E,D]=br(a),g=-E/2,v=-D/2+u*Fr(f,o,n)-yn+m+Math.log(b),O=g>-700?Math.exp(g)*Math.exp(v):Math.exp(g+v);return h!==e?{lin:O,log:g+v}:{lin:1-O,log:Math.log1p(-O)}}var gr=(()=>{let n=[[1]];for(let t=1;t<=12;t++){let r=n[t-1],e=new Array(r.length+3).fill(0);r.forEach((i,u)=>{i!==0&&(e[u+1]=e[u+1]+u*i/2+i/(8*(u+1)),e[u+3]=e[u+3]-u*i/2-5*i/(8*(u+3)))}),n.push(e)}return n})();function Dr(n,t){let r=1,e=1;for(let i=1;i<gr.length&&(e/=n,!(e<1e-20));i++){let u=gr[i],o=0;for(let s=u.length-1;s>=0;s--)o=o*t+u[s];r+=o*e}return r}function Ln(n,t,r,e){let i=t/2-1,u=_t(n,r),o=Math.hypot(i,u),s=o+i,a=e??(n>1e307?2*Zt(I(I(k(r/2,t/2),[-1,0]),[-n/2,0])):Zt(I(I(k(r,t),[-2,0]),[-n,0]))),f=n+u*(u/s),c=f<1/0?-(n/f)*(a/s):-(a/2)/(s/2+r/2),h=Math.log(Dr(i,i/o)),N=c>-.5?ct(c):Math.log(n)-Math.log(s)-c,m=-Math.LN2-r/2*c*c+i*N-yn-.5*Math.log(o)+h;return{r:n/s,e:c,R:o,ls:h,logf:m}}function _r(n,t,r,e,i){let u=t/2-1,{r:o,e:s,R:a,ls:f,logf:c}=Ln(n,t,r,i),h=g=>-(s+g)*(r+u/(o+g))+r/(2*(a+r*g)),N=h(0)<=0,m=N?1:-1,M=g=>{let v=m*g,O=a+r*v,F=Math.exp(-(r/2)*v*(v+2*s)-u*v*s/o+u*ct(v/o)+.5*Math.log1p(r*v/a)+Math.log(Dr(u,u/O))-f);return Number.isNaN(F)?0:F},l=g=>-m*h(m*g),d=N?1/0:o,y=1/(Math.abs(l(0))+Math.hypot(Math.sqrt(r),Math.sqrt(u)/o)),L=0,b=0,p=pt();for(let g=0;g<200&&L<d;g++){let v=Math.min(L+y,d);b+=ut(M,L,v,b,0,p);let O=l(v);if(O>0&&M(v)<=1e-17*O*b)break;L=v,y*=2}let E=c+Math.LN2+Math.log(a)+Math.log(b),D=Math.exp(E);return N!==e?{lin:D,log:E}:{lin:1-D,log:Math.log1p(-D)}}function nt(n,t,r,e){return Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)?NaN:In(t,r)?r===0?P(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:yt(r/2,n/t)?P(n,t/2,2,e):Dt(n,t,r,e):NaN}function Zt(n){return n[0]+n[1]}function Ar(n,t,r,e){let i=Math.abs(t)<700?n*Math.exp(t):Math.exp(Math.log(n)+t);if(!(i>0&&i<1/0)||!In(r,e)||e===0)return nt(i,r,e,!0);let u=gn(r,_t(i,e));if(u==="hankel")return kr(i,r,e,!0,I(pn(n,e),[Math.sqrt(n)*Math.expm1(t/2),0]));if(u==="debye"){let o=I(I(k(e,r),[-2,0]),[-n,0]);return Ln(i,r,e,Zt(I(o,[-n*Math.expm1(t),0]))).logf}return Dt(i,r,e,!0)}function Er(n,t,r,e,i){let u=Math.abs(r)<700?t*Math.exp(r):Math.exp(Math.log(t)+r);if(!(u>0))return e?i?-1/0:0:i?0:1;if(u===1/0)return e?i?0:1:i?-1/0:0;let o=I(I(k(2*n,-2),[-2*t,0]),[-2*t*Math.expm1(r),0]),s=_r(2*u,2*n,0,e,Zt(o));return i?s.log:s.lin}function Wt(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(!In(t,r))return NaN;if(n<0)return U(e,i);if(n===0){if(t>0)return U(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)}if(r===0)return n===1/0?S(e,i):W(t/2,Math.max(n/2,Number.MIN_VALUE),e,i);if(n===1/0)return S(e,i);let u=bn(xe(n,t,r),e,i);return u!==void 0?u:Lr(n,t,r,e,i)}var ve=-746;function bn(n,t,r){return n===void 0?void 0:n==="lower"===t?r?void 0:0:r?0:1}function xe(n,t,r){let[e,i]=I(k(r,t),[-n,0]),u=e+i,o=Math.hypot(t,2*Math.sqrt(n)*Math.sqrt(r)),s=Math.abs(u)/(2*n+4*n*(r/(o+t)));if(!(s>0)||!Number.isFinite(s))return;let a=u>0?1:-1;if((s<=.25?-2*n*s*s-t/2*ct(2*a*s):a>0?s*n-t/2*(Math.LN2+Math.log(s+.5))-r/(2+1/s):-s*n-t/2*Math.log1p(-2*s)+r*s/(1-2*s))<ve)return u>0?"lower":"upper"}function Yt(n,t,r,e,i){let u=Math.abs(t-r)/Math.max(1,Math.abs(r));return u<=1e-15||u<=1e-9&&i(n)&&!i(n*(1-1e-14))?n:e()}function jt(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 u=G(n,0,1/0,e,i);if(u!==void 0)return u;if(!Number.isFinite(r))return i&&Math.exp(n)===1?e?1/0:0:NaN;if(r===0)return it(n,t/2,2,e,i);let{lower:o,logTarget:s,linearTarget:a}=$(n,e,i),f=ke(t,r),c=Lr(Number.MIN_VALUE,t,r,o,!0);if(o?c>=s:c<=s)return 0;let h=(t+2*r)/(t+r),N=(t+r)*((t+r)/(t+2*r)),m;if(N>1e5){let p=2/(9*N);m=h*N*(1-p+T(s,{lowerTail:o,logP:!0})*Math.sqrt(p))**3}else m=h*it(s,N/2,2,o,!0);(!(m>0)||!Number.isFinite(m))&&(m=t+r);let M=p=>o?f(p,!0).log>=s:f(p,!1).log<=s,d=Math.sqrt(2*(t+2*r))<1e-10*(t+r)?gt(m,Number.MAX_VALUE,M):void 0;if(d!==void 0)return d;let y=0,L=Math.max(m,t+r,1);for(let p=0;p<2e3&&!M(L);p++)y=L,L*=2;let b=J({logTarget:s,...a!==void 0&&{linearTarget:a},lower:o,cdf:(p,E)=>f(p,E).lin,cdfLog:(p,E)=>f(p,E).log,pdfLog:p=>Dt(p,t,r,!0),x0:m<L?m:L*(1-2**-26),lo:0,hi:L,positive:!0,maxIter:60});return Yt(b,f(b,o).log,s,()=>Nt(b,y,L,M),M)}function Br(n,t,r,e){let i=k(n,t),u=Math.log2(r[0])+Math.log2(Math.min(1,n+t)),o=u<-830?Math.ceil((-830-u)/500):0,s=r;for(let a=0;a<o;a++)s=[s[0]*2**500,s[1]*2**500];return{ratioK:-o,cdf:(a,f,c)=>ht(n+a,t,r,e,f,c),inc:(a,f)=>{let[c,h]=xr(n,t,a,r);if(!vr(c,t,r,e)){let m=qr(c,t,r,e),M=(typeof m=="number"?m:m[0]+m[1])+h;return f?M:Math.exp(M)}let N=t/(c+t);return f?w(c,t,r,e,!0)+Math.log(N)+h:w(c,t,r,e,!1)*N*(1+h)},ratio:a=>B(R(s,I(i,[a-1,0])),k(n,a)),incLogDD:a=>{let[f,c]=xr(n,t,a,r);if(!vr(f,t,r,e)){let m=qr(f,t,r,e);return typeof m=="number"?m+c:I(m,[c,0])}let{e:h,logDenom:N}=xt(f,t,r,e);return I([-h[0],-h[1]],[-.5*N+Math.log(t/(f+t))+c,0])}}}function vr(n,t,r,e){return r[0]>1e-305&&e[0]>1e-305&&n>1e-10&&t>1e-10}function xr(n,t,r,e){let[i,u]=k(n,r);return u===0?[i,0]:[i,u*(Math.log(e[0])+e[1]/e[0]+lt(i+t)-lt(i+1))]}function qr(n,t,r,e){if(!(r[0]>0&&e[0]>0))return-1/0;let i=I(tn(A(r),n),tn(A(e),t));return n<1&&t<1?I(i,[-(V(n)+V(t)-V(n+t)+Math.log1p(n/t)),0]):I(I(i,et(Zn(n,t))),[-Math.log(n),0])}function Dn(n){return n<=.5?[[n,0],k(1,-n)]:[k(1,-(1-n)),[1-n,0]]}function _n(n,t,r,e,i,u,o,s=An(e,i)){let a=zt(n,t,r);if(a!=="mixture"){let c=qe(n,t,r,e,i);return c!==void 0?u?o?c:Math.exp(c):o?Math.log1p(-Math.exp(c)):-Math.expm1(c):Be(a,n,t,r,s,u,o)}let f=Kt(r/2,Br(n,t,e,i),u,e[0]<(n+r/2)/(n+r/2+t));return o?f.log:f.lin}function qe(n,t,r,e,i){let u=r/2,o=e[0]*Math.max(1,(n+t)/(n+1));if(n>1e15||t>1e15)return;if(u*o>100)return o<=1e-16?-u+ht(n,t,e,i,!0,!0):void 0;let s=Math.log(u),a=-1/0,f=[];for(let h=0;h<1e3;h++){let N=h*s-V(h)+ht(n+h,t,e,i,!0,!0);if(f.push(N),N>a)a=N;else if(N<a+Se&&h>u*o)break}let c=0;for(let h of f)c+=Math.exp(h-a);return-u+a+Math.log(c)}var Se=Math.log(1e-18);function Cr(n,t,r,e,i,u,o,s=An(e,i)){let a=zt(n,t,r);if(a!=="mixture"){let M=R(e,i),l=i[0]>1e-300?Math.log(M[0]+M[1]):Math.log(e[0]+e[1])+s.l1mx,d=Ge(a,n,t,r,e,s)+l-Math.log(u);return o?d:Math.exp(d)}let f=r/2,c=e[0],h=f*c,N=n-1-h,m=(-N+Math.sqrt(Math.max(0,N*N+4*h*(n+t-1))))/2;return Qt(f,Br(n,t,e,i),M=>n+M,m,u,o)}var Re=1e6;function zt(n,t,r){let e=r/2,i=n+e+10*Math.sqrt(e)+10;return t>1e20*i*i?"chisq":2*Math.sqrt(n+r)*(40*Math.sqrt(t)+750)<1e-4*(2*n+r)?"gamma":40*(2*n+r)/(2*Math.sqrt(n+r))+750<1e-5*Math.sqrt(t)?"w":e>Re||n>1e15||t>1e15?"integral":"mixture"}function Ue(n,t){return n[0]<=.5?-Math.log1p(-(n[0]+n[1])):-(Math.log(t[0])+t[1]/t[0])}function Oe(n,t){let r=B(t,n);return r[0]+r[1]}function An(n,t){let r=Oe(n,t),e=r>1e-300&&r<1e300?Math.log(r):Math.log(t[0])-Math.log(n[0]);return{k:r,lk:e,l1mx:-Ue(n,t)}}function H(n,t){return t.k>1e-300&&t.k<1e300?n*t.k:Math.exp(Math.log(n)+t.lk)}function Fn(n,t,r=0,e=Math.log(n)){let i=e+r,u=r===0?n:Math.exp(i);if(t>1e4){let o=(n-t+n*Math.expm1(r))/t;return t*ct(o)-i+.5*Math.log(t/(2*Math.PI))-1/(12*t)+1/(360*t*t*t)}return t<1e-10?Math.log(t)+(t-1)*i-u-V(t):!(u>1e-300)||u>1e300*t||t>1e300*u?(t-1)*i-u-Gn(t):P(u,t,1,!0)}function Gr(n,t,r,e,i=0,u=Math.log(t)){let o=u+i,s=i===0?t:Math.exp(o);if(s<1e-300){let h=n*o-V(n);return r?e?h:Math.exp(h):e?h>-Math.LN2?Math.log(-Math.expm1(h)):Math.log1p(-Math.exp(h)):-Math.expm1(h)}if(n>1e4)return Er(n,t,i,r,e);let a=W(n,s,!0,!1),f=a<=.5,c=f?a:W(n,s,!1,!1);return f!==r?e?Math.log1p(-c):1-c:e?c>1e-300?Math.log(c):W(n,s,r,!0):c}function Be(n,t,r,e,i,u,o){if(n==="chisq")return Wt(-2*r*i.l1mx,2*t,e,u,o);let s=Ce(t,r,e,i);if(s!==void 0)return u?o?s:0:o?-0:1;let a=n==="gamma"?Vr(t,r,e,i,!u,o):n==="w"?Ve(t,r,e,i,u,o):void 0;if(a!==void 0)return a;let f=Sr(t,r,e,i.lk,u);if(f>-Math.LN2){let c=Math.exp(Sr(t,r,e,i.lk,!u));if(c<=.5)return o?Math.log1p(-c):1-c}return o?f:Math.exp(f)}function Ce(n,t,r,e){let i=r/2;if(!(i>1e18))return;let u=e.l1mx>-1?i*Math.exp(e.l1mx):H(i,e)/(1+e.k);return u>=1e17*(n+t+1)*(Math.log(i)+50)?-u:void 0}function Sr(n,t,r,e,i){let u=e-Math.LN2;return Kr(n,r,(s,a)=>Gr(t,Math.exp(s+u),!i,!0,a,s+u)+s+a,t,i?n:n+t)}function Ge(n,t,r,e,i,u){let o=i[0]+i[1];if(n==="chisq")return nt(-2*r*u.l1mx,2*t,e,!0)+Math.log(2*r)-u.l1mx;if(n==="gamma"){let f=H(t+e/2,u),c=r-1-f,h=(t+e)/(t+e/2)/(t+e/2)*(c*c-(r-1)+2*c);if(Math.abs(h)<.001)return Fn(f,r)+Math.log(t+e/2)+Math.log1p(h/2)-2*Math.log(o)}if(n==="w"){let f=H(2*r,{k:1/u.k,lk:-u.lk,l1mx:NaN});return nt(f,2*t,e,!0)+Math.log(f)-u.lk-2*Math.log(o)}let s=u.lk-Math.LN2;return Kr(t,e,(f,c)=>Fn(Math.exp(f+s),r,c,f+s)-Math.LN2+2*(f+c),r,t+r)-2*Math.log(o)}function Vr(n,t,r,e,i,u){let o=H(n+r/2,e),s=Gr(t,o,i,u),a=(i?o<t:o>t)&&Math.abs(o-t)>40*Math.sqrt(t)+750;if(u){let D=i?t:t-1,g=a?D/o-1:1,v=H(H(n+r,e),e);if(v*Math.max(1,g*g)/2<=1e-16*Math.abs(s))return s;let O=H(H(H(2*n+3*r,e),e),e);if(a&&O*Math.abs(g*g*g)/6<=1e-16*Math.abs(s))return s+v/2*(g*g-D/o/o)}let f=2*Math.sqrt(n+r)/(2*n+r);if(a&&!(f*Math.abs(o-t)<1e-4)){let D=u?void 0:Vr(n,t,r,e,i,!0);return D===void 0?void 0:Math.exp(D)}let c=Fn(o,t)+Math.log(o),h=u?Math.exp(c-s):s>0?Math.exp(c)/s:0;if(!(o>0&&o<1/0)||h===0)return s;let N=n+r/2,[m,M]=[n/N,r/N],l=(m+M)/N,d=(2*m+3*M)/N/N,y=6*(m+2*M)/N/N/N,L=t-1-o,b=t-1,p=l/2*L+d/6*(L*L-b)+(y+3*l*l)/24*(L*L*L-3*L*b+2*b),E=(i?1:-1)*h*p;if(Math.abs(E)<.001)return u?s+Math.log1p(E):s*(1+E)}function Ve(n,t,r,e,i,u){let o=H(2*t,{k:1/e.k,lk:-e.lk,l1mx:NaN}),s=Wt(o,2*n,r,i,u);if(!(o>0&&o<1/0))return s;let a=1e-6,f=(nt(o*(1+a),2*n,r,!0)-nt(o*(1-a),2*n,r,!0))/(2*a*o),c=nt(o,2*n,r,!0),h=u?Math.exp(c-s):s>0?Math.exp(c)/s:0,N=(i?1:-1)*H(o,{k:1/e.k,lk:-e.lk,l1mx:NaN})*h*f;if(Math.abs(N)<.001)return u?s+Math.log1p(N):s*(1+N)}var Rr=-744,Ur=709.78;function Kr(n,t,r,e,i){let u=(F,x)=>{let C=Ar(Math.exp(F),x,2*n,t)+r(F,x);return Number.isNaN(C)||C===1/0?-1/0:C},o=F=>u(F,0),s=Math.log(2*n+t),a=(3-Math.sqrt(5))/2,f=Rr,c=Ur,h=f+a*(c-f),N=c-a*(c-f),m=o(h),M=o(N),l=()=>(Math.abs(m)>1e18?1e-8:1e-14)*Math.max(1,Math.abs(h));for(let F=0;F<300&&c-f>l();F++)m>M||m===M&&N>s?(c=N,N=h,M=m,h=f+a*(c-f),m=o(h)):(f=h,h=N,m=M,N=c-a*(c-f),M=o(N));let[d,y]=m>=M?[h,m]:[N,M];if(!Number.isFinite(y)||Math.abs(y)>1e18)return y;let L=F=>{let x=Math.exp(u(d,F)-y);return Number.isFinite(x)?x:0},b=2*n+t,p=Math.min(.1,2*Math.sqrt(n+t)/b,1/Math.sqrt(e)),E=0;for(let F=0;F<30;F++)if(E=2*y-u(d,p)-u(d,-p),E<.01&&p<1)p*=10;else if(E>100)p/=10;else break;let D=E>0&&Number.isFinite(E)?p/Math.sqrt(E):p,g=0,v=pt(Math.max(1e-15,4*Number.EPSILON*Math.abs(y)),300),O;for(let F of[1,-1]){let x=F>0?Ur-d:d-Rr,C=0,Rn=D,Un=y;for(let On=0;On<200&&C<x;On++){let rt=Math.min(C+Rn,x);g+=ut(Pt=>L(F*Pt),C,rt,g,0,v);let at=u(d,F*rt),Bn=(Un-at)/(rt-C),Cn=Bn>0?Math.exp(at-y)/Bn:1/0;if((F>0||i>.5)&&Cn<=1e-17*g)break;if(F<0&&rt<x){if(O??=u(d,-x),Cn<=1e-17*g&&Math.exp(O-y)/i<=1e-17*g)break;let Pt=at-i*(x-rt);if(Number.isFinite(O)&&Math.abs(O-Pt)<=1e-9*Math.max(1,Math.abs(O))){g+=Math.exp(at-y)/i;break}}rt===x&&F<0&&(g+=Math.exp(at-y)/i),Un=at,C=rt,Rn*=2}}return Number.isFinite(g)?y+Math.log(g):-1/0}function En(n,t,r){return n>0&&t>0&&Number.isFinite(n)&&Number.isFinite(t)&&r>=0&&Number.isFinite(r)}function Qr(n,t,r,e,i){let[u,o]=Dn(n),s=R(u,o);return Cr(t,r,e,u,o,s[0]+s[1],i)}function Nr(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(e))return NaN;if(!En(t,r,e))return NaN;if(e===0)return kt(n,t,r,i);if(n<0||n>1)return i?-1/0:0;let u=e/2;return n===0?t>1?i?-1/0:0:t<1?1/0:i?Math.log(r)-u:r*Math.exp(-u):n===1?r>1?i?-1/0:0:r<1?1/0:i?Math.log(t+u):t+u:yt(u,n*((t+r)/t))?kt(n,t,r,i):Qr(n,t,r,e,i)}function Mr(n,t,r,e,i,u){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(e))return NaN;if(n<=0)return U(i,u);if(n>=1)return S(i,u);if(!En(t,r,e))return NaN;if(e===0)return Mn(n,t,r,i,u);let[o,s]=Dn(n);return _n(t,r,e,o,s,i,u)}function Xr(n,t,r){return Math.max(2*Math.sqrt(n+r)/(2*n+r),1/Math.sqrt(t))}function Hr(n){let t=new Map;return(r,e,i)=>{let u=`${r} ${e} ${i}`,o=t.get(u);return o===void 0&&(o=n(r,e,i),t.set(u,o)),o}}function Mt(n){return n>=1e-10&&n<=1e15}function mr(n,t,r,e,i,u){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 o=G(n,0,1,i,u);if(o!==void 0)return o;if(!En(t,r,e))return NaN;if(e===0)return Xt(n,t,r,i,u);let{lower:s,logTarget:a,linearTarget:f}=$(n,i,u),c=Hr((b,p,E)=>{let[D,g]=Dn(b);return _n(t,r,e,D,g,p,E)}),h=c(Number.MIN_VALUE,s,!0);if(s?h>=a:h<=a)return 0;let N=c(1-Number.EPSILON/2,s,!0);if(s?N<a:N>a)return 1;let M=zt(t,r,e)==="mixture"&&Mt(t)&&Mt(r)?Xt(a,t+e/2,r,s,!0):(t+e/2)/(t+e/2+r);M>0&&M<1||(M=.5);let l=b=>s?c(b,!0,!0)>=a:c(b,!1,!0)<=a,d=Xr(t,r,e)<1e-10?gt(M,1-Number.EPSILON/2,l):void 0;if(d!==void 0)return d;let y=J({logTarget:a,...f!==void 0&&{linearTarget:f},lower:s,cdf:(b,p)=>c(b,p,!1),cdfLog:(b,p)=>c(b,p,!0),pdfLog:b=>Qr(b,t,r,e,!0),x0:M,lo:0,hi:1,positive:!0,maxIter:60}),L=()=>Nt(y,Number.MIN_VALUE,1-Number.EPSILON/2,l);return Yt(y,c(y,s,!0),a,L,l)}function Zr(n,t,r){let e=Q(t,n);if(e[0]<1e-290){let u=R(B([t,0],[r,0]),[n,0]),o=I(u,[1,0]);return[B(u,o),B([1,0],o)]}if(Number.isFinite(e[0])&&Number.isFinite(e[1])&&Math.abs(e[0])<1e290){let u=I(e,[r,0]);return[B(e,u),B([r,0],u)]}let i=r/t/n;return[k(1,-i),[i,0]]}function Wr(n,t,r,e,i){let u=An(e,i);if(!(u.k<1e-300))return u;let o=r/t/n,s=Math.log(r)-Math.log(t)-Math.log(n);return{k:o,lk:s,l1mx:s-Math.log1p(o)}}function Yr(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))-Y(s,r/2)-Math.log(n);return i?a:Math.exp(a)}let[u,o]=Zr(n,t,r);return Cr(t/2,r/2,e,u,o,n,i,Wr(n,t,r,u,o))}function jr(n,t,r,e,i,u){let o=t/2,s=-e/2+o*(Math.log(t/r)+Math.log(n))-Math.log(o)-Y(o,r/2);return i?u?s:Math.exp(s):u?Math.log1p(-Math.exp(s)):-Math.expm1(s)}function $r(n,t,r,e,i,u){if(t/r*n<1e-306)return jr(n,t,r,e,i,u);let[o,s]=Zr(n,t,r);return _n(t/2,r/2,e,o,s,i,u,Wr(n,t,r,o,s))}function Jr(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:$t(n,t,r,i);if(r===1/0){let u=nt(n*t,t,e,i);return i?u+Math.log(t):u*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||yt(e/2,(1+r/t)/(1+r/(t*n)))?$t(n,t,r,i):Yr(n,t,r,e,i)}function zr(n,t,r,e,i,u){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;if(t===1/0&&r===1/0)return NaN;if(n<=0)return U(i,u);if(n===1/0)return S(i,u);if(t===1/0)return NaN;if(r===1/0)return Wt(n*t,t,e,i,u);if(t/r*n<1e-306)return jr(n,t,r,e,i,u);if(e===0)return kn(n,t,r,i,u);let o=bn(Ke(n,t,r,e),i,u);return o!==void 0?o:$r(n,t,r,e,i,u)}var Or=-746;function Ke(n,t,r,e){if(Jt(n,t,r,e,!0)<Or)return"lower";if(Jt(n,t,r,e,!1)<Or)return"upper"}function Jt(n,t,r,e,i){let u=n*t<1/0?n*t/r:n*(t/r);if(!(u>0&&Number.isFinite(u)))return NaN;let o=i?f=>-(t/2)*Math.log1p(2*f)-e*f/(1+2*f)-r/2*Math.log1p(-2*(u*f)):f=>-(t/2)*Math.log1p(-2*f)+e*f/(1-2*f)-r/2*Math.log1p(2*(u*f)),s=i?1/(2*u):.5,a=1/0;for(let f=1;f<=60;f++){let c=Math.min(o(s*2**-f),o(s*(1-2**-f)));c<a&&(a=c)}return a}function Tr(n,t,r,e,i,u){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 o=G(n,0,1/0,i,u);return o!==void 0?o:t===1/0?NaN:r===1/0?jt(n,t,e,i,u)/t:e===0?At(n,t,r,i,u):Qe(n,t,r,e,i,u)}function Qe(n,t,r,e,i,u){let{lower:o,logTarget:s,linearTarget:a}=$(n,i,u),f=Hr((D,g,v)=>$r(D,t,r,e,g,v));if(Jt(Number.MAX_VALUE,t,r,e,!0)<(o?s:-Math.LN2))return 1/0;if(Jt(Number.MIN_VALUE,t,r,e,!1)<(o?-Math.LN2:s))return 0;let c=-s;if(r>1e40*(c+1)&&r>1e20*(t+2*c+1e3+4*Math.sqrt((t+e)*(c+1))))return jt(n,t,e,i,u)/t;let h=f(Number.MIN_VALUE,o,!0);if(o?h>=s:h<=s)return 0;let N=f(Number.MAX_VALUE,o,!0);if(o?N<s:N>s)return 1/0;let m=(t+e)*((t+e)/(t+2*e)),M=zt(t/2,r/2,e)==="mixture"&&Mt(t)&&Mt(r),l=!M&&Mt(r)?At(s,1/0,r,o,!0):1,d=(t+e)/t*(M?At(s,m,r,o,!0):l),y=r>1e15&&Mt(t);y&&(d=jt(s,t,e,o,!0)/t),(!(d>0)||!Number.isFinite(d))&&(d=1);let L=D=>o?f(D,!0,!0)>=s:f(D,!1,!0)<=s,b=Xr(t/2,r/2,e)<1e-10?gt(d,Number.MAX_VALUE,L):void 0;if(b!==void 0)return b;let p=J({logTarget:s,...a!==void 0&&{linearTarget:a},lower:o,cdf:(D,g)=>f(D,g,!1),cdfLog:(D,g)=>f(D,g,!0),pdfLog:D=>Yr(D,t,r,e,!0),x0:d,lo:0,hi:1/0,positive:!0,maxIter:60,...y&&{residualTolerance:1e-12*Math.max(1,-s)}}),E=()=>Nt(p,Number.MIN_VALUE,Number.MAX_VALUE,L);return Yt(p,f(p,o,!0),s,E,L)}var Tt=Math.log(22250738585072014e-324);function vn(n,t,r,e){let i=n/2,u=t/2,o=Math.min(i,u),s=o<rn?I([Math.log(o)-Math.log1p(o/Math.max(i,u)),0],Wn(i,u)):[-Y(i,u),0];return I(I(I(vt(A([n,0]),A([t,0])),R(r,k(i,-1))),R(e,k(u,1))),s)}function xn(n,t){return t?n[0]+n[1]:Math.exp(n[0])*(1+n[1])}function qn(n,t,r){let e=4149515568880993e165,i=n>1e290?Q(t*e,n/e):t>1e290?Q(t/e,n*e):Q(t,n);if(!(Number.isFinite(i[0])&&Number.isFinite(i[1])&&Math.abs(i[0])<1e290))return;let u=r;n>0&&i[0]<1e-290&&r<1e127&&(i=t<n?Q(t*e,n):Q(t,n*e),u=r*e);let o=I(i,[u,0]);return[B(i,o),B([u,0],o)]}function Pr(n,t,r,e){if(n>0&&n<1/0&&Math.abs(Math.log(t)+Math.log(n)-Math.log(r))>700){let h=I(vt(A([t,0]),A([r,0])),A([n,0]));if(h[0]<Tt)return xn(vn(t,r,h,[-Math.exp(h[0]),0]),e);if(-h[0]<Tt)return xn(vn(t,r,[-Math.exp(-h[0]),0],et(h)),e)}let i=qn(n,t,r),u,o;if(i!==void 0?[u,o]=i:(o=[r/t/n,0],u=[1,-o[0]]),Math.min(t,r)/2<rn)return xn(vn(t,r,A(u),A(o)),e);let s=u[0],a=o[0];if(t>=2){let h=t*a/2,N=w((t-2)/2,r/2,u,o,e);return e?Math.log(h)+N:h*N}let f=t/(r+t*n)*t*r/(2*(t+r)*s),c=w(t/2,r/2,u,o,e);return e?Math.log(f)+c:f*c}function $t(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 q(e);if(n===0)return t>2?q(e):t===2?e?0:1:1/0;if(!Number.isFinite(t)&&!Number.isFinite(r))return n===1?1/0:q(e);if(!Number.isFinite(r))return P(n,t/2,2/t,e);if(!Number.isFinite(t)){let i=P(1/n,r/2,2/r,e);return e?i-2*Math.log(n):i/(n*n)}return Number.isFinite(n)?Pr(n,t,r,e):t<2?NaN:q(e)}function te(n,t,r,e,i){if(!(n>0&&n<1/0)||Math.abs(Math.log(t)+Math.log(n)-Math.log(r))<700)return;let u=vt(I(A([t,0]),A([n,0])),A([r,0]));if(u[0]<Tt)return en(t/2,r/2,Math.exp(u[0]),u,e,i);if(-u[0]<Tt)return en(r/2,t/2,Math.exp(-u[0]),et(u),!e,i)}function mt(n,t,r,e,i){if(n===1/0)return e===i?0:e?1:-1/0;let u=te(n,t,r,e,i);if(u!==void 0)return i?u[0]:u[1];let o=qn(n,t,r);if(o!==void 0)return ht(t/2,r/2,o[0],o[1],e,i);let s=r/t/n;return K(t/2,r/2,1-s,s,e,i)}function Xe(n,t,r,e){let i=mn(n/2,t/2,r,e);if(i===void 0)return 1;let u=t*i/(n*(1-i));return u>0&&Number.isFinite(u)?u:1}function He(n,t,r,e){if(n===1/0)return e?[0,1]:[-1/0,0];let i=te(n,t,r,e,!0);if(i!==void 0)return i;let u=qn(n,t,r);if(u!==void 0)return Yn(t/2,r/2,u[0],u[1],e);let o=r/t/n;return St(t/2,r/2,1-o,o,e)}var Et=22250738585072014e-324;function Ze(n,t,r,e){let i=n*t;return i<Et&&t>Et?qt(n,t/2,2/t,r,e):qt(i,t/2,2,r,e)}function wr(n,t,r,e){let i=it(n,t/2,2,r,e);return(i<Et||i/t<Et)&&t>Et?it(n,t/2,2/t,r,e):i/t}function kn(n,t,r,e,i){return Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r)?NaN:t<=0||r<=0?NaN:n<=0?U(e,i):n===1/0?S(e,i):!Number.isFinite(t)&&!Number.isFinite(r)?n===1?i?-Math.LN2:.5:n<1?U(e,i):S(e,i):Number.isFinite(r)?Number.isFinite(t)?mt(n,t,r,e,i):qt(r/n,r/2,2,!e,i):Ze(n,t,e,i)}function At(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 u=G(n,0,1/0,e,i);if(u!==void 0)return u;if(!Number.isFinite(t)&&!Number.isFinite(r))return 1;if(!Number.isFinite(r))return wr(n,t,e,i);if(!Number.isFinite(t))return r/it(n,r/2,2,!e,i);let{lower:o,logTarget:s,linearTarget:a}=$(n,e,i);return r>1e20*(t-2*s+1e3)**2?wr(n,t,e,i):o&&(s+Math.log(t/2)+Y(t/2,r/2))/(t/2)+Math.log(r/t)<-746?0:!o&&-(s+Math.log(r/2)+Y(t/2,r/2))/(r/2)+Math.log(r/t)>709.78&&mt(Number.MAX_VALUE,t,r,!1,!0)>s||o&&r<1&&mt(Number.MAX_VALUE,t,r,!0,!0)<s?1/0:!o&&t<1&&mt(Number.MIN_VALUE,t,r,!1,!0)<s?0:J({logTarget:s,...a!==void 0&&{linearTarget:a},lower:o,cdf:(f,c)=>mt(f,t,r,c,!1),cdfLog:(f,c)=>mt(f,t,r,c,!0),cdfBoth:(f,c)=>He(f,t,r,c),pdfLog:f=>Pr(f,t,r,!0),dlogPdf:f=>(t/2-1)/f-(t+r)/2*(t/(r+t*f)),x0:Xe(t,r,o,s),lo:0,hi:1/0,positive:!0})}function yu(n,t,r,e={}){let{log:i=!1,ncp:u}=e;return u!==void 0?_(n,o=>Jr(o,t,r,u,i)):_(n,o=>$t(o,t,r,i))}function Lu(n,t,r,e={}){let{lowerTail:i=!0,logP:u=!1,ncp:o}=e;return o!==void 0?_(n,s=>zr(s,t,r,o,i,u)):_(n,s=>kn(s,t,r,i,u))}function bu(n,t,r,e={}){let{lowerTail:i=!0,logP:u=!1,ncp:o}=e;return o!==void 0?_(n,s=>Tr(s,t,r,o,i,u)):_(n,s=>At(s,t,r,i,u))}function Sn(n,t){return Ut(n)||n<0||!Number.isFinite(n)||t<0||t>1}function We(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(t===1/0&&r>=0&&r<=1)return r===0&&n===0?e?0:1:q(e);if(Sn(t,r))return NaN;if(Ut(n)||n<0||!Number.isFinite(n))return q(e);let i=Math.round(n),u=Math.round(t);if(i>u)return q(e);let o=r<=.5?[r,0]:k(1,-(1-r)),s=r<=.5?k(1,-r):[1-r,0];return w(i,u-i,o,s,e)}function ne(n,t,r,e,i){return K(n+1,t-n,r,1-r,!e,i)}function Ye(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(Sn(t,r))return NaN;let u=Math.round(t);if(n<0)return U(e,i);let o=Math.floor(n+1e-7);return u<=o?S(e,i):r===0?S(e,i):r===1?U(e,i):ne(o,u,r,e,i)}function je(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 u=G(n,0,$e(t),e,i);if(u!==void 0)return u;if(Sn(t,r))return NaN;let o=Math.round(t);if(r===0||o===0)return 0;if(r===1)return o;let s=1-r,a=o*r,f=Math.sqrt(o*r*s),c=(s-r)/f,h=T(n,{lowerTail:e,logP:i}),N=a+f*(h+c*(h*h-1)/6);return Rt({p:n,lowerTail:e,logP:i,cdf:(m,M,l)=>m>=o?S(M,l):ne(m,o,r,M,l),y0:Number.isFinite(N)?N:a,lo:0,hi:o})}function Su(n,t,r,e={}){let i=e.log??!1;return _(n,u=>We(u,t,r,i))}function Ru(n,t,r,e={}){let{lowerTail:i=!0,logP:u=!1}=e;return _(n,o=>Ye(o,t,r,i,u))}function Uu(n,t,r,e={}){let{lowerTail:i=!0,logP:u=!1}=e;return _(n,o=>je(o,t,r,i,u))}function $e(n){let t=Math.round(n);return Math.abs(n%1)===.5&&t%2!==0?t-1:t}var ft=1.1447298858494002,Je=2**-1022;function re(n){let t=n<9332636185032189e-317?600:0,r=Math.floor(Math.log2(n*2**t));return[n*2**t*2**-r,r-t]}function ze(n,t,r,e){if(r<=1)return e?-(ft+Math.log(t))-Math.log1p(r*r):1/(Math.PI*(1+r*r))/t;let i=Math.abs(n),u=t/i;if(e)return-ft+Math.log(t)-2*Math.log(i)-Math.log1p(u*u);if(i===1/0)return 0;let[o,s]=re(t),[a,f]=re(i),c=s-2*f,h=Math.trunc(c/2);return o/(a*a)/(Math.PI*(1+u*u))*2**h*2**(c-h)}function ie(n,t){if(!(Number.isFinite(n-t)||!Number.isFinite(n)||!Number.isFinite(t)))return Math.abs(n/2-t/2)}function Te(n,t,r,e){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(!(r>0))return NaN;let i=(n-t)/r;if(Number.isNaN(i))return NaN;let u=ie(n,t);if(u!==void 0){let a=r/u/2;return e?-(ft+Math.log(r))-2*(Math.log(u)+Math.LN2-Math.log(r))-Math.log1p(a*a):a/(Math.PI*r)*(a/(1+a*a))}let o=Math.abs(i);if(r<Je)return ze(n-t,r,o,e);if(o<=1)return e?-(ft+Math.log(r))-Math.log1p(i*i):1/(Math.PI*r*(1+i*i));let s=1/o;return e?-(ft+Math.log(r))-2*Math.log(o)-Math.log1p(s*s):s/(Math.PI*r)*(s/(1+s*s))}function we(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(!(r>0))return NaN;let u=n-t;if(Number.isNaN(u))return NaN;let o=ie(n,t);if(o!==void 0){let c=r/o/2,h=Math.atan(c)/Math.PI;return e===u<0?i?c<1e-150?Math.log(r)-Math.log(o)-Math.LN2-ft:Math.log(h):h:i?Math.log1p(-h):1-h}if(!(Math.abs(u)>r)){let c=u/r,h=.5+Math.atan(e?c:-c)/Math.PI;return i?Math.log(h):h}let s=r/Math.abs(u),a=Math.atan(s)/Math.PI;return e===u<0?i?s<1e-150?Math.log(r)-Math.log(Math.abs(u))-ft:Math.log(a):a:i?Math.log1p(-a):1-a}var Pe=1e-200,ti=-460;function ee(n,t,r){if(!r){let i=n/t;return Number.isFinite(i)?i/Math.PI:n/Math.PI/t}let e=Math.exp(-t/4);return e*n/Math.PI*e*e*e}function wt(n){return n<=.25?-1/Math.tan(Math.PI*n):-Math.tan(Math.PI*(.5-n))}function ni(n,t,r,e,i){if(Number.isNaN(n)||Number.isNaN(t)||Number.isNaN(r))return NaN;if(i?n>0:n<0||n>1)return NaN;if(!(r>0)||!Number.isFinite(r))return r===0?t:NaN;let u;if(i)if(n===0)u=1/0;else if(n===-1/0)u=-1/0;else{if(n<ti)return t+(e?-1:1)*ee(r,n,!0);u=n<-Math.LN2?wt(Math.exp(n)):-wt(-Math.expm1(n))}else if(n===0)u=-1/0;else if(n===1)u=1/0;else{if(n<Pe)return t+(e?-1:1)*ee(r,n,!1);u=n<=.5?wt(n):-wt(1-n)}return Qn(t,r,e?u:-u)}function Gu(n,t={}){let{location:r=0,scale:e=1,log:i=!1}=t;return _(n,u=>Te(u,r,e,i))}function Vu(n,t={}){let{location:r=0,scale:e=1,lowerTail:i=!0,logP:u=!1}=t;return _(n,o=>we(o,r,e,i,u))}function Ku(n,t={}){let{location:r=0,scale:e=1,lowerTail:i=!0,logP:u=!1}=t;return _(n,o=>ni(o,r,e,i,u))}export{nt as a,Wt as b,jt as c,Rt as d,Ut as e,oe as f,se as g,fe as h,ci as i,hi as j,Ni as k,kn as l,At as m,yu as n,Lu as o,bu as p,Mn as q,Xt as r,vi as s,xi as t,qi as u,We as v,Ye as w,Su as x,Ru as y,Uu as z,Te as A,we as B,ni as C,Gu as D,Vu as E,Ku as F};