@numero-uno-jpn/rstats 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/README.ja.md +8 -8
  3. package/README.md +8 -8
  4. package/THIRD_PARTY_NOTICES.md +3 -2
  5. package/dist/chunks/{chunk-WQWZ7FND.js → chunk-4KCSBTR5.js} +2 -2
  6. package/dist/chunks/{chunk-IEOD5GWC.js → chunk-4VRMAYPY.js} +2 -2
  7. package/dist/chunks/{chunk-BQSIBJVX.js → chunk-7IJCUSA5.js} +2 -2
  8. package/dist/chunks/{chunk-WIBKS73G.js → chunk-7KJ24LYK.js} +2 -2
  9. package/dist/chunks/{chunk-3W5NFFAA.js → chunk-DR4GQ7PW.js} +1 -1
  10. package/dist/chunks/{chunk-H7I32ZZE.js → chunk-DTJG2IL2.js} +2 -2
  11. package/dist/chunks/{chunk-BWKHYRM6.js → chunk-EJYCDE4Z.js} +1 -1
  12. package/dist/chunks/{chunk-YG5S5AVP.js → chunk-GGJA3JRO.js} +2 -2
  13. package/dist/chunks/{chunk-4OLDGML4.js → chunk-GJEKNJP7.js} +2 -2
  14. package/dist/chunks/{chunk-4F2IALD4.js → chunk-GRUQRNX7.js} +2 -2
  15. package/dist/chunks/chunk-GYGQUYEP.js +2 -0
  16. package/dist/chunks/{chunk-O2SQMGE3.js → chunk-HRA7PCQT.js} +2 -2
  17. package/dist/chunks/{chunk-63OPBEYO.js → chunk-HUWOSLKE.js} +1 -1
  18. package/dist/chunks/{chunk-6XJBCRBV.js → chunk-HZLSNJQM.js} +2 -2
  19. package/dist/chunks/{chunk-QZK3CCBA.js → chunk-JNWWLNE3.js} +2 -2
  20. package/dist/chunks/{chunk-NSWENS3S.js → chunk-N5BDSMXS.js} +1 -1
  21. package/dist/chunks/{chunk-WWVMVZUL.js → chunk-NDTJ23A6.js} +2 -2
  22. package/dist/chunks/{chunk-CKV4JWW2.js → chunk-OG7UORIX.js} +1 -1
  23. package/dist/chunks/{chunk-UKNDX4BA.js → chunk-QUTJEYDX.js} +2 -2
  24. package/dist/chunks/{chunk-LROMWFAK.js → chunk-U7BRXOUS.js} +2 -2
  25. package/dist/chunks/{chunk-QQX46TCI.js → chunk-UMLMY4XS.js} +2 -2
  26. package/dist/chunks/{chunk-UJ66VQIG.js → chunk-X4J6UJHN.js} +2 -2
  27. package/dist/chunks/{chunk-YHNMBYSW.js → chunk-Y4YWLSWU.js} +2 -2
  28. package/dist/chunks/{chunk-F7YGX7PN.js → chunk-YN5MLKDL.js} +2 -2
  29. package/dist/chunks/{chunk-DCAWMF4K.js → chunk-Z2HGLFZN.js} +2 -2
  30. package/dist/descriptive.js +2 -2
  31. package/dist/distributions/signrank.js +2 -2
  32. package/dist/distributions.js +2 -2
  33. package/dist/entries/tests.d.ts +1 -1
  34. package/dist/htest/ansariTest.js +32 -34
  35. package/dist/htest/cor.d.ts +2 -2
  36. package/dist/htest/cor.js +2 -1
  37. package/dist/htest/core/scoreDistribution.d.ts +39 -0
  38. package/dist/htest/core/scoreDistribution.js +151 -0
  39. package/dist/htest/wilcoxTest.d.ts +23 -8
  40. package/dist/htest/wilcoxTest.js +521 -199
  41. package/dist/linalg/chol.d.ts +3 -3
  42. package/dist/linalg/chol.js +10 -2
  43. package/dist/linalg/qr.js +39 -15
  44. package/dist/linalg.js +2 -2
  45. package/dist/mixed.js +2 -2
  46. package/dist/models/anovaSequential.d.ts +16 -1
  47. package/dist/models/anovaSequential.js +40 -5
  48. package/dist/models/aovStrata.js +21 -4
  49. package/dist/models/glm.d.ts +15 -4
  50. package/dist/models/glm.js +13 -6
  51. package/dist/models/survival.d.ts +4 -1
  52. package/dist/models/survival.js +7 -1
  53. package/dist/numerics.js +2 -2
  54. package/dist/rstats.js +16 -16
  55. package/dist/special.js +2 -2
  56. package/dist/tests.js +13 -13
  57. package/llms.txt +1 -1
  58. package/package.json +1 -1
  59. package/dist/chunks/chunk-KICBQGFN.js +0 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,46 @@ 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
+ ## 1.1.0 - 2026-11-06
11
+
12
+ The reference is now R 4.6.2 (until 1.0.0, R 4.5.2): every fixture was regenerated with `oracle/Dockerfile.r46`
13
+ (R 4.6.2, the same dated package snapshot, Ubuntu 26.04 with OpenBLAS 0.3.32), and the functions whose results R 4.6
14
+ changed follow it, except where R 4.6.2 is wrong (docs/differences-from-r.md). The fixture of `fisherTest` is still R 4.5.2's
15
+ (`fisher.test` is unchanged in R 4.6; its oracle needs nearly all of the Docker VM's memory).
16
+
17
+ ### Changed
18
+
19
+ - `glmRstandard` follows R 4.6: standardized Pearson residuals by default (R 4.6's default type of `rstandard()`), the
20
+ deviance residuals with the new option `type: "deviance"`, divided by sigma sqrt(1 - h).
21
+ - `ansariTest` follows R 4.6: the normal approximation with ties is centred and scaled with the mean and variance of
22
+ the observed scores (p-values, intervals and estimates change; without ties as before), and the warning reads
23
+ "cannot compute exact confidence interval with ties".
24
+ - `moodTest` with ties agrees with R 4.6, which fixed its tie correction of the variance (the values here, the exact
25
+ permutation variance of the averaged scores, are unchanged; the entry in differences-from-r is removed).
26
+ - `corTest` follows R 4.6's text of the Kendall and Spearman warning: "cannot compute exact p-value with ties" (lower
27
+ case).
28
+ - `aovSummary` follows R 4.6's `summary.aov`: the warning "essentially perfect fit for ‘1’: summary may be unreliable"
29
+ where the residual variance is below 1e-30 times mean(f)^2 + var(f) of the fitted values f (also for each stratum of
30
+ a fit with `Error()`).
31
+ - `survfit` follows survival 3.8-12 (with R 4.6): with `confType: "log-log"`, the limits are 1 and 1 (not `NaN`) at the
32
+ times where the estimate is 1.
33
+ - `chol` with `pivot: true` follows R 4.6: when the decomposition stops early (rank deficiency), the trailing submatrix
34
+ of the factor is zeroed, so that `x[pivot, pivot] = t(R) R` holds for positive semi-definite `x`.
35
+ - `qr` with `lapack: true` follows LAPACK 3.12.1 (as R 4.6.2 with OpenBLAS 0.3.32): the reflections are applied in
36
+ 3.12.1's order (dlarf1f), which changes the last bits and the choice among columns tied for the pivot.
37
+ - `wilcoxTest` follows R 4.6: with ties or zero differences the exact test (default for n < 50, zeros counted) is the
38
+ conditional test given the mid-ranks, the signed rank test ranking the zeros with the data (Pratt), instead of the
39
+ normal approximation, and the exact-test warnings are gone; exact intervals report the achieved confidence level
40
+ ((-Inf, Inf) at level 1 where none is reached); the two-sided exact two-sample p-value takes both tails; `correct`
41
+ also takes 0..3 (Edgeworth terms in the normal p-value); the normal interval of the signed rank test is searched on
42
+ the observations, values equal to `mu` included. Two values differ from R 4.6.2, where it is wrong
43
+ (docs/differences-from-r.md): the one-sample conditional interval's lower end (R's is one Walsh average too high)
44
+ and its level, the level of a conditional interval (one or two samples) with an end at the first or last Walsh
45
+ average or difference (R reports tail 0 there), and two-sided normal p-values below 1/64 from the upper tail itself (R's 2 (1 - F) gives 0 for
46
+ `1:300`). The conditional distribution has time and memory limits (RangeError suggesting `exact: false`).
47
+ - `pairwiseWilcoxTest` follows R 4.6's `wilcox.test` through `wilcoxTest`: exact p-values with ties and zeros, no
48
+ ties warnings, and `correct` 0..3.
49
+
10
50
  ## 1.0.0 - 2026-11-05
11
51
 
12
52
  The first stable version: from 1.0.0 the public API follows Semantic Versioning (see Versioning in the README), so
package/README.ja.md CHANGED
@@ -7,7 +7,7 @@
7
7
  JavaScript とブラウザで使える、R と互換の統計関数のライブラリです。TypeScript で書いています。
8
8
  [ブラウザで試す](https://numero-uno-jpn.github.io/rStats.js/demo/) (すべての関数を、R が出す値と並べて試せます)。
9
9
 
10
- - **R と同じ数値を返します。** 関数名・既定値・結果は R に合わせています。すべての関数を R 4.5.2 と
10
+ - **R と同じ数値を返します。** 関数名・既定値・結果は R に合わせています。すべての関数を R 4.6.2 と
11
11
  比べてテストしています (分布関数は相対誤差 1e-14)。R 自身が不正確なところでは、高精度の参照値と
12
12
  比べています。
13
13
  - **JavaScript らしい呼び出し方です。** 必須の引数は位置で渡し、省略できる引数は camelCase のキーを
@@ -16,7 +16,7 @@ JavaScript とブラウザで使える、R と互換の統計関数のライブ
16
16
  - **どこでも動きます。** ESM のみで、依存パッケージはなく、Node 専用の API も使っていません。
17
17
  tree-shaking が効きます (`pnorm` だけなら gzip で 1.6 KB)。
18
18
 
19
- 状態: **1.0.0。** R の stats パッケージの数値計算の中心
19
+ 状態: **1.1.0。** R の stats パッケージの数値計算の中心
20
20
  (分布・記述統計・検定・線形モデル・特殊関数・数値計算・線形代数の基本) を、R と同じ結果でカバーすることを目指しています。残っている作業は
21
21
  [ROADMAP.ja.md](ROADMAP.ja.md)、変更履歴は [CHANGELOG.md](CHANGELOG.md) (英語) にあります。
22
22
 
@@ -267,12 +267,12 @@ double-double 演算で計算しているためです。詳しくは [docs/ja/ac
267
267
  | `pnorm` | 1.6 KB |
268
268
  | `setSeed`, `rnorm` | 2.0 KB |
269
269
  | `solve` / `svd` / `eigen` | 2.4 / 2.4 / 5.1 KB |
270
- | `wilcoxTest` / `fisherTest` / `tTest` | 16.4 / 27.7 / 31.0 KB |
270
+ | `wilcoxTest` / `fisherTest` / `tTest` | 18.9 / 27.7 / 31.0 KB |
271
271
  | `qbeta` / `pt` と `qt` | 43.5 / 40.0 KB |
272
- | `glm` と `glmSummary` / `glm` とそのすべての関数 | 35.0 / 50.9 KB |
273
- | `lmer` (`/mixed` から) / `lmerSummary`・`lmerContest`・`lmerAnova` も | 19.4 / 69.5 KB |
274
- | `glmer` (`/mixed` から) / `glmerSummary`・`glmerAnova`・`glmerPredict` も | 47.1 / 65.6 KB |
275
- | すべて (`/mixed` を除く) | 248.9 KB |
272
+ | `glm` と `glmSummary` / `glm` とそのすべての関数 | 35.0 / 51.0 KB |
273
+ | `lmer` (`/mixed` から) / `lmerSummary`・`lmerContest`・`lmerAnova` も | 19.4 / 69.6 KB |
274
+ | `glmer` (`/mixed` から) / `glmerSummary`・`glmerAnova`・`glmerPredict` も | 47.2 / 65.7 KB |
275
+ | すべて (`/mixed` を除く) | 251.5 KB |
276
276
 
277
277
  (`npm run size` で測れます。)
278
278
 
@@ -287,7 +287,7 @@ minify 済みの ES モジュール、gzip で 249 KB) を jsDelivr から読み
287
287
 
288
288
  ```html
289
289
  <script type="module">
290
- import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@1.0.0/dist/rstats.js";
290
+ import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@1.1.0/dist/rstats.js";
291
291
  console.log(pnorm(1.96)); // ≈ 0.9750021049
292
292
  </script>
293
293
  ```
package/README.md CHANGED
@@ -6,7 +6,7 @@ R-compatible statistical functions for JavaScript and the browser, written in Ty
6
6
  [Try it in the browser](https://numero-uno-jpn.github.io/rStats.js/demo/) (every function, with the values R gives).
7
7
 
8
8
  - **Same numbers as R.** Function names, defaults and results follow R. Every function is
9
- tested against R 4.5.2 (relative error 1e-14 for distributions), and where R itself is
9
+ tested against R 4.6.2 (relative error 1e-14 for distributions), and where R itself is
10
10
  inaccurate, against high-precision reference values.
11
11
  - **JavaScript-style calls.** Required arguments are positional, optional ones go in an object
12
12
  with camelCase keys: `pt(q, df, { lowerTail: false })` is R's `pt(q, df, lower.tail = FALSE)`.
@@ -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.6 KB gzipped).
16
16
 
17
- Status: **1.0.0.** The goal is to cover the numerical core of R's
17
+ Status: **1.1.0.** The goal is to cover the numerical core of R's
18
18
  `stats` package (distributions, descriptive statistics, hypothesis tests, linear models, special
19
19
  functions, numerical methods and the basics of linear algebra) with R-compatible results; see [ROADMAP.md](ROADMAP.md) for what remains. See [CHANGELOG.md](CHANGELOG.md).
20
20
 
@@ -266,12 +266,12 @@ removed. Approximate sizes after minification and gzip:
266
266
  | `pnorm` | 1.6 KB |
267
267
  | `setSeed`, `rnorm` | 2.0 KB |
268
268
  | `solve` / `svd` / `eigen` | 2.4 / 2.4 / 5.1 KB |
269
- | `wilcoxTest` / `fisherTest` / `tTest` | 16.4 / 27.7 / 31.0 KB |
269
+ | `wilcoxTest` / `fisherTest` / `tTest` | 18.9 / 27.7 / 31.0 KB |
270
270
  | `qbeta` / `pt` and `qt` | 43.5 / 40.0 KB |
271
- | `glm` and `glmSummary` / `glm` with all its methods | 35.0 / 50.9 KB |
272
- | `lmer` (from `/mixed`) / with `lmerSummary`, `lmerContest`, `lmerAnova` | 19.4 / 69.5 KB |
273
- | `glmer` (from `/mixed`) / with `glmerSummary`, `glmerAnova`, `glmerPredict` | 47.1 / 65.6 KB |
274
- | everything (except `/mixed`) | 248.9 KB |
271
+ | `glm` and `glmSummary` / `glm` with all its methods | 35.0 / 51.0 KB |
272
+ | `lmer` (from `/mixed`) / with `lmerSummary`, `lmerContest`, `lmerAnova` | 19.4 / 69.6 KB |
273
+ | `glmer` (from `/mixed`) / with `glmerSummary`, `glmerAnova`, `glmerPredict` | 47.2 / 65.7 KB |
274
+ | everything (except `/mixed`) | 251.5 KB |
275
275
 
276
276
  (`npm run size` measures these.)
277
277
 
@@ -285,7 +285,7 @@ function except those of `/mixed`, 249 KB gzipped) from jsDelivr, which serves e
285
285
 
286
286
  ```html
287
287
  <script type="module">
288
- import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@1.0.0/dist/rstats.js";
288
+ import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@1.1.0/dist/rstats.js";
289
289
  console.log(pnorm(1.96)); // ≈ 0.9750021049
290
290
  </script>
291
291
  ```
@@ -237,9 +237,10 @@ DAMAGE.
237
237
 
238
238
  ## LAPACK
239
239
 
240
- - Source: https://github.com/Reference-LAPACK/lapack (tag v3.12.0)
240
+ - Source: https://github.com/Reference-LAPACK/lapack (tag v3.12.0; tag v3.12.1 where noted)
241
241
  - `BLAS/SRC/dtrsm.f`, `SRC/dlange.f`, `SRC/dpotf2.f`, `SRC/dpstf2.f`, `SRC/dpotri.f` (`dtrti2.f`, `dlauu2.f`),
242
- `SRC/dgeqp3.f` (`dlaqp2.f`, `dlarfg.f`, `dlarf.f`), `SRC/dorm2r.f`, `SRC/dgetf2.f`, `SRC/dgetrs.f`,
242
+ `SRC/dgeqp3.f` (`dlaqp2.f`, `dlarfg.f`, `dlarf.f`; v3.12.1: `dlaqp2.f` with `dlarf1f.f`), `SRC/dorm2r.f`
243
+ (v3.12.1, with `dlarf1f.f`), `SRC/dgetf2.f`, `SRC/dgetrs.f`,
243
244
  `SRC/dgecon.f`, `SRC/dtrcon.f`, `SRC/dlacn2.f`, `SRC/dgebal.f`, `SRC/dgebak.f`, `SRC/dlanv2.f`
244
245
  - Used in: `src/linalg/basic.ts`, `src/linalg/norm.ts`, `src/linalg/chol.ts`, `src/linalg/qr.ts`, `src/linalg/solve.ts`, `src/linalg/svd.ts`, `src/linalg/balance.ts`, `src/linalg/schur.ts`
245
246
  - License: modified BSD
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.0.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{G as i,l as n,z as t}from"./chunk-WWVMVZUL.js";function o(r){return Number.isNaN(r)||r<-1?NaN:r===-1||r===1/0?-1/0:i(r)}function a(r){return Number.isNaN(r)||r===-1/0?NaN:r===1/0||r<=-1&&r===Math.floor(r)?1/0:t(r)}function m(r){return Number.isNaN(r)||r<0?NaN:r===0?-1/0:r===1/0?0:n(-r)}function p(r){return Number.isNaN(r)?NaN:r<=-37?Math.exp(r):r<=18?Math.log1p(Math.exp(r)):r<=33.3?r+Math.exp(-r):r}export{o as a,a as b,m as c,p as d};
1
+ /*! rStats.js 1.1.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
+ import{G as i,l as n,z as t}from"./chunk-NDTJ23A6.js";function o(r){return Number.isNaN(r)||r<-1?NaN:r===-1||r===1/0?-1/0:i(r)}function a(r){return Number.isNaN(r)||r===-1/0?NaN:r===1/0||r<=-1&&r===Math.floor(r)?1/0:t(r)}function m(r){return Number.isNaN(r)||r<0?NaN:r===0?-1/0:r===1/0?0:n(-r)}function p(r){return Number.isNaN(r)?NaN:r<=-37?Math.exp(r):r<=18?Math.log1p(Math.exp(r)):r<=33.3?r+Math.exp(-r):r}export{o as a,a as b,m as c,p as d};
@@ -1,3 +1,3 @@
1
- /*! rStats.js 1.0.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{F as at,G as ct,H as ut,i as rt,j as ot,z as st}from"./chunk-H7I32ZZE.js";import{j as G}from"./chunk-KICBQGFN.js";import{a as ft,g as mt}from"./chunk-LROMWFAK.js";import{h as et}from"./chunk-YG5S5AVP.js";import{c as ht}from"./chunk-4OLDGML4.js";import{c as lt,g as z}from"./chunk-NSWENS3S.js";import{a as W}from"./chunk-WQWZ7FND.js";import{c as j}from"./chunk-UJ66VQIG.js";import{C as A,q as Z,r as tt,s as nt}from"./chunk-WWVMVZUL.js";import{P as it,l as J,u as b}from"./chunk-63OPBEYO.js";var Ot=["contrasts","levels"];function It(n){let t=(n+1)/2,e=Array.from({length:n},(u,c)=>c+1-t),o=[new Array(n).fill(1/Math.sqrt(n))],s=(u,c)=>u.reduce((l,r,i)=>l+r*c[i],0);for(let u=1;u<n;u++){let c=o[u-1].map((r,i)=>r*e[i]);for(let r=0;r<2;r++)for(let i of o){let a=s(i,c);for(let f=0;f<n;f++)c[f]-=a*i[f]}let l=Math.sqrt(s(c,c));o.push(c.map(r=>r/l))}return e.map((u,c)=>o.slice(1).map(l=>l[c]))}function qt(n){return It(n)}function _t(n,t){let e=n.length,o=n.map(()=>[]),s;switch(t){case"indicators":n.forEach((u,c)=>n.forEach((l,r)=>o[c].push(c===r?1:0))),s=[...n];break;case"contr.treatment":n.forEach((u,c)=>{for(let l=1;l<e;l++)o[c].push(c===l?1:0)}),s=n.slice(1);break;case"contr.sum":n.forEach((u,c)=>{for(let l=0;l<e-1;l++)o[c].push(c===l?1:c===e-1?-1:0)}),s=Array.from({length:e-1},(u,c)=>String(c+1));break;case"contr.helmert":n.forEach((u,c)=>{for(let l=1;l<e;l++)o[c].push(c<l?-1:c===l?l:0)}),s=Array.from({length:e-1},(u,c)=>String(c+1));break;case"contr.poly":{let u=qt(e);n.forEach((c,l)=>o[l].push(...u[l])),s=Array.from({length:e-1},(c,l)=>[".L",".Q",".C"][l]??`^${l+1}`);break}default:throw new RangeError(`unknown contrast '${String(t)}'`)}return{m:o,names:s}}function At(n,t,e={},o=n.rhs){if(typeof t!="object"||t===null)throw new TypeError("data must be an object of columns");let s=mt(n,Object.keys(t),o);e.intercept!==void 0&&(s.intercept=e.intercept);let u=[...s.variables,...(e.extraVariables??[]).filter(p=>!s.variables.includes(p))],c={};e.levels!==void 0&&(c.levels=e.levels),e.weights!==void 0&&(c.weights=e.weights),e.dropUnusedLevels!==void 0&&(c.dropUnusedLevels=e.dropUnusedLevels);let l=ht(t,u,c),r=l.variables,i=l.rows.length,a=s.terms.map((p,N)=>N!==s.responseTerm),f=[],m=e.contrastVariables??s.variables;for(let p of Object.keys(e.contrasts??{}))if(!m.includes(p))f.push(`variable '${p}' is absent, its contrast will be ignored`);else if(r[s.variables.indexOf(p)]?.kind==="numeric")throw new TypeError("contrasts apply only to factors");let g=s.terms.map((p,N)=>p.map(w=>s.factors[w][N]));for(let p=0;p<s.terms.length;p++)if(a[p])for(let N of s.terms[p]){let w=r[N];if(w.kind==="factor"&&w.levels.length<2)throw new RangeError("contrasts can be applied only to factors with 2 or more levels")}if(!s.intercept)t:for(let p=0;p<s.terms.length;p++){if(!a[p])continue;let N=s.terms[p];for(let w=0;w<N.length;w++)if(r[N[w]].kind==="factor"){g[p][w]=2;break t}}let M=(p,N)=>{let w=[],P=[],_=[];s.intercept&&(w.push(new Array(N).fill(1)),P.push("(Intercept)"),_.push(0));let R=(x,O)=>{let I=r[x],k=p[x],y=s.variables[x];if(I.kind==="numeric")return[{name:y,values:k.values}];let F=e.contrasts!==void 0&&Object.hasOwn(e.contrasts,y)?e.contrasts[y]:void 0,U=O===2?"indicators":e.allContrasts??F??"contr.treatment",{m:D,names:T}=_t(I.levels,U),kt=k.codes;return T.map((Et,xt)=>({name:y+Et,values:kt.map(yt=>D[yt]?.[xt]??NaN)}))};return s.terms.forEach((x,O)=>{if(!a[O])return;let I=R(x[0],g[O][0]);for(let k=1;k<x.length;k++){let y=[];for(let F of R(x[k],g[O][k]))for(let U of I)y.push({name:`${U.name}:${F.name}`,values:U.values.map((D,T)=>D*F.values[T])});I=y}for(let k of I)w.push(k.values),P.push(k.name),_.push(O+1)}),{columns:w,colNames:P,assign:_}},{columns:d,colNames:h,assign:v}=M(r,i),S=Array.from({length:i},(p,N)=>d.map(w=>w[N])),C=(p,N)=>{let w=M(p,N).columns;return Array.from({length:N},(P,_)=>w.map(R=>R[_]))},$=s.warnings.filter(p=>!p.startsWith("problem with term")),Nt=[...$,...f,...s.warnings.filter(p=>!$.includes(p))],Y={terms:s,frame:l,x:S,colNames:h,assign:v,warnings:Nt,rowsOf:C};if(s.response>=0){let p=r[s.response];if(p.kind==="numeric")Y.y=p.values;else if(e.anyResponse!==!0)throw new TypeError("the response must be numeric")}return Y}function Wt(n,t,e={}){J(e,Ot,"modelMatrix");let o=At(ft(n),t,{...e,anyResponse:!0});return lt("modelMatrix",{colNames:o.colNames,assign:o.assign,x:o.x,rows:o.frame.rows,termLabels:o.terms.termLabels,order:o.terms.order,intercept:o.terms.intercept,variables:o.terms.variables,factors:o.terms.terms.length>0?o.terms.factors:[],warnings:o.warnings})}var Ht='prediction from rank-deficient fit; attr(*, "non-estim") has doubtful cases';function Xt(n,t,e){if(n===void 0)return[];let o=n.pivot.length;if(t>=o)return[];let s=n.qr,u=n.pivot,c=[];for(let m=t;m<o;m++){let g=new Array(t).fill(0);for(let d=t-1;d>=0;d--){let h=-s[d][m];for(let v=d+1;v<t;v++)h-=s[d][v]*g[v];g[d]=h/s[d][d]}let M=new Array(o).fill(0);for(let d=0;d<t;d++)M[u[d]]=g[d];M[u[m]]=1,c.push(M)}let l=Math.sqrt(Number.EPSILON),r=m=>Math.hypot(...m),i=m=>it([m]).groups[0],a=c.map(m=>{let g=i(m);return{u:g,n:r(g)}}),f=[];return e.forEach((m,g)=>{let M=i(m),d=r(M);a.some(({u:h,n:v})=>Math.abs(M.reduce((S,C,$)=>S+C*h[$],0))>l*d*v)&&f.push(g)}),f}function Yt(n,t){if(n.length===0||n[0].length===0)return!0;let e=t.length===0||t[0].length===0?0:G(t).rank;return G(t.map((o,s)=>[...o,...n[s]])).rank===e}var Lt={gaussian:["identity","log","inverse"],binomial:["logit","probit","cauchit","log","cloglog"],quasibinomial:["logit","probit","cauchit","log","cloglog"],poisson:["log","identity","sqrt"],quasipoisson:["log","identity","sqrt"],Gamma:["inverse","identity","log"],"inverse.gaussian":["1/mu^2","inverse","identity","log"],quasi:["identity","logit","probit","cloglog","inverse","log","1/mu^2","sqrt"]},B=n=>Number.isFinite(n)&&n>0,q=()=>!0;function $t(n){return n<0&&z("NaNs produced"),Math.sqrt(n)}function pt(n){return n<0&&z("NaNs produced"),Math.log(n)}function K(n){if(!Number.isFinite(n))return Number.isNaN(n)?"nan":n>0?"inf":"-inf";let t=n.toExponential(5),e=Number(t.slice(t.indexOf("e")+1));if(e>=-4&&e<6)return n.toFixed(5-e).replace(/\.?0+$/,"");let[o,s]=t.split("e");return`${o.replace(/\.?0+$/,"")}e${e<0?"-":"+"}${String(Math.abs(Number(s))).padStart(2,"0")}`}function Pt(n){if(n<0||n>1)throw new RangeError(`Value ${K(n)} out of range (0, 1)`);return Math.log(n/(1-n))}var Rt=["logit","probit","cauchit","cloglog","identity","log","sqrt","1/mu^2","inverse"],Q=n=>Math.min(Math.max(n,Number.MIN_VALUE),1-2**-53);function H(n){switch(n){case"identity":return{name:n,link:t=>t,linkinv:t=>t,muEta:()=>1,etaOk:q,muPower:{c:1,a:0}};case"log":return{name:n,link:Math.log,linkinv:t=>Math.max(Math.exp(t),Number.MIN_VALUE),muEta:t=>Math.max(Math.exp(t),Number.MIN_VALUE),etaOk:q,muPower:{c:1,a:1}};case"inverse":return{name:n,link:t=>1/t,linkinv:t=>1/t,muEta:t=>-1/(t*t),etaOk:t=>Number.isFinite(t)&&t!==0,muPower:{c:-1,a:2}};case"sqrt":return{name:n,link:Math.sqrt,linkinv:t=>t*t,muEta:t=>2*t,etaOk:B,muPower:{c:2,a:.5}};case"1/mu^2":return{name:n,link:t=>1/(t*t),linkinv:t=>1/$t(t),muEta:t=>-1/(2*t**1.5),etaOk:B,muPower:{c:-.5,a:3}};case"logit":return{name:n,link:Pt,linkinv:t=>{if(t>30)return Math.min(1/(1+Math.exp(-t)),1-2**-53);let e=Math.exp(t);return Math.max(e/(1+e),Number.MIN_VALUE)},muEta:t=>{if(Math.abs(t)>30){let o=Math.exp(-Math.abs(t));return Math.max(o/((1+o)*(1+o)),Number.MIN_VALUE)}let e=Math.exp(t);return e/((1+e)*(1+e))},etaOk:q};case"probit":return{name:n,link:t=>nt(t),linkinv:t=>Q(tt(t)),muEta:t=>Math.max(Z(t),Number.MIN_VALUE),etaOk:q};case"cauchit":return{name:n,link:t=>ut(t,0,1,!0,!1),linkinv:t=>Q(ct(t,0,1,!0,!1)),muEta:t=>Math.max(at(t,0,1,!1),Number.MIN_VALUE),etaOk:q};case"cloglog":return{name:n,link:t=>Math.log(-Math.log1p(-t)),linkinv:t=>Q(-Math.expm1(-Math.exp(t))),muEta:t=>{let e=Math.min(t,700);return Math.max(Math.exp(e)*Math.exp(-Math.exp(e)),Number.MIN_VALUE)},etaOk:q};default:throw new RangeError(`unknown link "${String(n)}"`)}}function Ft(n){if(!Number.isFinite(n))throw new RangeError("invalid power for the power link");if(n<=0)return H("log");if(n===1)return H("identity");let t=1/n;return{name:`mu^${Math.round(n*1e3)/1e3}`,link:e=>e**n,linkinv:e=>Math.max(e===1?1:e**t,Number.MIN_VALUE),muEta:e=>Ut(e,n,t),etaOk:B,...Number.isFinite(t)?{muPower:{c:t,a:1-n}}:{}}}function Ut(n,t,e){let o=e*n**(e-1);if(o<1/0)return Math.max(o,Number.MIN_VALUE);if(n===1)return e;let s=n**e,u=t*n;return s>0&&s<1/0&&u>=2**-1022&&u<1/0?Math.max(s/u,Number.MIN_VALUE):Math.max(Math.exp(e*Math.log(n)-Math.log(t)-Math.log(n)),Number.MIN_VALUE)}function Vt(n){switch(n){case"constant":return{variance:()=>1,muOk:()=>!0,dev:(t,e,o)=>o*(t-e)**2,varPower:0};case"mu(1-mu)":return{variance:t=>t*(1-t),muOk:t=>t>0&&t<1,dev:vt};case"mu":return{variance:t=>t,muOk:t=>t>0,varPower:1,dev:Mt};case"mu^2":return{variance:t=>t*t,muOk:t=>t>0,varPower:2,dev:(t,e,o)=>X(t,e)?gt(t,e,o):Math.max(bt(t,e,o,t!==0?t/e:1/e),0)};case"mu^3":return{variance:t=>t*t*t,muOk:t=>t>0,dev:wt,varPower:3};default:throw new RangeError(`'variance' "${String(n)}" is invalid: possible values are "mu(1-mu)", "mu", "mu^2", "mu^3" and "constant"`)}}var X=(n,t)=>Math.abs(n-t)<.1*t,gt=(n,t,e)=>-2*e*W((n-t)/t);function dt(n,t){let e=t/n;return n*(e*Math.log1p(e)+W(e))}var E=n=>Math.floor(Math.log2(Math.abs(n)));function L(n,t,e){if(n===0)return 0;let o=E(n);return b(2*b(n,-o)*t,o+e)}var V=(n,t,e,o,s)=>!(Number.isFinite(s)&&Math.abs(o)>=2**-1022)&&n>0&&n<1/0&&t>0&&t<1/0&&e>=0&&e<1/0&&n!==t;function St(n,t,e){let o=E(Math.max(n,t)),s=b(n,-o),u=b(t,-o),c=n/t,l=c>=2**-1022&&c<1/0?Math.log(c):Math.log(n)-Math.log(t);return L(e,s*l-(s-u),o)}function bt(n,t,e,o){let s=pt(o)-(n-t)/t,u=-2*e*s;if(!V(n,t,e,s,u))return u;let c=E(n),l=c-E(t),r=b(n,-c)/b(t,-(c-l)),i=Math.log(r)+l*Math.LN2;return l>0?L(e,r-b(1+i,-l),l):L(e,b(r,l)-1-i,0)}function Mt(n,t,e){if(X(n,t)){let u=A(n,t),c=2*e*u;if(!V(n,t,e,u,c))return c;let l=E(t);return L(e,A(b(n,-l),b(t,-l)),l)}let o=(n===0?0:n*pt(n/t))-(n-t),s=2*e*o;return V(n,t,e,o,s)?St(n,t,e):s}function Ct(n,t,e){let o=E(t);return L(e,A(b(n,-o),b(t,-o))+b(dt(1-t,t-n),-o),o)}function vt(n,t,e){if(Math.abs(n-t)<.1*Math.min(t,1-t)){let u=A(n,t)+dt(1-t,t-n),c=2*e*u;return V(n,t,e,u,c)?Ct(n,t,e):c}let o=n===0?0:n*Math.log(n/t),s=n===1?0:n===0&&t<.1?-Math.log1p(-t):(1-n)*Math.log((1-n)/(1-t));return 2*e*(o+s)}function wt(n,t,e){let o=n*t*t,s=e*(n-t)**2/o;if(Number.isFinite(s)&&!(Math.abs(o)<2**-1022))return s;let u=(n-t)/t,c=e*(u*u/n);if(Number.isFinite(c)||!(e>0&&e<1/0&&n>0&&n<1/0&&t>0&&t<1/0))return c;let l=n-t,[r,i,a,f]=[E(e),E(l),E(n),E(t)],m=b(l,-i),g=b(t,-f);return b(b(e,-r)*(m*m/(b(n,-a)*g*g)),r+2*i-a-2*f)}function ln(n,t){let e=typeof n=="string"?{family:n}:n,o=e.family,s=Lt[o];if(s===void 0)throw new RangeError(`unknown family "${String(o)}"`);let u=t??e.link??s[0],c;if(typeof u=="object"){if(o!=="quasi")throw new RangeError(`link "power" not available for ${o} family`);c=Ft(u.power)}else{if(o==="quasi"&&!s.includes(u))throw new RangeError(`link "${u}" not available for ${o} family; available links are ${s.map(r=>`'${r}'`).join(", ")}`);if(!Rt.includes(u))throw new RangeError(`\u2018${u}\u2019 link not recognised`);c=H(u)}if(e.variance!==void 0&&o!=="quasi")throw new TypeError("'variance' is only used by the quasi family");let l={...c,family:o,varianceName:void 0,fixedDispersion:!1};switch(o){case"gaussian":return{...l,varPower:0,variance:()=>1,muOk:()=>!0,devContribution:(r,i,a)=>a*(r-i)**2};case"binomial":case"quasibinomial":return{...l,fixedDispersion:o==="binomial",variance:r=>r*(1-r),muOk:r=>Number.isFinite(r)&&r>0&&r<1,devContribution:vt};case"poisson":case"quasipoisson":return{...l,fixedDispersion:o==="poisson",varPower:1,variance:r=>r,muOk:r=>Number.isFinite(r)&&r>0,devContribution:(r,i,a)=>r>0?Mt(r,i,a):2*a*i};case"Gamma":return{...l,varPower:2,variance:r=>r*r,muOk:r=>Number.isFinite(r)&&r>0,devContribution:(r,i,a)=>X(r,i)?gt(r,i,a):bt(r,i,a,r===0?1:r/i)};case"inverse.gaussian":return{...l,varPower:3,variance:r=>r*r*r,muOk:r=>Number.isFinite(r)&&r>0,devContribution:wt};case"quasi":{let r=e.variance??"constant",i=Vt(r);return{...l,varianceName:r,variance:i.variance,muOk:i.muOk,devContribution:i.dev,...i.varPower===void 0?{}:{varPower:i.varPower}}}}}function Dt(n,t,e,o,s){let u=n.family,c=u==="binomial"||u==="quasibinomial";if(t.length>0&&Array.isArray(t[0])){let a=t;if(a.every(h=>h.length===1))return Dt(n,a.map(h=>h[0]),e,o,s);if(!c)throw new TypeError("y must be a vector (or, for the binomial families, a two-column matrix)");if(a.some(h=>h.length!==2))throw new TypeError(`for the '${u}' family, y must be a vector of 0 and 1's
1
+ /*! rStats.js 1.1.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
+ import{F as at,G as ct,H as ut,i as rt,j as ot,z as st}from"./chunk-DTJG2IL2.js";import{j as G}from"./chunk-GYGQUYEP.js";import{a as ft,g as mt}from"./chunk-U7BRXOUS.js";import{h as et}from"./chunk-GGJA3JRO.js";import{c as ht}from"./chunk-GJEKNJP7.js";import{c as lt,g as z}from"./chunk-N5BDSMXS.js";import{a as W}from"./chunk-4KCSBTR5.js";import{c as j}from"./chunk-X4J6UJHN.js";import{C as A,q as Z,r as tt,s as nt}from"./chunk-NDTJ23A6.js";import{P as it,l as J,u as b}from"./chunk-HUWOSLKE.js";var Ot=["contrasts","levels"];function It(n){let t=(n+1)/2,e=Array.from({length:n},(u,c)=>c+1-t),o=[new Array(n).fill(1/Math.sqrt(n))],s=(u,c)=>u.reduce((l,r,i)=>l+r*c[i],0);for(let u=1;u<n;u++){let c=o[u-1].map((r,i)=>r*e[i]);for(let r=0;r<2;r++)for(let i of o){let a=s(i,c);for(let f=0;f<n;f++)c[f]-=a*i[f]}let l=Math.sqrt(s(c,c));o.push(c.map(r=>r/l))}return e.map((u,c)=>o.slice(1).map(l=>l[c]))}function qt(n){return It(n)}function _t(n,t){let e=n.length,o=n.map(()=>[]),s;switch(t){case"indicators":n.forEach((u,c)=>n.forEach((l,r)=>o[c].push(c===r?1:0))),s=[...n];break;case"contr.treatment":n.forEach((u,c)=>{for(let l=1;l<e;l++)o[c].push(c===l?1:0)}),s=n.slice(1);break;case"contr.sum":n.forEach((u,c)=>{for(let l=0;l<e-1;l++)o[c].push(c===l?1:c===e-1?-1:0)}),s=Array.from({length:e-1},(u,c)=>String(c+1));break;case"contr.helmert":n.forEach((u,c)=>{for(let l=1;l<e;l++)o[c].push(c<l?-1:c===l?l:0)}),s=Array.from({length:e-1},(u,c)=>String(c+1));break;case"contr.poly":{let u=qt(e);n.forEach((c,l)=>o[l].push(...u[l])),s=Array.from({length:e-1},(c,l)=>[".L",".Q",".C"][l]??`^${l+1}`);break}default:throw new RangeError(`unknown contrast '${String(t)}'`)}return{m:o,names:s}}function At(n,t,e={},o=n.rhs){if(typeof t!="object"||t===null)throw new TypeError("data must be an object of columns");let s=mt(n,Object.keys(t),o);e.intercept!==void 0&&(s.intercept=e.intercept);let u=[...s.variables,...(e.extraVariables??[]).filter(p=>!s.variables.includes(p))],c={};e.levels!==void 0&&(c.levels=e.levels),e.weights!==void 0&&(c.weights=e.weights),e.dropUnusedLevels!==void 0&&(c.dropUnusedLevels=e.dropUnusedLevels);let l=ht(t,u,c),r=l.variables,i=l.rows.length,a=s.terms.map((p,N)=>N!==s.responseTerm),f=[],m=e.contrastVariables??s.variables;for(let p of Object.keys(e.contrasts??{}))if(!m.includes(p))f.push(`variable '${p}' is absent, its contrast will be ignored`);else if(r[s.variables.indexOf(p)]?.kind==="numeric")throw new TypeError("contrasts apply only to factors");let g=s.terms.map((p,N)=>p.map(w=>s.factors[w][N]));for(let p=0;p<s.terms.length;p++)if(a[p])for(let N of s.terms[p]){let w=r[N];if(w.kind==="factor"&&w.levels.length<2)throw new RangeError("contrasts can be applied only to factors with 2 or more levels")}if(!s.intercept)t:for(let p=0;p<s.terms.length;p++){if(!a[p])continue;let N=s.terms[p];for(let w=0;w<N.length;w++)if(r[N[w]].kind==="factor"){g[p][w]=2;break t}}let M=(p,N)=>{let w=[],P=[],_=[];s.intercept&&(w.push(new Array(N).fill(1)),P.push("(Intercept)"),_.push(0));let R=(x,O)=>{let I=r[x],k=p[x],y=s.variables[x];if(I.kind==="numeric")return[{name:y,values:k.values}];let F=e.contrasts!==void 0&&Object.hasOwn(e.contrasts,y)?e.contrasts[y]:void 0,U=O===2?"indicators":e.allContrasts??F??"contr.treatment",{m:D,names:T}=_t(I.levels,U),kt=k.codes;return T.map((Et,xt)=>({name:y+Et,values:kt.map(yt=>D[yt]?.[xt]??NaN)}))};return s.terms.forEach((x,O)=>{if(!a[O])return;let I=R(x[0],g[O][0]);for(let k=1;k<x.length;k++){let y=[];for(let F of R(x[k],g[O][k]))for(let U of I)y.push({name:`${U.name}:${F.name}`,values:U.values.map((D,T)=>D*F.values[T])});I=y}for(let k of I)w.push(k.values),P.push(k.name),_.push(O+1)}),{columns:w,colNames:P,assign:_}},{columns:d,colNames:h,assign:v}=M(r,i),S=Array.from({length:i},(p,N)=>d.map(w=>w[N])),C=(p,N)=>{let w=M(p,N).columns;return Array.from({length:N},(P,_)=>w.map(R=>R[_]))},$=s.warnings.filter(p=>!p.startsWith("problem with term")),Nt=[...$,...f,...s.warnings.filter(p=>!$.includes(p))],Y={terms:s,frame:l,x:S,colNames:h,assign:v,warnings:Nt,rowsOf:C};if(s.response>=0){let p=r[s.response];if(p.kind==="numeric")Y.y=p.values;else if(e.anyResponse!==!0)throw new TypeError("the response must be numeric")}return Y}function Wt(n,t,e={}){J(e,Ot,"modelMatrix");let o=At(ft(n),t,{...e,anyResponse:!0});return lt("modelMatrix",{colNames:o.colNames,assign:o.assign,x:o.x,rows:o.frame.rows,termLabels:o.terms.termLabels,order:o.terms.order,intercept:o.terms.intercept,variables:o.terms.variables,factors:o.terms.terms.length>0?o.terms.factors:[],warnings:o.warnings})}var Ht='prediction from rank-deficient fit; attr(*, "non-estim") has doubtful cases';function Xt(n,t,e){if(n===void 0)return[];let o=n.pivot.length;if(t>=o)return[];let s=n.qr,u=n.pivot,c=[];for(let m=t;m<o;m++){let g=new Array(t).fill(0);for(let d=t-1;d>=0;d--){let h=-s[d][m];for(let v=d+1;v<t;v++)h-=s[d][v]*g[v];g[d]=h/s[d][d]}let M=new Array(o).fill(0);for(let d=0;d<t;d++)M[u[d]]=g[d];M[u[m]]=1,c.push(M)}let l=Math.sqrt(Number.EPSILON),r=m=>Math.hypot(...m),i=m=>it([m]).groups[0],a=c.map(m=>{let g=i(m);return{u:g,n:r(g)}}),f=[];return e.forEach((m,g)=>{let M=i(m),d=r(M);a.some(({u:h,n:v})=>Math.abs(M.reduce((S,C,$)=>S+C*h[$],0))>l*d*v)&&f.push(g)}),f}function Yt(n,t){if(n.length===0||n[0].length===0)return!0;let e=t.length===0||t[0].length===0?0:G(t).rank;return G(t.map((o,s)=>[...o,...n[s]])).rank===e}var Lt={gaussian:["identity","log","inverse"],binomial:["logit","probit","cauchit","log","cloglog"],quasibinomial:["logit","probit","cauchit","log","cloglog"],poisson:["log","identity","sqrt"],quasipoisson:["log","identity","sqrt"],Gamma:["inverse","identity","log"],"inverse.gaussian":["1/mu^2","inverse","identity","log"],quasi:["identity","logit","probit","cloglog","inverse","log","1/mu^2","sqrt"]},B=n=>Number.isFinite(n)&&n>0,q=()=>!0;function $t(n){return n<0&&z("NaNs produced"),Math.sqrt(n)}function pt(n){return n<0&&z("NaNs produced"),Math.log(n)}function K(n){if(!Number.isFinite(n))return Number.isNaN(n)?"nan":n>0?"inf":"-inf";let t=n.toExponential(5),e=Number(t.slice(t.indexOf("e")+1));if(e>=-4&&e<6)return n.toFixed(5-e).replace(/\.?0+$/,"");let[o,s]=t.split("e");return`${o.replace(/\.?0+$/,"")}e${e<0?"-":"+"}${String(Math.abs(Number(s))).padStart(2,"0")}`}function Pt(n){if(n<0||n>1)throw new RangeError(`Value ${K(n)} out of range (0, 1)`);return Math.log(n/(1-n))}var Rt=["logit","probit","cauchit","cloglog","identity","log","sqrt","1/mu^2","inverse"],Q=n=>Math.min(Math.max(n,Number.MIN_VALUE),1-2**-53);function H(n){switch(n){case"identity":return{name:n,link:t=>t,linkinv:t=>t,muEta:()=>1,etaOk:q,muPower:{c:1,a:0}};case"log":return{name:n,link:Math.log,linkinv:t=>Math.max(Math.exp(t),Number.MIN_VALUE),muEta:t=>Math.max(Math.exp(t),Number.MIN_VALUE),etaOk:q,muPower:{c:1,a:1}};case"inverse":return{name:n,link:t=>1/t,linkinv:t=>1/t,muEta:t=>-1/(t*t),etaOk:t=>Number.isFinite(t)&&t!==0,muPower:{c:-1,a:2}};case"sqrt":return{name:n,link:Math.sqrt,linkinv:t=>t*t,muEta:t=>2*t,etaOk:B,muPower:{c:2,a:.5}};case"1/mu^2":return{name:n,link:t=>1/(t*t),linkinv:t=>1/$t(t),muEta:t=>-1/(2*t**1.5),etaOk:B,muPower:{c:-.5,a:3}};case"logit":return{name:n,link:Pt,linkinv:t=>{if(t>30)return Math.min(1/(1+Math.exp(-t)),1-2**-53);let e=Math.exp(t);return Math.max(e/(1+e),Number.MIN_VALUE)},muEta:t=>{if(Math.abs(t)>30){let o=Math.exp(-Math.abs(t));return Math.max(o/((1+o)*(1+o)),Number.MIN_VALUE)}let e=Math.exp(t);return e/((1+e)*(1+e))},etaOk:q};case"probit":return{name:n,link:t=>nt(t),linkinv:t=>Q(tt(t)),muEta:t=>Math.max(Z(t),Number.MIN_VALUE),etaOk:q};case"cauchit":return{name:n,link:t=>ut(t,0,1,!0,!1),linkinv:t=>Q(ct(t,0,1,!0,!1)),muEta:t=>Math.max(at(t,0,1,!1),Number.MIN_VALUE),etaOk:q};case"cloglog":return{name:n,link:t=>Math.log(-Math.log1p(-t)),linkinv:t=>Q(-Math.expm1(-Math.exp(t))),muEta:t=>{let e=Math.min(t,700);return Math.max(Math.exp(e)*Math.exp(-Math.exp(e)),Number.MIN_VALUE)},etaOk:q};default:throw new RangeError(`unknown link "${String(n)}"`)}}function Ft(n){if(!Number.isFinite(n))throw new RangeError("invalid power for the power link");if(n<=0)return H("log");if(n===1)return H("identity");let t=1/n;return{name:`mu^${Math.round(n*1e3)/1e3}`,link:e=>e**n,linkinv:e=>Math.max(e===1?1:e**t,Number.MIN_VALUE),muEta:e=>Ut(e,n,t),etaOk:B,...Number.isFinite(t)?{muPower:{c:t,a:1-n}}:{}}}function Ut(n,t,e){let o=e*n**(e-1);if(o<1/0)return Math.max(o,Number.MIN_VALUE);if(n===1)return e;let s=n**e,u=t*n;return s>0&&s<1/0&&u>=2**-1022&&u<1/0?Math.max(s/u,Number.MIN_VALUE):Math.max(Math.exp(e*Math.log(n)-Math.log(t)-Math.log(n)),Number.MIN_VALUE)}function Vt(n){switch(n){case"constant":return{variance:()=>1,muOk:()=>!0,dev:(t,e,o)=>o*(t-e)**2,varPower:0};case"mu(1-mu)":return{variance:t=>t*(1-t),muOk:t=>t>0&&t<1,dev:vt};case"mu":return{variance:t=>t,muOk:t=>t>0,varPower:1,dev:Mt};case"mu^2":return{variance:t=>t*t,muOk:t=>t>0,varPower:2,dev:(t,e,o)=>X(t,e)?gt(t,e,o):Math.max(bt(t,e,o,t!==0?t/e:1/e),0)};case"mu^3":return{variance:t=>t*t*t,muOk:t=>t>0,dev:wt,varPower:3};default:throw new RangeError(`'variance' "${String(n)}" is invalid: possible values are "mu(1-mu)", "mu", "mu^2", "mu^3" and "constant"`)}}var X=(n,t)=>Math.abs(n-t)<.1*t,gt=(n,t,e)=>-2*e*W((n-t)/t);function dt(n,t){let e=t/n;return n*(e*Math.log1p(e)+W(e))}var E=n=>Math.floor(Math.log2(Math.abs(n)));function L(n,t,e){if(n===0)return 0;let o=E(n);return b(2*b(n,-o)*t,o+e)}var V=(n,t,e,o,s)=>!(Number.isFinite(s)&&Math.abs(o)>=2**-1022)&&n>0&&n<1/0&&t>0&&t<1/0&&e>=0&&e<1/0&&n!==t;function St(n,t,e){let o=E(Math.max(n,t)),s=b(n,-o),u=b(t,-o),c=n/t,l=c>=2**-1022&&c<1/0?Math.log(c):Math.log(n)-Math.log(t);return L(e,s*l-(s-u),o)}function bt(n,t,e,o){let s=pt(o)-(n-t)/t,u=-2*e*s;if(!V(n,t,e,s,u))return u;let c=E(n),l=c-E(t),r=b(n,-c)/b(t,-(c-l)),i=Math.log(r)+l*Math.LN2;return l>0?L(e,r-b(1+i,-l),l):L(e,b(r,l)-1-i,0)}function Mt(n,t,e){if(X(n,t)){let u=A(n,t),c=2*e*u;if(!V(n,t,e,u,c))return c;let l=E(t);return L(e,A(b(n,-l),b(t,-l)),l)}let o=(n===0?0:n*pt(n/t))-(n-t),s=2*e*o;return V(n,t,e,o,s)?St(n,t,e):s}function Ct(n,t,e){let o=E(t);return L(e,A(b(n,-o),b(t,-o))+b(dt(1-t,t-n),-o),o)}function vt(n,t,e){if(Math.abs(n-t)<.1*Math.min(t,1-t)){let u=A(n,t)+dt(1-t,t-n),c=2*e*u;return V(n,t,e,u,c)?Ct(n,t,e):c}let o=n===0?0:n*Math.log(n/t),s=n===1?0:n===0&&t<.1?-Math.log1p(-t):(1-n)*Math.log((1-n)/(1-t));return 2*e*(o+s)}function wt(n,t,e){let o=n*t*t,s=e*(n-t)**2/o;if(Number.isFinite(s)&&!(Math.abs(o)<2**-1022))return s;let u=(n-t)/t,c=e*(u*u/n);if(Number.isFinite(c)||!(e>0&&e<1/0&&n>0&&n<1/0&&t>0&&t<1/0))return c;let l=n-t,[r,i,a,f]=[E(e),E(l),E(n),E(t)],m=b(l,-i),g=b(t,-f);return b(b(e,-r)*(m*m/(b(n,-a)*g*g)),r+2*i-a-2*f)}function ln(n,t){let e=typeof n=="string"?{family:n}:n,o=e.family,s=Lt[o];if(s===void 0)throw new RangeError(`unknown family "${String(o)}"`);let u=t??e.link??s[0],c;if(typeof u=="object"){if(o!=="quasi")throw new RangeError(`link "power" not available for ${o} family`);c=Ft(u.power)}else{if(o==="quasi"&&!s.includes(u))throw new RangeError(`link "${u}" not available for ${o} family; available links are ${s.map(r=>`'${r}'`).join(", ")}`);if(!Rt.includes(u))throw new RangeError(`\u2018${u}\u2019 link not recognised`);c=H(u)}if(e.variance!==void 0&&o!=="quasi")throw new TypeError("'variance' is only used by the quasi family");let l={...c,family:o,varianceName:void 0,fixedDispersion:!1};switch(o){case"gaussian":return{...l,varPower:0,variance:()=>1,muOk:()=>!0,devContribution:(r,i,a)=>a*(r-i)**2};case"binomial":case"quasibinomial":return{...l,fixedDispersion:o==="binomial",variance:r=>r*(1-r),muOk:r=>Number.isFinite(r)&&r>0&&r<1,devContribution:vt};case"poisson":case"quasipoisson":return{...l,fixedDispersion:o==="poisson",varPower:1,variance:r=>r,muOk:r=>Number.isFinite(r)&&r>0,devContribution:(r,i,a)=>r>0?Mt(r,i,a):2*a*i};case"Gamma":return{...l,varPower:2,variance:r=>r*r,muOk:r=>Number.isFinite(r)&&r>0,devContribution:(r,i,a)=>X(r,i)?gt(r,i,a):bt(r,i,a,r===0?1:r/i)};case"inverse.gaussian":return{...l,varPower:3,variance:r=>r*r*r,muOk:r=>Number.isFinite(r)&&r>0,devContribution:wt};case"quasi":{let r=e.variance??"constant",i=Vt(r);return{...l,varianceName:r,variance:i.variance,muOk:i.muOk,devContribution:i.dev,...i.varPower===void 0?{}:{varPower:i.varPower}}}}}function Dt(n,t,e,o,s){let u=n.family,c=u==="binomial"||u==="quasibinomial";if(t.length>0&&Array.isArray(t[0])){let a=t;if(a.every(h=>h.length===1))return Dt(n,a.map(h=>h[0]),e,o,s);if(!c)throw new TypeError("y must be a vector (or, for the binomial families, a two-column matrix)");if(a.some(h=>h.length!==2))throw new TypeError(`for the '${u}' family, y must be a vector of 0 and 1's
3
3
  or a 2 column matrix where col 1 is no. successes and col 2 is no. failures`);if(u==="binomial"&&a.some(h=>Math.abs(h[0]-Math.round(h[0]))>.001||Math.abs(h[1]-Math.round(h[1]))>.001)&&s.add("non-integer counts in a binomial glm!"),a.some(h=>h[0]<0||h[1]<0))throw new RangeError("counts must be nonnegative");let f=a.map(h=>h[0]+h[1]),m=a.findIndex((h,v)=>Number.isFinite(h[0])&&Number.isFinite(h[1])&&!Number.isFinite(f[v]));if(m>=0)throw new RangeError(`the total of successes and failures overflows in row ${m+1} (${K(a[m][0])} + ${K(a[m][1])}): the binomial size must be a finite double`);let g=a.map((h,v)=>f[v]===0?0:h[0]/f[v]),M=e.map((h,v)=>h*f[v]),d=g.map((h,v)=>(f[v]*h+.5)/(f[v]+1));return{y:g,weights:M,mustart:d,size:f}}let r=t.slice(),i=e.slice();switch(u){case"binomial":case"quasibinomial":{for(let f=0;f<r.length;f++)i[f]===0&&(r[f]=0);if(r.some(f=>f<0||f>1))throw new RangeError("y values must be 0 <= y <= 1");let a=r.map((f,m)=>(i[m]*f+.5)/(i[m]+1));return u==="binomial"&&r.some((f,m)=>Math.abs(i[m]*f-Math.round(i[m]*f))>.001)&&s.add("non-integer #successes in a binomial glm!"),{y:r,weights:i,mustart:a,size:r.map(()=>1)}}case"poisson":case"quasipoisson":if(r.some(a=>a<0))throw new RangeError(`negative values not allowed for the '${u==="poisson"?"Poisson":"quasiPoisson"}' family`);return{y:r,weights:i,mustart:r.map(a=>a+.1),size:void 0};case"Gamma":if(r.some(a=>a<=0))throw new RangeError("non-positive values not allowed for the 'Gamma' family");return{y:r,weights:i,mustart:r.slice(),size:void 0};case"inverse.gaussian":if(r.some(a=>a<=0))throw new RangeError("positive values only are allowed for the 'inverse.gaussian' family");return{y:r,weights:i,mustart:r.slice(),size:void 0};case"gaussian":if(!o&&(n.name==="inverse"&&r.some(a=>a===0)||n.name==="log"&&r.some(a=>a<=0)))throw new Error("cannot find valid starting values: please specify some");return{y:r,weights:i,mustart:r.slice(),size:void 0};case"quasi":{let a=n.varianceName,f=a==="constant"?r.slice():a==="mu(1-mu)"?r.map(m=>Math.min(Math.max(m,.001),.999)):r.map(m=>m+(m===0?.1:0));return{y:r,weights:i,mustart:f,size:void 0}}}}function fn(n,t,e,o,s,u,c){let l=t.length,r=0;switch(n.family){case"gaussian":{let i=0,a=0;for(let g of o)g>0&&(i+=Math.log(g),a++);let f=2*Math.PI*u/a,m=f===1/0&&u<1/0?Math.log(2*Math.PI)+Math.log(u/a):Math.log(f);return a*(m+1)+2-i}case"binomial":{let i=s!==void 0&&s.some(a=>a>1)?s:o;for(let a=0;a<l;a++)i[a]>0&&(r+=o[a]/i[a]*st(j(i[a]*t[a]),j(i[a]),e[a],!0));return-2*r}case"poisson":for(let i=0;i<l;i++)o[i]>0&&(rt(t[i])&&c.add(`non-integer x = ${t[i].toFixed(6)}`),r+=o[i]*ot(t[i],e[i],!0));return-2*r;case"Gamma":{let i=0;for(let f of o)i+=f;let a=u/i;for(let f=0;f<l;f++)o[f]>0&&(r+=o[f]*et(t[f],1/a,e[f]*a,!0));return-2*r+2}case"inverse.gaussian":{let i=0,a=0;for(let M=0;M<l;M++)o[M]>0&&(i+=o[M],a+=o[M]*Math.log(t[M]));let f=2*Math.PI*u/i,m=u/i,g=f===1/0&&u<1/0?Math.log(2*Math.PI)+(m<1/0?Math.log(m):Math.log(u)-Math.log(i)):Math.log(f);return i*(g+1)+3*a+2}default:return NaN}}export{At as a,Wt as b,Ht as c,Xt as d,Yt as e,ln as f,Dt as g,fn as h};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.0.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{l as u}from"./chunk-63OPBEYO.js";function c(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function p(n,o,f){let i={},e;for(let t=0;t<o.length;t++){let r=o[t];if(t<=n.length&&c(r)){e=r;break}t<n.length&&r!==void 0&&(i[n[t]]=r)}if(e!==void 0){f!==void 0&&u(e,n,f);for(let t of n)if(e[t]!==void 0){if(Object.hasOwn(i,t))throw new RangeError(`'${t}' is given both as an argument and in the options`);i[t]=e[t]}}return i}function s(n){for(let o of n)if(c(o))return o}export{c as a,p as b,s as c};
1
+ /*! rStats.js 1.1.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
+ import{l as u}from"./chunk-HUWOSLKE.js";function c(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&!ArrayBuffer.isView(n)}function p(n,o,f){let i={},e;for(let t=0;t<o.length;t++){let r=o[t];if(t<=n.length&&c(r)){e=r;break}t<n.length&&r!==void 0&&(i[n[t]]=r)}if(e!==void 0){f!==void 0&&u(e,n,f);for(let t of n)if(e[t]!==void 0){if(Object.hasOwn(i,t))throw new RangeError(`'${t}' is given both as an argument and in the options`);i[t]=e[t]}}return i}function s(n){for(let o of n)if(c(o))return o}export{c as a,p as b,s as c};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.0.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{f as q,g as he,h as J}from"./chunk-UKNDX4BA.js";import{A as ue,B as le,a as ie,b as ae,c as se,f as j,z as ce}from"./chunk-H7I32ZZE.js";import{a as S,b as T,c as C,d as L,e as Jt,h as ne,i as re,l as oe}from"./chunk-YG5S5AVP.js";import{a as fe}from"./chunk-CKV4JWW2.js";import{a as F,b as Q,c as v}from"./chunk-UJ66VQIG.js";import{A as kt,B as te,E as ee,e as E,r as R,s as B}from"./chunk-WWVMVZUL.js";import{b as Ut,c as Nt,d as ot,e as Vt,f as Zt,g as z,i as it,k as zt,l as y}from"./chunk-63OPBEYO.js";var gn=["log","ncp"],dn=["lowerTail","logP","ncp"],Nn=["lowerTail","logP","ncp"];function Dr(t,e,n={}){y(n,gn,"dchisq");let{log:r=!1,ncp:o}=n;if(o!==void 0)return E(t,a=>ie(a,e,o,r));let i=e<0?NaN:e/2;return E(t,a=>ne(a,i,2,r))}function Yr(t,e,n={}){y(n,dn,"pchisq");let{lowerTail:r=!0,logP:o=!1,ncp:i}=n;if(i!==void 0)return E(t,s=>ae(s,e,i,r,o));let a=e<0?NaN:e/2;return E(t,s=>re(s,a,2,r,o))}function Kr(t,e,n={}){y(n,Nn,"qchisq");let{lowerTail:r=!0,logP:o=!1,ncp:i}=n;if(i!==void 0)return E(t,s=>se(s,e,i,r,o));let a=e<0?NaN:e/2;return E(t,s=>oe(s,a,2,r,o))}var bn=["log"],wn=["lowerTail","logP"],xn=["lowerTail","logP"];function bt(t,e,n,r){if(t===0&&e===0)return{e:[0,0],logDenom:0};if(t===0||e===0){let o=t+e,[i,a]=t===0?[r,n]:[n,r];return{e:a[0]<.1?ot(te(o,z([o,0],i)),z([o,0],a)):Vt(z([o,0],zt(i))),logDenom:0}}return ee(t,e,n,r)}function ge(t,e,n,r){let o=e+n,i=it([r,0],[o,0]),a=it([o-r,0],[o,0]),s=bt(t,e-t,i,a),c=bt(r-t,n-r+t,i,a),u=bt(r,o-r,i,a);return{e:Zt(ot(s.e,c.e),u.e),logDenom:s.logDenom+c.logDenom-u.logDenom}}function de(t,e){let[n,r]=t.e,o=e*Math.exp(-.5*t.logDenom);return n<700?Math.exp(-n)*(1-r)*o:Math.exp(700-n)*(1-r)*o*Math.exp(-700)}function Ne(t){return-t.e[0]-t.e[1]-.5*t.logDenom}function wt(t,e){return Ut(t,e)[1]===0}function at(t,e,n){return[Math.max(0,n-e),Math.min(n,t)]}function En(t,e,n,r,o){if([t,e,n,r].some(Number.isNaN))return NaN;if(![e,n,r].every(Number.isFinite)||F(e)||F(n)||F(r))return NaN;if(e=v(e),n=v(n),r=v(r),e<0||n<0||r<0||r>e+n)return NaN;if(Et(e,n,r))return ce(t,r,xt(e,n),o);if(F(t))return C(o);t=v(t);let[i,a]=at(e,n,r);if(t<i||t>a)return C(o);if(r===0)return o?0:1;if(!wt(e,n))return NaN;if(r===e+n)return o?0:1;let s=ge(t,e,n,r);return o?Ne(s):de(s,1)}function Me(t,e,n,r){return it(Nt(t,e),Nt(n,r))}function yn(t,e,n,r,o,i,a){let s=[1,0],c=[1,0],u=t;for(;!(o?u<=i:u>=a);){let l=o?Me(u,n-r+u,e-u+1,r-u+1):Me(e-u,r-u,u+1,n-r+u+1);s=z(s,l),c=ot(c,s),u+=o?-1:1;let h=l[0];if(h<1&&s[0]*h/(1-h)<c[0]*2**-60)break}return c[0]+c[1]}function be(t,e,n,r,o,i){let[a,s]=at(e,n,r),c=e+n,u=t*c<r*e,l=pe(t,e,n,r,u,a,s);if(l.value>.5){let h=pe(t,e,n,r,!u,a,s);h.value<l.value&&(l=h,u=!u)}return u===o?i?l.value>1e-300?Math.log(l.value):Ne(l.form)+Math.log(l.sum):l.value:i?Math.log1p(-l.value):1-l.value}function pe(t,e,n,r,o,i,a){let s=o?t:t+1,c=ge(s,e,n,r),u=yn(s,e,n,r,o,i,a);return{form:c,sum:u,value:de(c,u)}}function xt(t,e){return t>=e?1/(1+e/t):e/t===1/0?0:t/e/(1+t/e)}function Et(t,e,n){return n>0&&n<t*2**-60+e*2**-60}function we(t,e,n){if([t,e,n].every(Number.isFinite)&&(t=v(t),e=v(e),n=v(n),!(t<0||e<0||n<0||n>t+e)))return[t,e,n]}function In(t,e,n,r,o,i){if([t,e,n,r].some(Number.isNaN))return NaN;let a=we(e,n,r);if(a===void 0)return NaN;if([e,n,r]=a,Et(e,n,r))return ue(t,r,xt(e,n),o,i);let s=Q(t),[c,u]=at(e,n,r);if(s<c)return S(o,i);if(s>=u)return T(o,i);if(u>Ee||!wt(e,n))return NaN;let l=vn(s,e,n,r,c,u);if(l>_n)throw new RangeError(`phyper: m = ${e}, n = ${n}, k = ${r} needs about ${Math.round(l)} terms at q = ${t} (at most 2^26)`);return be(s,e,n,r,o,i)}function xe(t,e,n,r){return n*t/r*(e/r)*(r-n)/Math.max(r-1,1)}function me(t,e,n,r,o,i){let a=e?n-t:t-n,s=Math.sqrt(a*a+83*r);return Math.min(a>=0?83*r/(s+a):s-a,e?t-o:i-t)}function vn(t,e,n,r,o,i){let a=e+n,s=r*e/a,c=xe(e,n,r,a),u=t*a<r*e,l=u?t:t+1,h=me(l,u,s,c,o,i);return Math.abs(l-s)>=1?h:h+me(u?t+1:t,!u,s,c,o,i)}var _n=2**26,An=2**21,Ee=2**53;function Rn(t,e,n,r,o,i,a=!0){if([t,e,n,r].some(Number.isNaN))return NaN;let s=we(e,n,r);if(s===void 0)return NaN;if([e,n,r]=s,Et(e,n,r))return le(t,r,xt(e,n),o,i);let[c,u]=at(e,n,r),l=L(t,c,u,o,i);if(l!==void 0)return l;if(c===u)return c;if(u>Ee||!wt(e,n))return NaN;let h=e+n,f=r*e/h,p=Math.sqrt(xe(e,n,r,h));if(a&&p>An)throw new RangeError(`qhyper: m = ${e}, n = ${n}, k = ${r} has a standard deviation of about ${p.toPrecision(3)} (at most 2^21)`);let M=B(t,{lowerTail:o,logP:i}),N=f+p*M;return j({p:t,lowerTail:o,logP:i,cdf:(g,I,d)=>g<c?S(I,d):g>=u?T(I,d):be(g,e,n,r,I,d),y0:Number.isFinite(N)?N:f,lo:c,hi:u})}function Jr(t,e,n,r,o={}){y(o,bn,"dhyper");let i=o.log??!1;return E(t,a=>En(a,e,n,r,i))}function kr(t,e,n,r,o={}){y(o,wn,"phyper");let{lowerTail:i=!0,logP:a=!1}=o;return E(t,s=>In(s,e,n,r,i,a))}function to(t,e,n,r,o={}){y(o,xn,"qhyper");let{lowerTail:i=!0,logP:a=!1}=o;return E(t,s=>Rn(s,e,n,r,i,a))}var Sn=["log"],Tn=["lowerTail","logP"],Pn=["lowerTail","logP"],Cn=2**900,ye=-900,W=new Map,Fn=2**21,st=0,Ln=2**25;function ve(t,e){if(e+1>Ln)throw new RangeError(`signrank: n = ${t} needs too large a table (${e+1} entries)`);let n=new Float64Array(e+1);n[0]=1;let r=0,o=-1/0,i=Math.min(t,e);for(let u=1;u<=i;u++){for(let l=e;l>=u;l--)n[l]+=n[l-u];if(n[Math.min(e,Math.floor(u*(u+1)/4))]>Cn){let l=2**ye;for(let h=0;h<=e;h++)n[h]*=l;r-=ye,o=Math.max(o,r-1015+i-u)}}let a=new Float64Array(e+1),s=0,c=0;for(let u=0;u<=e;u++){let l=n[u]-c,h=s+l;c=h-s-l,s=h,a[u]=s}return{n:t,len:e+1,count:n,cum:a,scale:r,minTrusted:2**(o-r)}}function Ie(t,e,n=!1){let r=n?-t:t,o=W.get(r);if(o!==void 0&&o.len>e)return W.delete(r),W.set(r,o),o;let i=Math.floor(t*(t+1)/4),a=Math.min(i,Math.max(e,o===void 0?0:2*o.len));return _e(r,ve(t,a),o)}function _e(t,e,n){n!==void 0&&(W.delete(t),st-=n.len),W.set(t,e),st+=e.len;for(let[r,o]of W){if(st<=Fn||r===t)break;W.delete(r),st-=o.len}return e}function yt(t,e,n){let r=(a,s)=>e===a.len-1||s>=(n?(e+1)*a.minTrusted:a.minTrusted),o=Ie(t,e),i=(n?o.cum:o.count)[e];return r(o,i)?[i,o]:(o=Ie(t,e,!0),i=(n?o.cum:o.count)[e],r(o,i)?[i,o]:(o=_e(-t,ve(t,e),W.get(-t)),[(n?o.cum:o.count)[e],o]))}function It(t,e,n){let r=e.scale-e.n,o=Math.trunc(r/2),i=t*2**o*2**(r-o);if(!n)return i;if(i>=1e-300)return Math.log(i);let a=Math.floor(Math.log2(t)),s=Math.trunc(a/2),c=t*2**-s*2**-(a-s);return c>=2?(c/=2,a++):c<1&&(c*=2,a--),Math.log(c)+(a+r)*Math.LN2}function vt(t){return Number.isFinite(t)?(t=v(t),t<=0||t>=2**27?NaN:t):NaN}function qn(t,e,n){if(Number.isNaN(t)||Number.isNaN(e))return NaN;if(e=vt(e),Number.isNaN(e))return NaN;if(F(t))return C(n);t=v(t);let r=e*(e+1)/2;if(t<0||t>r)return C(n);let o=Math.min(t,r-t),[i,a]=yt(e,o,!1);return It(i,a,n)}function Ae(t,e,n,r){let o=e*(e+1)/2,i=t,a=o-t-1,s=n?i:a,c=n?a:i;if(s<=c){let[f,p]=yt(e,s,!0);return It(f,p,r)}let[u,l]=yt(e,c,!0),h=It(u,l,!1);return r?Math.log1p(-h):1-h}function Wn(t,e,n,r){if(Number.isNaN(t)||Number.isNaN(e))return NaN;if(e=vt(e),Number.isNaN(e))return NaN;let o=Q(t),i=e*(e+1)/2;return o<0?S(n,r):o>=i?T(n,r):Ae(o,e,n,r)}function $n(t,e,n,r){if(Number.isNaN(t)||Number.isNaN(e))return NaN;if(e=vt(e),Number.isNaN(e))return NaN;let o=e*(e+1)/2,i=L(t,0,o,n,r);if(i!==void 0)return i;let a=o/2,s=Math.sqrt(e*(e+1)*(2*e+1)/24),c=a+s*B(t,{lowerTail:n,logP:r});return j({p:t,lowerTail:n,logP:r,cdf:(u,l,h)=>u<0?S(l,h):u>=o?T(l,h):Ae(u,e,l,h),y0:Number.isFinite(c)?c:a,lo:0,hi:o})}function co(t,e,n={}){y(n,Sn,"dsignrank");let r=n.log??!1;return E(t,o=>qn(o,e,r))}function uo(t,e,n={}){y(n,Tn,"psignrank");let{lowerTail:r=!0,logP:o=!1}=n;return E(t,i=>Wn(i,e,r,o))}function lo(t,e,n={}){y(n,Pn,"qsignrank");let{lowerTail:r=!0,logP:o=!1}=n;return E(t,i=>$n(i,e,r,o))}var On=["log"],Dn=["lowerTail","logP"],Yn=["lowerTail","logP"],Re=960,Se=2**996,Kn=2**25,Fe=2**29,Hn=2**760,Te=200,Xn=2**-969,ct=134217729,$=new Map,Bn=2**21,ut=0;function Le(t,e,n){if(n+1>Kn)throw new RangeError(`wilcox: m = ${t}, n = ${e} needs too large a table (${n+1} entries)`);if(t*(n+1)>Fe)throw new RangeError(`wilcox: m = ${t}, n = ${e} needs ${t*(n+1)} steps for a table of ${n+1} entries (at most 2^29)`);let r=new Float64Array(n+1),o=new Float64Array(n+1);r[0]=2**Re;let i=Re,a=NaN,s=n+1;for(let f=1;f<=t;f++){let p=Math.min(s-1,f*e),M=e+f,N=ct*f,g=N-(N-f),I=f-g;N=ct*M;let d=N-(N-M),m=M-d;for(let b=0;b<=p;b++){let x=r[b];if(x===0)continue;if(!(Math.abs(x)<=Se)){s=b,p=b-1;break}let P=x*f;N=ct*x;let A=N-(N-x),H=x-A,pn=A*g-P+A*I+H*g+H*I+o[b]*f,X=P/M,Qt=X*M;N=ct*X;let gt=N-(N-X),jt=X-gt,mn=gt*d-Qt+gt*m+jt*d+jt*m,Gt=(P-Qt-mn+pn)/M,dt=X+Gt;o[b]=Gt-(dt-X),r[b]=dt,Math.abs(dt)<Xn&&Number.isNaN(a)&&(a=i)}let w=e+f;for(let b=p;b>=w;b--)Pe(r,o,b,b-w,-1);for(let b=f;b<=p;b++)Pe(r,o,b,b-f,1);let _=Math.min(p,Math.floor(f*e/2));for(;_>=0&&r[_]>0&&r[_]<Hn;){let b=2**Te;for(let x=0;x<=p;x++)r[x]*=b,o[x]*=b;i+=Te}}let c=new Float64Array(n+1),u=0,l=0;for(let f=0;f<s;f++){let p=r[f];if(!(Math.abs(p)<=Se)){s=f;break}let M=u+p,N=M-u,g=u-(M-N)+(p-N);g+=l+o[f],u=M+g,l=g-(u-M),c[f]=u}let h=Number.isNaN(a)?0:2**Math.min(1023,-909+Math.ceil(Math.log2(t*(n+1)))+i-a);return{m:t,n:e,len:n+1,prob:r,cum:c,scale:i,minTrusted:h,valid:s}}function Pe(t,e,n,r,o){let i=t[n],a=o*t[r],s=i+a,c=s-i,u=i-(s-c)+(a-c);u+=e[n]+o*e[r];let l=s+u;e[n]=u-(l-s),t[n]=l}function Ce(t,e,n,r=!1){let o=`${t},${e}${r?",low":""}`,i=$.get(o);if(i!==void 0&&i.len>n)return $.delete(o),$.set(o,i),i;let a=Math.floor(t*e/2),s=i===void 0?0:Math.min(2*i.len,Math.floor(Fe/t)-1),c=Math.min(a,Math.max(n,s));return qe(o,Le(t,e,c),i)}function qe(t,e,n){n!==void 0&&($.delete(t),ut-=n.len),$.set(t,e),ut+=e.len;for(let[r,o]of $){if(ut<=Bn||r===t)break;$.delete(r),ut-=o.len}return e}function _t(t,e,n,r){t>e&&([t,e]=[e,t]);let o=u=>{if(n>=u.valid)throw new RangeError(`wilcox: the exact distribution for m = ${t}, n = ${e} cannot be computed accurately at ${n} (from ${u.valid} on, near the center of large samples)`);return(r?u.cum:u.prob)[n]},i=(u,l)=>n===u.len-1||l>=(r?(n+1)*u.minTrusted:u.minTrusted),a=Ce(t,e,n),s=o(a);if(i(a,s))return[s,a];if(a=Ce(t,e,n,!0),s=o(a),i(a,s))return[s,a];let c=`${t},${e},low`;return a=qe(c,Le(t,e,n),$.get(c)),[o(a),a]}var Qn=.6931471803691238,jn=19082149292705877e-26;function At(t,e,n){let r=-e.scale,o=Math.trunc(r/2),i=t*2**o*2**(r-o);if(!n)return i;if(i>=1e-300)return Math.log(i);let a=Math.floor(Math.log2(t)),s=Math.trunc(a/2),c=t*2**-s*2**-(a-s);return c>=2?(c/=2,a++):c<1&&(c*=2,a--),(a+r)*Qn+(Math.log(c)+(a+r)*jn)}function Rt(t,e){if(!(!Number.isFinite(t)||!Number.isFinite(e))&&(t=v(t),e=v(e),!(t<=0||e<=0||t*e>2**53)))return t*e===2**53&&BigInt(t)*BigInt(e)!==2n**53n?void 0:[t,e]}function Gn(t,e,n,r){if(Number.isNaN(t)||Number.isNaN(e)||Number.isNaN(n))return NaN;let o=Rt(e,n);if(o===void 0)return NaN;if([e,n]=o,F(t))return C(r);t=v(t);let i=e*n;if(t<0||t>i)return C(r);let a=Math.min(t,i-t),[s,c]=_t(e,n,a,!1);return At(s,c,r)}function We(t,e,n,r,o){let i=e*n,a=r?t:i-t-1,s=r?i-t-1:t;if(a<=s){let[h,f]=_t(e,n,a,!0);return At(h,f,o)}let[c,u]=_t(e,n,s,!0),l=At(c,u,!1);return o?Math.log1p(-l):1-l}function Un(t,e,n,r,o){if(Number.isNaN(t)||Number.isNaN(e)||Number.isNaN(n))return NaN;let i=Rt(e,n);if(i===void 0)return NaN;[e,n]=i;let a=Q(t);return a<0?S(r,o):a>=e*n?T(r,o):We(a,e,n,r,o)}function Vn(t,e,n,r,o){if(Number.isNaN(t)||Number.isNaN(e)||Number.isNaN(n))return NaN;let i=Rt(e,n);if(i===void 0)return NaN;[e,n]=i;let a=e*n,s=L(t,0,a,r,o);if(s!==void 0)return s;let c=a/2,u=Math.sqrt(a*(e+n+1)/12),l=c+u*B(t,{lowerTail:r,logP:o});return j({p:t,lowerTail:r,logP:o,cdf:(h,f,p)=>h<0?S(f,p):h>=a?T(f,p):We(h,e,n,f,p),y0:Number.isFinite(l)?l:c,lo:0,hi:a})}function bo(t,e,n,r={}){y(r,On,"dwilcox");let o=r.log??!1;return E(t,i=>Gn(i,e,n,o))}function wo(t,e,n,r={}){y(r,Dn,"pwilcox");let{lowerTail:o=!0,logP:i=!1}=r;return E(t,a=>Un(a,e,n,o,i))}function xo(t,e,n,r={}){y(r,Yn,"qwilcox");let{lowerTail:o=!0,logP:i=!1}=r;return E(t,a=>Vn(a,e,n,o,i))}var Zn=["nranges","lowerTail","logP"],zn=["nranges","lowerTail","logP"],D=128,et=Number.EPSILON,Jn=256,$t=Float64Array.from({length:2*D+1},(t,e)=>Math.cos(Math.PI*e/D));function kn(t){let e=new Float64Array(t+1);for(let n=0;n<=t;n++){let r=0;for(let o=0;o<=t;o+=2)r+=(o===0||o===t?.5:1)*$t[o*n%(2*t)*(D/t)]*2/(1-o*o);e[n]=(n===0||n===t?.5:1)*2*r/t}return e}var tr=new Map([16,32,64,128].map(t=>[t,kn(t)]));function er(t,e){let n=tr.get(e),r=D/e,o=0,i=0;for(let s=0;s<=e;s++)o+=n[s]*t[s],i+=Math.abs(n[s]*t[s]);let a=0;for(let s=e-7;s<=e;s++){let c=.5*(t[0]+(s%2===0?t[e]:-t[e]));for(let u=1;u<e;u++)c+=t[u]*$t[s*u%(2*e)*r];c*=2/e,s===e&&(c*=.5),a=Math.max(a,Math.abs(c))}return{integral:o,tail:a,scale:i}}var tt=class{f;a;b;noise;c;h;values=new Float64Array(D+1);have=new Uint8Array(D+1);N=0;integral=0;error=1/0;constructor(e,n,r,o){this.f=e,this.a=n,this.b=r,this.noise=o,this.c=.5*(n+r),this.h=.5*(r-n)}advance(e){let n=D/e,r=new Float64Array(e+1);for(let i=0;i<=e;i++){let a=i*n;this.have[a]||(this.values[a]=this.f(this.c+this.h*$t[a]),this.have[a]=1),r[i]=this.values[a]}let o=er(r,e);this.N=e,this.integral=o.integral*this.h,this.error=Math.max(o.tail*4/e,this.noise*o.scale)*Math.abs(this.h)}};function ht(t,e,n,r=4*et){let o=[];for(let a=0;a+1<e.length;a++){let s=new tt(t,e[a],e[a+1],r);s.advance(16),o.push(s)}for(let a=0;a<40;a++){let s=0;for(let f of o)s+=f.integral;let c=n*Math.abs(s)/o.length,u=!0,l=o.length,h=[];for(let f of o){if(f.error<=c||f.error<=r*Math.abs(f.integral)){h.push(f);continue}if(u=!1,f.N<D)f.advance(2*f.N),h.push(f);else if(l>=Jn)h.push(f);else{l++;let p=new tt(t,f.a,f.c,r),M=new tt(t,f.c,f.b,r);p.advance(16),M.advance(16),h.push(p,M)}}if(o=h,u)break}let i=0;for(let a of o)i+=a.integral;return i}function De(t,e,n){let r=Math.max(1,Math.ceil((e-t)/n));return Array.from({length:r+1},(o,i)=>i===r?e:t+(e-t)*i/r)}var Ye=2e-15,Ke=1e-16,nr={lowerTail:!1},rr={logP:!0},or={lowerTail:!1,logP:!0},rt=.9189385332046728,Mt=t=>R(t),U=t=>R(t,nr),Ot=t=>R(t,rr),Dt=t=>R(t,or),ir=.3989422804014327;function V(t){let e=Math.round(t*16)/16,n=t-e;return ir*Math.exp(-.5*e*e)*Math.exp(-.5*n*(t+e))}var Pt=[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],He=[.362683783378362,.31370664587788727,.22238103445337448,.10122853629037626];function ar(t,e){let n=t-.5*e,r=.5*e,o=0;for(let i=0;i<4;i++)o+=He[i]*(V(n-r*Pt[i])+V(n+r*Pt[i]));return o*r}function sr(t,e){let n=t-.5*e,r=.5*e,o=0;for(let i=0;i<4;i++){let a=r*Pt[i];o+=He[i]*(Math.exp(n*a-a*a/2)+Math.exp(-n*a-a*a/2))}return-rt-n*n/2+Math.log(o*r)}var Yt=(t,e)=>e*Math.max(1,Math.abs(t),Math.abs(t-e))<.5;function Z(t,e){let n=t-e,r=n-t,o=t-(n-r)+(-e-r);return{ah:n,al:o}}function nt(t,e){return Mt(t)+V(t)*e}function cr(t,e){return U(t)-V(t)*e}function Xe(t,e){if(Yt(t,e))return ar(t,e);let{ah:n,al:r}=Z(t,e);return n>=0?cr(n,r)-U(t):t<=0?Mt(t)-nt(n,r):1-nt(n,r)-U(t)}function ur(t,e,n){if(t>0&&t-e<0&&!Yt(t,e)){let{ah:o,al:i}=Z(t,e);return Math.exp(n*Math.log1p(-(nt(o,i)+U(t))))}let r=Xe(t,e);return r>0?r**n:0}function lr(t,e){return t>0?Math.exp(e*Math.log1p(-U(t))):Mt(t)**e}function Be(t,e){let{ah:n,al:r}=Z(t,e),o=Ot(n);return o+r*Math.exp(-rt-n*n/2-o)}function fr(t,e){let{ah:n,al:r}=Z(t,e),o=Dt(n);return o-r*Math.exp(-rt-n*n/2-o)}function Qe(t,e){if(Yt(t,e))return sr(t,e);if(t-e>=0){let i=fr(t,e);return i+Math.log(-Math.expm1(Dt(t)-i))}if(t<=0){let i=Ot(t);return i+Math.log(-Math.expm1(Be(t,e)-i))}let{ah:r,al:o}=Z(t,e);return Math.log1p(-nt(r,o)-U(t))}var je=2,St=1e-18;function Ge(t,e,n){let r=De(e,n,je),o=r.map(t),i=0;for(let f=1;f<o.length;f++)o[f]>o[i]&&(i=f);let a=o[i];if(!(a>0))return 0;let s=Math.max(i-1,0),c=Math.min(i+1,o.length-1);for(;s>0&&o[s]>a*St;)s--;for(;c<o.length-1&&o[c]>a*St;)c++;let u=a*St,l=r[s],h=r[c];if(o[s]<=u){let f=r[s+1];for(let p=0;p<2;p++){let M=.5*(l+f);t(M)<=u?l=M:f=M}}if(o[c]<=u){let f=r[c-1];for(let p=0;p<2;p++){let M=.5*(h+f);t(M)<=u?h=M:f=M}}return ht(t,[l,h],Ke)}function Ue(t,e,n){let r=De(e,n,je),o=r.map(t),i=0;for(let m=1;m<o.length;m++)o[m]>o[i]&&(i=m);if(!(o[i]>-1/0))return-1/0;let a=r[Math.max(i-1,0)],s=r[Math.min(i+1,r.length-1)],c=(Math.sqrt(5)-1)/2,u=s-c*(s-a),l=a+c*(s-a),h=t(u),f=t(l);for(let m=0;m<80&&s-a>1e-12*Math.max(1,Math.abs(a));m++)h<f?(a=u,u=l,h=f,l=a+c*(s-a),f=t(l)):(s=l,l=u,f=h,u=s-c*(s-a),h=t(u));let p=h>f?u:l,M=Math.max(h,f);o[i]>M&&(p=r[i],M=o[i]);let N=m=>{let w=m<0?e:n,_=Math.max(1e-6,.001*(r[1]-r[0])),b=p;for(;;){let x=p+m*_;if(m<0?x<=w:x>=w)return w;if(t(x)<M-46){let P=x;for(let A=0;A<6;A++){let H=.5*(b+P);t(H)<M-46?P=H:b=H}return P}b=x,_*=2}},g=N(-1),I=N(1),d=[...new Set([g,p,I])].sort((m,w)=>m-w);return M+Math.log(ht(m=>Math.exp(t(m)-M),d,Ke,4*et*Math.max(1,Math.abs(M))))}var Kt=-10,Ht=10;function hr(t,e){return t<=0?0:e*Ge(n=>V(n)*ur(n,t,e-1),Kt,Ht)}function Ve(t,e){if(t<=0)return 1;let n=i=>{let a=Mt(i);if(a===0)return 0;let{ah:s,al:c}=Z(i,t),u=nt(s,c),l=u<.5*a?-Math.expm1((e-1)*Math.log1p(-u/a)):-Math.expm1((e-1)*Math.log(Xe(i,t)/a));return V(i)*lr(i,e-1)*l};if(t>60)return 0;let[r,o]=Ze(t);return e*Ge(n,r,o)}function Ze(t){return t>40?[t/2-15,t/2+15]:[Kt,t+Ht]}function Mr(t,e){if(t>100)return-Math.exp(ze(t,e));let n=r=>-rt-r*r/2+(e-1)*Qe(r,t);return Math.log(e)+Ue(n,Kt,Ht)}function ze(t,e){if(t>100){let i=e*(e-1);return(Number.isFinite(i)?Math.log(i):Math.log(e)+Math.log(e-1))+Dt(t/Math.SQRT2)}let n=i=>{let a=Ot(i),s=Be(i,t)-a,c;return s<-40?c=Math.log(e-1)+s:s<-Math.LN2?c=Math.log(-Math.expm1((e-1)*Math.log1p(-Math.exp(s)))):c=Math.log(-Math.expm1((e-1)*(Qe(i,t)-a))),-rt-i*i/2+(e-1)*a+c},[r,o]=Ze(t);return Math.log(e)+Ue(n,r,o)}function pr(t,e){let n=-1/0;for(let r of e)n=Math.max(n,t(r));for(let r=0;r+1<e.length;r++)n=Math.max(n,t(.5*(e[r]+e[r+1])));if(n===-1/0)return-1/0;if(et*Math.abs(n)>1)return n;for(let r=0;r<4;r++){let o=n,i=ht(a=>{let s=t(a);return s>o&&(o=s),Math.exp(s-n)},e,Ye,8*et*Math.max(1,Math.abs(n)));if(Number.isFinite(i)&&o-n<300)return n+Math.log(i);n=o}return NaN}var O=32,mr=1e-15,G=Math.log(.01),pt=Math.log(20),Je=Math.log(40),ke=Float64Array.from({length:2*O+1},(t,e)=>Math.cos(Math.PI*e/O));function gr(t,e){let n=new Float64Array(e+1);for(let r=0;r<=e;r++){let o=.5*(t[0]+(r%2===0?t[e]:-t[e]));for(let i=1;i<e;i++)o+=t[i]*ke[r*i%(2*e)];o*=2/e,(r===0||r===e)&&(o*=.5),n[r]=o}return n}function Tt(t,e,n){let r=[],o=[[e,n,0]];for(;o.length>0;){let[i,a,s]=o.pop(),c=.5*(i+a),u=.5*(a-i),l=new Float64Array(O+1),h=1/0;for(let M=0;M<=O;M++)l[M]=t(c+u*ke[M]),h=Math.min(h,Math.max(1,Math.abs(l[M])));let f=gr(l,O),p=0;for(let M=O-3;M<=O;M++)p=Math.max(p,Math.abs(f[M]));p<=mr*h||s>=14||!l.every(Number.isFinite)?r.push({a:i,b:a,coef:f}):o.push([c,a,s+1],[i,c,s+1])}return r.sort((i,a)=>i.a-a.a)}function Ct(t,e){let n=0,r=t.length-1;for(;n<r;){let l=n+r+1>>1;t[l].a<=e?n=l:r=l-1}let{a:o,b:i,coef:a}=t[n],s=(2*e-o-i)/(i-o),c=0,u=0;for(let l=O;l>=1;l--){let h=2*s*c-u+a[l];u=c,c=h}return s*c-u+a[0]}var k=new Map,dr=64,tn=Math.log(1e-10);function en(t){let e=k.get(t);if(e!==void 0)return e;let n=o=>{let i=hr(o,t);return i>1e-290?Math.log(i):Mr(o,t)},r=o=>{let i=Math.exp(o);return Ve(i,t)*nn(i)};return e={logW:Tt(o=>n(Math.exp(o)),G,pt),scaledWc:Tt(r,G,Je),smallW:Tt(o=>n(Math.exp(o))-(t-1)*o,tn,G)},k.size>=dr&&k.delete(k.keys().next().value),k.set(t,e),e}function nn(t){let e=t*t,n=134217729*t,r=n-(n-t),o=t-r,i=r*r-e+2*r*o+o*o;return Math.exp(e/4)*(1+i/4)}function rn(t,e){let n=Math.log(t);if(n>=pt)return 0;let r=en(e);return n>=G?Ct(r.logW,n):Ct(r.smallW,Math.max(n,tn))+(e-1)*n}function Ft(t,e){return Math.log(t)>=pt?1:Math.exp(rn(t,e))}function Lt(t,e){let n=Math.log(t);return n>=G&&n<=Je?Ct(en(e).scaledWc,n)/nn(t):n<G?1-Ft(t,e):Ve(t,e)}function lt(t,e,n,r){if(!r){let i=Math.min(Ft(t,e),1);return n===1?i:i**n}let o=Math.min(Lt(t,e),1);return o<=.5?n===1?o:-Math.expm1(n*Math.log1p(-o)):1-Math.min(Ft(t,e),1)**n}function qt(t,e,n,r){if(!r)return n*(Math.log(t)<pt?rn(t,e):Math.log1p(-Math.min(Lt(t,e),1)));let o=Math.min(Lt(t,e),1),i=o>1e-290?Math.log(o):ze(t,e);return n===1?i:i<-700?Math.log(n)+i:Math.log(-Math.expm1(n*Math.log1p(-Math.exp(i))))}function Wt(t,e,n,r,o){if(n===1/0||an(t,e,n,r))return lt(t,e,r,o);let i=n/2,a=on(i);return ht(c=>{let u=Math.exp(a(c));return u===0?0:u*lt(t*Math.exp(.5*c),e,r,o)},sn(t,e,n,r,o),Ye)}function on(t){let e=.5*Math.log(t/(2*Math.PI))-kt(t);return n=>{let r;if(Math.abs(n)<.5){let o=n*n/2;r=o;for(let i=3;i<60&&(o*=n/i,r+=o,!(Math.abs(o)<1e-17*r));i++);}else r=Math.expm1(n)-n;return e-t*r}}function an(t,e,n,r){let o=Math.max((e-1)*r,t*t,1);return o*o<1e-17*n}function Nr(t,e,n,r,o){if(n===1/0||an(t,e,n,r))return qt(t,e,r,o);let i=on(n/2),a=Math.log(t);return pr(c=>i(c)+qt(Math.exp(a+.5*c),e,r,o),sn(t,e,n,r,o,!0))}function sn(t,e,n,r,o,i=!1){let a=n/2,s=a,c;if(o){let m=2*Math.log(t)-Math.log(4*a);c=-(m>30?m:Math.log1p(Math.exp(m)))}else s=a+(e-1)*r/2,c=Math.log1p((e-1)*r/(2*a));let u=(m,w)=>[m-9/Math.sqrt(w)-41/w,m+9/Math.sqrt(w)+Math.log1p(41/w)],[l,h]=u(0,a),[f,p]=u(c,s),M=i?Math.min(l,f):Math.max(Math.min(l,f),-740-Math.log(a)),N=Math.max(h,p),g=1/Math.sqrt(a),I=1/Math.sqrt(s),d=[M,Math.min(-4*g,c-4*I),Math.max(4*g,c+4*I),N];return[...new Set(d.map(m=>Math.min(Math.max(m,M),N)))].sort((m,w)=>m-w)}function cn(t,e,n){return t>=2&&e>=2&&n>=1&&Number.isFinite(t)&&Number.isFinite(n)&&!Number.isNaN(e)}function ft(t,e,n,r,o,i){if(t<$e){let s=ft($e,e,n,r,!0,!0)+(e-1)*r*Math.log(t*10715086071862673e285);return o?i?s:Math.exp(s):i?-Math.exp(s):-Math.expm1(s)}let a;return K!==void 0&&K.q===t&&K.k===e&&K.df===n&&K.r===r?a=K.tail:(a=br(t,e,n,r,!o),K={q:t,k:e,df:n,r,tail:a}),a.upper===!o?i?a.log:a.value:i?Math.log1p(-a.value):1-a.value}var K,$e=2**-1e3;function br(t,e,n,r,o){let i=o;n!==1/0&&lt(t,e,r,i)>.5&&(i=!i);let a=Wt(t,e,n,r,i);if(a>.5){let s=Wt(t,e,n,r,!i);s<a&&(a=s,i=!i)}if(a<1e-290){let s=Nr(t,e,n,r,i);return{upper:i,value:Math.exp(s),log:s}}return{upper:i,value:a,log:Math.log(a)}}function wr(t,e,n,r,o,i){return[t,e,n,r].some(Number.isNaN)?NaN:cn(e,n,r)?t<=0?S(o,i):t===1/0?T(o,i):ft(t,e,n,r,o,i):NaN}function xr(t,e,n,r,o,i){if([t,e,n,r].some(Number.isNaN))return NaN;if(!cn(e,n,r))return NaN;let a=L(t,0,1/0,o,i);if(a!==void 0)return a;let{lower:s,logTarget:c,linearTarget:u}=Jt(t,o,i),l=f=>p=>{let M=Math.exp(p);if(u!==void 0&&u>1e-290){let g=f===1/0?Wt(M,e,f,r,!s):ft(M,e,f,r,s,!1);if(g>0)return Math.log(g/u)}return(f===1/0?Er(M,e,r,s):ft(M,e,f,r,s,!0))-c},h=Oe(l(1/0),Math.log(3),s);return Math.exp(n===1/0?h:Oe(l(n),h,s))}function Er(t,e,n,r){let o=lt(t,e,n,!r);return o>1e-290?Math.log(o):qt(t,e,n,!r)}function Oe(t,e,n){let r=e,o=t(r);if(o===0)return r;let i=o>0===n?-1:1,a=.05,s=r+i*a,c=t(s),u=NaN;for(let l=0;l<200&&Math.sign(c)===Math.sign(o)&&c!==0;l++){if(Math.abs(u-s)<.001)return s;for(r=s,o=c,a*=2,s=(r+i*a-u)*i>=0?.5*(r+u):r+i*a,c=t(s);!Number.isFinite(c);){if(u=s,Math.abs(u-r)<.001)return r;s=.5*(r+u),c=t(s)}}return c===0?s:!Number.isFinite(c)||Math.sign(c)===Math.sign(o)?Number.isFinite(c)?s:r:yr(t,r,s,o,c)}function yr(t,e,n,r,o){let i=e,a=r,s=n-e,c=s;for(let u=0;u<100;u++){Math.sign(o)===Math.sign(a)&&(i=e,a=r,s=n-e,c=s),Math.abs(a)<Math.abs(o)&&(e=n,n=i,i=e,r=o,o=a,a=r);let l=2*et*Math.abs(n)+1e-300,h=.5*(i-n);if(Math.abs(h)<=l||o===0)return n;if(Math.abs(c)>=l&&Math.abs(r)>Math.abs(o)){let f=o/r,p,M;if(e===i)p=2*h*f,M=1-f;else{let N=r/a,g=o/a;p=f*(2*h*N*(N-g)-(n-e)*(g-1)),M=(N-1)*(g-1)*(f-1)}p>0?M=-M:p=-p,2*p<Math.min(3*h*M-Math.abs(l*M),Math.abs(c*M))?(c=s,s=p/M):(s=h,c=h)}else s=h,c=h;e=n,r=o,n+=Math.abs(s)>l?s:h>0?l:-l,o=t(n)}return n}function Ro(t,e,n,r={}){y(r,Zn,"ptukey");let{nranges:o=1,lowerTail:i=!0,logP:a=!1}=r;return E(t,s=>wr(s,e,n,o,i,a))}function So(t,e,n,r={}){y(r,zn,"qtukey");let{nranges:o=1,lowerTail:i=!0,logP:a=!1}=r;return E(t,s=>xr(s,e,n,o,i,a))}function Xt(t){let e=[],n=[];for(let r=1;r<=t/2;r++){let o=Math.cos(Math.PI*(r-.25)/(t+.5)),i=0;for(let a=0;a<100;a++){let s=1,c=o;for(let l=2;l<=t;l++)[s,c]=[c,((2*l-1)*o*c-(l-1)*s)/l];i=t*(o*c-s)/(o*o-1);let u=c/i;if(o-=u,Math.abs(u)<=1e-17)break}e.push(o),n.push(2/((1-o*o)*i*i))}return{x:e,w:n}}var Ir=[Xt(6),Xt(12),Xt(20)],Bt=2*Math.PI,Y=t=>R(t,{lowerTail:!1});function vr(t,e,n){if(n===1)return Y(Math.max(t,e));if(n===-1)return t>=-e?0:t>=0?Y(t)-Y(-e):R(-e)-R(t);let{x:r,w:o}=Ir[Math.abs(n)<.3?0:Math.abs(n)<.75?1:2],i=t*e;if(Math.abs(n)<.925){let g=(t*t+e*e)/2,I=Math.asin(n),d=0;for(let m=0;m<r.length;m++)for(let w of[1-r[m],1+r[m]]){let _=Math.sin(I*w/2);d+=o[m]*Math.exp((_*i-g)/(1-_*_))}return d*I/(2*Bt)+Y(t)*Y(e)}let a=n<0?-e:e,s=n<0?-i:i,c=(1-n)*(1+n),u=Math.sqrt(c),l=(t-a)**2,h=(4-s)/8,f=(12-s)/16,p=u*Math.exp(-(l/c+s)/2)*(1-h*(l-c)*(1-f*l/5)/3+h*f*c*c/5);if(s>-160){let g=Math.sqrt(l);p-=Math.exp(-s/2)*Math.sqrt(Bt)*R(-g/u)*g*(1-h*l*(1-f*l/5)/3)}let M=u/2;for(let g=0;g<r.length;g++)for(let I of[1-r[g],1+r[g]]){let d=(M*I)**2,m=Math.sqrt(1-d);p+=M*o[g]*(Math.exp(-l/(2*d)-s/(1+m))/m-Math.exp(-(l/d+s)/2)*(1+h*d*(1+f*d)))}let N=-p/Bt;return n>0?N+Y(Math.max(t,a)):-N+(a>t?R(a)-R(t):0)}function mt(t,e,n){return t===1/0||e===1/0?0:t===-1/0?e===-1/0?1:Y(e):e===-1/0?Y(t):vr(t,e,n)}function Co(t,e,n){if(t.length!==2||e.length!==2)throw new TypeError("'lower' and 'upper' must have length 2");if(!(n>=-1&&n<=1))throw new RangeError("'rho' must be in [-1, 1]");let[r,o]=t,[i,a]=e;if([r,o,i,a].some(Number.isNaN))return NaN;if([r,o,i,a]=[r,o,i,a].map(c=>c>40?1/0:c<-40?-1/0:c),!(r<i&&o<a))return 0;r+i+o+a<0&&([r,o,i,a]=[-i,-a,-r,-o]);let s=mt(r,o,n)-mt(r,a,n)-mt(i,o,n)+mt(i,a,n);return Math.max(0,s)}var _r=["size","replace","prob"],Ar=["size","replace","prob"];function $o(t,e={}){return y(e,Ar,"sampleInt"),un(t,e).map(n=>n-1)}function un(t,e){if(!Number.isFinite(t)||t<0||t>45e14)throw new RangeError("n must be a non-negative number up to 4.5e15");t=Math.trunc(t);let{replace:n=!1,prob:r}=e,o=e.size!==void 0,i=o?e.size:t;if(!Number.isFinite(i)||i<=-1)throw new RangeError("size must be a non-negative number");let a=Math.trunc(i);if(t===0&&a>0)throw new RangeError("cannot take a sample from an empty population");if(r!==void 0){if(a>=2**31)throw new RangeError("size must be less than 2^31 with prob");if(t>=2**31)throw new RangeError("n must be less than 2^31 with prob");if(r.length!==t)throw new TypeError("prob must have length n");let l=fn(r,a,n);if(n){let h=ln(l),f=new Array(a);for(let p=0;p<a;p++)f[p]=h();return f}if(a>t)throw new RangeError("cannot take a sample larger than the population when replace is false");return Tr(l,a)}if(!n&&a>t)throw new RangeError("cannot take a sample larger than the population when replace is false");if(!n&&t>1e7&&o&&a<=t/2){let l=new Set,h=[];for(;h.length<a;){let f=J(t);l.has(f)||(l.add(f),h.push(f+1))}return h}let s=new Array(a);if(n||a<2){for(let l=0;l<a;l++)s[l]=J(t)+1;return s}if(t>=2**31)throw new RangeError("n must be less than 2^31 to sample without replacement with size above n / 2");let c=new Int32Array(t);for(let l=0;l<t;l++)c[l]=l;let u=t;for(let l=0;l<a;l++){let h=J(u);s[l]=c[h]+1,c[h]=c[--u]}return s}function Oo(t,e){if(!Number.isFinite(t)||t<0||t>45e14)throw new RangeError("n must be a non-negative number up to 4.5e15");if(t=Math.trunc(t),t>=2**31)throw new RangeError("n must be less than 2^31 with prob");if(e.length!==t)throw new TypeError("prob must have length n");let n=ln(fn(e,0,!0));return()=>n()-1}function ln(t){let e=t.length,n=0;for(let r=0;r<e;r++)e*t[r]>.1&&n++;return n>200?Pr(t):Sr(t)}function Do(t,e={}){return y(e,_r,"sample"),un(t.length,e).map(n=>t[n-1])}function fn(t,e,n){let r=0,o=0;for(let i of t){if(!Number.isFinite(i))throw new RangeError("prob contains NaN or infinite values");if(i<0)throw new RangeError("prob contains negative values");i>0&&(o++,r+=i)}if(o===0||!n&&e>o)throw new RangeError("too few positive probabilities");if(r===1/0){let i=fe(t);r=0;for(let a of t)r+=a/i;return Float64Array.from(t,a=>a/i/r)}return Float64Array.from(t,i=>i/r)}function Rr(t,e){let n=t.length;if(n<=1)return;let r=c=>t[c-1],o=(n>>1)+1,i=n,a,s;for(;;){if(o>1)o=o-1,a=r(o),s=e[o-1];else if(a=r(i),s=e[i-1],t[i-1]=r(1),e[i-1]=e[0],--i===1){t[0]=a,e[0]=s;return}let c=o,u=o<<1;for(;u<=i;)u<i&&r(u)>r(u+1)&&++u,a>r(u)?(t[c-1]=r(u),e[c-1]=e[u-1],c=u,u+=u):u=i+1;t[c-1]=a,e[c-1]=s}}function hn(t){let e=new Int32Array(t.length);for(let n=0;n<t.length;n++)e[n]=n+1;return Rr(t,e),e}function Sr(t){let e=Float64Array.from(t),n=e.length,r=hn(e);for(let o=1;o<n;o++)e[o]+=e[o-1];return()=>{let o=q(),i=0;for(;i<n-1&&!(o<=e[i]);i++);return r[i]}}function Tr(t,e){let n=Float64Array.from(t),r=n.length,o=hn(n),i=new Array(e),a=1;for(let s=0,c=r-1;s<e;s++,c--){let u=a*q(),l=0,h=0;for(;h<c&&(l+=n[h],!(u<=l));h++);i[s]=o[h],a-=n[h];for(let f=h;f<c;f++)n[f]=n[f+1],o[f]=o[f+1]}return i}function Pr(t){let e=t.length,n=new Float64Array(e),r=new Int32Array(e),o=new Int32Array(e),i=-1,a=e;for(let c=0;c<e;c++)n[c]=t[c]*e,n[c]<1?o[++i]=c:o[--a]=c;if(i>=0&&a<e)for(let c=0;c<e-1;c++){let u=o[c],l=o[a];if(r[u]=l,n[l]+=n[u]-1,n[l]<1&&a++,a>=e)break}let s=he();return()=>{let c,u;return s?(u=q()*e,c=Math.trunc(u)):(c=J(e),u=c+q()),u<n[c]+c?c+1:r[c]+1}}var Cr=2**24;function Fr(t){let e=new Float64Array(t+1);for(let n=2;n<=t;n++)e[n]=e[n-1]+Math.log(n);return e}function Lr(t,e,n,r){let o=t.length,i=e.length,a=Array.from(e),s=0;for(let u of t)s+=u;for(let u=0;u<o-1;u++){let l=t[u],h=s;s-=l;let f=0;for(;f<i-1;f++){let p=a[f],M=h;h-=p;let N=M-l,g=N-p;if(M===0){for(let m=f;m<i-1;m++)r[u+m*o]=0;l=0;break}let I=q(),d;t:for(;;){d=Math.floor(l*(p/M)+.5);let m=Math.exp(n[l]+n[N]+n[h]+n[p]-n[M]-n[d]-n[p-d]-n[l-d]-n[g+d]);if(m>=I)break;if(m===0)throw new Error(`r2dtable: probability underflow at cell [${u}, ${f}]`);let w=m,_=m,b=d,x=!1,P=!1;for(;!(x&&P);){if(!x){let A=(p-d)*(l-d);if(A===0)x=!0;else if(d++,m=m*A/(d*(g+d)),w+=m,w>=I)break t}do{let A=b*(g+b);if(A===0){P=!0;break}if(b--,_=_*A/((p-b)*(l-b)),w+=_,w>=I){d=b;break t}}while(x)}I=w*q()}r[u+f*o]=d,l-=d,a[f]=a[f]-d}r[u+(i-1)*o]=l}let c=e[i-1];for(let u=0;u<o-1;u++)c-=r[u+(i-1)*o];for(let u=0;u<i-1;u++)r[o-1+u*o]=a[u];r[o-1+(i-1)*o]=c}function Mn(t,e){let n=Array.from(t,r=>Math.trunc(r));if(n.length<=1||n.some(r=>!(r>=0)||r>2147483647))throw new RangeError(`invalid argument '${e}'`);return n}function Ho(t,e,n){if(!(Number.isFinite(t)&&t>-1&&t<2**31))throw new RangeError("invalid argument 'n'");let r=Math.trunc(t),o=Mn(e,"r"),i=Mn(n,"c"),a=o.reduce((l,h)=>l+h,0);if(a!==i.reduce((l,h)=>l+h,0))throw new RangeError("arguments 'r' and 'c' must have the same sums");if(a>2147483647)throw new RangeError("the sum of 'r' must be at most 2147483647");if(r===0)return[];if(a>Cr)throw new RangeError("the sum of 'r' must be at most 16777216 (2^24) to generate tables");let s=Fr(a),c=new Int32Array(o.length*i.length),u=[];for(let l=0;l<r;l++)Lr(o,i,s,c),u.push(o.map((h,f)=>i.map((p,M)=>c[f+M*o.length])));return u}export{Dr as a,Yr as b,Kr as c,En as d,xt as e,In as f,Rn as g,Jr as h,kr as i,to as j,Wn as k,$n as l,co as m,uo as n,lo as o,Gn as p,Un as q,Vn as r,bo as s,wo as t,xo as u,Ro as v,So as w,Co as x,$o as y,Oo as z,Do as A,Cr as B,Fr as C,Lr as D,Ho as E};
1
+ /*! rStats.js 1.1.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
+ import{f as q,g as he,h as J}from"./chunk-QUTJEYDX.js";import{A as ue,B as le,a as ie,b as ae,c as se,f as j,z as ce}from"./chunk-DTJG2IL2.js";import{a as S,b as T,c as C,d as L,e as Jt,h as ne,i as re,l as oe}from"./chunk-GGJA3JRO.js";import{a as fe}from"./chunk-OG7UORIX.js";import{a as F,b as Q,c as v}from"./chunk-X4J6UJHN.js";import{A as kt,B as te,E as ee,e as E,r as R,s as B}from"./chunk-NDTJ23A6.js";import{b as Ut,c as Nt,d as ot,e as Vt,f as Zt,g as z,i as it,k as zt,l as y}from"./chunk-HUWOSLKE.js";var gn=["log","ncp"],dn=["lowerTail","logP","ncp"],Nn=["lowerTail","logP","ncp"];function Dr(t,e,n={}){y(n,gn,"dchisq");let{log:r=!1,ncp:o}=n;if(o!==void 0)return E(t,a=>ie(a,e,o,r));let i=e<0?NaN:e/2;return E(t,a=>ne(a,i,2,r))}function Yr(t,e,n={}){y(n,dn,"pchisq");let{lowerTail:r=!0,logP:o=!1,ncp:i}=n;if(i!==void 0)return E(t,s=>ae(s,e,i,r,o));let a=e<0?NaN:e/2;return E(t,s=>re(s,a,2,r,o))}function Kr(t,e,n={}){y(n,Nn,"qchisq");let{lowerTail:r=!0,logP:o=!1,ncp:i}=n;if(i!==void 0)return E(t,s=>se(s,e,i,r,o));let a=e<0?NaN:e/2;return E(t,s=>oe(s,a,2,r,o))}var bn=["log"],wn=["lowerTail","logP"],xn=["lowerTail","logP"];function bt(t,e,n,r){if(t===0&&e===0)return{e:[0,0],logDenom:0};if(t===0||e===0){let o=t+e,[i,a]=t===0?[r,n]:[n,r];return{e:a[0]<.1?ot(te(o,z([o,0],i)),z([o,0],a)):Vt(z([o,0],zt(i))),logDenom:0}}return ee(t,e,n,r)}function ge(t,e,n,r){let o=e+n,i=it([r,0],[o,0]),a=it([o-r,0],[o,0]),s=bt(t,e-t,i,a),c=bt(r-t,n-r+t,i,a),u=bt(r,o-r,i,a);return{e:Zt(ot(s.e,c.e),u.e),logDenom:s.logDenom+c.logDenom-u.logDenom}}function de(t,e){let[n,r]=t.e,o=e*Math.exp(-.5*t.logDenom);return n<700?Math.exp(-n)*(1-r)*o:Math.exp(700-n)*(1-r)*o*Math.exp(-700)}function Ne(t){return-t.e[0]-t.e[1]-.5*t.logDenom}function wt(t,e){return Ut(t,e)[1]===0}function at(t,e,n){return[Math.max(0,n-e),Math.min(n,t)]}function En(t,e,n,r,o){if([t,e,n,r].some(Number.isNaN))return NaN;if(![e,n,r].every(Number.isFinite)||F(e)||F(n)||F(r))return NaN;if(e=v(e),n=v(n),r=v(r),e<0||n<0||r<0||r>e+n)return NaN;if(Et(e,n,r))return ce(t,r,xt(e,n),o);if(F(t))return C(o);t=v(t);let[i,a]=at(e,n,r);if(t<i||t>a)return C(o);if(r===0)return o?0:1;if(!wt(e,n))return NaN;if(r===e+n)return o?0:1;let s=ge(t,e,n,r);return o?Ne(s):de(s,1)}function Me(t,e,n,r){return it(Nt(t,e),Nt(n,r))}function yn(t,e,n,r,o,i,a){let s=[1,0],c=[1,0],u=t;for(;!(o?u<=i:u>=a);){let l=o?Me(u,n-r+u,e-u+1,r-u+1):Me(e-u,r-u,u+1,n-r+u+1);s=z(s,l),c=ot(c,s),u+=o?-1:1;let h=l[0];if(h<1&&s[0]*h/(1-h)<c[0]*2**-60)break}return c[0]+c[1]}function be(t,e,n,r,o,i){let[a,s]=at(e,n,r),c=e+n,u=t*c<r*e,l=pe(t,e,n,r,u,a,s);if(l.value>.5){let h=pe(t,e,n,r,!u,a,s);h.value<l.value&&(l=h,u=!u)}return u===o?i?l.value>1e-300?Math.log(l.value):Ne(l.form)+Math.log(l.sum):l.value:i?Math.log1p(-l.value):1-l.value}function pe(t,e,n,r,o,i,a){let s=o?t:t+1,c=ge(s,e,n,r),u=yn(s,e,n,r,o,i,a);return{form:c,sum:u,value:de(c,u)}}function xt(t,e){return t>=e?1/(1+e/t):e/t===1/0?0:t/e/(1+t/e)}function Et(t,e,n){return n>0&&n<t*2**-60+e*2**-60}function we(t,e,n){if([t,e,n].every(Number.isFinite)&&(t=v(t),e=v(e),n=v(n),!(t<0||e<0||n<0||n>t+e)))return[t,e,n]}function In(t,e,n,r,o,i){if([t,e,n,r].some(Number.isNaN))return NaN;let a=we(e,n,r);if(a===void 0)return NaN;if([e,n,r]=a,Et(e,n,r))return ue(t,r,xt(e,n),o,i);let s=Q(t),[c,u]=at(e,n,r);if(s<c)return S(o,i);if(s>=u)return T(o,i);if(u>Ee||!wt(e,n))return NaN;let l=vn(s,e,n,r,c,u);if(l>_n)throw new RangeError(`phyper: m = ${e}, n = ${n}, k = ${r} needs about ${Math.round(l)} terms at q = ${t} (at most 2^26)`);return be(s,e,n,r,o,i)}function xe(t,e,n,r){return n*t/r*(e/r)*(r-n)/Math.max(r-1,1)}function me(t,e,n,r,o,i){let a=e?n-t:t-n,s=Math.sqrt(a*a+83*r);return Math.min(a>=0?83*r/(s+a):s-a,e?t-o:i-t)}function vn(t,e,n,r,o,i){let a=e+n,s=r*e/a,c=xe(e,n,r,a),u=t*a<r*e,l=u?t:t+1,h=me(l,u,s,c,o,i);return Math.abs(l-s)>=1?h:h+me(u?t+1:t,!u,s,c,o,i)}var _n=2**26,An=2**21,Ee=2**53;function Rn(t,e,n,r,o,i,a=!0){if([t,e,n,r].some(Number.isNaN))return NaN;let s=we(e,n,r);if(s===void 0)return NaN;if([e,n,r]=s,Et(e,n,r))return le(t,r,xt(e,n),o,i);let[c,u]=at(e,n,r),l=L(t,c,u,o,i);if(l!==void 0)return l;if(c===u)return c;if(u>Ee||!wt(e,n))return NaN;let h=e+n,f=r*e/h,p=Math.sqrt(xe(e,n,r,h));if(a&&p>An)throw new RangeError(`qhyper: m = ${e}, n = ${n}, k = ${r} has a standard deviation of about ${p.toPrecision(3)} (at most 2^21)`);let M=B(t,{lowerTail:o,logP:i}),N=f+p*M;return j({p:t,lowerTail:o,logP:i,cdf:(g,I,d)=>g<c?S(I,d):g>=u?T(I,d):be(g,e,n,r,I,d),y0:Number.isFinite(N)?N:f,lo:c,hi:u})}function Jr(t,e,n,r,o={}){y(o,bn,"dhyper");let i=o.log??!1;return E(t,a=>En(a,e,n,r,i))}function kr(t,e,n,r,o={}){y(o,wn,"phyper");let{lowerTail:i=!0,logP:a=!1}=o;return E(t,s=>In(s,e,n,r,i,a))}function to(t,e,n,r,o={}){y(o,xn,"qhyper");let{lowerTail:i=!0,logP:a=!1}=o;return E(t,s=>Rn(s,e,n,r,i,a))}var Sn=["log"],Tn=["lowerTail","logP"],Pn=["lowerTail","logP"],Cn=2**900,ye=-900,W=new Map,Fn=2**21,st=0,Ln=2**25;function ve(t,e){if(e+1>Ln)throw new RangeError(`signrank: n = ${t} needs too large a table (${e+1} entries)`);let n=new Float64Array(e+1);n[0]=1;let r=0,o=-1/0,i=Math.min(t,e);for(let u=1;u<=i;u++){for(let l=e;l>=u;l--)n[l]+=n[l-u];if(n[Math.min(e,Math.floor(u*(u+1)/4))]>Cn){let l=2**ye;for(let h=0;h<=e;h++)n[h]*=l;r-=ye,o=Math.max(o,r-1015+i-u)}}let a=new Float64Array(e+1),s=0,c=0;for(let u=0;u<=e;u++){let l=n[u]-c,h=s+l;c=h-s-l,s=h,a[u]=s}return{n:t,len:e+1,count:n,cum:a,scale:r,minTrusted:2**(o-r)}}function Ie(t,e,n=!1){let r=n?-t:t,o=W.get(r);if(o!==void 0&&o.len>e)return W.delete(r),W.set(r,o),o;let i=Math.floor(t*(t+1)/4),a=Math.min(i,Math.max(e,o===void 0?0:2*o.len));return _e(r,ve(t,a),o)}function _e(t,e,n){n!==void 0&&(W.delete(t),st-=n.len),W.set(t,e),st+=e.len;for(let[r,o]of W){if(st<=Fn||r===t)break;W.delete(r),st-=o.len}return e}function yt(t,e,n){let r=(a,s)=>e===a.len-1||s>=(n?(e+1)*a.minTrusted:a.minTrusted),o=Ie(t,e),i=(n?o.cum:o.count)[e];return r(o,i)?[i,o]:(o=Ie(t,e,!0),i=(n?o.cum:o.count)[e],r(o,i)?[i,o]:(o=_e(-t,ve(t,e),W.get(-t)),[(n?o.cum:o.count)[e],o]))}function It(t,e,n){let r=e.scale-e.n,o=Math.trunc(r/2),i=t*2**o*2**(r-o);if(!n)return i;if(i>=1e-300)return Math.log(i);let a=Math.floor(Math.log2(t)),s=Math.trunc(a/2),c=t*2**-s*2**-(a-s);return c>=2?(c/=2,a++):c<1&&(c*=2,a--),Math.log(c)+(a+r)*Math.LN2}function vt(t){return Number.isFinite(t)?(t=v(t),t<=0||t>=2**27?NaN:t):NaN}function qn(t,e,n){if(Number.isNaN(t)||Number.isNaN(e))return NaN;if(e=vt(e),Number.isNaN(e))return NaN;if(F(t))return C(n);t=v(t);let r=e*(e+1)/2;if(t<0||t>r)return C(n);let o=Math.min(t,r-t),[i,a]=yt(e,o,!1);return It(i,a,n)}function Ae(t,e,n,r){let o=e*(e+1)/2,i=t,a=o-t-1,s=n?i:a,c=n?a:i;if(s<=c){let[f,p]=yt(e,s,!0);return It(f,p,r)}let[u,l]=yt(e,c,!0),h=It(u,l,!1);return r?Math.log1p(-h):1-h}function Wn(t,e,n,r){if(Number.isNaN(t)||Number.isNaN(e))return NaN;if(e=vt(e),Number.isNaN(e))return NaN;let o=Q(t),i=e*(e+1)/2;return o<0?S(n,r):o>=i?T(n,r):Ae(o,e,n,r)}function $n(t,e,n,r){if(Number.isNaN(t)||Number.isNaN(e))return NaN;if(e=vt(e),Number.isNaN(e))return NaN;let o=e*(e+1)/2,i=L(t,0,o,n,r);if(i!==void 0)return i;let a=o/2,s=Math.sqrt(e*(e+1)*(2*e+1)/24),c=a+s*B(t,{lowerTail:n,logP:r});return j({p:t,lowerTail:n,logP:r,cdf:(u,l,h)=>u<0?S(l,h):u>=o?T(l,h):Ae(u,e,l,h),y0:Number.isFinite(c)?c:a,lo:0,hi:o})}function co(t,e,n={}){y(n,Sn,"dsignrank");let r=n.log??!1;return E(t,o=>qn(o,e,r))}function uo(t,e,n={}){y(n,Tn,"psignrank");let{lowerTail:r=!0,logP:o=!1}=n;return E(t,i=>Wn(i,e,r,o))}function lo(t,e,n={}){y(n,Pn,"qsignrank");let{lowerTail:r=!0,logP:o=!1}=n;return E(t,i=>$n(i,e,r,o))}var On=["log"],Dn=["lowerTail","logP"],Yn=["lowerTail","logP"],Re=960,Se=2**996,Kn=2**25,Fe=2**29,Hn=2**760,Te=200,Xn=2**-969,ct=134217729,$=new Map,Bn=2**21,ut=0;function Le(t,e,n){if(n+1>Kn)throw new RangeError(`wilcox: m = ${t}, n = ${e} needs too large a table (${n+1} entries)`);if(t*(n+1)>Fe)throw new RangeError(`wilcox: m = ${t}, n = ${e} needs ${t*(n+1)} steps for a table of ${n+1} entries (at most 2^29)`);let r=new Float64Array(n+1),o=new Float64Array(n+1);r[0]=2**Re;let i=Re,a=NaN,s=n+1;for(let f=1;f<=t;f++){let p=Math.min(s-1,f*e),M=e+f,N=ct*f,g=N-(N-f),I=f-g;N=ct*M;let d=N-(N-M),m=M-d;for(let b=0;b<=p;b++){let x=r[b];if(x===0)continue;if(!(Math.abs(x)<=Se)){s=b,p=b-1;break}let P=x*f;N=ct*x;let A=N-(N-x),H=x-A,pn=A*g-P+A*I+H*g+H*I+o[b]*f,X=P/M,Qt=X*M;N=ct*X;let gt=N-(N-X),jt=X-gt,mn=gt*d-Qt+gt*m+jt*d+jt*m,Gt=(P-Qt-mn+pn)/M,dt=X+Gt;o[b]=Gt-(dt-X),r[b]=dt,Math.abs(dt)<Xn&&Number.isNaN(a)&&(a=i)}let w=e+f;for(let b=p;b>=w;b--)Pe(r,o,b,b-w,-1);for(let b=f;b<=p;b++)Pe(r,o,b,b-f,1);let _=Math.min(p,Math.floor(f*e/2));for(;_>=0&&r[_]>0&&r[_]<Hn;){let b=2**Te;for(let x=0;x<=p;x++)r[x]*=b,o[x]*=b;i+=Te}}let c=new Float64Array(n+1),u=0,l=0;for(let f=0;f<s;f++){let p=r[f];if(!(Math.abs(p)<=Se)){s=f;break}let M=u+p,N=M-u,g=u-(M-N)+(p-N);g+=l+o[f],u=M+g,l=g-(u-M),c[f]=u}let h=Number.isNaN(a)?0:2**Math.min(1023,-909+Math.ceil(Math.log2(t*(n+1)))+i-a);return{m:t,n:e,len:n+1,prob:r,cum:c,scale:i,minTrusted:h,valid:s}}function Pe(t,e,n,r,o){let i=t[n],a=o*t[r],s=i+a,c=s-i,u=i-(s-c)+(a-c);u+=e[n]+o*e[r];let l=s+u;e[n]=u-(l-s),t[n]=l}function Ce(t,e,n,r=!1){let o=`${t},${e}${r?",low":""}`,i=$.get(o);if(i!==void 0&&i.len>n)return $.delete(o),$.set(o,i),i;let a=Math.floor(t*e/2),s=i===void 0?0:Math.min(2*i.len,Math.floor(Fe/t)-1),c=Math.min(a,Math.max(n,s));return qe(o,Le(t,e,c),i)}function qe(t,e,n){n!==void 0&&($.delete(t),ut-=n.len),$.set(t,e),ut+=e.len;for(let[r,o]of $){if(ut<=Bn||r===t)break;$.delete(r),ut-=o.len}return e}function _t(t,e,n,r){t>e&&([t,e]=[e,t]);let o=u=>{if(n>=u.valid)throw new RangeError(`wilcox: the exact distribution for m = ${t}, n = ${e} cannot be computed accurately at ${n} (from ${u.valid} on, near the center of large samples)`);return(r?u.cum:u.prob)[n]},i=(u,l)=>n===u.len-1||l>=(r?(n+1)*u.minTrusted:u.minTrusted),a=Ce(t,e,n),s=o(a);if(i(a,s))return[s,a];if(a=Ce(t,e,n,!0),s=o(a),i(a,s))return[s,a];let c=`${t},${e},low`;return a=qe(c,Le(t,e,n),$.get(c)),[o(a),a]}var Qn=.6931471803691238,jn=19082149292705877e-26;function At(t,e,n){let r=-e.scale,o=Math.trunc(r/2),i=t*2**o*2**(r-o);if(!n)return i;if(i>=1e-300)return Math.log(i);let a=Math.floor(Math.log2(t)),s=Math.trunc(a/2),c=t*2**-s*2**-(a-s);return c>=2?(c/=2,a++):c<1&&(c*=2,a--),(a+r)*Qn+(Math.log(c)+(a+r)*jn)}function Rt(t,e){if(!(!Number.isFinite(t)||!Number.isFinite(e))&&(t=v(t),e=v(e),!(t<=0||e<=0||t*e>2**53)))return t*e===2**53&&BigInt(t)*BigInt(e)!==2n**53n?void 0:[t,e]}function Gn(t,e,n,r){if(Number.isNaN(t)||Number.isNaN(e)||Number.isNaN(n))return NaN;let o=Rt(e,n);if(o===void 0)return NaN;if([e,n]=o,F(t))return C(r);t=v(t);let i=e*n;if(t<0||t>i)return C(r);let a=Math.min(t,i-t),[s,c]=_t(e,n,a,!1);return At(s,c,r)}function We(t,e,n,r,o){let i=e*n,a=r?t:i-t-1,s=r?i-t-1:t;if(a<=s){let[h,f]=_t(e,n,a,!0);return At(h,f,o)}let[c,u]=_t(e,n,s,!0),l=At(c,u,!1);return o?Math.log1p(-l):1-l}function Un(t,e,n,r,o){if(Number.isNaN(t)||Number.isNaN(e)||Number.isNaN(n))return NaN;let i=Rt(e,n);if(i===void 0)return NaN;[e,n]=i;let a=Q(t);return a<0?S(r,o):a>=e*n?T(r,o):We(a,e,n,r,o)}function Vn(t,e,n,r,o){if(Number.isNaN(t)||Number.isNaN(e)||Number.isNaN(n))return NaN;let i=Rt(e,n);if(i===void 0)return NaN;[e,n]=i;let a=e*n,s=L(t,0,a,r,o);if(s!==void 0)return s;let c=a/2,u=Math.sqrt(a*(e+n+1)/12),l=c+u*B(t,{lowerTail:r,logP:o});return j({p:t,lowerTail:r,logP:o,cdf:(h,f,p)=>h<0?S(f,p):h>=a?T(f,p):We(h,e,n,f,p),y0:Number.isFinite(l)?l:c,lo:0,hi:a})}function bo(t,e,n,r={}){y(r,On,"dwilcox");let o=r.log??!1;return E(t,i=>Gn(i,e,n,o))}function wo(t,e,n,r={}){y(r,Dn,"pwilcox");let{lowerTail:o=!0,logP:i=!1}=r;return E(t,a=>Un(a,e,n,o,i))}function xo(t,e,n,r={}){y(r,Yn,"qwilcox");let{lowerTail:o=!0,logP:i=!1}=r;return E(t,a=>Vn(a,e,n,o,i))}var Zn=["nranges","lowerTail","logP"],zn=["nranges","lowerTail","logP"],D=128,et=Number.EPSILON,Jn=256,$t=Float64Array.from({length:2*D+1},(t,e)=>Math.cos(Math.PI*e/D));function kn(t){let e=new Float64Array(t+1);for(let n=0;n<=t;n++){let r=0;for(let o=0;o<=t;o+=2)r+=(o===0||o===t?.5:1)*$t[o*n%(2*t)*(D/t)]*2/(1-o*o);e[n]=(n===0||n===t?.5:1)*2*r/t}return e}var tr=new Map([16,32,64,128].map(t=>[t,kn(t)]));function er(t,e){let n=tr.get(e),r=D/e,o=0,i=0;for(let s=0;s<=e;s++)o+=n[s]*t[s],i+=Math.abs(n[s]*t[s]);let a=0;for(let s=e-7;s<=e;s++){let c=.5*(t[0]+(s%2===0?t[e]:-t[e]));for(let u=1;u<e;u++)c+=t[u]*$t[s*u%(2*e)*r];c*=2/e,s===e&&(c*=.5),a=Math.max(a,Math.abs(c))}return{integral:o,tail:a,scale:i}}var tt=class{f;a;b;noise;c;h;values=new Float64Array(D+1);have=new Uint8Array(D+1);N=0;integral=0;error=1/0;constructor(e,n,r,o){this.f=e,this.a=n,this.b=r,this.noise=o,this.c=.5*(n+r),this.h=.5*(r-n)}advance(e){let n=D/e,r=new Float64Array(e+1);for(let i=0;i<=e;i++){let a=i*n;this.have[a]||(this.values[a]=this.f(this.c+this.h*$t[a]),this.have[a]=1),r[i]=this.values[a]}let o=er(r,e);this.N=e,this.integral=o.integral*this.h,this.error=Math.max(o.tail*4/e,this.noise*o.scale)*Math.abs(this.h)}};function ht(t,e,n,r=4*et){let o=[];for(let a=0;a+1<e.length;a++){let s=new tt(t,e[a],e[a+1],r);s.advance(16),o.push(s)}for(let a=0;a<40;a++){let s=0;for(let f of o)s+=f.integral;let c=n*Math.abs(s)/o.length,u=!0,l=o.length,h=[];for(let f of o){if(f.error<=c||f.error<=r*Math.abs(f.integral)){h.push(f);continue}if(u=!1,f.N<D)f.advance(2*f.N),h.push(f);else if(l>=Jn)h.push(f);else{l++;let p=new tt(t,f.a,f.c,r),M=new tt(t,f.c,f.b,r);p.advance(16),M.advance(16),h.push(p,M)}}if(o=h,u)break}let i=0;for(let a of o)i+=a.integral;return i}function De(t,e,n){let r=Math.max(1,Math.ceil((e-t)/n));return Array.from({length:r+1},(o,i)=>i===r?e:t+(e-t)*i/r)}var Ye=2e-15,Ke=1e-16,nr={lowerTail:!1},rr={logP:!0},or={lowerTail:!1,logP:!0},rt=.9189385332046728,Mt=t=>R(t),U=t=>R(t,nr),Ot=t=>R(t,rr),Dt=t=>R(t,or),ir=.3989422804014327;function V(t){let e=Math.round(t*16)/16,n=t-e;return ir*Math.exp(-.5*e*e)*Math.exp(-.5*n*(t+e))}var Pt=[.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],He=[.362683783378362,.31370664587788727,.22238103445337448,.10122853629037626];function ar(t,e){let n=t-.5*e,r=.5*e,o=0;for(let i=0;i<4;i++)o+=He[i]*(V(n-r*Pt[i])+V(n+r*Pt[i]));return o*r}function sr(t,e){let n=t-.5*e,r=.5*e,o=0;for(let i=0;i<4;i++){let a=r*Pt[i];o+=He[i]*(Math.exp(n*a-a*a/2)+Math.exp(-n*a-a*a/2))}return-rt-n*n/2+Math.log(o*r)}var Yt=(t,e)=>e*Math.max(1,Math.abs(t),Math.abs(t-e))<.5;function Z(t,e){let n=t-e,r=n-t,o=t-(n-r)+(-e-r);return{ah:n,al:o}}function nt(t,e){return Mt(t)+V(t)*e}function cr(t,e){return U(t)-V(t)*e}function Xe(t,e){if(Yt(t,e))return ar(t,e);let{ah:n,al:r}=Z(t,e);return n>=0?cr(n,r)-U(t):t<=0?Mt(t)-nt(n,r):1-nt(n,r)-U(t)}function ur(t,e,n){if(t>0&&t-e<0&&!Yt(t,e)){let{ah:o,al:i}=Z(t,e);return Math.exp(n*Math.log1p(-(nt(o,i)+U(t))))}let r=Xe(t,e);return r>0?r**n:0}function lr(t,e){return t>0?Math.exp(e*Math.log1p(-U(t))):Mt(t)**e}function Be(t,e){let{ah:n,al:r}=Z(t,e),o=Ot(n);return o+r*Math.exp(-rt-n*n/2-o)}function fr(t,e){let{ah:n,al:r}=Z(t,e),o=Dt(n);return o-r*Math.exp(-rt-n*n/2-o)}function Qe(t,e){if(Yt(t,e))return sr(t,e);if(t-e>=0){let i=fr(t,e);return i+Math.log(-Math.expm1(Dt(t)-i))}if(t<=0){let i=Ot(t);return i+Math.log(-Math.expm1(Be(t,e)-i))}let{ah:r,al:o}=Z(t,e);return Math.log1p(-nt(r,o)-U(t))}var je=2,St=1e-18;function Ge(t,e,n){let r=De(e,n,je),o=r.map(t),i=0;for(let f=1;f<o.length;f++)o[f]>o[i]&&(i=f);let a=o[i];if(!(a>0))return 0;let s=Math.max(i-1,0),c=Math.min(i+1,o.length-1);for(;s>0&&o[s]>a*St;)s--;for(;c<o.length-1&&o[c]>a*St;)c++;let u=a*St,l=r[s],h=r[c];if(o[s]<=u){let f=r[s+1];for(let p=0;p<2;p++){let M=.5*(l+f);t(M)<=u?l=M:f=M}}if(o[c]<=u){let f=r[c-1];for(let p=0;p<2;p++){let M=.5*(h+f);t(M)<=u?h=M:f=M}}return ht(t,[l,h],Ke)}function Ue(t,e,n){let r=De(e,n,je),o=r.map(t),i=0;for(let m=1;m<o.length;m++)o[m]>o[i]&&(i=m);if(!(o[i]>-1/0))return-1/0;let a=r[Math.max(i-1,0)],s=r[Math.min(i+1,r.length-1)],c=(Math.sqrt(5)-1)/2,u=s-c*(s-a),l=a+c*(s-a),h=t(u),f=t(l);for(let m=0;m<80&&s-a>1e-12*Math.max(1,Math.abs(a));m++)h<f?(a=u,u=l,h=f,l=a+c*(s-a),f=t(l)):(s=l,l=u,f=h,u=s-c*(s-a),h=t(u));let p=h>f?u:l,M=Math.max(h,f);o[i]>M&&(p=r[i],M=o[i]);let N=m=>{let w=m<0?e:n,_=Math.max(1e-6,.001*(r[1]-r[0])),b=p;for(;;){let x=p+m*_;if(m<0?x<=w:x>=w)return w;if(t(x)<M-46){let P=x;for(let A=0;A<6;A++){let H=.5*(b+P);t(H)<M-46?P=H:b=H}return P}b=x,_*=2}},g=N(-1),I=N(1),d=[...new Set([g,p,I])].sort((m,w)=>m-w);return M+Math.log(ht(m=>Math.exp(t(m)-M),d,Ke,4*et*Math.max(1,Math.abs(M))))}var Kt=-10,Ht=10;function hr(t,e){return t<=0?0:e*Ge(n=>V(n)*ur(n,t,e-1),Kt,Ht)}function Ve(t,e){if(t<=0)return 1;let n=i=>{let a=Mt(i);if(a===0)return 0;let{ah:s,al:c}=Z(i,t),u=nt(s,c),l=u<.5*a?-Math.expm1((e-1)*Math.log1p(-u/a)):-Math.expm1((e-1)*Math.log(Xe(i,t)/a));return V(i)*lr(i,e-1)*l};if(t>60)return 0;let[r,o]=Ze(t);return e*Ge(n,r,o)}function Ze(t){return t>40?[t/2-15,t/2+15]:[Kt,t+Ht]}function Mr(t,e){if(t>100)return-Math.exp(ze(t,e));let n=r=>-rt-r*r/2+(e-1)*Qe(r,t);return Math.log(e)+Ue(n,Kt,Ht)}function ze(t,e){if(t>100){let i=e*(e-1);return(Number.isFinite(i)?Math.log(i):Math.log(e)+Math.log(e-1))+Dt(t/Math.SQRT2)}let n=i=>{let a=Ot(i),s=Be(i,t)-a,c;return s<-40?c=Math.log(e-1)+s:s<-Math.LN2?c=Math.log(-Math.expm1((e-1)*Math.log1p(-Math.exp(s)))):c=Math.log(-Math.expm1((e-1)*(Qe(i,t)-a))),-rt-i*i/2+(e-1)*a+c},[r,o]=Ze(t);return Math.log(e)+Ue(n,r,o)}function pr(t,e){let n=-1/0;for(let r of e)n=Math.max(n,t(r));for(let r=0;r+1<e.length;r++)n=Math.max(n,t(.5*(e[r]+e[r+1])));if(n===-1/0)return-1/0;if(et*Math.abs(n)>1)return n;for(let r=0;r<4;r++){let o=n,i=ht(a=>{let s=t(a);return s>o&&(o=s),Math.exp(s-n)},e,Ye,8*et*Math.max(1,Math.abs(n)));if(Number.isFinite(i)&&o-n<300)return n+Math.log(i);n=o}return NaN}var O=32,mr=1e-15,G=Math.log(.01),pt=Math.log(20),Je=Math.log(40),ke=Float64Array.from({length:2*O+1},(t,e)=>Math.cos(Math.PI*e/O));function gr(t,e){let n=new Float64Array(e+1);for(let r=0;r<=e;r++){let o=.5*(t[0]+(r%2===0?t[e]:-t[e]));for(let i=1;i<e;i++)o+=t[i]*ke[r*i%(2*e)];o*=2/e,(r===0||r===e)&&(o*=.5),n[r]=o}return n}function Tt(t,e,n){let r=[],o=[[e,n,0]];for(;o.length>0;){let[i,a,s]=o.pop(),c=.5*(i+a),u=.5*(a-i),l=new Float64Array(O+1),h=1/0;for(let M=0;M<=O;M++)l[M]=t(c+u*ke[M]),h=Math.min(h,Math.max(1,Math.abs(l[M])));let f=gr(l,O),p=0;for(let M=O-3;M<=O;M++)p=Math.max(p,Math.abs(f[M]));p<=mr*h||s>=14||!l.every(Number.isFinite)?r.push({a:i,b:a,coef:f}):o.push([c,a,s+1],[i,c,s+1])}return r.sort((i,a)=>i.a-a.a)}function Ct(t,e){let n=0,r=t.length-1;for(;n<r;){let l=n+r+1>>1;t[l].a<=e?n=l:r=l-1}let{a:o,b:i,coef:a}=t[n],s=(2*e-o-i)/(i-o),c=0,u=0;for(let l=O;l>=1;l--){let h=2*s*c-u+a[l];u=c,c=h}return s*c-u+a[0]}var k=new Map,dr=64,tn=Math.log(1e-10);function en(t){let e=k.get(t);if(e!==void 0)return e;let n=o=>{let i=hr(o,t);return i>1e-290?Math.log(i):Mr(o,t)},r=o=>{let i=Math.exp(o);return Ve(i,t)*nn(i)};return e={logW:Tt(o=>n(Math.exp(o)),G,pt),scaledWc:Tt(r,G,Je),smallW:Tt(o=>n(Math.exp(o))-(t-1)*o,tn,G)},k.size>=dr&&k.delete(k.keys().next().value),k.set(t,e),e}function nn(t){let e=t*t,n=134217729*t,r=n-(n-t),o=t-r,i=r*r-e+2*r*o+o*o;return Math.exp(e/4)*(1+i/4)}function rn(t,e){let n=Math.log(t);if(n>=pt)return 0;let r=en(e);return n>=G?Ct(r.logW,n):Ct(r.smallW,Math.max(n,tn))+(e-1)*n}function Ft(t,e){return Math.log(t)>=pt?1:Math.exp(rn(t,e))}function Lt(t,e){let n=Math.log(t);return n>=G&&n<=Je?Ct(en(e).scaledWc,n)/nn(t):n<G?1-Ft(t,e):Ve(t,e)}function lt(t,e,n,r){if(!r){let i=Math.min(Ft(t,e),1);return n===1?i:i**n}let o=Math.min(Lt(t,e),1);return o<=.5?n===1?o:-Math.expm1(n*Math.log1p(-o)):1-Math.min(Ft(t,e),1)**n}function qt(t,e,n,r){if(!r)return n*(Math.log(t)<pt?rn(t,e):Math.log1p(-Math.min(Lt(t,e),1)));let o=Math.min(Lt(t,e),1),i=o>1e-290?Math.log(o):ze(t,e);return n===1?i:i<-700?Math.log(n)+i:Math.log(-Math.expm1(n*Math.log1p(-Math.exp(i))))}function Wt(t,e,n,r,o){if(n===1/0||an(t,e,n,r))return lt(t,e,r,o);let i=n/2,a=on(i);return ht(c=>{let u=Math.exp(a(c));return u===0?0:u*lt(t*Math.exp(.5*c),e,r,o)},sn(t,e,n,r,o),Ye)}function on(t){let e=.5*Math.log(t/(2*Math.PI))-kt(t);return n=>{let r;if(Math.abs(n)<.5){let o=n*n/2;r=o;for(let i=3;i<60&&(o*=n/i,r+=o,!(Math.abs(o)<1e-17*r));i++);}else r=Math.expm1(n)-n;return e-t*r}}function an(t,e,n,r){let o=Math.max((e-1)*r,t*t,1);return o*o<1e-17*n}function Nr(t,e,n,r,o){if(n===1/0||an(t,e,n,r))return qt(t,e,r,o);let i=on(n/2),a=Math.log(t);return pr(c=>i(c)+qt(Math.exp(a+.5*c),e,r,o),sn(t,e,n,r,o,!0))}function sn(t,e,n,r,o,i=!1){let a=n/2,s=a,c;if(o){let m=2*Math.log(t)-Math.log(4*a);c=-(m>30?m:Math.log1p(Math.exp(m)))}else s=a+(e-1)*r/2,c=Math.log1p((e-1)*r/(2*a));let u=(m,w)=>[m-9/Math.sqrt(w)-41/w,m+9/Math.sqrt(w)+Math.log1p(41/w)],[l,h]=u(0,a),[f,p]=u(c,s),M=i?Math.min(l,f):Math.max(Math.min(l,f),-740-Math.log(a)),N=Math.max(h,p),g=1/Math.sqrt(a),I=1/Math.sqrt(s),d=[M,Math.min(-4*g,c-4*I),Math.max(4*g,c+4*I),N];return[...new Set(d.map(m=>Math.min(Math.max(m,M),N)))].sort((m,w)=>m-w)}function cn(t,e,n){return t>=2&&e>=2&&n>=1&&Number.isFinite(t)&&Number.isFinite(n)&&!Number.isNaN(e)}function ft(t,e,n,r,o,i){if(t<$e){let s=ft($e,e,n,r,!0,!0)+(e-1)*r*Math.log(t*10715086071862673e285);return o?i?s:Math.exp(s):i?-Math.exp(s):-Math.expm1(s)}let a;return K!==void 0&&K.q===t&&K.k===e&&K.df===n&&K.r===r?a=K.tail:(a=br(t,e,n,r,!o),K={q:t,k:e,df:n,r,tail:a}),a.upper===!o?i?a.log:a.value:i?Math.log1p(-a.value):1-a.value}var K,$e=2**-1e3;function br(t,e,n,r,o){let i=o;n!==1/0&&lt(t,e,r,i)>.5&&(i=!i);let a=Wt(t,e,n,r,i);if(a>.5){let s=Wt(t,e,n,r,!i);s<a&&(a=s,i=!i)}if(a<1e-290){let s=Nr(t,e,n,r,i);return{upper:i,value:Math.exp(s),log:s}}return{upper:i,value:a,log:Math.log(a)}}function wr(t,e,n,r,o,i){return[t,e,n,r].some(Number.isNaN)?NaN:cn(e,n,r)?t<=0?S(o,i):t===1/0?T(o,i):ft(t,e,n,r,o,i):NaN}function xr(t,e,n,r,o,i){if([t,e,n,r].some(Number.isNaN))return NaN;if(!cn(e,n,r))return NaN;let a=L(t,0,1/0,o,i);if(a!==void 0)return a;let{lower:s,logTarget:c,linearTarget:u}=Jt(t,o,i),l=f=>p=>{let M=Math.exp(p);if(u!==void 0&&u>1e-290){let g=f===1/0?Wt(M,e,f,r,!s):ft(M,e,f,r,s,!1);if(g>0)return Math.log(g/u)}return(f===1/0?Er(M,e,r,s):ft(M,e,f,r,s,!0))-c},h=Oe(l(1/0),Math.log(3),s);return Math.exp(n===1/0?h:Oe(l(n),h,s))}function Er(t,e,n,r){let o=lt(t,e,n,!r);return o>1e-290?Math.log(o):qt(t,e,n,!r)}function Oe(t,e,n){let r=e,o=t(r);if(o===0)return r;let i=o>0===n?-1:1,a=.05,s=r+i*a,c=t(s),u=NaN;for(let l=0;l<200&&Math.sign(c)===Math.sign(o)&&c!==0;l++){if(Math.abs(u-s)<.001)return s;for(r=s,o=c,a*=2,s=(r+i*a-u)*i>=0?.5*(r+u):r+i*a,c=t(s);!Number.isFinite(c);){if(u=s,Math.abs(u-r)<.001)return r;s=.5*(r+u),c=t(s)}}return c===0?s:!Number.isFinite(c)||Math.sign(c)===Math.sign(o)?Number.isFinite(c)?s:r:yr(t,r,s,o,c)}function yr(t,e,n,r,o){let i=e,a=r,s=n-e,c=s;for(let u=0;u<100;u++){Math.sign(o)===Math.sign(a)&&(i=e,a=r,s=n-e,c=s),Math.abs(a)<Math.abs(o)&&(e=n,n=i,i=e,r=o,o=a,a=r);let l=2*et*Math.abs(n)+1e-300,h=.5*(i-n);if(Math.abs(h)<=l||o===0)return n;if(Math.abs(c)>=l&&Math.abs(r)>Math.abs(o)){let f=o/r,p,M;if(e===i)p=2*h*f,M=1-f;else{let N=r/a,g=o/a;p=f*(2*h*N*(N-g)-(n-e)*(g-1)),M=(N-1)*(g-1)*(f-1)}p>0?M=-M:p=-p,2*p<Math.min(3*h*M-Math.abs(l*M),Math.abs(c*M))?(c=s,s=p/M):(s=h,c=h)}else s=h,c=h;e=n,r=o,n+=Math.abs(s)>l?s:h>0?l:-l,o=t(n)}return n}function Ro(t,e,n,r={}){y(r,Zn,"ptukey");let{nranges:o=1,lowerTail:i=!0,logP:a=!1}=r;return E(t,s=>wr(s,e,n,o,i,a))}function So(t,e,n,r={}){y(r,zn,"qtukey");let{nranges:o=1,lowerTail:i=!0,logP:a=!1}=r;return E(t,s=>xr(s,e,n,o,i,a))}function Xt(t){let e=[],n=[];for(let r=1;r<=t/2;r++){let o=Math.cos(Math.PI*(r-.25)/(t+.5)),i=0;for(let a=0;a<100;a++){let s=1,c=o;for(let l=2;l<=t;l++)[s,c]=[c,((2*l-1)*o*c-(l-1)*s)/l];i=t*(o*c-s)/(o*o-1);let u=c/i;if(o-=u,Math.abs(u)<=1e-17)break}e.push(o),n.push(2/((1-o*o)*i*i))}return{x:e,w:n}}var Ir=[Xt(6),Xt(12),Xt(20)],Bt=2*Math.PI,Y=t=>R(t,{lowerTail:!1});function vr(t,e,n){if(n===1)return Y(Math.max(t,e));if(n===-1)return t>=-e?0:t>=0?Y(t)-Y(-e):R(-e)-R(t);let{x:r,w:o}=Ir[Math.abs(n)<.3?0:Math.abs(n)<.75?1:2],i=t*e;if(Math.abs(n)<.925){let g=(t*t+e*e)/2,I=Math.asin(n),d=0;for(let m=0;m<r.length;m++)for(let w of[1-r[m],1+r[m]]){let _=Math.sin(I*w/2);d+=o[m]*Math.exp((_*i-g)/(1-_*_))}return d*I/(2*Bt)+Y(t)*Y(e)}let a=n<0?-e:e,s=n<0?-i:i,c=(1-n)*(1+n),u=Math.sqrt(c),l=(t-a)**2,h=(4-s)/8,f=(12-s)/16,p=u*Math.exp(-(l/c+s)/2)*(1-h*(l-c)*(1-f*l/5)/3+h*f*c*c/5);if(s>-160){let g=Math.sqrt(l);p-=Math.exp(-s/2)*Math.sqrt(Bt)*R(-g/u)*g*(1-h*l*(1-f*l/5)/3)}let M=u/2;for(let g=0;g<r.length;g++)for(let I of[1-r[g],1+r[g]]){let d=(M*I)**2,m=Math.sqrt(1-d);p+=M*o[g]*(Math.exp(-l/(2*d)-s/(1+m))/m-Math.exp(-(l/d+s)/2)*(1+h*d*(1+f*d)))}let N=-p/Bt;return n>0?N+Y(Math.max(t,a)):-N+(a>t?R(a)-R(t):0)}function mt(t,e,n){return t===1/0||e===1/0?0:t===-1/0?e===-1/0?1:Y(e):e===-1/0?Y(t):vr(t,e,n)}function Co(t,e,n){if(t.length!==2||e.length!==2)throw new TypeError("'lower' and 'upper' must have length 2");if(!(n>=-1&&n<=1))throw new RangeError("'rho' must be in [-1, 1]");let[r,o]=t,[i,a]=e;if([r,o,i,a].some(Number.isNaN))return NaN;if([r,o,i,a]=[r,o,i,a].map(c=>c>40?1/0:c<-40?-1/0:c),!(r<i&&o<a))return 0;r+i+o+a<0&&([r,o,i,a]=[-i,-a,-r,-o]);let s=mt(r,o,n)-mt(r,a,n)-mt(i,o,n)+mt(i,a,n);return Math.max(0,s)}var _r=["size","replace","prob"],Ar=["size","replace","prob"];function $o(t,e={}){return y(e,Ar,"sampleInt"),un(t,e).map(n=>n-1)}function un(t,e){if(!Number.isFinite(t)||t<0||t>45e14)throw new RangeError("n must be a non-negative number up to 4.5e15");t=Math.trunc(t);let{replace:n=!1,prob:r}=e,o=e.size!==void 0,i=o?e.size:t;if(!Number.isFinite(i)||i<=-1)throw new RangeError("size must be a non-negative number");let a=Math.trunc(i);if(t===0&&a>0)throw new RangeError("cannot take a sample from an empty population");if(r!==void 0){if(a>=2**31)throw new RangeError("size must be less than 2^31 with prob");if(t>=2**31)throw new RangeError("n must be less than 2^31 with prob");if(r.length!==t)throw new TypeError("prob must have length n");let l=fn(r,a,n);if(n){let h=ln(l),f=new Array(a);for(let p=0;p<a;p++)f[p]=h();return f}if(a>t)throw new RangeError("cannot take a sample larger than the population when replace is false");return Tr(l,a)}if(!n&&a>t)throw new RangeError("cannot take a sample larger than the population when replace is false");if(!n&&t>1e7&&o&&a<=t/2){let l=new Set,h=[];for(;h.length<a;){let f=J(t);l.has(f)||(l.add(f),h.push(f+1))}return h}let s=new Array(a);if(n||a<2){for(let l=0;l<a;l++)s[l]=J(t)+1;return s}if(t>=2**31)throw new RangeError("n must be less than 2^31 to sample without replacement with size above n / 2");let c=new Int32Array(t);for(let l=0;l<t;l++)c[l]=l;let u=t;for(let l=0;l<a;l++){let h=J(u);s[l]=c[h]+1,c[h]=c[--u]}return s}function Oo(t,e){if(!Number.isFinite(t)||t<0||t>45e14)throw new RangeError("n must be a non-negative number up to 4.5e15");if(t=Math.trunc(t),t>=2**31)throw new RangeError("n must be less than 2^31 with prob");if(e.length!==t)throw new TypeError("prob must have length n");let n=ln(fn(e,0,!0));return()=>n()-1}function ln(t){let e=t.length,n=0;for(let r=0;r<e;r++)e*t[r]>.1&&n++;return n>200?Pr(t):Sr(t)}function Do(t,e={}){return y(e,_r,"sample"),un(t.length,e).map(n=>t[n-1])}function fn(t,e,n){let r=0,o=0;for(let i of t){if(!Number.isFinite(i))throw new RangeError("prob contains NaN or infinite values");if(i<0)throw new RangeError("prob contains negative values");i>0&&(o++,r+=i)}if(o===0||!n&&e>o)throw new RangeError("too few positive probabilities");if(r===1/0){let i=fe(t);r=0;for(let a of t)r+=a/i;return Float64Array.from(t,a=>a/i/r)}return Float64Array.from(t,i=>i/r)}function Rr(t,e){let n=t.length;if(n<=1)return;let r=c=>t[c-1],o=(n>>1)+1,i=n,a,s;for(;;){if(o>1)o=o-1,a=r(o),s=e[o-1];else if(a=r(i),s=e[i-1],t[i-1]=r(1),e[i-1]=e[0],--i===1){t[0]=a,e[0]=s;return}let c=o,u=o<<1;for(;u<=i;)u<i&&r(u)>r(u+1)&&++u,a>r(u)?(t[c-1]=r(u),e[c-1]=e[u-1],c=u,u+=u):u=i+1;t[c-1]=a,e[c-1]=s}}function hn(t){let e=new Int32Array(t.length);for(let n=0;n<t.length;n++)e[n]=n+1;return Rr(t,e),e}function Sr(t){let e=Float64Array.from(t),n=e.length,r=hn(e);for(let o=1;o<n;o++)e[o]+=e[o-1];return()=>{let o=q(),i=0;for(;i<n-1&&!(o<=e[i]);i++);return r[i]}}function Tr(t,e){let n=Float64Array.from(t),r=n.length,o=hn(n),i=new Array(e),a=1;for(let s=0,c=r-1;s<e;s++,c--){let u=a*q(),l=0,h=0;for(;h<c&&(l+=n[h],!(u<=l));h++);i[s]=o[h],a-=n[h];for(let f=h;f<c;f++)n[f]=n[f+1],o[f]=o[f+1]}return i}function Pr(t){let e=t.length,n=new Float64Array(e),r=new Int32Array(e),o=new Int32Array(e),i=-1,a=e;for(let c=0;c<e;c++)n[c]=t[c]*e,n[c]<1?o[++i]=c:o[--a]=c;if(i>=0&&a<e)for(let c=0;c<e-1;c++){let u=o[c],l=o[a];if(r[u]=l,n[l]+=n[u]-1,n[l]<1&&a++,a>=e)break}let s=he();return()=>{let c,u;return s?(u=q()*e,c=Math.trunc(u)):(c=J(e),u=c+q()),u<n[c]+c?c+1:r[c]+1}}var Cr=2**24;function Fr(t){let e=new Float64Array(t+1);for(let n=2;n<=t;n++)e[n]=e[n-1]+Math.log(n);return e}function Lr(t,e,n,r){let o=t.length,i=e.length,a=Array.from(e),s=0;for(let u of t)s+=u;for(let u=0;u<o-1;u++){let l=t[u],h=s;s-=l;let f=0;for(;f<i-1;f++){let p=a[f],M=h;h-=p;let N=M-l,g=N-p;if(M===0){for(let m=f;m<i-1;m++)r[u+m*o]=0;l=0;break}let I=q(),d;t:for(;;){d=Math.floor(l*(p/M)+.5);let m=Math.exp(n[l]+n[N]+n[h]+n[p]-n[M]-n[d]-n[p-d]-n[l-d]-n[g+d]);if(m>=I)break;if(m===0)throw new Error(`r2dtable: probability underflow at cell [${u}, ${f}]`);let w=m,_=m,b=d,x=!1,P=!1;for(;!(x&&P);){if(!x){let A=(p-d)*(l-d);if(A===0)x=!0;else if(d++,m=m*A/(d*(g+d)),w+=m,w>=I)break t}do{let A=b*(g+b);if(A===0){P=!0;break}if(b--,_=_*A/((p-b)*(l-b)),w+=_,w>=I){d=b;break t}}while(x)}I=w*q()}r[u+f*o]=d,l-=d,a[f]=a[f]-d}r[u+(i-1)*o]=l}let c=e[i-1];for(let u=0;u<o-1;u++)c-=r[u+(i-1)*o];for(let u=0;u<i-1;u++)r[o-1+u*o]=a[u];r[o-1+(i-1)*o]=c}function Mn(t,e){let n=Array.from(t,r=>Math.trunc(r));if(n.length<=1||n.some(r=>!(r>=0)||r>2147483647))throw new RangeError(`invalid argument '${e}'`);return n}function Ho(t,e,n){if(!(Number.isFinite(t)&&t>-1&&t<2**31))throw new RangeError("invalid argument 'n'");let r=Math.trunc(t),o=Mn(e,"r"),i=Mn(n,"c"),a=o.reduce((l,h)=>l+h,0);if(a!==i.reduce((l,h)=>l+h,0))throw new RangeError("arguments 'r' and 'c' must have the same sums");if(a>2147483647)throw new RangeError("the sum of 'r' must be at most 2147483647");if(r===0)return[];if(a>Cr)throw new RangeError("the sum of 'r' must be at most 16777216 (2^24) to generate tables");let s=Fr(a),c=new Int32Array(o.length*i.length),u=[];for(let l=0;l<r;l++)Lr(o,i,s,c),u.push(o.map((h,f)=>i.map((p,M)=>c[f+M*o.length])));return u}export{Dr as a,Yr as b,Kr as c,En as d,xt as e,In as f,Rn as g,Jr as h,kr as i,to as j,Wn as k,$n as l,co as m,uo as n,lo as o,Gn as p,Un as q,Vn as r,bo as s,wo as t,xo as u,Ro as v,So as w,Co as x,$o as y,Oo as z,Do as A,Cr as B,Fr as C,Lr as D,Ho as E};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.0.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
1
+ /*! rStats.js 1.1.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
2
  var K=2220446049250313e-31,i0=22250738585072014e-324,D=17976931348623157e292,g0=[.06667134430868814,.1494513491505806,.21908636251598204,.26926671930999635,.29552422471475287],h0=[.9956571630258081,.9739065285171717,.9301574913557082,.8650633666889845,.7808177265864169,.6794095682990244,.5627571346686047,.4333953941292472,.2943928627014602,.14887433898163122,0],X=[.011694638867371874,.032558162307964725,.054755896574351995,.07503967481091996,.0931254545836976,.10938715880229764,.12349197626206584,.13470921731147334,.14277593857706009,.14773910490133849,.1494455540029169];function u0(n,o,u,s,t){let c=Math.abs((n-o)*u);return t!==0&&c!==0&&(c=t*Math.min(1,Math.pow(200*c/t,1.5))),s>i0/(50*K)&&(c=Math.max(K*50*s,c)),c}function v0(n,o,u){let s=.5*(o+u),t=.5*(u-o),c=Math.abs(t),p=new Array(10),M=new Array(10),w=n(s),h=0,r=X[10]*w,l=Math.abs(r);for(let b=0;b<5;b++){let a=2*b+1,k=t*h0[a],e=n(s-k),f=n(s+k);p[a]=e,M[a]=f;let g=e+f;h+=g0[b]*g,r+=X[a]*g,l+=X[a]*(Math.abs(e)+Math.abs(f))}for(let b=0;b<5;b++){let a=2*b,k=t*h0[a],e=n(s-k),f=n(s+k);p[a]=e,M[a]=f;let g=e+f;r+=X[a]*g,l+=X[a]*(Math.abs(e)+Math.abs(f))}let A=r*.5,i=X[10]*Math.abs(w-A);for(let b=0;b<10;b++)i+=X[b]*(Math.abs(p[b]-A)+Math.abs(M[b]-A));return l*=c,i*=c,{result:r*t,abserr:u0(r,h,t,l,i),resabs:l,resasc:i}}var M0=[0,.1294849661688697,0,.27970539148927664,0,.3818300505051189,0,.4179591836734694],x0=[.9914553711208126,.9491079123427585,.8648644233597691,.7415311855993945,.5860872354676911,.4058451513773972,.20778495500789848,0],B=[.022935322010529224,.06309209262997856,.10479001032225019,.14065325971552592,.1690047266392679,.19035057806478542,.20443294007529889,.20948214108472782];function y0(n,o,u,s,t){let c=u>1?1:u,p=.5*(s+t),M=.5*(t-s),w=new Array(7),h=new Array(7),r=e=>{let f=o+c*(1-e)/e,g=n(f);return u===2&&(g+=n(-f)),g},l=r(p)/p/p,A=l*M0[7],i=l*B[7],b=Math.abs(i);for(let e=0;e<7;e++){let f=M*x0[e],g=p-f,q=p+f,G=r(g),y=r(q);G=G/g/g,y=y/q/q,w[e]=G,h[e]=y;let F=G+y;A+=M0[e]*F,i+=B[e]*F,b+=B[e]*(Math.abs(G)+Math.abs(y))}let a=i*.5,k=B[7]*Math.abs(l-a);for(let e=0;e<7;e++)k+=B[e]*(Math.abs(w[e]-a)+Math.abs(h[e]-a));return b*=M,k*=M,{result:i*M,abserr:u0(i,A,M,b,k),resabs:b,resasc:k}}function j0(n){let o=n.epstab,u=n.n;n.nres+=1;let s=D,t=o[n.n];if(n.n<2)return s=Math.max(s,5*K*Math.abs(t)),[t,s];let c=49;o[n.n+2]=o[n.n];let p=Math.trunc(n.n/2);o[n.n]=D;let M=n.n;for(let r=0;r<p;r++){let l=M-1,A=M-2,i=o[M+2],b=o[A],a=o[l],k=i,e=Math.abs(a),f=k-a,g=Math.abs(f),q=Math.max(Math.abs(k),e)*K,G=a-b,y=Math.abs(G),F=Math.max(e,Math.abs(b))*K;if(!(g>q||y>F))return t=i,s=g+y,s=Math.max(s,5*K*Math.abs(t)),[t,s];let W=o[M];o[M]=a;let _=a-W,m=Math.abs(_),x=Math.max(e,Math.abs(W))*K;if(m<=x||g<=q||y<=F){n.n=r+r;break}let j=1/_+1/f-1/G;if(!(Math.abs(j*a)>1e-4)){n.n=r+r;break}i=a+1/j,o[M]=i,M-=2;let C=g+Math.abs(i-k)+y;C>s||(s=C,t=i)}n.n===c&&(n.n=2*Math.trunc(c/2));let w=u%2;for(let r=0;r<=p;r++)o[2*r+w]=o[2*r+2+w];if(n.n!==u){let r=u-n.n;for(let l=0;l<=n.n;l++)o[l]=o[r],r++}let h=n.res3la;return n.nres<4?(h[n.nres-1]=t,s=D):(s=Math.abs(t-h[2])+Math.abs(t-h[1])+Math.abs(t-h[0]),h[0]=h[1],h[1]=h[2],h[2]=t),s=Math.max(s,5*K*Math.abs(t)),[t,s]}function K0(n,o,u,s,t,c){if(o<=2){t[0]=0,t[1]=1;let b=t[c];return[b,s[b],c]}let p=s[u];for(;c>0&&p>s[t[c-1]];)t[c]=t[c-1],c-=1;let M=o>Math.trunc(n/2)+2?n-o+2:o-1,w=s[o-1],h=M-1,r=c+1,l=r,A=!1;if(r<=h)for(l=r;l<=h;l++){if(p>=s[t[l]]){A=!0;break}t[l-1]=t[l]}if(!A)t[h]=u,t[M]=o-1;else{t[l-1]=u;let b=h;for(let a=l;a<=h&&!(w<s[t[b]]);a++)t[b+1]=t[b],b--;w<s[t[b]]?t[b+1]=o-1:t[l]=o-1}let i=t[c];return[i,s[i],c]}function k0(n,o,u,s,t,c,p,M){let w=Math.min(c+1,128),h=new Float64Array(w),r=new Float64Array(w),l=new Float64Array(w),A=new Float64Array(w),i=new Int32Array(w),b=d=>{w=Math.min(c+1,Math.max(d,2*w));let L=P=>{let S=new Float64Array(w);return S.set(P),S};h=L(h),r=L(r),l=L(l),A=L(A);let E=new Int32Array(w);E.set(i),i=E},a=0,k=0,e=0,f=0;if(h[0]=o,r[0]=u,s<=0&&t<Math.max(50*K,5e-29))return{result:0,abserr:0,neval:0,ier:6,last:0};let g=n(o,u);e=g.result,f=g.abserr;let q=g.resabs,G=g.resasc,y=Math.abs(e),F=Math.max(s,t*y);if(k=1,l[0]=e,A[0]=f,i[0]=0,f<=100*K*q&&f>F&&(a=2),c===1&&(a=1),a!==0||f<=F&&f!==G||f===0)return{result:e,abserr:f,neval:M(k),ier:a,last:k};let W={epstab:new Float64Array(52),res3la:new Float64Array(3),n:1,nres:0};W.epstab[0]=e;let _=f,m=0,x=e,j=f;f=D;let O=0,C=0,J=!1,s0=!1,Q=0,a0=0,V=0,n0=0,N=0,H=0,R=0,r0=0,w0=y>=(1-50*K)*q?1:-1,o0=!1,v=1;for(v=1;v<c;v++){k=v+1,w<v+2&&b(v+2);let d=h[m],L=.5*(h[m]+r[m]),E=L,P=r[m],S=_,Y=n(d,L),Z=n(E,P),$=Y.result,U=Y.abserr,m0=Y.resasc,t0=Z.result,z=Z.abserr,p0=Z.resasc,e0=$+t0,T=U+z;if(j=j+T-_,x=x+e0-l[m],m0!==U&&p0!==z&&(Math.abs(l[m]-e0)>1e-5*Math.abs(e0)||T<.99*_||(J?V++:a0++),v>9&&T>_&&n0++),l[m]=$,l[v]=t0,F=Math.max(s,t*Math.abs(x)),(a0+V>=10||n0>=20)&&(a=2),V>=5&&(Q=3),k===c&&(a=1),Math.max(Math.abs(d),Math.abs(P))<=(1+100*K)*(Math.abs(E)+1e3*i0)&&(a=4),z>U?(h[m]=E,h[v]=d,r[v]=L,l[m]=t0,l[v]=$,A[m]=z,A[v]=U):(h[v]=E,r[m]=L,r[v]=P,A[m]=U,A[v]=z),[m,_,O]=K0(c,k,m,A,i,O),j<=F){o0=!0;break}if(a!==0)break;if(v===1){N=p,H=j,R=F,W.epstab[1]=x;continue}if(s0)continue;if(H-=S,Math.abs(L-d)>N&&(H+=T),!J){if(Math.abs(r[m]-h[m])>N)continue;J=!0,O=1}if(!(Q===3||H<=R)){let A0=k>2+Math.trunc(c/2)?c+3-k:k,l0=!1;for(let b0=O;b0<A0;b0++){if(m=i[O],_=A[m],Math.abs(r[m]-h[m])>N){l0=!0;break}O++}if(l0)continue}W.n+=1,W.epstab[W.n]=x;let[c0,f0]=j0(W);if(C+=1,C>5&&f<.001*j&&(a=5),f0<f&&(C=0,f=f0,e=c0,r0=H,R=Math.max(s,t*Math.abs(c0)),f<=R)||(W.n===0&&(s0=!0),a===5))break;m=i[0],_=A[m],O=0,J=!1,N*=.5,H=j}let I;if(o0||f===D?I=115:a+Q===0?I=110:(Q===3&&(f+=r0),a===0&&(a=3),e!==0&&x!==0?I=105:f>j?I=115:x===0?I=130:I=110),I===105&&(I=f/Math.abs(e)>j/Math.abs(x)?115:110),I===110)w0===-1&&Math.max(Math.abs(e),Math.abs(x))<=q*.01||(.01>e/x||e/x>100||j>Math.abs(x))&&(a=6);else if(I===115){e=0;for(let d=0;d<=v;d++)e+=l[d];f=j}return a>2&&(a-=1),{result:e,abserr:f,neval:M(k),ier:a,last:k}}function F0(n,o,u,s,t,c){return k0((p,M)=>v0(n,p,M),o,u,s,t,c,Math.abs(u-o)*.375,p=>42*p-21)}function q0(n,o,u,s,t,c){let p=u===2?0:o;return k0((M,w)=>y0(n,p,u,M,w),0,1,s,t,c,.375,M=>(30*M-15)*(u===2?2:1))}export{F0 as a,q0 as b};