@numero-uno-jpn/rstats 1.13.0 → 1.14.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 (63) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.ja.md +3 -3
  3. package/README.md +3 -3
  4. package/dist/causal.js +2 -2
  5. package/dist/chunks/{chunk-JJGRQ22M.js → chunk-2426YL2X.js} +2 -2
  6. package/dist/chunks/{chunk-GRXOLZ6J.js → chunk-3746VXPM.js} +2 -2
  7. package/dist/chunks/{chunk-2N7PIFPJ.js → chunk-3DA7CMFN.js} +2 -2
  8. package/dist/chunks/{chunk-24UIPUSE.js → chunk-3XUHCWLU.js} +1 -1
  9. package/dist/chunks/{chunk-JTARV4D3.js → chunk-4O6XLQBN.js} +2 -2
  10. package/dist/chunks/{chunk-TQ4P6W3P.js → chunk-62Y36UKH.js} +2 -2
  11. package/dist/chunks/{chunk-KOF2HBUV.js → chunk-6HUTVWPO.js} +2 -2
  12. package/dist/chunks/{chunk-CCYGRSQW.js → chunk-6VY3XNAF.js} +2 -2
  13. package/dist/chunks/{chunk-VO65CBCV.js → chunk-7BBIQY4W.js} +2 -2
  14. package/dist/chunks/{chunk-CKQOWTX7.js → chunk-7FGVMDJE.js} +2 -2
  15. package/dist/chunks/{chunk-2SOBG73L.js → chunk-7VMGP2U7.js} +2 -2
  16. package/dist/chunks/{chunk-LS55YUPZ.js → chunk-A5DZG7FH.js} +2 -2
  17. package/dist/chunks/{chunk-QWXSJEDI.js → chunk-AONDWNMF.js} +2 -2
  18. package/dist/chunks/{chunk-XRB552MP.js → chunk-AQHG7BEZ.js} +2 -2
  19. package/dist/chunks/{chunk-3T4TVNXS.js → chunk-B6NPCYFO.js} +2 -2
  20. package/dist/chunks/{chunk-NWWY2WMF.js → chunk-BCXYAILN.js} +2 -2
  21. package/dist/chunks/{chunk-C7NEFIAH.js → chunk-CKUBQW2A.js} +2 -2
  22. package/dist/chunks/{chunk-5Y425VAJ.js → chunk-D25AVVVI.js} +2 -2
  23. package/dist/chunks/{chunk-NRBTDLVW.js → chunk-DZQWGBTW.js} +2 -2
  24. package/dist/chunks/{chunk-UMLJFZJ5.js → chunk-EDRBKZ3C.js} +2 -2
  25. package/dist/chunks/{chunk-IIKFLH2E.js → chunk-EWNJT27V.js} +2 -2
  26. package/dist/chunks/{chunk-DZLOU6HK.js → chunk-F6KKW5YN.js} +2 -2
  27. package/dist/chunks/{chunk-RGEW3YLB.js → chunk-FPJ2CWLK.js} +2 -2
  28. package/dist/chunks/{chunk-ST6I33C6.js → chunk-H5GBKP57.js} +1 -1
  29. package/dist/chunks/{chunk-CEY7FHMZ.js → chunk-I2OTBVRK.js} +2 -2
  30. package/dist/chunks/{chunk-EWJS4VYF.js → chunk-IXFWR3LH.js} +2 -2
  31. package/dist/chunks/{chunk-M3LK23YR.js → chunk-JCGCJT7T.js} +1 -1
  32. package/dist/chunks/{chunk-GQ4HYF4L.js → chunk-KITNZUYC.js} +2 -2
  33. package/dist/chunks/{chunk-TTBKW2KL.js → chunk-MCEZRRQO.js} +2 -2
  34. package/dist/chunks/{chunk-7V6FRF32.js → chunk-MJHFGGPU.js} +2 -2
  35. package/dist/chunks/{chunk-CAOEREY3.js → chunk-MXOBCQQP.js} +2 -2
  36. package/dist/chunks/{chunk-OWD2GUXJ.js → chunk-NA7EDZ4Q.js} +2 -2
  37. package/dist/chunks/{chunk-2BXB6DRK.js → chunk-PHDTVTKV.js} +1 -1
  38. package/dist/chunks/{chunk-P6HSXCGZ.js → chunk-QLKZ2OFQ.js} +2 -2
  39. package/dist/chunks/{chunk-OVJU5WCL.js → chunk-SDIIGAY5.js} +2 -2
  40. package/dist/chunks/{chunk-CBAEKGP7.js → chunk-SEKOIW43.js} +2 -2
  41. package/dist/chunks/{chunk-AH6IVJRF.js → chunk-TGXUU5NB.js} +1 -1
  42. package/dist/chunks/{chunk-7ZKPFHAO.js → chunk-VWCCPBBG.js} +2 -2
  43. package/dist/chunks/{chunk-CSZCDPF3.js → chunk-XXH5OIUO.js} +2 -2
  44. package/dist/chunks/{chunk-Y4UWFH4Q.js → chunk-Y7VD43TO.js} +2 -2
  45. package/dist/chunks/{chunk-XRBNTYQW.js → chunk-YLUF4WTL.js} +2 -2
  46. package/dist/chunks/{chunk-P2UT6OCU.js → chunk-ZJJJDLRL.js} +2 -2
  47. package/dist/chunks/{chunk-DQ2MIFRQ.js → chunk-ZWSHIUBZ.js} +2 -2
  48. package/dist/descriptive.js +2 -2
  49. package/dist/distributions.js +2 -2
  50. package/dist/entries/regression.d.ts +1 -0
  51. package/dist/entries/regression.js +2 -0
  52. package/dist/linalg.js +2 -2
  53. package/dist/mixed.js +2 -2
  54. package/dist/models/multinom.d.ts +250 -0
  55. package/dist/models/multinom.js +520 -0
  56. package/dist/multivariate.js +2 -2
  57. package/dist/numerics.js +2 -2
  58. package/dist/regression.js +3 -3
  59. package/dist/rstats.js +1 -1
  60. package/dist/special.js +2 -2
  61. package/dist/tests.js +2 -2
  62. package/dist/timeseries.js +2 -2
  63. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ 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.14.0 - 2026-11-24
11
+
12
+ ### Added
13
+
14
+ - **Multinomial logistic regression** in `/regression`: `multinom` (after `nnet::multinom`: baseline-category logits, case weights, decay), `multinomSummary` (Wald tests, odds ratios, McFadden's, Cox-Snell's and Nagelkerke's pseudo R²), `multinomConfint`, `multinomPredict` (probabilities and classes, R's tie-breaking), `multinomAnova` (likelihood-ratio tests of nested models) and `multinomVcov`. The coefficients are the exact maximum; R's BFGS stops about 1e-5 from it ([the differences](docs/differences-from-r.md#multinomial-logistic-regression-1140)).
15
+
10
16
  ## 1.13.0 - 2026-11-24
11
17
 
12
18
  ### Added
package/README.ja.md CHANGED
@@ -16,7 +16,7 @@ JavaScript とブラウザで使える、R と互換の統計関数のライブ
16
16
  - **どこでも動きます。** ESM のみで、依存パッケージはなく、Node 専用の API も使っていません。
17
17
  tree-shaking が効きます (`pnorm` だけなら gzip で 1.6 KB)。
18
18
 
19
- 状態: **1.13.0。** R の stats パッケージの数値計算の中心
19
+ 状態: **1.14.0。** R の stats パッケージの数値計算の中心
20
20
  (分布・記述統計・検定・線形モデル・特殊関数・数値計算・線形代数の基本) を、R と同じ結果でカバーすることを目指しています。残っている作業は
21
21
  [ROADMAP.ja.md](ROADMAP.ja.md)、変更履歴は [CHANGELOG.md](CHANGELOG.md) (英語) にあります。
22
22
 
@@ -227,7 +227,7 @@ eigen([[2, 1], [1, 3]]).values; // ≈ [3.618033989, 1.381966011]
227
227
  | 試験デザインの標本サイズと検出力 | `epiSsequb`・`epiSsequc`・`epiSsninfb`・`epiSsninfc`・`epiSssupb`・`epiSssupc` (epiR: 比率と平均の同等性・非劣性・優越性)、`powerPaired2x2` (対応のある 2 × 2 表の正確な McNemar 検定の検出力)、`ssizeCT`・`powerCT`・`ssizeEpi`・`powerEpi`・`numDEpi` (生存時間の標本サイズと検出力)、`ph2simon` (Simon の 2 段階デザイン) |
228
228
  | メタアナリシス | `escalc` (効果量と標本分散)、`rma` (等効果・ランダム効果のメタアナリシスとメタ回帰)、`confintRma`・`predictRma`・`regtest` (metafor) |
229
229
  | 線形モデル | `lm` (formula とデータフレーム、または行列で渡す。`summary` の値も返す), `modelMatrix` (`model.matrix`), `confint`, `predict`。`glm` (行列で渡す形。R の `stats` のすべての族とリンク) と `glmSummary` (`summary.glm`)、`svyglm` (逆確率重みに対する `survey::svyglm`: デザインに基づく標準誤差)、`glmResiduals` (4 種類)、`glmHatvalues`、`glmRstandard`、`glmCooksDistance`、`glmPredict` (標準誤差つき)、`glmConfint` (プロファイル尤度、厳密な限界)、`glmAnova` (`anova.glm`)。`vcovHC`、`vcovCL` (sandwich: HC0〜HC5、一元と多元のクラスター)、`coeftest`、`coefci` (lmtest) |
230
- | 回帰 | `polr`・`polrSummary`・`polrVcov`・`polrPredict`・`polrConfint`・`polrAnova` (MASS: logistic・probit・cloglog・loglog・cauchit のリンクによる順序ロジスティック回帰)、`rlm`・`rlmSummary`・`rlmVcov`・`psiHuber`・`psiHampel`・`psiBisquare` (MASS: M 推定と MM 推定によるロバスト回帰)、`nls`・`nlsSummary`・`nlsVcov`・`nlsPredict`・`nlsConfint`・`nlsAnova` (非線形最小二乗法: 既定・`plinear`・`port` のアルゴリズムと 10 個の自己開始モデル)、`rq`・`rqSummary`・`rqPredict`・`rqPredictInterval`・`rqAnova` (分位点回帰)、`geeglm`・`geeSummary`・`geeVcov`・`geePredict`・`geeAnova`・`geeQIC` (一般化推定方程式)、`glmnet`・`glmnetCoef`・`glmnetPredict`・`cvGlmnet` (Gaussian・binomial・Poisson・multinomial の正則化回帰)。`@numero-uno-jpn/rstats/regression` から import します |
230
+ | 回帰 | `multinom`・`multinomSummary`・`multinomConfint`・`multinomPredict`・`multinomAnova`・`multinomVcov` (nnet: 重みと decay つきの多項ロジスティック回帰)、`polr`・`polrSummary`・`polrVcov`・`polrPredict`・`polrConfint`・`polrAnova` (MASS: logistic・probit・cloglog・loglog・cauchit のリンクによる順序ロジスティック回帰)、`rlm`・`rlmSummary`・`rlmVcov`・`psiHuber`・`psiHampel`・`psiBisquare` (MASS: M 推定と MM 推定によるロバスト回帰)、`nls`・`nlsSummary`・`nlsVcov`・`nlsPredict`・`nlsConfint`・`nlsAnova` (非線形最小二乗法: 既定・`plinear`・`port` のアルゴリズムと 10 個の自己開始モデル)、`rq`・`rqSummary`・`rqPredict`・`rqPredictInterval`・`rqAnova` (分位点回帰)、`geeglm`・`geeSummary`・`geeVcov`・`geePredict`・`geeAnova`・`geeQIC` (一般化推定方程式)、`glmnet`・`glmnetCoef`・`glmnetPredict`・`cvGlmnet` (Gaussian・binomial・Poisson・multinomial の正則化回帰)。`@numero-uno-jpn/rstats/regression` から import します |
231
231
  | 多変量解析 | `manova`・`manovaSummary` (逐次 MANOVA: Pillai・Wilks・Hotelling-Lawley・Roy)、`lda`・`ldaPredict` (線形判別分析)、`cancor` (正準相関)、`dist`・`asDist`・`hclust`・`cutree`・`kmeans` (クラスタ分析)、`cmdscale` (古典的多次元尺度法)、`ca`・`caSummary`・`caCoord` (対応分析)、`mjca` (多重対応分析)、`sammon`・`isoMDS` (非計量多次元尺度法)。`@numero-uno-jpn/rstats/multivariate` から import します |
232
232
  | 混合モデル | `lmer` (lme4: REML と最尤法、相関のある変量効果と相関のない変量効果、交差と入れ子の群。`fixef`、`vcov`、`VarCorr`、`ranef`、`logLik`、`AIC`、`BIC`、`REMLcrit`、`isSingular`)、`lmerSummary`・`lmerContest`・`lmerAnova` (lmerTest: Satterthwaite の t 検定と F 検定、Type I/II/III の分散分析表。当てはめどうしの尤度比検定)、`glmer` (lme4: glm のすべての族、ラプラス近似と適応的 Gauss-Hermite 求積)、`glmerSummary`・`glmerAnova`・`glmerPredict`・`lmerPredict`・`confintLmer`・`confintGlmer`・`simulateLmer`・`simulateGlmer`。
233
233
  `@numero-uno-jpn/rstats/mixed` から import する |
@@ -317,7 +317,7 @@ minify 済みの ES モジュール、gzip で 322 KB) を jsDelivr から読み
317
317
 
318
318
  ```html
319
319
  <script type="module">
320
- import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@1.13.0/dist/rstats.js";
320
+ import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@1.14.0/dist/rstats.js";
321
321
  console.log(pnorm(1.96)); // ≈ 0.9750021049
322
322
  </script>
323
323
  ```
package/README.md CHANGED
@@ -14,7 +14,7 @@ R-compatible statistical functions for JavaScript and the browser, written in Ty
14
14
  - **Runs anywhere.** ESM only, no dependencies, no Node-specific APIs, tree-shakable
15
15
  (`pnorm` alone is 1.6 KB gzipped).
16
16
 
17
- Status: **1.13.0.** The goal is to cover the numerical core of R's
17
+ Status: **1.14.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
 
@@ -225,7 +225,7 @@ eigen([[2, 1], [1, 3]]).values; // ≈ [3.618033989, 1.381966011]
225
225
  | Sample size and power for trial designs | `epiSsequb`, `epiSsequc`, `epiSsninfb`, `epiSsninfc`, `epiSssupb`, `epiSssupc` (epiR: equivalence, non-inferiority and superiority for proportions and means), `powerPaired2x2` (exact paired McNemar power), `ssizeCT`, `powerCT`, `ssizeEpi`, `powerEpi`, `numDEpi` (survival sample size and power), `ph2simon` (Simon two-stage designs) |
226
226
  | Meta-analysis | `escalc` (effect sizes and sampling variances), `rma` (equal- and random-effects meta-analysis and meta-regression), `confintRma`, `predictRma`, `regtest` (metafor) |
227
227
  | Linear models | `lm` (a formula and a data frame, or a matrix, with the `summary` quantities), `modelMatrix` (`model.matrix`), `confint`, `predict`; `glm` (matrix interface, every family and link of R's `stats`) with `glmSummary` (`summary.glm`), `svyglm` (`survey::svyglm` for inverse probability weights: design-based standard errors), `glmResiduals` (the four kinds), `glmHatvalues`, `glmRstandard`, `glmCooksDistance`, `glmPredict` (with standard errors), `glmConfint` (profile likelihood, exact limits), `glmAnova` (`anova.glm`); `vcovHC`, `vcovCL` (sandwich: HC0 to HC5, one-way and multi-way clustered), `coeftest`, `coefci` (lmtest) |
228
- | Regression | `polr`, `polrSummary`, `polrVcov`, `polrPredict`, `polrConfint`, `polrAnova` (MASS: ordinal logistic regression with logistic, probit, cloglog, loglog and cauchit links); `rlm`, `rlmSummary`, `rlmVcov`, `psiHuber`, `psiHampel`, `psiBisquare` (MASS: robust M and MM regression); `nls`, `nlsSummary`, `nlsVcov`, `nlsPredict`, `nlsConfint`, `nlsAnova` (nonlinear least squares: default, `plinear` and `port` algorithms, and 10 self-starting models); `rq`, `rqSummary`, `rqPredict`, `rqPredictInterval`, `rqAnova` (quantile regression); `geeglm`, `geeSummary`, `geeVcov`, `geePredict`, `geeAnova`, `geeQIC` (generalized estimating equations); `glmnet`, `glmnetCoef`, `glmnetPredict`, `cvGlmnet` (penalized Gaussian, binomial, Poisson and multinomial regression), from `@numero-uno-jpn/rstats/regression` |
228
+ | Regression | `multinom`, `multinomSummary`, `multinomConfint`, `multinomPredict`, `multinomAnova`, `multinomVcov` (nnet: multinomial logistic regression with weights and decay), `polr`, `polrSummary`, `polrVcov`, `polrPredict`, `polrConfint`, `polrAnova` (MASS: ordinal logistic regression with logistic, probit, cloglog, loglog and cauchit links); `rlm`, `rlmSummary`, `rlmVcov`, `psiHuber`, `psiHampel`, `psiBisquare` (MASS: robust M and MM regression); `nls`, `nlsSummary`, `nlsVcov`, `nlsPredict`, `nlsConfint`, `nlsAnova` (nonlinear least squares: default, `plinear` and `port` algorithms, and 10 self-starting models); `rq`, `rqSummary`, `rqPredict`, `rqPredictInterval`, `rqAnova` (quantile regression); `geeglm`, `geeSummary`, `geeVcov`, `geePredict`, `geeAnova`, `geeQIC` (generalized estimating equations); `glmnet`, `glmnetCoef`, `glmnetPredict`, `cvGlmnet` (penalized Gaussian, binomial, Poisson and multinomial regression), from `@numero-uno-jpn/rstats/regression` |
229
229
  | Multivariate analysis | `manova`, `manovaSummary` (sequential MANOVA: Pillai, Wilks, Hotelling-Lawley and Roy); `lda`, `ldaPredict` (linear discriminant analysis); `cancor` (canonical correlation); `dist`, `asDist`, `hclust`, `cutree`, `kmeans` (cluster analysis); `cmdscale` (classical multidimensional scaling); `ca`, `caSummary`, `caCoord` (correspondence analysis); `mjca` (multiple correspondence analysis); `sammon` and `isoMDS` (non-metric multidimensional scaling), from `@numero-uno-jpn/rstats/multivariate` |
230
230
  | Mixed models | `lmer` (lme4: REML and ML, correlated and uncorrelated random effects, crossed and nested grouping factors; `fixef`, `vcov`, `VarCorr`, `ranef`, `logLik`, `AIC`, `BIC`, `REMLcrit`, `isSingular`), `lmerSummary`, `lmerContest` and `lmerAnova` (lmerTest: Satterthwaite's t- and F-tests, Type I/II/III ANOVA tables; likelihood-ratio comparison of fits), `glmer` (lme4: all glm families, Laplace approximation and adaptive Gauss-Hermite quadrature), `glmerSummary`, `glmerAnova`, `glmerPredict`, `lmerPredict`, `confintLmer`, `confintGlmer`, `simulateLmer` and
231
231
  `simulateGlmer`, from `@numero-uno-jpn/rstats/mixed` |
@@ -316,7 +316,7 @@ function except those of `/mixed` and `/regression`, 322 KB gzipped) from jsDeli
316
316
 
317
317
  ```html
318
318
  <script type="module">
319
- import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@1.13.0/dist/rstats.js";
319
+ import { pnorm } from "https://cdn.jsdelivr.net/npm/@numero-uno-jpn/rstats@1.14.0/dist/rstats.js";
320
320
  console.log(pnorm(1.96)); // ≈ 0.9750021049
321
321
  </script>
322
322
  ```
package/dist/causal.js CHANGED
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.13.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{a as H}from"./chunks/chunk-5Y425VAJ.js";import"./chunks/chunk-DQ2MIFRQ.js";import{b as Q}from"./chunks/chunk-2SOBG73L.js";import"./chunks/chunk-CBAEKGP7.js";import"./chunks/chunk-2N7PIFPJ.js";import{f as L}from"./chunks/chunk-QWXSJEDI.js";import"./chunks/chunk-P6HSXCGZ.js";import{d as $}from"./chunks/chunk-VO65CBCV.js";import"./chunks/chunk-GQ4HYF4L.js";import"./chunks/chunk-DZLOU6HK.js";import"./chunks/chunk-IIKFLH2E.js";import"./chunks/chunk-CEY7FHMZ.js";import"./chunks/chunk-7V6FRF32.js";import"./chunks/chunk-UMLJFZJ5.js";import{a as D}from"./chunks/chunk-NRBTDLVW.js";import{g as G,m as J,n as K,o as B}from"./chunks/chunk-CCYGRSQW.js";import"./chunks/chunk-2BXB6DRK.js";import"./chunks/chunk-24UIPUSE.js";import"./chunks/chunk-TQ4P6W3P.js";import"./chunks/chunk-M3LK23YR.js";import"./chunks/chunk-KOF2HBUV.js";import{r as V,s as U}from"./chunks/chunk-P2UT6OCU.js";import{h as _}from"./chunks/chunk-3T4TVNXS.js";import{l as W}from"./chunks/chunk-AH6IVJRF.js";function Z(s){let i=0;for(let n of s)Math.abs(n)>i&&(i=Math.abs(n));return i>0&&Number.isFinite(i)?Math.floor(Math.log2(i)):0}function I(s){let i=Z(s),n=s.map(e=>_(e,-i)),r=n[0]??0,t=n.map(e=>e-r),p=Z(t);return{values:t.map(e=>_(e,-p)),unitExp:i+p}}var ce=["estimand","M","caliper"];function fe(s,i,n={}){W(n,ce,"match");let{estimand:r="ATT",M:t=1,caliper:p}=n,e=s.length;if(i.length!==e)throw new RangeError("length(Tr) != nrow(X)");if(r!=="ATT"&&r!=="ATE"&&r!=="ATC")throw new RangeError(`invalid 'estimand': ${String(r)}`);if(!Number.isInteger(t)||t<1)throw new RangeError("'M' must be a positive integer");if(p!==void 0&&!(p>0&&Number.isFinite(p)))throw new RangeError("'caliper' must be a positive number");let a=[];for(let u=0;u<e;u++){let b=s[u];if(b===!0||b===1)a.push(!0);else if(b===!1||b===0)a.push(!1);else throw typeof b=="number"&&Number.isNaN(b)?new RangeError("Match(): input includes NAs"):new RangeError("Treatment indicator ('Tr') must be a logical variable---i.e., TRUE (1) or FALSE (0)");if(!Number.isFinite(i[u]))throw new RangeError("Match(): input includes NAs")}if(!a.includes(!0)||!a.includes(!1))throw new RangeError("Treatment indicator ('Tr') must contain both treatment and control observations");let l=0;for(let u of i)l=Math.max(l,Math.abs(u));let c=l>0?Math.floor(Math.log2(l)):0,o=i.map(u=>_(u,-c)),d=null,N=1/0;if(p!==void 0){let{values:u,unitExp:b}=I(o),x=0;for(let E of u)x+=E;x/=e;let S=0;for(let E of u)S+=(E-x)*(E-x);let k=_(Math.sqrt(S/e),b);N=p*k,d=_(N,c)}let R=[new Array(e).fill(!1),new Array(e).fill(!1)],g=[],w=[],v=[],T=[],M=0,f=0;for(let u=0;u<e;u++){let b=a[u];if(b?r==="ATC":r==="ATT")continue;let x=R[b?0:1],S=[];for(let y=0;y<e;y++){if(a[y]===b)continue;let q=Math.abs(o[u]-o[y]);q>N||x[y]||S.push({j:y,d:q})}if(S.length<t){f++,v.push(u+1);continue}let E=S.map(y=>y.d).sort((y,q)=>y-q)[t-1],C=S.filter(y=>y.d<=E).map(y=>y.j),j;if(C.length===t)j=C;else{T.push(C.length),j=[],C=C.slice();for(let y=0;y<t;y++){let q=C.length,O=Math.min(q-1,Math.floor(q*(1-G())));j.push(C[O]),C.splice(O,1)}j.sort((y,q)=>y-q)}for(let y of j)x[y]=!0,g.push((b?u:y)+1),w.push((b?y:u)+1);M++}let h=new Set([...g,...w]),A=d===null?[]:v.filter(u=>!h.has(u)),m=[];return g.length===0&&m.push("'Match' object contains no valid matches (probably because of the caliper or the exact option)."),{indexTreated:g,indexControl:w,weights:g.map(()=>1/t),indexDropped:A.length>0?A:null,caliper:p??null,ecaliper:d,nobs:e,wnobs:M,ndrops:f,estimand:r,M:t,tieSizes:T,warnings:m}}var ue=["match","weightit","weights","estimand","levels","binary"],he=["factor"];function X(s){let i=new Array(s.nobs).fill(0);return s.indexTreated.forEach((n,r)=>{i[n-1]+=s.weights[r],i[s.indexControl[r]-1]+=s.weights[r]}),i}function me(s,i){if(s===!0||s===1)return!0;if(s===!1||s===0)return!1;throw new RangeError(`'tr' must be 0 or 1 (element ${i+1})`)}function F(s,i,n,r){let t=0,p=0,e=0;for(let c=0;c<s.length;c++){if(n[c]!==r)continue;let o=i===null?1:i[c];t+=o,p+=o*o,e+=o*s[c]}let a=e/t,l=0;for(let c=0;c<s.length;c++){if(n[c]!==r)continue;let o=i===null?1:i[c];l+=o*(s[c]-a)*(s[c]-a)}return[a,l/(t-p/t)]}function pe(s,i,n={}){W(n,ue,"balTab");let{match:r,weightit:t,binary:p="raw",levels:e={}}=n;if(r!==void 0&&t!==void 0)throw new RangeError("give 'match' or 'weightit', not both");let a=r!==void 0?X(r):t!==void 0?t.weights:n.weights,l=r?.estimand??t?.estimand??n.estimand??"ATT",c=new Set(r?.indexDropped??[]),o=r!==void 0&&r.caliper!==null,d=s.length,N=s.map(me);if(!N.includes(!0)||!N.includes(!1))throw new RangeError("'tr' must contain both groups");if(a!==void 0&&a.length!==d)throw new RangeError("'weights' must have the length of 'tr'");if(l==="ATO"&&a===void 0)throw new RangeError("estimand 'ATO' needs the weights");let R=[];t?.ps&&R.push(["prop.score",t.ps,"Distance"]);for(let[T,M]of Object.entries(i)){if(M.length!==d)throw new RangeError(`covariate '${T}' must have the length of 'tr'`);if(M.every(h=>typeof h=="number")){R.push([T,M,null]);continue}if(!M.every(h=>typeof h=="string"))throw new TypeError(`covariate '${T}' must be all numbers or all strings`);let f=e[T]??[...new Set(M)].sort(D);if(M.some(h=>!f.includes(h)))throw new RangeError(`covariate '${T}' has values not among its levels`);for(let h of f.length===2?f.slice(1):f)R.push([`${T}_${h}`,M.map(A=>A===h?1:0),null])}let g=N.map(()=>!0),w=t!==void 0,v={rows:R.map(([T])=>T),type:[],diffUn:[],diffAdj:[],vRatioUn:[],vRatioAdj:[],observations:{rows:w?["Unadjusted","Adjusted"]:["All (ESS)","All (Unweighted)","Matched (ESS)","Matched (Unweighted)","Unmatched",...o?["Discarded"]:[]],control:[],treated:[]}};for(let[T,M,f]of R){if(M.some(O=>!Number.isFinite(O)))throw new RangeError(`covariate '${T}' has missing or infinite values`);let h=f===null&&new Set(M).size<=2&&M.every(O=>O===0||O===1),A=h?null:I(M),m=A===null?M:A.values,[u,b]=F(m,null,N,!0),[x,S]=F(m,null,N,!1),k;if(l==="ATO"){let[O,P]=F(m,a,g,!0);k=Math.sqrt(h?O*(1-O):P)}else{let O=h?[u*(1-u),x*(1-x)]:[b,S];if(k=Math.sqrt(l==="ATT"?O[0]:l==="ATC"?O[1]:(O[0]+O[1])/2),_(k,A?.unitExp??0)<Math.sqrt(Number.EPSILON)){let[P,le]=F(m,null,g,!0);k=Math.sqrt(h?P*(1-P):le)}}let E=h&&p==="raw"?1:k;if(v.type.push(f??(h?"Binary":"Contin.")),v.diffUn.push(u===x?0:(u-x)/E),v.vRatioUn.push(h||S===0?NaN:b/S),a===void 0){v.diffAdj.push(NaN),v.vRatioAdj.push(NaN);continue}let[C,j]=F(m,a,N,!0),[y,q]=F(m,a,N,!1);v.diffAdj.push(C===y?0:(C-y)/E),v.vRatioAdj.push(h||q===0?NaN:j/q)}for(let T of[!1,!0]){let M=0,f=0,h=0,A=0,m=0;for(let x=0;x<d;x++){if(N[x]!==T||(M++,c.has(x+1)&&m++,a===void 0))continue;let S=a[x];f+=S,h+=S*S,S>0&&A++}let u=T?v.observations.treated:v.observations.control;if(w){u.push(M,f*f/h);continue}let b=a===void 0?[NaN,NaN,NaN]:[f*f/h,A,M-A-m];o&&b.push(m),u.push(M,M,...b)}return v}function de(s,i,n={}){W(n,he,"tableOneSmd");let{factor:r=!1}=n;if(s.length!==i.length)throw new RangeError("'x' and 'group' must have the same length");let t=[...new Set(i)].sort((g,w)=>g<w?-1:g>w?1:0);if(t.length!==2)throw new RangeError("'group' must have exactly two levels");let p=g=>g!==null&&!(typeof g=="number"&&Number.isNaN(g)),e=t.map(g=>s.filter((w,v)=>i[v]===g&&p(w)));if(!r){if(e.flat().some(f=>typeof f!="number"))throw new TypeError("'x' must be numeric unless factor: true");let g=I(e.flat()).values,v=[g.slice(0,e[0].length),g.slice(e[0].length)].map(f=>{let h=f.reduce((A,m)=>A+m,0)/f.length;return[h,f.reduce((A,m)=>A+(m-h)*(m-h),0)/(f.length-1)]}),T=v[1][0]-v[0][0],M=Math.sqrt((v[0][1]+v[1][1])/2);return T===0?0:Math.abs(T)/M}let a=[...new Set(e.flat())].sort((g,w)=>typeof g=="number"&&typeof w=="number"?g-w:String(g)<String(w)?-1:String(g)>String(w)?1:0),l=e.map(g=>a.slice(1).map(w=>g.filter(v=>v===w).length/g.length)),c=l[1].map((g,w)=>g-l[0][w]);if(c.every(g=>g===0))return 0;let o=c.length,d=Array.from({length:o},(g,w)=>Array.from({length:o},(v,T)=>{let M=f=>w===T?f[w]*(1-f[w]):-f[w]*f[T];return(M(l[0])+M(l[1]))/2}));if(d.every(g=>g.every(w=>w===0)))return NaN;let N=Q(d),R=0;for(let g=0;g<o;g++)for(let w=0;w<o;w++)R+=c[g]*N[g][w]*c[w];return Math.sqrt(R)}var ge=["method","link","estimand","stabilize"],we=["at","lower","treat"],z=Number.EPSILON;function be(s){return s.map((i,n)=>{if(i===!0||i===1)return 1;if(i===!1||i===0)return 0;throw new RangeError(`'tr' must be 0 or 1 (element ${n+1})`)})}function ve(s,i){let n=[],r=[],t={};for(let[p,e]of Object.entries(s)){if(e.length!==i)throw new RangeError(`covariate '${p}' must have the length of 'tr'`);if(e.every(c=>typeof c=="number")){let c=e;if(c.some(o=>!Number.isFinite(o)))throw new RangeError(`covariate '${p}' has missing or infinite values`);n.push(p),r.push(c.slice());continue}if(!e.every(c=>typeof c=="string"))throw new TypeError(`covariate '${p}' must be all numbers or all strings`);let a=e,l=[...new Set(a)].sort(D);t[p]=l;for(let c of l.slice(1))n.push(p+c),r.push(a.map(o=>o===c?1:0))}return{names:n,columns:r,factors:t}}function ee(s){return s.map(i=>{let n=i.reduce((t,p)=>t+p,0)/i.length,r=i.reduce((t,p)=>Math.max(t,Math.abs(p-n)),0);return i.map(t=>r>0?(t-n)/r:0)})}function Me(s){let i=s[0]?.length??0,n=[new Array(i).fill(1/Math.sqrt(i))],r=[];for(let t of s){let p=Math.sqrt(t.reduce((l,c)=>l+c*c,0)),e=t.slice();for(let l=0;l<2;l++)for(let c of n){let o=e.reduce((d,N,R)=>d+N*c[R],0);for(let d=0;d<i;d++)e[d]-=o*c[d]}let a=Math.sqrt(e.reduce((l,c)=>l+c*c,0));a>1e-7*p&&(n.push(e.map(l=>l/a)),r.push(t))}return r}function ae(s,i){let n=i.length,r=s.map((e,a)=>[...e,i[a]]),t=0;for(let e of s)for(let a of e)t=Math.max(t,Math.abs(a));for(let e=0;e<n;e++){let a=e;for(let l=e+1;l<n;l++)Math.abs(r[l][e])>Math.abs(r[a][e])&&(a=l);if(!(Math.abs(r[a][e])>1e-13*t))return null;[r[e],r[a]]=[r[a],r[e]];for(let l=e+1;l<n;l++){let c=r[l][e]/r[e][e];if(c!==0)for(let o=e;o<=n;o++)r[l][o]-=c*r[e][o]}}let p=new Array(n).fill(0);for(let e=n-1;e>=0;e--){let a=r[e][n];for(let l=e+1;l<n;l++)a-=r[e][l]*p[l];p[e]=a/r[e][e]}return p}function Y(s,i){return Array.from({length:i},(n,r)=>[1,...s.map(t=>t[r])])}function te(s,i,n){let r=n.length,t=new Array(r).fill(0);t[0]=Math.log(n[0]/i.length);let p=c=>{let o=0;for(let d of i)o+=Math.exp(s[d].reduce((N,R,g)=>N+R*c[g],0));return o-n.reduce((d,N,R)=>d+N*c[R],0)},e=p(t),a=!1,l=1e-13*Math.max(1,Math.abs(n[0]));for(let c=0;c<200;c++){let o=n.map(f=>-f),d=Array.from({length:r},()=>new Array(r).fill(0));for(let f of i){let h=s[f],A=Math.exp(h.reduce((m,u,b)=>m+u*t[b],0));for(let m=0;m<r;m++){o[m]+=A*h[m];for(let u=0;u<=m;u++)d[m][u]+=A*h[m]*h[u]}}for(let f=0;f<r;f++)for(let h=f+1;h<r;h++)d[f][h]=d[h][f];let N=Math.max(...o.map(Math.abs));if(N<=l){a=!0;break}let R=ae(d,o.map(f=>-f));if(R===null||R.some(f=>!Number.isFinite(f)))break;let g=1e-12*(Math.abs(e)+1),w=1,v=t.map((f,h)=>f+R[h]),T=p(v);for(;!(T<=e+g)&&w>1e-10;)w/=2,v=t.map((f,h)=>f+w*R[h]),T=p(v);if(!(T<=e+g))break;let M=R.some((f,h)=>Math.abs(w*f)>1e-15*Math.max(1,Math.abs(t[h])));if(t.splice(0,r,...v),e=T,!M){a=N<=1e-9*Math.max(1,Math.abs(n[0]));break}}return{eta:s.map(c=>c.reduce((o,d,N)=>o+d*t[N],0)),converged:a}}var Te={logit:{p:s=>$(s),q:s=>$(-s),d:s=>$(s)*$(-s)},probit:{p:s=>U(s),q:s=>U(-s),d:s=>V(s)}};function Ae(s,i,n,r,t){let p=i.length,e=t.length,a=t.slice(),l=w=>{let v=new Array(e).fill(0),T=Array.from({length:e},()=>new Array(e).fill(0));for(let M=0;M<p;M++){let f=s[M],h=f.reduce((k,E,C)=>k+E*w[C],0),A=r.p(h),m=r.q(h),u=r.d(h),b=i[M],x,S;n==="ATE"?(x=b?1/A:-1/m,S=b?-u/(A*A):-u/(m*m)):n==="ATT"?(x=b?1:-A/m,S=b?0:-u/(m*m)):n==="ATC"?(x=b?m/A:-1,S=b?-u/(A*A):0):(x=b?m:-A,S=-u);for(let k=0;k<e;k++){v[k]+=x*f[k];for(let E=0;E<e;E++)T[k][E]+=S*f[k]*f[E]}}return{g:v,J:T}},c=w=>w.reduce((v,T)=>v+T*T,0),{g:o,J:d}=l(a),N=c(o),R=!1,g=1e-12*p;for(let w=0;w<200;w++){if(Math.max(...o.map(Math.abs))<=g){R=!0;break}let v=ae(d,o.map(A=>-A));if(v===null||v.some(A=>!Number.isFinite(A)))break;let T=1,M=a.map((A,m)=>A+v[m]),f=l(M),h=c(f.g);for(;!(h<N)&&T>1e-10;)T/=2,M=a.map((A,m)=>A+T*v[m]),f=l(M),h=c(f.g);if(!(h<N)){R=Math.max(...o.map(Math.abs))<=1e-8*p;break}a=M,o=f.g,d=f.J,N=h}return{eta:s.map(w=>w.reduce((v,T,M)=>v+T*a[M],0)),converged:R}}function ne(s,i,n,r){switch(s){case"ATE":return i?1/n:1/r;case"ATT":return i?1:n/r;case"ATC":return i?r/n:1;default:return i?r:n}}var ye={glm:"glm.fit: algorithm did not converge",cbps:"The covariate balancing conditions could not be solved, so the covariates will not be exactly balanced.",ipt:"The optimization failed to converge; consider using fewer covariates or a different link function.",ebal:"The estimated weights do not balance the covariates, indicating the optimization arrived at a degenerate solution. Try decreasing the number of variables supplied to the optimization."},re={cbps:"covariate balancing propensity score weighting",ipt:"inverse probability tilting",ebal:"entropy balancing"};function Ee(s,i,n={}){W(n,ge,"weightit");let{method:r="glm",estimand:t="ATE",stabilize:p=!1}=n,e=r==="ps"?"glm":r;if(!["glm","cbps","ipt","ebal"].includes(e))throw new RangeError(`unknown method '${String(r)}'`);if(!["ATE","ATT","ATC","ATO"].includes(t))throw new RangeError(`unknown estimand '${String(t)}'`);let a=e==="ebal"?null:n.link??"logit";if(a!==null&&!{glm:["logit","probit","cauchit","cloglog"],cbps:["logit","probit"],ipt:["logit"]}[e].includes(a))throw new RangeError(`link '${a}' is not available for method '${e}'`);if((e==="ipt"||e==="ebal")&&t==="ATO")throw new RangeError(`"ATO" is not an allowable estimand for ${re[e]} with a binary treatment. Only "ATE", "ATT", and "ATC" are allowed.`);let c=[];if(p&&e==="glm"&&t!=="ATE")throw new RangeError('`stabilize` can only be supplied when `estimand = "ATE"`.');p&&e!=="glm"&&c.push(`\`stabilize\` cannot be used with ${re[e]} and will be ignored.`);let o=be(s),d=o.length;if(!o.includes(0)||!o.includes(1))throw new RangeError("The treatment must have at least two unique values.");let{names:N,columns:R}=ve(i,d);if(R.length===0)throw new RangeError("'covariates' must have at least one column");let g=Me(R.map(m=>I(m).values)),w=o.flatMap((m,u)=>m?[u]:[]),v=o.flatMap((m,u)=>m?[]:[u]),T=o.map((m,u)=>u),M=t==="ATT"?1:t==="ATC"?0:null,f=null,h,A=!0;if(e==="glm"){let m=B(()=>L(Y(g,d).map(u=>u.slice(1)),o,{family:"binomial",link:a}));A=m.converged,f=m.fittedValues.map((u,b)=>a==="logit"&&Math.abs(m.linearPredictors[b])>30?m.linearPredictors[b]>0?1-z:z:Math.min(Math.max(u,z),1-z)),h=o.map((u,b)=>ne(t,u,f[b],1-f[b])),f.some(u=>u<=10*z||u>=1-10*z)&&c.push("Propensity scores numerically equal to 0 or 1 were estimated, indicating perfect separation. These may yield problems with inference. See `?method_glm` (`?WeightIt::method_glm()`) for details.")}else if(e==="cbps"){let m=ee(g),u=Y(m,d),b=B(()=>L(u.map(E=>E.slice(1)),o,{family:"binomial",link:a})).coefficients.map(E=>Number.isFinite(E)?E:0),x=Te[a],S=Ae(u,o,t,x,b);A=S.converged;let k=E=>Math.min(Math.max(E,z),1-z);f=S.eta.map(E=>k(x.p(E))),h=o.map((E,C)=>ne(t,E,f[C],k(x.q(S.eta[C]))))}else{let m=ee(g),u=Y(m,d),b=C=>u[0].map((j,y)=>C.reduce((q,O)=>q+u[O][y],0)),x={C:t!=="ATC",T:t!=="ATT"},S=e==="ebal"&&t==="ATE"?{C:b(T),T:b(T)}:{C:b(w),T:b(v)},k=x.C?te(u,v,S.C):null,E=x.T?te(u,w,S.T):null;if(A=(k?.converged??!0)&&(E?.converged??!0),e==="ebal")h=o.map((C,j)=>C?E?Math.exp(E.eta[j]):1:k?Math.exp(k.eta[j]):1);else{let C=t==="ATE"?1:0;h=o.map((j,y)=>j?E?C+Math.exp(E.eta[y]):1:k?C+Math.exp(k.eta[y]):1),f=o.map((j,y)=>t==="ATT"?$(k.eta[y]):t==="ATC"?$(-E.eta[y]):j?$(-E.eta[y]):$(k.eta[y]))}}if(A||c.push(ye[e]),p&&e==="glm"){let m=[v.length/d,w.length/d];h=h.map((u,b)=>u*m[o[b]])}return h.every(m=>Math.abs(m-1)<Math.sqrt(z))&&c.push("All weights are 1, possibly indicating an estimation failure."),K("weightit",{weights:h,ps:f,treat:o,estimand:t,method:e,link:a,stabilized:p&&e==="glm",focal:M,columnNames:N,converged:A,warnings:c})}function oe(s,i,n,r){let t=s.slice();if(i.length===0)return t;let p=i.map(l=>s[l]),e,a;if(n<1){let l=n<.5?1-n:n;e=H(p,l,{type:3}),a=H(p,1-l,{type:3})}else{if(!Number.isInteger(n))throw new RangeError("'at' must be below 1 or a whole number");if(n>=p.length)return null;let l=n>p.length/2?p.length-n:n,c=p.slice().sort((o,d)=>o-d);e=c[c.length-1-l],a=c[l]}for(let l of i)s[l]>e&&(t[l]=e),r&&s[l]<a&&(t[l]=a);return t}var se=s=>`\`at\` must be less than ${s}, the number of units. Weights will not be trimmed.`;function Ne(s,i){W(i,we,"trimWeights");let{at:n,lower:r=!1}=i;if(!(n>0)||!Number.isFinite(n))throw new RangeError("'at' must be a positive number");if(Array.isArray(s)||ArrayBuffer.isView(s)){let a=Array.from(s);if(i.treat!==void 0&&i.treat.length!==a.length)throw new RangeError("'treat' must have the length of 'w'");let l=oe(a,a.map((c,o)=>o),n,r);return l===null?(J("trimWeights",[se(a.length)]),a):l}let t=s,p=t.treat.flatMap((a,l)=>t.focal===null||a!==t.focal?[l]:[]),e=oe(t.weights,p,n,r);return e===null?K("trimWeights",{...t,weights:t.weights.slice(),warnings:[se(p.length)]}):{...t,weights:e,warnings:t.warnings.slice()}}function ie(s,i){let n=i.map(o=>s[o]),r=n.length,t=0,p=0;for(let o of n)t+=o,p+=o*o;let e=t/r,a=n.reduce((o,d)=>o+(d-e)*(d-e),0),l=n.map(o=>e>0?o/e:NaN),c=n.map((o,d)=>d).sort((o,d)=>n[d]-n[o]||o-d).slice(0,5).reverse();return{range:[Math.min(...n),Math.max(...n)],top:{index:c.map(o=>i[o]+1),weights:c.map(o=>n[o])},mean:e,coefOfVar:Math.sqrt(a/(r-1))/e,scaledMad:l.reduce((o,d)=>o+Math.abs(d-1),0)/r,negativeEntropy:l.reduce((o,d)=>o+(Number.isNaN(d)?NaN:d>0?d*Math.log(d):0),0)/r,numZeros:n.filter(o=>Math.abs(o)<1e-10).length,n:r,ess:t*t/p}}function xe(s){let i=s.treat.flatMap((r,t)=>r?[t]:[]),n=s.treat.flatMap((r,t)=>r?[]:[t]);return{treated:ie(s.weights,i),control:ie(s.weights,n),stabilized:s.stabilized}}export{pe as balTab,fe as match,X as matchWeights,de as tableOneSmd,Ne as trimWeights,xe as weightSummary,Ee as weightit};
1
+ /*! rStats.js 1.14.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
+ import{a as H}from"./chunks/chunk-D25AVVVI.js";import"./chunks/chunk-ZWSHIUBZ.js";import{b as Q}from"./chunks/chunk-7VMGP2U7.js";import"./chunks/chunk-SEKOIW43.js";import"./chunks/chunk-3DA7CMFN.js";import{f as L}from"./chunks/chunk-AONDWNMF.js";import"./chunks/chunk-QLKZ2OFQ.js";import{d as $}from"./chunks/chunk-7BBIQY4W.js";import"./chunks/chunk-KITNZUYC.js";import"./chunks/chunk-F6KKW5YN.js";import"./chunks/chunk-EWNJT27V.js";import"./chunks/chunk-I2OTBVRK.js";import"./chunks/chunk-MJHFGGPU.js";import"./chunks/chunk-EDRBKZ3C.js";import{a as D}from"./chunks/chunk-DZQWGBTW.js";import{g as G,m as J,n as K,o as B}from"./chunks/chunk-6VY3XNAF.js";import"./chunks/chunk-PHDTVTKV.js";import"./chunks/chunk-3XUHCWLU.js";import"./chunks/chunk-62Y36UKH.js";import"./chunks/chunk-JCGCJT7T.js";import"./chunks/chunk-6HUTVWPO.js";import{r as V,s as U}from"./chunks/chunk-ZJJJDLRL.js";import{h as _}from"./chunks/chunk-B6NPCYFO.js";import{l as W}from"./chunks/chunk-TGXUU5NB.js";function Z(s){let i=0;for(let n of s)Math.abs(n)>i&&(i=Math.abs(n));return i>0&&Number.isFinite(i)?Math.floor(Math.log2(i)):0}function I(s){let i=Z(s),n=s.map(e=>_(e,-i)),r=n[0]??0,t=n.map(e=>e-r),p=Z(t);return{values:t.map(e=>_(e,-p)),unitExp:i+p}}var ce=["estimand","M","caliper"];function fe(s,i,n={}){W(n,ce,"match");let{estimand:r="ATT",M:t=1,caliper:p}=n,e=s.length;if(i.length!==e)throw new RangeError("length(Tr) != nrow(X)");if(r!=="ATT"&&r!=="ATE"&&r!=="ATC")throw new RangeError(`invalid 'estimand': ${String(r)}`);if(!Number.isInteger(t)||t<1)throw new RangeError("'M' must be a positive integer");if(p!==void 0&&!(p>0&&Number.isFinite(p)))throw new RangeError("'caliper' must be a positive number");let a=[];for(let u=0;u<e;u++){let b=s[u];if(b===!0||b===1)a.push(!0);else if(b===!1||b===0)a.push(!1);else throw typeof b=="number"&&Number.isNaN(b)?new RangeError("Match(): input includes NAs"):new RangeError("Treatment indicator ('Tr') must be a logical variable---i.e., TRUE (1) or FALSE (0)");if(!Number.isFinite(i[u]))throw new RangeError("Match(): input includes NAs")}if(!a.includes(!0)||!a.includes(!1))throw new RangeError("Treatment indicator ('Tr') must contain both treatment and control observations");let l=0;for(let u of i)l=Math.max(l,Math.abs(u));let c=l>0?Math.floor(Math.log2(l)):0,o=i.map(u=>_(u,-c)),d=null,N=1/0;if(p!==void 0){let{values:u,unitExp:b}=I(o),x=0;for(let E of u)x+=E;x/=e;let S=0;for(let E of u)S+=(E-x)*(E-x);let k=_(Math.sqrt(S/e),b);N=p*k,d=_(N,c)}let R=[new Array(e).fill(!1),new Array(e).fill(!1)],g=[],w=[],v=[],T=[],M=0,f=0;for(let u=0;u<e;u++){let b=a[u];if(b?r==="ATC":r==="ATT")continue;let x=R[b?0:1],S=[];for(let y=0;y<e;y++){if(a[y]===b)continue;let q=Math.abs(o[u]-o[y]);q>N||x[y]||S.push({j:y,d:q})}if(S.length<t){f++,v.push(u+1);continue}let E=S.map(y=>y.d).sort((y,q)=>y-q)[t-1],C=S.filter(y=>y.d<=E).map(y=>y.j),j;if(C.length===t)j=C;else{T.push(C.length),j=[],C=C.slice();for(let y=0;y<t;y++){let q=C.length,O=Math.min(q-1,Math.floor(q*(1-G())));j.push(C[O]),C.splice(O,1)}j.sort((y,q)=>y-q)}for(let y of j)x[y]=!0,g.push((b?u:y)+1),w.push((b?y:u)+1);M++}let h=new Set([...g,...w]),A=d===null?[]:v.filter(u=>!h.has(u)),m=[];return g.length===0&&m.push("'Match' object contains no valid matches (probably because of the caliper or the exact option)."),{indexTreated:g,indexControl:w,weights:g.map(()=>1/t),indexDropped:A.length>0?A:null,caliper:p??null,ecaliper:d,nobs:e,wnobs:M,ndrops:f,estimand:r,M:t,tieSizes:T,warnings:m}}var ue=["match","weightit","weights","estimand","levels","binary"],he=["factor"];function X(s){let i=new Array(s.nobs).fill(0);return s.indexTreated.forEach((n,r)=>{i[n-1]+=s.weights[r],i[s.indexControl[r]-1]+=s.weights[r]}),i}function me(s,i){if(s===!0||s===1)return!0;if(s===!1||s===0)return!1;throw new RangeError(`'tr' must be 0 or 1 (element ${i+1})`)}function F(s,i,n,r){let t=0,p=0,e=0;for(let c=0;c<s.length;c++){if(n[c]!==r)continue;let o=i===null?1:i[c];t+=o,p+=o*o,e+=o*s[c]}let a=e/t,l=0;for(let c=0;c<s.length;c++){if(n[c]!==r)continue;let o=i===null?1:i[c];l+=o*(s[c]-a)*(s[c]-a)}return[a,l/(t-p/t)]}function pe(s,i,n={}){W(n,ue,"balTab");let{match:r,weightit:t,binary:p="raw",levels:e={}}=n;if(r!==void 0&&t!==void 0)throw new RangeError("give 'match' or 'weightit', not both");let a=r!==void 0?X(r):t!==void 0?t.weights:n.weights,l=r?.estimand??t?.estimand??n.estimand??"ATT",c=new Set(r?.indexDropped??[]),o=r!==void 0&&r.caliper!==null,d=s.length,N=s.map(me);if(!N.includes(!0)||!N.includes(!1))throw new RangeError("'tr' must contain both groups");if(a!==void 0&&a.length!==d)throw new RangeError("'weights' must have the length of 'tr'");if(l==="ATO"&&a===void 0)throw new RangeError("estimand 'ATO' needs the weights");let R=[];t?.ps&&R.push(["prop.score",t.ps,"Distance"]);for(let[T,M]of Object.entries(i)){if(M.length!==d)throw new RangeError(`covariate '${T}' must have the length of 'tr'`);if(M.every(h=>typeof h=="number")){R.push([T,M,null]);continue}if(!M.every(h=>typeof h=="string"))throw new TypeError(`covariate '${T}' must be all numbers or all strings`);let f=e[T]??[...new Set(M)].sort(D);if(M.some(h=>!f.includes(h)))throw new RangeError(`covariate '${T}' has values not among its levels`);for(let h of f.length===2?f.slice(1):f)R.push([`${T}_${h}`,M.map(A=>A===h?1:0),null])}let g=N.map(()=>!0),w=t!==void 0,v={rows:R.map(([T])=>T),type:[],diffUn:[],diffAdj:[],vRatioUn:[],vRatioAdj:[],observations:{rows:w?["Unadjusted","Adjusted"]:["All (ESS)","All (Unweighted)","Matched (ESS)","Matched (Unweighted)","Unmatched",...o?["Discarded"]:[]],control:[],treated:[]}};for(let[T,M,f]of R){if(M.some(O=>!Number.isFinite(O)))throw new RangeError(`covariate '${T}' has missing or infinite values`);let h=f===null&&new Set(M).size<=2&&M.every(O=>O===0||O===1),A=h?null:I(M),m=A===null?M:A.values,[u,b]=F(m,null,N,!0),[x,S]=F(m,null,N,!1),k;if(l==="ATO"){let[O,P]=F(m,a,g,!0);k=Math.sqrt(h?O*(1-O):P)}else{let O=h?[u*(1-u),x*(1-x)]:[b,S];if(k=Math.sqrt(l==="ATT"?O[0]:l==="ATC"?O[1]:(O[0]+O[1])/2),_(k,A?.unitExp??0)<Math.sqrt(Number.EPSILON)){let[P,le]=F(m,null,g,!0);k=Math.sqrt(h?P*(1-P):le)}}let E=h&&p==="raw"?1:k;if(v.type.push(f??(h?"Binary":"Contin.")),v.diffUn.push(u===x?0:(u-x)/E),v.vRatioUn.push(h||S===0?NaN:b/S),a===void 0){v.diffAdj.push(NaN),v.vRatioAdj.push(NaN);continue}let[C,j]=F(m,a,N,!0),[y,q]=F(m,a,N,!1);v.diffAdj.push(C===y?0:(C-y)/E),v.vRatioAdj.push(h||q===0?NaN:j/q)}for(let T of[!1,!0]){let M=0,f=0,h=0,A=0,m=0;for(let x=0;x<d;x++){if(N[x]!==T||(M++,c.has(x+1)&&m++,a===void 0))continue;let S=a[x];f+=S,h+=S*S,S>0&&A++}let u=T?v.observations.treated:v.observations.control;if(w){u.push(M,f*f/h);continue}let b=a===void 0?[NaN,NaN,NaN]:[f*f/h,A,M-A-m];o&&b.push(m),u.push(M,M,...b)}return v}function de(s,i,n={}){W(n,he,"tableOneSmd");let{factor:r=!1}=n;if(s.length!==i.length)throw new RangeError("'x' and 'group' must have the same length");let t=[...new Set(i)].sort((g,w)=>g<w?-1:g>w?1:0);if(t.length!==2)throw new RangeError("'group' must have exactly two levels");let p=g=>g!==null&&!(typeof g=="number"&&Number.isNaN(g)),e=t.map(g=>s.filter((w,v)=>i[v]===g&&p(w)));if(!r){if(e.flat().some(f=>typeof f!="number"))throw new TypeError("'x' must be numeric unless factor: true");let g=I(e.flat()).values,v=[g.slice(0,e[0].length),g.slice(e[0].length)].map(f=>{let h=f.reduce((A,m)=>A+m,0)/f.length;return[h,f.reduce((A,m)=>A+(m-h)*(m-h),0)/(f.length-1)]}),T=v[1][0]-v[0][0],M=Math.sqrt((v[0][1]+v[1][1])/2);return T===0?0:Math.abs(T)/M}let a=[...new Set(e.flat())].sort((g,w)=>typeof g=="number"&&typeof w=="number"?g-w:String(g)<String(w)?-1:String(g)>String(w)?1:0),l=e.map(g=>a.slice(1).map(w=>g.filter(v=>v===w).length/g.length)),c=l[1].map((g,w)=>g-l[0][w]);if(c.every(g=>g===0))return 0;let o=c.length,d=Array.from({length:o},(g,w)=>Array.from({length:o},(v,T)=>{let M=f=>w===T?f[w]*(1-f[w]):-f[w]*f[T];return(M(l[0])+M(l[1]))/2}));if(d.every(g=>g.every(w=>w===0)))return NaN;let N=Q(d),R=0;for(let g=0;g<o;g++)for(let w=0;w<o;w++)R+=c[g]*N[g][w]*c[w];return Math.sqrt(R)}var ge=["method","link","estimand","stabilize"],we=["at","lower","treat"],z=Number.EPSILON;function be(s){return s.map((i,n)=>{if(i===!0||i===1)return 1;if(i===!1||i===0)return 0;throw new RangeError(`'tr' must be 0 or 1 (element ${n+1})`)})}function ve(s,i){let n=[],r=[],t={};for(let[p,e]of Object.entries(s)){if(e.length!==i)throw new RangeError(`covariate '${p}' must have the length of 'tr'`);if(e.every(c=>typeof c=="number")){let c=e;if(c.some(o=>!Number.isFinite(o)))throw new RangeError(`covariate '${p}' has missing or infinite values`);n.push(p),r.push(c.slice());continue}if(!e.every(c=>typeof c=="string"))throw new TypeError(`covariate '${p}' must be all numbers or all strings`);let a=e,l=[...new Set(a)].sort(D);t[p]=l;for(let c of l.slice(1))n.push(p+c),r.push(a.map(o=>o===c?1:0))}return{names:n,columns:r,factors:t}}function ee(s){return s.map(i=>{let n=i.reduce((t,p)=>t+p,0)/i.length,r=i.reduce((t,p)=>Math.max(t,Math.abs(p-n)),0);return i.map(t=>r>0?(t-n)/r:0)})}function Me(s){let i=s[0]?.length??0,n=[new Array(i).fill(1/Math.sqrt(i))],r=[];for(let t of s){let p=Math.sqrt(t.reduce((l,c)=>l+c*c,0)),e=t.slice();for(let l=0;l<2;l++)for(let c of n){let o=e.reduce((d,N,R)=>d+N*c[R],0);for(let d=0;d<i;d++)e[d]-=o*c[d]}let a=Math.sqrt(e.reduce((l,c)=>l+c*c,0));a>1e-7*p&&(n.push(e.map(l=>l/a)),r.push(t))}return r}function ae(s,i){let n=i.length,r=s.map((e,a)=>[...e,i[a]]),t=0;for(let e of s)for(let a of e)t=Math.max(t,Math.abs(a));for(let e=0;e<n;e++){let a=e;for(let l=e+1;l<n;l++)Math.abs(r[l][e])>Math.abs(r[a][e])&&(a=l);if(!(Math.abs(r[a][e])>1e-13*t))return null;[r[e],r[a]]=[r[a],r[e]];for(let l=e+1;l<n;l++){let c=r[l][e]/r[e][e];if(c!==0)for(let o=e;o<=n;o++)r[l][o]-=c*r[e][o]}}let p=new Array(n).fill(0);for(let e=n-1;e>=0;e--){let a=r[e][n];for(let l=e+1;l<n;l++)a-=r[e][l]*p[l];p[e]=a/r[e][e]}return p}function Y(s,i){return Array.from({length:i},(n,r)=>[1,...s.map(t=>t[r])])}function te(s,i,n){let r=n.length,t=new Array(r).fill(0);t[0]=Math.log(n[0]/i.length);let p=c=>{let o=0;for(let d of i)o+=Math.exp(s[d].reduce((N,R,g)=>N+R*c[g],0));return o-n.reduce((d,N,R)=>d+N*c[R],0)},e=p(t),a=!1,l=1e-13*Math.max(1,Math.abs(n[0]));for(let c=0;c<200;c++){let o=n.map(f=>-f),d=Array.from({length:r},()=>new Array(r).fill(0));for(let f of i){let h=s[f],A=Math.exp(h.reduce((m,u,b)=>m+u*t[b],0));for(let m=0;m<r;m++){o[m]+=A*h[m];for(let u=0;u<=m;u++)d[m][u]+=A*h[m]*h[u]}}for(let f=0;f<r;f++)for(let h=f+1;h<r;h++)d[f][h]=d[h][f];let N=Math.max(...o.map(Math.abs));if(N<=l){a=!0;break}let R=ae(d,o.map(f=>-f));if(R===null||R.some(f=>!Number.isFinite(f)))break;let g=1e-12*(Math.abs(e)+1),w=1,v=t.map((f,h)=>f+R[h]),T=p(v);for(;!(T<=e+g)&&w>1e-10;)w/=2,v=t.map((f,h)=>f+w*R[h]),T=p(v);if(!(T<=e+g))break;let M=R.some((f,h)=>Math.abs(w*f)>1e-15*Math.max(1,Math.abs(t[h])));if(t.splice(0,r,...v),e=T,!M){a=N<=1e-9*Math.max(1,Math.abs(n[0]));break}}return{eta:s.map(c=>c.reduce((o,d,N)=>o+d*t[N],0)),converged:a}}var Te={logit:{p:s=>$(s),q:s=>$(-s),d:s=>$(s)*$(-s)},probit:{p:s=>U(s),q:s=>U(-s),d:s=>V(s)}};function Ae(s,i,n,r,t){let p=i.length,e=t.length,a=t.slice(),l=w=>{let v=new Array(e).fill(0),T=Array.from({length:e},()=>new Array(e).fill(0));for(let M=0;M<p;M++){let f=s[M],h=f.reduce((k,E,C)=>k+E*w[C],0),A=r.p(h),m=r.q(h),u=r.d(h),b=i[M],x,S;n==="ATE"?(x=b?1/A:-1/m,S=b?-u/(A*A):-u/(m*m)):n==="ATT"?(x=b?1:-A/m,S=b?0:-u/(m*m)):n==="ATC"?(x=b?m/A:-1,S=b?-u/(A*A):0):(x=b?m:-A,S=-u);for(let k=0;k<e;k++){v[k]+=x*f[k];for(let E=0;E<e;E++)T[k][E]+=S*f[k]*f[E]}}return{g:v,J:T}},c=w=>w.reduce((v,T)=>v+T*T,0),{g:o,J:d}=l(a),N=c(o),R=!1,g=1e-12*p;for(let w=0;w<200;w++){if(Math.max(...o.map(Math.abs))<=g){R=!0;break}let v=ae(d,o.map(A=>-A));if(v===null||v.some(A=>!Number.isFinite(A)))break;let T=1,M=a.map((A,m)=>A+v[m]),f=l(M),h=c(f.g);for(;!(h<N)&&T>1e-10;)T/=2,M=a.map((A,m)=>A+T*v[m]),f=l(M),h=c(f.g);if(!(h<N)){R=Math.max(...o.map(Math.abs))<=1e-8*p;break}a=M,o=f.g,d=f.J,N=h}return{eta:s.map(w=>w.reduce((v,T,M)=>v+T*a[M],0)),converged:R}}function ne(s,i,n,r){switch(s){case"ATE":return i?1/n:1/r;case"ATT":return i?1:n/r;case"ATC":return i?r/n:1;default:return i?r:n}}var ye={glm:"glm.fit: algorithm did not converge",cbps:"The covariate balancing conditions could not be solved, so the covariates will not be exactly balanced.",ipt:"The optimization failed to converge; consider using fewer covariates or a different link function.",ebal:"The estimated weights do not balance the covariates, indicating the optimization arrived at a degenerate solution. Try decreasing the number of variables supplied to the optimization."},re={cbps:"covariate balancing propensity score weighting",ipt:"inverse probability tilting",ebal:"entropy balancing"};function Ee(s,i,n={}){W(n,ge,"weightit");let{method:r="glm",estimand:t="ATE",stabilize:p=!1}=n,e=r==="ps"?"glm":r;if(!["glm","cbps","ipt","ebal"].includes(e))throw new RangeError(`unknown method '${String(r)}'`);if(!["ATE","ATT","ATC","ATO"].includes(t))throw new RangeError(`unknown estimand '${String(t)}'`);let a=e==="ebal"?null:n.link??"logit";if(a!==null&&!{glm:["logit","probit","cauchit","cloglog"],cbps:["logit","probit"],ipt:["logit"]}[e].includes(a))throw new RangeError(`link '${a}' is not available for method '${e}'`);if((e==="ipt"||e==="ebal")&&t==="ATO")throw new RangeError(`"ATO" is not an allowable estimand for ${re[e]} with a binary treatment. Only "ATE", "ATT", and "ATC" are allowed.`);let c=[];if(p&&e==="glm"&&t!=="ATE")throw new RangeError('`stabilize` can only be supplied when `estimand = "ATE"`.');p&&e!=="glm"&&c.push(`\`stabilize\` cannot be used with ${re[e]} and will be ignored.`);let o=be(s),d=o.length;if(!o.includes(0)||!o.includes(1))throw new RangeError("The treatment must have at least two unique values.");let{names:N,columns:R}=ve(i,d);if(R.length===0)throw new RangeError("'covariates' must have at least one column");let g=Me(R.map(m=>I(m).values)),w=o.flatMap((m,u)=>m?[u]:[]),v=o.flatMap((m,u)=>m?[]:[u]),T=o.map((m,u)=>u),M=t==="ATT"?1:t==="ATC"?0:null,f=null,h,A=!0;if(e==="glm"){let m=B(()=>L(Y(g,d).map(u=>u.slice(1)),o,{family:"binomial",link:a}));A=m.converged,f=m.fittedValues.map((u,b)=>a==="logit"&&Math.abs(m.linearPredictors[b])>30?m.linearPredictors[b]>0?1-z:z:Math.min(Math.max(u,z),1-z)),h=o.map((u,b)=>ne(t,u,f[b],1-f[b])),f.some(u=>u<=10*z||u>=1-10*z)&&c.push("Propensity scores numerically equal to 0 or 1 were estimated, indicating perfect separation. These may yield problems with inference. See `?method_glm` (`?WeightIt::method_glm()`) for details.")}else if(e==="cbps"){let m=ee(g),u=Y(m,d),b=B(()=>L(u.map(E=>E.slice(1)),o,{family:"binomial",link:a})).coefficients.map(E=>Number.isFinite(E)?E:0),x=Te[a],S=Ae(u,o,t,x,b);A=S.converged;let k=E=>Math.min(Math.max(E,z),1-z);f=S.eta.map(E=>k(x.p(E))),h=o.map((E,C)=>ne(t,E,f[C],k(x.q(S.eta[C]))))}else{let m=ee(g),u=Y(m,d),b=C=>u[0].map((j,y)=>C.reduce((q,O)=>q+u[O][y],0)),x={C:t!=="ATC",T:t!=="ATT"},S=e==="ebal"&&t==="ATE"?{C:b(T),T:b(T)}:{C:b(w),T:b(v)},k=x.C?te(u,v,S.C):null,E=x.T?te(u,w,S.T):null;if(A=(k?.converged??!0)&&(E?.converged??!0),e==="ebal")h=o.map((C,j)=>C?E?Math.exp(E.eta[j]):1:k?Math.exp(k.eta[j]):1);else{let C=t==="ATE"?1:0;h=o.map((j,y)=>j?E?C+Math.exp(E.eta[y]):1:k?C+Math.exp(k.eta[y]):1),f=o.map((j,y)=>t==="ATT"?$(k.eta[y]):t==="ATC"?$(-E.eta[y]):j?$(-E.eta[y]):$(k.eta[y]))}}if(A||c.push(ye[e]),p&&e==="glm"){let m=[v.length/d,w.length/d];h=h.map((u,b)=>u*m[o[b]])}return h.every(m=>Math.abs(m-1)<Math.sqrt(z))&&c.push("All weights are 1, possibly indicating an estimation failure."),K("weightit",{weights:h,ps:f,treat:o,estimand:t,method:e,link:a,stabilized:p&&e==="glm",focal:M,columnNames:N,converged:A,warnings:c})}function oe(s,i,n,r){let t=s.slice();if(i.length===0)return t;let p=i.map(l=>s[l]),e,a;if(n<1){let l=n<.5?1-n:n;e=H(p,l,{type:3}),a=H(p,1-l,{type:3})}else{if(!Number.isInteger(n))throw new RangeError("'at' must be below 1 or a whole number");if(n>=p.length)return null;let l=n>p.length/2?p.length-n:n,c=p.slice().sort((o,d)=>o-d);e=c[c.length-1-l],a=c[l]}for(let l of i)s[l]>e&&(t[l]=e),r&&s[l]<a&&(t[l]=a);return t}var se=s=>`\`at\` must be less than ${s}, the number of units. Weights will not be trimmed.`;function Ne(s,i){W(i,we,"trimWeights");let{at:n,lower:r=!1}=i;if(!(n>0)||!Number.isFinite(n))throw new RangeError("'at' must be a positive number");if(Array.isArray(s)||ArrayBuffer.isView(s)){let a=Array.from(s);if(i.treat!==void 0&&i.treat.length!==a.length)throw new RangeError("'treat' must have the length of 'w'");let l=oe(a,a.map((c,o)=>o),n,r);return l===null?(J("trimWeights",[se(a.length)]),a):l}let t=s,p=t.treat.flatMap((a,l)=>t.focal===null||a!==t.focal?[l]:[]),e=oe(t.weights,p,n,r);return e===null?K("trimWeights",{...t,weights:t.weights.slice(),warnings:[se(p.length)]}):{...t,weights:e,warnings:t.warnings.slice()}}function ie(s,i){let n=i.map(o=>s[o]),r=n.length,t=0,p=0;for(let o of n)t+=o,p+=o*o;let e=t/r,a=n.reduce((o,d)=>o+(d-e)*(d-e),0),l=n.map(o=>e>0?o/e:NaN),c=n.map((o,d)=>d).sort((o,d)=>n[d]-n[o]||o-d).slice(0,5).reverse();return{range:[Math.min(...n),Math.max(...n)],top:{index:c.map(o=>i[o]+1),weights:c.map(o=>n[o])},mean:e,coefOfVar:Math.sqrt(a/(r-1))/e,scaledMad:l.reduce((o,d)=>o+Math.abs(d-1),0)/r,negativeEntropy:l.reduce((o,d)=>o+(Number.isNaN(d)?NaN:d>0?d*Math.log(d):0),0)/r,numZeros:n.filter(o=>Math.abs(o)<1e-10).length,n:r,ess:t*t/p}}function xe(s){let i=s.treat.flatMap((r,t)=>r?[t]:[]),n=s.treat.flatMap((r,t)=>r?[]:[t]);return{treated:ie(s.weights,i),control:ie(s.weights,n),stabilized:s.stabilized}}export{pe as balTab,fe as match,X as matchWeights,de as tableOneSmd,Ne as trimWeights,xe as weightSummary,Ee as weightit};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.13.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{b as A}from"./chunk-2BXB6DRK.js";var y=t=>new SyntaxError(`invalid formula: ${t}`),L=/^(?:[\p{L}\p{Nl}.]|(?![0-9])\p{Nd})[\p{L}\p{Nl}\p{Nd}\p{M}._]*/u;function R(t,u,i=!1){let a=[],n=0;for(;n<t.length;){let e=t[n];if(/\s/.test(e)){n++;continue}if(/[0-9]/.test(e)||e==="."&&/[0-9]/.test(t[n+1]??"")){let c=/^(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:[eE][+-]?[0-9]+)?/.exec(t.slice(n));a.push({kind:"num",text:c[0]}),n+=c[0].length;continue}let r=L.exec(t.slice(n));if(r!==null){a.push({kind:"name",text:r[0]}),n+=r[0].length;continue}if(t.startsWith("%in%",n)){a.push({kind:"op",text:"%in%"}),n+=4;continue}if(u&&e==="|"){let c=t[n+1]==="|"?"||":"|";a.push({kind:"op",text:c}),n+=c.length;continue}if("~+-*/:^()".includes(e)||i&&e===","){a.push({kind:"op",text:e}),n++;continue}throw y(`unexpected '${e}'`)}return a.push({kind:"end"}),a}var T={"|":.5,"||":.5,"+":1,"-":1,"*":2,"/":2,"%in%":3,":":4,"^":6},C=5;function I(t,u=!1,i=!1,a=!1){if(typeof t!="string")throw new TypeError("the formula must be a string");let n=R(t,i,a),e=0,r=()=>n[e],c=()=>n[e++],f=(o,d)=>o.kind==="op"&&o.text===d;function m(){let o=c();if(o.kind==="name"){if(f(r(),"(")){if(o.text!=="Error"||!u)throw y(`function calls are not supported (${o.text})`);c();let d=g(0);if(!f(c(),")"))throw y("missing ')'");return{type:"Error",arg:d}}if(o.text===".")return{type:"dot"};if(/^\.[0-9]/.test(o.text))throw y(`unexpected '${o.text}'`);return{type:"var",name:o.text}}if(o.kind==="num")return{type:"num",value:Number(o.text),text:o.text};if(o.kind==="op"&&o.text==="("){let d=g(0);if(!f(c(),")"))throw y("missing ')'");return{type:"paren",arg:d}}if(o.kind==="op"&&(o.text==="-"||o.text==="+"))return{type:"unary",op:o.text,arg:g(C)};throw y(o.kind==="end"?"unexpected end of input":`unexpected '${o.kind==="op"?o.text:""}'`)}function g(o){let d=m();for(;;){let x=r();if(x.kind!=="op")break;let h=T[x.text];if(h===void 0||h<=o)break;c();let v=g(x.text==="^"?h-1:h);d=x.text==="|"||x.text==="||"?{type:"bar",double:x.text==="||",lhs:d,group:v}:{type:"binary",op:x.text,left:d,right:v}}return d}let b,l,s=n[0];if(a&&s.kind==="name"&&s.text==="cbind"&&f(n[1],"(")){let o=n[2],d=n[4],x=h=>h.kind==="name"&&h.text!=="."&&!/^\.[0-9]/.test(h.text);if(!(x(o)&&f(n[3],",")&&x(d)&&f(n[5],")")&&f(n[6],"~")))throw y("the response cbind() must have two column names: cbind(successes, failures)");l=[o.text,d.text],b=l[0],e=6}else if(!f(r(),"~")){let o=c();if(o.kind!=="name"||o.text==="."||!f(r(),"~"))throw y("the response must be a variable name followed by '~'");b=o.text}c();let p=g(0);if(r().kind!=="end")throw y("unexpected input after the formula");return l===void 0?{response:b,rhs:p}:{response:b,responseColumns:l,rhs:p}}function V(t){let u=[],i=e=>{if(e.type==="Error"){u.push(e.arg);return}if(e.type==="paren"){let r=i(e.arg);return r===void 0?void 0:{...e,arg:r}}if(e.type==="binary"&&e.op==="+"){let r=i(e.left),c=i(e.right);return r===void 0?c:c===void 0?r:{...e,left:r,right:c}}if(e.type==="binary"&&e.op==="-"){let r=i(e.left);return r===void 0?{type:"unary",op:"-",arg:e.right}:{...e,left:r}}return e},a=i(t),n=e=>{if(e.type==="Error")throw y("Error() must be a term of the right-hand side");e.type==="binary"?(n(e.left),n(e.right)):(e.type==="unary"||e.type==="paren")&&n(e.arg)};return a!==void 0&&n(a),u.forEach(n),{treatment:a,errors:u}}function Y(t){let u=[],i=e=>{switch(e.type){case"bar":u.push(e);return;case"paren":{let r=i(e.arg);return r===void 0?void 0:{...e,arg:r}}case"binary":if(e.op==="+"){let r=i(e.left),c=i(e.right);return r===void 0?c:c===void 0?r:{...e,left:r,right:c}}if(e.op==="-"){let r=i(e.left);return r===void 0?{type:"unary",op:"-",arg:e.right}:{...e,left:r}}return e;default:return e}},a=i(t),n=e=>{if(e.type==="bar")throw y("a random-effects term (lhs | group) must be a term of the right-hand side");e.type==="binary"?(n(e.left),n(e.right)):(e.type==="unary"||e.type==="paren"||e.type==="Error")&&n(e.arg)};a!==void 0&&n(a);for(let e of u)n(e.lhs),n(e.group);return{fixed:a,bars:u}}var M=new Set(["+","-","*","%in%"]);function w(t){switch(t.type){case"var":return t.name;case"dot":return".";case"num":return A(t.value);case"binary":{let u=w(t.left),i=w(t.right);return M.has(t.op)?`${u} ${t.op} ${i}`:`${u}${t.op}${i}`}case"unary":return`${t.op}${w(t.arg)}`;case"paren":return`(${w(t.arg)})`;case"Error":return`Error(${w(t.arg)})`;case"bar":return`${w(t.lhs)} ${t.double?"||":"|"} ${w(t.group)}`}}function k(t,u,i){if(t!==void 0)switch(t.type){case"var":i.includes(t.name)||i.push(t.name);return;case"dot":for(let a of u)i.includes(a)||i.push(a);return;case"num":return;case"binary":k(t.left,u,i),t.op!=="^"&&k(t.right,u,i);return;case"unary":case"paren":case"Error":k(t.arg,u,i);return;case"bar":k(t.lhs,u,i),k(t.group,u,i)}}function j(t,u){let i=[];return k(t,u,i),i}var N=t=>t.join(",");function E(t){let u=new Set;return t.filter(i=>{let a=N(i);return u.has(a)?!1:(u.add(a),!0)})}var $=(t,u)=>[...new Set([...t,...u])].sort((i,a)=>i-a);function B(t,u,i){let a=!0,n=(r,c)=>{switch(r.type){case"var":return[[u(r.name)]];case"dot":return i.map(f=>[u(f)]);case"num":if(r.value===1)a=!c;else if(r.value===0)a=c;else throw y(`a number (${r.text}) is not a term`);return[];case"paren":return n(r.arg,c);case"Error":throw y("Error() must be a term of the right-hand side");case"bar":throw y("a random-effects term (lhs | group) must be a term of the right-hand side");case"unary":return r.op==="+"?n(r.arg,c):(n(r.arg,!c),[]);case"binary":{if(r.op==="^"){let l=n(r.left,c),s=r.right;for(;s.type==="paren";)s=s.arg;let p=s.type==="num"?Math.trunc(s.value):NaN;if(!(p>=2&&p<=2147483647))throw new Error("invalid power in formula");let o=l;for(let d=1;d<p;d++){let x=[];for(let S of l)for(let O of o)x.push($(S,O));let h=E(x),v=h.length===o.length&&h.every((S,O)=>N(S)===N(o[O]));if(o=h,v)break}return o}if(r.op==="-"){let l=n(r.left,c),s=new Set(n(r.right,!c).map(N));return l.filter(p=>!s.has(N(p)))}let f=n(r.left,c),m=n(r.right,c);if(f.length===0&&r.op!=="+")return[];let g=()=>{let l=[];for(let s of f)for(let p of m)l.push($(s,p));return l},b=l=>l.reduce((s,p)=>$(s,p),[]);switch(r.op){case"+":return E([...f,...m]);case":":return E(g());case"*":return E([...f,...m,...g()]);case"/":{let l=b(f);return E([...f,...m.map(s=>$(s,l))])}case"%in%":{let l=b(m);return E(f.map(s=>$(s,l)))}}}}throw y("unsupported expression")};return{terms:t===void 0?[]:n(t,!1),intercept:a}}function z(t,u,i=t.rhs){let{response:a,responseColumns:n}=t,e=u.filter(s=>s!==a&&!(n?.includes(s)??!1)),r=a===void 0?[]:[a];n!==void 0&&n[1]!==a&&r.push(n[1]),k(t.rhs,e,r);let f=B(i,s=>r.indexOf(s),e),m=f.terms.map((s,p)=>[s,p]).sort((s,p)=>s[0].length-p[0].length||s[1]-p[1]).map(([s])=>s),g=[],b=a===void 0?-1:m.findIndex(s=>s.length===1&&s[0]===0);b>=0&&(g.push("the response appeared on the right-hand side and was dropped"),g.push(`problem with term ${b+1} in model.matrix: no columns are assigned`));let l=r.map(()=>m.map(()=>0));return m.forEach((s,p)=>{for(let o of s){let d=s.filter(h=>h!==o),x=d.length===0||m.slice(0,p).some(h=>d.every(v=>h.includes(v)));l[o][p]=x?1:2}}),{variables:r,response:a===void 0?-1:0,terms:m,termLabels:m.map(s=>s.map(p=>r[p]).join(":")),order:m.map(s=>s.length),intercept:f.intercept,factors:l,responseTerm:b,warnings:g}}export{I as a,V as b,Y as c,w as d,j as e,B as f,z as g};
1
+ /*! rStats.js 1.14.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{b as A}from"./chunk-PHDTVTKV.js";var y=t=>new SyntaxError(`invalid formula: ${t}`),L=/^(?:[\p{L}\p{Nl}.]|(?![0-9])\p{Nd})[\p{L}\p{Nl}\p{Nd}\p{M}._]*/u;function R(t,u,i=!1){let a=[],n=0;for(;n<t.length;){let e=t[n];if(/\s/.test(e)){n++;continue}if(/[0-9]/.test(e)||e==="."&&/[0-9]/.test(t[n+1]??"")){let c=/^(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:[eE][+-]?[0-9]+)?/.exec(t.slice(n));a.push({kind:"num",text:c[0]}),n+=c[0].length;continue}let r=L.exec(t.slice(n));if(r!==null){a.push({kind:"name",text:r[0]}),n+=r[0].length;continue}if(t.startsWith("%in%",n)){a.push({kind:"op",text:"%in%"}),n+=4;continue}if(u&&e==="|"){let c=t[n+1]==="|"?"||":"|";a.push({kind:"op",text:c}),n+=c.length;continue}if("~+-*/:^()".includes(e)||i&&e===","){a.push({kind:"op",text:e}),n++;continue}throw y(`unexpected '${e}'`)}return a.push({kind:"end"}),a}var T={"|":.5,"||":.5,"+":1,"-":1,"*":2,"/":2,"%in%":3,":":4,"^":6},C=5;function I(t,u=!1,i=!1,a=!1){if(typeof t!="string")throw new TypeError("the formula must be a string");let n=R(t,i,a),e=0,r=()=>n[e],c=()=>n[e++],f=(o,d)=>o.kind==="op"&&o.text===d;function m(){let o=c();if(o.kind==="name"){if(f(r(),"(")){if(o.text!=="Error"||!u)throw y(`function calls are not supported (${o.text})`);c();let d=g(0);if(!f(c(),")"))throw y("missing ')'");return{type:"Error",arg:d}}if(o.text===".")return{type:"dot"};if(/^\.[0-9]/.test(o.text))throw y(`unexpected '${o.text}'`);return{type:"var",name:o.text}}if(o.kind==="num")return{type:"num",value:Number(o.text),text:o.text};if(o.kind==="op"&&o.text==="("){let d=g(0);if(!f(c(),")"))throw y("missing ')'");return{type:"paren",arg:d}}if(o.kind==="op"&&(o.text==="-"||o.text==="+"))return{type:"unary",op:o.text,arg:g(C)};throw y(o.kind==="end"?"unexpected end of input":`unexpected '${o.kind==="op"?o.text:""}'`)}function g(o){let d=m();for(;;){let x=r();if(x.kind!=="op")break;let h=T[x.text];if(h===void 0||h<=o)break;c();let v=g(x.text==="^"?h-1:h);d=x.text==="|"||x.text==="||"?{type:"bar",double:x.text==="||",lhs:d,group:v}:{type:"binary",op:x.text,left:d,right:v}}return d}let b,l,s=n[0];if(a&&s.kind==="name"&&s.text==="cbind"&&f(n[1],"(")){let o=n[2],d=n[4],x=h=>h.kind==="name"&&h.text!=="."&&!/^\.[0-9]/.test(h.text);if(!(x(o)&&f(n[3],",")&&x(d)&&f(n[5],")")&&f(n[6],"~")))throw y("the response cbind() must have two column names: cbind(successes, failures)");l=[o.text,d.text],b=l[0],e=6}else if(!f(r(),"~")){let o=c();if(o.kind!=="name"||o.text==="."||!f(r(),"~"))throw y("the response must be a variable name followed by '~'");b=o.text}c();let p=g(0);if(r().kind!=="end")throw y("unexpected input after the formula");return l===void 0?{response:b,rhs:p}:{response:b,responseColumns:l,rhs:p}}function V(t){let u=[],i=e=>{if(e.type==="Error"){u.push(e.arg);return}if(e.type==="paren"){let r=i(e.arg);return r===void 0?void 0:{...e,arg:r}}if(e.type==="binary"&&e.op==="+"){let r=i(e.left),c=i(e.right);return r===void 0?c:c===void 0?r:{...e,left:r,right:c}}if(e.type==="binary"&&e.op==="-"){let r=i(e.left);return r===void 0?{type:"unary",op:"-",arg:e.right}:{...e,left:r}}return e},a=i(t),n=e=>{if(e.type==="Error")throw y("Error() must be a term of the right-hand side");e.type==="binary"?(n(e.left),n(e.right)):(e.type==="unary"||e.type==="paren")&&n(e.arg)};return a!==void 0&&n(a),u.forEach(n),{treatment:a,errors:u}}function Y(t){let u=[],i=e=>{switch(e.type){case"bar":u.push(e);return;case"paren":{let r=i(e.arg);return r===void 0?void 0:{...e,arg:r}}case"binary":if(e.op==="+"){let r=i(e.left),c=i(e.right);return r===void 0?c:c===void 0?r:{...e,left:r,right:c}}if(e.op==="-"){let r=i(e.left);return r===void 0?{type:"unary",op:"-",arg:e.right}:{...e,left:r}}return e;default:return e}},a=i(t),n=e=>{if(e.type==="bar")throw y("a random-effects term (lhs | group) must be a term of the right-hand side");e.type==="binary"?(n(e.left),n(e.right)):(e.type==="unary"||e.type==="paren"||e.type==="Error")&&n(e.arg)};a!==void 0&&n(a);for(let e of u)n(e.lhs),n(e.group);return{fixed:a,bars:u}}var M=new Set(["+","-","*","%in%"]);function w(t){switch(t.type){case"var":return t.name;case"dot":return".";case"num":return A(t.value);case"binary":{let u=w(t.left),i=w(t.right);return M.has(t.op)?`${u} ${t.op} ${i}`:`${u}${t.op}${i}`}case"unary":return`${t.op}${w(t.arg)}`;case"paren":return`(${w(t.arg)})`;case"Error":return`Error(${w(t.arg)})`;case"bar":return`${w(t.lhs)} ${t.double?"||":"|"} ${w(t.group)}`}}function k(t,u,i){if(t!==void 0)switch(t.type){case"var":i.includes(t.name)||i.push(t.name);return;case"dot":for(let a of u)i.includes(a)||i.push(a);return;case"num":return;case"binary":k(t.left,u,i),t.op!=="^"&&k(t.right,u,i);return;case"unary":case"paren":case"Error":k(t.arg,u,i);return;case"bar":k(t.lhs,u,i),k(t.group,u,i)}}function j(t,u){let i=[];return k(t,u,i),i}var N=t=>t.join(",");function E(t){let u=new Set;return t.filter(i=>{let a=N(i);return u.has(a)?!1:(u.add(a),!0)})}var $=(t,u)=>[...new Set([...t,...u])].sort((i,a)=>i-a);function B(t,u,i){let a=!0,n=(r,c)=>{switch(r.type){case"var":return[[u(r.name)]];case"dot":return i.map(f=>[u(f)]);case"num":if(r.value===1)a=!c;else if(r.value===0)a=c;else throw y(`a number (${r.text}) is not a term`);return[];case"paren":return n(r.arg,c);case"Error":throw y("Error() must be a term of the right-hand side");case"bar":throw y("a random-effects term (lhs | group) must be a term of the right-hand side");case"unary":return r.op==="+"?n(r.arg,c):(n(r.arg,!c),[]);case"binary":{if(r.op==="^"){let l=n(r.left,c),s=r.right;for(;s.type==="paren";)s=s.arg;let p=s.type==="num"?Math.trunc(s.value):NaN;if(!(p>=2&&p<=2147483647))throw new Error("invalid power in formula");let o=l;for(let d=1;d<p;d++){let x=[];for(let S of l)for(let O of o)x.push($(S,O));let h=E(x),v=h.length===o.length&&h.every((S,O)=>N(S)===N(o[O]));if(o=h,v)break}return o}if(r.op==="-"){let l=n(r.left,c),s=new Set(n(r.right,!c).map(N));return l.filter(p=>!s.has(N(p)))}let f=n(r.left,c),m=n(r.right,c);if(f.length===0&&r.op!=="+")return[];let g=()=>{let l=[];for(let s of f)for(let p of m)l.push($(s,p));return l},b=l=>l.reduce((s,p)=>$(s,p),[]);switch(r.op){case"+":return E([...f,...m]);case":":return E(g());case"*":return E([...f,...m,...g()]);case"/":{let l=b(f);return E([...f,...m.map(s=>$(s,l))])}case"%in%":{let l=b(m);return E(f.map(s=>$(s,l)))}}}}throw y("unsupported expression")};return{terms:t===void 0?[]:n(t,!1),intercept:a}}function z(t,u,i=t.rhs){let{response:a,responseColumns:n}=t,e=u.filter(s=>s!==a&&!(n?.includes(s)??!1)),r=a===void 0?[]:[a];n!==void 0&&n[1]!==a&&r.push(n[1]),k(t.rhs,e,r);let f=B(i,s=>r.indexOf(s),e),m=f.terms.map((s,p)=>[s,p]).sort((s,p)=>s[0].length-p[0].length||s[1]-p[1]).map(([s])=>s),g=[],b=a===void 0?-1:m.findIndex(s=>s.length===1&&s[0]===0);b>=0&&(g.push("the response appeared on the right-hand side and was dropped"),g.push(`problem with term ${b+1} in model.matrix: no columns are assigned`));let l=r.map(()=>m.map(()=>0));return m.forEach((s,p)=>{for(let o of s){let d=s.filter(h=>h!==o),x=d.length===0||m.slice(0,p).some(h=>d.every(v=>h.includes(v)));l[o][p]=x?1:2}}),{variables:r,response:a===void 0?-1:0,terms:m,termLabels:m.map(s=>s.map(p=>r[p]).join(":")),order:m.map(s=>s.length),intercept:f.intercept,factors:l,responseTerm:b,warnings:g}}export{I as a,V as b,Y as c,w as d,j as e,B as f,z as g};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.13.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{a as A,c as C,e as O,g as V,i as _}from"./chunk-CEY7FHMZ.js";import{h as z}from"./chunk-3T4TVNXS.js";import{l as R}from"./chunk-AH6IVJRF.js";function B(y,M,o,l){let c=0,f=1;for(let e=0;e<o;e++){let p=y[M+e*l];if(p===0)continue;let a=Math.abs(p);c<a?(f=1+f*(c/a)**2,c=a):f+=(a/c)**2}return c*Math.sqrt(f)}function G(y,M){let o=M.nrow,l=M.data,c=(s,h)=>s+h*o,f=new Float64Array(o),e=(s,h,N)=>{for(let k=0;k<N;k++)[l[c(k,s)],l[c(k,h)]]=[l[c(k,h)],l[c(k,s)]]},p=(s,h,N)=>{for(let k=N;k<o;k++)[l[c(s,k)],l[c(h,k)]]=[l[c(h,k)],l[c(s,k)]]},a=0,t=o-1;if(y!=="S"){let s=!0;for(;s;){s=!1;for(let h=t;h>=0;h--){let N=!0;for(let k=0;k<=t;k++)if(h!==k&&l[c(h,k)]!==0){N=!1;break}if(N){if(f[t]=h,h!==t&&(e(h,t,t+1),p(h,t,a)),s=!0,t===0)return{ilo:0,ihi:0,scale:f};t--}}}for(s=!0;s;){s=!1;for(let h=a,N=t;h<=N;h++){let k=!0;for(let j=a;j<=t;j++)if(j!==h&&l[c(j,h)]!==0){k=!1;break}k&&(f[a]=h,h!==a&&(e(h,a,t+1),p(h,a,a)),s=!0,a++)}}}for(let s=a;s<=t;s++)f[s]=1;if(y==="P")return{ilo:a,ihi:t,scale:f};let i=2,g=.95,n=2**-1022/Number.EPSILON,v=1/n,m=n*i,b=1/m,w=!0;for(;w;){w=!1;for(let s=a;s<=t;s++){let h=B(l,c(a,s),t-a+1,1),N=B(l,c(s,a),t-a+1,o),k=0;for(let F=0;F<=t;F++)k=Math.max(k,Math.abs(l[c(F,s)]));let j=0;for(let F=a;F<o;F++)j=Math.max(j,Math.abs(l[c(s,F)]));if(h===0||N===0)continue;if(Number.isNaN(h+k+N+j))throw new RangeError("the matrix contains NaN or infinite values");let E=N/i,q=1,I=h+N;for(;h<E&&Math.max(q,h,k)<b&&Math.min(N,E,j)>m;)q*=i,h*=i,k*=i,N/=i,E/=i,j/=i;for(E=h/i;E>=N&&Math.max(N,j)<b&&Math.min(q,h,E,k)>m;)q/=i,h/=i,E/=i,k/=i,N*=i,j*=i;if(!(h+N>=g*I)&&!(q<1&&f[s]<1&&q*f[s]<=n)&&!(q>1&&f[s]>1&&f[s]>=v/q)){E=1/q,f[s]=f[s]*q,w=!0;for(let F=a;F<o;F++)l[c(s,F)]=l[c(s,F)]*E;for(let F=0;F<=t;F++)l[c(F,s)]=l[c(F,s)]*q}}}return{ilo:a,ihi:t,scale:f}}function K(y,M){let{ilo:o,ihi:l,scale:c}=y,f=M.nrow,e=M.ncol,p=M.data;if(f===0||e===0)return;if(o!==l)for(let t=o;t<=l;t++){let i=c[t];for(let g=0;g<e;g++)p[t+g*f]=p[t+g*f]*i}let a=t=>{let i=c[t];if(i!==t)for(let g=0;g<e;g++)[p[t+g*f],p[i+g*f]]=[p[i+g*f],p[t+g*f]]};for(let t=o-1;t>=0;t--)a(t);for(let t=l+1;t<f;t++)a(t)}var T=["symmetric","onlyValues"];function rt(y,M={}){R(M,T,"eigen");let o=C(y);if(V(o),o.nrow===0)throw new RangeError("the matrix has zero dimension");for(let a of o.data)if(!Number.isFinite(a))throw new RangeError("the matrix contains NaN or infinite values");let l=_(o.data,459),c=l===0?o:{...o,data:o.data.map(a=>z(a,-l))},f=M.symmetric??D(Y(o)),e=!(M.onlyValues??!1),p=f?H(c,e):U(c,e);return l!==0&&(p.values=p.values.map(a=>z(a,l)),p.valuesIm&&(p.valuesIm=p.valuesIm.map(a=>z(a,l)))),p}function Y(y){let M=0;for(let l of y.data)M=Math.max(M,Math.abs(l));if(M===0)return y;let o=2**Math.min(1023,-Math.floor(Math.log2(M)));return o===1?y:{...y,data:y.data.map(l=>l*o)}}function D(y){let M=y.nrow,o=i=>{let g=0,n=0,v=0,m=0;for(let b=0;b<M;b++)for(let w=0;w<M;w++){let s=y.data[w+b*M],h=y.data[b+w*M];s!==h&&(g+=Math.abs(s*i-h*i),n+=Math.abs(s*i),v++,m=Math.max(m,Math.abs(s)))}return{diff:g,size:n,count:v,mx:m}},{diff:l,size:c,count:f,mx:e}=o(1);if(f===0)return!0;(!Number.isFinite(l)||!Number.isFinite(c))&&({diff:l,size:c}=o(2**-Math.floor(Math.log2(e))));let p=100*Number.EPSILON,a=c/f,t=l/f;return(Number.isFinite(a)&&a>p?t/a:t)<=p}function H(y,M){let o=y.nrow,l=A(o,o);for(let a=0;a<o;a++)for(let t=a;t<o;t++)l.data[t+a*o]=y.data[t+a*o],l.data[a+t*o]=y.data[t+a*o];let c=new Float64Array(o),f=new Float64Array(o);J(l,c,f),Q(l,c,f);let e=Array.from(c).reverse();if(!M)return{values:e};let p=A(o,o);for(let a=0;a<o;a++)p.data.set(l.data.subarray((o-1-a)*o,(o-a)*o),a*o);return{values:e,vectors:O(p)}}function J(y,M,o){let l=y.nrow,c=y.data,f=(e,p)=>e+p*l;for(let e=0;e<l;e++)M[e]=c[f(l-1,e)];for(let e=l-1;e>0;e--){let p=0,a=0;for(let t=0;t<e;t++)p+=Math.abs(M[t]);if(p===0){o[e]=M[e-1];for(let t=0;t<e;t++)M[t]=c[f(e-1,t)],c[f(e,t)]=0,c[f(t,e)]=0}else{for(let n=0;n<e;n++)M[n]/=p,a+=M[n]*M[n];let t=M[e-1],i=Math.sqrt(a);t>0&&(i=-i),o[e]=p*i,a-=t*i,M[e-1]=t-i;for(let n=0;n<e;n++)o[n]=0;for(let n=0;n<e;n++){t=M[n],c[f(n,e)]=t,i=o[n]+c[f(n,n)]*t;for(let v=n+1;v<=e-1;v++)i+=c[f(v,n)]*M[v],o[v]+=c[f(v,n)]*t;o[n]=i}t=0;for(let n=0;n<e;n++)o[n]/=a,t+=o[n]*M[n];let g=t/(a+a);for(let n=0;n<e;n++)o[n]-=g*M[n];for(let n=0;n<e;n++){t=M[n],i=o[n];for(let v=n;v<=e-1;v++)c[f(v,n)]-=t*o[v]+i*M[v];M[n]=c[f(e-1,n)],c[f(e,n)]=0}}M[e]=a}for(let e=0;e<l-1;e++){c[f(l-1,e)]=c[f(e,e)],c[f(e,e)]=1;let p=M[e+1];if(p!==0){for(let a=0;a<=e;a++)M[a]=c[f(a,e+1)]/p;for(let a=0;a<=e;a++){let t=0;for(let i=0;i<=e;i++)t+=c[f(i,e+1)]*c[f(i,a)];for(let i=0;i<=e;i++)c[f(i,a)]-=t*M[i]}}for(let a=0;a<=e;a++)c[f(a,e+1)]=0}for(let e=0;e<l;e++)M[e]=c[f(l-1,e)],c[f(l-1,e)]=0;c[f(l-1,l-1)]=1,o[0]=0}function Q(y,M,o){let l=y.nrow,c=y.data,f=(t,i)=>t+i*l;for(let t=1;t<l;t++)o[t-1]=o[t];o[l-1]=0;let e=0,p=0,a=Number.EPSILON;for(let t=0;t<l;t++){p=Math.max(p,Math.abs(M[t])+Math.abs(o[t]));let i=t;for(;i<l-1&&Math.abs(o[i])>a*p;)i++;if(i>t){let g=0;do{if(++g>100)throw new Error("the eigendecomposition did not converge");let n=M[t],v=(M[t+1]-n)/(2*o[t]),m=Math.hypot(v,1);v<0&&(m=-m),M[t]=o[t]/(v+m),M[t+1]=o[t]*(v+m);let b=M[t+1],w=n-M[t];for(let q=t+2;q<l;q++)M[q]-=w;e+=w,v=M[i];let s=1,h=s,N=s,k=o[t+1],j=0,E=0;for(let q=i-1;q>=t;q--){N=h,h=s,E=j,n=s*o[q],w=s*v,m=Math.hypot(v,o[q]),o[q+1]=j*m,j=o[q]/m,s=v/m,v=s*M[q]-j*n,M[q+1]=w+j*(s*n+j*M[q]);for(let I=0;I<l;I++)w=c[f(I,q+1)],c[f(I,q+1)]=j*c[f(I,q)]+s*w,c[f(I,q)]=s*c[f(I,q)]-j*w}v=-j*E*N*k*o[t]/b,o[t]=j*v,M[t]=s*v}while(Math.abs(o[t])>a*p)}M[t]=M[t]+e,o[t]=0}for(let t=0;t<l-1;t++){let i=t,g=M[t];for(let n=t+1;n<l;n++)M[n]<g&&(i=n,g=M[n]);if(i!==t){M[i]=M[t],M[t]=g;for(let n=0;n<l;n++){let v=c[f(n,t)];c[f(n,t)]=c[f(n,i)],c[f(n,i)]=v}}}}function U(y,M){let o=y.nrow,l={nrow:o,ncol:o,data:y.data.slice()},c=A(o,o),f=new Float64Array(o),e=new Float64Array(o),p=G("B",l);X(l,c),Z(l,c,f,e);let a=Array.from(f,(w,s)=>Math.hypot(w,e[s])),t=Array.from({length:o},(w,s)=>s).sort((w,s)=>a[s]-a[w]||w-s),i=e.some(w=>w!==0),g={values:t.map(w=>f[w])};if(i&&(g.valuesIm=t.map(w=>e[w])),!M)return g;K(p,c);let n=A(o,o),v=A(o,o);for(let w=0;w<o;w++){let s=c.data.subarray(w*o,(w+1)*o);if(e[w]===0)n.data.set(s,w*o);else if(e[w]>0){let h=c.data.subarray((w+1)*o,(w+2)*o);n.data.set(s,w*o),v.data.set(h,w*o),n.data.set(s,(w+1)*o);for(let N=0;N<o;N++)v.data[N+(w+1)*o]=-h[N]}}W(n,v);let m=A(o,o),b=A(o,o);return t.forEach((w,s)=>{m.data.set(n.data.subarray(w*o,(w+1)*o),s*o),b.data.set(v.data.subarray(w*o,(w+1)*o),s*o)}),g.vectors=O(m),i&&(g.vectorsIm=O(b)),g}function W(y,M){let o=y.nrow;for(let l=0;l<o;l++){let c=l*o,f=0,e=0,p=-1;for(let g=0;g<o;g++){let n=Math.hypot(y.data[c+g],M.data[c+g]);f+=n*n,n>p&&(p=n,e=g)}let a=Math.sqrt(f);if(p>0&&!(f>=2**-1022&&f<1/0)){let g=0;for(let n=0;n<o;n++)g+=(Math.hypot(y.data[c+n],M.data[c+n])/p)**2;a=p*Math.sqrt(g)}if(a===0)continue;let t=y.data[c+e]/p/a,i=-M.data[c+e]/p/a;for(let g=0;g<o;g++){let n=y.data[c+g],v=M.data[c+g];y.data[c+g]=n*t-v*i,M.data[c+g]=n*i+v*t}M.data[c+e]=0}}function X(y,M){let o=y.nrow,l=y.data,c=M.data,f=(t,i)=>t+i*o,e=new Float64Array(o),p=0,a=o-1;for(let t=p+1;t<=a-1;t++){let i=0;for(let v=t;v<=a;v++)i+=Math.abs(l[f(v,t-1)]);if(i===0)continue;let g=0;for(let v=a;v>=t;v--)e[v]=l[f(v,t-1)]/i,g+=e[v]*e[v];let n=Math.sqrt(g);e[t]>0&&(n=-n),g-=e[t]*n,e[t]=e[t]-n;for(let v=t;v<o;v++){let m=0;for(let b=a;b>=t;b--)m+=e[b]*l[f(b,v)];m/=g;for(let b=t;b<=a;b++)l[f(b,v)]-=m*e[b]}for(let v=0;v<=a;v++){let m=0;for(let b=a;b>=t;b--)m+=e[b]*l[f(v,b)];m/=g;for(let b=t;b<=a;b++)l[f(v,b)]-=m*e[b]}e[t]=i*e[t],l[f(t,t-1)]=i*n}for(let t=0;t<o;t++)for(let i=0;i<o;i++)c[f(t,i)]=t===i?1:0;for(let t=a-1;t>=p+1;t--)if(l[f(t,t-1)]!==0){for(let i=t+1;i<=a;i++)e[i]=l[f(i,t-1)];for(let i=t;i<=a;i++){let g=0;for(let n=t;n<=a;n++)g+=e[n]*c[f(n,i)];g=g/e[t]/l[f(t,t-1)];for(let n=t;n<=a;n++)c[f(n,i)]+=g*e[n]}}}function L(y,M,o,l){if(Math.abs(o)>Math.abs(l)){let e=l/o,p=o+e*l;return[(y+e*M)/p,(M-e*y)/p]}let c=o/l,f=l+c*o;return[(c*y+M)/f,(c*M-y)/f]}function Z(y,M,o,l,c=!1){let f=y.nrow,e=y.data,p=M.data,a=(d,r)=>d+r*f,t=f-1,i=0,g=f-1,n=Number.EPSILON,v=0,m=0,b=0,w=0,s=0,h=0,N,k,j,E,q=0;for(let d=0;d<f;d++)for(let r=Math.max(d-1,0);r<f;r++)q+=Math.abs(e[a(d,r)]);let I=0,F=0;for(;t>=i;){let d=t;for(;d>i&&(s=Math.abs(e[a(d-1,d-1)])+Math.abs(e[a(d,d)]),s===0&&(s=q),!(Math.abs(e[a(d,d-1)])<n*s));)d--;if(d===t)e[a(t,t)]=e[a(t,t)]+v,o[t]=e[a(t,t)],l[t]=0,t--,I=0;else if(d===t-1){if(k=e[a(t,t-1)]*e[a(t-1,t)],m=(e[a(t-1,t-1)]-e[a(t,t)])/2,b=m*m+k,h=Math.sqrt(Math.abs(b)),e[a(t,t)]=e[a(t,t)]+v,e[a(t-1,t-1)]=e[a(t-1,t-1)]+v,j=e[a(t,t)],b>=0){h=m>=0?m+h:m-h,o[t-1]=j+h,o[t]=o[t-1],h!==0&&(o[t]=j-k/h),l[t-1]=0,l[t]=0,j=e[a(t,t-1)],s=Math.abs(j)+Math.abs(h),m=j/s,b=h/s,w=Math.sqrt(m*m+b*b),m/=w,b/=w;for(let r=t-1;r<f;r++)h=e[a(t-1,r)],e[a(t-1,r)]=b*h+m*e[a(t,r)],e[a(t,r)]=b*e[a(t,r)]-m*h;for(let r=0;r<=t;r++)h=e[a(r,t-1)],e[a(r,t-1)]=b*h+m*e[a(r,t)],e[a(r,t)]=b*e[a(r,t)]-m*h;for(let r=i;r<=g;r++)h=p[a(r,t-1)],p[a(r,t-1)]=b*h+m*p[a(r,t)],p[a(r,t)]=b*p[a(r,t)]-m*h}else o[t-1]=j+m,o[t]=j+m,l[t-1]=h,l[t]=-h;t-=2,I=0}else{if(j=e[a(t,t)],E=0,k=0,d<t&&(E=e[a(t-1,t-1)],k=e[a(t,t-1)]*e[a(t-1,t)]),I===10){v+=j;for(let u=i;u<=t;u++)e[a(u,u)]-=j;s=Math.abs(e[a(t,t-1)])+Math.abs(e[a(t-1,t-2)]),j=E=.75*s,k=-.4375*s*s}if(I===30&&(s=(E-j)/2,s=s*s+k,s>0)){s=Math.sqrt(s),E<j&&(s=-s),s=j-k/((E-j)/2+s);for(let u=i;u<=t;u++)e[a(u,u)]-=s;v+=s,j=E=k=.964}if(I++,++F>100*f)throw new Error("the eigendecomposition did not converge");let r=t-2;for(;r>=d&&(h=e[a(r,r)],w=j-h,s=E-h,m=(w*s-k)/e[a(r+1,r)]+e[a(r,r+1)],b=e[a(r+1,r+1)]-h-w-s,w=e[a(r+2,r+1)],s=Math.abs(m)+Math.abs(b)+Math.abs(w),m/=s,b/=s,w/=s,!(r===d||Math.abs(e[a(r,r-1)])*(Math.abs(b)+Math.abs(w))<n*(Math.abs(m)*(Math.abs(e[a(r-1,r-1)])+Math.abs(h)+Math.abs(e[a(r+1,r+1)])))));)r--;for(let u=r+2;u<=t;u++)e[a(u,u-2)]=0,u>r+2&&(e[a(u,u-3)]=0);for(let u=r;u<=t-1;u++){let S=u!==t-1;if(u!==r){if(m=e[a(u,u-1)],b=e[a(u+1,u-1)],w=S?e[a(u+2,u-1)]:0,j=Math.abs(m)+Math.abs(b)+Math.abs(w),j===0)continue;m/=j,b/=j,w/=j}if(s=Math.sqrt(m*m+b*b+w*w),m<0&&(s=-s),s!==0){u!==r?e[a(u,u-1)]=-s*j:d!==r&&(e[a(u,u-1)]=-e[a(u,u-1)]),m+=s,j=m/s,E=b/s,h=w/s,b/=m,w/=m;for(let x=u;x<f;x++)m=e[a(u,x)]+b*e[a(u+1,x)],S&&(m+=w*e[a(u+2,x)],e[a(u+2,x)]=e[a(u+2,x)]-m*h),e[a(u,x)]=e[a(u,x)]-m*j,e[a(u+1,x)]=e[a(u+1,x)]-m*E;for(let x=0;x<=Math.min(t,u+3);x++)m=j*e[a(x,u)]+E*e[a(x,u+1)],S&&(m+=h*e[a(x,u+2)],e[a(x,u+2)]=e[a(x,u+2)]-m*w),e[a(x,u)]=e[a(x,u)]-m,e[a(x,u+1)]=e[a(x,u+1)]-m*b;for(let x=i;x<=g;x++)m=j*p[a(x,u)]+E*p[a(x,u+1)],S&&(m+=h*p[a(x,u+2)],p[a(x,u+2)]=p[a(x,u+2)]-m*w),p[a(x,u)]=p[a(x,u)]-m,p[a(x,u+1)]=p[a(x,u+1)]-m*b}}}}if(!(q===0||c)){for(t=f-1;t>=0;t--)if(m=o[t],b=l[t],b===0){let d=t;e[a(t,t)]=1;for(let r=t-1;r>=0;r--){k=e[a(r,r)]-m,w=0;for(let u=d;u<=t;u++)w+=e[a(r,u)]*e[a(u,t)];if(l[r]<0)h=k,s=w;else if(d=r,l[r]===0?e[a(r,t)]=k!==0?-w/k:-w/(n*q):(j=e[a(r,r+1)],E=e[a(r+1,r)],b=(o[r]-m)*(o[r]-m)+l[r]*l[r],N=(j*s-h*w)/b,e[a(r,t)]=N,e[a(r+1,t)]=Math.abs(j)>Math.abs(h)?(-w-k*N)/j:(-s-E*N)/h),N=Math.abs(e[a(r,t)]),n*N*N>1)for(let u=r;u<=t;u++)e[a(u,t)]=e[a(u,t)]/N}}else if(b<0){let d=t-1;Math.abs(e[a(t,t-1)])>Math.abs(e[a(t-1,t)])?(e[a(t-1,t-1)]=b/e[a(t,t-1)],e[a(t-1,t)]=-(e[a(t,t)]-m)/e[a(t,t-1)]):[e[a(t-1,t-1)],e[a(t-1,t)]]=L(0,-e[a(t-1,t)],e[a(t-1,t-1)]-m,b),e[a(t,t-1)]=0,e[a(t,t)]=1;for(let r=t-2;r>=0;r--){let u=0,S=0;for(let x=d;x<=t;x++)u+=e[a(r,x)]*e[a(x,t-1)],S+=e[a(r,x)]*e[a(x,t)];if(k=e[a(r,r)]-m,l[r]<0)h=k,w=u,s=S;else{if(d=r,l[r]===0)[e[a(r,t-1)],e[a(r,t)]]=L(-u,-S,k,b);else{j=e[a(r,r+1)],E=e[a(r+1,r)];let x=(o[r]-m)*(o[r]-m)+l[r]*l[r]-b*b,P=(o[r]-m)*2*b;x===0&&P===0&&(x=n*q*(Math.abs(k)+Math.abs(b)+Math.abs(j)+Math.abs(E)+Math.abs(h))),[e[a(r,t-1)],e[a(r,t)]]=L(j*w-h*u+b*S,j*s-h*S-b*u,x,P),Math.abs(j)>Math.abs(h)+Math.abs(b)?(e[a(r+1,t-1)]=(-u-k*e[a(r,t-1)]+b*e[a(r,t)])/j,e[a(r+1,t)]=(-S-k*e[a(r,t)]-b*e[a(r,t-1)])/j):[e[a(r+1,t-1)],e[a(r+1,t)]]=L(-w-E*e[a(r,t-1)],-s-E*e[a(r,t)],h,b)}if(N=Math.max(Math.abs(e[a(r,t-1)]),Math.abs(e[a(r,t)])),n*N*N>1)for(let x=r;x<=t;x++)e[a(x,t-1)]=e[a(x,t-1)]/N,e[a(x,t)]=e[a(x,t)]/N}}}for(let d=f-1;d>=i;d--)for(let r=i;r<=g;r++){h=0;for(let u=i;u<=Math.min(d,g);u++)h+=p[a(r,u)]*e[a(u,d)];p[a(r,d)]=h}}}export{G as a,rt as b,D as c,X as d,Z as e};
1
+ /*! rStats.js 1.14.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
+ import{a as A,c as C,e as O,g as V,i as _}from"./chunk-I2OTBVRK.js";import{h as z}from"./chunk-B6NPCYFO.js";import{l as R}from"./chunk-TGXUU5NB.js";function B(y,M,o,l){let c=0,f=1;for(let e=0;e<o;e++){let p=y[M+e*l];if(p===0)continue;let a=Math.abs(p);c<a?(f=1+f*(c/a)**2,c=a):f+=(a/c)**2}return c*Math.sqrt(f)}function G(y,M){let o=M.nrow,l=M.data,c=(s,h)=>s+h*o,f=new Float64Array(o),e=(s,h,N)=>{for(let k=0;k<N;k++)[l[c(k,s)],l[c(k,h)]]=[l[c(k,h)],l[c(k,s)]]},p=(s,h,N)=>{for(let k=N;k<o;k++)[l[c(s,k)],l[c(h,k)]]=[l[c(h,k)],l[c(s,k)]]},a=0,t=o-1;if(y!=="S"){let s=!0;for(;s;){s=!1;for(let h=t;h>=0;h--){let N=!0;for(let k=0;k<=t;k++)if(h!==k&&l[c(h,k)]!==0){N=!1;break}if(N){if(f[t]=h,h!==t&&(e(h,t,t+1),p(h,t,a)),s=!0,t===0)return{ilo:0,ihi:0,scale:f};t--}}}for(s=!0;s;){s=!1;for(let h=a,N=t;h<=N;h++){let k=!0;for(let j=a;j<=t;j++)if(j!==h&&l[c(j,h)]!==0){k=!1;break}k&&(f[a]=h,h!==a&&(e(h,a,t+1),p(h,a,a)),s=!0,a++)}}}for(let s=a;s<=t;s++)f[s]=1;if(y==="P")return{ilo:a,ihi:t,scale:f};let i=2,g=.95,n=2**-1022/Number.EPSILON,v=1/n,m=n*i,b=1/m,w=!0;for(;w;){w=!1;for(let s=a;s<=t;s++){let h=B(l,c(a,s),t-a+1,1),N=B(l,c(s,a),t-a+1,o),k=0;for(let F=0;F<=t;F++)k=Math.max(k,Math.abs(l[c(F,s)]));let j=0;for(let F=a;F<o;F++)j=Math.max(j,Math.abs(l[c(s,F)]));if(h===0||N===0)continue;if(Number.isNaN(h+k+N+j))throw new RangeError("the matrix contains NaN or infinite values");let E=N/i,q=1,I=h+N;for(;h<E&&Math.max(q,h,k)<b&&Math.min(N,E,j)>m;)q*=i,h*=i,k*=i,N/=i,E/=i,j/=i;for(E=h/i;E>=N&&Math.max(N,j)<b&&Math.min(q,h,E,k)>m;)q/=i,h/=i,E/=i,k/=i,N*=i,j*=i;if(!(h+N>=g*I)&&!(q<1&&f[s]<1&&q*f[s]<=n)&&!(q>1&&f[s]>1&&f[s]>=v/q)){E=1/q,f[s]=f[s]*q,w=!0;for(let F=a;F<o;F++)l[c(s,F)]=l[c(s,F)]*E;for(let F=0;F<=t;F++)l[c(F,s)]=l[c(F,s)]*q}}}return{ilo:a,ihi:t,scale:f}}function K(y,M){let{ilo:o,ihi:l,scale:c}=y,f=M.nrow,e=M.ncol,p=M.data;if(f===0||e===0)return;if(o!==l)for(let t=o;t<=l;t++){let i=c[t];for(let g=0;g<e;g++)p[t+g*f]=p[t+g*f]*i}let a=t=>{let i=c[t];if(i!==t)for(let g=0;g<e;g++)[p[t+g*f],p[i+g*f]]=[p[i+g*f],p[t+g*f]]};for(let t=o-1;t>=0;t--)a(t);for(let t=l+1;t<f;t++)a(t)}var T=["symmetric","onlyValues"];function rt(y,M={}){R(M,T,"eigen");let o=C(y);if(V(o),o.nrow===0)throw new RangeError("the matrix has zero dimension");for(let a of o.data)if(!Number.isFinite(a))throw new RangeError("the matrix contains NaN or infinite values");let l=_(o.data,459),c=l===0?o:{...o,data:o.data.map(a=>z(a,-l))},f=M.symmetric??D(Y(o)),e=!(M.onlyValues??!1),p=f?H(c,e):U(c,e);return l!==0&&(p.values=p.values.map(a=>z(a,l)),p.valuesIm&&(p.valuesIm=p.valuesIm.map(a=>z(a,l)))),p}function Y(y){let M=0;for(let l of y.data)M=Math.max(M,Math.abs(l));if(M===0)return y;let o=2**Math.min(1023,-Math.floor(Math.log2(M)));return o===1?y:{...y,data:y.data.map(l=>l*o)}}function D(y){let M=y.nrow,o=i=>{let g=0,n=0,v=0,m=0;for(let b=0;b<M;b++)for(let w=0;w<M;w++){let s=y.data[w+b*M],h=y.data[b+w*M];s!==h&&(g+=Math.abs(s*i-h*i),n+=Math.abs(s*i),v++,m=Math.max(m,Math.abs(s)))}return{diff:g,size:n,count:v,mx:m}},{diff:l,size:c,count:f,mx:e}=o(1);if(f===0)return!0;(!Number.isFinite(l)||!Number.isFinite(c))&&({diff:l,size:c}=o(2**-Math.floor(Math.log2(e))));let p=100*Number.EPSILON,a=c/f,t=l/f;return(Number.isFinite(a)&&a>p?t/a:t)<=p}function H(y,M){let o=y.nrow,l=A(o,o);for(let a=0;a<o;a++)for(let t=a;t<o;t++)l.data[t+a*o]=y.data[t+a*o],l.data[a+t*o]=y.data[t+a*o];let c=new Float64Array(o),f=new Float64Array(o);J(l,c,f),Q(l,c,f);let e=Array.from(c).reverse();if(!M)return{values:e};let p=A(o,o);for(let a=0;a<o;a++)p.data.set(l.data.subarray((o-1-a)*o,(o-a)*o),a*o);return{values:e,vectors:O(p)}}function J(y,M,o){let l=y.nrow,c=y.data,f=(e,p)=>e+p*l;for(let e=0;e<l;e++)M[e]=c[f(l-1,e)];for(let e=l-1;e>0;e--){let p=0,a=0;for(let t=0;t<e;t++)p+=Math.abs(M[t]);if(p===0){o[e]=M[e-1];for(let t=0;t<e;t++)M[t]=c[f(e-1,t)],c[f(e,t)]=0,c[f(t,e)]=0}else{for(let n=0;n<e;n++)M[n]/=p,a+=M[n]*M[n];let t=M[e-1],i=Math.sqrt(a);t>0&&(i=-i),o[e]=p*i,a-=t*i,M[e-1]=t-i;for(let n=0;n<e;n++)o[n]=0;for(let n=0;n<e;n++){t=M[n],c[f(n,e)]=t,i=o[n]+c[f(n,n)]*t;for(let v=n+1;v<=e-1;v++)i+=c[f(v,n)]*M[v],o[v]+=c[f(v,n)]*t;o[n]=i}t=0;for(let n=0;n<e;n++)o[n]/=a,t+=o[n]*M[n];let g=t/(a+a);for(let n=0;n<e;n++)o[n]-=g*M[n];for(let n=0;n<e;n++){t=M[n],i=o[n];for(let v=n;v<=e-1;v++)c[f(v,n)]-=t*o[v]+i*M[v];M[n]=c[f(e-1,n)],c[f(e,n)]=0}}M[e]=a}for(let e=0;e<l-1;e++){c[f(l-1,e)]=c[f(e,e)],c[f(e,e)]=1;let p=M[e+1];if(p!==0){for(let a=0;a<=e;a++)M[a]=c[f(a,e+1)]/p;for(let a=0;a<=e;a++){let t=0;for(let i=0;i<=e;i++)t+=c[f(i,e+1)]*c[f(i,a)];for(let i=0;i<=e;i++)c[f(i,a)]-=t*M[i]}}for(let a=0;a<=e;a++)c[f(a,e+1)]=0}for(let e=0;e<l;e++)M[e]=c[f(l-1,e)],c[f(l-1,e)]=0;c[f(l-1,l-1)]=1,o[0]=0}function Q(y,M,o){let l=y.nrow,c=y.data,f=(t,i)=>t+i*l;for(let t=1;t<l;t++)o[t-1]=o[t];o[l-1]=0;let e=0,p=0,a=Number.EPSILON;for(let t=0;t<l;t++){p=Math.max(p,Math.abs(M[t])+Math.abs(o[t]));let i=t;for(;i<l-1&&Math.abs(o[i])>a*p;)i++;if(i>t){let g=0;do{if(++g>100)throw new Error("the eigendecomposition did not converge");let n=M[t],v=(M[t+1]-n)/(2*o[t]),m=Math.hypot(v,1);v<0&&(m=-m),M[t]=o[t]/(v+m),M[t+1]=o[t]*(v+m);let b=M[t+1],w=n-M[t];for(let q=t+2;q<l;q++)M[q]-=w;e+=w,v=M[i];let s=1,h=s,N=s,k=o[t+1],j=0,E=0;for(let q=i-1;q>=t;q--){N=h,h=s,E=j,n=s*o[q],w=s*v,m=Math.hypot(v,o[q]),o[q+1]=j*m,j=o[q]/m,s=v/m,v=s*M[q]-j*n,M[q+1]=w+j*(s*n+j*M[q]);for(let I=0;I<l;I++)w=c[f(I,q+1)],c[f(I,q+1)]=j*c[f(I,q)]+s*w,c[f(I,q)]=s*c[f(I,q)]-j*w}v=-j*E*N*k*o[t]/b,o[t]=j*v,M[t]=s*v}while(Math.abs(o[t])>a*p)}M[t]=M[t]+e,o[t]=0}for(let t=0;t<l-1;t++){let i=t,g=M[t];for(let n=t+1;n<l;n++)M[n]<g&&(i=n,g=M[n]);if(i!==t){M[i]=M[t],M[t]=g;for(let n=0;n<l;n++){let v=c[f(n,t)];c[f(n,t)]=c[f(n,i)],c[f(n,i)]=v}}}}function U(y,M){let o=y.nrow,l={nrow:o,ncol:o,data:y.data.slice()},c=A(o,o),f=new Float64Array(o),e=new Float64Array(o),p=G("B",l);X(l,c),Z(l,c,f,e);let a=Array.from(f,(w,s)=>Math.hypot(w,e[s])),t=Array.from({length:o},(w,s)=>s).sort((w,s)=>a[s]-a[w]||w-s),i=e.some(w=>w!==0),g={values:t.map(w=>f[w])};if(i&&(g.valuesIm=t.map(w=>e[w])),!M)return g;K(p,c);let n=A(o,o),v=A(o,o);for(let w=0;w<o;w++){let s=c.data.subarray(w*o,(w+1)*o);if(e[w]===0)n.data.set(s,w*o);else if(e[w]>0){let h=c.data.subarray((w+1)*o,(w+2)*o);n.data.set(s,w*o),v.data.set(h,w*o),n.data.set(s,(w+1)*o);for(let N=0;N<o;N++)v.data[N+(w+1)*o]=-h[N]}}W(n,v);let m=A(o,o),b=A(o,o);return t.forEach((w,s)=>{m.data.set(n.data.subarray(w*o,(w+1)*o),s*o),b.data.set(v.data.subarray(w*o,(w+1)*o),s*o)}),g.vectors=O(m),i&&(g.vectorsIm=O(b)),g}function W(y,M){let o=y.nrow;for(let l=0;l<o;l++){let c=l*o,f=0,e=0,p=-1;for(let g=0;g<o;g++){let n=Math.hypot(y.data[c+g],M.data[c+g]);f+=n*n,n>p&&(p=n,e=g)}let a=Math.sqrt(f);if(p>0&&!(f>=2**-1022&&f<1/0)){let g=0;for(let n=0;n<o;n++)g+=(Math.hypot(y.data[c+n],M.data[c+n])/p)**2;a=p*Math.sqrt(g)}if(a===0)continue;let t=y.data[c+e]/p/a,i=-M.data[c+e]/p/a;for(let g=0;g<o;g++){let n=y.data[c+g],v=M.data[c+g];y.data[c+g]=n*t-v*i,M.data[c+g]=n*i+v*t}M.data[c+e]=0}}function X(y,M){let o=y.nrow,l=y.data,c=M.data,f=(t,i)=>t+i*o,e=new Float64Array(o),p=0,a=o-1;for(let t=p+1;t<=a-1;t++){let i=0;for(let v=t;v<=a;v++)i+=Math.abs(l[f(v,t-1)]);if(i===0)continue;let g=0;for(let v=a;v>=t;v--)e[v]=l[f(v,t-1)]/i,g+=e[v]*e[v];let n=Math.sqrt(g);e[t]>0&&(n=-n),g-=e[t]*n,e[t]=e[t]-n;for(let v=t;v<o;v++){let m=0;for(let b=a;b>=t;b--)m+=e[b]*l[f(b,v)];m/=g;for(let b=t;b<=a;b++)l[f(b,v)]-=m*e[b]}for(let v=0;v<=a;v++){let m=0;for(let b=a;b>=t;b--)m+=e[b]*l[f(v,b)];m/=g;for(let b=t;b<=a;b++)l[f(v,b)]-=m*e[b]}e[t]=i*e[t],l[f(t,t-1)]=i*n}for(let t=0;t<o;t++)for(let i=0;i<o;i++)c[f(t,i)]=t===i?1:0;for(let t=a-1;t>=p+1;t--)if(l[f(t,t-1)]!==0){for(let i=t+1;i<=a;i++)e[i]=l[f(i,t-1)];for(let i=t;i<=a;i++){let g=0;for(let n=t;n<=a;n++)g+=e[n]*c[f(n,i)];g=g/e[t]/l[f(t,t-1)];for(let n=t;n<=a;n++)c[f(n,i)]+=g*e[n]}}}function L(y,M,o,l){if(Math.abs(o)>Math.abs(l)){let e=l/o,p=o+e*l;return[(y+e*M)/p,(M-e*y)/p]}let c=o/l,f=l+c*o;return[(c*y+M)/f,(c*M-y)/f]}function Z(y,M,o,l,c=!1){let f=y.nrow,e=y.data,p=M.data,a=(d,r)=>d+r*f,t=f-1,i=0,g=f-1,n=Number.EPSILON,v=0,m=0,b=0,w=0,s=0,h=0,N,k,j,E,q=0;for(let d=0;d<f;d++)for(let r=Math.max(d-1,0);r<f;r++)q+=Math.abs(e[a(d,r)]);let I=0,F=0;for(;t>=i;){let d=t;for(;d>i&&(s=Math.abs(e[a(d-1,d-1)])+Math.abs(e[a(d,d)]),s===0&&(s=q),!(Math.abs(e[a(d,d-1)])<n*s));)d--;if(d===t)e[a(t,t)]=e[a(t,t)]+v,o[t]=e[a(t,t)],l[t]=0,t--,I=0;else if(d===t-1){if(k=e[a(t,t-1)]*e[a(t-1,t)],m=(e[a(t-1,t-1)]-e[a(t,t)])/2,b=m*m+k,h=Math.sqrt(Math.abs(b)),e[a(t,t)]=e[a(t,t)]+v,e[a(t-1,t-1)]=e[a(t-1,t-1)]+v,j=e[a(t,t)],b>=0){h=m>=0?m+h:m-h,o[t-1]=j+h,o[t]=o[t-1],h!==0&&(o[t]=j-k/h),l[t-1]=0,l[t]=0,j=e[a(t,t-1)],s=Math.abs(j)+Math.abs(h),m=j/s,b=h/s,w=Math.sqrt(m*m+b*b),m/=w,b/=w;for(let r=t-1;r<f;r++)h=e[a(t-1,r)],e[a(t-1,r)]=b*h+m*e[a(t,r)],e[a(t,r)]=b*e[a(t,r)]-m*h;for(let r=0;r<=t;r++)h=e[a(r,t-1)],e[a(r,t-1)]=b*h+m*e[a(r,t)],e[a(r,t)]=b*e[a(r,t)]-m*h;for(let r=i;r<=g;r++)h=p[a(r,t-1)],p[a(r,t-1)]=b*h+m*p[a(r,t)],p[a(r,t)]=b*p[a(r,t)]-m*h}else o[t-1]=j+m,o[t]=j+m,l[t-1]=h,l[t]=-h;t-=2,I=0}else{if(j=e[a(t,t)],E=0,k=0,d<t&&(E=e[a(t-1,t-1)],k=e[a(t,t-1)]*e[a(t-1,t)]),I===10){v+=j;for(let u=i;u<=t;u++)e[a(u,u)]-=j;s=Math.abs(e[a(t,t-1)])+Math.abs(e[a(t-1,t-2)]),j=E=.75*s,k=-.4375*s*s}if(I===30&&(s=(E-j)/2,s=s*s+k,s>0)){s=Math.sqrt(s),E<j&&(s=-s),s=j-k/((E-j)/2+s);for(let u=i;u<=t;u++)e[a(u,u)]-=s;v+=s,j=E=k=.964}if(I++,++F>100*f)throw new Error("the eigendecomposition did not converge");let r=t-2;for(;r>=d&&(h=e[a(r,r)],w=j-h,s=E-h,m=(w*s-k)/e[a(r+1,r)]+e[a(r,r+1)],b=e[a(r+1,r+1)]-h-w-s,w=e[a(r+2,r+1)],s=Math.abs(m)+Math.abs(b)+Math.abs(w),m/=s,b/=s,w/=s,!(r===d||Math.abs(e[a(r,r-1)])*(Math.abs(b)+Math.abs(w))<n*(Math.abs(m)*(Math.abs(e[a(r-1,r-1)])+Math.abs(h)+Math.abs(e[a(r+1,r+1)])))));)r--;for(let u=r+2;u<=t;u++)e[a(u,u-2)]=0,u>r+2&&(e[a(u,u-3)]=0);for(let u=r;u<=t-1;u++){let S=u!==t-1;if(u!==r){if(m=e[a(u,u-1)],b=e[a(u+1,u-1)],w=S?e[a(u+2,u-1)]:0,j=Math.abs(m)+Math.abs(b)+Math.abs(w),j===0)continue;m/=j,b/=j,w/=j}if(s=Math.sqrt(m*m+b*b+w*w),m<0&&(s=-s),s!==0){u!==r?e[a(u,u-1)]=-s*j:d!==r&&(e[a(u,u-1)]=-e[a(u,u-1)]),m+=s,j=m/s,E=b/s,h=w/s,b/=m,w/=m;for(let x=u;x<f;x++)m=e[a(u,x)]+b*e[a(u+1,x)],S&&(m+=w*e[a(u+2,x)],e[a(u+2,x)]=e[a(u+2,x)]-m*h),e[a(u,x)]=e[a(u,x)]-m*j,e[a(u+1,x)]=e[a(u+1,x)]-m*E;for(let x=0;x<=Math.min(t,u+3);x++)m=j*e[a(x,u)]+E*e[a(x,u+1)],S&&(m+=h*e[a(x,u+2)],e[a(x,u+2)]=e[a(x,u+2)]-m*w),e[a(x,u)]=e[a(x,u)]-m,e[a(x,u+1)]=e[a(x,u+1)]-m*b;for(let x=i;x<=g;x++)m=j*p[a(x,u)]+E*p[a(x,u+1)],S&&(m+=h*p[a(x,u+2)],p[a(x,u+2)]=p[a(x,u+2)]-m*w),p[a(x,u)]=p[a(x,u)]-m,p[a(x,u+1)]=p[a(x,u+1)]-m*b}}}}if(!(q===0||c)){for(t=f-1;t>=0;t--)if(m=o[t],b=l[t],b===0){let d=t;e[a(t,t)]=1;for(let r=t-1;r>=0;r--){k=e[a(r,r)]-m,w=0;for(let u=d;u<=t;u++)w+=e[a(r,u)]*e[a(u,t)];if(l[r]<0)h=k,s=w;else if(d=r,l[r]===0?e[a(r,t)]=k!==0?-w/k:-w/(n*q):(j=e[a(r,r+1)],E=e[a(r+1,r)],b=(o[r]-m)*(o[r]-m)+l[r]*l[r],N=(j*s-h*w)/b,e[a(r,t)]=N,e[a(r+1,t)]=Math.abs(j)>Math.abs(h)?(-w-k*N)/j:(-s-E*N)/h),N=Math.abs(e[a(r,t)]),n*N*N>1)for(let u=r;u<=t;u++)e[a(u,t)]=e[a(u,t)]/N}}else if(b<0){let d=t-1;Math.abs(e[a(t,t-1)])>Math.abs(e[a(t-1,t)])?(e[a(t-1,t-1)]=b/e[a(t,t-1)],e[a(t-1,t)]=-(e[a(t,t)]-m)/e[a(t,t-1)]):[e[a(t-1,t-1)],e[a(t-1,t)]]=L(0,-e[a(t-1,t)],e[a(t-1,t-1)]-m,b),e[a(t,t-1)]=0,e[a(t,t)]=1;for(let r=t-2;r>=0;r--){let u=0,S=0;for(let x=d;x<=t;x++)u+=e[a(r,x)]*e[a(x,t-1)],S+=e[a(r,x)]*e[a(x,t)];if(k=e[a(r,r)]-m,l[r]<0)h=k,w=u,s=S;else{if(d=r,l[r]===0)[e[a(r,t-1)],e[a(r,t)]]=L(-u,-S,k,b);else{j=e[a(r,r+1)],E=e[a(r+1,r)];let x=(o[r]-m)*(o[r]-m)+l[r]*l[r]-b*b,P=(o[r]-m)*2*b;x===0&&P===0&&(x=n*q*(Math.abs(k)+Math.abs(b)+Math.abs(j)+Math.abs(E)+Math.abs(h))),[e[a(r,t-1)],e[a(r,t)]]=L(j*w-h*u+b*S,j*s-h*S-b*u,x,P),Math.abs(j)>Math.abs(h)+Math.abs(b)?(e[a(r+1,t-1)]=(-u-k*e[a(r,t-1)]+b*e[a(r,t)])/j,e[a(r+1,t)]=(-S-k*e[a(r,t)]-b*e[a(r,t-1)])/j):[e[a(r+1,t-1)],e[a(r+1,t)]]=L(-w-E*e[a(r,t-1)],-s-E*e[a(r,t)],h,b)}if(N=Math.max(Math.abs(e[a(r,t-1)]),Math.abs(e[a(r,t)])),n*N*N>1)for(let x=r;x<=t;x++)e[a(x,t-1)]=e[a(x,t-1)]/N,e[a(x,t)]=e[a(x,t)]/N}}}for(let d=f-1;d>=i;d--)for(let r=i;r<=g;r++){h=0;for(let u=i;u<=Math.min(d,g);u++)h+=p[a(r,u)]*e[a(u,d)];p[a(r,d)]=h}}}export{G as a,rt as b,D as c,X as d,Z as e};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.13.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{a as k,c as C,e as V,f as L,i as R,k as O,l as z}from"./chunk-CEY7FHMZ.js";import{h as j}from"./chunk-3T4TVNXS.js";import{l as _}from"./chunk-AH6IVJRF.js";var K=["nu","nv"];function H(s,l={}){_(l,K,"svd");let{s:f,...n}=P(s,l);return{...n,d:n.d.map(a=>j(a,f))}}function P(s,l={}){let f=C(s);for(let u of f.data)if(!Number.isFinite(u))throw new RangeError("the matrix contains NaN or infinite values");let n=Math.min(f.nrow,f.ncol),a=(u,v,p)=>{if(Number.isNaN(v)||v<0)throw new RangeError(`${u} must be a non-negative number`);return Math.min(Math.trunc(v),p)},y=a("nu",l.nu??n,f.nrow),i=a("nv",l.nv??n,f.ncol),F=f.nrow<f.ncol,N=R(f.data),e=N===0?f:{...f,data:f.data.map(u=>j(u,-N))},m=I(F?L(e):e,F?i:y,F?y:i),c={d:Array.from(m.d),s:N},[g,d]=F?[m.v,m.u]:[m.u,m.v];return y>0&&(c.u=V(D(g,y))),i>0&&(c.v=V(D(d,i))),c}function J(s){let l=R(s.data),f=l===0?s:{...s,data:s.data.map(n=>j(n,-l))};return I(f.nrow<f.ncol?L(f):f,0,0).d.map(n=>j(n,l))}function D(s,l){return{nrow:s.nrow,ncol:l,data:s.data.slice(0,s.nrow*l)}}function I(s,l,f){let n=s.nrow,a=s.ncol,y=new Float64Array(a);if(a===0)return{d:y,u:k(n,n),v:k(0,0)};let i={nrow:n,ncol:a,data:s.data.slice()},F=new Float64Array(a),N=new Float64Array(a),e=new Float64Array(a);for(let t=0;t<a;t++){let o=t*n;if(N[t]=O(i.data,o+t,n-t),y[t]=i.data[o+t],t<a-1&&(i.data[o+t]=1,z(i.data,o+t,n-t,N[t],i,t,t+1,a-t-1),i.data[o+t]=y[t]),t<a-1){let r=new Float64Array(a-t-1);for(let h=0;h<r.length;h++)r[h]=i.data[t+(t+1+h)*n];e[t]=O(r,0,r.length),F[t+1]=r[0],r[0]=1;let w=e[t];if(w!==0)for(let h=t+1;h<n;h++){let M=0;for(let b=0;b<r.length;b++)M+=i.data[h+(t+1+b)*n]*r[b];M*=w;for(let b=0;b<r.length;b++)i.data[h+(t+1+b)*n]-=M*r[b]}r[0]=F[t+1];for(let h=0;h<r.length;h++)i.data[t+(t+1+h)*n]=r[h]}}let m=l===0?0:Math.max(l,a),c;if(m>0){c=k(n,m);for(let t=0;t<m;t++)c.data[t+t*n]=1;for(let t=a-1;t>=0;t--){let o=t*n,r=i.data[o+t];i.data[o+t]=1,z(i.data,o+t,n-t,N[t],c,t,0,m),i.data[o+t]=r}}let g;if(f>0){g=k(a,a);for(let o=0;o<a;o++)g.data[o+o*a]=1;let t=new Float64Array(a);for(let o=a-2;o>=0;o--){let r=a-o-1;t[0]=1;for(let w=1;w<r;w++)t[w]=i.data[o+(o+1+w)*n];z(t,0,r,e[o],g,o+1,0,a)}}Y(y,F,c,g);let d=Array.from({length:a},(t,o)=>o).sort((t,o)=>y[o]-y[t]||t-o),u=Float64Array.from(d,t=>y[t]),v=(t,o)=>{if(t===void 0)return;let r={nrow:t.nrow,ncol:t.ncol,data:t.data.slice()};for(let w=0;w<o;w++)r.data.set(t.data.subarray(d[w]*t.nrow,(d[w]+1)*t.nrow),w*t.nrow);return r},p={d:u};return c&&(p.u=v(c,a)),g&&(p.v=v(g,a)),p}function Y(s,l,f,n){let a=s.length,y=Number.EPSILON,i=0;for(let e=0;e<a;e++)i=Math.max(i,Math.abs(s[e])+Math.abs(l[e]));let F=(e,m,c,g)=>{if(!f)return;let d=f.nrow;for(let u=0;u<d;u++){let v=f.data[u+e*d],p=f.data[u+m*d];f.data[u+e*d]=v*c+p*g,f.data[u+m*d]=p*c-v*g}},N=(e,m,c,g)=>{if(n)for(let d=0;d<a;d++){let u=n.data[d+e*a],v=n.data[d+m*a];n.data[d+e*a]=u*c+v*g,n.data[d+m*a]=v*c-u*g}};for(let e=a-1;e>=0;e--)for(let m=0;;m++){let c=e,g=!0;for(;c>=0;c--){if(c===0||Math.abs(l[c])<=y*i){g=!1;break}if(Math.abs(s[c-1])<=y*i)break}if(g){let M=c-1,b=0,x=1;for(let A=c;A<=e;A++){let E=x*l[A];if(l[A]=b*l[A],Math.abs(E)<=y*i)break;let U=s[A],S=Math.hypot(E,U);s[A]=S,b=U/S,x=-E/S,F(M,A,b,x)}}let d=s[e];if(c===e){if(d<0&&(s[e]=-d,n))for(let M=0;M<a;M++)n.data[M+e*a]=-n.data[M+e*a];break}if(m>=75)throw new Error("the singular value decomposition did not converge");let u=s[c],v=e-1,p=s[v],t=l[v],o=l[e],r=((p-d)*(p+d)+(t-o)*(t+o))/(2*o*p);t=Math.hypot(r,1),r=((u-d)*(u+d)+o*(p/(r+(r>=0?Math.abs(t):-Math.abs(t)))-o))/u;let w=1,h=1;for(let M=c;M<=v;M++){let b=M+1;t=l[b],p=s[b],o=h*t,t=w*t;let x=Math.hypot(r,o);l[M]=x,w=r/x,h=o/x,r=u*w+t*h,t=t*w-u*h,o=p*h,p*=w,N(M,b,w,h),x=Math.hypot(r,o),s[M]=x,x!==0&&(w=r/x,h=o/x),r=w*t+h*p,u=w*p-h*t,F(M,b,w,h)}l[c]=0,l[e]=r,s[e]=u}}export{H as a,P as b,J as c};
1
+ /*! rStats.js 1.14.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
+ import{a as k,c as C,e as V,f as L,i as R,k as O,l as z}from"./chunk-I2OTBVRK.js";import{h as j}from"./chunk-B6NPCYFO.js";import{l as _}from"./chunk-TGXUU5NB.js";var K=["nu","nv"];function H(s,l={}){_(l,K,"svd");let{s:f,...n}=P(s,l);return{...n,d:n.d.map(a=>j(a,f))}}function P(s,l={}){let f=C(s);for(let u of f.data)if(!Number.isFinite(u))throw new RangeError("the matrix contains NaN or infinite values");let n=Math.min(f.nrow,f.ncol),a=(u,v,p)=>{if(Number.isNaN(v)||v<0)throw new RangeError(`${u} must be a non-negative number`);return Math.min(Math.trunc(v),p)},y=a("nu",l.nu??n,f.nrow),i=a("nv",l.nv??n,f.ncol),F=f.nrow<f.ncol,N=R(f.data),e=N===0?f:{...f,data:f.data.map(u=>j(u,-N))},m=I(F?L(e):e,F?i:y,F?y:i),c={d:Array.from(m.d),s:N},[g,d]=F?[m.v,m.u]:[m.u,m.v];return y>0&&(c.u=V(D(g,y))),i>0&&(c.v=V(D(d,i))),c}function J(s){let l=R(s.data),f=l===0?s:{...s,data:s.data.map(n=>j(n,-l))};return I(f.nrow<f.ncol?L(f):f,0,0).d.map(n=>j(n,l))}function D(s,l){return{nrow:s.nrow,ncol:l,data:s.data.slice(0,s.nrow*l)}}function I(s,l,f){let n=s.nrow,a=s.ncol,y=new Float64Array(a);if(a===0)return{d:y,u:k(n,n),v:k(0,0)};let i={nrow:n,ncol:a,data:s.data.slice()},F=new Float64Array(a),N=new Float64Array(a),e=new Float64Array(a);for(let t=0;t<a;t++){let o=t*n;if(N[t]=O(i.data,o+t,n-t),y[t]=i.data[o+t],t<a-1&&(i.data[o+t]=1,z(i.data,o+t,n-t,N[t],i,t,t+1,a-t-1),i.data[o+t]=y[t]),t<a-1){let r=new Float64Array(a-t-1);for(let h=0;h<r.length;h++)r[h]=i.data[t+(t+1+h)*n];e[t]=O(r,0,r.length),F[t+1]=r[0],r[0]=1;let w=e[t];if(w!==0)for(let h=t+1;h<n;h++){let M=0;for(let b=0;b<r.length;b++)M+=i.data[h+(t+1+b)*n]*r[b];M*=w;for(let b=0;b<r.length;b++)i.data[h+(t+1+b)*n]-=M*r[b]}r[0]=F[t+1];for(let h=0;h<r.length;h++)i.data[t+(t+1+h)*n]=r[h]}}let m=l===0?0:Math.max(l,a),c;if(m>0){c=k(n,m);for(let t=0;t<m;t++)c.data[t+t*n]=1;for(let t=a-1;t>=0;t--){let o=t*n,r=i.data[o+t];i.data[o+t]=1,z(i.data,o+t,n-t,N[t],c,t,0,m),i.data[o+t]=r}}let g;if(f>0){g=k(a,a);for(let o=0;o<a;o++)g.data[o+o*a]=1;let t=new Float64Array(a);for(let o=a-2;o>=0;o--){let r=a-o-1;t[0]=1;for(let w=1;w<r;w++)t[w]=i.data[o+(o+1+w)*n];z(t,0,r,e[o],g,o+1,0,a)}}Y(y,F,c,g);let d=Array.from({length:a},(t,o)=>o).sort((t,o)=>y[o]-y[t]||t-o),u=Float64Array.from(d,t=>y[t]),v=(t,o)=>{if(t===void 0)return;let r={nrow:t.nrow,ncol:t.ncol,data:t.data.slice()};for(let w=0;w<o;w++)r.data.set(t.data.subarray(d[w]*t.nrow,(d[w]+1)*t.nrow),w*t.nrow);return r},p={d:u};return c&&(p.u=v(c,a)),g&&(p.v=v(g,a)),p}function Y(s,l,f,n){let a=s.length,y=Number.EPSILON,i=0;for(let e=0;e<a;e++)i=Math.max(i,Math.abs(s[e])+Math.abs(l[e]));let F=(e,m,c,g)=>{if(!f)return;let d=f.nrow;for(let u=0;u<d;u++){let v=f.data[u+e*d],p=f.data[u+m*d];f.data[u+e*d]=v*c+p*g,f.data[u+m*d]=p*c-v*g}},N=(e,m,c,g)=>{if(n)for(let d=0;d<a;d++){let u=n.data[d+e*a],v=n.data[d+m*a];n.data[d+e*a]=u*c+v*g,n.data[d+m*a]=v*c-u*g}};for(let e=a-1;e>=0;e--)for(let m=0;;m++){let c=e,g=!0;for(;c>=0;c--){if(c===0||Math.abs(l[c])<=y*i){g=!1;break}if(Math.abs(s[c-1])<=y*i)break}if(g){let M=c-1,b=0,x=1;for(let A=c;A<=e;A++){let E=x*l[A];if(l[A]=b*l[A],Math.abs(E)<=y*i)break;let U=s[A],S=Math.hypot(E,U);s[A]=S,b=U/S,x=-E/S,F(M,A,b,x)}}let d=s[e];if(c===e){if(d<0&&(s[e]=-d,n))for(let M=0;M<a;M++)n.data[M+e*a]=-n.data[M+e*a];break}if(m>=75)throw new Error("the singular value decomposition did not converge");let u=s[c],v=e-1,p=s[v],t=l[v],o=l[e],r=((p-d)*(p+d)+(t-o)*(t+o))/(2*o*p);t=Math.hypot(r,1),r=((u-d)*(u+d)+o*(p/(r+(r>=0?Math.abs(t):-Math.abs(t)))-o))/u;let w=1,h=1;for(let M=c;M<=v;M++){let b=M+1;t=l[b],p=s[b],o=h*t,t=w*t;let x=Math.hypot(r,o);l[M]=x,w=r/x,h=o/x,r=u*w+t*h,t=t*w-u*h,o=p*h,p*=w,N(M,b,w,h),x=Math.hypot(r,o),s[M]=x,x!==0&&(w=r/x,h=o/x),r=w*t+h*p,u=w*p-h*t,F(M,b,w,h)}l[c]=0,l[e]=r,s[e]=u}}export{H as a,P as b,J as c};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.13.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.14.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
  function e(n){let t=-1/0;for(let i=0;i<n.length;i++)t=Math.max(t,n[i]);return t}function r(n,t){let i=.5*(n+t);return Number.isFinite(i)||!Number.isFinite(n)||!Number.isFinite(t)?i:.5*n+.5*t}function m(n){let t=1/0;for(let i=0;i<n.length;i++)t=Math.min(t,n[i]);return t}export{e as a,r as b,m as c};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.13.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{a as d}from"./chunk-7ZKPFHAO.js";import{a as h,c as l}from"./chunk-M3LK23YR.js";import{c as F,d as O,f as y,g as v,w as x,x as E}from"./chunk-KOF2HBUV.js";import{h as b}from"./chunk-3T4TVNXS.js";import{b as s,d as N,g as M,i as p,k as g,l as I}from"./chunk-AH6IVJRF.js";var H=["rCompatible"],K=["rCompatible"],C=30;function c(t){return t===Math.floor(t)}function L(t,r){if(c(t))return t;if(t>=0)return h(t)?t:l(t);let e=r-1-t;return h(e)?t:r-1-l(e)||-0}function j(t,r){let e=[1,0];for(let i=0;i<r;i++)e=p(M(e,s(t,-i)),[i+1,0]);return e}function _(t,r){let e=Math.floor(Math.log2(Math.abs(t))),i=[1,0];for(let o=0;o<r;o++){let n=s(t,-o);i=p(M(i,[b(n[0],-e),b(n[1],-e)]),[o+1,0])}return b(i[0]+i[1],e*r)}function S(t,r){return Math.min(t,r)>=1&&Math.max(t,r)<2**52?E(t,r):[x(t,r),0]}function D(t,r){if(t<0){let m=N(g(s(r,-t)),S(-t,r+1));return{log:[-m[0],-m[1]],sign:r%2===0?1:-1}}if(c(t)&&t<r)return;if(t>=r-1){let m=N(g(s(t,1)),S(t-r+1,r+1));return{log:[-m[0],-m[1]],sign:1}}let e=F(t),[i,o]=s(t,1),[n,f]=s(r,-t),a=o===0&&f===0?0:d(i+n),u=(o===0?0:o*(d(i)-a))+(f===0?0:f*(d(n)-a));return{log:N(S(i,n),[Math.log(Math.abs(e)/Math.PI)+u,0]),sign:(r%2===0?-1:1)*Math.sign(e)}}function G(t,r,e){if(I(e,H,"choose"),Number.isNaN(t)||Number.isNaN(r))return NaN;let i=e?.rCompatible??!0;if(r=l(r),r<0)return 0;if(r===0)return 1;if(!Number.isFinite(r))return i&&t>=0&&t<1/0?0:NaN;if(!Number.isFinite(t))return i&&r>=C?NaN:t>0||r%2===0?1/0:-1/0;if(r<C){let f=i&&!c(t)&&!h(t);if(f&&t>=0&&l(t)<r)return 0;let a=j(t,r),u=a[0]+a[1];return Number.isFinite(u)?c(t)||f?Math.round(u):u:_(t,r)}if(i&&(t=L(t,r),Object.is(t,-0)))return r%2===0?0:-0;let o=D(t,r);if(o===void 0)return 0;let n=o.sign*Math.exp(o.log[0])*(1+o.log[1]);return c(t)&&Number.isFinite(n)?Math.round(n):n}function J(t,r,e){if(I(e,K,"lchoose"),Number.isNaN(t)||Number.isNaN(r))return NaN;let i=e?.rCompatible??!0;if(r=l(r),r<0)return-1/0;if(r===0)return 0;if(!Number.isFinite(r))return i&&t>=0&&t<1/0?-1/0:NaN;if(!Number.isFinite(t))return i&&r>=2?NaN:1/0;if(i&&r>=2&&(t=L(t,r)),r<C){let n=j(t,r),f=Math.abs(n[0]+n[1]);if(f>1e-300&&f<1e300){let u=g(n[0]<0?[-n[0],-n[1]]:n);return u[0]+u[1]}let a=-y(r+1);for(let u=0;u<r;u++)a+=Math.log(Math.abs(t-u));return a}let o=D(t,r);return o===void 0?-1/0:c(t)&&o.log[0]<36?Math.log(Math.round(Math.exp(o.log[0])*(1+o.log[1]))):o.log[0]+o.log[1]}function Q(t){return O(t+1)}function T(t){return Math.abs(t)<=.2?v(t):y(t+1)}export{G as a,J as b,Q as c,T as d};
1
+ /*! rStats.js 1.14.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
+ import{a as d}from"./chunk-VWCCPBBG.js";import{a as h,c as l}from"./chunk-JCGCJT7T.js";import{c as F,d as O,f as y,g as v,w as x,x as E}from"./chunk-6HUTVWPO.js";import{h as b}from"./chunk-B6NPCYFO.js";import{b as s,d as N,g as M,i as p,k as g,l as I}from"./chunk-TGXUU5NB.js";var H=["rCompatible"],K=["rCompatible"],C=30;function c(t){return t===Math.floor(t)}function L(t,r){if(c(t))return t;if(t>=0)return h(t)?t:l(t);let e=r-1-t;return h(e)?t:r-1-l(e)||-0}function j(t,r){let e=[1,0];for(let i=0;i<r;i++)e=p(M(e,s(t,-i)),[i+1,0]);return e}function _(t,r){let e=Math.floor(Math.log2(Math.abs(t))),i=[1,0];for(let o=0;o<r;o++){let n=s(t,-o);i=p(M(i,[b(n[0],-e),b(n[1],-e)]),[o+1,0])}return b(i[0]+i[1],e*r)}function S(t,r){return Math.min(t,r)>=1&&Math.max(t,r)<2**52?E(t,r):[x(t,r),0]}function D(t,r){if(t<0){let m=N(g(s(r,-t)),S(-t,r+1));return{log:[-m[0],-m[1]],sign:r%2===0?1:-1}}if(c(t)&&t<r)return;if(t>=r-1){let m=N(g(s(t,1)),S(t-r+1,r+1));return{log:[-m[0],-m[1]],sign:1}}let e=F(t),[i,o]=s(t,1),[n,f]=s(r,-t),a=o===0&&f===0?0:d(i+n),u=(o===0?0:o*(d(i)-a))+(f===0?0:f*(d(n)-a));return{log:N(S(i,n),[Math.log(Math.abs(e)/Math.PI)+u,0]),sign:(r%2===0?-1:1)*Math.sign(e)}}function G(t,r,e){if(I(e,H,"choose"),Number.isNaN(t)||Number.isNaN(r))return NaN;let i=e?.rCompatible??!0;if(r=l(r),r<0)return 0;if(r===0)return 1;if(!Number.isFinite(r))return i&&t>=0&&t<1/0?0:NaN;if(!Number.isFinite(t))return i&&r>=C?NaN:t>0||r%2===0?1/0:-1/0;if(r<C){let f=i&&!c(t)&&!h(t);if(f&&t>=0&&l(t)<r)return 0;let a=j(t,r),u=a[0]+a[1];return Number.isFinite(u)?c(t)||f?Math.round(u):u:_(t,r)}if(i&&(t=L(t,r),Object.is(t,-0)))return r%2===0?0:-0;let o=D(t,r);if(o===void 0)return 0;let n=o.sign*Math.exp(o.log[0])*(1+o.log[1]);return c(t)&&Number.isFinite(n)?Math.round(n):n}function J(t,r,e){if(I(e,K,"lchoose"),Number.isNaN(t)||Number.isNaN(r))return NaN;let i=e?.rCompatible??!0;if(r=l(r),r<0)return-1/0;if(r===0)return 0;if(!Number.isFinite(r))return i&&t>=0&&t<1/0?-1/0:NaN;if(!Number.isFinite(t))return i&&r>=2?NaN:1/0;if(i&&r>=2&&(t=L(t,r)),r<C){let n=j(t,r),f=Math.abs(n[0]+n[1]);if(f>1e-300&&f<1e300){let u=g(n[0]<0?[-n[0],-n[1]]:n);return u[0]+u[1]}let a=-y(r+1);for(let u=0;u<r;u++)a+=Math.log(Math.abs(t-u));return a}let o=D(t,r);return o===void 0?-1/0:c(t)&&o.log[0]<36?Math.log(Math.round(Math.exp(o.log[0])*(1+o.log[1]))):o.log[0]+o.log[1]}function Q(t){return O(t+1)}function T(t){return Math.abs(t)<=.2?v(t):y(t+1)}export{G as a,J as b,Q as c,T as d};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.13.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 t,n as i}from"./chunk-KOF2HBUV.js";import{m as n}from"./chunk-P2UT6OCU.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.14.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 t,n as i}from"./chunk-6HUTVWPO.js";import{m as n}from"./chunk-ZJJJDLRL.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,2 +1,2 @@
1
- /*! rStats.js 1.13.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{a as L1,b as F3,e as P3}from"./chunk-P2UT6OCU.js";import{a as D3,b as R,c as k0,d as m,e as U1,f as w,g as k,h as D,i as m1,j as T0,k as b}from"./chunk-AH6IVJRF.js";var O=11102230246251565e-32;var Z=171.6243769563027,w1=.9189385332046728,L3=1.1447298858494002;var C0=.5772156649015329;var F6=[.00016011952247675185,.0011913514700658638,.010421379756176158,.04763678004571372,.20744822764843598,.4942148268014971,1],D6=[-23158187332412014e-21,.0005396055804933034,-.004456419138517973,.011813978522206043,.035823639860549865,-.23459179571824335,.0714304917030273,1];function q3(e){let t=1;e<0&&(e=-e,t=-1);let n=e%2;return n<.5?t*Math.sin(Math.PI*n):n>1.5?t*Math.sin(Math.PI*(n-2)):-t*Math.sin(Math.PI*(n-1))}function O0(e){if(e>Z)return 1/0;let t=e-1,n=m(D(b([t,0]),t),[-t+k6(t),0]);return Math.sqrt(2*Math.PI*t)*Math.exp(n[0])*(1+n[1])}function e1(e){if(!Number.isFinite(e))return e>0?e:NaN;if(e===0)return NaN;let t=Math.abs(e);if(t>33){if(e<0){let o=Math.floor(t);if(o===t)return NaN;let s=o%2===0?-1:1,r=t-o;if(r>.5&&(o+=1,r=t-o),r=t*q3(r),r===0)return s*(1/0);let i=Math.abs(r)*O0(t);if(Number.isFinite(i))return s*Math.PI/i;let c=1;for(let u=1;u<=10;u++)c*=t-u;return s*Math.PI/(Math.abs(r)*O0(t-10))/c}return O0(e)}let n=1;for(;e>=3;)e-=1,n*=e;for(;e<0;){if(e>-1e-9)return w3(e,n);n/=e,e+=1}for(;e<2;){if(e<1e-9)return w3(e,n);n/=e,e+=1}return e===2?n:(e-=2,n*L1(e,F6)/L1(e,D6))}function w3(e,t){return e===0?NaN:t/((1+C0*e)*e)}var P6=[.0008116141674705085,-.0005950619042843014,.0007936503404577169,-.002777777777300997,.08333333333333319],L6=[-1378.2515256912086,-38801.631513463784,-331612.9927388712,-1162370974927623e-9,-1.7217370082083966e6,-853555.6642457654],w6=[-351.81570143652345,-17064.210665188115,-220528.59055385445,-1.1393344436798252e6,-2.5325230717758294e6,-2.0188914143353277e6],E6=2556348e299;function q6(e){let t=(e-.5)*Math.log(e)-e+w1;if(e>1e8)return t;let n=1/(e*e);return t+((.0007936507936507937*n-.002777777777777778)*n+.08333333333333333)/e}function V(e){if(!Number.isFinite(e))return{value:e===-1/0?1/0:e,sign:1};if(e<-34){let o=-e,s=V(o).value,r=Math.floor(o);if(r===o)return{value:1/0,sign:1};let i=r%2===0?-1:1,c=o-r;return c>.5&&(r+=1,c=r-o),c=o*q3(c),c===0?{value:1/0,sign:1}:{value:L3-Math.log(c)-s,sign:i}}if(e!==0&&Math.abs(e)<1e-300)return{value:-Math.log(Math.abs(e)),sign:e>0?1:-1};if(e<13){let o=1,s=0,r=e;for(;r>=3;)s-=1,r=e+s,o*=r;for(;r<2;){if(r===0)return{value:1/0,sign:1};o/=r,s+=1,r=e+s}let i=1;if(o<0&&(i=-1,o=-o),r===2)return{value:Math.log(o),sign:i};s-=2;let c=e+s;return{value:Math.log(o)+c*L1(c,L6)/F3(c,w6),sign:i}}if(e>E6)return{value:1/0,sign:1};if(e>=1e3)return{value:q6(e),sign:1};let t=(e-.5)*Math.log(e)-e+w1,n=1/(e*e);return{value:t+L1(n,P6)/e,sign:1}}function J(e){return Math.abs(e-1)<=.2?x(e-1):Math.abs(e-2)<=.2?x(e-2)+Math.log1p(e-2):V(e).value}var G6=[1.6449340668482264,1.2020569031595942,1.0823232337111381,1.03692775514337,1.0173430619844492,1.008349277381923,1.0040773561979444,1.0020083928260821,1.000994575127818,1.0004941886041194,1.000246086553308,1.0001227133475785,1.0000612481350588,1.000030588236307,1.0000152822594086,1.0000076371976379,1.000003817293265,1.0000019082127165,1.0000009539620338,1.0000004769329869,1.0000002384505027,1.000000119219926,1.000000059608189,1.0000000298035034,1.0000000149015549,1.0000000074507118,1.000000003725334,1.0000000018626598,1.0000000009313275,1.0000000004656628,1.000000000232831,1.0000000001164155,1.0000000000582077,1.0000000000291038,1.000000000014552,1.000000000007276,1.000000000003638,1.000000000001819,1.0000000000009095,1.0000000000004547];function E3(e){if(e===0)return 0;let t=-C0*e,n=-e;for(let o=2;o<42;o++){n*=-e;let s=G6[o-2]*n/o;if(t+=s,Math.abs(s)<O*Math.abs(t))break}return t}function x(e){return Math.abs(e)<=.2?E3(e):Math.abs(e-1)<=.2?Math.log(e)+E3(e-1):J(e+1)}var R6=[1/12,-1/360,1/1260,-1/1680,1/1188,-691/360360,1/156];function k6(e){let t=1/(e*e),n=0,o=1/e;for(let s of R6)n+=s*o,o*=t;return n}var G3=[1/12,-1/360,1/1260,-1/1680,1/1188,-691/360360,1/156];function R3(e,t){let n=B0(e,t);return n[0]+n[1]}function B0(e,t){if(e===0)return[0,0];let n=0,o=t;for(;o<=15;)n-=Math.log1p(e/o),o+=1;let s=Math.log1p(e/o),r=e*Math.log(o+e),i=Math.abs(r)>2&&Number.isFinite(r)&&e<1e300?D(b(R(o,e)),e):[r,0],c=(o-.5)*s-e,u=1/o,f=1/(o*o);for(let l=0;l<G3.length;l++){let a=2*l+1;c+=G3[l]*u*Math.expm1(-a*s),u*=f}return m(i,[n+c,0])}var k3=22250738585072014e-324,Q0=1.8378770664093456,T6=[.15342640972002736,.08106146679532726,.05481412105191765,.0413406959554093,.03316287351993629,.02767792568499834,.023746163656297496,.020790672103765093,.018488450532673187,.016644691189821193,.015134973221917378,.013876128823070748,.012810465242920227,.01189670994589177,.011104559758206917,.010411265261972096,.009799416126158804,.009255462182712733,.008768700134139386,.00833056343336287,.00793411456431402,.007573675487951841,.007244554301320383,.00694284010720953,.006665247032707682,.006408994188004207,.006171712263039458,.0059513701127588475,.0057462165130101155,.005554733551962801],Y1=1/12,Q1=1/360,X0=1/1260,T3=1/1680,C6=1/1188,O6=691/360360,B6=1/156;function C3(e){let t=1/(e*e);return e>500?(Y1-Q1*t)/e:e>80?(Y1-(Q1-X0*t)*t)/e:e>35?(Y1-(Q1-(X0-T3*t)*t)*t)/e:(Y1-(Q1-(X0-(T3-(C6-(O6-B6*t)*t)*t)*t)*t)*t)/e}function q(e){if(e>15)return C3(e);let t=2*e;if(t===Math.floor(t)&&t>=1)return T6[t-1];if(e<1)return x(e)-(e+.5)*Math.log(e)+e-w1;let n=0,o=e;for(;o<=15;)n+=(o+.5)*Math.log1p(1/o)-1,o+=1;return n+C3(o)}var X6=.12;function p1(e,t){if(e===0)return t;if(Math.max(e,t[0])>1e299&&Math.min(e,t[0])>1e-250)return J1(p1(e*2**-64,[t[0]*2**-64,t[1]*2**-64]));if(!D3())return j6(e,t);let n=-t[0],o=-t[1],s=e+n,r=s-e,i=e-(s-r)+(n-r),c=0+o,u=c-0,f=0-(c-u)+(o-u),l=i+c,a=s+l,I=l-(a-s)+f,S=a+I,P=I-(S-a),M=S,g=P;if(Math.abs(M)<.1*(e+t[0])){let C=e+t[0],j=C-e,N=e-(C-j)+(t[0]-j),_=0+t[1],A=_-0,L=0-(_-A)+(t[1]-A),F=N+_,y=C+F,n1=F-(y-C)+L,v=y+n1,z=n1-(v-y),G=M/v,o1=v*G,g1=134217729*v,W=g1-(g1-v),N1=v-W,E1=134217729*G,x1=E1-(E1-G),$0=G-x1,x0=W*x1-o1+W*$0+N1*x1+N1*$0+z*G,e2=o1+x0,o6=x0-(e2-o1),t2=-e2,n2=-o6,q1=M+t2,o2=q1-M,s6=M-(q1-o2)+(t2-o2),e0=g+n2,s2=e0-g,r6=g-(e0-s2)+(n2-s2),r2=s6+e0,t0=q1+r2,c2=r2-(t0-q1)+r6,d1=t0+c2,n0=c2-(d1-t0),s1=d1/v,o0=v*s1,i2=134217729*v,s0=i2-(i2-v),u2=v-s0,f2=134217729*s1,r0=f2-(f2-s1),a2=s1-r0,l2=s0*r0-o0+s0*a2+u2*r0+u2*a2+z*s1,h2=o0+l2,c6=l2-(h2-o0),M2=-h2,m2=-c6,G1=d1+M2,p2=G1-d1,i6=d1-(G1-p2)+(M2-p2),c0=n0+m2,b2=c0-n0,u6=n0-(c0-b2)+(m2-b2),g2=i6+c0,i0=G1+g2,N2=g2-(i0-G1)+u6,d2=i0+N2,m5=N2-(d2-i0),I2=d2/v,R1=G+s1,u0=s1-(R1-G),k1=R1+I2,A2=k1-R1,f6=R1-(k1-A2)+(I2-A2),f0=u0+0,y2=f0-u0,a6=u0-(f0-y2)+(0-y2),v2=f6+f0,a0=k1+v2,S2=v2-(a0-k1)+a6,_2=a0+S2,l6=S2-(_2-a0),p=_2,T1=l6,l0=M*p,F2=134217729*M,h0=F2-(F2-M),D2=M-h0,P2=134217729*p,M0=P2-(P2-p),L2=p-M0,w2=h0*M0-l0+h0*L2+D2*M0+D2*L2+(M*T1+g*p),E2=l0+w2,h6=w2-(E2-l0),U=E2,K=h6;if(Math.abs(e*p*p*p)<=X6){let f1=p*p,r1=2*e*p*f1,a1=r1/3;for(let h1=2;h1<1e3;h1++){r1*=f1;let M1=r1/(2*h1+1);if(a1+=M1,Math.abs(M1)<=2**-60*U)break}let $=U+a1,v1=$-U,C1=U-($-v1)+(a1-v1),c1=K+0,S1=c1-K,U2=K-(c1-S1)+(0-S1),_1=C1+c1,l1=$+_1,E=_1-(l1-$)+U2,Q=l1+E,F1=E-(Q-l1);return[Q,F1]}let I1=2*e,m0=p*I1,q2=134217729*p,p0=q2-(q2-p),G2=p-p0,R2=134217729*I1,b0=R2-(R2-I1),k2=I1-b0,T2=p0*b0-m0+p0*k2+G2*b0+G2*k2+T1*I1,C2=m0+T2,M6=T2-(C2-m0),Y=C2,A1=M6,g0=p*p,O2=134217729*p,N0=O2-(O2-p),B2=p-N0,X2=134217729*p,d0=X2-(X2-p),j2=p-d0,H2=N0*d0-g0+N0*j2+B2*d0+B2*j2+(p*T1+T1*p),z2=g0+H2,m6=H2-(z2-g0),y1=z2,p6=m6;for(let f1=1;f1<1e3;f1++){let r1=Y*y1,a1=134217729*Y,$=a1-(a1-Y),v1=Y-$,C1=134217729*y1,c1=C1-(C1-y1),S1=y1-c1,_1=$*c1-r1+$*S1+v1*c1+v1*S1+(Y*p6+A1*y1),l1=r1+_1,Y2=_1-(l1-r1);Y=l1,A1=Y2;let E=2*f1+1,Q=Y/E,F1=E*Q,h1=134217729*E,M1=h1-(h1-E),Q2=E-M1,V2=134217729*Q,I0=V2-(V2-Q),K2=Q-I0,Z2=M1*I0-F1+M1*K2+Q2*I0+Q2*K2+0*Q,J2=F1+Z2,b6=Z2-(J2-F1),W2=-J2,$2=-b6,O1=Y+W2,x2=O1-Y,g6=Y-(O1-x2)+(W2-x2),A0=A1+$2,e3=A0-A1,N6=A1-(A0-e3)+($2-e3),t3=g6+A0,y0=O1+t3,n3=t3-(y0-O1)+N6,D1=y0+n3,v0=n3-(D1-y0),i1=D1/E,S0=E*i1,o3=134217729*E,_0=o3-(o3-E),s3=E-_0,r3=134217729*i1,F0=r3-(r3-i1),c3=i1-F0,i3=_0*F0-S0+_0*c3+s3*F0+s3*c3+0*i1,u3=S0+i3,d6=i3-(u3-S0),f3=-u3,a3=-d6,B1=D1+f3,l3=B1-D1,I6=D1-(B1-l3)+(f3-l3),D0=v0+a3,h3=D0-v0,A6=v0-(D0-h3)+(a3-h3),M3=I6+D0,P0=B1+M3,m3=M3-(P0-B1)+A6,p3=P0+m3,v5=m3-(p3-P0),b3=p3/E,X1=Q+i1,L0=i1-(X1-Q),j1=X1+b3,g3=j1-X1,y6=X1-(j1-g3)+(b3-g3),w0=L0+0,N3=w0-L0,v6=L0-(w0-N3)+(0-N3),d3=y6+w0,E0=j1+d3,I3=d3-(E0-j1)+v6,H1=E0+I3,A3=I3-(H1-E0),z1=U+H1,y3=z1-U,S6=U-(z1-y3)+(H1-y3),q0=K+A3,v3=q0-K,_6=K-(q0-v3)+(A3-v3),S3=S6+q0,G0=z1+S3,_3=S3-(G0-z1)+_6,P1=G0+_3,R0=_3-(P1-G0);if(Math.abs(H1)<=1e-33*Math.abs(P1)||P1===U&&R0===K)return[P1,R0];U=P1,K=R0}return[U,K]}let B=e/t[0],X=B>1e-290&&B<1e290&&Math.max(e,t[0])<1e300?b(m1([e,0],t)):w(b([e,0]),b(t));return O3(X,e,[M,g])}function j6(e,t){let n=w([e,0],t);if(Math.abs(n[0])<.1*(e+t[0])){let r=m1(n,m([e,0],t)),i=k(n,r),c=D(r,2*e),u=k(r,r);for(let f=1;f<1e3;f++){c=k(c,u);let l=T0(c,2*f+1),a=m(i,l);if(Math.abs(l[0])<=1e-33*Math.abs(a[0])||a[0]===i[0]&&a[1]===i[1])return a;i=a}return i}let o=e/t[0],s=o>1e-290&&o<1e290&&Math.max(e,t[0])<1e300?b(m1([e,0],t)):w(b([e,0]),b(t));return O3(s,e,n)}function O3(e,t,n){return t<1e299?m(D(e,t),U1(n)):J1(m(D(e,t*2**-64),[-n[0]*2**-64,-n[1]*2**-64]))}function J1(e){let t=e[0]*18446744073709552e3;return Number.isFinite(t)?[t,e[1]*2**64]:[t,0]}function Z1(e,t,n,o=0){let s=t[0]>1e299?5421010862427522e-35:1,r;if(o===0){let c=k([t[0]*s,t[1]*s],n);r=[c[0]/s,c[1]/s]}else r=U0(t,n,o);if(r[0]>=1e-290)return p1(e,r);let i=w(b([e,0]),m(b(t),j0(n,o)));return m(D(i,e),R(o===0?t[0]*n[0]:r[0],-e))}var V1=(e,t)=>e*2**Math.trunc(t/2)*2**(t-Math.trunc(t/2)),H6=[.6931471805599453,23190468138462996e-33],j0=(e,t)=>t===0?b(e):w(b(e),D(H6,t));function C5(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||t===0)return NaN;if(e===0)return t;let n=p1(e,[t,0]);return n[0]+n[1]}function H0(e,t,n,o){if(t)return-e[0]-e[1]-.5*n();if(e[0]<700)return Math.exp(-e[0])*(1-e[1])/Math.sqrt(o());if(e[0]>2e3)return 0;let s=o();return!Number.isFinite(s)||s===0?Math.exp(-e[0]-e[1]-.5*n()):Math.exp(700-e[0])*(1-e[1])/Math.sqrt(s)*Math.exp(-700)}function z0(e,t){return e[0]>1e299?J1(k([e[0]*2**-64,e[1]*2**-64],t)):k(e,t)}var z6=[0,0];function U0(e,t,n){if(n===0)return z0(e,t);let o=Math.floor(Math.log2(e[0])),s=k([V1(e[0],-o),V1(e[1],-o)],t);return[V1(s[0],o-n),V1(s[1],o-n)]}var K1=e=>e[0]<-2e3?0:Math.exp(e[0])*(1+e[1]);function O5(e,t,n,o,s,r,i=z6){let[c,u]=i,f=s?-1/0:0,l=s?0:1,a=R(e,t),h=a[0];if(n[0]===0)return e===0?l:f;if(o[0]===0)return t===0?l:f;if(e===0){if(h===0)return l;if(c>0||n[0]<.1){let g=m(Z1(h,a,o,u),U0(a,n,c));return s?-g[0]-g[1]:K1([-g[0],-g[1]])}let M=z0(a,j0(o,u));return s?M[0]+M[1]:K1(M)}if(t===0){if(u>0||o[0]<.1){let g=m(Z1(h,a,n,c),U0(a,o,u));return s?-g[0]-g[1]:K1([-g[0],-g[1]])}let M=z0(a,j0(n,c));return s?M[0]+M[1]:K1(M)}if(e<0||t<0)return f;let I=r!==void 0&&(a[0]!==r||a[1]!==0)?U6(e,r,n,o):V0(e,t,a,n,o,c,u),S=e*(t/h)>2e307,P=H0(I,s,()=>Q0+Math.log(e)+Math.log(t)-Math.log(h),S?()=>Math.PI/8*(e*(t/h)):()=>2*Math.PI*e*(t/h));return S&&!s?P/4:P}function B5(e,t,n,o){let s=R(e,t),r=s[0];return{e:V0(e,t,s,n,o),logDenom:Q0+Math.log(e)+Math.log(t)-Math.log(r)}}function U6(e,t,n,o){let s=[e,0],r=R(t,-e),i=a=>{if(t<1e299)return k0(t,a);let h=k0(t*2**-64,a);return[h[0]*2**64,h[1]*2**64]},c,u;if(n[1]===0)c=w(s,i(n[0])),u=U1(c);else if(o[1]===0)u=w(r,i(o[0])),c=U1(u);else return V0(e,r[0],R(e,r[0]),n,o);let f=Y0(s,w(s,c),c),l=Y0(r,w(r,u),u);return Number.isFinite(f[0]+l[0])?m(m(f,l),R(q(e)+q(r[0]),-q(t))):[1/0,0]}function Y0(e,t,n){if(Math.max(e[0],t[0])>1e299){let r=5421010862427522e-35;return J1(Y0([e[0]*r,e[1]*r],[t[0]*r,t[1]*r],[n[0]*r,n[1]*r]))}if(Math.abs(n[0])<.1*(e[0]+t[0])){let r=m1(n,m(e,t)),i=k(n,r),c=k(r,[2*e[0],2*e[1]]),u=k(r,r);for(let f=1;f<1e3;f++){c=k(c,u);let l=T0(c,2*f+1),a=m(i,l);if(Math.abs(l[0])<=1e-33*Math.abs(a[0])||a[0]===i[0]&&a[1]===i[1])return a;i=a}return i}let o=e[0]/t[0],s=o>1e-290&&o<1e290?b(m1(e,t)):w(b(e),b(t));return w(k(s,e),n)}function V0(e,t,n,o,s,r=0,i=0){let c=Z1(e,n,o,r),u=Z1(t,n,s,i);return Number.isFinite(c[0]+u[0])?m(m(c,u),R(q(e)+q(t),-q(n[0]))):[1/0,0]}function u1(e,t,n){let o=B3(e,t,n,!n);return n?o[0]:o[1]}function K0(e,t){return B3(e,t,!0,!0)}function B3(e,t,n,o){if(t===0)return e===0?[0,1]:[-1/0,0];if(!Number.isFinite(t)||e<0)return[-1/0,0];if(e<=t*k3)return[-t,o?Math.exp(-t):NaN];if(t<e*k3){if(!Number.isFinite(e))return[-1/0,0];let f=x(e),l=f===1/0?-1/0:-t+e*Math.log(t)-f;return[l,o?Math.exp(l):NaN]}if(e<.01&&t<700){let f=e*Math.log(t)-x(e);return[-t+f,o?Math.exp(-t)*Math.exp(f):NaN]}let s=p1(e,[t,0]),r=s[0]===1/0?s:m(s,[q(e),0]),i=()=>Q0+Math.log(e),c=e>2e307,u=c?()=>Math.PI/8*e:()=>2*Math.PI*e;return[n?H0(r,!0,i,u):NaN,o?H0(r,!1,i,u)/(c?4:1):NaN]}var W1=1e6;function X3(e,t){let{value:n,sign:o}=V(t),s=n;return s-=t*Math.log(e),s+=t*(1-t)/(2*e),s+=t*(1-t)*(1-2*t)/(12*e*e),s+=-t*t*(1-t)*(1-t)/(12*e*e*e),{value:s,sign:o}}function Q5(e,t){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(e<0||t<0)return NaN;if(e===1/0&&t>0||t===1/0&&e>0)return 0;if(e>0&&t>0&&Math.max(e,t)>15){let i=Math.min(e,t),c=Math.max(e,t);if(i<1){let f=B0(i,c);return e1(i)*Math.exp(-f[0])*(1-f[1])}let u=c>=H3?z3(c,i):U3(e,t);return Math.exp(u[0])*(1+u[1])}let n=1;if(e===0||t===0||1/Math.min(e,t)===1/0)return 1/0;if(Math.abs(e)<Math.abs(t)&&([e,t]=[t,e]),Math.abs(e)>W1*Math.abs(t)&&e>W1){let i=X3(e,t);return i.sign*Math.exp(i.value)}let o=e+t;if(Math.abs(o)>Z||Math.abs(e)>Z||Math.abs(t)>Z){let i=V(o);n*=i.sign;let c=V(t);n*=c.sign;let u=V(e);n*=u.sign;let f=u.value+(c.value-i.value);return n*Math.exp(f)}o=1/e1(o);let s=e1(e),r=e1(t);return Number.isFinite(o)?Math.abs(Math.abs(s*o)-1)>Math.abs(Math.abs(r*o)-1)?r*o*s:s*o*r:n*(1/0)}function V5(e,t){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(e<0||t<0)return NaN;if(e===1/0&&t>0||t===1/0&&e>0)return-1/0;if(e>0&&t>0&&Number.isFinite(e)&&Number.isFinite(t)&&Math.max(e,t)>15){let i=Math.min(e,t),c=Math.max(e,t);if(i<1)return J(i)-R3(i,c);let u=c>=H3?z3(c,i):U3(e,t);return u[0]+u[1]}if(e===0||t===0)return 1/0;if(Math.min(e,t)<1e-300)return J(e)+J(t)-J(e+t);if(Math.abs(e)<Math.abs(t)&&([e,t]=[t,e]),Math.abs(e)>W1*Math.abs(t)&&e>W1)return X3(e,t).value;let n=e+t;if(Math.abs(n)>Z||Math.abs(e)>Z||Math.abs(t)>Z)return V(e).value+(V(t).value-V(n).value);n=1/e1(n);let o=e1(e),s=e1(t);if(!Number.isFinite(n))return 1/0;let r=Math.abs(Math.abs(o*n)-1)>Math.abs(Math.abs(s*n)-1)?s*n*o:o*n*s;return Math.log(Math.abs(r))}var j3=[.9189385332046728,-38782941580672414e-33],H3=2**52;function z3(e,t){let n=D(w(b([t,0]),b([e,0])),t),o=Math.log1p(t/e),s=Number.isFinite(e+t)?(e+t-.5)*o:e*o+(t-.5)*o,r=-.5*Math.log(t)-s+(q(e)+q(t)-q(e+t));return m(m(n,j3),[r,0])}function U3(e,t){let n=R(e,t),o=D(b([e,0]),e-.5),s=D(b([t,0]),t-.5),r=Y6(b(n),m(n,[-.5,0])),i=w(m(o,s),r);return i=m(i,j3),m(i,R(q(e)+q(t),-q(n[0])))}function Y6(e,t){return m(D(e,t[0]),D(e,t[1]))}function Z0(e){if(Math.abs(e)<.5){if(e*e===0)return 0;let t=e,n=0;for(let o=2;o<500;o++){t*=-e;let s=t/o;if(n+=s,Math.abs(s)<O*Math.abs(n))break}return n}return Math.log1p(e)-e}var Y3=[[-.3333333333333333,.08333333333333333,-.014814814814814815,.0011574074074074073,.0003527336860670194,-.0001787551440329218,3919263178522438e-20,-21854485106799924e-22,-185406221071516e-20,8296711340953087e-22,-17665952736826078e-23,6707853543401498e-24,10261809784240309e-24,-4382036018453353e-24,914769958223679e-24,-2551419399494625e-26,-5830772132550426e-26,24361948020667415e-27,-50276692801141755e-28,11004392031956135e-29,33717632624009856e-29,-1392388722418162e-28,28534893807047445e-30,-5139111834242572e-31,-19752288294349442e-31],[-.001851851851851852,-.003472222222222222,.0026455026455026454,-.0009902263374485596,.00020576131687242798,-4018775720164609e-22,-18098550334489977e-21,764916091608111e-20,-16120900894563446e-22,4647127802807434e-24,1378633446915721e-22,-5752545603517705e-23,11951628599778148e-24,-17543241719747647e-27,-10091543710600413e-25,4162792991842583e-25,-856390702649298e-25,6067215101604758e-29,71624989648114856e-28,-2933186643771437e-27,5996696365683689e-28,-21671786527323313e-32,-4978339972369262e-29,20291628823713425e-30,-413125571381061e-29],[.004133597883597883,-.0026813271604938273,.0007716049382716049,20093878600823047e-22,-.00010736653226365161,52923448829120125e-21,-12760635188618728e-21,3423578734096138e-23,13721957309062932e-22,-6298992138380055e-22,14280614206064242e-23,-20477098421990866e-26,-1409252991086752e-23,6228974084922022e-24,-13670488396617112e-25,9428356159014678e-28,12872252400089318e-26,-55645956134363323e-27,1197593554636698e-26,-41689782251838634e-31,-10940640427884595e-28,4662239946390136e-28,-9905105763906907e-29,18931876768373515e-33,8859221872591127e-30],[.0006494341563786008,.00022947209362139917,-.0004691894943952557,.00026772063206283885,-7561801671883977e-20,-2396505113867297e-22,11082654115347302e-21,-56749528269915965e-22,14230900732435883e-22,-27861080291528143e-27,-16958404091930278e-23,8099464905388083e-23,-19111168485973655e-24,23928620439808118e-28,20620131815488797e-25,-9460496661855133e-25,21541049775774907e-26,-1388823336813903e-29,-21894761681963938e-27,9790998951171684e-27,-2178219188018096e-27,6208819573407901e-32,2126978363279737e-28,-9344688791517433e-29,2045367122678285e-29],[-.0008618882909167117,.0007840392217200666,-.0002990724803031902,-14638452578843418e-22,6641498215465122e-20,-3968365047179435e-20,11375726970678419e-21,2507497226237533e-25,-16954149536558305e-22,8907507532205309e-22,-2292934834000805e-22,2956794137544049e-26,28865829742708783e-24,-14189739437803219e-24,34463580499464896e-25,-23024517174528067e-29,-39409233028046403e-26,186023389685045e-24,-4356323005056618e-26,1278600101629623e-30,467927502665792e-26,-2149246470613483e-27,4908815614809652e-28,-633859148489156e-32,-5045332069080094e-29],[-.00033679855336635813,-6972813758365858e-20,.0002772753244959392,-.00019932570516188847,6797780477937208e-20,1419062920643967e-22,-13594048189768693e-21,8018470256334202e-21,-2291481176508095e-21,-3252473551298454e-25,34652846491085265e-23,-18447187191171344e-23,48240967037894184e-24,-17989466721743514e-30,-6306194500013523e-24,3162417628774568e-24,-7840924253697429e-25,5192679165254041e-30,9358944242306784e-26,-4513426216163278e-26,10799129993116828e-27,-3661886712685252e-32,-1210902069055155e-27,5680743584990564e-28,-13249659916340829e-29],[.0005313079364639922,-.0005921664373536939,.0002708782096718045,7902353232660328e-22,-8153969367561969e-20,561168275310625e-19,-18329116582843375e-21,-30796134506033047e-25,3465155368803609e-21,-20291327396058603e-22,5788792863149004e-22,2338630673826657e-28,-8828600746330484e-23,47435958880408125e-24,-12545415020710382e-24,8649648858010293e-29,16846058979264062e-25,-8575492823577594e-25,21598224929232125e-26,-7613230520476153e-31,-26639822008536144e-27,13065700536611057e-27,-31799163902367977e-28,4710976121367431e-33,36902800842763465e-29],[.00034436760689237765,5171790908260592e-20,-.00033493161081142234,.0002812695154763237,-.00010976582244684731,-12741009095484485e-23,27744451511563645e-21,-18263488805711332e-21,57876949497350525e-22,493875893393627e-24,-10595367014026043e-22,6166714376110408e-22,-17562973359060463e-23,-1297447328701544e-27,2695423606288966e-23,-14578352908731272e-24,3887645959386175e-24,-3881002251019412e-32,-5327994173877286e-25,27437977643314844e-26,-6995796092070568e-26,2589986387486848e-32,8856689099669639e-27,-4403168815871311e-27,10865561947091654e-28],[-.0006526239185953094,.0008394987206720873,-.000438297098541721,-6969091458420552e-22,.00016644846642067547,-.00012783517679769218,4629953263691304e-20,4557909867922708e-24,-10595271125805195e-21,6783342904865167e-21,-21075476666258803e-22,-17213731432817144e-27,3773587741611098e-22,-21867506700122867e-23,6220228804018927e-23,6597703826733e-28,-9590386497425686e-24,5213214492280807e-24,-13991589583935709e-25,5382058999060575e-31,19484714275467745e-26,-10127287556389682e-26,26077347197254926e-27,-5090418699993299e-33,-33721464474854593e-28],[-.0005967612901927463,-7204895416020011e-20,.0006782308837667328,-.0006401475260262758,.00027750107634328704,1819700838046515e-22,-8479507117068503e-20,6105192082501531e-20,-21073920183404862e-21,-8858589014125599e-25,45284535953805374e-22,-28427815022504407e-22,8708234177864641e-22,36886101871706966e-28,-1534469519070206e-22,8862466778790695e-23,-25184812301826817e-24,-10225912098215092e-30,3896947075815478e-24,-21267304792235634e-25,5737013552805138e-25,-1887749850169741e-34,-8093153869465787e-26,423827232834492e-25,-11002224534207727e-27],[.0013324454494800656,-.0019144384985654776,.0011089369134596636,99324041226423e-20,-.0005087450129309319,.00042735056665392886,-.000168588537679108,-81301893922785e-22,45284402370562144e-21,-3127053674781734e-20,1044986828530338e-20,48435226265680926e-27,-2148256587345626e-21,1329369701097492e-21,-4029569309210103e-22,-1756787766632329e-28,7014504316366825e-23,-4040787734999483e-23,11474026743371962e-24,39642746853563326e-34,-17804938269892715e-25,9748026254873165e-25,-26405338676507616e-26,5794875163403742e-33,3764774955354384e-26],[.001579727660730835,.00016251626278391583,-.0020633421035543276,.00213896861856891,-.0010108559391263003,-399127055299192e-21,.0003623502508476469,-.00028143901463712157,.00010449513336495887,212114184918303e-23,-25779417251947842e-21,17281818956040464e-21,-5641377387290428e-21,-11024320105776174e-27,11223224418895176e-22,-6869339637952674e-22,20653236975414888e-23,46714772409838506e-30,-35609886164949055e-24,20470855345905963e-24,-5809173863328336e-24,-1332821287582869e-31,9035460439133513e-25,-4959878251733084e-25,13481607129399748e-26],[-.004072512119514016,.00640336283380807,-.004041016108167662,-2183732802866233e-21,.002174044180125464,-.001970044051841889,.0008359546974796246,19445447567109655e-24,-.000257793871204217,.00019009987368139304,-6769649993743896e-20,-14440629666426571e-26,15712512518742267e-21,-10304008744776892e-21,3304517767401387e-21,7982976024232571e-28,-64097794149313e-20,38894624761300054e-23,-1161834764494887e-22,-2816808630596451e-30,19878012911297094e-24,-11407719956357511e-24,32355857064185554e-25,4175946829345594e-35,-5042311271810582e-25],[-.0059475779383993,-.0005401647678926045,.00879104135507679,-.009857631558785612,.005013469503102154,12807521786221875e-22,-.0020626019342754685,.0017109128573523059,-.000676953127141338,-6901154567656214e-24,.00018855128143995903,-.0001339521566349197,4626318303352804e-20,4003423061332135e-26,-10255652921494033e-21,6612086372797651e-21,-20913022027253007e-22,-20951775649603836e-29,3975602904199325e-22,-2395621197881589e-22,7118288338214586e-23,8925574873053455e-31,-12101547235064675e-24,6935061824833439e-24,-196614644538561e-23],[.01740202778752271,-.029527880945699123,.020045875571402798,70289515966903405e-22,-.012375421071343148,.011976293444235253,-.0054156038466518525,-6329089339641862e-23,.0018855118129005065,-.001473473274825001,.0005551581009770838,5240683441255066e-25,-.00014357913535784837,991812932249433e-19,-3346083474947831e-20,-3575583729109899e-27,71560851960630075e-22,-4551680262815553e-21,14236576649271474e-22,18803149082089665e-30,-2662340389892921e-22,15950642189595716e-23,-471875146738411e-22,-6510787295875518e-32,7979509102674624e-24],[.03024912416090589,.0024817436002649977,-.049939134373457025,.05991564300930787,-.03248320760162339,-5721296865210344e-21,.015085251778569354,-.013261324005088445,.0055515262632426145,3026318225703001e-23,-.0017229548406756724,.0012893570099929638,-.00046845138348319875,-1830259937893045e-25,.00011449739014822654,-7737856522124447e-20,25625836246985202e-21,10766165333192815e-28,-5324680928242262e-21,3349634863064464e-21,-10381253128684019e-22,-5608909920621128e-30,19150821930676592e-23,-11418365800203487e-23,33654425209171787e-24],[-.09905102088015905,.17954011706123485,-.12989606383463778,-31478872752284355e-21,.09051063527684813,-.0928288244111844,.04441211283987781,27779236316835886e-23,-.017229543805449696,.014182925050891573,-.005621416163374734,-239598509186381e-23,.0016029634366079909,-.0011606784674435774,.00041001337768153875,1836580075409066e-26,-958442565636559e-19,6364306233776471e-20,-2076250624489065e-20,-11806020912804483e-29,4213180823912065e-21,-2626224133701247e-21,8077062049493066e-22,6012591212363273e-31,-1472973737401884e-22],[-.19994542198219728,-.015056113040026424,.36470239469348487,-.4643519231173355,.26640934719197895,3403826602714719e-20,-.13784338709329624,.1276467178337056,-.056213828755200985,-1753150885483011e-22,.019235592956768112,-.015088821281095314,.005740185445135012,10622382710310225e-25,-.0015335082692563998,.0010819320643228215,-.0003737251019394566,-6617090972903199e-27,8426361738090962e-20,-5515070682748348e-20,1776953644834807e-20,3882792321020553e-29,-353513697488768e-20,2186583213004527e-21,-668128494476256e-21],[.7243860850402943,-1.3918010932653375,1.0654143352413967,.0001876173868950258,-.827055011761527,.8935243334782842,-.44971003995291337,-16107401567546651e-22,.1923559016527109,-.1659770216004261,.06888222268181433,13910091724608687e-24,-.02146911561508663,.016228980898865892,-.005979601617258426,-11287469112826745e-26,.0015167451119784856,-.00104786342935539,.0003553907288912642,8170432211180152e-28,-777730134424524e-19,5029141389700772e-20,-16035083867000518e-21,12469354315487606e-30,31369106244517616e-22],[1.6668949727276812,.1165462765994632,-3.3288393225018904,4.469232548286404,-2.6977693045875806,-.0002600667859891061,1.5389017615694538,-1.4937962361134611,.6888196463323315,13077482004552384e-22,-.2576296332559629,.21097676102125448,-.08371440835921988,-7792042888135476e-24,.0242679230648336,-.017813678334552312,.006397033038890006,4943080709048052e-26,-.0015554602758465635,.0010561196919903215,-.000352771844604729,9300233464502246e-29,7528585502655717e-20,-4818651556915635e-20,15227271505597605e-21],[-6.618829886137293,13.397985455142589,-10.789350606845145,-.0014352254537875018,9.23336945961898,-10.456552819547769,5.510552602903347,12024439690716742e-21,-2.5762961164755818,2.320744274538718,-1.0045728797216285,-10207833290021913e-23,.3397509217116947,-.2672051745075747,.10235252851562705,8432973048487163e-25,-.027998284958442594,.020066274144976814,-.007055436891508624,19402238183698188e-28,.0016562888105449611,-.0011082898580743682,.0003654545161310169,-5129003202697179e-26,-7634010369686903e-20],[-17.112706061976095,-1.1208044642899115,37.131966511885445,-52.29827102534896,33.058589696624615,.002479129897620022,-20.61089403411526,20.88672775145582,-10.045703956517752,-12238783449063012e-21,4.077013427422114,-3.473667358470195,1.4329352617312006,7135991441187971e-23,-.4479725715911561,.3411266608064446,-.12699786326594922,-2895367726908153e-25,.03312577627825986,-.023274087021036102,.008039999350364889,-1177805216235265e-24,-.001832162489107167,.0012108282933588664,-.0003947994124682252],[73.89033153567425,-156.80141270402274,132.2177542759164,.013692876877324546,-123.66496885920151,146.2068939106273,-80.36558772486535,-.00011259851148881298,40.77013219617994,-38.21034001327303,17.19522294277362,9351970795516835e-22,-6.271615990774704,5.116899907185264,-2.0319658112299095,-4950721558276154e-24,.596263972943326,-.44220765337238094,.16079998700166273,-24733786203223403e-24,-.040307574759979765,.02784905074709787,-.009475185899205422,6419922235909132e-21,.002125018077469946],[212.1683709838252,13.107863022633868,-496.9828593287175,731.215952669692,-482.1382172089085,-.028817248692894887,326.167203029471,-343.8934028008712,171.95193870816232,.00014038077378096157,-75.2594195897599,66.51969984520935,-28.447519748152462,-7613702615875392e-22,9.540223710530437,-7.517530111331138,2.894399756887196,-466121949995382e-21,-.8061514959879409,.5848300657063102,-.20845408972964957,.00014765818959305816,.05100043386375302,-.03306625214188366,.015109265210467774],[-989.5964309832236,2192.555536090523,-1928.3586782723355,-.15925738122215252,1956.9985945919857,-2407.2514765081555,1375.6149959336497,.0012920735237496668,-752.5941715948055,731.7166874220871,-341.37023466220063,-9985739026060805e-21,133.56313181291574,-112.76295161252794,46.31039609820446,-7923738713361476e-21,-14.510726927018647,11.111771248100563,-4.169081794527089,.0031008219800117806,1.1220095449981469,-.7605237992614992,.36262236505085255,.2216867741940747,.48683443692930506]];var b1=1e7,V6=20,W0=200,K6=.3,Z6=4.5,Z3=4503599627370496,T=2220446049250313e-31,$1=2**-1022;function V3(e,t,n){let o=J3(e,t);if(n)return u1(e,t,!0)+Math.log(o);let s=u1(e,t,!1);return s>=$1?s*o:Math.exp(u1(e,t,!0)+Math.log(o))}function K3(e,t){let n=J3(e,t),o=K0(e,t),s=o[0]+Math.log(n);return[s,o[1]>=$1?o[1]*n:Math.exp(s)]}function J3(e,t){if(e>1e3&&t>.97*e)return W6(e,t);let n=e,o=1,s=1;for(let r=0;r<b1&&(n+=1,o*=t/n,s+=o,!(o<=O*s));r++);return s}var J6=2**-64;function W6(e,t){let n=1,o=0,s=1,r=0;for(let i=1;i<b1;i++){let c=e+i,u=c-e,f=e-(c-u)+(i-u),l=t/c,a=134217729*l,h=a-(a-l),I=l-h;a=134217729*c;let S=a-(a-c),P=c-S,M=l*c,g=h*S-M+h*P+I*S+I*P,B=(t-M-g-l*f)/c;a=134217729*n;let X=a-(a-n),C=n-X,j=n*l,N=X*h-j+X*I+C*h+C*I+(n*B+o*l);n=j+N,o=N-(n-j);let _=s+n,A=_-s,L=s-(_-A)+(n-A)+(r+o);if(s=_+L,r=L-(s-_),n*l<=J6*s*(1-l))break}return s+r}function $6(e,t,n){let o=W3(e,t);if(n)return Math.log(e)+u1(e,t,!0)+Math.log(o);let s=u1(e,t,!1);return s>=$1?e*s*o:Math.exp(Math.log(e)+u1(e,t,!0)+Math.log(o))}function x6(e,t){let n=W3(e,t),o=K0(e,t),s=Math.log(e)+o[0]+Math.log(n);return[s,o[1]>=$1?e*o[1]*n:Math.exp(s)]}function W3(e,t){if(t>1e20)return o5(e,t);if(e<e5&&t<t5)return n5(e,t);let n=1-e,o=t+n+1,s=0,r=1,i=t,c=t+1,u=o*t,f=c/u;for(let l=0;l<b1;l++){s+=1,n+=1,o+=2;let a=n*s,h=c*o-r*a,I=u*o-i*a,S;if(I!==0){let P=h/I;S=Math.abs((f-P)/P),f=P}else S=1;if(r=c,c=h,i=u,u=I,Math.abs(h)>Z3&&(r*=T,c*=T,i*=T,u*=T),S<=O)break}return f}var e5=4,t5=64;function n5(e,t){let n=0,o=0,s=(N,_,A,L)=>{let F=N*A,y=134217729*N,H=y-(y-N),n1=N-H;y=134217729*A;let v=y-(y-A),z=A-v,G=H*v-F+H*z+n1*v+n1*z+(N*L+_*A);n=F+G,o=G-(n-F)},r=(N,_,A,L)=>{let F=N-A,y=F-N,H=N-(F-y)-(A+y)+(_-L);n=F+H,o=H-(n-F)},i=(N,_,A)=>{let L=N+A,F=L-N,y=N-(L-F)+(A-F)+_;n=L+y,o=y-(n-L)};r(1,0,e,0);let c=n,u=o;i(c,u,1),r(n,o,-t,0);let f=n,l=o,a=0,h=1,I=0,S=t,P=0;i(t,0,1);let M=n,g=o;s(f,l,t,0);let B=n,X=o,C=M/B,j=0;for(let N=0;N<b1;N++){a+=1,i(c,u,1),c=n,u=o,i(f,l,2),f=n,l=o,s(c,u,a,0);let _=n,A=o;s(M,g,f,l);let L=n,F=o;s(h,I,_,A),r(L,F,n,o);let y=n,H=o;s(B,X,f,l);let n1=n,v=o;s(S,P,_,A),r(n1,v,n,o);let z=n,G=o,o1=y/z;s(o1,0,z,G),r(y,H,n,o);let g1=(n+o)/z,W=o1+g1,N1=g1-(W-o1),E1=C-W+(j-N1);if(C=W,j=N1,h=M,I=g,M=y,g=H,S=B,P=X,B=z,X=G,Math.abs(M)>Z3&&(h*=T,I*=T,M*=T,g*=T,S*=T,P*=T,B*=T,X*=T),Math.abs(E1)<=2**-58*Math.abs(W))break}return C+j}function o5(e,t){let o=t+1-e,s=1/1e-300,r=1/o,i=r;for(let c=1;c<b1;c++){let u=-c*(c-e);o+=2,r=u*r+o,Math.abs(r)<1e-300&&(r=1e-300),s=o+u/s,Math.abs(s)<1e-300&&(s=1e-300),r=1/r;let f=r*s;if(i*=f,Math.abs(f-1)<=O)break}return i}function $3(e,t){let n=1,o=0;for(let c=1;c<b1;c++){n*=-t/c;let u=n/(e+c);if(o+=u,Math.abs(u)<=O*Math.abs(o))break}let s=Math.log(t),r=e*s-x(e);return-Math.expm1(r)-e*Math.exp(r)*o}function s5(e,t){let n=t/e,o=(t-e)/e;return n>1?Math.sqrt(-2*Z0(o)):n<1?-Math.sqrt(-2*Z0(o)):0}function r5(e,t){let n=new Array(25).fill(0);n[0]=1;let o=0,s=0,r=1,i=1/0;for(let c=0;c<25;c++){let u=Y3[c],f=u[0];for(let h=1;h<25;h++){h>o&&(n[h]=t*n[h-1],o+=1);let I=u[h]*n[h];if(f+=I,Math.abs(I)<O*Math.abs(f))break}let l=f*r,a=Math.abs(l);if(a>i||(s+=l,a<O*Math.abs(s)))break;i=a,r/=e}return s}function x3(e,t){return e>V6&&e<W0&&t<K6||e>W0&&t<Z6/Math.sqrt(e)}var e6=1e299,t6=(e,t)=>e>W0&&(t<.001||e>e6);function c5(e,t){let n=p1(e,[t,0]),o=t>e?1:-1,s=s5(e,t),r=e>e6&&Math.abs(s)>.1?1/((t-e)/e)-1/s:r5(e,s),i=.5*P3(Math.sqrt(n[0]+n[1]))+o*r/Math.sqrt(2*Math.PI*e);return[-n[0]-n[1]+Math.log(i),n[0]>2e3?0:Math.exp(-n[0])*(1-n[1])*i]}function n6(e,t,n){let[o,s]=c5(e,t);return t>e!==n?[o,s]:[Math.log1p(-s),1-s]}function J0(e,t,n){if(t>1.1)return t<e?{lower:!0,value:V3(e,t,n)}:{lower:!1,value:$6(e,t,n)};if(t<=.5?-.4/Math.log(t)<e:t*1.1<e)return{lower:!0,value:V3(e,t,n)};let s=$3(e,t);return{lower:!1,value:n?Math.log(s):s}}function i5(e,t){if(t>1.1){let[s,r]=t<e?K3(e,t):x6(e,t);return{lower:t<e,log:s,lin:r}}if(t<=.5?-.4/Math.log(t)<e:t*1.1<e){let[s,r]=K3(e,t);return{lower:!0,log:s,lin:r}}let o=$3(e,t);return{lower:!1,log:Math.log(o),lin:o}}var t1=1e-300;function u5(e,t,n){if(Number.isNaN(e)||Number.isNaN(t))return[NaN,NaN];if(t<0||e<0)return[NaN,NaN];if(e===0)return t>0?n?[0,1]:[-1/0,0]:[NaN,NaN];if(t===0)return n?[-1/0,0]:[0,1];if(e===1/0)return t===1/0?[NaN,NaN]:n?[-1/0,0]:[0,1];if(t===1/0)return n?[0,1]:[-1/0,0];if(t>1e15*Math.max(e,1)){let r=(e-1)*Math.log(t)-t-J(e)+Math.log1p((e-1)/t);return n?[Math.log1p(-Math.exp(r)),-Math.expm1(r)]:[r,Math.exp(r)]}if(!n&&e<t1){let[r,i]=u5(t1,t,!1);return[r+Math.log(e/t1),i*(e/t1)]}let o=Math.abs(t-e)/e;if(x3(e,o)||t6(e,o))return n6(e,t,n);let s=i5(e,t);return s.lower===n?[s.log,s.lin]:[s.lin>0?Math.log1p(-s.lin):-Math.exp(s.log),1-s.lin]}function f5(e,t,n,o){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(t<0||e<0)return NaN;let s=o?-1/0:0,r=o?0:1;if(e===0)return t>0?n?r:s:NaN;if(t===0)return n?s:r;if(e===1/0)return t===1/0?NaN:n?s:r;if(t===1/0)return n?r:s;if(t>1e15*Math.max(e,1)){let u=(e-1)*Math.log(t)-t-J(e)+Math.log1p((e-1)/t);return n?o?Math.log1p(-Math.exp(u)):-Math.expm1(u):o?u:Math.exp(u)}if(!n&&e<t1){let u=f5(t1,t,!1,o);return o?u+Math.log(e/t1):u*(e/t1)}let i=Math.abs(t-e)/e;if(x3(e,i)||t6(e,i))return n6(e,t,n)[o?0:1];if(o){let u=J0(e,t,!0);if(u.lower===n)return u.value;let f=J0(e,t,!1).value;return f>0?Math.log1p(-f):-Math.exp(u.value)}let c=J0(e,t,!1);return c.lower===n?c.value:1-c.value}export{O as a,C0 as b,q3 as c,e1 as d,V as e,J as f,x as g,q as h,p1 as i,C5 as j,O5 as k,B5 as l,u1 as m,Z0 as n,J3 as o,W6 as p,W3 as q,u5 as r,f5 as s,R3 as t,B0 as u,Q5 as v,V5 as w,U3 as x};
1
+ /*! rStats.js 1.14.0 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
+ import{a as L1,b as F3,e as P3}from"./chunk-ZJJJDLRL.js";import{a as D3,b as R,c as k0,d as m,e as U1,f as w,g as k,h as D,i as m1,j as T0,k as b}from"./chunk-TGXUU5NB.js";var O=11102230246251565e-32;var Z=171.6243769563027,w1=.9189385332046728,L3=1.1447298858494002;var C0=.5772156649015329;var F6=[.00016011952247675185,.0011913514700658638,.010421379756176158,.04763678004571372,.20744822764843598,.4942148268014971,1],D6=[-23158187332412014e-21,.0005396055804933034,-.004456419138517973,.011813978522206043,.035823639860549865,-.23459179571824335,.0714304917030273,1];function q3(e){let t=1;e<0&&(e=-e,t=-1);let n=e%2;return n<.5?t*Math.sin(Math.PI*n):n>1.5?t*Math.sin(Math.PI*(n-2)):-t*Math.sin(Math.PI*(n-1))}function O0(e){if(e>Z)return 1/0;let t=e-1,n=m(D(b([t,0]),t),[-t+k6(t),0]);return Math.sqrt(2*Math.PI*t)*Math.exp(n[0])*(1+n[1])}function e1(e){if(!Number.isFinite(e))return e>0?e:NaN;if(e===0)return NaN;let t=Math.abs(e);if(t>33){if(e<0){let o=Math.floor(t);if(o===t)return NaN;let s=o%2===0?-1:1,r=t-o;if(r>.5&&(o+=1,r=t-o),r=t*q3(r),r===0)return s*(1/0);let i=Math.abs(r)*O0(t);if(Number.isFinite(i))return s*Math.PI/i;let c=1;for(let u=1;u<=10;u++)c*=t-u;return s*Math.PI/(Math.abs(r)*O0(t-10))/c}return O0(e)}let n=1;for(;e>=3;)e-=1,n*=e;for(;e<0;){if(e>-1e-9)return w3(e,n);n/=e,e+=1}for(;e<2;){if(e<1e-9)return w3(e,n);n/=e,e+=1}return e===2?n:(e-=2,n*L1(e,F6)/L1(e,D6))}function w3(e,t){return e===0?NaN:t/((1+C0*e)*e)}var P6=[.0008116141674705085,-.0005950619042843014,.0007936503404577169,-.002777777777300997,.08333333333333319],L6=[-1378.2515256912086,-38801.631513463784,-331612.9927388712,-1162370974927623e-9,-1.7217370082083966e6,-853555.6642457654],w6=[-351.81570143652345,-17064.210665188115,-220528.59055385445,-1.1393344436798252e6,-2.5325230717758294e6,-2.0188914143353277e6],E6=2556348e299;function q6(e){let t=(e-.5)*Math.log(e)-e+w1;if(e>1e8)return t;let n=1/(e*e);return t+((.0007936507936507937*n-.002777777777777778)*n+.08333333333333333)/e}function V(e){if(!Number.isFinite(e))return{value:e===-1/0?1/0:e,sign:1};if(e<-34){let o=-e,s=V(o).value,r=Math.floor(o);if(r===o)return{value:1/0,sign:1};let i=r%2===0?-1:1,c=o-r;return c>.5&&(r+=1,c=r-o),c=o*q3(c),c===0?{value:1/0,sign:1}:{value:L3-Math.log(c)-s,sign:i}}if(e!==0&&Math.abs(e)<1e-300)return{value:-Math.log(Math.abs(e)),sign:e>0?1:-1};if(e<13){let o=1,s=0,r=e;for(;r>=3;)s-=1,r=e+s,o*=r;for(;r<2;){if(r===0)return{value:1/0,sign:1};o/=r,s+=1,r=e+s}let i=1;if(o<0&&(i=-1,o=-o),r===2)return{value:Math.log(o),sign:i};s-=2;let c=e+s;return{value:Math.log(o)+c*L1(c,L6)/F3(c,w6),sign:i}}if(e>E6)return{value:1/0,sign:1};if(e>=1e3)return{value:q6(e),sign:1};let t=(e-.5)*Math.log(e)-e+w1,n=1/(e*e);return{value:t+L1(n,P6)/e,sign:1}}function J(e){return Math.abs(e-1)<=.2?x(e-1):Math.abs(e-2)<=.2?x(e-2)+Math.log1p(e-2):V(e).value}var G6=[1.6449340668482264,1.2020569031595942,1.0823232337111381,1.03692775514337,1.0173430619844492,1.008349277381923,1.0040773561979444,1.0020083928260821,1.000994575127818,1.0004941886041194,1.000246086553308,1.0001227133475785,1.0000612481350588,1.000030588236307,1.0000152822594086,1.0000076371976379,1.000003817293265,1.0000019082127165,1.0000009539620338,1.0000004769329869,1.0000002384505027,1.000000119219926,1.000000059608189,1.0000000298035034,1.0000000149015549,1.0000000074507118,1.000000003725334,1.0000000018626598,1.0000000009313275,1.0000000004656628,1.000000000232831,1.0000000001164155,1.0000000000582077,1.0000000000291038,1.000000000014552,1.000000000007276,1.000000000003638,1.000000000001819,1.0000000000009095,1.0000000000004547];function E3(e){if(e===0)return 0;let t=-C0*e,n=-e;for(let o=2;o<42;o++){n*=-e;let s=G6[o-2]*n/o;if(t+=s,Math.abs(s)<O*Math.abs(t))break}return t}function x(e){return Math.abs(e)<=.2?E3(e):Math.abs(e-1)<=.2?Math.log(e)+E3(e-1):J(e+1)}var R6=[1/12,-1/360,1/1260,-1/1680,1/1188,-691/360360,1/156];function k6(e){let t=1/(e*e),n=0,o=1/e;for(let s of R6)n+=s*o,o*=t;return n}var G3=[1/12,-1/360,1/1260,-1/1680,1/1188,-691/360360,1/156];function R3(e,t){let n=B0(e,t);return n[0]+n[1]}function B0(e,t){if(e===0)return[0,0];let n=0,o=t;for(;o<=15;)n-=Math.log1p(e/o),o+=1;let s=Math.log1p(e/o),r=e*Math.log(o+e),i=Math.abs(r)>2&&Number.isFinite(r)&&e<1e300?D(b(R(o,e)),e):[r,0],c=(o-.5)*s-e,u=1/o,f=1/(o*o);for(let l=0;l<G3.length;l++){let a=2*l+1;c+=G3[l]*u*Math.expm1(-a*s),u*=f}return m(i,[n+c,0])}var k3=22250738585072014e-324,Q0=1.8378770664093456,T6=[.15342640972002736,.08106146679532726,.05481412105191765,.0413406959554093,.03316287351993629,.02767792568499834,.023746163656297496,.020790672103765093,.018488450532673187,.016644691189821193,.015134973221917378,.013876128823070748,.012810465242920227,.01189670994589177,.011104559758206917,.010411265261972096,.009799416126158804,.009255462182712733,.008768700134139386,.00833056343336287,.00793411456431402,.007573675487951841,.007244554301320383,.00694284010720953,.006665247032707682,.006408994188004207,.006171712263039458,.0059513701127588475,.0057462165130101155,.005554733551962801],Y1=1/12,Q1=1/360,X0=1/1260,T3=1/1680,C6=1/1188,O6=691/360360,B6=1/156;function C3(e){let t=1/(e*e);return e>500?(Y1-Q1*t)/e:e>80?(Y1-(Q1-X0*t)*t)/e:e>35?(Y1-(Q1-(X0-T3*t)*t)*t)/e:(Y1-(Q1-(X0-(T3-(C6-(O6-B6*t)*t)*t)*t)*t)*t)/e}function q(e){if(e>15)return C3(e);let t=2*e;if(t===Math.floor(t)&&t>=1)return T6[t-1];if(e<1)return x(e)-(e+.5)*Math.log(e)+e-w1;let n=0,o=e;for(;o<=15;)n+=(o+.5)*Math.log1p(1/o)-1,o+=1;return n+C3(o)}var X6=.12;function p1(e,t){if(e===0)return t;if(Math.max(e,t[0])>1e299&&Math.min(e,t[0])>1e-250)return J1(p1(e*2**-64,[t[0]*2**-64,t[1]*2**-64]));if(!D3())return j6(e,t);let n=-t[0],o=-t[1],s=e+n,r=s-e,i=e-(s-r)+(n-r),c=0+o,u=c-0,f=0-(c-u)+(o-u),l=i+c,a=s+l,I=l-(a-s)+f,S=a+I,P=I-(S-a),M=S,g=P;if(Math.abs(M)<.1*(e+t[0])){let C=e+t[0],j=C-e,N=e-(C-j)+(t[0]-j),_=0+t[1],A=_-0,L=0-(_-A)+(t[1]-A),F=N+_,y=C+F,n1=F-(y-C)+L,v=y+n1,z=n1-(v-y),G=M/v,o1=v*G,g1=134217729*v,W=g1-(g1-v),N1=v-W,E1=134217729*G,x1=E1-(E1-G),$0=G-x1,x0=W*x1-o1+W*$0+N1*x1+N1*$0+z*G,e2=o1+x0,o6=x0-(e2-o1),t2=-e2,n2=-o6,q1=M+t2,o2=q1-M,s6=M-(q1-o2)+(t2-o2),e0=g+n2,s2=e0-g,r6=g-(e0-s2)+(n2-s2),r2=s6+e0,t0=q1+r2,c2=r2-(t0-q1)+r6,d1=t0+c2,n0=c2-(d1-t0),s1=d1/v,o0=v*s1,i2=134217729*v,s0=i2-(i2-v),u2=v-s0,f2=134217729*s1,r0=f2-(f2-s1),a2=s1-r0,l2=s0*r0-o0+s0*a2+u2*r0+u2*a2+z*s1,h2=o0+l2,c6=l2-(h2-o0),M2=-h2,m2=-c6,G1=d1+M2,p2=G1-d1,i6=d1-(G1-p2)+(M2-p2),c0=n0+m2,b2=c0-n0,u6=n0-(c0-b2)+(m2-b2),g2=i6+c0,i0=G1+g2,N2=g2-(i0-G1)+u6,d2=i0+N2,m5=N2-(d2-i0),I2=d2/v,R1=G+s1,u0=s1-(R1-G),k1=R1+I2,A2=k1-R1,f6=R1-(k1-A2)+(I2-A2),f0=u0+0,y2=f0-u0,a6=u0-(f0-y2)+(0-y2),v2=f6+f0,a0=k1+v2,S2=v2-(a0-k1)+a6,_2=a0+S2,l6=S2-(_2-a0),p=_2,T1=l6,l0=M*p,F2=134217729*M,h0=F2-(F2-M),D2=M-h0,P2=134217729*p,M0=P2-(P2-p),L2=p-M0,w2=h0*M0-l0+h0*L2+D2*M0+D2*L2+(M*T1+g*p),E2=l0+w2,h6=w2-(E2-l0),U=E2,K=h6;if(Math.abs(e*p*p*p)<=X6){let f1=p*p,r1=2*e*p*f1,a1=r1/3;for(let h1=2;h1<1e3;h1++){r1*=f1;let M1=r1/(2*h1+1);if(a1+=M1,Math.abs(M1)<=2**-60*U)break}let $=U+a1,v1=$-U,C1=U-($-v1)+(a1-v1),c1=K+0,S1=c1-K,U2=K-(c1-S1)+(0-S1),_1=C1+c1,l1=$+_1,E=_1-(l1-$)+U2,Q=l1+E,F1=E-(Q-l1);return[Q,F1]}let I1=2*e,m0=p*I1,q2=134217729*p,p0=q2-(q2-p),G2=p-p0,R2=134217729*I1,b0=R2-(R2-I1),k2=I1-b0,T2=p0*b0-m0+p0*k2+G2*b0+G2*k2+T1*I1,C2=m0+T2,M6=T2-(C2-m0),Y=C2,A1=M6,g0=p*p,O2=134217729*p,N0=O2-(O2-p),B2=p-N0,X2=134217729*p,d0=X2-(X2-p),j2=p-d0,H2=N0*d0-g0+N0*j2+B2*d0+B2*j2+(p*T1+T1*p),z2=g0+H2,m6=H2-(z2-g0),y1=z2,p6=m6;for(let f1=1;f1<1e3;f1++){let r1=Y*y1,a1=134217729*Y,$=a1-(a1-Y),v1=Y-$,C1=134217729*y1,c1=C1-(C1-y1),S1=y1-c1,_1=$*c1-r1+$*S1+v1*c1+v1*S1+(Y*p6+A1*y1),l1=r1+_1,Y2=_1-(l1-r1);Y=l1,A1=Y2;let E=2*f1+1,Q=Y/E,F1=E*Q,h1=134217729*E,M1=h1-(h1-E),Q2=E-M1,V2=134217729*Q,I0=V2-(V2-Q),K2=Q-I0,Z2=M1*I0-F1+M1*K2+Q2*I0+Q2*K2+0*Q,J2=F1+Z2,b6=Z2-(J2-F1),W2=-J2,$2=-b6,O1=Y+W2,x2=O1-Y,g6=Y-(O1-x2)+(W2-x2),A0=A1+$2,e3=A0-A1,N6=A1-(A0-e3)+($2-e3),t3=g6+A0,y0=O1+t3,n3=t3-(y0-O1)+N6,D1=y0+n3,v0=n3-(D1-y0),i1=D1/E,S0=E*i1,o3=134217729*E,_0=o3-(o3-E),s3=E-_0,r3=134217729*i1,F0=r3-(r3-i1),c3=i1-F0,i3=_0*F0-S0+_0*c3+s3*F0+s3*c3+0*i1,u3=S0+i3,d6=i3-(u3-S0),f3=-u3,a3=-d6,B1=D1+f3,l3=B1-D1,I6=D1-(B1-l3)+(f3-l3),D0=v0+a3,h3=D0-v0,A6=v0-(D0-h3)+(a3-h3),M3=I6+D0,P0=B1+M3,m3=M3-(P0-B1)+A6,p3=P0+m3,v5=m3-(p3-P0),b3=p3/E,X1=Q+i1,L0=i1-(X1-Q),j1=X1+b3,g3=j1-X1,y6=X1-(j1-g3)+(b3-g3),w0=L0+0,N3=w0-L0,v6=L0-(w0-N3)+(0-N3),d3=y6+w0,E0=j1+d3,I3=d3-(E0-j1)+v6,H1=E0+I3,A3=I3-(H1-E0),z1=U+H1,y3=z1-U,S6=U-(z1-y3)+(H1-y3),q0=K+A3,v3=q0-K,_6=K-(q0-v3)+(A3-v3),S3=S6+q0,G0=z1+S3,_3=S3-(G0-z1)+_6,P1=G0+_3,R0=_3-(P1-G0);if(Math.abs(H1)<=1e-33*Math.abs(P1)||P1===U&&R0===K)return[P1,R0];U=P1,K=R0}return[U,K]}let B=e/t[0],X=B>1e-290&&B<1e290&&Math.max(e,t[0])<1e300?b(m1([e,0],t)):w(b([e,0]),b(t));return O3(X,e,[M,g])}function j6(e,t){let n=w([e,0],t);if(Math.abs(n[0])<.1*(e+t[0])){let r=m1(n,m([e,0],t)),i=k(n,r),c=D(r,2*e),u=k(r,r);for(let f=1;f<1e3;f++){c=k(c,u);let l=T0(c,2*f+1),a=m(i,l);if(Math.abs(l[0])<=1e-33*Math.abs(a[0])||a[0]===i[0]&&a[1]===i[1])return a;i=a}return i}let o=e/t[0],s=o>1e-290&&o<1e290&&Math.max(e,t[0])<1e300?b(m1([e,0],t)):w(b([e,0]),b(t));return O3(s,e,n)}function O3(e,t,n){return t<1e299?m(D(e,t),U1(n)):J1(m(D(e,t*2**-64),[-n[0]*2**-64,-n[1]*2**-64]))}function J1(e){let t=e[0]*18446744073709552e3;return Number.isFinite(t)?[t,e[1]*2**64]:[t,0]}function Z1(e,t,n,o=0){let s=t[0]>1e299?5421010862427522e-35:1,r;if(o===0){let c=k([t[0]*s,t[1]*s],n);r=[c[0]/s,c[1]/s]}else r=U0(t,n,o);if(r[0]>=1e-290)return p1(e,r);let i=w(b([e,0]),m(b(t),j0(n,o)));return m(D(i,e),R(o===0?t[0]*n[0]:r[0],-e))}var V1=(e,t)=>e*2**Math.trunc(t/2)*2**(t-Math.trunc(t/2)),H6=[.6931471805599453,23190468138462996e-33],j0=(e,t)=>t===0?b(e):w(b(e),D(H6,t));function C5(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||t===0)return NaN;if(e===0)return t;let n=p1(e,[t,0]);return n[0]+n[1]}function H0(e,t,n,o){if(t)return-e[0]-e[1]-.5*n();if(e[0]<700)return Math.exp(-e[0])*(1-e[1])/Math.sqrt(o());if(e[0]>2e3)return 0;let s=o();return!Number.isFinite(s)||s===0?Math.exp(-e[0]-e[1]-.5*n()):Math.exp(700-e[0])*(1-e[1])/Math.sqrt(s)*Math.exp(-700)}function z0(e,t){return e[0]>1e299?J1(k([e[0]*2**-64,e[1]*2**-64],t)):k(e,t)}var z6=[0,0];function U0(e,t,n){if(n===0)return z0(e,t);let o=Math.floor(Math.log2(e[0])),s=k([V1(e[0],-o),V1(e[1],-o)],t);return[V1(s[0],o-n),V1(s[1],o-n)]}var K1=e=>e[0]<-2e3?0:Math.exp(e[0])*(1+e[1]);function O5(e,t,n,o,s,r,i=z6){let[c,u]=i,f=s?-1/0:0,l=s?0:1,a=R(e,t),h=a[0];if(n[0]===0)return e===0?l:f;if(o[0]===0)return t===0?l:f;if(e===0){if(h===0)return l;if(c>0||n[0]<.1){let g=m(Z1(h,a,o,u),U0(a,n,c));return s?-g[0]-g[1]:K1([-g[0],-g[1]])}let M=z0(a,j0(o,u));return s?M[0]+M[1]:K1(M)}if(t===0){if(u>0||o[0]<.1){let g=m(Z1(h,a,n,c),U0(a,o,u));return s?-g[0]-g[1]:K1([-g[0],-g[1]])}let M=z0(a,j0(n,c));return s?M[0]+M[1]:K1(M)}if(e<0||t<0)return f;let I=r!==void 0&&(a[0]!==r||a[1]!==0)?U6(e,r,n,o):V0(e,t,a,n,o,c,u),S=e*(t/h)>2e307,P=H0(I,s,()=>Q0+Math.log(e)+Math.log(t)-Math.log(h),S?()=>Math.PI/8*(e*(t/h)):()=>2*Math.PI*e*(t/h));return S&&!s?P/4:P}function B5(e,t,n,o){let s=R(e,t),r=s[0];return{e:V0(e,t,s,n,o),logDenom:Q0+Math.log(e)+Math.log(t)-Math.log(r)}}function U6(e,t,n,o){let s=[e,0],r=R(t,-e),i=a=>{if(t<1e299)return k0(t,a);let h=k0(t*2**-64,a);return[h[0]*2**64,h[1]*2**64]},c,u;if(n[1]===0)c=w(s,i(n[0])),u=U1(c);else if(o[1]===0)u=w(r,i(o[0])),c=U1(u);else return V0(e,r[0],R(e,r[0]),n,o);let f=Y0(s,w(s,c),c),l=Y0(r,w(r,u),u);return Number.isFinite(f[0]+l[0])?m(m(f,l),R(q(e)+q(r[0]),-q(t))):[1/0,0]}function Y0(e,t,n){if(Math.max(e[0],t[0])>1e299){let r=5421010862427522e-35;return J1(Y0([e[0]*r,e[1]*r],[t[0]*r,t[1]*r],[n[0]*r,n[1]*r]))}if(Math.abs(n[0])<.1*(e[0]+t[0])){let r=m1(n,m(e,t)),i=k(n,r),c=k(r,[2*e[0],2*e[1]]),u=k(r,r);for(let f=1;f<1e3;f++){c=k(c,u);let l=T0(c,2*f+1),a=m(i,l);if(Math.abs(l[0])<=1e-33*Math.abs(a[0])||a[0]===i[0]&&a[1]===i[1])return a;i=a}return i}let o=e[0]/t[0],s=o>1e-290&&o<1e290?b(m1(e,t)):w(b(e),b(t));return w(k(s,e),n)}function V0(e,t,n,o,s,r=0,i=0){let c=Z1(e,n,o,r),u=Z1(t,n,s,i);return Number.isFinite(c[0]+u[0])?m(m(c,u),R(q(e)+q(t),-q(n[0]))):[1/0,0]}function u1(e,t,n){let o=B3(e,t,n,!n);return n?o[0]:o[1]}function K0(e,t){return B3(e,t,!0,!0)}function B3(e,t,n,o){if(t===0)return e===0?[0,1]:[-1/0,0];if(!Number.isFinite(t)||e<0)return[-1/0,0];if(e<=t*k3)return[-t,o?Math.exp(-t):NaN];if(t<e*k3){if(!Number.isFinite(e))return[-1/0,0];let f=x(e),l=f===1/0?-1/0:-t+e*Math.log(t)-f;return[l,o?Math.exp(l):NaN]}if(e<.01&&t<700){let f=e*Math.log(t)-x(e);return[-t+f,o?Math.exp(-t)*Math.exp(f):NaN]}let s=p1(e,[t,0]),r=s[0]===1/0?s:m(s,[q(e),0]),i=()=>Q0+Math.log(e),c=e>2e307,u=c?()=>Math.PI/8*e:()=>2*Math.PI*e;return[n?H0(r,!0,i,u):NaN,o?H0(r,!1,i,u)/(c?4:1):NaN]}var W1=1e6;function X3(e,t){let{value:n,sign:o}=V(t),s=n;return s-=t*Math.log(e),s+=t*(1-t)/(2*e),s+=t*(1-t)*(1-2*t)/(12*e*e),s+=-t*t*(1-t)*(1-t)/(12*e*e*e),{value:s,sign:o}}function Q5(e,t){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(e<0||t<0)return NaN;if(e===1/0&&t>0||t===1/0&&e>0)return 0;if(e>0&&t>0&&Math.max(e,t)>15){let i=Math.min(e,t),c=Math.max(e,t);if(i<1){let f=B0(i,c);return e1(i)*Math.exp(-f[0])*(1-f[1])}let u=c>=H3?z3(c,i):U3(e,t);return Math.exp(u[0])*(1+u[1])}let n=1;if(e===0||t===0||1/Math.min(e,t)===1/0)return 1/0;if(Math.abs(e)<Math.abs(t)&&([e,t]=[t,e]),Math.abs(e)>W1*Math.abs(t)&&e>W1){let i=X3(e,t);return i.sign*Math.exp(i.value)}let o=e+t;if(Math.abs(o)>Z||Math.abs(e)>Z||Math.abs(t)>Z){let i=V(o);n*=i.sign;let c=V(t);n*=c.sign;let u=V(e);n*=u.sign;let f=u.value+(c.value-i.value);return n*Math.exp(f)}o=1/e1(o);let s=e1(e),r=e1(t);return Number.isFinite(o)?Math.abs(Math.abs(s*o)-1)>Math.abs(Math.abs(r*o)-1)?r*o*s:s*o*r:n*(1/0)}function V5(e,t){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(e<0||t<0)return NaN;if(e===1/0&&t>0||t===1/0&&e>0)return-1/0;if(e>0&&t>0&&Number.isFinite(e)&&Number.isFinite(t)&&Math.max(e,t)>15){let i=Math.min(e,t),c=Math.max(e,t);if(i<1)return J(i)-R3(i,c);let u=c>=H3?z3(c,i):U3(e,t);return u[0]+u[1]}if(e===0||t===0)return 1/0;if(Math.min(e,t)<1e-300)return J(e)+J(t)-J(e+t);if(Math.abs(e)<Math.abs(t)&&([e,t]=[t,e]),Math.abs(e)>W1*Math.abs(t)&&e>W1)return X3(e,t).value;let n=e+t;if(Math.abs(n)>Z||Math.abs(e)>Z||Math.abs(t)>Z)return V(e).value+(V(t).value-V(n).value);n=1/e1(n);let o=e1(e),s=e1(t);if(!Number.isFinite(n))return 1/0;let r=Math.abs(Math.abs(o*n)-1)>Math.abs(Math.abs(s*n)-1)?s*n*o:o*n*s;return Math.log(Math.abs(r))}var j3=[.9189385332046728,-38782941580672414e-33],H3=2**52;function z3(e,t){let n=D(w(b([t,0]),b([e,0])),t),o=Math.log1p(t/e),s=Number.isFinite(e+t)?(e+t-.5)*o:e*o+(t-.5)*o,r=-.5*Math.log(t)-s+(q(e)+q(t)-q(e+t));return m(m(n,j3),[r,0])}function U3(e,t){let n=R(e,t),o=D(b([e,0]),e-.5),s=D(b([t,0]),t-.5),r=Y6(b(n),m(n,[-.5,0])),i=w(m(o,s),r);return i=m(i,j3),m(i,R(q(e)+q(t),-q(n[0])))}function Y6(e,t){return m(D(e,t[0]),D(e,t[1]))}function Z0(e){if(Math.abs(e)<.5){if(e*e===0)return 0;let t=e,n=0;for(let o=2;o<500;o++){t*=-e;let s=t/o;if(n+=s,Math.abs(s)<O*Math.abs(n))break}return n}return Math.log1p(e)-e}var Y3=[[-.3333333333333333,.08333333333333333,-.014814814814814815,.0011574074074074073,.0003527336860670194,-.0001787551440329218,3919263178522438e-20,-21854485106799924e-22,-185406221071516e-20,8296711340953087e-22,-17665952736826078e-23,6707853543401498e-24,10261809784240309e-24,-4382036018453353e-24,914769958223679e-24,-2551419399494625e-26,-5830772132550426e-26,24361948020667415e-27,-50276692801141755e-28,11004392031956135e-29,33717632624009856e-29,-1392388722418162e-28,28534893807047445e-30,-5139111834242572e-31,-19752288294349442e-31],[-.001851851851851852,-.003472222222222222,.0026455026455026454,-.0009902263374485596,.00020576131687242798,-4018775720164609e-22,-18098550334489977e-21,764916091608111e-20,-16120900894563446e-22,4647127802807434e-24,1378633446915721e-22,-5752545603517705e-23,11951628599778148e-24,-17543241719747647e-27,-10091543710600413e-25,4162792991842583e-25,-856390702649298e-25,6067215101604758e-29,71624989648114856e-28,-2933186643771437e-27,5996696365683689e-28,-21671786527323313e-32,-4978339972369262e-29,20291628823713425e-30,-413125571381061e-29],[.004133597883597883,-.0026813271604938273,.0007716049382716049,20093878600823047e-22,-.00010736653226365161,52923448829120125e-21,-12760635188618728e-21,3423578734096138e-23,13721957309062932e-22,-6298992138380055e-22,14280614206064242e-23,-20477098421990866e-26,-1409252991086752e-23,6228974084922022e-24,-13670488396617112e-25,9428356159014678e-28,12872252400089318e-26,-55645956134363323e-27,1197593554636698e-26,-41689782251838634e-31,-10940640427884595e-28,4662239946390136e-28,-9905105763906907e-29,18931876768373515e-33,8859221872591127e-30],[.0006494341563786008,.00022947209362139917,-.0004691894943952557,.00026772063206283885,-7561801671883977e-20,-2396505113867297e-22,11082654115347302e-21,-56749528269915965e-22,14230900732435883e-22,-27861080291528143e-27,-16958404091930278e-23,8099464905388083e-23,-19111168485973655e-24,23928620439808118e-28,20620131815488797e-25,-9460496661855133e-25,21541049775774907e-26,-1388823336813903e-29,-21894761681963938e-27,9790998951171684e-27,-2178219188018096e-27,6208819573407901e-32,2126978363279737e-28,-9344688791517433e-29,2045367122678285e-29],[-.0008618882909167117,.0007840392217200666,-.0002990724803031902,-14638452578843418e-22,6641498215465122e-20,-3968365047179435e-20,11375726970678419e-21,2507497226237533e-25,-16954149536558305e-22,8907507532205309e-22,-2292934834000805e-22,2956794137544049e-26,28865829742708783e-24,-14189739437803219e-24,34463580499464896e-25,-23024517174528067e-29,-39409233028046403e-26,186023389685045e-24,-4356323005056618e-26,1278600101629623e-30,467927502665792e-26,-2149246470613483e-27,4908815614809652e-28,-633859148489156e-32,-5045332069080094e-29],[-.00033679855336635813,-6972813758365858e-20,.0002772753244959392,-.00019932570516188847,6797780477937208e-20,1419062920643967e-22,-13594048189768693e-21,8018470256334202e-21,-2291481176508095e-21,-3252473551298454e-25,34652846491085265e-23,-18447187191171344e-23,48240967037894184e-24,-17989466721743514e-30,-6306194500013523e-24,3162417628774568e-24,-7840924253697429e-25,5192679165254041e-30,9358944242306784e-26,-4513426216163278e-26,10799129993116828e-27,-3661886712685252e-32,-1210902069055155e-27,5680743584990564e-28,-13249659916340829e-29],[.0005313079364639922,-.0005921664373536939,.0002708782096718045,7902353232660328e-22,-8153969367561969e-20,561168275310625e-19,-18329116582843375e-21,-30796134506033047e-25,3465155368803609e-21,-20291327396058603e-22,5788792863149004e-22,2338630673826657e-28,-8828600746330484e-23,47435958880408125e-24,-12545415020710382e-24,8649648858010293e-29,16846058979264062e-25,-8575492823577594e-25,21598224929232125e-26,-7613230520476153e-31,-26639822008536144e-27,13065700536611057e-27,-31799163902367977e-28,4710976121367431e-33,36902800842763465e-29],[.00034436760689237765,5171790908260592e-20,-.00033493161081142234,.0002812695154763237,-.00010976582244684731,-12741009095484485e-23,27744451511563645e-21,-18263488805711332e-21,57876949497350525e-22,493875893393627e-24,-10595367014026043e-22,6166714376110408e-22,-17562973359060463e-23,-1297447328701544e-27,2695423606288966e-23,-14578352908731272e-24,3887645959386175e-24,-3881002251019412e-32,-5327994173877286e-25,27437977643314844e-26,-6995796092070568e-26,2589986387486848e-32,8856689099669639e-27,-4403168815871311e-27,10865561947091654e-28],[-.0006526239185953094,.0008394987206720873,-.000438297098541721,-6969091458420552e-22,.00016644846642067547,-.00012783517679769218,4629953263691304e-20,4557909867922708e-24,-10595271125805195e-21,6783342904865167e-21,-21075476666258803e-22,-17213731432817144e-27,3773587741611098e-22,-21867506700122867e-23,6220228804018927e-23,6597703826733e-28,-9590386497425686e-24,5213214492280807e-24,-13991589583935709e-25,5382058999060575e-31,19484714275467745e-26,-10127287556389682e-26,26077347197254926e-27,-5090418699993299e-33,-33721464474854593e-28],[-.0005967612901927463,-7204895416020011e-20,.0006782308837667328,-.0006401475260262758,.00027750107634328704,1819700838046515e-22,-8479507117068503e-20,6105192082501531e-20,-21073920183404862e-21,-8858589014125599e-25,45284535953805374e-22,-28427815022504407e-22,8708234177864641e-22,36886101871706966e-28,-1534469519070206e-22,8862466778790695e-23,-25184812301826817e-24,-10225912098215092e-30,3896947075815478e-24,-21267304792235634e-25,5737013552805138e-25,-1887749850169741e-34,-8093153869465787e-26,423827232834492e-25,-11002224534207727e-27],[.0013324454494800656,-.0019144384985654776,.0011089369134596636,99324041226423e-20,-.0005087450129309319,.00042735056665392886,-.000168588537679108,-81301893922785e-22,45284402370562144e-21,-3127053674781734e-20,1044986828530338e-20,48435226265680926e-27,-2148256587345626e-21,1329369701097492e-21,-4029569309210103e-22,-1756787766632329e-28,7014504316366825e-23,-4040787734999483e-23,11474026743371962e-24,39642746853563326e-34,-17804938269892715e-25,9748026254873165e-25,-26405338676507616e-26,5794875163403742e-33,3764774955354384e-26],[.001579727660730835,.00016251626278391583,-.0020633421035543276,.00213896861856891,-.0010108559391263003,-399127055299192e-21,.0003623502508476469,-.00028143901463712157,.00010449513336495887,212114184918303e-23,-25779417251947842e-21,17281818956040464e-21,-5641377387290428e-21,-11024320105776174e-27,11223224418895176e-22,-6869339637952674e-22,20653236975414888e-23,46714772409838506e-30,-35609886164949055e-24,20470855345905963e-24,-5809173863328336e-24,-1332821287582869e-31,9035460439133513e-25,-4959878251733084e-25,13481607129399748e-26],[-.004072512119514016,.00640336283380807,-.004041016108167662,-2183732802866233e-21,.002174044180125464,-.001970044051841889,.0008359546974796246,19445447567109655e-24,-.000257793871204217,.00019009987368139304,-6769649993743896e-20,-14440629666426571e-26,15712512518742267e-21,-10304008744776892e-21,3304517767401387e-21,7982976024232571e-28,-64097794149313e-20,38894624761300054e-23,-1161834764494887e-22,-2816808630596451e-30,19878012911297094e-24,-11407719956357511e-24,32355857064185554e-25,4175946829345594e-35,-5042311271810582e-25],[-.0059475779383993,-.0005401647678926045,.00879104135507679,-.009857631558785612,.005013469503102154,12807521786221875e-22,-.0020626019342754685,.0017109128573523059,-.000676953127141338,-6901154567656214e-24,.00018855128143995903,-.0001339521566349197,4626318303352804e-20,4003423061332135e-26,-10255652921494033e-21,6612086372797651e-21,-20913022027253007e-22,-20951775649603836e-29,3975602904199325e-22,-2395621197881589e-22,7118288338214586e-23,8925574873053455e-31,-12101547235064675e-24,6935061824833439e-24,-196614644538561e-23],[.01740202778752271,-.029527880945699123,.020045875571402798,70289515966903405e-22,-.012375421071343148,.011976293444235253,-.0054156038466518525,-6329089339641862e-23,.0018855118129005065,-.001473473274825001,.0005551581009770838,5240683441255066e-25,-.00014357913535784837,991812932249433e-19,-3346083474947831e-20,-3575583729109899e-27,71560851960630075e-22,-4551680262815553e-21,14236576649271474e-22,18803149082089665e-30,-2662340389892921e-22,15950642189595716e-23,-471875146738411e-22,-6510787295875518e-32,7979509102674624e-24],[.03024912416090589,.0024817436002649977,-.049939134373457025,.05991564300930787,-.03248320760162339,-5721296865210344e-21,.015085251778569354,-.013261324005088445,.0055515262632426145,3026318225703001e-23,-.0017229548406756724,.0012893570099929638,-.00046845138348319875,-1830259937893045e-25,.00011449739014822654,-7737856522124447e-20,25625836246985202e-21,10766165333192815e-28,-5324680928242262e-21,3349634863064464e-21,-10381253128684019e-22,-5608909920621128e-30,19150821930676592e-23,-11418365800203487e-23,33654425209171787e-24],[-.09905102088015905,.17954011706123485,-.12989606383463778,-31478872752284355e-21,.09051063527684813,-.0928288244111844,.04441211283987781,27779236316835886e-23,-.017229543805449696,.014182925050891573,-.005621416163374734,-239598509186381e-23,.0016029634366079909,-.0011606784674435774,.00041001337768153875,1836580075409066e-26,-958442565636559e-19,6364306233776471e-20,-2076250624489065e-20,-11806020912804483e-29,4213180823912065e-21,-2626224133701247e-21,8077062049493066e-22,6012591212363273e-31,-1472973737401884e-22],[-.19994542198219728,-.015056113040026424,.36470239469348487,-.4643519231173355,.26640934719197895,3403826602714719e-20,-.13784338709329624,.1276467178337056,-.056213828755200985,-1753150885483011e-22,.019235592956768112,-.015088821281095314,.005740185445135012,10622382710310225e-25,-.0015335082692563998,.0010819320643228215,-.0003737251019394566,-6617090972903199e-27,8426361738090962e-20,-5515070682748348e-20,1776953644834807e-20,3882792321020553e-29,-353513697488768e-20,2186583213004527e-21,-668128494476256e-21],[.7243860850402943,-1.3918010932653375,1.0654143352413967,.0001876173868950258,-.827055011761527,.8935243334782842,-.44971003995291337,-16107401567546651e-22,.1923559016527109,-.1659770216004261,.06888222268181433,13910091724608687e-24,-.02146911561508663,.016228980898865892,-.005979601617258426,-11287469112826745e-26,.0015167451119784856,-.00104786342935539,.0003553907288912642,8170432211180152e-28,-777730134424524e-19,5029141389700772e-20,-16035083867000518e-21,12469354315487606e-30,31369106244517616e-22],[1.6668949727276812,.1165462765994632,-3.3288393225018904,4.469232548286404,-2.6977693045875806,-.0002600667859891061,1.5389017615694538,-1.4937962361134611,.6888196463323315,13077482004552384e-22,-.2576296332559629,.21097676102125448,-.08371440835921988,-7792042888135476e-24,.0242679230648336,-.017813678334552312,.006397033038890006,4943080709048052e-26,-.0015554602758465635,.0010561196919903215,-.000352771844604729,9300233464502246e-29,7528585502655717e-20,-4818651556915635e-20,15227271505597605e-21],[-6.618829886137293,13.397985455142589,-10.789350606845145,-.0014352254537875018,9.23336945961898,-10.456552819547769,5.510552602903347,12024439690716742e-21,-2.5762961164755818,2.320744274538718,-1.0045728797216285,-10207833290021913e-23,.3397509217116947,-.2672051745075747,.10235252851562705,8432973048487163e-25,-.027998284958442594,.020066274144976814,-.007055436891508624,19402238183698188e-28,.0016562888105449611,-.0011082898580743682,.0003654545161310169,-5129003202697179e-26,-7634010369686903e-20],[-17.112706061976095,-1.1208044642899115,37.131966511885445,-52.29827102534896,33.058589696624615,.002479129897620022,-20.61089403411526,20.88672775145582,-10.045703956517752,-12238783449063012e-21,4.077013427422114,-3.473667358470195,1.4329352617312006,7135991441187971e-23,-.4479725715911561,.3411266608064446,-.12699786326594922,-2895367726908153e-25,.03312577627825986,-.023274087021036102,.008039999350364889,-1177805216235265e-24,-.001832162489107167,.0012108282933588664,-.0003947994124682252],[73.89033153567425,-156.80141270402274,132.2177542759164,.013692876877324546,-123.66496885920151,146.2068939106273,-80.36558772486535,-.00011259851148881298,40.77013219617994,-38.21034001327303,17.19522294277362,9351970795516835e-22,-6.271615990774704,5.116899907185264,-2.0319658112299095,-4950721558276154e-24,.596263972943326,-.44220765337238094,.16079998700166273,-24733786203223403e-24,-.040307574759979765,.02784905074709787,-.009475185899205422,6419922235909132e-21,.002125018077469946],[212.1683709838252,13.107863022633868,-496.9828593287175,731.215952669692,-482.1382172089085,-.028817248692894887,326.167203029471,-343.8934028008712,171.95193870816232,.00014038077378096157,-75.2594195897599,66.51969984520935,-28.447519748152462,-7613702615875392e-22,9.540223710530437,-7.517530111331138,2.894399756887196,-466121949995382e-21,-.8061514959879409,.5848300657063102,-.20845408972964957,.00014765818959305816,.05100043386375302,-.03306625214188366,.015109265210467774],[-989.5964309832236,2192.555536090523,-1928.3586782723355,-.15925738122215252,1956.9985945919857,-2407.2514765081555,1375.6149959336497,.0012920735237496668,-752.5941715948055,731.7166874220871,-341.37023466220063,-9985739026060805e-21,133.56313181291574,-112.76295161252794,46.31039609820446,-7923738713361476e-21,-14.510726927018647,11.111771248100563,-4.169081794527089,.0031008219800117806,1.1220095449981469,-.7605237992614992,.36262236505085255,.2216867741940747,.48683443692930506]];var b1=1e7,V6=20,W0=200,K6=.3,Z6=4.5,Z3=4503599627370496,T=2220446049250313e-31,$1=2**-1022;function V3(e,t,n){let o=J3(e,t);if(n)return u1(e,t,!0)+Math.log(o);let s=u1(e,t,!1);return s>=$1?s*o:Math.exp(u1(e,t,!0)+Math.log(o))}function K3(e,t){let n=J3(e,t),o=K0(e,t),s=o[0]+Math.log(n);return[s,o[1]>=$1?o[1]*n:Math.exp(s)]}function J3(e,t){if(e>1e3&&t>.97*e)return W6(e,t);let n=e,o=1,s=1;for(let r=0;r<b1&&(n+=1,o*=t/n,s+=o,!(o<=O*s));r++);return s}var J6=2**-64;function W6(e,t){let n=1,o=0,s=1,r=0;for(let i=1;i<b1;i++){let c=e+i,u=c-e,f=e-(c-u)+(i-u),l=t/c,a=134217729*l,h=a-(a-l),I=l-h;a=134217729*c;let S=a-(a-c),P=c-S,M=l*c,g=h*S-M+h*P+I*S+I*P,B=(t-M-g-l*f)/c;a=134217729*n;let X=a-(a-n),C=n-X,j=n*l,N=X*h-j+X*I+C*h+C*I+(n*B+o*l);n=j+N,o=N-(n-j);let _=s+n,A=_-s,L=s-(_-A)+(n-A)+(r+o);if(s=_+L,r=L-(s-_),n*l<=J6*s*(1-l))break}return s+r}function $6(e,t,n){let o=W3(e,t);if(n)return Math.log(e)+u1(e,t,!0)+Math.log(o);let s=u1(e,t,!1);return s>=$1?e*s*o:Math.exp(Math.log(e)+u1(e,t,!0)+Math.log(o))}function x6(e,t){let n=W3(e,t),o=K0(e,t),s=Math.log(e)+o[0]+Math.log(n);return[s,o[1]>=$1?e*o[1]*n:Math.exp(s)]}function W3(e,t){if(t>1e20)return o5(e,t);if(e<e5&&t<t5)return n5(e,t);let n=1-e,o=t+n+1,s=0,r=1,i=t,c=t+1,u=o*t,f=c/u;for(let l=0;l<b1;l++){s+=1,n+=1,o+=2;let a=n*s,h=c*o-r*a,I=u*o-i*a,S;if(I!==0){let P=h/I;S=Math.abs((f-P)/P),f=P}else S=1;if(r=c,c=h,i=u,u=I,Math.abs(h)>Z3&&(r*=T,c*=T,i*=T,u*=T),S<=O)break}return f}var e5=4,t5=64;function n5(e,t){let n=0,o=0,s=(N,_,A,L)=>{let F=N*A,y=134217729*N,H=y-(y-N),n1=N-H;y=134217729*A;let v=y-(y-A),z=A-v,G=H*v-F+H*z+n1*v+n1*z+(N*L+_*A);n=F+G,o=G-(n-F)},r=(N,_,A,L)=>{let F=N-A,y=F-N,H=N-(F-y)-(A+y)+(_-L);n=F+H,o=H-(n-F)},i=(N,_,A)=>{let L=N+A,F=L-N,y=N-(L-F)+(A-F)+_;n=L+y,o=y-(n-L)};r(1,0,e,0);let c=n,u=o;i(c,u,1),r(n,o,-t,0);let f=n,l=o,a=0,h=1,I=0,S=t,P=0;i(t,0,1);let M=n,g=o;s(f,l,t,0);let B=n,X=o,C=M/B,j=0;for(let N=0;N<b1;N++){a+=1,i(c,u,1),c=n,u=o,i(f,l,2),f=n,l=o,s(c,u,a,0);let _=n,A=o;s(M,g,f,l);let L=n,F=o;s(h,I,_,A),r(L,F,n,o);let y=n,H=o;s(B,X,f,l);let n1=n,v=o;s(S,P,_,A),r(n1,v,n,o);let z=n,G=o,o1=y/z;s(o1,0,z,G),r(y,H,n,o);let g1=(n+o)/z,W=o1+g1,N1=g1-(W-o1),E1=C-W+(j-N1);if(C=W,j=N1,h=M,I=g,M=y,g=H,S=B,P=X,B=z,X=G,Math.abs(M)>Z3&&(h*=T,I*=T,M*=T,g*=T,S*=T,P*=T,B*=T,X*=T),Math.abs(E1)<=2**-58*Math.abs(W))break}return C+j}function o5(e,t){let o=t+1-e,s=1/1e-300,r=1/o,i=r;for(let c=1;c<b1;c++){let u=-c*(c-e);o+=2,r=u*r+o,Math.abs(r)<1e-300&&(r=1e-300),s=o+u/s,Math.abs(s)<1e-300&&(s=1e-300),r=1/r;let f=r*s;if(i*=f,Math.abs(f-1)<=O)break}return i}function $3(e,t){let n=1,o=0;for(let c=1;c<b1;c++){n*=-t/c;let u=n/(e+c);if(o+=u,Math.abs(u)<=O*Math.abs(o))break}let s=Math.log(t),r=e*s-x(e);return-Math.expm1(r)-e*Math.exp(r)*o}function s5(e,t){let n=t/e,o=(t-e)/e;return n>1?Math.sqrt(-2*Z0(o)):n<1?-Math.sqrt(-2*Z0(o)):0}function r5(e,t){let n=new Array(25).fill(0);n[0]=1;let o=0,s=0,r=1,i=1/0;for(let c=0;c<25;c++){let u=Y3[c],f=u[0];for(let h=1;h<25;h++){h>o&&(n[h]=t*n[h-1],o+=1);let I=u[h]*n[h];if(f+=I,Math.abs(I)<O*Math.abs(f))break}let l=f*r,a=Math.abs(l);if(a>i||(s+=l,a<O*Math.abs(s)))break;i=a,r/=e}return s}function x3(e,t){return e>V6&&e<W0&&t<K6||e>W0&&t<Z6/Math.sqrt(e)}var e6=1e299,t6=(e,t)=>e>W0&&(t<.001||e>e6);function c5(e,t){let n=p1(e,[t,0]),o=t>e?1:-1,s=s5(e,t),r=e>e6&&Math.abs(s)>.1?1/((t-e)/e)-1/s:r5(e,s),i=.5*P3(Math.sqrt(n[0]+n[1]))+o*r/Math.sqrt(2*Math.PI*e);return[-n[0]-n[1]+Math.log(i),n[0]>2e3?0:Math.exp(-n[0])*(1-n[1])*i]}function n6(e,t,n){let[o,s]=c5(e,t);return t>e!==n?[o,s]:[Math.log1p(-s),1-s]}function J0(e,t,n){if(t>1.1)return t<e?{lower:!0,value:V3(e,t,n)}:{lower:!1,value:$6(e,t,n)};if(t<=.5?-.4/Math.log(t)<e:t*1.1<e)return{lower:!0,value:V3(e,t,n)};let s=$3(e,t);return{lower:!1,value:n?Math.log(s):s}}function i5(e,t){if(t>1.1){let[s,r]=t<e?K3(e,t):x6(e,t);return{lower:t<e,log:s,lin:r}}if(t<=.5?-.4/Math.log(t)<e:t*1.1<e){let[s,r]=K3(e,t);return{lower:!0,log:s,lin:r}}let o=$3(e,t);return{lower:!1,log:Math.log(o),lin:o}}var t1=1e-300;function u5(e,t,n){if(Number.isNaN(e)||Number.isNaN(t))return[NaN,NaN];if(t<0||e<0)return[NaN,NaN];if(e===0)return t>0?n?[0,1]:[-1/0,0]:[NaN,NaN];if(t===0)return n?[-1/0,0]:[0,1];if(e===1/0)return t===1/0?[NaN,NaN]:n?[-1/0,0]:[0,1];if(t===1/0)return n?[0,1]:[-1/0,0];if(t>1e15*Math.max(e,1)){let r=(e-1)*Math.log(t)-t-J(e)+Math.log1p((e-1)/t);return n?[Math.log1p(-Math.exp(r)),-Math.expm1(r)]:[r,Math.exp(r)]}if(!n&&e<t1){let[r,i]=u5(t1,t,!1);return[r+Math.log(e/t1),i*(e/t1)]}let o=Math.abs(t-e)/e;if(x3(e,o)||t6(e,o))return n6(e,t,n);let s=i5(e,t);return s.lower===n?[s.log,s.lin]:[s.lin>0?Math.log1p(-s.lin):-Math.exp(s.log),1-s.lin]}function f5(e,t,n,o){if(Number.isNaN(e)||Number.isNaN(t))return NaN;if(t<0||e<0)return NaN;let s=o?-1/0:0,r=o?0:1;if(e===0)return t>0?n?r:s:NaN;if(t===0)return n?s:r;if(e===1/0)return t===1/0?NaN:n?s:r;if(t===1/0)return n?r:s;if(t>1e15*Math.max(e,1)){let u=(e-1)*Math.log(t)-t-J(e)+Math.log1p((e-1)/t);return n?o?Math.log1p(-Math.exp(u)):-Math.expm1(u):o?u:Math.exp(u)}if(!n&&e<t1){let u=f5(t1,t,!1,o);return o?u+Math.log(e/t1):u*(e/t1)}let i=Math.abs(t-e)/e;if(x3(e,i)||t6(e,i))return n6(e,t,n)[o?0:1];if(o){let u=J0(e,t,!0);if(u.lower===n)return u.value;let f=J0(e,t,!1).value;return f>0?Math.log1p(-f):-Math.exp(u.value)}let c=J0(e,t,!1);return c.lower===n?c.value:1-c.value}export{O as a,C0 as b,q3 as c,e1 as d,V as e,J as f,x as g,q as h,p1 as i,C5 as j,O5 as k,B5 as l,u1 as m,Z0 as n,J3 as o,W6 as p,W3 as q,u5 as r,f5 as s,R3 as t,B0 as u,Q5 as v,V5 as w,U3 as x};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.13.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 R}from"./chunk-AH6IVJRF.js";var _=23283064365386963e-26,w=2328306437080797e-25,c=class{mt=new Uint32Array(624);mti=625;setSeed(t){let e=t>>>0;for(let n=0;n<50;n++)e=Math.imul(69069,e)+1>>>0;e=Math.imul(69069,e)+1>>>0;for(let n=0;n<624;n++)e=Math.imul(69069,e)+1>>>0,this.mt[n]=e;this.mti=624}sgenrand(t){for(let e=0;e<624;e++)this.mt[e]=t&4294901760,t=Math.imul(69069,t)+1>>>0,this.mt[e]=(this.mt[e]|(t&4294901760)>>>16)>>>0,t=Math.imul(69069,t)+1>>>0;this.mti=624}nextUint32(){let t=this.mt;if(this.mti>=624||this.mti===0){this.mti===625&&this.sgenrand(4357);let n=0,o;for(;n<227;n++)o=t[n]&2147483648|t[n+1]&2147483647,t[n]=t[n+397]^o>>>1^(o&1?2567483615:0);for(;n<623;n++)o=t[n]&2147483648|t[n+1]&2147483647,t[n]=t[n+-227]^o>>>1^(o&1?2567483615:0);o=t[623]&2147483648|t[0]&2147483647,t[623]=t[396]^o>>>1^(o&1?2567483615:0),this.mti=0}let e=t[this.mti++];return e^=e>>>11,e^=e<<7&2636928640,e^=e<<15&4022730752,e^=e>>>18,e>>>0}nextDouble(){let t=this.nextUint32()*_;return t<=0?.5*w:1-t<=0?1-.5*w:t}getRandomSeed(t){let e=new Int32Array(626);e[0]=t,e[1]=this.mti;for(let n=0;n<624;n++)e[n+2]=this.mt[n]|0;return e}setRandomSeed(t){if(t.length!==626)throw new RangeError("the random seed state must have 626 integers");let e=t[1];if(!Number.isInteger(e)||e<0||e>2**31-1)throw new RangeError("the position in the random seed state must be a non-negative 32-bit integer");for(let n=0;n<624;n++){let o=t[n+2];if(!Number.isInteger(o)||o<-(2**31)||o>=2**32)throw new RangeError("the random seed state must hold 32-bit integers")}this.mti=e;for(let n=0;n<624;n++)this.mt[n]=t[n+2]>>>0}};var v=2328306549295728e-25,x=r=>Math.imul(69069,r)+1>>>0,a=class{s=new Float64Array(6);setSeed(t){let e=t>>>0;for(let n=0;n<50;n++)e=x(e);for(let n=0;n<6;n++){do e=x(e);while(e>=4294944443);this.s[n]=e}}nextDouble(){let t=this.s,e=(1403580*t[1]-810728*t[0])%4294967087;e<0&&(e+=4294967087),t[0]=t[1],t[1]=t[2],t[2]=e;let n=(527612*t[5]-1370589*t[3])%4294944443;return n<0&&(n+=4294944443),t[3]=t[4],t[4]=t[5],t[5]=n,(e>n?e-n:e-n+4294967087)*v}};function N(r){if(r.length!==7)throw new RangeError("the random seed state of L'Ecuyer-CMRG must have 7 integers");let t=[];for(let e=1;e<=6;e++){let n=r[e];if(!Number.isInteger(n)||n<-2147483648||n>4294967295)throw new RangeError("the random seed state must hold 32-bit integers");t.push(n>>>0)}if(t[0]===0&&t[1]===0&&t[2]===0||t.slice(0,3).some(e=>e>=4294967087)||t.slice(3).some(e=>e>=4294944443))throw new RangeError("invalid L'Ecuyer-CMRG state: the first three seeds must be below 4294967087 and not all zero, the last three below 4294944443");return t}var L=[3.3871328727963665,133.14166789178438,1971.5909503065513,13731.69376550946,45921.95393154987,67265.7709270087,33430.57558358813,2509.0809287301227],T=[1,42.31333070160091,687.1870074920579,5394.196021424751,21213.794301586597,39307.89580009271,28729.085735721943,5226.495278852854],G=[1.4234371107496835,4.630337846156546,5.769497221460691,3.6478483247632045,1.2704582524523684,.2417807251774506,.022723844989269184,.0007745450142783414],D=[1,2.053191626637759,1.6763848301838038,.6897673349851,.14810397642748008,.015198666563616457,.0005475938084995345,10507500716444169e-25],P=[6.657904643501103,5.463784911164114,1.7848265399172913,.29656057182850487,.026532189526576124,.0012426609473880784,27115555687434876e-21,20103343992922881e-23],U=[1,.599832206555888,.1369298809227358,.014875361290850615,.0007868691311456133,18463183175100548e-21,1421511758316446e-22,20442631033899397e-31];function f(r,t){let e=r[7];for(let n=6;n>=0;n--)e=e*t+r[n];return e}function b(r){let t=r-.5;if(Math.abs(t)<=.425){let o=.180625-t*t;return t*f(L,o)/f(T,o)}let e=t<0?r:1-r;e=Math.sqrt(-Math.log(e));let n;return e<=5?(e-=1.6,n=f(G,e)/f(D,e)):(e-=5,n=f(P,e)/f(U,e)),t<0?-n:n}var j=["kind","sampleKind"],u=new c,i=u,l=!1,h=!1;function p(r){i.setSeed(r),h=!0}function Q(){return h}function M(){if(h)return;let r=(Date.now()^Math.floor(Math.random()*2**32))>>>0;typeof globalThis.crypto?.getRandomValues=="function"&&(r=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]),p(r)}function J(r){if(!Number.isFinite(r))throw new RangeError("seed must be a finite number");let t=Math.trunc(r);if(Math.abs(t)>2147483647)throw new RangeError("seed must be a 32-bit integer");p(t)}var O={default:!1,"Mersenne-Twister":!1,"L'Ecuyer-CMRG":!0},W={default:!1,Rejection:!1,Rounding:!0};function S(r,t,e){if(t===void 0)return;let n=r[t];if(typeof n!="boolean")throw new RangeError(`unsupported ${e} "${t}"`);return n}function Z(r={}){R(r,j,"RNGkind");let t={kind:i===u?"Mersenne-Twister":"L'Ecuyer-CMRG",normalKind:"Inversion",sampleKind:l?"Rounding":"Rejection"},e=S(O,r.kind,"RNG kind"),n=S(W,r.sampleKind,"sample kind");if((e!==void 0||n!==void 0)&&M(),e!==void 0){let o=Math.trunc(s()*4294967295);i=e?i===u?new a:i:u,p(o)}return n!==void 0&&(l=n),t}var y=()=>(i===u?3:7)+400+(l?0:1e4);function tt(){return M(),i===u?u.getRandomSeed(y()):Int32Array.of(y(),...i.s)}function et(r){let t=r[0],e=t%100;if(!Number.isInteger(t)||t<0||t>10407||e!==3&&e!==7||Math.floor(t/100)%100!==4)throw new RangeError(`unsupported RNG kind code ${String(t)} (supported: 10403, 403, 10407, 407)`);if(e===7){let n=new a;n.s.set(N(r)),i=n}else u.setRandomSeed(r),i=u;l=t<1e4,h=!0}function s(){return M(),i.nextDouble()}var nt=()=>l;function C(r){let t=2**Math.max(r-16,0),e=0;for(let n=0;n<=r;n+=16){let o=Math.floor(s()*65536);e=65536*(e%t)+o}return e%2**r}var E=33554432;function rt(r){if(l)return Math.floor(r*(r>2147483647?(Math.floor(E*s())+s())/E:s()));if(r<=0)return 0;let t=Math.ceil(Math.log2(r)),e;do e=C(t);while(r<=e);return e}var A=134217728;function ot(){let r=s();return r=Math.trunc(A*r)+s(),b(r/A)}var d=(()=>{let r=[],t=1,e=0;for(let n=1;n<=16;n++)t*=Math.LN2/n,e+=t,r.push(e);return r})();function it(){let r=0,t=s();for(;t<=0||t>=1;)t=s();for(;t+=t,!(t>1);)r+=d[0];if(t-=1,t<=d[0])return r+t;let e=0,n=s(),o=n;do n=s(),o>n&&(o=n),e++;while(t>d[e]);return r+o*d[0]}var I="@numero-uno-jpn/rstats.warningHandler";function K(){return globalThis[Symbol.for(I)]??null}function ut(r){if(r!==null&&typeof r!="function")throw new TypeError("handler must be a function or null");let t=K();return globalThis[Symbol.for(I)]=r,t}var g=0;function H(r,t){if(g>0||t.length===0)return;let e=K();if(e!==null)for(let n of new Set(t))e(n,r)}function ft(r,t,...e){let n=new Set(e.flatMap(o=>X(o)));return H(r,(t.warnings??[]).filter(o=>!n.has(o))),t}function X(r){let t=typeof r=="object"&&r!==null?r.warnings:void 0;return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function lt(r){g++;try{return r()}finally{g--}}var k=class{list=[];add(t){this.list.includes(t)||this.list.push(t)}},m;function at(r,t){let e=m;m=r;try{return t()}finally{m=e}}function ct(r){m?.add(r)}export{N as a,Q as b,J as c,Z as d,tt as e,et as f,s as g,nt as h,rt as i,ot as j,it as k,ut as l,H as m,ft as n,lt as o,k as p,at as q,ct as r};
1
+ /*! rStats.js 1.14.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 R}from"./chunk-TGXUU5NB.js";var _=23283064365386963e-26,w=2328306437080797e-25,c=class{mt=new Uint32Array(624);mti=625;setSeed(t){let e=t>>>0;for(let n=0;n<50;n++)e=Math.imul(69069,e)+1>>>0;e=Math.imul(69069,e)+1>>>0;for(let n=0;n<624;n++)e=Math.imul(69069,e)+1>>>0,this.mt[n]=e;this.mti=624}sgenrand(t){for(let e=0;e<624;e++)this.mt[e]=t&4294901760,t=Math.imul(69069,t)+1>>>0,this.mt[e]=(this.mt[e]|(t&4294901760)>>>16)>>>0,t=Math.imul(69069,t)+1>>>0;this.mti=624}nextUint32(){let t=this.mt;if(this.mti>=624||this.mti===0){this.mti===625&&this.sgenrand(4357);let n=0,o;for(;n<227;n++)o=t[n]&2147483648|t[n+1]&2147483647,t[n]=t[n+397]^o>>>1^(o&1?2567483615:0);for(;n<623;n++)o=t[n]&2147483648|t[n+1]&2147483647,t[n]=t[n+-227]^o>>>1^(o&1?2567483615:0);o=t[623]&2147483648|t[0]&2147483647,t[623]=t[396]^o>>>1^(o&1?2567483615:0),this.mti=0}let e=t[this.mti++];return e^=e>>>11,e^=e<<7&2636928640,e^=e<<15&4022730752,e^=e>>>18,e>>>0}nextDouble(){let t=this.nextUint32()*_;return t<=0?.5*w:1-t<=0?1-.5*w:t}getRandomSeed(t){let e=new Int32Array(626);e[0]=t,e[1]=this.mti;for(let n=0;n<624;n++)e[n+2]=this.mt[n]|0;return e}setRandomSeed(t){if(t.length!==626)throw new RangeError("the random seed state must have 626 integers");let e=t[1];if(!Number.isInteger(e)||e<0||e>2**31-1)throw new RangeError("the position in the random seed state must be a non-negative 32-bit integer");for(let n=0;n<624;n++){let o=t[n+2];if(!Number.isInteger(o)||o<-(2**31)||o>=2**32)throw new RangeError("the random seed state must hold 32-bit integers")}this.mti=e;for(let n=0;n<624;n++)this.mt[n]=t[n+2]>>>0}};var v=2328306549295728e-25,x=r=>Math.imul(69069,r)+1>>>0,a=class{s=new Float64Array(6);setSeed(t){let e=t>>>0;for(let n=0;n<50;n++)e=x(e);for(let n=0;n<6;n++){do e=x(e);while(e>=4294944443);this.s[n]=e}}nextDouble(){let t=this.s,e=(1403580*t[1]-810728*t[0])%4294967087;e<0&&(e+=4294967087),t[0]=t[1],t[1]=t[2],t[2]=e;let n=(527612*t[5]-1370589*t[3])%4294944443;return n<0&&(n+=4294944443),t[3]=t[4],t[4]=t[5],t[5]=n,(e>n?e-n:e-n+4294967087)*v}};function N(r){if(r.length!==7)throw new RangeError("the random seed state of L'Ecuyer-CMRG must have 7 integers");let t=[];for(let e=1;e<=6;e++){let n=r[e];if(!Number.isInteger(n)||n<-2147483648||n>4294967295)throw new RangeError("the random seed state must hold 32-bit integers");t.push(n>>>0)}if(t[0]===0&&t[1]===0&&t[2]===0||t.slice(0,3).some(e=>e>=4294967087)||t.slice(3).some(e=>e>=4294944443))throw new RangeError("invalid L'Ecuyer-CMRG state: the first three seeds must be below 4294967087 and not all zero, the last three below 4294944443");return t}var L=[3.3871328727963665,133.14166789178438,1971.5909503065513,13731.69376550946,45921.95393154987,67265.7709270087,33430.57558358813,2509.0809287301227],T=[1,42.31333070160091,687.1870074920579,5394.196021424751,21213.794301586597,39307.89580009271,28729.085735721943,5226.495278852854],G=[1.4234371107496835,4.630337846156546,5.769497221460691,3.6478483247632045,1.2704582524523684,.2417807251774506,.022723844989269184,.0007745450142783414],D=[1,2.053191626637759,1.6763848301838038,.6897673349851,.14810397642748008,.015198666563616457,.0005475938084995345,10507500716444169e-25],P=[6.657904643501103,5.463784911164114,1.7848265399172913,.29656057182850487,.026532189526576124,.0012426609473880784,27115555687434876e-21,20103343992922881e-23],U=[1,.599832206555888,.1369298809227358,.014875361290850615,.0007868691311456133,18463183175100548e-21,1421511758316446e-22,20442631033899397e-31];function f(r,t){let e=r[7];for(let n=6;n>=0;n--)e=e*t+r[n];return e}function b(r){let t=r-.5;if(Math.abs(t)<=.425){let o=.180625-t*t;return t*f(L,o)/f(T,o)}let e=t<0?r:1-r;e=Math.sqrt(-Math.log(e));let n;return e<=5?(e-=1.6,n=f(G,e)/f(D,e)):(e-=5,n=f(P,e)/f(U,e)),t<0?-n:n}var j=["kind","sampleKind"],u=new c,i=u,l=!1,h=!1;function p(r){i.setSeed(r),h=!0}function Q(){return h}function M(){if(h)return;let r=(Date.now()^Math.floor(Math.random()*2**32))>>>0;typeof globalThis.crypto?.getRandomValues=="function"&&(r=globalThis.crypto.getRandomValues(new Uint32Array(1))[0]),p(r)}function J(r){if(!Number.isFinite(r))throw new RangeError("seed must be a finite number");let t=Math.trunc(r);if(Math.abs(t)>2147483647)throw new RangeError("seed must be a 32-bit integer");p(t)}var O={default:!1,"Mersenne-Twister":!1,"L'Ecuyer-CMRG":!0},W={default:!1,Rejection:!1,Rounding:!0};function S(r,t,e){if(t===void 0)return;let n=r[t];if(typeof n!="boolean")throw new RangeError(`unsupported ${e} "${t}"`);return n}function Z(r={}){R(r,j,"RNGkind");let t={kind:i===u?"Mersenne-Twister":"L'Ecuyer-CMRG",normalKind:"Inversion",sampleKind:l?"Rounding":"Rejection"},e=S(O,r.kind,"RNG kind"),n=S(W,r.sampleKind,"sample kind");if((e!==void 0||n!==void 0)&&M(),e!==void 0){let o=Math.trunc(s()*4294967295);i=e?i===u?new a:i:u,p(o)}return n!==void 0&&(l=n),t}var y=()=>(i===u?3:7)+400+(l?0:1e4);function tt(){return M(),i===u?u.getRandomSeed(y()):Int32Array.of(y(),...i.s)}function et(r){let t=r[0],e=t%100;if(!Number.isInteger(t)||t<0||t>10407||e!==3&&e!==7||Math.floor(t/100)%100!==4)throw new RangeError(`unsupported RNG kind code ${String(t)} (supported: 10403, 403, 10407, 407)`);if(e===7){let n=new a;n.s.set(N(r)),i=n}else u.setRandomSeed(r),i=u;l=t<1e4,h=!0}function s(){return M(),i.nextDouble()}var nt=()=>l;function C(r){let t=2**Math.max(r-16,0),e=0;for(let n=0;n<=r;n+=16){let o=Math.floor(s()*65536);e=65536*(e%t)+o}return e%2**r}var E=33554432;function rt(r){if(l)return Math.floor(r*(r>2147483647?(Math.floor(E*s())+s())/E:s()));if(r<=0)return 0;let t=Math.ceil(Math.log2(r)),e;do e=C(t);while(r<=e);return e}var A=134217728;function ot(){let r=s();return r=Math.trunc(A*r)+s(),b(r/A)}var d=(()=>{let r=[],t=1,e=0;for(let n=1;n<=16;n++)t*=Math.LN2/n,e+=t,r.push(e);return r})();function it(){let r=0,t=s();for(;t<=0||t>=1;)t=s();for(;t+=t,!(t>1);)r+=d[0];if(t-=1,t<=d[0])return r+t;let e=0,n=s(),o=n;do n=s(),o>n&&(o=n),e++;while(t>d[e]);return r+o*d[0]}var I="@numero-uno-jpn/rstats.warningHandler";function K(){return globalThis[Symbol.for(I)]??null}function ut(r){if(r!==null&&typeof r!="function")throw new TypeError("handler must be a function or null");let t=K();return globalThis[Symbol.for(I)]=r,t}var g=0;function H(r,t){if(g>0||t.length===0)return;let e=K();if(e!==null)for(let n of new Set(t))e(n,r)}function ft(r,t,...e){let n=new Set(e.flatMap(o=>X(o)));return H(r,(t.warnings??[]).filter(o=>!n.has(o))),t}function X(r){let t=typeof r=="object"&&r!==null?r.warnings:void 0;return Array.isArray(t)?t.filter(e=>typeof e=="string"):[]}function lt(r){g++;try{return r()}finally{g--}}var k=class{list=[];add(t){this.list.includes(t)||this.list.push(t)}},m;function at(r,t){let e=m;m=r;try{return t()}finally{m=e}}function ct(r){m?.add(r)}export{N as a,Q as b,J as c,Z as d,tt as e,et as f,s as g,nt as h,rt as i,ot as j,it as k,ut as l,H as m,ft as n,lt as o,k as p,at as q,ct as r};
@@ -1,2 +1,2 @@
1
- /*! rStats.js 1.13.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{d as b}from"./chunk-UMLJFZJ5.js";import{f as a,h as f,k as l,l as c,m as g,q as m}from"./chunk-P2UT6OCU.js";import{l as s}from"./chunk-AH6IVJRF.js";var d=["location","scale","log"],x=["location","scale","lowerTail","logP"],M=["location","scale","lowerTail","logP"],p=2**-1022;function h(r,o,t,N){if(Number.isNaN(r)||Number.isNaN(o)||Number.isNaN(t))return NaN;if(!(t>0))return NaN;let e=f(r,o,t);if(Number.isNaN(e[0]))return NaN;let n=e[0]<0?[-e[0],-e[1]]:[e[0],e[1]],i=l(n);if(N)return-n[0]-n[1]-Math.log(t)-2*Math.log1p(i);if(i<p)return c(n,t);let u=t*(1+i)*(1+i);return t>=p&&u<1/0?i/u:i/((1+i)*(1+i))/t}function I(r,o,t,N,e){if(Number.isNaN(r)||Number.isNaN(o)||Number.isNaN(t))return NaN;if(!(t>0))return NaN;let n=f(r,o,t);if(Number.isNaN(n[0]))return NaN;let i=n[0]<0?[-n[0],-n[1]]:[n[0],n[1]],u=l(i);return N===n[0]>=0?e?-Math.log1p(u):1/(1+u):e?-i[0]-i[1]-Math.log1p(u):u/(1+u)}function S(r,o){return o?r-g(r):r<.25?Math.log(r/(1-r)):Math.log1p((2*r-1)/(1-r))}function O(r,o,t,N,e){if(Number.isNaN(r)||Number.isNaN(o)||Number.isNaN(t))return NaN;let n=b(r,-1/0,1/0,N,e);if(n!==void 0)return n;if(t<0)return NaN;if(t===0)return o;let i=S(r,e);return m(o,t,N?i:-i)}function w(r,o={}){s(o,d,"dlogis");let{location:t=0,scale:N=1,log:e=!1}=o;return a(r,n=>h(n,t,N,e))}function y(r,o={}){s(o,x,"plogis");let{location:t=0,scale:N=1,lowerTail:e=!0,logP:n=!1}=o;return a(r,i=>I(i,t,N,e,n))}function D(r,o={}){s(o,M,"qlogis");let{location:t=0,scale:N=1,lowerTail:e=!0,logP:n=!1}=o;return a(r,i=>O(i,t,N,e,n))}export{h as a,I as b,w as c,y as d,D as e};
1
+ /*! rStats.js 1.14.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{d as b}from"./chunk-EDRBKZ3C.js";import{f as a,h as f,k as l,l as c,m as g,q as m}from"./chunk-ZJJJDLRL.js";import{l as s}from"./chunk-TGXUU5NB.js";var d=["location","scale","log"],x=["location","scale","lowerTail","logP"],M=["location","scale","lowerTail","logP"],p=2**-1022;function h(r,o,t,N){if(Number.isNaN(r)||Number.isNaN(o)||Number.isNaN(t))return NaN;if(!(t>0))return NaN;let e=f(r,o,t);if(Number.isNaN(e[0]))return NaN;let n=e[0]<0?[-e[0],-e[1]]:[e[0],e[1]],i=l(n);if(N)return-n[0]-n[1]-Math.log(t)-2*Math.log1p(i);if(i<p)return c(n,t);let u=t*(1+i)*(1+i);return t>=p&&u<1/0?i/u:i/((1+i)*(1+i))/t}function I(r,o,t,N,e){if(Number.isNaN(r)||Number.isNaN(o)||Number.isNaN(t))return NaN;if(!(t>0))return NaN;let n=f(r,o,t);if(Number.isNaN(n[0]))return NaN;let i=n[0]<0?[-n[0],-n[1]]:[n[0],n[1]],u=l(i);return N===n[0]>=0?e?-Math.log1p(u):1/(1+u):e?-i[0]-i[1]-Math.log1p(u):u/(1+u)}function S(r,o){return o?r-g(r):r<.25?Math.log(r/(1-r)):Math.log1p((2*r-1)/(1-r))}function O(r,o,t,N,e){if(Number.isNaN(r)||Number.isNaN(o)||Number.isNaN(t))return NaN;let n=b(r,-1/0,1/0,N,e);if(n!==void 0)return n;if(t<0)return NaN;if(t===0)return o;let i=S(r,e);return m(o,t,N?i:-i)}function w(r,o={}){s(o,d,"dlogis");let{location:t=0,scale:N=1,log:e=!1}=o;return a(r,n=>h(n,t,N,e))}function y(r,o={}){s(o,x,"plogis");let{location:t=0,scale:N=1,lowerTail:e=!0,logP:n=!1}=o;return a(r,i=>I(i,t,N,e,n))}function D(r,o={}){s(o,M,"qlogis");let{location:t=0,scale:N=1,lowerTail:e=!0,logP:n=!1}=o;return a(r,i=>O(i,t,N,e,n))}export{h as a,I as b,w as c,y as d,D as e};