@numero-uno-jpn/rstats 0.15.2 → 0.16.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 (297) hide show
  1. package/CHANGELOG.md +280 -0
  2. package/README.ja.md +40 -33
  3. package/README.md +36 -28
  4. package/dist/chunks/chunk-2D2IQWUQ.js +2 -0
  5. package/dist/chunks/chunk-5UQCRBAG.js +2 -0
  6. package/dist/chunks/chunk-6CSTWA5E.js +2 -0
  7. package/dist/chunks/chunk-72Y3HZID.js +2 -0
  8. package/dist/chunks/chunk-BG2KLEHM.js +2 -0
  9. package/dist/chunks/chunk-CMEKBNHQ.js +2 -0
  10. package/dist/chunks/chunk-FLJNSXSW.js +2 -0
  11. package/dist/chunks/chunk-GM53LWSR.js +2 -0
  12. package/dist/chunks/chunk-JBCA56ZS.js +3 -0
  13. package/dist/chunks/chunk-K3RJAD2T.js +2 -0
  14. package/dist/chunks/chunk-KAZRWIB5.js +2 -0
  15. package/dist/chunks/chunk-KBVVIMXX.js +3 -0
  16. package/dist/chunks/chunk-N3SIFCZX.js +2 -0
  17. package/dist/chunks/chunk-QNNL7AZ3.js +2 -0
  18. package/dist/chunks/chunk-SC6CV4Z3.js +2 -0
  19. package/dist/chunks/chunk-SYWOBOTR.js +2 -0
  20. package/dist/chunks/chunk-URIO5LY5.js +2 -0
  21. package/dist/chunks/chunk-VTUGG2SV.js +2 -0
  22. package/dist/chunks/chunk-W26LRYOJ.js +2 -0
  23. package/dist/chunks/chunk-XHETEYVC.js +2 -0
  24. package/dist/chunks/{chunk-PWVQVJTP.js → chunk-YRZWONZB.js} +1 -1
  25. package/dist/chunks/chunk-ZGABZMWX.js +2 -0
  26. package/dist/data/grouping.js +20 -5
  27. package/dist/descriptive/basic.js +90 -8
  28. package/dist/descriptive/cov.js +12 -4
  29. package/dist/descriptive/dataFrames.d.ts +4 -2
  30. package/dist/descriptive/dataFrames.js +56 -18
  31. package/dist/descriptive/factanal.js +16 -7
  32. package/dist/descriptive/hist.d.ts +8 -5
  33. package/dist/descriptive/hist.js +71 -31
  34. package/dist/descriptive/missing.js +3 -1
  35. package/dist/descriptive/moments.js +72 -19
  36. package/dist/descriptive/omega.d.ts +1 -1
  37. package/dist/descriptive/omega.js +68 -9
  38. package/dist/descriptive/pivot.d.ts +21 -9
  39. package/dist/descriptive/pivot.js +161 -35
  40. package/dist/descriptive/quantile.js +2 -1
  41. package/dist/descriptive/rank.js +4 -1
  42. package/dist/descriptive/table.d.ts +3 -2
  43. package/dist/descriptive/table.js +24 -9
  44. package/dist/descriptive.js +2 -2
  45. package/dist/distributions/arcsine.js +19 -2
  46. package/dist/distributions/beta.js +35 -5
  47. package/dist/distributions/binomial.js +37 -14
  48. package/dist/distributions/bvnorm.js +11 -2
  49. package/dist/distributions/cauchy.js +87 -8
  50. package/dist/distributions/chisq.js +7 -3
  51. package/dist/distributions/exponential.js +11 -1
  52. package/dist/distributions/f.js +73 -22
  53. package/dist/distributions/gamma.js +61 -6
  54. package/dist/distributions/geometric.js +53 -14
  55. package/dist/distributions/hypergeometric.d.ts +5 -1
  56. package/dist/distributions/hypergeometric.js +93 -6
  57. package/dist/distributions/invgamma.js +6 -1
  58. package/dist/distributions/kumaraswamy.js +22 -4
  59. package/dist/distributions/laplace.js +31 -7
  60. package/dist/distributions/logistic.js +11 -2
  61. package/dist/distributions/lognormal.js +20 -3
  62. package/dist/distributions/multinomial.js +54 -11
  63. package/dist/distributions/nbeta.js +128 -35
  64. package/dist/distributions/nchisq.js +85 -14
  65. package/dist/distributions/negbinomial.js +100 -18
  66. package/dist/distributions/normal.js +35 -5
  67. package/dist/distributions/nt.d.ts +28 -3
  68. package/dist/distributions/nt.js +536 -35
  69. package/dist/distributions/pareto.js +9 -1
  70. package/dist/distributions/poisson.js +28 -3
  71. package/dist/distributions/signrank.js +7 -4
  72. package/dist/distributions/summary.js +450 -60
  73. package/dist/distributions/t.js +55 -3
  74. package/dist/distributions/triangular.js +45 -13
  75. package/dist/distributions/tukey.js +21 -2
  76. package/dist/distributions/uniform.js +2 -0
  77. package/dist/distributions/weibull.js +33 -3
  78. package/dist/distributions/wilcox.d.ts +9 -3
  79. package/dist/distributions/wilcox.js +155 -26
  80. package/dist/distributions.js +2 -2
  81. package/dist/htest/agreement.d.ts +3 -2
  82. package/dist/htest/agreement.js +76 -14
  83. package/dist/htest/ansariTest.d.ts +6 -1
  84. package/dist/htest/ansariTest.js +75 -8
  85. package/dist/htest/aov.d.ts +1 -1
  86. package/dist/htest/aov.js +48 -34
  87. package/dist/htest/binomTest.d.ts +5 -0
  88. package/dist/htest/binomTest.js +41 -17
  89. package/dist/htest/brunnerMunzelTest.d.ts +4 -3
  90. package/dist/htest/brunnerMunzelTest.js +7 -5
  91. package/dist/htest/chisqTest.d.ts +2 -1
  92. package/dist/htest/chisqTest.js +130 -43
  93. package/dist/htest/cor.d.ts +2 -1
  94. package/dist/htest/cor.js +17 -19
  95. package/dist/htest/core/ansari.d.ts +9 -0
  96. package/dist/htest/core/ansari.js +21 -1
  97. package/dist/htest/core/kolmogorov.d.ts +25 -0
  98. package/dist/htest/core/kolmogorov.js +123 -0
  99. package/dist/htest/core/mantelhaen.js +6 -4
  100. package/dist/htest/core/shapiro.d.ts +1 -1
  101. package/dist/htest/core/shapiro.js +5 -1
  102. package/dist/htest/dunnett.js +14 -5
  103. package/dist/htest/effectSize.d.ts +2 -0
  104. package/dist/htest/effectSize.js +91 -29
  105. package/dist/htest/fisherTest.d.ts +2 -2
  106. package/dist/htest/fisherTest.js +36 -18
  107. package/dist/htest/groups.d.ts +7 -0
  108. package/dist/htest/groups.js +21 -4
  109. package/dist/htest/ksTest.d.ts +3 -1
  110. package/dist/htest/ksTest.js +23 -2
  111. package/dist/htest/leveneTest.js +19 -3
  112. package/dist/htest/mantelhaenTest.js +125 -25
  113. package/dist/htest/mcnemarTest.js +32 -11
  114. package/dist/htest/multipleComparisons.d.ts +8 -1
  115. package/dist/htest/multipleComparisons.js +44 -21
  116. package/dist/htest/normalityTests.js +44 -10
  117. package/dist/htest/onewayTest.js +96 -5
  118. package/dist/htest/pAdjust.d.ts +3 -2
  119. package/dist/htest/pAdjust.js +38 -6
  120. package/dist/htest/pairwise.d.ts +1 -1
  121. package/dist/htest/pairwise.js +17 -15
  122. package/dist/htest/poissonTest.d.ts +1 -1
  123. package/dist/htest/poissonTest.js +111 -59
  124. package/dist/htest/polycor.js +27 -7
  125. package/dist/htest/power.d.ts +11 -1
  126. package/dist/htest/power.js +112 -8
  127. package/dist/htest/propTest.js +21 -4
  128. package/dist/htest/pwr.js +121 -24
  129. package/dist/htest/rankTests.js +29 -5
  130. package/dist/htest/tTest.js +44 -21
  131. package/dist/htest/trendTests.d.ts +7 -3
  132. package/dist/htest/trendTests.js +114 -20
  133. package/dist/htest/types.d.ts +5 -0
  134. package/dist/htest/types.js +7 -0
  135. package/dist/htest/varTest.js +45 -14
  136. package/dist/htest/wilcoxTest.js +114 -21
  137. package/dist/integrate/quadpack.js +27 -5
  138. package/dist/internal/covmat.d.ts +5 -0
  139. package/dist/internal/covmat.js +20 -0
  140. package/dist/internal/ddexp.d.ts +23 -1
  141. package/dist/internal/ddexp.js +86 -6
  142. package/dist/internal/discrete.d.ts +14 -0
  143. package/dist/internal/discrete.js +78 -5
  144. package/dist/internal/extremes.d.ts +9 -0
  145. package/dist/internal/extremes.js +24 -0
  146. package/dist/internal/fround.js +13 -4
  147. package/dist/internal/integer.d.ts +9 -0
  148. package/dist/internal/integer.js +12 -0
  149. package/dist/internal/invert.d.ts +5 -0
  150. package/dist/internal/invert.js +25 -7
  151. package/dist/internal/noncentral.d.ts +7 -0
  152. package/dist/internal/noncentral.js +9 -0
  153. package/dist/internal/poissonMixture.js +29 -6
  154. package/dist/internal/scaledInverse.d.ts +10 -0
  155. package/dist/internal/scaledInverse.js +22 -0
  156. package/dist/internal/seq.js +15 -2
  157. package/dist/internal/summary.d.ts +90 -0
  158. package/dist/internal/summary.js +458 -39
  159. package/dist/internal/uniroot.d.ts +7 -0
  160. package/dist/internal/uniroot.js +28 -3
  161. package/dist/linalg/basic.d.ts +3 -1
  162. package/dist/linalg/basic.js +51 -7
  163. package/dist/linalg/chol.js +4 -1
  164. package/dist/linalg/dot.d.ts +29 -0
  165. package/dist/linalg/dot.js +132 -0
  166. package/dist/linalg/eigen.d.ts +6 -1
  167. package/dist/linalg/eigen.js +71 -14
  168. package/dist/linalg/expm.d.ts +3 -2
  169. package/dist/linalg/expm.js +109 -15
  170. package/dist/linalg/kappa.js +58 -10
  171. package/dist/linalg/lu.d.ts +2 -1
  172. package/dist/linalg/lu.js +35 -5
  173. package/dist/linalg/matrix.d.ts +14 -0
  174. package/dist/linalg/matrix.js +24 -0
  175. package/dist/linalg/ops.js +60 -13
  176. package/dist/linalg/qr.d.ts +2 -1
  177. package/dist/linalg/qr.js +91 -23
  178. package/dist/linalg/schur.js +11 -3
  179. package/dist/linalg/solve.d.ts +6 -1
  180. package/dist/linalg/solve.js +147 -26
  181. package/dist/linalg/svd.d.ts +9 -2
  182. package/dist/linalg/svd.js +29 -11
  183. package/dist/linalg.js +2 -2
  184. package/dist/mixed.js +4 -4
  185. package/dist/models/anovaSequential.d.ts +16 -1
  186. package/dist/models/anovaSequential.js +124 -25
  187. package/dist/models/aovEz.js +140 -30
  188. package/dist/models/aovStrata.js +55 -22
  189. package/dist/models/carAnova.d.ts +1 -1
  190. package/dist/models/carAnova.js +83 -32
  191. package/dist/models/coxph.js +148 -66
  192. package/dist/models/estimable.d.ts +15 -0
  193. package/dist/models/estimable.js +68 -0
  194. package/dist/models/formula.d.ts +1 -1
  195. package/dist/models/formula.js +26 -8
  196. package/dist/models/glm.d.ts +35 -5
  197. package/dist/models/glm.js +398 -55
  198. package/dist/models/glmAnova.js +84 -13
  199. package/dist/models/glmConfint.d.ts +1 -1
  200. package/dist/models/glmConfint.js +115 -27
  201. package/dist/models/glmFamily.d.ts +10 -0
  202. package/dist/models/glmFamily.js +244 -40
  203. package/dist/models/lm.d.ts +12 -1
  204. package/dist/models/lm.js +235 -36
  205. package/dist/models/lmer.d.ts +20 -1
  206. package/dist/models/lmer.js +109 -27
  207. package/dist/models/lmerAnova.js +37 -4
  208. package/dist/models/lmerHypotheses.d.ts +6 -2
  209. package/dist/models/lmerHypotheses.js +14 -2
  210. package/dist/models/lmerTest.d.ts +9 -2
  211. package/dist/models/lmerTest.js +64 -19
  212. package/dist/models/mauchly.d.ts +4 -1
  213. package/dist/models/mauchly.js +34 -13
  214. package/dist/models/mixedStructure.js +6 -0
  215. package/dist/models/modelFrame.js +8 -2
  216. package/dist/models/modelMatrix.d.ts +3 -1
  217. package/dist/models/modelMatrix.js +40 -15
  218. package/dist/models/scaledTables.d.ts +8 -0
  219. package/dist/models/scaledTables.js +6 -0
  220. package/dist/models/survival.d.ts +6 -1
  221. package/dist/models/survival.js +67 -27
  222. package/dist/models/tiedTimes.d.ts +2 -0
  223. package/dist/models/tiedTimes.js +34 -0
  224. package/dist/numerics/deriv.d.ts +1 -1
  225. package/dist/numerics/deriv.js +64 -8
  226. package/dist/numerics/integrate.d.ts +9 -1
  227. package/dist/numerics/integrate.js +103 -16
  228. package/dist/numerics/interp.d.ts +8 -2
  229. package/dist/numerics/interp.js +352 -50
  230. package/dist/numerics/ode.js +55 -1
  231. package/dist/numerics.js +2 -2
  232. package/dist/optim/localmin.js +4 -0
  233. package/dist/optim/optim.d.ts +3 -1
  234. package/dist/optim/optim.js +80 -8
  235. package/dist/random/beta.js +53 -4
  236. package/dist/random/binomial.d.ts +14 -3
  237. package/dist/random/binomial.js +59 -24
  238. package/dist/random/continuous.js +33 -5
  239. package/dist/random/extra.js +42 -9
  240. package/dist/random/gamma.d.ts +4 -1
  241. package/dist/random/gamma.js +36 -8
  242. package/dist/random/hyper.js +9 -6
  243. package/dist/random/mt.js +17 -2
  244. package/dist/random/poisson.js +26 -3
  245. package/dist/random/r2dtable.d.ts +8 -1
  246. package/dist/random/r2dtable.js +24 -3
  247. package/dist/random/rank.d.ts +2 -0
  248. package/dist/random/rank.js +44 -4
  249. package/dist/random/sample.d.ts +12 -2
  250. package/dist/random/sample.js +57 -20
  251. package/dist/random/streams.js +4 -2
  252. package/dist/rstats.js +14 -14
  253. package/dist/special/besselIK.d.ts +12 -0
  254. package/dist/special/besselIK.js +168 -23
  255. package/dist/special/besselJY.d.ts +11 -1
  256. package/dist/special/besselJY.js +127 -19
  257. package/dist/special/besselSeries.d.ts +27 -0
  258. package/dist/special/besselSeries.js +45 -2
  259. package/dist/special/beta.js +11 -1
  260. package/dist/special/choose.js +17 -8
  261. package/dist/special/dd.js +122 -18
  262. package/dist/special/extra.js +14 -2
  263. package/dist/special/gamma.js +15 -2
  264. package/dist/special/igam.js +33 -6
  265. package/dist/special/incbet.js +100 -10
  266. package/dist/special/incbetLargeA.js +7 -2
  267. package/dist/special/incbetPrefactor.d.ts +5 -0
  268. package/dist/special/incbetPrefactor.js +14 -3
  269. package/dist/special/incbetTemme.d.ts +7 -0
  270. package/dist/special/incbetTemme.js +45 -12
  271. package/dist/special/loader.d.ts +1 -1
  272. package/dist/special/loader.js +179 -33
  273. package/dist/special/log1pmx.js +4 -0
  274. package/dist/special.js +2 -2
  275. package/dist/tests.js +11 -11
  276. package/llms.txt +12 -6
  277. package/package.json +1 -1
  278. package/dist/chunks/chunk-2CUKVVRO.js +0 -2
  279. package/dist/chunks/chunk-3WQCKGKP.js +0 -2
  280. package/dist/chunks/chunk-4Z2XDWKV.js +0 -2
  281. package/dist/chunks/chunk-AJBLCNZ7.js +0 -3
  282. package/dist/chunks/chunk-D4F7GQAY.js +0 -2
  283. package/dist/chunks/chunk-EBQMGCQZ.js +0 -2
  284. package/dist/chunks/chunk-HBMHR5SS.js +0 -2
  285. package/dist/chunks/chunk-IBPWRQIF.js +0 -2
  286. package/dist/chunks/chunk-JLAH3X77.js +0 -2
  287. package/dist/chunks/chunk-LG74QY5U.js +0 -2
  288. package/dist/chunks/chunk-PEYGUK32.js +0 -2
  289. package/dist/chunks/chunk-Q4PGYESP.js +0 -2
  290. package/dist/chunks/chunk-RCAL4VHM.js +0 -3
  291. package/dist/chunks/chunk-SREPSVTT.js +0 -2
  292. package/dist/chunks/chunk-UFT662QZ.js +0 -2
  293. package/dist/chunks/chunk-VWJ74UHC.js +0 -2
  294. package/dist/chunks/chunk-XNPU54NH.js +0 -2
  295. package/dist/chunks/chunk-XPLDEK6D.js +0 -2
  296. package/dist/chunks/chunk-YGT4P7EU.js +0 -2
  297. package/dist/chunks/chunk-YVREYVI2.js +0 -2
@@ -1,2 +0,0 @@
1
- /*! rStats.js 0.15.2 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{c as N}from"./chunk-PWVQVJTP.js";function h(f,e,a){let n=Math.ceil(a);if(n===1)return[f];let s=(e-f)/(n-1),r=Array.from({length:n},(o,t)=>f+t*s);return n>0&&(r[n-1]=e),r}function y(f,e){let a=Array.from(f).map(r=>Math.trunc(r));if(e!==void 0){if(Number.isNaN(e))throw new RangeError("missing value where TRUE/FALSE needed");if(Math.trunc(e)<0)throw new RangeError("invalid 'nbin' argument");if(Math.trunc(e)>=2**31)throw new RangeError("attempt to make a table with >= 2^31 elements")}let n=e===void 0?Math.max(1,...a.filter(r=>!Number.isNaN(r))):Math.trunc(e),s=new Array(Math.max(0,n)).fill(0);for(let r of a)r>=1&&r<=n&&s[r-1]++;return s}function A(f,e={}){let a=e.useNA??"no",n=N(Array.from(f)),s=new Map,r=0;for(let i of n)Number.isNaN(i)?r++:s.set(i,(s.get(i)??0)+1);let o=Array.from(s.keys()).sort((i,u)=>i-u),t=o.map(i=>s.get(i));return(a==="always"||a==="ifany"&&r>0)&&(o.push(NaN),t.push(r)),{values:o,counts:t}}function E(f){let e=new Set,a=[];for(let n of Array.from(f)){let s=n===0?0:n;e.has(s)||(e.add(s),a.push(n))}return a}function x(f,e,a={}){let n=a.right??!0,s=a.includeLowest??!1,r=Array.from(f),o;if(typeof e=="number"||e.length===1){let t=typeof e=="number"?e:e[0];if(!(t>=2))throw new RangeError("invalid number of intervals");let i=Math.trunc(t+1),u=r.filter(w=>!Number.isNaN(w)),l=Math.min(...u),m=Math.max(...u);if(u.length>0&&l===m&&!Number.isFinite(l))throw new RangeError("missing value where TRUE/FALSE needed");if(u.length===0||l===-1/0)throw new RangeError("'from' must be a finite number");if(m===1/0)throw new RangeError("'to' must be a finite number");let c=m-l;c===0?(c=l!==0?Math.abs(l):1,o=h(l-c/1e3,m+c/1e3,i)):(o=h(l,m,i),o[0]=l-c/1e3,o[i-1]=m+c/1e3)}else o=e.filter(t=>!Number.isNaN(t)).sort((t,i)=>t-i);if(new Set(o).size<o.length)throw new RangeError("'breaks' are not unique");return d(r,o,n,s)}function d(f,e,a,n){let s=e.length;return f.map(r=>{if(Number.isNaN(r))return NaN;let o=0,t=s;for(;o<t;){let u=o+t>>1;(a?e[u]<r:e[u]<=r)?o=u+1:t=u}let i=o;return n&&(a&&r===e[0]&&(i=1),!a&&r===e[s-1]&&(i=s-1)),i>=1&&i<=s-1?i:NaN})}function M(f,e,a={}){let n=e.length;for(let t=1;t<n;t++)if(!(e[t]>=e[t-1]))throw new RangeError("'vec' must be sorted non-decreasingly and not contain NAs");if(e.some(Number.isNaN))throw new RangeError("'vec' must be sorted non-decreasingly and not contain NAs");let{rightmostClosed:s=!1,allInside:r=!1,leftOpen:o=!1}=a;return Array.from(f).map(t=>{if(Number.isNaN(t))return NaN;if(n===0)return 0;if(o?t<=e[0]:t<e[0])return r||s&&o&&t===e[0]?1:0;if(o?t>e[n-1]:t>=e[n-1])return r||s&&!o&&t===e[n-1]?n-1:n;let i=0,u=n;for(;i<u;){let l=i+u>>1;(o?e[l]<t:e[l]<=t)?i=l+1:u=l}return i})}export{h as a,y as b,A as c,E as d,x as e,M as f};
@@ -1,2 +0,0 @@
1
- /*! rStats.js 0.15.2 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{A as Ye,B as qs,C as _n,E as Vn,c as Ss,d as In,e as It,g as V,h as Pt,i as xn,l as Fs,o as ct,p as w,q as vn,r as Ds,s as Ue,t as Yn,u as Ts,x as ys}from"./chunk-2CUKVVRO.js";import{a as As,b as G,c as K,d as A,e as kt,f as J,g as B,h as C,i as O,j as Ls,k as U}from"./chunk-LG74QY5U.js";function Es(t,n){return t?n?-1/0:0:n?0:1}function Ps(t,n){return t?n?0:1:n?-1/0:0}function Cs(t){return t?-1/0:0}function On(t,n,e,o,s){if(s){if(t>0)return NaN;if(t===0)return o?e:n;if(t===-1/0)return o?n:e}else{if(t<0||t>1)return NaN;if(t===0)return o?n:e;if(t===1)return o?e:n}}function jn(t,n,e){let o=e?t:Math.log(t);if(o<=-Math.LN2)return e?{lower:n,logTarget:o}:{lower:n,logTarget:o,linearTarget:t};let s=e?-Math.expm1(t):1-t;return{lower:!n,logTarget:Math.log(s),linearTarget:s}}function Wn(t){let{logTarget:n,lower:e,cdfLog:o,pdfLog:s,linearTarget:c,cdf:i,cdfBoth:r,dlogPdf:a}=t,u=(h,d)=>{if(c!==void 0&&i!==void 0&&d>-700){let x=i(h,e);if(x>0)return Math.log(x/c)}return d-n},f=h=>{if(r===void 0){let k=o(h,e);return[k,u(h,k)]}let[d,x]=r(h,e);return c!==void 0&&d>-700&&x>0?[d,Math.log(x/c)]:[d,d-n]},M=t.positive??!1,p=t.maxIter??200,m=M?Math.exp:h=>h,I=M?Math.log(t.lo):t.lo,g=M?Math.log(t.hi):t.hi,b=M?Math.log(t.x0):t.x0;b>I&&b<g||(b=Rs(I,g,NaN));let v=b,D=1/0;for(let h=0;h<p;h++){let d=m(b),[x,k]=f(d);if(Math.abs(k)<D&&(D=Math.abs(k),v=b),k===0)return d;k<0===e?I=b:g=b;let N=(e?1:-1)*Math.exp(s(d)-x+(M?Math.log(d):0)),F=k/N;if(M&&a!==void 0){let y=N*(1+d*a(d))-N*N,q=2*k*N/(2*N*N-k*y),S=q/F;S>=.5&&S<=2&&(F=q)}let l=b-F,L=l===b&&Number.isFinite(N)&&N!==0;!L&&(!Number.isFinite(l)||l<=I||l>=g)&&(l=Rs(I,g,b));let _=M?Math.abs(l-b)<=2e-16:Math.abs(l-b)<=4e-16*Math.abs(b);if(L||_)return T(m(v));if(I===g)break;b=l}return T(m(v));function T(h){if(!M||!(h>0)||!Number.isFinite(h)||Math.abs(Math.log(h))<=2)return h;let d=h,[x,k]=f(d);for(let N=0;N<4&&k!==0;N++){let F=(e?1:-1)*Math.exp(s(d)-x),l=d-k/F;if(!(l>0)||!Number.isFinite(l)||l===d)break;let[L,_]=f(l);if(!(Math.abs(_)<Math.abs(k)))break;d=l,x=L,k=_}return Math.abs(k)>1e-9?P(d,k):d}function P(h,d){let x=F=>F<0===e,k=m(I),N=m(g);x(d)?k=Math.max(k,h):N=Math.min(N,h);for(let F=0,l=1e-13;F<60&&!(k>0);F++,l*=2){let L=l<.5?h*(1-l):h/(2*l);x(f(L)[1])?k=L:N=Math.min(N,L)}for(let F=0,l=1e-13;F<60&&!Number.isFinite(N);F++,l*=2){let L=h*(1+l);x(f(L)[1])?k=Math.max(k,L):N=L}if(!(k>0&&N>k&&Number.isFinite(N)))return h;for(let F=0;F<64;F++){let l=k+(N-k)/2;if(l<=k||l>=N)break;let L=f(l)[1];if(L===0)return l;x(L)?k=l:N=l}return Math.abs(f(k)[1])<Math.abs(f(N)[1])?k:N}}function Rs(t,n,e){if(Number.isFinite(t)&&Number.isFinite(n))return t+(n-t)/2;if(Number.isFinite(t)){let o=Number.isFinite(e)?Math.max(e,t):t;return o+Math.max(1,Math.abs(o))}if(Number.isFinite(n)){let o=Number.isFinite(e)?Math.min(e,n):n;return o-Math.max(1,Math.abs(o))}return Number.isFinite(e)?e*2+1:0}var Oe=1,An=2**52,Jn=100;function Ct(t,n,e,o){let s=Math.min(t,n),c=Math.max(t,n),i,r;if(s<Oe)i=s/(1+s/c),r=je(t,n);else if(c>=An&&s<=Jn)i=1/Fs(s),r=Ln(s,c);else return;let a=e[0]<=.5?U(e):zs(o),u=o[0]<=.5?U(o):zs(e);return[i,A(A(Ve(a,t),Ve(u,n)),r)]}function Ln(t,n){return A(Ve(U([n,0]),t),[t*(t-1)/(2*n),0])}function je(t,n){let e=Math.min(t,n),o=Math.max(t,n);return o<1?[qs(e,1+o)-ct(e),0]:A(o>=An?Ln(e,o):_n(e,o),[Math.log1p(e/o)-ct(e),0])}function zs(t){return t[0]<1e-15?kt(A(t,[t[0]*t[0]/2,0])):U(J([1,0],t))}function Ve(t,n){return n>1e290?C(C(t,n/2**64),2**64):C(t,n)}var Zn=25,Bs=1,$n=30,jc=12,Wc=1.5,Qs=1.772453850905516,We=6.283185307179586,Rt=new Float64Array($n+2),Kn=new Float64Array($n+3),xt=new Float64Array($n);function Jc(t,n,e){let o=0;for(let s=n-1;s>=0;s--)o=o*e+t[s];return o}function Kc(t,n,e){let o=n-t,s=t*n;Rt[1]=1,Kn[1]=0,Kn[2]=1;for(let c=3;c<=e+1;c++){let i=2/c*(o*Rt[c-2]-s*Kn[c-2]),r=0;for(let a=2;a<=c-2;a++)r+=Rt[a]*Rt[c-a];Rt[c-1]=(i-r)/2,Kn[c]=i}xt[0]=1;for(let c=1;c<e;c++){let i=0;for(let r=1;r<=c;r++)i+=Rt[r+1]*xt[c-r];xt[c]=-i}}function Xs(t,n,e,o){let s=e,c=1,i=0;for(let r=0;r<jc&&s>1;r++){let a;if(o)a=r===0?0:c*Jc(xt,s,t);else{let u=0;for(let f=s-1;f>=1;f--)u=u*t+xt[f];a=c*u}if(i+=a,r>1&&Math.abs(a)<=1e-17*Math.abs(i))break;for(let u=0;u+2<s;u++)xt[u]=(u+1)*xt[u+2];s-=2,c/=n}return i}var Gs=[.9602898564975363,.7966664774136267,.525532409916329,.1834346424956498],Zc=[.10122853629037626,.22238103445337448,.31370664587788727,.362683783378362],$c=.15729920705028513;function zt(t){if(t<.5||t>=1)return .5*Ss(t);let n=(1+t)/2,e=(1-t)/2,o=0;for(let s=0;s<4;s++){let c=n+e*Gs[s],i=n-e*Gs[s];o+=Zc[s]*(Math.exp(-c*c)+Math.exp(-i*i))}return .5*$c+e*o/Qs}function wc(t){let n=t*t,e=Math.ceil(4+120/n),o=0;for(let s=e;s>=1;s--)o=-s*(s+.5)/(n+2*s+1.5+o);return-1/(4*Qs*t*(n+1.5+o))}function Hs(t,n){if(!(t[0]>1e299))return B(t,n);let e=B([t[0]*2**-64,t[1]*2**-64],n);return[e[0]*2**64,e[1]*2**64]}function Us(t,n,e,o,s,c){let i=G(t,n),r=i[0],a=t*n,u=Number.isFinite(a)?a/r:t*(n/r);if(!(u>=Zn)||!Number.isFinite(r))return;let f=t/r,M=n/r,p=u/r,m=e[0];if(Math.abs(m-f)>2*p)return;let I=Hs(i,e),g=J(I,[t,0]),b=g[0]+g[1],v=A(vn(t,I),vn(n,Hs(i,o))),D=v[0]+v[1],T=2*D/u;if(!(T<=Bs*Bs))return;let P=Math.sqrt(T),h=b<0?-P:P,d=P<=.5?20:P<=.75?24:$n;Kc(f,M,d);let x=Math.exp(-(w(t)+w(n)-w(r))),k=Math.sqrt(D),N=b<0;if(k<Wc){let L=Math.exp(-v[0])*(1-v[1])*x*Xs(h,u,d,!1)/Math.sqrt(We*u),_=b<0?k:-k,y=(_>=0?zt(_):1-zt(-_))-L,q=(_<=0?zt(-_):1-zt(_))+L,S=s?y:q;return c?[s===N?Math.log(S):Math.log1p(-(N?y:q)),S]:[NaN,S]}let F=wc(k)+x*(Math.sqrt(u/We)/Math.abs(b)+Xs(h,u,d,!0)/(P*Math.sqrt(We*u))),l;return v[0]<700?l=Math.exp(-v[0])*(1-v[1])*F:l=Math.exp(700-v[0])*(1-v[1])*F*Math.exp(-700),s===N?[c?-v[0]-v[1]+Math.log(F):NaN,l]:[c?Math.log1p(-l):NaN,1-l]}var Os=15,js=40,tr=.3,nr=.1,er=500,Fn=30,Ys=2**-56,Je=new Float64Array(Fn+1);{let t=1;Je[0]=1;for(let n=1;n<=Fn;n++)t*=2*n*(2*n+1),Je[n]=1/t}var Sn=new Float64Array(Fn+1),or=1.772453850905516,sr=[.15915494309189535,-9839338337591243e-33];function cr(t,n,e){if(t===.5){let a=Math.sqrt(n),u=or/a*(a>=1?In(a):2*Math.exp(n)*zt(a));return u*(1+e*(1-t/n-1/(n*u)))}let o=A(G(n,-t),[e,0]),s=o[0],c=0;for(let a=Math.ceil(100/n+t/2)+10;a>2;a--)c=-a*(a-t)/(s+(2*a+1)+c);let i=[c,0];for(let a=2;a>=1;a--)i=O(C(G(a,-t),-a),A(A(o,[2*a+1,0]),i));let r=O([1,0],A(A(o,[1,0]),i));return r[0]+r[1]}function Vs(t,n){let e=0;for(let o=1;o<=n;o++)e+=(o*t-n)*Sn[n-o]*Je[o];return Sn[n]=e/n}function Ke(t,n,e,o,s,c){let i=o[0];if(!(i<=tr))return;let r=-(t+(n-1)/2)*Math.log1p(-i),a=n>=1?n-1/3:Math.pow(.5,1/n),u=r>=a;if(r>er&&e[0]<1||u&&r<nr)return;let f=G(n,-1),M=A([t,0],[f[0]/2,f[1]/2]),p=i<1e-15?kt(A(o,[i*i/2,0])):U(e),m=[-p[0],-p[1]],I=B(M,m),g=I[0]+I[1];if(!(g>0&&g<1/0))return;let b=I[1]-(g-I[0]),v=m[0],D=M[0],T=J(m,o),P=n*Math.log1p((T[0]+T[1])/i)-(n-1)/2*v,h,d,x,k=0,N=Ct(t,n,e,o);if(N!==void 0){let[S,z]=N;[h,d,x]=[z[0],z[1],S]}else{let{e:S}=Yn(t,n,e,o),z=B(O(K(t,n),G(t,n)),sr),R=Math.sqrt(z[0]),Y=K(R,R);[h,d,x]=[-S[0],-S[1],R],k=(z[0]-Y[0]-Y[1]+z[1])/(2*z[0])}let F=Math.expm1(P+d)+k,l=v/2*(v/2),L=4*D*D,_;if(Sn[0]=1,u){let S=cr(n,g,b);_=S;let z=1,R=n,Y=1/0;for(let Q=1;Q<=Fn;Q++){S=(R*(R+1)*S+z*(g+R+1))/L,z*=l,R+=2;let ot=Vs(n,Q)*S,st=Math.abs(ot);if(st>Y||(_+=ot,st<=Ys*_))break;Y=st}}else{let S=0,z=1;for(let Q=1;Q<=Fn&&!(Math.abs(Vs(n,Q))*z*l<=Ys);Q++)z*=l,S=Q;let R=n+2*S,Y=z*ys(R,g)/R;_=Sn[S]*Y;for(let Q=S;Q>=1;Q--)z/=l,R-=2,Y=(L*Y+z*(g+R+1))/(R*(R+1)),_+=Sn[Q-1]*Y;_*=1+b*(1-n/g+1/(g*Y))}let y=Math.exp(h)*(x*_),q=y+y*F;if(!(q>=1e-290)){if(e[0]<1||!(_>0))return;let S=x*_>0?Math.log(x*_):Math.log(x)+Math.log(_),z=h+(P+d)+S+Math.log1p(k),R=Math.exp(z);return s===u?[c?z:NaN,R]:[c?-R:NaN,1-R]}return s===u?[c?Math.log(q):NaN,q]:[c?Math.log1p(-q):NaN,1-q]}var H=4503599627370496,X=2220446049250313e-31;function ws(t,n,e,o){let s=Ct(t,n,e,o);return s!==void 0?Math.log(s[0])+s[1][0]+s[1][1]:Ue(t,n,e,o,!0)+Math.log(t)+Math.log(n)-Math.log(t+n)}function tc(t,n,e,o){let s=Ct(t,n,e,o);return s!==void 0?s[0]*(Math.exp(s[1][0])*(1+s[1][1])):Ue(t,n,e,o,!1)*(t*n/(t+n))}var nc=22250738585072014e-324*1e3;function ec(t,n,e,o,s){let c=Ct(t,n,e,o);if(c!==void 0){let[u,f]=c,M=s*u;if(!(f[0]>-1400)||!Number.isFinite(M)||M===0)return;let p=Math.exp(f[0]+700)*(1+f[1])*M*Math.exp(-700);return p>0?p:void 0}let{e:i}=Yn(t,n,e,o),r=s*(t*n/(t+n))/Math.sqrt(2*Math.PI*t*(n/(t+n)));if(!(i[0]<1400)||!Number.isFinite(r)||r===0)return;let a=Math.exp(700-i[0])*(1-i[1])*r*Math.exp(-700);return a>0?a:void 0}function oc(t,n,e){let o=(1-n)*e,s=o/(t+1),c=s,i=o,r=2,a=0;for(;(Math.abs(s)>xn*Math.abs(a+c)||r<4)&&!(r>1e7);)o=(r-n)*e/r,i*=o,s=i/(t+r),a+=s,r+=1;return a+c}function Ws(t,n,e,o){let s=e[0],c=n>=An&&t<=Jn?Ln(t,n):_n(t,n),i=A(A(C(U(e),t),c),[-ct(t),0]),r=Math.exp(i[0])*(1+i[1]),a=-(Math.expm1(i[0])+i[1]*Math.exp(i[0]))-r*t*oc(t,n,s);return o?Math.log(a):a}function Dn(t,n,e,o,s){let c=e[0],i=1/t,r=(1-n)*c,a=r/(t+1),u=a,f=r,M=2,p=0,m=xn*i;for(;Math.abs(a)>m;)r=(M-n)*c/M,f*=r,a=f/(t+M),p+=a,M+=1;p+=u,p+=i;let I=ar(e);if(!s){let b=tc(t,n,e,o);if(b>nc)return p*b/Math.exp(n*I);let v=ec(t,n,e,o,p/Math.exp(n*I));if(v!==void 0)return v}let g=Math.log(p)+ws(t,n,e,o)-n*I;return s?g:Math.exp(g)}var tt=new Float64Array(2);function wn(t,n,e,o){let s=t/e,c=e*s,i=134217729*e,r=i-(i-e),a=e-r,u=134217729*s,f=u-(u-s),M=s-f,m=r*f-c+r*M+a*f+a*M+o*s,I=c+m,g=m-(I-c),b=-I,v=-g,D=t+b,T=D-t,P=t-(D-T)+(b-T),h=n+v,d=h-n,x=n-(h-d)+(v-d),k=P+h,N=D+k,l=k-(N-D)+x,L=N+l,_=l-(L-N),y=L/e,q=e*y,S=134217729*e,z=S-(S-e),R=e-z,Y=134217729*y,Q=Y-(Y-y),ot=y-Q,Xt=z*Q-q+z*ot+R*Q+R*ot+o*y,Gt=q+Xt,Ht=Xt-(Gt-q),Qt=-Gt,ee=-Ht,rt=L+Qt,nt=rt-L,oe=L-(rt-nt)+(Qt-nt),it=_+ee,Ut=it-_,Yt=_-(it-Ut)+(ee-Ut),Vt=oe+it,At=rt+Vt,Ot=Vt-(At-rt)+Yt,se=At+Ot,ce=Ot-(se-At),jt=se/e,Lt=s+y,St=y-(Lt-s),at=Lt+jt,Ft=at-Lt,Cn=Lt-(at-Ft)+(jt-Ft),Dt=St+0,Tt=Dt-St,Rn=St-(Dt-Tt)+(0-Tt),zn=Cn+Dt,j=at+zn,yt=zn-(j-at)+Rn,Wt=j+yt,Jt=yt-(Wt-j);tt[0]=Wt,tt[1]=Jt}var Js=200002;function sc(t){return t>=2**20&&t<2**52&&t+Js-t!==Js}function Ks(t,n,e,o,s){if(!As()||Math.max(t,n)>=2**52||sc(t))return rr(t,n,e,o,s);let c=e[0],i=e[1];s&&(wn(e[0],e[1],o[0],o[1]),c=tt[0],i=tt[1]);let r=n+-1,a=r-n,u=n-(r-a)+(-1-a),f=t+n,M=f-t,p=t-(f-M)+(n-M),m=s?r:f,I=s?u:p,g=s?f:r,b=s?p:u,v=t,D=t,T=t+1,P=1,h=t+1,d=t+2,x=s?-1:1,k=-x,N=0,F=0,l=1,L=0,_=1,y=0,q=1,S=0,z=1,R=0;for(let Y=0;Y<1e5;Y++){let Q=c*v,ot=134217729*c,st=ot-(ot-c),Xt=c-st,Gt=134217729*v,Ht=Gt-(Gt-v),Qt=v-Ht,rt=st*Ht-Q+st*Qt+Xt*Ht+Xt*Qt+i*v,nt=Q+rt,oe=rt-(nt-Q),it=nt*m,Ut=134217729*nt,Yt=Ut-(Ut-nt),Vt=nt-Yt,At=134217729*m,Pn=At-(At-m),Ot=m-Pn,ce=Yt*Pn-it+Yt*Ot+Vt*Pn+Vt*Ot+(nt*I+oe*m),jt=it+ce,Lt=ce-(jt-it),St=D*T,at=134217729*D,Ft=at-(at-D),Cn=D-Ft,Dt=134217729*T,Tt=Dt-(Dt-T),Rn=T-Tt,zn=Ft*Tt-St+Ft*Rn+Cn*Tt+Cn*Rn;wn(jt,Lt,St,zn);let j=tt[0],re=tt[1],yt=N*j,Wt=134217729*N,Jt=Wt-(Wt-N),so=N-Jt,co=134217729*j,ie=co-(co-j),ro=j-ie,io=Jt*ie-yt+Jt*ro+so*ie+so*ro+(N*re+F*j),ao=yt+io,xc=io-(ao-yt),uo=-ao,fo=-xc,Bn=_+uo,lo=Bn-_,vc=_-(Bn-lo)+(uo-lo),ae=y+fo,ho=ae-y,_c=y-(ae-ho)+(fo-ho),Mo=vc+ae,ue=Bn+Mo,mo=Mo-(ue-Bn)+_c,po=ue+mo,Ac=mo-(po-ue),fe=l*j,No=134217729*l,le=No-(No-l),go=l-le,bo=134217729*j,he=bo-(bo-j),ko=j-he,Io=le*he-fe+le*ko+go*he+go*ko+(l*re+L*j),xo=fe+Io,Lc=Io-(xo-fe),vo=-xo,_o=-Lc,Xn=q+vo,Ao=Xn-q,Sc=q-(Xn-Ao)+(vo-Ao),Me=S+_o,Lo=Me-S,Fc=S-(Me-Lo)+(_o-Lo),So=Sc+Me,me=Xn+So,Fo=So-(me-Xn)+Fc,Do=me+Fo,Dc=Fo-(Do-me);N=_,F=y,_=po,y=Ac,l=q,L=S,q=Do,S=Dc;let pe=c*P,To=134217729*c,de=To-(To-c),yo=c-de,qo=134217729*P,Ne=qo-(qo-P),Eo=P-Ne,Po=de*Ne-pe+de*Eo+yo*Ne+yo*Eo+i*P,qt=pe+Po,Tc=Po-(qt-pe),ge=qt*g,Co=134217729*qt,be=Co-(Co-qt),Ro=qt-be,zo=134217729*g,ke=zo-(zo-g),Bo=g-ke,Xo=be*ke-ge+be*Bo+Ro*ke+Ro*Bo+(qt*b+Tc*g),Go=ge+Xo,yc=Xo-(Go-ge),Ho=h*d,Qo=134217729*h,Ie=Qo-(Qo-h),Uo=h-Ie,Yo=134217729*d,xe=Yo-(Yo-d),Vo=d-xe,qc=Ie*xe-Ho+Ie*Vo+Uo*xe+Uo*Vo;wn(Go,yc,Ho,qc);let $=tt[0],Oo=tt[1],ve=N*$,jo=134217729*N,_e=jo-(jo-N),Wo=N-_e,Jo=134217729*$,Ae=Jo-(Jo-$),Ko=$-Ae,Zo=_e*Ae-ve+_e*Ko+Wo*Ae+Wo*Ko+(N*Oo+F*$),Le=ve+Zo,$o=Zo-(Le-ve),Gn=_+Le,wo=Gn-_,Ec=_-(Gn-wo)+(Le-wo),Se=y+$o,ts=Se-y,Pc=y-(Se-ts)+($o-ts),ns=Ec+Se,Fe=Gn+ns,es=ns-(Fe-Gn)+Pc,Kt=Fe+es,os=es-(Kt-Fe),De=l*$,ss=134217729*l,Te=ss-(ss-l),cs=l-Te,rs=134217729*$,ye=rs-(rs-$),is=$-ye,as=Te*ye-De+Te*is+cs*ye+cs*is+(l*Oo+L*$),qe=De+as,us=as-(qe-De),Hn=q+qe,fs=Hn-q,Cc=q-(Hn-fs)+(qe-fs),Ee=S+us,ls=Ee-S,Rc=S-(Ee-ls)+(us-ls),hs=Cc+Ee,Pe=Hn+hs,Ms=hs-(Pe-Hn)+Rc,Et=Pe+Ms,ms=Ms-(Et-Pe);if(N=_,F=y,_=Kt,y=os,l=q,L=S,q=Et,S=ms,Et!==0){wn(Kt,os,Et,ms);let W=tt[0],ut=tt[1],et=W!==0?Math.abs((z-W)/W):1;if(z=W,R=ut,et<xn&&Y>1)break}let Qn=m+x,ps=Qn-m,zc=m-(Qn-ps)+(x-ps),Ce=I+0,ds=Ce-I,Bc=I-(Ce-ds)+(0-ds),Ns=zc+Ce,Re=Qn+Ns,gs=Ns-(Re-Qn)+Bc,bs=Re+gs,Xc=gs-(bs-Re);m=bs,I=Xc;let Un=g+k,ks=Un-g,Gc=g-(Un-ks)+(k-ks),ze=b+0,Is=ze-b,Hc=b-(ze-Is)+(0-Is),xs=Gc+ze,Be=Un+xs,vs=xs-(Be-Un)+Hc,_s=Be+vs,Qc=vs-(_s-Be);if(g=_s,b=Qc,P+=1,v+=1,D+=2,T+=2,h+=2,d+=2,Math.abs(Et)+Math.abs(Kt)>H){let W=N*X,ut=134217729*N,et=ut-(ut-N),Zt=N-et,$t=134217729*X,ft=$t-($t-X),wt=X-ft,tn=et*ft-W+et*wt+Zt*ft+Zt*wt+F*X,nn=W+tn,Xe=tn-(nn-W);N=nn,F=Xe;let lt=_*X,en=134217729*_,ht=en-(en-_),on=_-ht,sn=134217729*X,Mt=sn-(sn-X),cn=X-Mt,rn=ht*Mt-lt+ht*cn+on*Mt+on*cn+y*X,an=lt+rn,Ge=rn-(an-lt);_=an,y=Ge;let mt=l*X,un=134217729*l,pt=un-(un-l),fn=l-pt,ln=134217729*X,dt=ln-(ln-X),hn=X-dt,Mn=pt*dt-mt+pt*hn+fn*dt+fn*hn+L*X,mn=mt+Mn,He=Mn-(mn-mt);l=mn,L=He;let Nt=q*X,pn=134217729*q,gt=pn-(pn-q),dn=q-gt,Nn=134217729*X,bt=Nn-(Nn-X),gn=X-bt,bn=gt*bt-Nt+gt*gn+dn*bt+dn*gn+S*X,kn=Nt+bn,Qe=bn-(kn-Nt);q=kn,S=Qe}if(Math.abs(Et)<X||Math.abs(Kt)<X){let W=N*H,ut=134217729*N,et=ut-(ut-N),Zt=N-et,$t=134217729*H,ft=$t-($t-H),wt=H-ft,tn=et*ft-W+et*wt+Zt*ft+Zt*wt+F*H,nn=W+tn,Xe=tn-(nn-W);N=nn,F=Xe;let lt=_*H,en=134217729*_,ht=en-(en-_),on=_-ht,sn=134217729*H,Mt=sn-(sn-H),cn=H-Mt,rn=ht*Mt-lt+ht*cn+on*Mt+on*cn+y*H,an=lt+rn,Ge=rn-(an-lt);_=an,y=Ge;let mt=l*H,un=134217729*l,pt=un-(un-l),fn=l-pt,ln=134217729*H,dt=ln-(ln-H),hn=H-dt,Mn=pt*dt-mt+pt*hn+fn*dt+fn*hn+L*H,mn=mt+Mn,He=Mn-(mn-mt);l=mn,L=He;let Nt=q*H,pn=134217729*q,gt=pn-(pn-q),dn=q-gt,Nn=134217729*H,bt=Nn-(Nn-H),gn=H-bt,bn=gt*bt-Nt+gt*gn+dn*bt+dn*gn+S*H,kn=Nt+bn,Qe=bn-(kn-Nt);q=kn,S=Qe}}return z+R}function rr(t,n,e,o,s){let c=s?O(e,o):e,i=Math.max(t,n)>=2**52||sc(t),r=Math.max(t,n)>1e150,a=t,u=s?G(n,-1):G(t,n),f=t,M=t+1,p=1,m=s?G(t,n):G(n,-1),I=t+1,g=t+2,b=[t,0],v=[t,0],D=G(t,1),T=G(t,1),P=G(t,2),h=s?-1:1,d=[0,0],x=[1,0],k=[1,0],N=[1,0],F=[1,0];for(let l=0;l<1e5;l++){let L=r?B(B(c,O(b,v)),O(u,D)):i?O(B(B(c,b),u),B(v,D)):O(B(C(c,a),u),K(f,M)),_=J(k,B(d,L)),y=J(N,B(x,L));if(d=k,k=_,x=N,N=y,L=r?B(C(c,p),O(O(m,T),P)):O(B(C(c,p),m),i?B(T,P):K(I,g)),_=A(k,B(d,L)),y=A(N,B(x,L)),d=k,k=_,x=N,N=y,y[0]!==0){let S=O(_,y),z=S[0]!==0?Math.abs((F[0]-S[0])/S[0]):1;if(F=S,z<xn&&l>1)break}u=A(u,[h,0]),m=A(m,[-h,0]),p+=1,i?(b=A(b,[1,0]),v=A(v,[2,0]),D=A(D,[2,0]),T=A(T,[2,0]),P=A(P,[2,0])):(a+=1,f+=2,M+=2,I+=2,g+=2),Math.abs(y[0])+Math.abs(_[0])>H&&(d=C(d,X),k=C(k,X),x=C(x,X),N=C(N,X)),(Math.abs(y[0])<X||Math.abs(_[0])<X)&&(d=C(d,H),k=C(k,H),x=C(x,H),N=C(N,H))}return F[0]+F[1]}function Tn(t,n,e){return n*e<=1&&e<=.95}function te(t,n,e,o){return e[0]<=.5?e[0]<=t/(t+n):o[0]>=(t+n<1/0?n/(t+n):1/(1+t/n))}function vt(t,n,e,o,s){let c=e[0],i=o[0],a=c*(t+n-2)-(t-1)<0?Ks(t,n,e,o,!1):Ks(t,n,e,o,!0)/i;if(!s){let f=tc(t,n,e,o);if(f>nc)return f*(a/t);let M=ec(t,n,e,o,a/t);if(M!==void 0)return M}let u=ws(t,n,e,o)-Math.log(t)+Math.log(a);return s?u:Math.exp(u)}function ai(t,n,e,o,s,c){if(e<=0)return s?c?-1/0:0:c?0:1;if(o<=0)return s?c?0:1:c?-1/0:0;let i=e<=o?[e,0]:G(1,-o),r=e<=o?G(1,-e):[o,0];return Ze(t,n,i,r,s,c)}function Ze(t,n,e,o,s,c){let i=$e(t,n,e,o,s,c);return c?i[0]:i[1]}function cc(t,n,e,o,s){return $e(t,n,e,o,s,!0)}function ui(t,n,e,o,s){if(e<=0)return s?[-1/0,0]:[0,1];if(o<=0)return s?[0,1]:[-1/0,0];let c=e<=o?[e,0]:G(1,-o),i=e<=o?G(1,-e):[o,0];return $e(t,n,c,i,s,!0)}var Zs=22250738585072014e-324;function $s(t,n,e,o,s,c){let i=Math.log1p(t*oc(t,n,e)),r=1,a=0,u;if(Math.min(t,n)<Oe){let p=Math.min(t,n)/Math.max(t,n);[r,a]=t<=n?[1/(1+p),-Math.log1p(p)]:[p/(1+p),Math.log(p)-Math.log1p(p)],u=A(A(C(o,t),je(t,n)),[i,0])}else{let p=n>=An&&t<=Jn?Ln(t,n):_n(t,n);u=A(A(C(o,t),p),[i-ct(t),0])}let f=a+u[0]+u[1],M=r*(Math.exp(u[0])*(1+u[1]));return s?[f,M]:[c?f<-Math.LN2?Math.log1p(-M):Math.log(-Math.expm1(f)):NaN,-Math.expm1(f)]}function $e(t,n,e,o,s,c){let i=ir(t,n,e,o,s,c);return i[1]>1||i[0]>0?[Math.min(i[0],0),Math.min(i[1],1)]:i}function ir(t,n,e,o,s,c){if(e[0]<=0)return s?[-1/0,0]:[0,1];if(o[0]<=0)return s?[0,1]:[-1/0,0];if(e[0]<Zs)return $s(t,n,e[0],U(e),s,c);if(o[0]<Zs)return $s(n,t,o[0],U(o),!s,c);if(t>=Zn&&n>=Zn){let h=Us(t,n,e,o,s,c);if(h!==void 0)return h}let[i,r,a,u]=s?[t,n,e,o]:[n,t,o,e],[f,M,p,m]=s?[n,t,o,e]:[t,n,e,o],I=Math.max(t,n)>=Os&&(Math.min(t,n)<=js||(t>=n?e[0]:o[0])===1&&Math.min(t,n)<=1e4&&Math.min(t,n)<1e-8*Math.max(t,n)),g=(h,d)=>{if(I)return t>=n?Ke(t,n,e,o,h,d):Ke(n,t,o,e,!h,d)},b=(h,d)=>{if(!c)return[NaN,h];if(h>.5){let x=d();if(x!==void 0)return[Math.log1p(-x),h]}return[Math.log(h),h]},v=()=>{if(Tn(f,M,p[0]))return Dn(f,M,p,m,!1);if(Tn(i,r,a[0])){let h=Ws(i,r,a,!1);if(i*Math.abs(Math.log(a[0]))>32*h){let d=g(!s,!1)?.[1];if(d!==void 0)return d;if(p[0]<1&&te(f,M,p,m))return vt(f,M,p,m,!1)}return h}if(te(f,M,p,m))return g(!s,!1)?.[1]??vt(f,M,p,m,!1)},D=1e-290;if(Tn(i,r,a[0])){let h=Dn(i,r,a,u,!1);if(c&&h<D)return[Dn(i,r,a,u,!0),h];if(h>.5&&Tn(f,M,p[0])){let d=Dn(f,M,p,m,!1);return[c?Math.log1p(-d):NaN,1-d]}return b(h,v)}if(Tn(f,M,p[0])){let h=Dn(f,M,p,m,!1);if(h<.5)return[c?Math.log1p(-h):NaN,1-h];let d=Ws(f,M,p,!1);if(f*Math.abs(Math.log(p[0]))>32*d){let x=g(s,c);if(x!==void 0)return x;if(a[0]<1&&te(i,r,a,u)){let k=vt(i,r,a,u,!1);return c&&k<D?[vt(i,r,a,u,!0),k]:b(k,v)}}return b(d,()=>h)}let T=g(s,c);if(T!==void 0)return T;if(te(i,r,a,u)){let h=vt(i,r,a,u,!1);return c&&h<D?[vt(i,r,a,u,!0),h]:b(h,v)}let P=vt(f,M,p,m,!1);return[c?Math.log1p(-P):NaN,1-P]}function ar(t){return Math.log1p(-t[0])-t[1]/(1-t[0])}var Z=.9189385332046728,ur=.7978845608028654,rc=[.6931471805599453,23190468138462996e-33];function fr(t){let n=Math.round(t[0]/rc[0]),e=A(t,C(rc,-n)),o=[e[0]/256,e[1]/256],s=[1,0],c=[1,0];for(let r=1;r<=12&&(s=B(s,o),s=[s[0]/r,s[1]/r],c=A(c,s),!(Math.abs(s[0])<1e-34));r++);for(let r=0;r<8;r++)c=B(c,c);let i=2**n;return[c[0]*i,c[1]*i]}function lr(t,n){if(Math.abs(t[0])<1e-6){let e=B(t,t),o=C(B(e,t),1/6);return A(A([e[0]/2,e[1]/2],o),[e[0]*e[0]/24,0])}return A(A(n,[-1,0]),[-t[0],-t[1]])}function eo(t){if(Math.abs(t)<.1){let n=t*t/2,e=n;for(let o=3;o<30&&(n*=t/o,e+=n,!(Math.abs(n)<=1e-17*e));o++);return e}return Math.expm1(t)-t}function Bt(t){return t<0?ur/In(-t*Math.SQRT1_2):Math.exp(-.5*t*t-Z)/V(t)}var uc=1e-300;function oo(t,n){return n<700?t*Math.exp(n):Math.exp(Math.log(t)+n)}function to(t,n,e){let o=oo(t,n);if(o>uc)return[Ye(t,o,e,!0),Ts(t,o,!0)];let s=t*(Math.log(t)+n)-ct(t);return[e?s:s>-Math.LN2?Math.log(-Math.expm1(s)):Math.log1p(-Math.exp(s)),s]}function we(t,n){let{a:e,t:o,delta:s}=t,c=Math.exp(n),i=Math.exp(n/2),r=o*i,a=r-s,u=eo(n);if(t.kind==="cdfQ"||t.kind==="cdfP"){let m=oo(e,n),I=t.kind==="cdfQ",[g,b]=to(e,n,!I),v=e*Math.exp(b-g),D=I?-1:1,T=Math.log(o/2)+n/2-.5*a*a-Z+g,P=.5-a*r/2+D*v,h=-(r*r)/4-a*r/4+D*v*(e-m)-v*v;return[T,P,h]}let f=t.logC-e*u,M=-e*Math.expm1(n),p=-e*c;if(t.kind==="cdf"){let m=Bt(a);f+=V(a,{logP:!0}),M+=r/2*m,p+=r/4*m-r/2*(r/2)*m*(a+m)}else f+=n/2-.5*a*a-Z,M+=.5-a*r/2,p+=-(r*r)/4-a*r/4;return[f,M,p]}function fc(t){let n=0,[e,o,s]=we(t,n);for(let i=0;i<400;i++){let r=s<0?-o/s:4*Math.sign(o);Number.isFinite(r)||(r=Math.sign(o)||0),r=Math.max(-4,Math.min(4,r));let a=n+r,u=we(t,a);for(let M=0;M<60&&!(u[0]>=e);M++)r/=2,a=n+r,u=we(t,a);if(!(u[0]>=e))break;let f=Math.abs(r)<1e-10*Math.max(1,Math.abs(n));if(n=a,[e,o,s]=u,f)break}let c=s<0?Math.min(1/Math.sqrt(-s),10):1;return{w:n,sigma:c,L:e}}function lc(t){let n=t[0],e=t[1]*Bt(n);if(n>-5)return G(V(n,{logP:!0}),e);let o=B(t,t);return A([-o[0]/2,-o[1]/2],[Math.log(.5*In(-n*Math.SQRT1_2)),0])}function hr(t,n,e,o=1/0){let{a:s,t:c,delta:i}=t;if(!e&&(t.kind==="cdf"||t.kind==="pdf")){let g=n[0]+n[1],b=Math.exp(g/2),v=s*eo(g),D=c*b,T=D-i,P=Math.exp(t.logC-v);if(t.kind==="cdf"){let h=P*V(T);if((v+Bt(T)*Math.abs(D))*h<=4*o)return[h,0]}else{let h=t.logC-v-.5*T*T-Z,d=h>-700?Math.exp(h)*b:Math.exp(h+g/2);if((v+Math.abs(T*D)+T*T+(h>-700?0:-h))*d<=4*o)return[d,0]}}let r=fr([n[0]/2,n[1]/2]),a=B(r,r);if(t.kind==="cdfQ"||t.kind==="cdfP"){let g=A(C(r,c),[-i,0]),b=B(g,g),v=n[0]<700?s*a[0]+s*a[1]:oo(s,n[0]+n[1]),D=t.kind==="cdfP";if(e){let P=Math.log(c/2)+Math.log(r[0])+r[1]/r[0]-Z+to(s,n[0]+n[1],D)[0];return A([-b[0]/2,-b[1]/2],[P,0])}let T=v>uc?Ye(s,v,D,!1):Math.exp(to(s,n[0]+n[1],D)[0]);return[c/2*(r[0]+r[1])*Math.exp(-.5*b[0]-Z)*(1-b[1]/2)*T,0]}let u=lr(n,a),f=u[0]<1e290?C(u,s):G(s*u[0],s*u[1]);if(!(f[0]<1/0))return[e?-1/0:0,0];let M=A(C(r,c),[-i,0]),p=M[0];if(t.kind==="cdf"){if(e)return A([t.logC-f[0],-f[1]],lc(M));let g=M[1]*Bt(p);return[Math.exp(t.logC-f[0])*(1-f[1])*V(p)*(1+g),0]}let m=B(M,M);if(e)return A(A([t.logC-f[0],-f[1]],[-m[0]/2,-m[1]/2]),[n[0]/2-Z,n[1]/2]);let I=t.logC-f[0]-.5*m[0]-Z;return I<-700?[Math.exp(I+n[0]/2)*(1-f[1]-m[1]/2+n[1]/2),0]:[Math.exp(I)*(1-f[1]-m[1]/2)*(r[0]+r[1]),0]}function ic(t,n,e,o,s,c,i,r){let a=0,u=M=>{let p=Math.exp(-M),m=e/2*(M-Math.expm1(-M)),I=hr(t,G(n,m),s,r),g=e/2*(1+p);return s?Math.exp(I[0]-c)*(1+I[1])*g:I[0]*g},f=i?1:0;i||(a+=u(0));for(let M of[1,-1]){let p=0;for(let m=i?f:1;m<1e5;m+=i?2:1){let I=M*m*o,g=u(I);a+=g;let b=Math.abs(a);if(g>1e-19*b)p=0;else if(p++,p>=3)break;if(Math.abs(I)>40)break}}return a}function no(t,n){if(t.a>Mr){let e=pr(t);if(e!==void 0)return e}if(t.kind==="cdf"){let e=t.a<ac?void 0:fc(t),o=!0;if(e!==void 0){let s=Math.exp(e.w/2),c=Math.min(1/Math.sqrt(t.a*Math.exp(e.w)),10);o=Math.abs(t.t)*s*c/2>2}if(o){if(t.t>0){let i=yn({...t,kind:"cdfQ"},n);return{lin:V(-t.delta)+i.lin,log:n?hc(V(-t.delta,{logP:!0}),i.log):NaN}}if(t.a>=ac)return yn({...t,t:-t.t,delta:-t.delta,kind:"cdfP"},n);let s=yn({...t,t:-t.t,delta:-t.delta,kind:"cdfQ"},n),c=V(-t.delta,{logP:!0});return{lin:V(-t.delta)-s.lin,log:n?c+Math.log1p(-Math.exp(s.log-c)):NaN}}return yn(t,n,e)}return yn(t,n)}var ac=1e-5,Mr=1e5;function mr(t){let n,e,o;if(t<-3){let r=-t,a=0;for(let u=Math.ceil(20+600/(r*r));u>=2;u--)a=u/(r+a);e=1/(r+a),n=r+e,o=e*(a-e)}else n=Bt(t),e=t+n,o=1-n*e;let s=-n*e;if(t<-1e3){let r=1/(t*t);return[n,s,-(2-24*r+300*r*r)*r/t,(6-120*r+2100*r*r)*r*r]}let c=-s*e-n*o,i=-c*(t+2*n)-2*s*o;return[n,s,c,i]}function pr(t){let{a:n,t:e,delta:o,kind:s}=t,c=s==="cdf",i=N=>{let F=Math.exp(N),l=e*Math.exp(N/2),L=Math.abs(N)<1?e-o+e*Math.expm1(N/2):l-o,_;if(c){let[y,q,S,z]=mr(L),R=l*l;_=[y*l/2,(q*R+y*l)/4,(S*l*R+3*q*R+y*l)/8,(z*R*R+6*S*l*R+7*q*R+y*l)/16]}else _=[.5-L*l/2,-(l*l+L*l)/4,-(3*l*l+L*l)/8,-(7*l*l+L*l)/16];return{u:L,v:l,f:_,d1:-n*Math.expm1(N)+_[0],L2:n*F-_[1]}},r=-1400,a=50,u=0,f=i(u);for(let N=0;N<300&&a-r>4e-16*Math.max(1,Math.abs(u));N++){let F=f.d1/f.L2;if(Math.abs(F)*Math.sqrt(f.L2)<1e-9)break;if(f.d1>0)r=u;else if(f.d1<0)a=u;else break;let l=u+F;u=l>r&&l<a?l:(r+a)/2,f=i(u)}let{u:M,v:p,f:m,L2:I}=f,g=Math.exp(u);if(!(u>-1390&&I>=1e5))return;let b=(-n*g+m[2])/I,D=(-n*g+m[3])/I/I/8+5*b*b/I/24,T=Math.expm1(u)-m[1]/n,h=-.5*(Math.abs(T)<.5?Math.log1p(T):Math.log(g-m[1]/n))-w(n)+Math.log1p(D)-n*eo(u),d=Math.abs(u)<1?A(G(e,-o),K(e,Math.expm1(u/2))):G(p,-o),x;if(c){let N=lc(d),F=N[0]+(N[1]+h);x={lin:F<-745?0:V(d[0])*(1+d[1]*Bt(d[0]))*Math.exp(h),log:F}}else{let N=B(d,d),F=h+u/2-Z-N[1]/2,l=-N[0]/2,L=l+F;x={lin:l>-700?Math.exp(l)*Math.exp(F):Math.exp(L),log:L}}let k=c?Math.abs(p)/2/(Math.sqrt(I)*Math.max(1,-M)):0;return 1/(I*I)+k**6<=1e-17*Math.max(1,Math.abs(x.log))?x:void 0}function hc(t,n){return t===-1/0?n:n===-1/0?t:t>n?t+Math.log1p(Math.exp(n-t)):n+Math.log1p(Math.exp(t-n))}function yn(t,n,e){let{w:o,sigma:s,L:c}=e??fc(t);if(!n&&c<-800)return{lin:0,log:NaN};let i=c<-650||c>650,r=i?c:0,a=i?0:Math.exp(c),u=i?Math.max(1e-15,2e-16*Math.abs(c)):1e-15,f=.5,M=ic(t,o,s,f,i,r,!1,a)*f;for(let m=0;m<6;m++){let I=ic(t,o,s,f/2,i,r,!0,a)*(f/2),g=M/2+I;f/=2;let b=Math.abs(g-M)<=u*Math.abs(g);if(M=g,b)break}return i?{lin:r>-700?Math.exp(r)*M:Math.exp(r+700)*M*Math.exp(-700),log:r+Math.log(M)}:{lin:M,log:Math.log(M)}}function ne(t,n,e,o){return{a:t,t:n,delta:e,kind:o,logC:.5*Math.log(t)-Z-w(t)}}function En(t,n){return 1e10*(Math.abs(n)+10)*Math.sqrt(t+1)}function dr(t,n,e){return Math.abs(t)>En(n,e)?Mc(t,n,e,t<0).log:qn(t,2*n,e,t<0).log}function Mc(t,n,e,o){let s=En(n,e),c=Math.sign(t),i=c<0,r=qn(c*s,2*n,e,i),a=2*n*(Math.log(Math.abs(t))-Math.log(s)),u={lin:r.lin>0?r.lin*Math.exp(-a):Math.exp(r.log-a),log:r.log-a};if(o===i)return u;if(u.lin<.5)return{lin:1-u.lin,log:Math.log1p(-u.lin)};let f=qn(c*s,2*n,e,!i),M=-Math.expm1(-a);return{lin:f.lin+r.lin*M,log:hc(f.log,r.log+Math.log(M))}}function Nr(t,n,e){return Math.abs(t)*Math.sqrt((4*n+2*e*e+800)/n)*(Math.abs(e)+2)<=1e-17}function qn(t,n,e,o,s=!0){let c=n/2;if(Nr(t,c,e)){let u=o?-e:e;return{lin:V(u),log:V(u,{logP:!0})}}if(Math.abs(t)>En(c,e))return Mc(t,c,e,o);let i=u=>no(u?ne(c,t,e,"cdf"):ne(c,-t,-e,"cdf"),s&&u===o),r=t<e,a=i(r);return a.lin>.5&&(r=!r,a=i(r)),r===o?a:{lin:1-a.lin,log:Math.log1p(-a.lin)}}function gr(t,n,e,o,s){let c=qn(t,n,e,o,s);return s?c.log:c.lin}function mc(t,n,e,o){let s=n/2,c=En(s,e);if(Math.abs(t)>c){let r=Math.sign(t)*c,a=no(ne(s,r,e,"pdf"),!0).log+(2*s+1)*(Math.log(c)-Math.log(Math.abs(t)));return o?a:Math.exp(a)}let i=no(ne(s,t,e,"pdf"),o);return o?i.log:i.lin}function pc(t,n,e,o){if(Number.isNaN(t)||Number.isNaN(n)||Number.isNaN(e))return NaN;if(n<=0)return NaN;if(!Number.isFinite(t)||!Number.isFinite(e))return o?-1/0:0;if(n===1/0){let s=t-e,c=-.5*s*s-Z;return o?c:Math.exp(c)}return mc(t,n,e,o)}function dc(t,n,e,o,s){if(Number.isNaN(t)||Number.isNaN(n)||Number.isNaN(e))return NaN;if(n<=0)return NaN;let c=o?s?-1/0:0:s?0:1,i=o?s?0:1:s?-1/0:0;return t===1/0?i:t===-1/0||e===1/0?c:e===-1/0?i:n===1/0?V(t-e,{lowerTail:o,logP:s}):t===0?V(-e,{lowerTail:o,logP:s}):gr(t,n,e,o,s)}function Nc(t,n,e,o,s){if(Number.isNaN(t)||Number.isNaN(n)||Number.isNaN(e))return NaN;if(n<=0)return NaN;let c=On(t,-1/0,1/0,o,s);if(c!==void 0)return c;if(n===1/0)return e+Pt(t,{lowerTail:o,logP:s});if(!Number.isFinite(e))return NaN;let{lower:i,logTarget:r,linearTarget:a}=jn(t,o,s),u=Pt(r,{lowerTail:i,logP:!0}),f=e+u*Math.sqrt(1+e*e/(2*n)),M=V(-e,{lowerTail:i,logP:!0}),p=i?r>M:r<M;if(r===M)return 0;let m=p?1:-1,I=m>0?i:!i,g=NaN,b=!0,v={lin:NaN,log:NaN},D=(d,x,k)=>((d!==g||x!==b)&&(v=qn(m*d,n,e,m>0?x:!x),g=d,b=x),k?v.log:v.lin),T=En(n/2,e),P=1/0;if(I){if(n<.001&&D(Number.MAX_VALUE,!0,!0)<r)return m*(1/0)}else{let d=dr(m*T,n/2,e);if(r<d){let x=Math.log(T)+(d-r)/n;return x>709.78?m*(1/0):m*Math.exp(x)}P=T}let h=Wn({logTarget:r,...a!==void 0&&{linearTarget:a},lower:I,cdf:(d,x)=>D(d,x,!1),cdfLog:(d,x)=>D(d,x,!0),pdfLog:d=>mc(m*d,n,e,!0),x0:Math.min(Math.abs(f)>0&&Number.isFinite(f)&&Math.sign(f)===m?Math.abs(f):1,P/2),lo:0,hi:P,positive:!0});return m*h}var gc=.9189385332046728,br=[-.9189385332046728,38782941580672414e-33];function bc(t,n,e){let o=n/2,s=w(o+.5)-w(o)-Ds(o,o+.5),c=K(t,t),i=c[0]/n;if(!(i<1e30)){let u=A(C(U([Math.abs(t),0]),2),kt(U([n,0])));Number.isFinite(i)&&(u=A(u,[Math.log1p(1/i),0]));let f=A(A(kt(B(u,G(o,.5))),[s,0]),br);return e?f[0]+f[1]:Math.exp(f[0])*(1+f[1])}let r;if(c[0]>.2*n){let u=U(A([1,0],Ls(c,n)));r=A([s,0],C(u,-o))}else{let u=C(A([n,0],c),.5);r=A(A(vn(o,u),C(c,-.5)),[s,0])}return e?r[0]+r[1]-gc-.5*Math.log1p(i):Math.exp(r[0])*(1+r[1])/Math.sqrt(2*Math.PI*(1+i))}function kr(t,n,e){if(Number.isNaN(t)||Number.isNaN(n))return NaN;if(n<=0)return NaN;if(!Number.isFinite(t))return Cs(e);if(!Number.isFinite(n)){let o=-.5*t*t-gc;return e?o:Math.exp(o)}return bc(t,n,e)}var kc=1e-15;function Ir(t,n){let e=t/Math.sqrt(n);return .5*n*(e<1e300?Math.asinh(e):Math.LN2+Math.log(t)-.5*Math.log(n))}function Ic(t,n){let e=t,o=n;if(t>1e150||n>1e290){let i=2**-Math.ceil(Math.log2(Math.max(t,Math.sqrt(n))));e=t*i,o=n*i*i}let s=K(e,e),c=A(s,[o,0]);return[O([o,0],c),O(s,c)]}function _t(t,n,e){if(n<kc){let a=Ir(t,n);return e?Math.log1p(-2*a)-Math.LN2:.5-a}let o=t*t;if(!(n/(n+o)>1e-250)){let a=J(U([n,0]),C(U([t,0]),2)),u=A(C(a,n/2),[-Math.log(n/2)-Vn(n/2,.5)-Math.LN2,0]);return e?u[0]+u[1]:Math.exp(u[0])*(1+u[1])}let[c,i]=Ic(t,n),r=Ze(n/2,.5,c,i,!0,e);return e?r-Math.LN2:r/2}function xr(t,n){if(n<kc)return[_t(t,n,!0),_t(t,n,!1)];let e=t*t;if(!(n/(n+e)>1e-250)){let r=J(U([n,0]),C(U([t,0]),2)),a=A(C(r,n/2),[-Math.log(n/2)-Vn(n/2,.5)-Math.LN2,0]);return[a[0]+a[1],Math.exp(a[0])*(1+a[1])]}let[s,c]=Ic(t,n),i=cc(n/2,.5,s,c,!0);return[i[0]-Math.LN2,i[1]/2]}function vr(t,n,e,o){if(Number.isNaN(t)||Number.isNaN(n))return NaN;if(n<=0)return NaN;if(!Number.isFinite(t))return t<0?Es(e,o):Ps(e,o);if(!Number.isFinite(n))return V(t,{lowerTail:e,logP:o});if(t===0)return o?-Math.LN2:.5;let s=t<0===e,c=Math.abs(t);if(s)return _t(c,n,o);let i=_t(c,n,!1);return o?Math.log1p(-i):1-i}function _r(t,n,e,o){if(Number.isNaN(t)||Number.isNaN(n))return NaN;let s=On(t,-1/0,1/0,e,o);if(s!==void 0)return s;if(n<=0)return NaN;if(!Number.isFinite(n))return Pt(t,{lowerTail:e,logP:o});let{lower:c,logTarget:i,linearTarget:r}=jn(t,e,o);if(i===-Math.LN2&&r===.5)return 0;let a=n,u,f=(.5*a*Math.log(a)-Math.log(a)-Vn(a/2,.5)-i)/a;if(f>709.79||f>709.77&&_t(Number.MAX_VALUE,a,!0)>i)return c?-1/0:1/0;if(i<-30&&2*f>Math.log(a)+1)u=Math.exp(f);else{let p=Math.abs(Pt(i,{logP:!0}));if(u=p,a>=3){let m=p*p,I=p*(m+1)/4,g=p*((5*m+16)*m+3)/96,b=p*(((3*m+19)*m+17)*m-15)/384,v=p*((((79*m+776)*m+1482)*m-1920)*m-945)/92160;u=p+(I+(g+(b+v/a)/a)/a)/a}}(!(u>0)||!Number.isFinite(u))&&(u=1);let M=Wn({logTarget:i,...r!==void 0&&{linearTarget:r},lower:!1,cdf:p=>_t(p,a,!1),cdfLog:p=>_t(p,a,!0),cdfBoth:p=>xr(p,a),pdfLog:p=>bc(p,a,!0),dlogPdf:p=>-(a+1)*p/(a+p*p),x0:u,lo:0,hi:1/0,positive:!0});return c?-M:M}function Di(t,n,e={}){let{log:o=!1,ncp:s}=e;return s!==void 0&&s!==0?It(t,c=>pc(c,n,s,o)):It(t,c=>kr(c,n,o))}function Ti(t,n,e={}){let{lowerTail:o=!0,logP:s=!1,ncp:c}=e;return c!==void 0&&c!==0?It(t,i=>dc(i,n,c,o,s)):It(t,i=>vr(i,n,o,s))}function yi(t,n,e={}){let{lowerTail:o=!0,logP:s=!1,ncp:c}=e;return c!==void 0&&c!==0?It(t,i=>Nc(i,n,c,o,s)):It(t,i=>_r(i,n,o,s))}export{Es as a,Ps as b,Cs as c,On as d,jn as e,Wn as f,Oe as g,Ct as h,je as i,ai as j,Ze as k,cc as l,ui as m,$s as n,vr as o,_r as p,Di as q,Ti as r,yi as s};
@@ -1,2 +0,0 @@
1
- /*! rStats.js 0.15.2 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{c as re}from"./chunk-3WQCKGKP.js";import{e as ne,h as se,j as X,k as I,m as oe}from"./chunk-IBPWRQIF.js";import{a as ae,g as ie}from"./chunk-PEYGUK32.js";import{o as B}from"./chunk-UFT662QZ.js";import{b as ce,c as S}from"./chunk-HBMHR5SS.js";import{b as Y}from"./chunk-PWVQVJTP.js";import{g as D,h as G}from"./chunk-2CUKVVRO.js";import{b as ee,c as te,d as V,f as q,g as C,i as W}from"./chunk-LG74QY5U.js";function j(e){if(e.kind==="factor")return ce(e);let t=[...new Set(e.values)].sort((s,o)=>s-o),n=[...new Set(t.map(Y))],r=new Map(n.map((s,o)=>[s,o]));return{levels:n,codes:e.values.map(s=>r.get(Y(s)))}}function A(e,t){if(e.kind!=="numeric")throw new TypeError(`'${t}' must be a numeric column`);return e.values}function R(e,t){let n=ae(e),r=ie(n,Object.keys(t));return{terms:r,rhsVariables:r.variables.slice(r.response===0?1:0)}}function fe(e){if(typeof e!="string")throw new TypeError("the formula must be a string");let t=e.indexOf("~");return t<0?void 0:{lhs:e.slice(0,t).trim(),rhs:e.slice(t+1)}}var Ae=/^Pair\s*\(\s*([A-Za-z.][A-Za-z0-9._]*)\s*,\s*([A-Za-z.][A-Za-z0-9._]*)\s*\)$/,F="'formula' missing or incorrect",le=(e,t)=>t.length===0&&e.terms.length===0&&e.intercept;function Ve(e,t,n){let r=fe(e),s=r===void 0?null:Ae.exec(r.lhs);if(s!==null){let{terms:m,rhsVariables:p}=R(`~${r.rhs}`,t);if(!n||!le(m,p))throw new Error(F);let w=S(t,[s[1],s[2]]);return{kind:"paired",x:A(w.variables[0],s[1]),y:A(w.variables[1],s[2])}}let{terms:o,rhsVariables:c}=R(e,t);if(o.response<0)throw new Error(F);let i=o.variables[0];if(n&&le(o,c))return{kind:"one",x:A(S(t,[i]).variables[0],i)};if(c.length!==1||o.terms.length!==1)throw new Error(F);let a=S(t,[i,c[0]],{dropUnusedLevels:!0}),l=A(a.variables[0],i),u=j(a.variables[1]);if(u.levels.length!==2)throw new Error("grouping factor must have exactly 2 levels");return{kind:"two",x:l.filter((m,p)=>u.codes[p]===0),y:l.filter((m,p)=>u.codes[p]===1),levels:[u.levels[0],u.levels[1]]}}function Ie(e,t){let n=Ve(e,t,!1);if(n.kind!=="two")throw new Error(F);return n}function je(e,t){let{terms:n,rhsVariables:r}=R(e,t);if(n.response<0)throw new Error(F);if(r.length!==1)throw new Error("'formula' should be of the form response ~ group");let s=n.variables[0],o=S(t,[s,r[0]],{dropUnusedLevels:!0});return{values:A(o.variables[0],s),group:j(o.variables[1])}}function ze(e,t){let n=t.levels.map(()=>[]);return e.forEach((r,s)=>n[t.codes[s]].push(r)),n}function Ue(e,t){let{terms:n,rhsVariables:r}=R(e,t);if(n.response<0||r.length===0)throw new Error(F);let s=n.variables[0],o=S(t,[s,...r],{dropUnusedLevels:!0}),c=o.variables.slice(1).map(j),i=o.rows.map((a,l)=>{let u=0,m=1;for(let p of c)u+=p.codes[l]*m,m*=p.levels.length;return u});return{values:A(o.variables[0],s),groups:i}}var ue="incorrect specification for 'formula'";function Ze(e,t){let n=fe(e),r=n?.rhs.split("|");if(n===void 0||n.lhs===""||r.length!==2)throw new Error(ue);let s=y=>{let{terms:E,rhsVariables:h}=R(y,t);if(h.length!==1||E.terms.length!==1)throw new Error(ue);return h[0]},{terms:o}=R(`${n.lhs} ~ 1`,t),c=o.variables[0],i=s(`~${r[0]}`),a=s(`~${r[1]}`),l=S(t,[c,i,a],{dropUnusedLevels:!0}),u=A(l.variables[0],c),m=j(l.variables[1]),p=j(l.variables[2]),w=p.levels.map(()=>m.levels.map(()=>NaN)),N=p.levels.map(()=>m.levels.map(()=>0));if(u.forEach((y,E)=>{let h=p.codes[E],g=m.codes[E];N[h][g]++,w[h][g]=y}),N.some(y=>y.some(E=>E!==1)))throw new Error("not an unreplicated complete block design");return w}function me(e,t){let{terms:n,rhsVariables:r}=R(e,t);if(n.response>=0)throw new Error("'formula' missing or invalid");if(r.length!==2)throw new Error("invalid formula");let s=S(t,r);return{x:A(s.variables[0],r[0]),y:A(s.variables[1],r[1])}}function he(e){if(e===void 0)return"two.sided";let n=["two.sided","less","greater"].filter(r=>r.startsWith(e));if(e.length===0||n.length!==1)throw new RangeError(`invalid alternative "${e}" (expected "two.sided", "less" or "greater")`);return n[0]}function pe(e){if(!(Number.isFinite(e)&&e>=0&&e<=1))throw new RangeError("confLevel must be a number between 0 and 1")}function Ge(e){if(!(Number.isFinite(e)&&e>0&&e<1))throw new RangeError("'conf.level' must be a single number between 0 and 1")}var Se=["pearson","kendall","spearman"];function Te(e){if(e===void 0)return"pearson";let t=Se.filter(n=>n.startsWith(e));if(e.length===0||t.length!==1)throw new RangeError(`invalid method "${e}"`);return t[0]}function de(e){if(!(e[0]>0))return[Math.sqrt(e[0]),0];let t=Math.sqrt(e[0]),n=q(e,te(t,t));return ee(t,n[0]/(2*t))}function we(e){let t=ne(e);if(!Number.isFinite(t[0]))return;let n=e.map(o=>q([o,0],t)),r=0;for(let o of n)r=Math.max(r,Math.abs(o[0]));if(r===0)return n;let s=2**-Math.max(-1022,Math.floor(Math.log2(r)));return n.map(o=>[o[0]*s,o[1]*s])}function H(e,t){let n=e.length;if(n<2)return[NaN,0];let r=we(e),s=we(t);if(r===void 0||s===void 0)return[NaN,0];let o=[0,0],c=[0,0],i=[0,0];for(let l=0;l<n;l++)o=V(o,C(r[l],s[l])),c=V(c,C(r[l],r[l])),i=V(i,C(s[l],s[l]));if(c[0]===0||i[0]===0)return[NaN,0];let a=W(o,C(de(c),de(i)));return a[0]>=1?[1,0]:a[0]<=-1?[-1,0]:a}function ge(e,t){let n=C(q([1,0],e),V([1,0],e));return Math.sqrt(t)*e[0]/Math.sqrt(n[0])}function De(e){return Math.abs(e[0])<.5?Math.atanh(e[0]):.5*Math.log(V([1,0],e)[0]/q([1,0],e)[0])}function Ne(e,t,n){return n==="less"?B(e,t,!0,!1):n==="greater"?B(e,t,!1,!1):2*Math.min(B(e,t,!0,!1),B(e,t,!1,!1))}function Re(e,t){return t==="less"?D(e):t==="greater"?D(e,{lowerTail:!1}):2*Math.min(D(e),D(e,{lowerTail:!1}))}function K(e,t){let n=e.length,r=0;for(let u=0;u<n;u++){let m=e[u],p=t[u];for(let w=u+1;w<n;w++){let N=(e[w]>m?1:0)-(e[w]<m?1:0),y=(t[w]>p?1:0)-(t[w]<p?1:0);r+=N*y}}let s=I(e),o=I(t),c=n*(n-1)/2,i=s.reduce((u,m)=>u+m*(m-1)/2,0),a=o.reduce((u,m)=>u+m*(m-1)/2,0),l=n<2||i===c||a===c?NaN:i===0&&a===0?r/c:r/Math.sqrt((c-i)*(c-a));return{s:r,tau:l,ties:s.length>0||o.length>0,tx:s,ty:o}}function be(e,t){let n=e*(e-1)/2;if(t<0)return 0;if(t>=n)return 1;let r=new Float64Array(t+1);r[0]=1;for(let o=2;o<=e;o++){let c=new Float64Array(t+1),i=0;for(let l=0;l<=t;l++)i+=r[l],c[l]=i;let a=new Float64Array(t+1);for(let l=0;l<=t;l++)a[l]=(c[l]-(l>=o?c[l-o]:0))/o;r=a}let s=0;for(let o=t;o>=0;o--)s+=r[o];return Math.min(1,s)}var ve=new Map;function Le(e){let t=ve.get(e);if(t!==void 0)return t;let n=e*(e*e-1)/3,r=1<<e,s=new Array(r);s[0]=new Float64Array(n+1),s[0][0]=1;let o=i=>{let a=0;for(;i;i&=i-1)a++;return a};for(let i=0;i<r;i++){let a=s[i];if(a===void 0)continue;let l=o(i);for(let u=0;u<e;u++){if(i&1<<u)continue;let m=(u-l)**2,p=i|1<<u,w=s[p]??=new Float64Array(n+1);for(let N=0;N+m<=n;N++)a[N]&&(w[N+m]+=a[N])}i!==r-1&&(s[i]=void 0)}let c=s[r-1];return ve.set(e,c),c}var x=[.2274,.2531,.1745,.0758,.1033,.3932,.0879,.0151,.0072,.0831,.0131,46e-5];function ye(e,t,n){let r=t;r%2!==0&&(r+=1);let s=1/e,o=(6*(r-1)*s/(e*e-1)-1)*Math.sqrt(1/s-1),c=o*o,a=o*s*(x[0]+s*(x[1]+x[2]*s)+c*(-x[3]+s*(x[4]+x[5]*s)-c*s*(x[6]+x[7]*s-c*(x[8]-x[9]*s+c*s*(x[10]-x[11]*c)))))/Math.exp(c/2),l=n?D(o)-a:a+D(o,{lowerTail:!1});return Math.min(1,Math.max(0,l))}function Me(e,t,n){let r=e*(e*e-1)/3;if(e<=9){let s=Le(e),o=1;for(let i=2;i<=e;i++)o*=i;let c=0;if(n)for(let i=Math.min(t,r);i>=0;i--)c+=s[i];else for(let i=r;i>=Math.max(t,0);i--)c+=s[i];return c/o}return n?t+1>r?1:t+1<=0?0:ye(e,t+1,!0):t<=0?1:t>r?0:ye(e,t,!1)}function _e(e,t,n={}){if(typeof e=="string"){let r=me(e,t);return _e(r.x,r.y,n)}return Ce(e,t,n)}function Ce(e,t,n){if(e.length!==t.length)throw new TypeError("x and y must have the same length");let r=he(n.alternative),s=Te(n.method),o=n.continuity??!1,[c,i]=oe(Array.from(e),Array.from(t)),a=c.length;if(s==="pearson"){let f=n.confLevel??.95;if(pe(f),a<3)throw new Error("not enough finite observations");let d=H(c,i),k=a-2,b=Number.isNaN(d[0])?NaN:ge(d,k),M={method:"Pearson's product-moment correlation",alternative:r,statistic:b,statisticName:"t",parameter:k,parameterName:"df",pValue:Ne(b,k,r),estimate:d[0],estimateNames:"cor",nullValue:0,nullValueName:"correlation"};if(a>3){let z=De(d),L=1/Math.sqrt(a-3),_=T=>Math.tanh(z+T),$;if(r==="less")$=[-1,_(L*G(f))];else if(r==="greater")$=[_(-L*G(f)),1];else{let T=L*G((1+f)/2);$=[_(-T),_(T)]}M.confInt=$,M.confLevel=f}return M}if(a<2)throw new Error("not enough finite observations");if(s==="kendall"){let f=K(c,i),d={method:"Kendall's rank correlation tau",alternative:r,estimate:f.tau,estimateNames:"tau",nullValue:0,nullValueName:"tau"};if(Number.isNaN(f.tau))return{...d,statistic:NaN,statisticName:"T",pValue:NaN};if((n.exact??a<50)&&!f.ties){let v=a*(a-1)/2,P=(f.s+v)/2,U=be(a,P),Z=be(a,v-P),Ee=r==="less"?U:r==="greater"?Z:Math.min(1,2*Math.min(U,Z));return{...d,statistic:P,statisticName:"T",pValue:Ee}}let b=(v,P)=>P.reduce((U,Z)=>U+v(Z),0),M=v=>v*(v-1),z=v=>v*(v-1)*(v-2),L=v=>v*(v-1)*(2*v+5),_=(a*(a-1)*(2*a+5)-b(L,f.tx)-b(L,f.ty))/18+b(z,f.tx)*b(z,f.ty)/(9*a*(a-1)*(a-2))+b(M,f.tx)*b(M,f.ty)/(2*a*(a-1)),T=(o?Math.sign(f.s)*(Math.abs(f.s)-1):f.s)/Math.sqrt(_);return{...d,statistic:T,statisticName:"z",pValue:Re(T,r)}}let l=X(c),u=X(i),m=H(l,u),p=a*a*a-a,w=p*(1-m[0])/6,N={method:"Spearman's rank correlation rho",alternative:r,statistic:w,statisticName:"S",estimate:m[0],estimateNames:"rho",nullValue:0,nullValueName:"rho"};if(Number.isNaN(m[0]))return{...N,pValue:NaN};let y=I(c).length>0||I(i).length>0;if((n.exact??a<=1290)&&!y&&a<=1290){let f=Math.round(w),d=Me(a,f,!0),k=Me(a,f,!1),b=r==="greater"?d:r==="less"?k:Math.min(1,2*Math.min(d,k));return{...N,pValue:b}}let h=m;if(o){let f=W([6,0],[p,0]);h=W(V(m,f),V([1,0],f)),Math.abs(h[0])>=1&&(h=[Math.sign(h[0]),0])}let g=ge(h,a-2);return{...N,pValue:Ne(g,a-2,r)}}function Fe(e,t){let n=e.length,r=new Array(n);if(t==="first"||t==="last"||t==="random"){let c=t==="random"?re(n):[],i=Array.from({length:n},(a,l)=>l);return i.sort((a,l)=>{let u=e[a]-e[l];return u!==0?u:t==="first"?a-l:t==="last"?l-a:c[a]-c[l]||a-l}),i.forEach((a,l)=>r[a]=l+1),r}let s=Array.from({length:n},(c,i)=>i).sort((c,i)=>e[c]-e[i]||c-i),o=0;for(;o<n;){let c=o;for(;c+1<n&&e[s[c+1]]===e[s[o]];)c++;let i=t==="average"?(o+c+2)/2:t==="min"?o+1:c+1;for(let a=o;a<=c;a++)r[s[a]]=i;o=c+1}return r}function J(e,t={}){let n=t.tiesMethod??"average";if(!["average","first","last","random","max","min"].includes(n))throw new RangeError(`invalid tiesMethod "${n}"`);let r=t.naLast??"last",s=Array.from(e),o=s.filter(m=>!Number.isNaN(m)),c=Fe(o,n),i=s.length-o.length,a=[],l=0,u=0;for(let m of s)Number.isNaN(m)?(u++,a.push(r==="keep"?NaN:r==="last"?o.length+u:u)):a.push(r==="first"?c[l++]+i:c[l++]);return a}var Oe=["pearson","kendall","spearman"],$e=["all.obs","complete.obs","pairwise.complete.obs","everything","na.or.complete"];function xe(e,t,n,r){if(e===void 0)return n;if(t.includes(e))return e;let s=t.filter(o=>o.startsWith(e));if(e.length===0||s.length!==1)throw new RangeError(`invalid '${r}' argument`);return s[0]}function O(e){return e.length>0&&Array.isArray(e[0])}function ke(e){if(!O(e))return[Array.from(e)];let t=e[0].length;return Array.from({length:t},(n,r)=>e.map(s=>s[r]))}function Q(e,t,n,r){let s=xe(n.method,Oe,"pearson","method"),o=xe(n.use,$e,"everything","use");if(t===void 0&&!O(e))throw new TypeError("supply both 'x' and 'y' or a matrix-like 'x'");let c=ke(e),i=t===void 0?c:ke(t),a=c[0]?.length??0;if(i.some(h=>h.length!==a))throw new RangeError("incompatible dimensions");let l=[...c,...i];if(o==="all.obs"&&l.some(h=>h.some(Number.isNaN)))throw new RangeError("missing observations in cov/cor");if(!r&&o==="pairwise.complete.obs"&&s!=="pearson")throw new RangeError("cannot handle 'pairwise.complete.obs'");let u;if((o==="complete.obs"||o==="na.or.complete")&&(u=Array.from({length:a},(h,g)=>l.every(f=>!Number.isNaN(f[g]))),!u.some(Boolean))){if(o==="complete.obs")throw new RangeError("no complete element pairs");return t===void 0||O(e)||O(t)?c.map(()=>i.map(()=>NaN)):NaN}let m=h=>{let g=u===void 0?h:h.filter((f,d)=>u[d]);return s==="spearman"&&o!=="pairwise.complete.obs"?J(g,{naLast:"keep"}):g},p=c.map(m),w=t===void 0?p:i.map(m),N=(h,g)=>{let f=h,d=g;if(o==="pairwise.complete.obs"){let k=h.map((b,M)=>!Number.isNaN(b)&&!Number.isNaN(g[M]));f=h.filter((b,M)=>k[M]),d=g.filter((b,M)=>k[M]),s==="spearman"&&(f=J(f),d=J(d))}else if(f.some(Number.isNaN)||d.some(Number.isNaN))return NaN;return f.length<2?NaN:s==="kendall"?r?K(f,d).tau:2*K(f,d).s:r?H(f,d)[0]:se(f,d)},y=p.map(h=>w.map(g=>N(h,g))),E=u===void 0?a:u.filter(Boolean).length;return r&&t===void 0&&o!=="pairwise.complete.obs"&&E>=2&&y.forEach((h,g)=>h[g]=1),t!==void 0&&!O(e)&&!O(t)?y[0][0]:y}function it(e,t,n={}){return t!==void 0&&!Array.isArray(t)&&!ArrayBuffer.isView(t)?Q(e,void 0,t,!1):Q(e,t,n,!1)}function ct(e,t,n={}){return t!==void 0&&!Array.isArray(t)&&!ArrayBuffer.isView(t)?Q(e,void 0,t,!0):Q(e,t,n,!0)}export{Ve as a,Ie as b,je as c,ze as d,Ue as e,Ze as f,he as g,pe as h,Ge as i,H as j,_e as k,J as l,it as m,ct as n};
@@ -1,2 +0,0 @@
1
- /*! rStats.js 0.15.2 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- function R(l,i){return{nrow:l,ncol:i,data:new Float64Array(l*i)}}function L(l){return l.length>0&&typeof l[0]!="number"}function I(l){let i=l.length,r=i===0?0:l[0].length,n=R(i,r);for(let a=0;a<i;a++){let s=l[a];if(s.length!==r)throw new TypeError("all rows of the matrix must have the same length");for(let o=0;o<r;o++)n.data[a+o*i]=s[o]}return n}function P(l){if(L(l))return I(l);let i=l;return{nrow:i.length,ncol:1,data:Float64Array.from(i)}}function $(l){let i=[];for(let r=0;r<l.nrow;r++){let n=new Array(l.ncol);for(let a=0;a<l.ncol;a++)n[a]=l.data[r+a*l.nrow];i.push(n)}return i}function W(l){let i=R(l.ncol,l.nrow);for(let r=0;r<l.ncol;r++)for(let n=0;n<l.nrow;n++)i.data[r+n*l.ncol]=l.data[n+r*l.nrow];return i}function O(l,i="the matrix"){if(l.nrow!==l.ncol)throw new TypeError(`${i} must be square (got ${l.nrow} x ${l.ncol})`)}function H(l,i={}){let r=I(l);if(i.lapack){let{tau:o,pivot:c}=mt(r),e=Array.from(o);return{qr:$(r),rank:Math.min(r.nrow,r.ncol),qraux:e,pivot:c.map(t=>t-1),useLapack:!0}}for(let o of r.data)if(!Number.isFinite(o))throw new RangeError("the matrix contains NaN or infinite values");let{qraux:n,pivot:a,rank:s}=wt(r,i.tol??1e-7);return{qr:$(r),rank:s,qraux:Array.from(n),pivot:a.map(o=>o-1),useLapack:!1}}function S(l,i,r){let n=0;for(let s=0;s<r;s++)n=Math.max(n,Math.abs(l[i+s]));if(n===0||!Number.isFinite(n))return n;let a=0;for(let s=0;s<r;s++){let o=l[i+s]/n;a+=o*o}return n*Math.sqrt(a)}function wt(l,i){let r=l.nrow,n=l.ncol,a=l.data,s=new Float64Array(n),o=new Float64Array(n),c=new Float64Array(n),e=Array.from({length:n},(f,m)=>m+1);for(let f=0;f<n;f++)s[f]=S(a,f*r,r),o[f]=s[f],c[f]=s[f]===0?1:s[f];let t=new Float64Array(r),u=Math.min(r,n),w=n;for(let f=0;f<u;f++){for(;f<w&&s[f]<c[f]*i;){t.set(a.subarray(f*r,(f+1)*r));let[d,g,h,M]=[s[f],o[f],c[f],e[f]];a.copyWithin(f*r,(f+1)*r,n*r),a.set(t,(n-1)*r),s.copyWithin(f,f+1),o.copyWithin(f,f+1),c.copyWithin(f,f+1),e.copyWithin(f,f+1),s[n-1]=d,o[n-1]=g,c[n-1]=h,e[n-1]=M,w--}if(f===r-1)break;let m=f*r,p=S(a,m+f,r-f);if(p!==0){a[m+f]!==0&&(p=Math.sign(a[m+f])*Math.abs(p));for(let d=f;d<r;d++)a[m+d]/=p;a[m+f]=1+a[m+f];for(let d=f+1;d<n;d++){let g=d*r,h=0;for(let y=f;y<r;y++)h-=a[m+y]*a[g+y];h/=a[m+f];for(let y=f;y<r;y++)a[g+y]+=h*a[m+y];if(s[d]===0)continue;let M=1-(Math.abs(a[g+f])/s[d])**2;M=Math.max(M,0);let j=M;M=1+.05*M*(s[d]/o[d])**2,M!==1?s[d]*=Math.sqrt(j):(s[d]=S(a,g+f+1,r-f-1),o[d]=s[d])}s[f]=a[m+f],a[m+f]=-p}}return{qraux:s,pivot:e,rank:Math.min(w,r)}}function mt(l){let i=l.nrow,r=l.ncol,n=l.data,a=Math.min(i,r),s=new Float64Array(a),o=Array.from({length:r},(u,w)=>w+1),c=new Float64Array(r),e=new Float64Array(r);for(let u=0;u<r;u++)c[u]=S(n,u*i,i),e[u]=c[u];let t=Math.sqrt(2**-53);for(let u=0;u<a;u++){let w=u;for(let m=u+1;m<r;m++)Math.abs(c[m])>Math.abs(c[w])&&(w=m);if(w!==u){for(let m=0;m<i;m++){let p=n[m+w*i];n[m+w*i]=n[m+u*i],n[m+u*i]=p}[o[w],o[u]]=[o[u],o[w]],c[w]=c[u],e[w]=e[u]}let f=u*i;if(s[u]=U(n,f+u,i-u),u<r-1){let m=n[f+u];n[f+u]=1,Q(n,f+u,i-u,s[u],l,u,u+1,r-u-1),n[f+u]=m}for(let m=u+1;m<r;m++){if(c[m]===0)continue;let p=1-(Math.abs(n[u+m*i])/c[m])**2;p=Math.max(p,0),p*(c[m]/e[m])**2<=t?u<i-1?(c[m]=S(n,m*i+u+1,i-u-1),e[m]=c[m]):(c[m]=0,e[m]=0):c[m]*=Math.sqrt(p)}}return{tau:s,pivot:o}}function U(l,i,r){if(r<=1)return 0;let n=S(l,i+1,r-1);if(n===0)return 0;let a=l[i],s=-Math.sign(a||1)*Math.hypot(a,n),o=2**-1022/2**-53,c=0;if(Math.abs(s)<o){let u=1/o;do{c++;for(let w=1;w<r;w++)l[i+w]*=u;s*=u,a*=u}while(Math.abs(s)<o&&c<20);n=S(l,i+1,r-1),s=-Math.sign(a||1)*Math.hypot(a,n)}let e=(s-a)/s,t=1/(a-s);for(let u=1;u<r;u++)l[i+u]*=t;for(let u=0;u<c;u++)s*=o;return l[i]=s,e}function Q(l,i,r,n,a,s,o,c){if(n===0)return;let e=a.nrow,t=a.data;for(let u=o;u<o+c;u++){let w=s+u*e,f=0;for(let m=0;m<r;m++)f+=t[w+m]*l[i+m];f*=n;for(let m=0;m<r;m++)t[w+m]-=l[i+m]*f}}function V(l){return{a:I(l.qr),qraux:l.qraux,rank:l.rank,pivot:l.pivot.map(i=>i+1),lapack:l.useLapack}}function X(l,i){let r=P(i);if(r.nrow!==l.a.nrow)throw new TypeError(`qr and y must have the same number of rows (${l.a.nrow} and ${r.nrow})`);return r}function _(l,i){return L(l)?$(i):Array.from(i.data)}function C(l,i,r,n=l.rank){let{a,qraux:s}=l,o=a.nrow;if(l.lapack){let t=Math.min(o,a.ncol),u=r?B(0,t):B(0,t).reverse();for(let w of u){let f=a.data[w+w*o];a.data[w+w*o]=1,Q(a.data,w+w*o,o-w,s[w],i,w,0,i.ncol),a.data[w+w*o]=f}return}let c=Math.min(n,o-1),e=r?B(0,c):B(0,c).reverse();for(let t of e){if(s[t]===0)continue;let u=t*o,w=a.data[u+t];a.data[u+t]=s[t];for(let f=0;f<i.ncol;f++){let m=f*o,p=0;for(let d=t;d<o;d++)p-=a.data[u+d]*i.data[m+d];p/=a.data[u+t];for(let d=t;d<o;d++)i.data[m+d]+=p*a.data[u+d]}a.data[u+t]=w}}function B(l,i){return Array.from({length:Math.max(0,i-l)},(r,n)=>l+n)}function St(l,i){let r=V(l),n=X(r,i);return C(r,n,!0),_(i,n)}function Ct(l,i){let r=V(l),n=X(r,i);return C(r,n,!1),_(i,n)}function pt(l,i){let r=V(l),n=X(r,i),a=r.a.ncol,s=r.a.nrow,o=r.lapack?Math.min(s,a):r.rank;C(r,n,!0);for(let e=0;e<n.ncol;e++){let t=e*s;for(let u=o-1;u>=0;u--){let w=r.a.data[u+u*s];if(w===0)throw new Error("exact singularity in qrCoef");n.data[t+u]/=w;let f=-n.data[t+u];for(let m=0;m<u;m++)n.data[t+m]+=f*r.a.data[m+u*s]}}let c=R(a,n.ncol);c.data.fill(NaN);for(let e=0;e<n.ncol;e++)for(let t=0;t<o;t++)c.data[r.pivot[t]-1+e*a]=n.data[t+e*s];return _(i,c)}function tt(l,i,r,n){let a=V(l);if(a.lapack)throw new TypeError("not supported for a QR decomposition computed with lapack: true");let s=n??a.rank;if(!Number.isInteger(s)||s<0||s>a.rank)throw new RangeError(`invalid k (got ${s})`);let o=X(a,i),c=a.a.nrow;if(s===0)return _(i,o);if(c===1)return r||o.data.fill(0),_(i,o);C(a,o,!0,s);for(let e=0;e<o.ncol;e++)r?o.data.fill(0,e*c+s,(e+1)*c):o.data.fill(0,e*c,e*c+s);return C(a,o,!1,s),_(i,o)}function Lt(l,i){return tt(l,i,!1)}function Pt(l,i,r={}){return tt(l,i,!0,r.k)}function _t(l,i={}){let r=V(l),n=r.a.nrow,a=i.complete?n:Math.min(n,r.a.ncol),s=i.dvec??new Array(a).fill(1);if(s.length!==a)throw new RangeError(`dvec must have length ${a}`);let o=R(n,a);for(let c=0;c<a;c++)o.data[c+c*n]=s[c];return C(r,o,!1),$(o)}function ot(l,i={}){let r=I(l.qr),n=i.complete?r.nrow:Math.min(r.nrow,r.ncol),a=R(n,r.ncol);for(let s=0;s<r.ncol;s++)for(let o=0;o<=Math.min(s,n-1);o++)a.data[o+s*n]=r.data[o+s*r.nrow];return $(a)}function Qt(l,i={}){let r=V(l),n=r.a.nrow,a=r.a.ncol,s=i.complete??!1,o=i.ncol??(s?n:Math.min(n,a));if(!Number.isInteger(o)||o<0)throw new RangeError(`invalid ncol (got ${o})`);if(r.pivot.some((w,f)=>w!==f+1)&&o<a)throw new RangeError("ncol must be at least the number of columns because the decomposition is pivoted");let e=R(n,o);for(let w=0;w<o;w++)if(w<a)for(let f=0;f<=Math.min(w,n-1);f++)e.data[f+w*n]=r.a.data[f+w*n];else w<n&&(e.data[w+w*n]=1);C(r,e,!1);let t=Math.min(o,a),u=R(n,o);u.data.set(e.data);for(let w=0;w<t;w++){let f=r.pivot[w]-1;f<t&&u.data.set(e.data.subarray(w*n,(w+1)*n),f*n)}return $(u)}function Vt(l,i,r={}){let n=Array.isArray(l)?H(l,{tol:r.tol??1e-7}):l,a=n.qr.length,s=a===0?0:n.qr[0].length;if(n.rank!==Math.min(a,s))throw new Error("singular matrix in qrSolve");if(i===void 0&&a!==s)throw new TypeError("only square matrices can be inverted");let o=i??Array.from({length:a},(t,u)=>Array.from({length:a},(w,f)=>u===f?1:0)),c=pt(n,o),e=t=>Number.isNaN(t)?0:t;return L(o)?c.map(t=>t.map(e)):c.map(e)}function Ut(l,i={}){let r=I(l);for(let w of r.data)if(!Number.isFinite(w))throw new RangeError("the matrix contains NaN or infinite values");let n=Math.min(r.nrow,r.ncol),a=Math.min(i.nu??n,r.nrow),s=Math.min(i.nv??n,r.ncol);for(let[w,f]of[["nu",a],["nv",s]])if(!Number.isInteger(f)||f<0)throw new RangeError(`${w} must be a non-negative integer`);let o=r.nrow<r.ncol,c=et(o?W(r):r,o?s:a,o?a:s),e={d:Array.from(c.d)},[t,u]=o?[c.v,c.u]:[c.u,c.v];return a>0&&(e.u=$(rt(t,a))),s>0&&(e.v=$(rt(u,s))),e}function nt(l){return et(l.nrow<l.ncol?W(l):l,0,0).d}function rt(l,i){return{nrow:l.nrow,ncol:i,data:l.data.slice(0,l.nrow*i)}}function et(l,i,r){let n=l.nrow,a=l.ncol,s=new Float64Array(a);if(a===0)return{d:s,u:R(n,n),v:R(0,0)};let o={nrow:n,ncol:a,data:l.data.slice()},c=new Float64Array(a),e=new Float64Array(a),t=new Float64Array(a);for(let h=0;h<a;h++){let M=h*n;if(e[h]=U(o.data,M+h,n-h),s[h]=o.data[M+h],h<a-1&&(o.data[M+h]=1,Q(o.data,M+h,n-h,e[h],o,h,h+1,a-h-1),o.data[M+h]=s[h]),h<a-1){let j=new Float64Array(a-h-1);for(let k=0;k<j.length;k++)j[k]=o.data[h+(h+1+k)*n];t[h]=U(j,0,j.length),c[h+1]=j[0],j[0]=1;let y=t[h];if(y!==0)for(let k=h+1;k<n;k++){let q=0;for(let N=0;N<j.length;N++)q+=o.data[k+(h+1+N)*n]*j[N];q*=y;for(let N=0;N<j.length;N++)o.data[k+(h+1+N)*n]-=q*j[N]}j[0]=c[h+1];for(let k=0;k<j.length;k++)o.data[h+(h+1+k)*n]=j[k]}}let u=i===0?0:Math.max(i,a),w;if(u>0){w=R(n,u);for(let h=0;h<u;h++)w.data[h+h*n]=1;for(let h=a-1;h>=0;h--){let M=h*n,j=o.data[M+h];o.data[M+h]=1,Q(o.data,M+h,n-h,e[h],w,h,0,u),o.data[M+h]=j}}let f;if(r>0){f=R(a,a);for(let M=0;M<a;M++)f.data[M+M*a]=1;let h=new Float64Array(a);for(let M=a-2;M>=0;M--){let j=a-M-1;h[0]=1;for(let y=1;y<j;y++)h[y]=o.data[M+(M+1+y)*n];Q(h,0,j,t[M],f,M+1,0,a)}}Mt(s,c,w,f);let m=Array.from({length:a},(h,M)=>M).sort((h,M)=>s[M]-s[h]||h-M),p=Float64Array.from(m,h=>s[h]),d=(h,M)=>{if(h===void 0)return;let j={nrow:h.nrow,ncol:h.ncol,data:h.data.slice()};for(let y=0;y<M;y++)j.data.set(h.data.subarray(m[y]*h.nrow,(m[y]+1)*h.nrow),y*h.nrow);return j},g={d:p};return w&&(g.u=d(w,a)),f&&(g.v=d(f,a)),g}function Mt(l,i,r,n){let a=l.length,s=Number.EPSILON,o=0;for(let t=0;t<a;t++)o=Math.max(o,Math.abs(l[t])+Math.abs(i[t]));let c=(t,u,w,f)=>{if(!r)return;let m=r.nrow;for(let p=0;p<m;p++){let d=r.data[p+t*m],g=r.data[p+u*m];r.data[p+t*m]=d*w+g*f,r.data[p+u*m]=g*w-d*f}},e=(t,u,w,f)=>{if(n)for(let m=0;m<a;m++){let p=n.data[m+t*a],d=n.data[m+u*a];n.data[m+t*a]=p*w+d*f,n.data[m+u*a]=d*w-p*f}};for(let t=a-1;t>=0;t--)for(let u=0;;u++){let w=t,f=!0;for(;w>=0;w--){if(w===0||Math.abs(i[w])<=s*o){f=!1;break}if(Math.abs(l[w-1])<=s*o)break}if(f){let q=w-1,N=0,F=1;for(let A=w;A<=t;A++){let E=F*i[A];if(i[A]=N*i[A],Math.abs(E)<=s*o)break;let b=l[A],v=Math.hypot(E,b);l[A]=v,N=b/v,F=-E/v,c(q,A,N,F)}}let m=l[t];if(w===t){if(m<0&&(l[t]=-m,n))for(let q=0;q<a;q++)n.data[q+t*a]=-n.data[q+t*a];break}if(u>=75)throw new Error("the singular value decomposition did not converge");let p=l[w],d=t-1,g=l[d],h=i[d],M=i[t],j=((g-m)*(g+m)+(h-M)*(h+M))/(2*M*g);h=Math.hypot(j,1),j=((p-m)*(p+m)+M*(g/(j+(j>=0?Math.abs(h):-Math.abs(h)))-M))/p;let y=1,k=1;for(let q=w;q<=d;q++){let N=q+1;h=i[N],g=l[N],M=k*h,h=y*h;let F=Math.hypot(j,M);i[q]=F,y=j/F,k=M/F,j=p*y+h*k,h=h*y-p*k,M=g*k,g*=y,e(q,N,y,k),F=Math.hypot(j,M),l[q]=F,F!==0&&(y=j/F,k=M/F),j=y*h+k*g,p=y*g-k*h,c(q,N,y,k)}i[w]=0,i[t]=j,l[t]=p}}function Ht(l,i={}){let r=I(l),n=i.type??"O";if(n.length!==1)throw new RangeError(`type must be a single character (got "${n}")`);switch(n.toUpperCase()){case"O":case"1":return D(r);case"I":return K(r);case"F":case"E":return dt(r);case"M":return at(r);case"2":return bt(r);default:throw new RangeError(`type must be one of "O", "I", "F", "M" and "2" (got "${n}")`)}}function J(l,i){return Number.isNaN(l)||Number.isNaN(i)?NaN:Math.max(l,i)}function D(l){let i=0;for(let r=0;r<l.ncol;r++){let n=0;for(let a=0;a<l.nrow;a++)n+=Math.abs(l.data[a+r*l.nrow]);i=J(i,n)}return i}function K(l){let i=new Float64Array(l.nrow);for(let n=0;n<l.ncol;n++)for(let a=0;a<l.nrow;a++)i[a]+=Math.abs(l.data[a+n*l.nrow]);let r=0;for(let n of i)r=J(r,n);return r}function at(l){let i=0;for(let r of l.data)i=J(i,Math.abs(r));return i}function dt(l){let i=at(l);if(i===0||!Number.isFinite(i))return i;let r=0;for(let n of l.data){let a=n/i;r+=a*a}return i*Math.sqrt(r)}function bt(l){if(l.nrow===0||l.ncol===0)return 0;if(l.data.some(Number.isNaN))return NaN;if(l.data.some(i=>!Number.isFinite(i)))throw new RangeError("the matrix contains infinite values");return nt(l)[0]}function Y(l){let i=l.nrow,r=l.ncol,n=l.data,a=Math.min(i,r),s=new Int32Array(a),o=2**-1022,c=0;for(let e=0;e<a;e++){let t=e*i,u=e,w=Math.abs(n[t+e]);for(let f=e+1;f<i;f++){let m=Math.abs(n[t+f]);m>w&&(w=m,u=f)}if(s[e]=u,n[t+u]!==0){if(u!==e)for(let m=0;m<r;m++){let p=n[e+m*i];n[e+m*i]=n[u+m*i],n[u+m*i]=p}let f=n[t+e];if(Math.abs(f)>=o){let m=1/f;for(let p=e+1;p<i;p++)n[t+p]*=m}else for(let m=e+1;m<i;m++)n[t+m]/=f}else c===0&&(c=e+1);for(let f=e+1;f<r;f++){let m=n[e+f*i];if(m===0)continue;let p=-m;for(let d=e+1;d<i;d++)n[d+f*i]+=n[t+d]*p}}return{ipiv:s,info:c}}function gt(l,i,r){let n=l.nrow,a=l.data,s=r.data;for(let o=0;o<r.ncol;o++){let c=o*n;for(let e=0;e<n;e++){let t=i[e];if(t!==e){let u=s[c+e];s[c+e]=s[c+t],s[c+t]=u}}for(let e=0;e<n;e++){let t=s[c+e];if(t!==0)for(let u=e+1;u<n;u++)s[c+u]-=t*a[u+e*n]}for(let e=n-1;e>=0;e--)if(s[c+e]!==0){s[c+e]/=a[e+e*n];let t=s[c+e];for(let u=0;u<e;u++)s[c+u]-=t*a[u+e*n]}}}function T(l,i,r,n,a){let s=l.nrow,o=l.data;if(r)if(i)for(let c=0;c<s;c++){let e=a[c];for(let t=0;t<c;t++)e-=o[t+c*s]*a[t];n||(e/=o[c+c*s]),a[c]=e}else for(let c=s-1;c>=0;c--){let e=a[c];for(let t=s-1;t>c;t--)e-=o[t+c*s]*a[t];n||(e/=o[c+c*s]),a[c]=e}else if(i){for(let c=s-1;c>=0;c--)if(a[c]!==0){n||(a[c]/=o[c+c*s]);let e=a[c];for(let t=c-1;t>=0;t--)a[t]-=e*o[t+c*s]}}else for(let c=0;c<s;c++)if(a[c]!==0){n||(a[c]/=o[c+c*s]);let e=a[c];for(let t=c+1;t<s;t++)a[t]-=e*o[t+c*s]}}function it(l,i){let r=new Float64Array(l),n=new Int32Array(l),a=()=>r.reduce((m,p)=>m+Math.abs(p),0),s=()=>{let m=0;for(let p=1;p<l;p++)Math.abs(r[p])>Math.abs(r[m])&&(m=p);return m},o=()=>{for(let m=0;m<l;m++)r[m]=r[m]>=0?1:-1,n[m]=r[m]};if(r.fill(1/l),i(1,r),l===1)return Math.abs(r[0]);let c=a();o(),i(2,r);let e=s(),t=2,u=5;for(;;){r.fill(0),r[e]=1,i(1,r);let m=c;c=a();let p=!1;for(let g=0;g<l;g++)if((r[g]>=0?1:-1)!==n[g]){p=!0;break}if(!p||c<=m)break;o(),i(2,r);let d=e;if(e=s(),r[d]!==Math.abs(r[e])&&t<u){t++;continue}break}let w=1;for(let m=0;m<l;m++)r[m]=w*(1+m/(l-1)),w=-w;i(1,r);let f=2*(a()/(3*l));return f>c?f:c}function ft(l,i,r){let n=l.nrow;if(n===0)return 1;if(!Number.isFinite(i))throw new RangeError("the matrix contains NaN or infinite values (LAPACK dgecon returned error -5)");if(i===0)return 0;let a=r?1:2,s=it(n,(o,c)=>{o===a?(T(l,!1,!1,!0,c),T(l,!0,!1,!1,c)):(T(l,!0,!0,!1,c),T(l,!1,!0,!0,c))});return Number.isFinite(s)?s===0?0:1/s/i:0}function vt(l,i,r){let n=l.nrow,a=new Float64Array(n);for(let o=0;o<n;o++){let[c,e]=i?[0,o]:[o,n-1];for(let t=c;t<=e;t++)a[r?o:t]+=Math.abs(l.data[t+o*n])}let s=0;for(let o of a)s=Number.isNaN(s)||Number.isNaN(o)?NaN:Math.max(s,o);return s}function st(l,i,r){let n=l.nrow;if(n===0)return 1;let a=vt(l,i,r);if(!(a>0))return 0;let s=r?1:2,o=it(n,(c,e)=>T(l,i,c!==s,!1,e));return Number.isFinite(o)?o===0?0:1/a/o:0}function to(l,i,r={}){let n=I(l);O(n);let a=n.nrow,s;if(i===void 0){s=R(a,a);for(let u=0;u<a;u++)s.data[u+u*a]=1}else if(s=P(i),s.nrow!==a)throw new TypeError(`b (${s.nrow} x ${s.ncol}) is not compatible with a (${a} x ${a})`);let o=D(n),{ipiv:c,info:e}=Y(n);if(e>0)throw new Error(`the system is exactly singular: U[${e}, ${e}] = 0`);let t=r.tol??Number.EPSILON;if(t>0&&Number.isFinite(o)){let u=ft(n,o,!0);if(u<t)throw new Error(`the system is computationally singular: reciprocal condition number = ${u.toPrecision(6)}`)}return gt(n,c,s),i!==void 0&&!L(i)?Array.from(s.data):$(s)}function kt(l,i={}){let r=i.logarithm??!0,n=I(l);O(n);let a=n.nrow,{ipiv:s,info:o}=Y(n);if(o>0)return{modulus:r?-1/0:0,logarithm:r,sign:1};let c=1,e=r?0:1;for(let t=0;t<a;t++){s[t]!==t&&(c=-c);let u=n.data[t+t*a];u<0&&(c=-c),r?e+=Math.log(Math.abs(u)):e*=Math.abs(u)}return{modulus:e,logarithm:r,sign:c}}function oo(l){let{modulus:i,sign:r}=kt(l);return r*Math.exp(i)}function ro(l,i={}){let r=i.norm??"O";if(!["O","1","I"].includes(r))throw new RangeError(`norm must be "O", "I" or "1" (got "${r}")`);let n=r!=="I",a=I(l);if(a.nrow!==a.ncol){let c=a.nrow<a.ncol?$(W(a)):l;return st(I(ot(H(c))),!0,n)}if(i.triangular)return st(a,(i.uplo??"U")==="U",n);let s=n?D(a):K(a);a={...a,data:a.data.slice()};let{info:o}=Y(a);return o>0?0:ft(a,s,n)}function ao(l,i={}){let r=I(l);if(O(r),r.nrow===0)throw new RangeError("the matrix has zero dimension");if(i.pivot){let{pivot:a,rank:s}=jt(r,i.tol??-1);return lt(r),{r:$(r),pivot:a.map(o=>o-1),rank:s}}let n=yt(r);if(n>0)throw new Error(`the matrix is not positive definite: the leading minor of order ${n} is not positive`);return lt(r),$(r)}function lt(l){let i=l.nrow;for(let r=0;r<i;r++)for(let n=r+1;n<i;n++)l.data[n+r*i]=0}function yt(l){let i=l.nrow,r=l.data;for(let n=0;n<i;n++){let a=n*i,s=r[n+a];for(let o=0;o<n;o++)s-=r[o+a]*r[o+a];if(s<=0)return r[n+a]=s,n+1;s=Math.sqrt(s),r[n+a]=s;for(let o=n+1;o<i;o++){let c=o*i,e=r[n+c];for(let t=0;t<n;t++)e-=r[t+a]*r[t+c];r[n+c]=e/s}}return 0}function jt(l,i){let r=l.nrow,n=l.data,a=Array.from({length:r},(w,f)=>f+1),s=(w,f)=>w+f*r,o=(w,f)=>{let m=n[w];n[w]=n[f],n[f]=m},c=0;for(let w=1;w<r;w++)n[s(w,w)]>n[s(c,c)]&&(c=w);let e=n[s(c,c)];if(e<=0||Number.isNaN(e))return{pivot:a,rank:0};let t=i<0?r*Number.EPSILON*e:i,u=new Float64Array(2*r);for(let w=0;w<r;w++){for(let f=w;f<r;f++)w>0&&(u[f]+=n[s(w-1,f)]**2),u[r+f]=n[s(f,f)]-u[f];if(w>0){c=w;for(let f=w+1;f<r;f++)u[r+f]>u[r+c]&&(c=f);if(e=u[r+c],e<=t||Number.isNaN(e))return n[s(w,w)]=e,{pivot:a,rank:w}}if(w!==c){n[s(c,c)]=n[s(w,w)];for(let f=0;f<w;f++)o(s(f,w),s(f,c));for(let f=c+1;f<r;f++)o(s(w,f),s(c,f));for(let f=w+1;f<c;f++)o(s(w,f),s(f,c));[u[w],u[c]]=[u[c],u[w]],[a[w],a[c]]=[a[c],a[w]]}e=Math.sqrt(e),n[s(w,w)]=e;for(let f=w+1;f<r;f++){let m=n[s(w,f)];for(let p=0;p<w;p++)m-=n[s(p,w)]*n[s(p,f)];n[s(w,f)]=m/e}}return{pivot:a,rank:r}}function so(l,i={}){let r=P(l),n=i.size??r.ncol;if(!Number.isInteger(n)||n<1)throw new RangeError(`size must be a positive integer (got ${n})`);if(n>r.ncol)throw new RangeError(`size cannot exceed the number of columns (${r.ncol})`);if(n>r.nrow)throw new RangeError(`size cannot exceed the number of rows (${r.nrow})`);let a=R(n,n);for(let s=0;s<n;s++)for(let o=0;o<=s;o++)a.data[o+s*n]=r.data[o+s*r.nrow];Nt(a);for(let s=0;s<n;s++)for(let o=s+1;o<n;o++)a.data[o+s*n]=a.data[s+o*n];return $(a)}function Nt(l){let i=l.nrow,r=l.data;for(let n=0;n<i;n++)if(r[n+n*i]===0)throw new Error(`element (${n+1}, ${n+1}) is zero, so the inverse cannot be computed`);for(let n=0;n<i;n++){let a=n*i;r[n+a]=1/r[n+a];let s=-r[n+a];for(let o=0;o<n;o++){let c=r[o+a];if(c!==0){for(let e=0;e<o;e++)r[e+a]+=c*r[e+o*i];r[o+a]=c*r[o+o*i]}}for(let o=0;o<n;o++)r[o+a]*=s}for(let n=0;n<i;n++){let a=r[n+n*i];if(n<i-1){let s=0;for(let o=n;o<i;o++)s+=r[n+o*i]*r[n+o*i];r[n+n*i]=s;for(let o=0;o<n;o++)r[o+n*i]*=a;for(let o=n+1;o<i;o++){let c=r[n+o*i];if(c!==0)for(let e=0;e<n;e++)r[e+n*i]+=c*r[e+o*i]}}else for(let s=0;s<=n;s++)r[s+n*i]*=a}}function ct(l,i,r,n){let a=0,s=1;for(let o=0;o<r;o++){let c=l[i+o*n];if(c===0)continue;let e=Math.abs(c);a<e?(s=1+s*(a/e)**2,a=e):s+=(e/a)**2}return a*Math.sqrt(s)}function ut(l,i){let r=i.nrow,n=i.data,a=(h,M)=>h+M*r,s=new Float64Array(r),o=(h,M,j)=>{for(let y=0;y<j;y++)[n[a(y,h)],n[a(y,M)]]=[n[a(y,M)],n[a(y,h)]]},c=(h,M,j)=>{for(let y=j;y<r;y++)[n[a(h,y)],n[a(M,y)]]=[n[a(M,y)],n[a(h,y)]]},e=0,t=r-1;if(l!=="S"){let h=!0;for(;h;){h=!1;for(let M=t;M>=0;M--){let j=!0;for(let y=0;y<=t;y++)if(M!==y&&n[a(M,y)]!==0){j=!1;break}if(j){if(s[t]=M,M!==t&&(o(M,t,t+1),c(M,t,e)),h=!0,t===0)return{ilo:0,ihi:0,scale:s};t--}}}for(h=!0;h;){h=!1;for(let M=e,j=t;M<=j;M++){let y=!0;for(let k=e;k<=t;k++)if(k!==M&&n[a(k,M)]!==0){y=!1;break}y&&(s[e]=M,M!==e&&(o(M,e,t+1),c(M,e,e)),h=!0,e++)}}}for(let h=e;h<=t;h++)s[h]=1;if(l==="P")return{ilo:e,ihi:t,scale:s};let u=2,w=.95,f=2**-1022/Number.EPSILON,m=1/f,p=f*u,d=1/p,g=!0;for(;g;){g=!1;for(let h=e;h<=t;h++){let M=ct(n,a(e,h),t-e+1,1),j=ct(n,a(h,e),t-e+1,r),y=0;for(let A=0;A<=t;A++)y=Math.max(y,Math.abs(n[a(A,h)]));let k=0;for(let A=e;A<r;A++)k=Math.max(k,Math.abs(n[a(h,A)]));if(M===0||j===0)continue;if(Number.isNaN(M+y+j+k))throw new RangeError("the matrix contains NaN or infinite values");let q=j/u,N=1,F=M+j;for(;M<q&&Math.max(N,M,y)<d&&Math.min(j,q,k)>p;)N*=u,M*=u,y*=u,j/=u,q/=u,k/=u;for(q=M/u;q>=j&&Math.max(j,k)<d&&Math.min(N,M,q,y)>p;)N/=u,M/=u,q/=u,y/=u,j*=u,k*=u;if(!(M+j>=w*F)&&!(N<1&&s[h]<1&&N*s[h]<=f)&&!(N>1&&s[h]>1&&s[h]>=m/N)){q=1/N,s[h]=s[h]*N,g=!0;for(let A=e;A<r;A++)n[a(h,A)]=n[a(h,A)]*q;for(let A=0;A<=t;A++)n[a(A,h)]=n[a(A,h)]*N}}}return{ilo:e,ihi:t,scale:s}}function ht(l,i){let{ilo:r,ihi:n,scale:a}=l,s=i.nrow,o=i.ncol,c=i.data;if(s===0||o===0)return;if(r!==n)for(let t=r;t<=n;t++){let u=a[t];for(let w=0;w<o;w++)c[t+w*s]=c[t+w*s]*u}let e=t=>{let u=a[t];if(u!==t)for(let w=0;w<o;w++)[c[t+w*s],c[u+w*s]]=[c[u+w*s],c[t+w*s]]};for(let t=r-1;t>=0;t--)e(t);for(let t=n+1;t<s;t++)e(t)}function uo(l,i={}){let r=I(l);if(O(r),r.nrow===0)throw new RangeError("the matrix has zero dimension");for(let s of r.data)if(!Number.isFinite(s))throw new RangeError("the matrix contains NaN or infinite values");let n=i.symmetric??xt(r),a=!(i.onlyValues??!1);return n?qt(r,a):At(r,a)}function xt(l){let i=l.nrow,r=0,n=0;for(let e=0;e<i;e++)for(let t=0;t<i;t++)r+=Math.abs(l.data[t+e*i]-l.data[e+t*i]),n+=Math.abs(l.data[t+e*i]);let a=100*Number.EPSILON,s=i*i,o=n/s,c=r/s;return(Number.isFinite(o)&&o>a?c/o:c)<=a}function qt(l,i){let r=l.nrow,n=R(r,r);for(let e=0;e<r;e++)for(let t=e;t<r;t++)n.data[t+e*r]=l.data[t+e*r],n.data[e+t*r]=l.data[t+e*r];let a=new Float64Array(r),s=new Float64Array(r);Et(n,a,s),Ft(n,a,s);let o=Array.from(a).reverse();if(!i)return{values:o};let c=R(r,r);for(let e=0;e<r;e++)c.data.set(n.data.subarray((r-1-e)*r,(r-e)*r),e*r);return{values:o,vectors:$(c)}}function Et(l,i,r){let n=l.nrow,a=l.data,s=(o,c)=>o+c*n;for(let o=0;o<n;o++)i[o]=a[s(n-1,o)];for(let o=n-1;o>0;o--){let c=0,e=0;for(let t=0;t<o;t++)c+=Math.abs(i[t]);if(c===0){r[o]=i[o-1];for(let t=0;t<o;t++)i[t]=a[s(o-1,t)],a[s(o,t)]=0,a[s(t,o)]=0}else{for(let f=0;f<o;f++)i[f]/=c,e+=i[f]*i[f];let t=i[o-1],u=Math.sqrt(e);t>0&&(u=-u),r[o]=c*u,e-=t*u,i[o-1]=t-u;for(let f=0;f<o;f++)r[f]=0;for(let f=0;f<o;f++){t=i[f],a[s(f,o)]=t,u=r[f]+a[s(f,f)]*t;for(let m=f+1;m<=o-1;m++)u+=a[s(m,f)]*i[m],r[m]+=a[s(m,f)]*t;r[f]=u}t=0;for(let f=0;f<o;f++)r[f]/=e,t+=r[f]*i[f];let w=t/(e+e);for(let f=0;f<o;f++)r[f]-=w*i[f];for(let f=0;f<o;f++){t=i[f],u=r[f];for(let m=f;m<=o-1;m++)a[s(m,f)]-=t*r[m]+u*i[m];i[f]=a[s(o-1,f)],a[s(o,f)]=0}}i[o]=e}for(let o=0;o<n-1;o++){a[s(n-1,o)]=a[s(o,o)],a[s(o,o)]=1;let c=i[o+1];if(c!==0){for(let e=0;e<=o;e++)i[e]=a[s(e,o+1)]/c;for(let e=0;e<=o;e++){let t=0;for(let u=0;u<=o;u++)t+=a[s(u,o+1)]*a[s(u,e)];for(let u=0;u<=o;u++)a[s(u,e)]-=t*i[u]}}for(let e=0;e<=o;e++)a[s(e,o+1)]=0}for(let o=0;o<n;o++)i[o]=a[s(n-1,o)],a[s(n-1,o)]=0;a[s(n-1,n-1)]=1,r[0]=0}function Ft(l,i,r){let n=l.nrow,a=l.data,s=(t,u)=>t+u*n;for(let t=1;t<n;t++)r[t-1]=r[t];r[n-1]=0;let o=0,c=0,e=Number.EPSILON;for(let t=0;t<n;t++){c=Math.max(c,Math.abs(i[t])+Math.abs(r[t]));let u=t;for(;u<n-1&&Math.abs(r[u])>e*c;)u++;if(u>t){let w=0;do{if(++w>100)throw new Error("the eigendecomposition did not converge");let f=i[t],m=(i[t+1]-f)/(2*r[t]),p=Math.hypot(m,1);m<0&&(p=-p),i[t]=r[t]/(m+p),i[t+1]=r[t]*(m+p);let d=i[t+1],g=f-i[t];for(let N=t+2;N<n;N++)i[N]-=g;o+=g,m=i[u];let h=1,M=h,j=h,y=r[t+1],k=0,q=0;for(let N=u-1;N>=t;N--){j=M,M=h,q=k,f=h*r[N],g=h*m,p=Math.hypot(m,r[N]),r[N+1]=k*p,k=r[N]/p,h=m/p,m=h*i[N]-k*f,i[N+1]=g+k*(h*f+k*i[N]);for(let F=0;F<n;F++)g=a[s(F,N+1)],a[s(F,N+1)]=k*a[s(F,N)]+h*g,a[s(F,N)]=h*a[s(F,N)]-k*g}m=-k*q*j*y*r[t]/d,r[t]=k*m,i[t]=h*m}while(Math.abs(r[t])>e*c)}i[t]=i[t]+o,r[t]=0}for(let t=0;t<n-1;t++){let u=t,w=i[t];for(let f=t+1;f<n;f++)i[f]<w&&(u=f,w=i[f]);if(u!==t){i[u]=i[t],i[t]=w;for(let f=0;f<n;f++){let m=a[s(f,t)];a[s(f,t)]=a[s(f,u)],a[s(f,u)]=m}}}}function At(l,i){let r=l.nrow,n={nrow:r,ncol:r,data:l.data.slice()},a=R(r,r),s=new Float64Array(r),o=new Float64Array(r),c=ut("B",n);$t(n,a),It(n,a,s,o);let e=Array.from(s,(g,h)=>Math.hypot(g,o[h])),t=Array.from({length:r},(g,h)=>h).sort((g,h)=>e[h]-e[g]||g-h),u=o.some(g=>g!==0),w={values:t.map(g=>s[g])};if(u&&(w.valuesIm=t.map(g=>o[g])),!i)return w;ht(c,a);let f=R(r,r),m=R(r,r);for(let g=0;g<r;g++){let h=a.data.subarray(g*r,(g+1)*r);if(o[g]===0)f.data.set(h,g*r);else if(o[g]>0){let M=a.data.subarray((g+1)*r,(g+2)*r);f.data.set(h,g*r),m.data.set(M,g*r),f.data.set(h,(g+1)*r);for(let j=0;j<r;j++)m.data[j+(g+1)*r]=-M[j]}}Rt(f,m);let p=R(r,r),d=R(r,r);return t.forEach((g,h)=>{p.data.set(f.data.subarray(g*r,(g+1)*r),h*r),d.data.set(m.data.subarray(g*r,(g+1)*r),h*r)}),w.vectors=$(p),u&&(w.vectorsIm=$(d)),w}function Rt(l,i){let r=l.nrow;for(let n=0;n<r;n++){let a=n*r,s=0,o=0,c=-1;for(let w=0;w<r;w++){let f=Math.hypot(l.data[a+w],i.data[a+w]);s+=f*f,f>c&&(c=f,o=w)}let e=Math.sqrt(s);if(e===0)continue;let t=l.data[a+o]/c/e,u=-i.data[a+o]/c/e;for(let w=0;w<r;w++){let f=l.data[a+w],m=i.data[a+w];l.data[a+w]=f*t-m*u,i.data[a+w]=f*u+m*t}i.data[a+o]=0}}function $t(l,i){let r=l.nrow,n=l.data,a=i.data,s=(t,u)=>t+u*r,o=new Float64Array(r),c=0,e=r-1;for(let t=c+1;t<=e-1;t++){let u=0;for(let m=t;m<=e;m++)u+=Math.abs(n[s(m,t-1)]);if(u===0)continue;let w=0;for(let m=e;m>=t;m--)o[m]=n[s(m,t-1)]/u,w+=o[m]*o[m];let f=Math.sqrt(w);o[t]>0&&(f=-f),w-=o[t]*f,o[t]=o[t]-f;for(let m=t;m<r;m++){let p=0;for(let d=e;d>=t;d--)p+=o[d]*n[s(d,m)];p/=w;for(let d=t;d<=e;d++)n[s(d,m)]-=p*o[d]}for(let m=0;m<=e;m++){let p=0;for(let d=e;d>=t;d--)p+=o[d]*n[s(m,d)];p/=w;for(let d=t;d<=e;d++)n[s(m,d)]-=p*o[d]}o[t]=u*o[t],n[s(t,t-1)]=u*f}for(let t=0;t<r;t++)for(let u=0;u<r;u++)a[s(t,u)]=t===u?1:0;for(let t=e-1;t>=c+1;t--)if(n[s(t,t-1)]!==0){for(let u=t+1;u<=e;u++)o[u]=n[s(u,t-1)];for(let u=t;u<=e;u++){let w=0;for(let f=t;f<=e;f++)w+=o[f]*a[s(f,u)];w=w/o[t]/n[s(t,t-1)];for(let f=t;f<=e;f++)a[s(f,u)]+=w*o[f]}}}function G(l,i,r,n){if(Math.abs(r)>Math.abs(n)){let o=n/r,c=r+o*n;return[(l+o*i)/c,(i-o*l)/c]}let a=r/n,s=n+a*r;return[(a*l+i)/s,(a*i-l)/s]}function It(l,i,r,n,a=!1){let s=l.nrow,o=l.data,c=i.data,e=(E,b)=>E+b*s,t=s-1,u=0,w=s-1,f=Number.EPSILON,m=0,p=0,d=0,g=0,h=0,M=0,j,y,k,q,N=0;for(let E=0;E<s;E++)for(let b=Math.max(E-1,0);b<s;b++)N+=Math.abs(o[e(E,b)]);let F=0,A=0;for(;t>=u;){let E=t;for(;E>u&&(h=Math.abs(o[e(E-1,E-1)])+Math.abs(o[e(E,E)]),h===0&&(h=N),!(Math.abs(o[e(E,E-1)])<f*h));)E--;if(E===t)o[e(t,t)]=o[e(t,t)]+m,r[t]=o[e(t,t)],n[t]=0,t--,F=0;else if(E===t-1){if(y=o[e(t,t-1)]*o[e(t-1,t)],p=(o[e(t-1,t-1)]-o[e(t,t)])/2,d=p*p+y,M=Math.sqrt(Math.abs(d)),o[e(t,t)]=o[e(t,t)]+m,o[e(t-1,t-1)]=o[e(t-1,t-1)]+m,k=o[e(t,t)],d>=0){M=p>=0?p+M:p-M,r[t-1]=k+M,r[t]=r[t-1],M!==0&&(r[t]=k-y/M),n[t-1]=0,n[t]=0,k=o[e(t,t-1)],h=Math.abs(k)+Math.abs(M),p=k/h,d=M/h,g=Math.sqrt(p*p+d*d),p/=g,d/=g;for(let b=t-1;b<s;b++)M=o[e(t-1,b)],o[e(t-1,b)]=d*M+p*o[e(t,b)],o[e(t,b)]=d*o[e(t,b)]-p*M;for(let b=0;b<=t;b++)M=o[e(b,t-1)],o[e(b,t-1)]=d*M+p*o[e(b,t)],o[e(b,t)]=d*o[e(b,t)]-p*M;for(let b=u;b<=w;b++)M=c[e(b,t-1)],c[e(b,t-1)]=d*M+p*c[e(b,t)],c[e(b,t)]=d*c[e(b,t)]-p*M}else r[t-1]=k+p,r[t]=k+p,n[t-1]=M,n[t]=-M;t-=2,F=0}else{if(k=o[e(t,t)],q=0,y=0,E<t&&(q=o[e(t-1,t-1)],y=o[e(t,t-1)]*o[e(t-1,t)]),F===10){m+=k;for(let v=u;v<=t;v++)o[e(v,v)]-=k;h=Math.abs(o[e(t,t-1)])+Math.abs(o[e(t-1,t-2)]),k=q=.75*h,y=-.4375*h*h}if(F===30&&(h=(q-k)/2,h=h*h+y,h>0)){h=Math.sqrt(h),q<k&&(h=-h),h=k-y/((q-k)/2+h);for(let v=u;v<=t;v++)o[e(v,v)]-=h;m+=h,k=q=y=.964}if(F++,++A>100*s)throw new Error("the eigendecomposition did not converge");let b=t-2;for(;b>=E&&(M=o[e(b,b)],g=k-M,h=q-M,p=(g*h-y)/o[e(b+1,b)]+o[e(b,b+1)],d=o[e(b+1,b+1)]-M-g-h,g=o[e(b+2,b+1)],h=Math.abs(p)+Math.abs(d)+Math.abs(g),p/=h,d/=h,g/=h,!(b===E||Math.abs(o[e(b,b-1)])*(Math.abs(d)+Math.abs(g))<f*(Math.abs(p)*(Math.abs(o[e(b-1,b-1)])+Math.abs(M)+Math.abs(o[e(b+1,b+1)])))));)b--;for(let v=b+2;v<=t;v++)o[e(v,v-2)]=0,v>b+2&&(o[e(v,v-3)]=0);for(let v=b;v<=t-1;v++){let z=v!==t-1;if(v!==b){if(p=o[e(v,v-1)],d=o[e(v+1,v-1)],g=z?o[e(v+2,v-1)]:0,k=Math.abs(p)+Math.abs(d)+Math.abs(g),k===0)continue;p/=k,d/=k,g/=k}if(h=Math.sqrt(p*p+d*d+g*g),p<0&&(h=-h),h!==0){v!==b?o[e(v,v-1)]=-h*k:E!==b&&(o[e(v,v-1)]=-o[e(v,v-1)]),p+=h,k=p/h,q=d/h,M=g/h,d/=p,g/=p;for(let x=v;x<s;x++)p=o[e(v,x)]+d*o[e(v+1,x)],z&&(p+=g*o[e(v+2,x)],o[e(v+2,x)]=o[e(v+2,x)]-p*M),o[e(v,x)]=o[e(v,x)]-p*k,o[e(v+1,x)]=o[e(v+1,x)]-p*q;for(let x=0;x<=Math.min(t,v+3);x++)p=k*o[e(x,v)]+q*o[e(x,v+1)],z&&(p+=M*o[e(x,v+2)],o[e(x,v+2)]=o[e(x,v+2)]-p*g),o[e(x,v)]=o[e(x,v)]-p,o[e(x,v+1)]=o[e(x,v+1)]-p*d;for(let x=u;x<=w;x++)p=k*c[e(x,v)]+q*c[e(x,v+1)],z&&(p+=M*c[e(x,v+2)],c[e(x,v+2)]=c[e(x,v+2)]-p*g),c[e(x,v)]=c[e(x,v)]-p,c[e(x,v+1)]=c[e(x,v+1)]-p*d}}}}if(!(N===0||a)){for(t=s-1;t>=0;t--)if(p=r[t],d=n[t],d===0){let E=t;o[e(t,t)]=1;for(let b=t-1;b>=0;b--){y=o[e(b,b)]-p,g=0;for(let v=E;v<=t;v++)g+=o[e(b,v)]*o[e(v,t)];if(n[b]<0)M=y,h=g;else if(E=b,n[b]===0?o[e(b,t)]=y!==0?-g/y:-g/(f*N):(k=o[e(b,b+1)],q=o[e(b+1,b)],d=(r[b]-p)*(r[b]-p)+n[b]*n[b],j=(k*h-M*g)/d,o[e(b,t)]=j,o[e(b+1,t)]=Math.abs(k)>Math.abs(M)?(-g-y*j)/k:(-h-q*j)/M),j=Math.abs(o[e(b,t)]),f*j*j>1)for(let v=b;v<=t;v++)o[e(v,t)]=o[e(v,t)]/j}}else if(d<0){let E=t-1;Math.abs(o[e(t,t-1)])>Math.abs(o[e(t-1,t)])?(o[e(t-1,t-1)]=d/o[e(t,t-1)],o[e(t-1,t)]=-(o[e(t,t)]-p)/o[e(t,t-1)]):[o[e(t-1,t-1)],o[e(t-1,t)]]=G(0,-o[e(t-1,t)],o[e(t-1,t-1)]-p,d),o[e(t,t-1)]=0,o[e(t,t)]=1;for(let b=t-2;b>=0;b--){let v=0,z=0;for(let x=E;x<=t;x++)v+=o[e(b,x)]*o[e(x,t-1)],z+=o[e(b,x)]*o[e(x,t)];if(y=o[e(b,b)]-p,n[b]<0)M=y,g=v,h=z;else{if(E=b,n[b]===0)[o[e(b,t-1)],o[e(b,t)]]=G(-v,-z,y,d);else{k=o[e(b,b+1)],q=o[e(b+1,b)];let x=(r[b]-p)*(r[b]-p)+n[b]*n[b]-d*d,Z=(r[b]-p)*2*d;x===0&&Z===0&&(x=f*N*(Math.abs(y)+Math.abs(d)+Math.abs(k)+Math.abs(q)+Math.abs(M))),[o[e(b,t-1)],o[e(b,t)]]=G(k*g-M*v+d*z,k*h-M*z-d*v,x,Z),Math.abs(k)>Math.abs(M)+Math.abs(d)?(o[e(b+1,t-1)]=(-v-y*o[e(b,t-1)]+d*o[e(b,t)])/k,o[e(b+1,t)]=(-z-y*o[e(b,t)]-d*o[e(b,t-1)])/k):[o[e(b+1,t-1)],o[e(b+1,t)]]=G(-g-q*o[e(b,t-1)],-h-q*o[e(b,t)],M,d)}if(j=Math.max(Math.abs(o[e(b,t-1)]),Math.abs(o[e(b,t)])),f*j*j>1)for(let x=b;x<=t;x++)o[e(x,t-1)]=o[e(x,t-1)]/j,o[e(x,t)]=o[e(x,t)]/j}}}for(let E=s-1;E>=u;E--)for(let b=u;b<=w;b++){M=0;for(let v=u;v<=Math.min(E,w);v++)M+=c[e(b,v)]*o[e(v,E)];c[e(b,E)]=M}}}export{R as a,L as b,I as c,P as d,$ as e,W as f,O as g,H as h,St as i,Ct as j,pt as k,Lt as l,Pt as m,_t as n,ot as o,Qt as p,Vt as q,Ut as r,Ht as s,D as t,K as u,to as v,kt as w,oo as x,ro as y,ao as z,yt as A,so as B,Nt as C,ut as D,uo as E,$t as F,It as G};
@@ -1,2 +0,0 @@
1
- /*! rStats.js 0.15.2 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{i as h,j as c,k as b}from"./chunk-D4F7GQAY.js";import{E as L,F as C,k as v,l as j,n as M,o as x}from"./chunk-2CUKVVRO.js";import{b as l,d as g,g as y,i as F,k as d}from"./chunk-LG74QY5U.js";var I=30;function m(t){return t===Math.floor(t)}function D(t,r){if(m(t))return t;if(t>=0)return h(t)?t:c(t);let n=r-1-t;return h(n)?t:r-1-c(n)||-0}function S(t,r){let n=[1,0];for(let i=0;i<r;i++)n=F(y(n,l(t,-i)),[i+1,0]);return n}function p(t,r){return Math.min(t,r)>=1&&Math.max(t,r)<2**52?C(t,r):[L(t,r),0]}function A(t,r){if(t<0){let a=g(d(l(r,-t)),p(-t,r+1));return{log:[-a[0],-a[1]],sign:r%2===0?1:-1}}if(m(t)&&t<r)return;if(t>=r-1){let a=g(d(l(t,1)),p(t-r+1,r+1));return{log:[-a[0],-a[1]],sign:1}}let n=v(t),[i,e]=l(t,1),[o,f]=l(r,-t),s=e===0&&f===0?0:b(i+o),u=(e===0?0:e*(b(i)-s))+(f===0?0:f*(b(o)-s));return{log:g(p(i,o),[Math.log(Math.abs(n)/Math.PI)+u,0]),sign:(r%2===0?-1:1)*Math.sign(n)}}function O(t,r,n){if(Number.isNaN(t)||Number.isNaN(r))return NaN;let i=n?.rCompatible??!0;if(r=c(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>=I?NaN:t>0||r%2===0?1/0:-1/0;if(r<I){let f=i&&!m(t)&&!h(t);if(f&&t>=0&&c(t)<r)return 0;let s=S(t,r),u=s[0]+s[1];if(Number.isFinite(u))return m(t)||f?Math.round(u):u;let N=1;for(let a=0;a<r;a++)N=N*(t-a)/(a+1);return N}if(i&&(t=D(t,r),Object.is(t,-0)))return r%2===0?0:-0;let e=A(t,r);if(e===void 0)return 0;let o=e.sign*Math.exp(e.log[0])*(1+e.log[1]);return m(t)&&Number.isFinite(o)?Math.round(o):o}function P(t,r,n){if(Number.isNaN(t)||Number.isNaN(r))return NaN;let i=n?.rCompatible??!0;if(r=c(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=D(t,r)),r<I){let o=S(t,r),f=Math.abs(o[0]+o[1]);if(f>1e-300&&f<1e300){let u=d(o[0]<0?[-o[0],-o[1]]:o);return u[0]+u[1]}if(f===0)return-1/0;let s=-M(r+1);for(let u=0;u<r;u++)s+=Math.log(Math.abs(t-u));return s}let e=A(t,r);return e===void 0?-1/0:m(t)&&e.log[0]<36?Math.log(Math.round(Math.exp(e.log[0])*(1+e.log[1]))):e.log[0]+e.log[1]}function R(t){return j(t+1)}function _(t){return Math.abs(t)<=.2?x(t):M(t+1)}export{O as a,P as b,R as c,_ as d};
@@ -1,2 +0,0 @@
1
- /*! rStats.js 0.15.2 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- var q=2220446049250313e-31,b0=22250738585072014e-324,z=17976931348623157e292,v0=[.06667134430868814,.1494513491505806,.21908636251598204,.26926671930999635,.29552422471475287],f0=[.9956571630258081,.9739065285171717,.9301574913557082,.8650633666889845,.7808177265864169,.6794095682990244,.5627571346686047,.4333953941292472,.2943928627014602,.14887433898163122,0],I=[.011694638867371874,.032558162307964725,.054755896574351995,.07503967481091996,.0931254545836976,.10938715880229764,.12349197626206584,.13470921731147334,.14277593857706009,.14773910490133849,.1494455540029169];function h0(a,o,i,s,t){let r=Math.abs((a-o)*i);return t!==0&&r!==0&&(r=t*Math.min(1,Math.pow(200*r/t,1.5))),s>b0/(50*q)&&(r=Math.max(q*50*s,r)),r}function g0(a,o,i){let s=.5*(o+i),t=.5*(i-o),r=Math.abs(t),w=new Array(10),u=new Array(10),p=a(s),M=0,c=I[10]*p,b=Math.abs(c);for(let e=0;e<5;e++){let n=2*e+1,l=t*f0[n],h=a(s-l),v=a(s+l);w[n]=h,u[n]=v;let g=h+v;M+=v0[e]*g,c+=I[n]*g,b+=I[n]*(Math.abs(h)+Math.abs(v))}for(let e=0;e<5;e++){let n=2*e,l=t*f0[n],h=a(s-l),v=a(s+l);w[n]=h,u[n]=v;let g=h+v;c+=I[n]*g,b+=I[n]*(Math.abs(h)+Math.abs(v))}let A=c*.5,f=I[10]*Math.abs(p-A);for(let e=0;e<10;e++)f+=I[e]*(Math.abs(w[e]-A)+Math.abs(u[e]-A));return b*=r,f*=r,{result:c*t,abserr:h0(c,M,t,b,f),resabs:b,resasc:f}}var l0=[0,.1294849661688697,0,.27970539148927664,0,.3818300505051189,0,.4179591836734694],x0=[.9914553711208126,.9491079123427585,.8648644233597691,.7415311855993945,.5860872354676911,.4058451513773972,.20778495500789848,0],U=[.022935322010529224,.06309209262997856,.10479001032225019,.14065325971552592,.1690047266392679,.19035057806478542,.20443294007529889,.20948214108472782];function A0(a,o,i,s,t){let r=i>1?1:i,w=.5*(s+t),u=.5*(t-s),p=new Array(7),M=new Array(7),c=h=>{let v=o+r*(1-h)/h,g=a(v);return i===2&&(g+=a(-v)),g},b=c(w)/w/w,A=b*l0[7],f=b*U[7],e=Math.abs(f);for(let h=0;h<7;h++){let v=u*x0[h],g=w-v,W=w+v,m=c(g),x=c(W);m=m/g/g,x=x/W/W,p[h]=m,M[h]=x;let K=m+x;A+=l0[h]*K,f+=U[h]*K,e+=U[h]*(Math.abs(m)+Math.abs(x))}let n=f*.5,l=U[7]*Math.abs(b-n);for(let h=0;h<7;h++)l+=U[h]*(Math.abs(p[h]-n)+Math.abs(M[h]-n));return e*=u,l*=u,{result:f*u,abserr:h0(f,A,u,e,l),resabs:e,resasc:l}}function j0(a){let o=a.epstab,i=a.n;a.nres+=1;let s=z,t=o[a.n];if(a.n<2)return s=Math.max(s,5*q*Math.abs(t)),[t,s];let r=49;o[a.n+2]=o[a.n];let w=Math.trunc(a.n/2);o[a.n]=z;let u=a.n;for(let c=0;c<w;c++){let b=u-1,A=u-2,f=o[u+2],e=o[A],n=o[b],l=f,h=Math.abs(n),v=l-n,g=Math.abs(v),W=Math.max(Math.abs(l),h)*q,m=n-e,x=Math.abs(m),K=Math.max(h,Math.abs(e))*q;if(!(g>W||x>K))return t=f,s=g+x,s=Math.max(s,5*q*Math.abs(t)),[t,s];let k=o[u];o[u]=n;let j=n-k,F=Math.abs(j),_=Math.max(h,Math.abs(k))*q;if(F<=_||g<=W||x<=K){a.n=c+c;break}let L=1/j+1/v-1/m;if(!(Math.abs(L*n)>1e-4)){a.n=c+c;break}f=n+1/L,o[u]=f,u-=2;let X=g+Math.abs(f-l)+x;X>s||(s=X,t=f)}a.n===r&&(a.n=2*Math.trunc(r/2));let p=i%2;for(let c=0;c<=w;c++)o[2*c+p]=o[2*c+2+p];if(a.n!==i){let c=i-a.n;for(let b=0;b<=a.n;b++)o[b]=o[c],c++}let M=a.res3la;return a.nres<4?(M[a.nres-1]=t,s=z):(s=Math.abs(t-M[2])+Math.abs(t-M[1])+Math.abs(t-M[0]),M[0]=M[1],M[1]=M[2],M[2]=t),s=Math.max(s,5*q*Math.abs(t)),[t,s]}function y0(a,o,i,s,t,r){if(o<=2){t[0]=0,t[1]=1;let e=t[r];return[e,s[e],r]}let w=s[i];for(;r>0&&w>s[t[r-1]];)t[r]=t[r-1],r-=1;let u=o>Math.trunc(a/2)+2?a-o+2:o-1,p=s[o-1],M=u-1,c=r+1,b=c,A=!1;if(c<=M)for(b=c;b<=M;b++){if(w>=s[t[b]]){A=!0;break}t[b-1]=t[b]}if(!A)t[M]=i,t[u]=o-1;else{t[b-1]=i;let e=M;for(let n=b;n<=M&&!(p<s[t[e]]);n++)t[e+1]=t[e],e--;p<s[t[e]]?t[e+1]=o-1:t[b]=o-1}let f=t[r];return[f,s[f],r]}function M0(a,o,i,s,t,r,w,u){let p=new Float64Array(r+1),M=new Float64Array(r+1),c=new Float64Array(r+1),b=new Float64Array(r+1),A=new Int32Array(r+1),f=0,e=0,n=0,l=0;if(p[0]=o,M[0]=i,s<=0&&t<Math.max(50*q,5e-29))return{result:0,abserr:0,neval:0,ier:6,last:0};let h=a(o,i);n=h.result,l=h.abserr;let v=h.resabs,g=h.resasc,W=Math.abs(n),m=Math.max(s,t*W);if(e=1,c[0]=n,b[0]=l,A[0]=0,l<=100*q*v&&l>m&&(f=2),r===1&&(f=1),f!==0||l<=m&&l!==g||l===0)return{result:n,abserr:l,neval:u(e),ier:f,last:e};let x={epstab:new Float64Array(52),res3la:new Float64Array(3),n:1,nres:0};x.epstab[0]=n;let K=l,k=0,j=n,F=l;l=z;let _=0,L=0,E=!1,X=!1,B=0,t0=0,R=0,s0=0,C=0,O=0,D=0,e0=0,u0=W>=(1-50*q)*v?1:-1,a0=!1,y=1;for(y=1;y<r;y++){e=y+1;let d=p[k],H=.5*(p[k]+M[k]),J=H,S=M[k],i0=K,T=a(d,H),V=a(J,S),Y=T.result,N=T.abserr,k0=T.resasc,Z=V.result,P=V.abserr,w0=V.resasc,$=Y+Z,Q=N+P;if(F=F+Q-K,j=j+$-c[k],k0!==N&&w0!==P&&(Math.abs(c[k]-$)>1e-5*Math.abs($)||Q<.99*K||(E?R++:t0++),y>9&&Q>K&&s0++),c[k]=Y,c[y]=Z,m=Math.max(s,t*Math.abs(j)),(t0+R>=10||s0>=20)&&(f=2),R>=5&&(B=3),e===r&&(f=1),Math.max(Math.abs(d),Math.abs(S))<=(1+100*q)*(Math.abs(J)+1e3*b0)&&(f=4),P>N?(p[k]=J,p[y]=d,M[y]=H,c[k]=Z,c[y]=Y,b[k]=P,b[y]=N):(p[y]=J,M[k]=H,M[y]=S,b[k]=N,b[y]=P),[k,K,_]=y0(r,e,k,b,A,_),F<=m){a0=!0;break}if(f!==0)break;if(y===1){C=w,O=F,D=m,x.epstab[1]=j;continue}if(X)continue;if(O-=i0,Math.abs(H-d)>C&&(O+=Q),!E){if(Math.abs(M[k]-p[k])>C)continue;E=!0,_=1}if(!(B===3||O<=D)){let p0=e>2+Math.trunc(r/2)?r+3-e:e,o0=!1;for(let c0=_;c0<p0;c0++){if(k=A[_],K=b[k],Math.abs(M[k]-p[k])>C){o0=!0;break}_++}if(o0)continue}x.n+=1,x.epstab[x.n]=j;let[n0,r0]=j0(x);if(L+=1,L>5&&l<.001*F&&(f=5),r0<l&&(L=0,l=r0,n=n0,e0=O,D=Math.max(s,t*Math.abs(n0)),l<=D)||(x.n===0&&(X=!0),f===5))break;k=A[0],K=b[k],_=0,E=!1,C*=.5,O=F}let G;if(a0||l===z?G=115:f+B===0?G=110:(B===3&&(l+=e0),f===0&&(f=3),n!==0&&j!==0?G=105:l>F?G=115:j===0?G=130:G=110),G===105&&(G=l/Math.abs(n)>F/Math.abs(j)?115:110),G===110)u0===-1&&Math.max(Math.abs(n),Math.abs(j))<=v*.01||(.01>n/j||n/j>100||F>Math.abs(j))&&(f=6);else if(G===115){n=0;for(let d=0;d<=y;d++)n+=c[d];l=F}return f>2&&(f-=1),{result:n,abserr:l,neval:u(e),ier:f,last:e}}function m0(a,o,i,s,t,r){return M0((w,u)=>g0(a,w,u),o,i,s,t,r,Math.abs(i-o)*.375,w=>42*w-21)}function K0(a,o,i,s,t,r){let w=i===2?0:o;return M0((u,p)=>A0(a,w,i,u,p),0,1,s,t,r,.375,u=>(30*u-15)*(i===2?2:1))}export{m0 as a,K0 as b};
@@ -1,2 +0,0 @@
1
- /*! rStats.js 0.15.2 | MIT License | includes code ported from SciPy, Boost.Math, statsmodels, LAPACK and others: see THIRD_PARTY_NOTICES.md at https://github.com/numero-uno-jpn/rStats.js */
2
- import{a as q,c as p,e as v,f as O,h as U,o as F,r as g,s as j,v as N,y as R}from"./chunk-XNPU54NH.js";function H(e,n={}){if(n.exact){let i=n.norm===void 0?"2":A(n.norm);if(i==="2"){let l=g(e,{nu:0,nv:0}).d,m=Math.min(...l);return m===0?1/0:Math.max(...l)/m}return j(e,{type:i})*j(N(e),{type:i})}let a=n.norm==="I"?"I":"O";if((n.method??"qr")==="direct"){if(n.triangular)return 1/C(p(e),(n.uplo??"U")==="U",a);let i=n.norm??"O",l=i.toUpperCase();if(l!=="1"&&l!=="O"&&l!=="I")throw new RangeError(`argument type[1]='${i}' must be one of '1','O', or 'I'`);return 1/R(e,{norm:l==="I"?"I":"O"})}let b=p(e),f=b.nrow<b.ncol?v(O(b)):e;return 1/C(p(F(U(f))),!0,a)}function C(e,n,a){return L(a==="I"?O(e):e,n)}function A(e){let n=e.toUpperCase();if(n==="1"||n==="O")return"O";if(n==="E")return"F";if(n==="I"||n==="F"||n==="M"||n==="2")return n;throw new RangeError(`invalid norm "${e}"`)}function L(e,n){let a=Math.min(e.nrow,e.ncol),b=e.nrow,f=(o,t)=>e.data[o+t*b],i=!n,l=0;for(let o=0;o<a;o++){let[t,u]=i?[o,a-o]:[0,o+1],s=0;for(let c=t;c<t+u;c++)s+=Math.abs(f(c,o));l=Math.max(l,s)}let m=1,r=new Float64Array(a),k=o=>{for(let t=0;t<a;t++)r[t]*=o};for(let o=0;o<a;o++){let t=i?a-1-o:o,u=f(t,t);if(r[t]!==0&&(m=r[t]>0?-Math.abs(m):Math.abs(m)),Math.abs(m-r[t])>Math.abs(u)){let d=Math.abs(u)/Math.abs(m-r[t]);k(d),m*=d}let s=m-r[t],c=-m-r[t],x=Math.abs(s),y=Math.abs(c);if(u!==0?(s/=u,c/=u):(s=1,c=1),o!==a-1){let[d,E]=i?[0,t-1]:[t+1,a-1];for(let M=d;M<=E;M++)y+=Math.abs(r[M]+c*f(t,M)),r[M]+=s*f(t,M),x+=Math.abs(r[M]);if(x<y){let M=c-s;s=c;for(let I=d;I<=E;I++)r[I]+=M*f(t,I)}}r[t]=s}k(1/$(r));let w=1;for(let o=0;o<a;o++){let t=i?o:a-1-o,u=f(t,t);if(Math.abs(r[t])>Math.abs(u)){let s=Math.abs(u)/Math.abs(r[t]);k(s),w*=s}if(u!==0?r[t]/=u:r[t]=1,o<a-1){let s=-r[t];if(i)for(let c=t+1;c<a;c++)r[c]+=s*f(c,t);else for(let c=0;c<t;c++)r[c]+=s*f(c,t)}}let h=1/$(r);return k(h),w*=h,l!==0?w/l:0}function $(e){let n=0;for(let a of e)n+=Math.abs(a);return n}function J(e,n={}){let a=n.tol??Math.sqrt(Number.EPSILON),b=p(e),{d:f,u:i,v:l}=g(e),m=b.nrow,r=b.ncol,k=q(r,m),w=Math.max(a*(f[0]??0),0);for(let h=0;h<f.length;h++){if(!(f[h]>w))continue;let o=1/f[h];for(let t=0;t<m;t++){let u=i[t][h]*o;for(let s=0;s<r;s++)k.data[s+t*r]+=l[s][h]*u}}return v(k)}export{H as a,J as b};