@numero-uno-jpn/rstats 0.10.0 → 0.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/README.ja.md +13 -9
- package/README.md +13 -8
- package/dist/chunks/{chunk-QJJWGNJP.js → chunk-2X7JYQBI.js} +2 -2
- package/dist/chunks/{chunk-O6PT7IVU.js → chunk-36GVER3O.js} +2 -2
- package/dist/chunks/{chunk-EWC6I75B.js → chunk-3WUXRSM6.js} +1 -1
- package/dist/chunks/{chunk-4NM37MGA.js → chunk-6I6QKTFK.js} +2 -2
- package/dist/chunks/{chunk-2XKG3DX4.js → chunk-ETOEZTGL.js} +1 -1
- package/dist/chunks/{chunk-IT354SHV.js → chunk-FVPDVRJQ.js} +2 -2
- package/dist/chunks/{chunk-QULPY6YM.js → chunk-GG4BJMJW.js} +1 -1
- package/dist/chunks/{chunk-7HPVUVZB.js → chunk-HITD7CX6.js} +1 -1
- package/dist/chunks/{chunk-LIMZKONM.js → chunk-KK4GE65D.js} +2 -2
- package/dist/chunks/chunk-LAUYSGV4.js +3 -0
- package/dist/chunks/chunk-M6GDXKKS.js +2 -0
- package/dist/chunks/{chunk-QFULZNHL.js → chunk-PHHUHR7T.js} +1 -1
- package/dist/chunks/{chunk-ENL43FNO.js → chunk-WQPFDDIY.js} +2 -2
- package/dist/chunks/chunk-X2AWQSVS.js +2 -0
- package/dist/chunks/{chunk-ZRIM4R4A.js → chunk-ZRJQD7VS.js} +2 -2
- package/dist/data/grouping.d.ts +100 -0
- package/dist/data/grouping.js +264 -0
- package/dist/descriptive/basic.d.ts +130 -17
- package/dist/descriptive/basic.js +115 -14
- package/dist/descriptive/cov.d.ts +22 -12
- package/dist/descriptive/dataFrames.d.ts +138 -0
- package/dist/descriptive/dataFrames.js +400 -0
- package/dist/descriptive/factanal.d.ts +26 -6
- package/dist/descriptive/factanal.js +7 -3
- package/dist/descriptive/hist.d.ts +27 -6
- package/dist/descriptive/hist.js +9 -3
- package/dist/descriptive/missing.d.ts +42 -0
- package/dist/descriptive/missing.js +52 -0
- package/dist/descriptive/moments.d.ts +91 -13
- package/dist/descriptive/moments.js +66 -9
- package/dist/descriptive/omega.d.ts +28 -6
- package/dist/descriptive/omega.js +16 -4
- package/dist/descriptive/pivot.d.ts +105 -0
- package/dist/descriptive/pivot.js +347 -0
- package/dist/descriptive/quantile.d.ts +33 -5
- package/dist/descriptive/quantile.js +20 -2
- package/dist/descriptive/rank.d.ts +12 -2
- package/dist/descriptive/rank.js +2 -0
- package/dist/descriptive/table.d.ts +55 -7
- package/dist/descriptive/table.js +38 -4
- package/dist/descriptive.js +2 -2
- package/dist/distributions/arcsine.d.ts +40 -5
- package/dist/distributions/arcsine.js +35 -4
- package/dist/distributions/beta.d.ts +12 -0
- package/dist/distributions/beta.js +12 -0
- package/dist/distributions/binomial.d.ts +18 -0
- package/dist/distributions/binomial.js +18 -0
- package/dist/distributions/bvnorm.d.ts +4 -1
- package/dist/distributions/bvnorm.js +4 -1
- package/dist/distributions/cauchy.d.ts +24 -0
- package/dist/distributions/cauchy.js +24 -0
- package/dist/distributions/chisq.d.ts +18 -0
- package/dist/distributions/chisq.js +18 -0
- package/dist/distributions/exponential.d.ts +29 -1
- package/dist/distributions/exponential.js +24 -0
- package/dist/distributions/f.d.ts +18 -0
- package/dist/distributions/f.js +18 -0
- package/dist/distributions/gamma.d.ts +20 -0
- package/dist/distributions/gamma.js +18 -0
- package/dist/distributions/geometric.d.ts +24 -0
- package/dist/distributions/geometric.js +24 -0
- package/dist/distributions/hypergeometric.d.ts +24 -0
- package/dist/distributions/hypergeometric.js +24 -0
- package/dist/distributions/invgamma.d.ts +32 -4
- package/dist/distributions/invgamma.js +27 -3
- package/dist/distributions/kumaraswamy.d.ts +31 -3
- package/dist/distributions/kumaraswamy.js +31 -3
- package/dist/distributions/laplace.d.ts +36 -4
- package/dist/distributions/laplace.js +31 -3
- package/dist/distributions/logistic.d.ts +29 -1
- package/dist/distributions/logistic.js +24 -0
- package/dist/distributions/lognormal.d.ts +29 -1
- package/dist/distributions/lognormal.js +24 -0
- package/dist/distributions/multinomial.d.ts +7 -1
- package/dist/distributions/multinomial.js +2 -0
- package/dist/distributions/negbinomial.d.ts +29 -1
- package/dist/distributions/negbinomial.js +24 -0
- package/dist/distributions/normal.d.ts +11 -1
- package/dist/distributions/normal.js +6 -0
- package/dist/distributions/pareto.d.ts +36 -4
- package/dist/distributions/pareto.js +31 -3
- package/dist/distributions/poisson.d.ts +18 -0
- package/dist/distributions/poisson.js +18 -0
- package/dist/distributions/signrank.d.ts +24 -0
- package/dist/distributions/signrank.js +24 -0
- package/dist/distributions/summary.d.ts +20 -2
- package/dist/distributions/summary.js +4 -0
- package/dist/distributions/t.d.ts +18 -0
- package/dist/distributions/t.js +18 -0
- package/dist/distributions/triangular.d.ts +36 -4
- package/dist/distributions/triangular.js +31 -3
- package/dist/distributions/tukey.d.ts +15 -1
- package/dist/distributions/tukey.js +10 -0
- package/dist/distributions/uniform.d.ts +29 -1
- package/dist/distributions/uniform.js +24 -0
- package/dist/distributions/weibull.d.ts +29 -1
- package/dist/distributions/weibull.js +24 -0
- package/dist/distributions/wilcox.d.ts +24 -0
- package/dist/distributions/wilcox.js +24 -0
- package/dist/distributions.js +2 -2
- package/dist/entries/descriptive.d.ts +5 -1
- package/dist/entries/descriptive.js +4 -0
- package/dist/entries/numerics.d.ts +1 -1
- package/dist/entries/tests.js +1 -1
- package/dist/htest/agreement.d.ts +61 -23
- package/dist/htest/agreement.js +19 -9
- package/dist/htest/ansariTest.d.ts +19 -1
- package/dist/htest/ansariTest.js +5 -17
- package/dist/htest/aov.d.ts +43 -10
- package/dist/htest/aov.js +17 -3
- package/dist/htest/binomTest.d.ts +12 -2
- package/dist/htest/binomTest.js +2 -0
- package/dist/htest/brunnerMunzelTest.d.ts +9 -3
- package/dist/htest/brunnerMunzelTest.js +4 -2
- package/dist/htest/chisqTest.d.ts +19 -3
- package/dist/htest/cor.d.ts +31 -3
- package/dist/htest/cor.js +9 -27
- package/dist/htest/effectSize.d.ts +70 -12
- package/dist/htest/effectSize.js +40 -7
- package/dist/htest/fisherTest.d.ts +9 -1
- package/dist/htest/fisherTest.js +2 -0
- package/dist/htest/groups.d.ts +5 -1
- package/dist/htest/ksTest.d.ts +32 -2
- package/dist/htest/ksTest.js +5 -8
- package/dist/htest/leveneTest.d.ts +15 -4
- package/dist/htest/leveneTest.js +5 -2
- package/dist/htest/mantelhaenTest.d.ts +25 -3
- package/dist/htest/mantelhaenTest.js +15 -1
- package/dist/htest/mcnemarTest.d.ts +14 -4
- package/dist/htest/mcnemarTest.js +4 -2
- package/dist/htest/multipleComparisons.d.ts +173 -29
- package/dist/htest/multipleComparisons.js +123 -19
- package/dist/htest/normalityTests.d.ts +56 -9
- package/dist/htest/normalityTests.js +40 -6
- package/dist/htest/onewayTest.d.ts +45 -2
- package/dist/htest/onewayTest.js +15 -7
- package/dist/htest/pAdjust.d.ts +9 -1
- package/dist/htest/pAdjust.js +2 -0
- package/dist/htest/pairwise.d.ts +50 -5
- package/dist/htest/pairwise.js +25 -0
- package/dist/htest/poissonTest.d.ts +12 -2
- package/dist/htest/poissonTest.js +2 -0
- package/dist/htest/polycor.d.ts +29 -10
- package/dist/htest/power.d.ts +60 -6
- package/dist/htest/power.js +6 -0
- package/dist/htest/propTest.d.ts +13 -2
- package/dist/htest/propTest.js +2 -0
- package/dist/htest/pwr.d.ts +286 -36
- package/dist/htest/pwr.js +116 -15
- package/dist/htest/rankTests.d.ts +132 -7
- package/dist/htest/rankTests.js +30 -33
- package/dist/htest/tTest.d.ts +32 -2
- package/dist/htest/tTest.js +19 -24
- package/dist/htest/testFormula.d.ts +57 -0
- package/dist/htest/testFormula.js +171 -0
- package/dist/htest/trendTests.d.ts +29 -8
- package/dist/htest/trendTests.js +8 -4
- package/dist/htest/types.d.ts +14 -2
- package/dist/htest/varTest.d.ts +46 -6
- package/dist/htest/varTest.js +11 -21
- package/dist/htest/wilcoxTest.d.ts +23 -1
- package/dist/htest/wilcoxTest.js +9 -24
- package/dist/internal/dpq.d.ts +4 -0
- package/dist/internal/noncentral.d.ts +2 -0
- package/dist/internal/vectorize.d.ts +4 -0
- package/dist/linalg/basic.d.ts +39 -5
- package/dist/linalg/basic.js +15 -0
- package/dist/linalg/chol.d.ts +26 -5
- package/dist/linalg/chol.js +7 -0
- package/dist/linalg/eigen.d.ts +16 -7
- package/dist/linalg/eigen.js +6 -5
- package/dist/linalg/expm.d.ts +15 -5
- package/dist/linalg/expm.js +5 -3
- package/dist/linalg/kappa.d.ts +21 -1
- package/dist/linalg/kappa.js +16 -0
- package/dist/linalg/lu.d.ts +30 -6
- package/dist/linalg/lu.js +15 -3
- package/dist/linalg/matrix.d.ts +4 -0
- package/dist/linalg/norm.d.ts +16 -1
- package/dist/linalg/norm.js +9 -0
- package/dist/linalg/ops.d.ts +168 -36
- package/dist/linalg/ops.js +116 -20
- package/dist/linalg/qr.d.ts +87 -12
- package/dist/linalg/qr.js +31 -0
- package/dist/linalg/schur.d.ts +8 -2
- package/dist/linalg/schur.js +3 -1
- package/dist/linalg/solve.d.ts +42 -6
- package/dist/linalg/solve.js +22 -0
- package/dist/linalg/svd.d.ts +12 -2
- package/dist/linalg/svd.js +2 -0
- package/dist/linalg.js +2 -2
- package/dist/models/anovaSequential.d.ts +26 -4
- package/dist/models/anovaSequential.js +3 -1
- package/dist/models/aovEz.d.ts +29 -6
- package/dist/models/aovEz.js +5 -2
- package/dist/models/aovStrata.d.ts +12 -2
- package/dist/models/carAnova.d.ts +9 -3
- package/dist/models/carAnova.js +4 -2
- package/dist/models/coxph.d.ts +33 -7
- package/dist/models/coxph.js +8 -3
- package/dist/models/glm.d.ts +128 -21
- package/dist/models/glm.js +71 -14
- package/dist/models/glmAnova.d.ts +30 -5
- package/dist/models/glmAnova.js +15 -2
- package/dist/models/glmConfint.d.ts +16 -2
- package/dist/models/glmConfint.js +9 -1
- package/dist/models/glmFamily.d.ts +27 -5
- package/dist/models/lm.d.ts +75 -17
- package/dist/models/lm.js +22 -4
- package/dist/models/mauchly.d.ts +20 -5
- package/dist/models/mauchly.js +7 -3
- package/dist/models/modelFrame.d.ts +5 -1
- package/dist/models/modelMatrix.d.ts +18 -4
- package/dist/models/modelMatrix.js +3 -1
- package/dist/models/survival.d.ts +41 -9
- package/dist/models/survival.js +10 -4
- package/dist/numerics/deriv.d.ts +21 -6
- package/dist/numerics/deriv.js +16 -5
- package/dist/numerics/integrate.d.ts +37 -7
- package/dist/numerics/integrate.js +8 -2
- package/dist/numerics/interp.d.ts +63 -12
- package/dist/numerics/interp.js +30 -6
- package/dist/numerics/ode.d.ts +15 -5
- package/dist/numerics/ode.js +5 -3
- package/dist/numerics.js +2 -2
- package/dist/optim/optim.d.ts +32 -8
- package/dist/optim/optim.js +8 -4
- package/dist/random/beta.d.ts +8 -0
- package/dist/random/beta.js +8 -0
- package/dist/random/binomial.d.ts +16 -0
- package/dist/random/binomial.js +16 -0
- package/dist/random/continuous.d.ts +51 -0
- package/dist/random/continuous.js +51 -0
- package/dist/random/extra.d.ts +66 -6
- package/dist/random/extra.js +66 -6
- package/dist/random/gamma.d.ts +33 -0
- package/dist/random/gamma.js +33 -0
- package/dist/random/hyper.d.ts +8 -0
- package/dist/random/hyper.js +8 -0
- package/dist/random/poisson.d.ts +25 -0
- package/dist/random/poisson.js +25 -0
- package/dist/random/r2dtable.d.ts +2 -0
- package/dist/random/r2dtable.js +2 -0
- package/dist/random/rank.d.ts +16 -0
- package/dist/random/rank.js +16 -0
- package/dist/random/rng.d.ts +49 -6
- package/dist/random/rng.js +29 -2
- package/dist/random/sample.d.ts +10 -2
- package/dist/random/sample.js +5 -1
- package/dist/random/streams.d.ts +13 -0
- package/dist/random/streams.js +13 -0
- package/dist/rstats.js +14 -14
- package/dist/special/besselIK.d.ts +11 -3
- package/dist/special/besselIK.js +6 -2
- package/dist/special/besselJY.d.ts +6 -2
- package/dist/special/besselJY.js +6 -2
- package/dist/special/beta.d.ts +16 -2
- package/dist/special/beta.js +16 -2
- package/dist/special/choose.d.ts +13 -5
- package/dist/special/choose.js +13 -5
- package/dist/special/erf.d.ts +8 -3
- package/dist/special/erf.js +8 -3
- package/dist/special/extra.d.ts +30 -10
- package/dist/special/extra.js +25 -9
- package/dist/special/gamma.d.ts +18 -2
- package/dist/special/gamma.js +18 -2
- package/dist/special/log1p.d.ts +16 -7
- package/dist/special/log1p.js +16 -7
- package/dist/special/psigamma.d.ts +9 -3
- package/dist/special/psigamma.js +9 -3
- package/dist/special/rCompatible.d.ts +5 -1
- package/dist/special.js +2 -2
- package/dist/tests.js +12 -13
- package/llms.txt +14 -0
- package/package.json +1 -1
- package/dist/chunks/chunk-AECGWZHD.js +0 -2
- package/dist/chunks/chunk-XWTZ4RTR.js +0 -2
package/dist/descriptive.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/*! rStats.js 0.
|
|
2
|
-
import{f as C,g as Q,h as j}from"./chunks/chunk-XWTZ4RTR.js";import"./chunks/chunk-ZRIM4R4A.js";import{a as U,b as z,c as D,d as T,e as V,f as X,g as L,h as k,i as R,j as Z,k as G,l as H,m as J,n as K,o as W,p as Y,q as $,r as v,s as tt,t as et,u as nt}from"./chunks/chunk-AECGWZHD.js";import{a as _,b as rt,c as ot,d as st,e as it,f as at}from"./chunks/chunk-QFULZNHL.js";import"./chunks/chunk-7HPVUVZB.js";import"./chunks/chunk-LIMZKONM.js";import"./chunks/chunk-4NM37MGA.js";import"./chunks/chunk-2XKG3DX4.js";var q=4*Number.EPSILON,ct={4:[0,1],5:[.5,.5],6:[0,0],8:[1/3,1/3],9:[3/8,3/8]};function lt(i,e,s){let r=i.length,c=n=>i[Math.min(Math.max(n,1),r)-1];if(s===7){let n=1+(r-1)*e,h=Math.floor(n),f=c(h),w=c(Math.ceil(n));if(n>h&&w!==f){let M=n-h;return(1-M)*f+M*w}return f}let a,t;if(s<=3){let n=s===3?r*e-.5:r*e;a=Math.floor(n*(1+q)),s===1?t=n>a?1:0:s===2?t=n>a?1:.5:t=n!==a||Math.abs(a%2)===1?1:0}else{let[n,h]=ct[s],f=n+e*(r+1-n-h);a=Math.floor(f*(1+q)),t=f-a,Math.abs(t)<q&&(t=0)}let o=c(a),l=c(a+1);return t===1?l:t>0&&t<1&&o!==l?(1-t)*o+t*l:o}function F(i,e=[0,.25,.5,.75,1],s={}){let r=s.type??7;if(!(Number.isInteger(r)&&r>=1&&r<=9))throw new RangeError("'type' must be an integer in 1..9");let c=U(i,s.naRm);if(c===void 0)throw new RangeError("missing values and NaN's not allowed if 'na.rm' is FALSE");let a=c.sort((n,h)=>n-h),t=typeof e=="number"?[e]:Array.from(e),o=100*Number.EPSILON;if(t.some(n=>n<-o||n>1+o))throw new RangeError("'probs' outside [0,1]");let l=t.map(n=>Number.isNaN(n)||a.length===0?NaN:lt(a,Math.min(Math.max(n,0),1),r));return typeof e=="number"?l[0]:l}function O(i,e={}){let[s,r]=F(i,[.25,.75],e);return r-s}function ft(i){let e=Array.from(i).filter(a=>!Number.isNaN(a)).sort((a,t)=>a-t),s=e.length;if(s===0)return[NaN,NaN,NaN,NaN,NaN];let r=Math.floor((s+3)/2)/2;return[1,r,(s+1)/2,s+1-r,s].map(a=>.5*(e[Math.floor(a)-1]+e[Math.ceil(a)-1]))}function ut(i,e={}){let s=U(i,e.naRm);if(s===void 0)return NaN;let r=e.center??k(s),c=e.constant??1.4826,a=e.low??!1,t=e.high??!1,o=s.map(n=>Math.abs(n-r)),l=o.length;if((a||t)&&l%2===0){if(a&&t)throw new RangeError("'low' and 'high' cannot be both TRUE");let n=l/2+(t?1:0),h=o.sort((f,w)=>f-w);return c*h[n-1]}return c*k(o)}function P(i,e={}){let s=Array.from(i).filter(Number.isFinite);if(s.length===0)return[];let r=e.n??5,c=e.minN??Math.floor(r/3),a=e.shrinkSml??.75,t=e.highUBias??1.5,o=e.u5Bias??.5+1.5*t,l=1/0,n=-1/0;for(let N of s)N<l&&(l=N),N>n&&(n=N);let h=n-l,f,w;if(h===0&&n===0)f=1,w=!0;else{f=Math.max(Math.abs(l),Math.abs(n));let p=(1+(o>=1.5*t+.5?1/(1+t):1.5/(1+o)))*Math.max(1,r)*Number.EPSILON;w=h<f*p*3}w?(f>10&&(f=9+f/10),f*=a,c>1&&(f/=c)):(f=r>1?h/r:h,h===1/0&&r>=2&&(f=n/r-l/r));let M=2**-20*mt;f<M?f=M:f>Number.MAX_VALUE/1.25&&(f=Number.MAX_VALUE/1.25);let x=10**Math.floor(Math.log10(f)),S=[[2*x,t],[5*x,o],[10*x,t]],g=x;for(let[N,p]of S)if(N-f<p*(f-g))g=N;else break;let m=1e-10,u=Math.floor(l/g+m);for(;u*g>l+m*g;)u--;for(;!Number.isFinite(u*g);)u++;let b=Math.ceil(n/g-m);for(;b*g<n-m*g;)b++;for(;!Number.isFinite(b*g);)b--;let d=Math.trunc(.5+b-u);if(d<c){let N=c-d,p=Math.floor(N/2),I=N%2;l===0&&u===0&&n!==0?b+=N:n===0&&b===0&&l!==0?u-=N:u>=0?(b+=p,u-=p+I):(u-=p,b+=p+I),d=c}let y=u*g<l?u*g:l,E=b*g>n?b*g:n;if(d<=0)return[y];let A;if(Number.isFinite(E-y))A=_(y,E,d+1);else{let N=E/d-y/d;A=Array.from({length:d+1},(p,I)=>y+I*N),A[d]=E}let B=E/d-y/d;return A.map(N=>Math.abs(N)<1e-14*B?0:N)}var mt=22250738585072014e-324;function ht(i){return i===0||!Number.isFinite(i)?i:Number(i.toPrecision(5))}function Nt(i,e){let s=i.length,[r,c]=R(i),a=c-r;switch(e.toLowerCase()){case"sturges":return Math.ceil(Math.log2(s)+1);case"scott":{let t=3.5*L(i)*s**-.3333333333333333;return t>0?Math.max(1,Math.ceil(a/t)):1}case"fd":case"freedman-diaconis":{let t=i.map(ht),o=2*O(t);for(let l=1/8;o===0&&l>=1/512;l/=2){let[n,h]=F(t,[l,1-l]);o=(h-n)/(1-2*l)}return o===0&&(o=3.5*L(i)),o>0?Math.ceil(a/o*s**(1/3)):1}default:throw new RangeError("unknown 'breaks' algorithm")}}function gt(i,e){let s=i.slice(1).map((r,c)=>r-i[c]);return i.length>5?k(s):i.length<=3?e:Math.min(...s.filter(r=>r>0))}function dt(i,e={}){let s=Array.from(i).filter(Number.isFinite),r=s.length,c=e.right??!0,a=e.includeLowest??!0,t=e.breaks??"Sturges",o;if(typeof t!="string"&&typeof t!="number"&&t.length>1)o=[...t].sort((m,u)=>m-u);else{a=!0;let m=typeof t=="string"?Nt(s,t):typeof t=="number"?t:t[0];if(!Number.isFinite(m)||m<1)throw new RangeError("invalid number of 'breaks'");m=Math.min(m,1e6);let[u,b]=R(s);o=P([u,b],{n:m,minN:1});for(let d=1;d<o.length;d++)if(!(o[d]-o[d-1]>0))throw new RangeError("'breaks' are not strictly increasing")}let l=o.length,[n,h]=r>0?R(s):[0,0],f=1e-7*gt(o,h-n),w=o.map((m,u)=>c?u===0&&a?m-f:m+f:u<l-1?m-f:a?m+f:m-f),M=new Array(Math.max(0,l-1)).fill(0),x=0;for(let m of s){let u=bt(m,w,c,a);u>=0&&(M[u]++,x++)}if(x<r)throw new RangeError("some 'x' not counted; maybe 'breaks' do not span range of 'x'");let S=M.map((m,u)=>m/(r*(o[u+1]-o[u]))),g=M.map((m,u)=>.5*(o[u+1]+o[u]));return{breaks:o,counts:M,density:S,mids:g}}function bt(i,e,s,r){let c=e.length-1;if(c<1)return-1;if(s){if(i===e[0]&&r)return 0;if(!(i>e[0]&&i<=e[c]))return-1;let o=1,l=c;for(;o<l;){let n=o+l>>1;i<=e[n]?l=n:o=n+1}return o-1}if(i===e[c]&&r)return c-1;if(!(i>=e[0]&&i<e[c]))return-1;let a=0,t=c-1;for(;a<t;){let o=a+t+1>>1;e[o]<=i?a=o:t=o-1}return a}function wt(i){let e=Array.from(i).filter(r=>!Number.isNaN(r)).sort((r,c)=>r-c),s=e.length;if(s<1)throw new RangeError("'x' must have 1 or more non-missing values");return r=>{if(Number.isNaN(r))return NaN;let c=0,a=s;for(;c<a;){let t=c+a>>1;e[t]<=r?c=t+1:a=t}return c/s}}export{O as IQR,j as cor,Q as cov,H as cummax,J as cummin,G as cumprod,Z as cumsum,it as cut,et as cv,K as diff,wt as ecdf,at as findInterval,ft as fivenum,$ as geometricMean,dt as hist,Y as kurtosis,ut as mad,T as mean,tt as meanAD,k as median,v as modes,P as pretty,D as prod,F as quantile,R as range,C as rank,nt as scale,L as sd,W as skewness,z as sum,ot as table,rt as tabulate,st as unique,X as variance,V as weightedMean};
|
|
1
|
+
/*! rStats.js 0.11.1 | 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 J,e as S,q as fe,r as ue,s as me}from"./chunks/chunk-LAUYSGV4.js";import"./chunks/chunk-ZRJQD7VS.js";import{A as ke,B as Re,C as Fe,D as je,E as Se,F as Te,a as q,b as T,c as z,d as k,e as G,f as he,g as pe,j as ge,k as ye,l as V,m as de,n as we,o as be,p as Ne,q as Ee,r as _,s as R,t as j,u as Ae,v as xe,w as Me,x as $e,y as ve,z as Oe}from"./chunks/chunk-X2AWQSVS.js";import{a as X}from"./chunks/chunk-M6GDXKKS.js";import{a as H,b as _e,c as Ce,d as Ie,e as Le,f as Pe}from"./chunks/chunk-PHHUHR7T.js";import"./chunks/chunk-HITD7CX6.js";import"./chunks/chunk-KK4GE65D.js";import"./chunks/chunk-6I6QKTFK.js";import"./chunks/chunk-ETOEZTGL.js";var B=4*Number.EPSILON,Ue={4:[0,1],5:[.5,.5],6:[0,0],8:[1/3,1/3],9:[3/8,3/8]};function qe(e,n,t){let r=e.length,o=a=>e[Math.min(Math.max(a,1),r)-1];if(t===7){let a=1+(r-1)*n,g=Math.floor(a),m=o(g),y=o(Math.ceil(a));if(a>g&&y!==m){let b=a-g;return(1-b)*m+b*y}return m}let i,l;if(t<=3){let a=t===3?r*n-.5:r*n;i=Math.floor(a*(1+B)),t===1?l=a>i?1:0:t===2?l=a>i?1:.5:l=a!==i||Math.abs(i%2)===1?1:0}else{let[a,g]=Ue[t],m=a+n*(r+1-a-g);i=Math.floor(m*(1+B)),l=m-i,Math.abs(l)<B&&(l=0)}let s=o(i),u=o(i+1);return l===1?u:l>0&&l<1&&s!==u?(1-l)*s+l*u:s}function C(e,n=[0,.25,.5,.75,1],t={}){let r=t.type??7;if(!(Number.isInteger(r)&&r>=1&&r<=9))throw new RangeError("'type' must be an integer in 1..9");let o=V(e,t.naRm);if(o===void 0)throw new RangeError("missing values and NaN's not allowed if 'na.rm' is FALSE");let i=o.sort((a,g)=>a-g),l=typeof n=="number"?[n]:Array.from(n),s=100*Number.EPSILON;if(l.some(a=>a<-s||a>1+s))throw new RangeError("'probs' outside [0,1]");let u=l.map(a=>Number.isNaN(a)||i.length===0?NaN:qe(i,Math.min(Math.max(a,0),1),r));return typeof n=="number"?u[0]:u}function W(e,n={}){let[t,r]=C(e,[.25,.75],n);return r-t}function ze(e){let n=Array.from(e).filter(i=>!Number.isNaN(i)).sort((i,l)=>i-l),t=n.length;if(t===0)return[NaN,NaN,NaN,NaN,NaN];let r=Math.floor((t+3)/2)/2;return[1,r,(t+1)/2,t+1-r,t].map(i=>.5*(n[Math.floor(i)-1]+n[Math.ceil(i)-1]))}function Ve(e,n={}){let t=V(e,n.naRm);if(t===void 0)return NaN;let r=n.center??R(t),o=n.constant??1.4826,i=n.low??!1,l=n.high??!1,s=t.map(a=>Math.abs(a-r)),u=s.length;if((i||l)&&u%2===0){if(i&&l)throw new RangeError("'low' and 'high' cannot be both TRUE");let a=u/2+(l?1:0),g=s.sort((m,y)=>m-y);return o*g[a-1]}return o*R(s)}var K=e=>e===null||typeof e=="number"&&Number.isNaN(e),Y=e=>Array.isArray(e)||ArrayBuffer.isView(e);function Be(e){if(Y(e))return{columns:[e],rows:e.length};if(typeof e!="object"||e===null)throw new TypeError("the arguments must be arrays or data frames");let n=Object.values(e),t=n[0]?.length??0;if(n.some(r=>r.length!==t))throw new RangeError("not all arguments have the same length");return{columns:n,rows:t}}function ee(...e){if(e.length===0)throw new RangeError("no input has determined the number of cases");let n=e.map(Be),t=n[0].rows;if(n.some(o=>o.rows!==t))throw new RangeError("not all arguments have the same length");let r=n.flatMap(o=>o.columns);return Array.from({length:t},(o,i)=>r.every(l=>!K(l[i])))}function We(e){if(Y(e))return Array.from(e).filter(r=>!K(r));let n=ee(e),t={};for(let[r,o]of Object.entries(e)){let i=Array.from(o).filter((l,s)=>n[s]);t[r]=o instanceof Float64Array?Float64Array.from(i):i}return t}function ne(e,n={}){let t=Array.from(e).filter(Number.isFinite);if(t.length===0)return[];let r=n.n??5,o=n.minN??Math.floor(r/3),i=n.shrinkSml??.75,l=n.highUBias??1.5,s=n.u5Bias??.5+1.5*l,u=1/0,a=-1/0;for(let w of t)w<u&&(u=w),w>a&&(a=w);let g=a-u,m,y;if(g===0&&a===0)m=1,y=!0;else{m=Math.max(Math.abs(u),Math.abs(a));let M=(1+(s>=1.5*l+.5?1/(1+l):1.5/(1+s)))*Math.max(1,r)*Number.EPSILON;y=g<m*M*3}y?(m>10&&(m=9+m/10),m*=i,o>1&&(m/=o)):(m=r>1?g/r:g,g===1/0&&r>=2&&(m=a/r-u/r));let b=2**-20*Ze;m<b?m=b:m>Number.MAX_VALUE/1.25&&(m=Number.MAX_VALUE/1.25);let d=10**Math.floor(Math.log10(m)),x=[[2*d,l],[5*d,s],[10*d,l]],N=d;for(let[w,M]of x)if(w-m<M*(m-N))N=w;else break;let h=1e-10,f=Math.floor(u/N+h);for(;f*N>u+h*N;)f--;for(;!Number.isFinite(f*N);)f++;let c=Math.ceil(a/N-h);for(;c*N<a-h*N;)c++;for(;!Number.isFinite(c*N);)c--;let p=Math.trunc(.5+c-f);if(p<o){let w=o-p,M=Math.floor(w/2),O=w%2;u===0&&f===0&&a!==0?c+=w:a===0&&c===0&&u!==0?f-=w:f>=0?(c+=M,f-=M+O):(f-=M,c+=M+O),p=o}let E=f*N<u?f*N:u,A=c*N>a?c*N:a;if(p<=0)return[E];let $;if(Number.isFinite(A-E))$=H(E,A,p+1);else{let w=A/p-E/p;$=Array.from({length:p+1},(M,O)=>E+O*w),$[p]=A}let v=A/p-E/p;return $.map(w=>Math.abs(w)<1e-14*v?0:w)}var Ze=22250738585072014e-324;function De(e){return e===0||!Number.isFinite(e)?e:Number(e.toPrecision(5))}function Qe(e,n){let t=e.length,[r,o]=j(e),i=o-r;switch(n.toLowerCase()){case"sturges":return Math.ceil(Math.log2(t)+1);case"scott":{let l=3.5*_(e)*t**-.3333333333333333;return l>0?Math.max(1,Math.ceil(i/l)):1}case"fd":case"freedman-diaconis":{let l=e.map(De),s=2*W(l);for(let u=1/8;s===0&&u>=1/512;u/=2){let[a,g]=C(l,[u,1-u]);s=(g-a)/(1-2*u)}return s===0&&(s=3.5*_(e)),s>0?Math.ceil(i/s*t**(1/3)):1}default:throw new RangeError("unknown 'breaks' algorithm")}}function Je(e,n){let t=e.slice(1).map((r,o)=>r-e[o]);return e.length>5?R(t):e.length<=3?n:Math.min(...t.filter(r=>r>0))}function Xe(e,n={}){let t=Array.from(e).filter(Number.isFinite),r=t.length,o=n.right??!0,i=n.includeLowest??!0,l=n.breaks??"Sturges",s;if(typeof l!="string"&&typeof l!="number"&&l.length>1)s=[...l].sort((h,f)=>h-f);else{i=!0;let h=typeof l=="string"?Qe(t,l):typeof l=="number"?l:l[0];if(!Number.isFinite(h)||h<1)throw new RangeError("invalid number of 'breaks'");h=Math.min(h,1e6);let[f,c]=j(t);s=ne([f,c],{n:h,minN:1});for(let p=1;p<s.length;p++)if(!(s[p]-s[p-1]>0))throw new RangeError("'breaks' are not strictly increasing")}let u=s.length,[a,g]=r>0?j(t):[0,0],m=1e-7*Je(s,g-a),y=s.map((h,f)=>o?f===0&&i?h-m:h+m:f<u-1?h-m:i?h+m:h-m),b=new Array(Math.max(0,u-1)).fill(0),d=0;for(let h of t){let f=Ge(h,y,o,i);f>=0&&(b[f]++,d++)}if(d<r)throw new RangeError("some 'x' not counted; maybe 'breaks' do not span range of 'x'");let x=b.map((h,f)=>h/(r*(s[f+1]-s[f]))),N=b.map((h,f)=>.5*(s[f+1]+s[f]));return{breaks:s,counts:b,density:x,mids:N}}function Ge(e,n,t,r){let o=n.length-1;if(o<1)return-1;if(t){if(e===n[0]&&r)return 0;if(!(e>n[0]&&e<=n[o]))return-1;let s=1,u=o;for(;s<u;){let a=s+u>>1;e<=n[a]?u=a:s=a+1}return s-1}if(e===n[o]&&r)return o-1;if(!(e>=n[0]&&e<n[o]))return-1;let i=0,l=o-1;for(;i<l;){let s=i+l+1>>1;n[s]<=e?i=s:l=s-1}return i}function He(e){let n=Array.from(e).filter(r=>!Number.isNaN(r)).sort((r,o)=>r-o),t=n.length;if(t<1)throw new RangeError("'x' must have 1 or more non-missing values");return r=>{if(Number.isNaN(r))return NaN;let o=0,i=t;for(;o<i;){let l=o+i>>1;n[l]<=r?o=l+1:i=l}return o/t}}var I=e=>e===null||typeof e=="number"&&Number.isNaN(e),Ke=(e,n)=>typeof e=="number"?e-n:typeof e=="string"?X(e,n):Number(e)-Number(n),Ye=e=>typeof e=="boolean"?e?"TRUE":"FALSE":typeof e=="string"?e:Number.isFinite(e)?S(e):e>0?"Inf":"-Inf";function en(e,n){let t=Array.from(n,s=>s===0?0:s),r=new Set(t.filter(s=>!I(s)).map(s=>typeof s));if(r.size>1)throw new TypeError(`${e} mixes ${[...r].join(" and ")} labels`);let o=[...r][0];if(o!==void 0&&o!=="number"&&o!=="string"&&o!=="boolean")throw new TypeError(`${e} has labels of an unsupported type`);let i=[...new Set(t.filter(s=>!I(s)))].sort(Ke),l=new Map(i.map((s,u)=>[s,u]));return{levels:i,codes:t.map(s=>I(s)?-1:l.get(s))}}var F=e=>Array.isArray(e)||e instanceof Float64Array;function se(e){if(e instanceof Float64Array)return[e];if(!Array.isArray(e))throw new TypeError("the group labels must be an array or an array of arrays");if(e.length>0&&e.every(F))return[...e];if(e.some(F))throw new TypeError("the group labels must be an array or an array of arrays");return[e]}function Z(e,n,t){e.forEach((l,s)=>{if(l.length!==t)throw new RangeError(`${n[s]} must have one label per row (${t}), not ${l.length}`)});let r=e.map((l,s)=>en(n[s],l)),o=r.reduce((l,s)=>l*s.levels.length,1),i=new Array(t);for(let l=0;l<t;l++){let s=0,u=1;for(let a of r){let g=a.codes[l];if(g<0){s=-1;break}s+=g*u,u*=a.levels.length}i[l]=s}return{factors:r,size:o,cells:i}}function D(e){let n=Array.from({length:e.size},()=>[]);return e.cells.forEach((t,r)=>{t>=0&&n[t].push(r)}),n}function le(e,n){return e.factors.map(t=>{let r=t.levels.length,o=t.levels[n%r];return n=Math.floor(n/r),o})}var ae=(e,n)=>Array.from({length:e},(t,r)=>e===1?n:`${n}[${r}]`);function nn(e,n,t){let r=Array.from(e),o=se(n),i=Z(o,ae(o.length,"index"),r.length),l=D(i).map(a=>a.length===0?null:{value:t(a.map(g=>r[g]))}),u=l.every(a=>a===null||typeof a.value=="number")?l.map(a=>a===null?NaN:a.value):l.map(a=>a===null?null:a.value);return{dim:i.factors.map(a=>a.levels.length),dimnames:i.factors.map(a=>[...a.levels]),values:u}}function tn(e,n){let t={};for(let[r,o]of Object.entries(e))t[r]=o instanceof Float64Array?Float64Array.from(n,i=>o[i]):n.map(i=>o[i]);return t}function rn(e){let t=Object.values(e)[0]?.length??0;for(let[r,o]of Object.entries(e)){if(!F(o))throw new TypeError(`column '${r}' must be an array`);if(o.length!==t)throw new RangeError(`the columns of the data frame have different lengths (found for '${r}')`)}return t}function on(e,n,t={}){let r=t.sep??".",o=se(n),i=!F(e);if(i&&(typeof e!="object"||e===null))throw new TypeError("x must be an array or a data frame");let l=i?rn(e):e.length,s=Z(o,ae(o.length,"f"),l),u=i?[]:Array.from(e),a=new Map;return D(s).forEach((g,m)=>{if(g.length===0&&(t.drop||s.factors.length===1))return;let y=le(s,m).map(Ye).join(r);a.set(y,i?tn(e,g):g.map(b=>u[b]))}),a}function te(e,n){if(n===void 0)throw new Error(`object '${e}' not found`);if(!F(n))throw new TypeError(`column '${e}' must be an array`);return Array.from(n,t=>{if(t===null)return NaN;if(typeof t!="number")throw new TypeError(`column '${e}' to summarise must be numeric`);return t})}function re(e,n){let t=Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0;if(t===void 0)throw new Error(`object '${n}' not found`);if(!F(t))throw new TypeError(`column '${n}' must be an array`);return t}function L(e,n){if(e.type==="var")n.push(e.name);else if(e.type==="binary"&&e.op==="+")L(e.left,n),L(e.right,n);else if(e.type==="paren")L(e.arg,n);else throw new SyntaxError("invalid formula: the right-hand side must be grouping variables joined by '+'");return n}function sn(e,n){if(typeof e!="string")throw new TypeError("the formula must be a string");let t=e.indexOf("~");if(t<0)throw new SyntaxError("invalid formula: missing '~'");let r=e.slice(0,t).trim(),o=L(J(`~ ${e.slice(t+1)}`).rhs,[]),i=/^[A-Za-z.][A-Za-z0-9._]*$/,l;if(r===".")l=n.filter(s=>!o.includes(s));else{let s=/^cbind\s*\((.*)\)$/s.exec(r);if(l=s===null?[r]:s[1].split(",").map(u=>u.trim()),l.some(u=>!i.test(u)||u==="."))throw new SyntaxError("invalid formula: the left-hand side must be a variable, cbind(...) of variables or '.'")}return{values:l,groups:o}}function oe(e,n,t,r,o,i){let l=r[0]?.length??0;e.forEach((m,y)=>{if(n[y].length!==l)throw new RangeError(`variable lengths differ (found for '${m}')`)});let s=Z(r,t,l),u=D(s).map((m,y)=>({cell:y,rows:m.filter(o)})).filter(m=>m.rows.length>0),a={},g=u.map(m=>le(s,m.cell));return t.forEach((m,y)=>{a[m]=g.map(b=>b[y])}),e.forEach((m,y)=>{let b=n[y],x=u.map(h=>i(h.rows.map(f=>b[f]))).map(h=>{if(typeof h=="number")return{names:void 0,values:[h]};if(Array.isArray(h))return{names:void 0,values:[...h]};let f=h;return{names:Object.keys(f),values:Object.values(f)}}),N=x[0]?.values.length??1;if(x.some(h=>h.values.length!==N))throw new RangeError("fun must return values of the same length for every group");if(N===1&&x[0]?.names===void 0){a[m]=x.map(h=>h.values[0]);return}for(let h=0;h<N;h++){let f=x[0].names?.[h]??String(h+1);a[`${m}.${f}`]=x.map(c=>c.values[h])}}),a}function ln(e,n,t){if(typeof n!="object"||n===null)throw new TypeError("the data must be an object of columns");if(typeof e=="string"){let s=n,{values:u,groups:a}=sn(e,Object.keys(s)),g=d=>Object.prototype.hasOwnProperty.call(s,d),m=u.map(d=>te(d,g(d)?s[d]:void 0)),y=a.map(d=>re(s,d));return oe(u,m,a,y,d=>m.every(x=>!Number.isNaN(x[d]))&&y.every(x=>!I(x[d])),t)}if(typeof e!="object"||e===null)throw new TypeError("x must be a data frame");let r=Object.keys(e),o=r.map(s=>te(s,e[s])),i=Object.keys(n);if(i.length===0)throw new RangeError("'by' must name at least one grouping column");let l=i.map(s=>re(n,s));return oe(r,o,i,l,()=>!0,t)}var P=e=>typeof e=="string"?[e]:[...e];function ce(e,n){for(let t of n)if(!Object.hasOwn(e,t))throw new Error(`Column \`${t}\` doesn't exist.`)}function an(e,n){if(n instanceof Float64Array)return"double";let t=null;for(let r of n){if(r===null)continue;let o=typeof r=="number"?"double":typeof r=="string"?"character":"logical";if(t!==null&&o!==t)throw new TypeError(`column '${e}' mixes ${t} and ${o} values`);t=o}return t}function cn(e,n){let t=null;for(let r of n){let o=an(r,e[r]);if(o!==null){if(t===null)t={type:o,column:r};else if(t.type!==o){if(t.type==="character"||o==="character")throw new TypeError(`Can't combine \`${t.column}\` <${t.type}> and \`${r}\` <${o}>.`);o==="double"&&(t={type:o,column:r})}}}return t?.type??null}function fn(e,n,t){let r=new RegExp(`${n}|`).exec("").length-1;if(r!==t)throw new Error(`\`regex\` should define ${t} groups; ${r} found.`);let o=new RegExp(n);return e.map(i=>{let l=o.exec(i);return Array.from({length:t},(s,u)=>l===null?null:l[u+1]??null)})}function un(e,n,t,r){let o=new RegExp(n,"g"),i=[],l=[],s=e.map((a,g)=>{let m=[],y=0;for(let b of a.matchAll(o))b[0].length!==0&&(m.push(a.slice(y,b.index)),y=b.index+b[0].length);return m.push(a.slice(y)),m.length>t&&i.push(g+1),m.length<t&&l.push(g+1),Array.from({length:t},(b,d)=>m[d]??null)}),u=a=>`${a.length} rows [${a.join(", ")}]`;return i.length>0&&r.push(`Expected ${t} pieces. Additional pieces discarded in ${u(i)}.`),l.length>0&&r.push(`Expected ${t} pieces. Missing pieces filled with \`NA\` in ${u(l)}.`),s}function mn(e,n,t,r){let{namesSep:o,namesPattern:i}=t;if(n.length===1){if(o!==void 0)throw new Error("`names_sep` can't be used with a length 1 `names_to`.");if(i===void 0)return e.map(s=>[s]);let l=new RegExp(i);return e.map(s=>[l.exec(s)?.[1]??null])}if(o===void 0==(i===void 0))throw new Error("If you supply multiple names in `names_to` you must also supply one of `names_sep` or `names_pattern`.");return o!==void 0?un(e,o,n.length,r):fn(e,i,n.length)}function hn(e,n){let t=q(e),r=Object.keys(e),o=typeof n.cols=="function"?r.filter(n.cols):[...new Set(n.cols)];if(ce(e,o),o.length===0)throw new Error("`cols` must select at least one column.");let i=P(n.namesTo??"name"),l=i.indexOf(".value");if(i.lastIndexOf(".value")!==l)throw new Error('`names_to` may contain ".value" only once');let s=[],u=n.namesPrefix===void 0?null:new RegExp(`^(?:${n.namesPrefix})`),a=o.map(f=>u===null?f:f.replace(u,"")),g=mn(a,i,n,s),m=[],y=[];if(l<0)m.push(...g),y.push({name:n.valuesTo??"value",sources:[...o]});else{let f=new Map,c=new Map;g.forEach((p,E)=>{let A=p.filter((O,U)=>U!==l),$=JSON.stringify(A),v=f.get($);if(v===void 0){v=m.length,f.set($,v),m.push(A);for(let O of y)O.sources.push(null)}let w=p[l]??"NA",M=c.get(w);if(M===void 0&&(M={name:w,sources:m.map(()=>null)},c.set(w,M),y.push(M)),M.sources[v]!==null)throw new Error(`the names give the value column '${w}' twice for one key`);M.sources[v]=o[E]})}let b=y.map(f=>cn(e,f.sources.filter(c=>c!==null))),d=[];if(n.colsVary==="slowest")for(let f=0;f<m.length;f++)for(let c=0;c<t;c++)d.push([c,f]);else for(let f=0;f<t;f++)for(let c=0;c<m.length;c++)d.push([f,c]);let x=(f,c,p)=>{let E=f.sources[p];return E==null?null:e[E][c]};n.valuesDropNa===!0&&(d=d.filter(([f,c])=>y.some(p=>!T(x(p,f,c)))));let N={},h=d.map(([f])=>f);for(let f of r)o.includes(f)||k(N,f,z(e[f],h));if(i.forEach((f,c)=>{if(c===l)return;let p=n.namesTransform?.[f],E=A=>{let $=m[A][c<l||l<0?c:c-1];return $===null||p===void 0?$:p($)};k(N,f,d.map(([,A])=>E(A)))}),y.forEach((f,c)=>{let p=b[c]==="double";if(p&&f.sources.every(E=>E!==null&&e[E]instanceof Float64Array))k(N,f.name,Float64Array.from(d,([E,A])=>x(f,E,A)));else{let E=d.map(([A,$])=>{let v=x(f,A,$);return p&&typeof v=="boolean"?Number(v):v});k(N,f.name,E)}}),n.onWarning!==void 0)for(let f of new Set(s))n.onWarning(f);return N}var pn=e=>T(e)?"NA":typeof e=="number"?`n${e}`:typeof e=="string"?`s${e}`:`b${String(e)}`;function ie(e,n){let t=new Map,r=[];return{codes:Array.from({length:n},(i,l)=>{let s=JSON.stringify(e.map(a=>pn(a[l]))),u=t.get(s);return u===void 0&&(u=r.length,t.set(s,u),r.push(l)),u}),firsts:r}}function gn(e){return T(e)?"NA":typeof e=="number"?Number.isFinite(e)?S(e):e>0?"Inf":"-Inf":typeof e=="boolean"?e?"TRUE":"FALSE":e}function Q(e,n,t){if(e!==void 0)return n(e)?e:e[t]}function yn(e,n={}){let t=q(e),r=P(n.namesFrom??"name"),o=P(n.valuesFrom??"value"),i=n.idCols===void 0?Object.keys(e).filter(c=>!r.includes(c)&&!o.includes(c)):P(n.idCols);ce(e,[...i,...r,...o]);let l=n.namesPrefix??"",s=n.namesSep??"_",u=ie(i.map(c=>e[c]),t),a=ie(r.map(c=>e[c]),t),g=a.firsts.map((c,p)=>p);n.namesSort===!0&&g.sort((c,p)=>{for(let E of r){let A=G(e[E][a.firsts[c]],e[E][a.firsts[p]]);if(A!==0)return A}return 0});let m=a.firsts.map(c=>l+r.map(p=>gn(e[p][c])).join(s)),y=a.firsts.length,b=Array.from({length:u.firsts.length*y},()=>[]);for(let c=0;c<t;c++)b[u.codes[c]*y+a.codes[c]].push(c);let d=c=>typeof c=="function",x=c=>typeof c!="object"||c===null,N=(c,p)=>{let E=e[c],A=Q(n.valuesFn,d,c),$=Q(n.valuesFill,x,c)??null,v=u.firsts.map((w,M)=>{let O=b[M*y+p];return O.length===0?$:A!==void 0?A(O.map(U=>E[U])):E[O[0]]});return E instanceof Float64Array&&v.every(w=>w===null||typeof w=="number")?Float64Array.from(v,w=>w===null?NaN:w):v};for(let c of o)if(Q(n.valuesFn,d,c)===void 0&&b.some(p=>p.length>1))throw new Error(`values from '${c}' are not uniquely identified; use valuesFn to summarise them`);let h={};for(let c of i)k(h,c,z(e[c],u.firsts));let f=(c,p)=>o.length===1?m[p]:`${c}${s}${m[p]}`;if(n.namesVary==="slowest")for(let c of g)for(let p of o)k(h,f(p,c),N(p,c));else for(let c of o)for(let p of g)k(h,f(c,p),N(c,p));return h}export{W as IQR,ln as aggregate,ee as completeCases,me as cor,ue as cov,Me as cummax,$e as cummin,xe as cumprod,Ae as cumsum,Le as cut,Se as cv,ve as diff,He as ecdf,Pe as findInterval,ze as fivenum,ge as fromRows,Re as geometricMean,Xe as hist,ke as kurtosis,Ve as mad,be as mean,je as meanAD,R as median,he as merge,Fe as modes,We as naOmit,hn as pivotLonger,yn as pivotWider,ne as pretty,we as prod,C as quantile,j as range,fe as rank,Te as scale,_ as sd,Oe as skewness,on as split,pe as subset,de as sum,Ce as table,_e as tabulate,nn as tapply,ye as toRows,Ie as unique,Ee as variance,Ne as weightedMean};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type Vectorizable, type VectorResult } from "../internal/vectorize.js";
|
|
2
2
|
import { type DensityOptions, type TailOptions } from "../internal/dpq.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Limits of the arcsine distribution.
|
|
5
|
+
*
|
|
6
|
+
* @category Distributions
|
|
7
|
+
*/
|
|
4
8
|
export interface ArcsineParams {
|
|
5
9
|
/** Lower limit. Default `0`. */
|
|
6
10
|
a?: number;
|
|
@@ -11,14 +15,45 @@ export declare function darcsine1(x: number, a: number, b: number, log: boolean)
|
|
|
11
15
|
export declare function parcsine1(q: number, a: number, b: number, lowerTail: boolean, logP: boolean): number;
|
|
12
16
|
export declare function qarcsine1(p: number, a: number, b: number, lowerTail: boolean, logP: boolean): number;
|
|
13
17
|
/**
|
|
14
|
-
* Density of the arcsine distribution on (a, b), f(x) = 1 / (pi sqrt((x - a)(b - x))).
|
|
15
|
-
*
|
|
18
|
+
* Density of the arcsine distribution on (a, b), f(x) = 1 / (pi sqrt((x - a)(b - x))).
|
|
19
|
+
* Not an R function. Neither base R nor extraDistr has the arcsine distribution; this equals
|
|
20
|
+
* `dbeta((x - a) / (b - a), 0.5, 0.5) / (b - a)`.
|
|
16
21
|
*
|
|
17
22
|
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
18
23
|
* @param options - `a` and `b` (see {@link ArcsineParams}) and `log` (see {@link DensityOptions}).
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* darcsine(0.5); // 0.6366197723675813
|
|
28
|
+
* darcsine(1, { a: 0, b: 4 }); // 0.1837762984739307
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @category Distributions
|
|
19
32
|
*/
|
|
20
33
|
export declare function darcsine<T extends Vectorizable>(x: T, options?: ArcsineParams & DensityOptions): VectorResult<T>;
|
|
21
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Distribution function of the arcsine distribution on (a, b): `pbeta((q - a) / (b - a), 0.5, 0.5)`.
|
|
36
|
+
* Not an R function. Neither base R nor extraDistr has the arcsine distribution.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* parcsine(0.25); // 0.3333333333333333
|
|
41
|
+
* parcsine(1, { a: 0, b: 4 }); // 0.3333333333333333
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @category Distributions
|
|
45
|
+
*/
|
|
22
46
|
export declare function parcsine<T extends Vectorizable>(q: T, options?: ArcsineParams & TailOptions): VectorResult<T>;
|
|
23
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Quantile function of the arcsine distribution on (a, b): `a + (b - a) qbeta(p, 0.5, 0.5)`.
|
|
49
|
+
* Not an R function. Neither base R nor extraDistr has the arcsine distribution.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* qarcsine(0.5); // 0.5
|
|
54
|
+
* qarcsine(0.25, { a: 0, b: 4 }); // 0.5857864376269049
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @category Distributions
|
|
58
|
+
*/
|
|
24
59
|
export declare function qarcsine<T extends Vectorizable>(p: T, options?: ArcsineParams & TailOptions): VectorResult<T>;
|
|
@@ -51,22 +51,53 @@ export function qarcsine1(p, a, b, lowerTail, logP) {
|
|
|
51
51
|
return b - (b - a) * qbeta1(p, 0.5, 0.5, !lowerTail, logP);
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
|
-
* Density of the arcsine distribution on (a, b), f(x) = 1 / (pi sqrt((x - a)(b - x))).
|
|
55
|
-
*
|
|
54
|
+
* Density of the arcsine distribution on (a, b), f(x) = 1 / (pi sqrt((x - a)(b - x))).
|
|
55
|
+
* Not an R function. Neither base R nor extraDistr has the arcsine distribution; this equals
|
|
56
|
+
* `dbeta((x - a) / (b - a), 0.5, 0.5) / (b - a)`.
|
|
56
57
|
*
|
|
57
58
|
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
58
59
|
* @param options - `a` and `b` (see {@link ArcsineParams}) and `log` (see {@link DensityOptions}).
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* darcsine(0.5); // 0.6366197723675813
|
|
64
|
+
* darcsine(1, { a: 0, b: 4 }); // 0.1837762984739307
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @category Distributions
|
|
59
68
|
*/
|
|
60
69
|
export function darcsine(x, options = {}) {
|
|
61
70
|
const { a = 0, b = 1, log = false } = options;
|
|
62
71
|
return vectorize(x, (v) => darcsine1(v, a, b, log));
|
|
63
72
|
}
|
|
64
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* Distribution function of the arcsine distribution on (a, b): `pbeta((q - a) / (b - a), 0.5, 0.5)`.
|
|
75
|
+
* Not an R function. Neither base R nor extraDistr has the arcsine distribution.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```ts
|
|
79
|
+
* parcsine(0.25); // 0.3333333333333333
|
|
80
|
+
* parcsine(1, { a: 0, b: 4 }); // 0.3333333333333333
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* @category Distributions
|
|
84
|
+
*/
|
|
65
85
|
export function parcsine(q, options = {}) {
|
|
66
86
|
const { a = 0, b = 1, lowerTail = true, logP = false } = options;
|
|
67
87
|
return vectorize(q, (v) => parcsine1(v, a, b, lowerTail, logP));
|
|
68
88
|
}
|
|
69
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* Quantile function of the arcsine distribution on (a, b): `a + (b - a) qbeta(p, 0.5, 0.5)`.
|
|
91
|
+
* Not an R function. Neither base R nor extraDistr has the arcsine distribution.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* qarcsine(0.5); // 0.5
|
|
96
|
+
* qarcsine(0.25, { a: 0, b: 4 }); // 0.5857864376269049
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* @category Distributions
|
|
100
|
+
*/
|
|
70
101
|
export function qarcsine(p, options = {}) {
|
|
71
102
|
const { a = 0, b = 1, lowerTail = true, logP = false } = options;
|
|
72
103
|
return vectorize(p, (v) => qarcsine1(v, a, b, lowerTail, logP));
|
|
@@ -23,6 +23,14 @@ export declare function qbeta1(p: number, a: number, b: number, lowerTail: boole
|
|
|
23
23
|
* @param shape2 - Second shape parameter (b).
|
|
24
24
|
* @param options - `ncp` (see {@link NoncentralOption}) and `log` (see {@link DensityOptions}).
|
|
25
25
|
* @returns The density (or log density).
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* dbeta(0.5, 2, 3); // 1.5
|
|
30
|
+
* dbeta([0.25, 0.75], 2, 3); // [1.6875, 0.5625]
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @category Distributions
|
|
26
34
|
*/
|
|
27
35
|
export declare function dbeta<T extends Vectorizable>(x: T, shape1: number, shape2: number, options?: DensityOptions & NoncentralOption): VectorResult<T>;
|
|
28
36
|
/**
|
|
@@ -40,6 +48,8 @@ export declare function dbeta<T extends Vectorizable>(x: T, shape1: number, shap
|
|
|
40
48
|
* ```ts
|
|
41
49
|
* pbeta(0.5, 2, 3); // 0.6875 (up to rounding)
|
|
42
50
|
* ```
|
|
51
|
+
*
|
|
52
|
+
* @category Distributions
|
|
43
53
|
*/
|
|
44
54
|
export declare function pbeta<T extends Vectorizable>(q: T, shape1: number, shape2: number, options?: TailOptions & NoncentralOption): VectorResult<T>;
|
|
45
55
|
/**
|
|
@@ -58,5 +68,7 @@ export declare function pbeta<T extends Vectorizable>(q: T, shape1: number, shap
|
|
|
58
68
|
* qbeta(0.025, 3, 7); // 0.07485463141969181
|
|
59
69
|
* qbeta([0.025, 0.975], 3, 7); // [0.07485463141969181, 0.6000935737163121]
|
|
60
70
|
* ```
|
|
71
|
+
*
|
|
72
|
+
* @category Distributions
|
|
61
73
|
*/
|
|
62
74
|
export declare function qbeta<T extends Vectorizable>(p: T, shape1: number, shape2: number, options?: TailOptions & NoncentralOption): VectorResult<T>;
|
|
@@ -208,6 +208,14 @@ export function qbeta1(p, a, b, lowerTail, logP) {
|
|
|
208
208
|
* @param shape2 - Second shape parameter (b).
|
|
209
209
|
* @param options - `ncp` (see {@link NoncentralOption}) and `log` (see {@link DensityOptions}).
|
|
210
210
|
* @returns The density (or log density).
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* dbeta(0.5, 2, 3); // 1.5
|
|
215
|
+
* dbeta([0.25, 0.75], 2, 3); // [1.6875, 0.5625]
|
|
216
|
+
* ```
|
|
217
|
+
*
|
|
218
|
+
* @category Distributions
|
|
211
219
|
*/
|
|
212
220
|
export function dbeta(x, shape1, shape2, options = {}) {
|
|
213
221
|
const { log = false, ncp } = options;
|
|
@@ -230,6 +238,8 @@ export function dbeta(x, shape1, shape2, options = {}) {
|
|
|
230
238
|
* ```ts
|
|
231
239
|
* pbeta(0.5, 2, 3); // 0.6875 (up to rounding)
|
|
232
240
|
* ```
|
|
241
|
+
*
|
|
242
|
+
* @category Distributions
|
|
233
243
|
*/
|
|
234
244
|
export function pbeta(q, shape1, shape2, options = {}) {
|
|
235
245
|
const { lowerTail = true, logP = false, ncp } = options;
|
|
@@ -253,6 +263,8 @@ export function pbeta(q, shape1, shape2, options = {}) {
|
|
|
253
263
|
* qbeta(0.025, 3, 7); // 0.07485463141969181
|
|
254
264
|
* qbeta([0.025, 0.975], 3, 7); // [0.07485463141969181, 0.6000935737163121]
|
|
255
265
|
* ```
|
|
266
|
+
*
|
|
267
|
+
* @category Distributions
|
|
256
268
|
*/
|
|
257
269
|
export function qbeta(p, shape1, shape2, options = {}) {
|
|
258
270
|
const { lowerTail = true, logP = false, ncp } = options;
|
|
@@ -11,6 +11,14 @@ export declare function qbinom1(p: number, size: number, prob: number, lowerTail
|
|
|
11
11
|
* @param prob - Probability of success on each trial.
|
|
12
12
|
* @param options - `log` (see {@link DensityOptions}).
|
|
13
13
|
* @returns The probability (or log probability).
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* dbinom(3, 10, 0.5); // 0.1171875
|
|
18
|
+
* dbinom([0, 5], 10, 0.5); // [0.0009765625, 0.24609375]
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @category Distributions
|
|
14
22
|
*/
|
|
15
23
|
export declare function dbinom<T extends Vectorizable>(x: T, size: number, prob: number, options?: DensityOptions): VectorResult<T>;
|
|
16
24
|
/**
|
|
@@ -27,6 +35,8 @@ export declare function dbinom<T extends Vectorizable>(x: T, size: number, prob:
|
|
|
27
35
|
* pbinom(3, 10, 0.5); // 0.171875
|
|
28
36
|
* pbinom([3, 5], 10, 0.5); // [0.171875, 0.623046875]
|
|
29
37
|
* ```
|
|
38
|
+
*
|
|
39
|
+
* @category Distributions
|
|
30
40
|
*/
|
|
31
41
|
export declare function pbinom<T extends Vectorizable>(q: T, size: number, prob: number, options?: TailOptions): VectorResult<T>;
|
|
32
42
|
/**
|
|
@@ -37,5 +47,13 @@ export declare function pbinom<T extends Vectorizable>(q: T, size: number, prob:
|
|
|
37
47
|
* @param prob - Probability of success on each trial.
|
|
38
48
|
* @param options - `lowerTail` and `logP` (see {@link TailOptions}).
|
|
39
49
|
* @returns The quantile(s).
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* qbinom(0.5, 10, 0.3); // 3
|
|
54
|
+
* qbinom([0.025, 0.975], 10, 0.3); // [0, 6]
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @category Distributions
|
|
40
58
|
*/
|
|
41
59
|
export declare function qbinom<T extends Vectorizable>(p: T, size: number, prob: number, options?: TailOptions): VectorResult<T>;
|
|
@@ -92,6 +92,14 @@ export function qbinom1(p, size, prob, lowerTail, logP) {
|
|
|
92
92
|
* @param prob - Probability of success on each trial.
|
|
93
93
|
* @param options - `log` (see {@link DensityOptions}).
|
|
94
94
|
* @returns The probability (or log probability).
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* dbinom(3, 10, 0.5); // 0.1171875
|
|
99
|
+
* dbinom([0, 5], 10, 0.5); // [0.0009765625, 0.24609375]
|
|
100
|
+
* ```
|
|
101
|
+
*
|
|
102
|
+
* @category Distributions
|
|
95
103
|
*/
|
|
96
104
|
export function dbinom(x, size, prob, options = {}) {
|
|
97
105
|
const log = options.log ?? false;
|
|
@@ -111,6 +119,8 @@ export function dbinom(x, size, prob, options = {}) {
|
|
|
111
119
|
* pbinom(3, 10, 0.5); // 0.171875
|
|
112
120
|
* pbinom([3, 5], 10, 0.5); // [0.171875, 0.623046875]
|
|
113
121
|
* ```
|
|
122
|
+
*
|
|
123
|
+
* @category Distributions
|
|
114
124
|
*/
|
|
115
125
|
export function pbinom(q, size, prob, options = {}) {
|
|
116
126
|
const { lowerTail = true, logP = false } = options;
|
|
@@ -124,6 +134,14 @@ export function pbinom(q, size, prob, options = {}) {
|
|
|
124
134
|
* @param prob - Probability of success on each trial.
|
|
125
135
|
* @param options - `lowerTail` and `logP` (see {@link TailOptions}).
|
|
126
136
|
* @returns The quantile(s).
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```ts
|
|
140
|
+
* qbinom(0.5, 10, 0.3); // 3
|
|
141
|
+
* qbinom([0.025, 0.975], 10, 0.3); // [0, 6]
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @category Distributions
|
|
127
145
|
*/
|
|
128
146
|
export function qbinom(p, size, prob, options = {}) {
|
|
129
147
|
const { lowerTail = true, logP = false } = options;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Probability that a standard bivariate normal pair (X, Y) with correlation `rho` lies in the rectangle
|
|
3
|
-
* `lower ≤ (X, Y) ≤ upper`. Equivalent to mvtnorm
|
|
3
|
+
* `lower ≤ (X, Y) ≤ upper`. Equivalent to `mvtnorm::pmvnorm()` in R. The same as
|
|
4
|
+
* `pmvnorm(lower, upper, corr = matrix(c(1, rho, rho, 1), 2))`.
|
|
4
5
|
* Bounds may be infinite. Accurate to about 1e-15 absolute.
|
|
5
6
|
*
|
|
6
7
|
* @param lower - Lower bounds `[a1, a2]`.
|
|
@@ -11,5 +12,7 @@
|
|
|
11
12
|
* ```ts
|
|
12
13
|
* pbvnorm([-Infinity, -Infinity], [0, 0], 0.5); // 0.3333333333333333
|
|
13
14
|
* ```
|
|
15
|
+
*
|
|
16
|
+
* @category Distributions
|
|
14
17
|
*/
|
|
15
18
|
export declare function pbvnorm(lower: readonly [number, number] | readonly number[], upper: readonly [number, number] | readonly number[], rho: number): number;
|
|
@@ -100,7 +100,8 @@ function orthant(h, k, r) {
|
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Probability that a standard bivariate normal pair (X, Y) with correlation `rho` lies in the rectangle
|
|
103
|
-
* `lower ≤ (X, Y) ≤ upper`. Equivalent to mvtnorm
|
|
103
|
+
* `lower ≤ (X, Y) ≤ upper`. Equivalent to `mvtnorm::pmvnorm()` in R. The same as
|
|
104
|
+
* `pmvnorm(lower, upper, corr = matrix(c(1, rho, rho, 1), 2))`.
|
|
104
105
|
* Bounds may be infinite. Accurate to about 1e-15 absolute.
|
|
105
106
|
*
|
|
106
107
|
* @param lower - Lower bounds `[a1, a2]`.
|
|
@@ -111,6 +112,8 @@ function orthant(h, k, r) {
|
|
|
111
112
|
* ```ts
|
|
112
113
|
* pbvnorm([-Infinity, -Infinity], [0, 0], 0.5); // 0.3333333333333333
|
|
113
114
|
* ```
|
|
115
|
+
*
|
|
116
|
+
* @category Distributions
|
|
114
117
|
*/
|
|
115
118
|
export function pbvnorm(lower, upper, rho) {
|
|
116
119
|
if (lower.length !== 2 || upper.length !== 2)
|
|
@@ -14,6 +14,14 @@ export declare function qcauchy1(p: number, location: number, scale: number, low
|
|
|
14
14
|
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
15
15
|
* @param options - `location` and `scale` (see {@link LocationScaleParams}) and `log` (see {@link DensityOptions}).
|
|
16
16
|
* @returns The density (or log density).
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* dcauchy(0); // 0.3183098861837907
|
|
21
|
+
* dcauchy(1, { location: 1, scale: 2 }); // 0.15915494309189535
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @category Distributions
|
|
17
25
|
*/
|
|
18
26
|
export declare function dcauchy<T extends Vectorizable>(x: T, options?: LocationScaleParams & DensityOptions): VectorResult<T>;
|
|
19
27
|
/**
|
|
@@ -22,6 +30,14 @@ export declare function dcauchy<T extends Vectorizable>(x: T, options?: Location
|
|
|
22
30
|
* @param q - Quantile(s): a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
23
31
|
* @param options - `location` and `scale` (see {@link LocationScaleParams}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
24
32
|
* @returns The probability (or log probability).
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* pcauchy(1); // 0.75
|
|
37
|
+
* pcauchy(3, { location: 1, scale: 2 }); // 0.75
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @category Distributions
|
|
25
41
|
*/
|
|
26
42
|
export declare function pcauchy<T extends Vectorizable>(q: T, options?: LocationScaleParams & TailOptions): VectorResult<T>;
|
|
27
43
|
/**
|
|
@@ -30,5 +46,13 @@ export declare function pcauchy<T extends Vectorizable>(q: T, options?: Location
|
|
|
30
46
|
* @param p - Probability (or log probability with `logP`): a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
31
47
|
* @param options - `location` and `scale` (see {@link LocationScaleParams}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
32
48
|
* @returns The quantile(s).
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* qcauchy(0.75); // 1.0000000000000002
|
|
53
|
+
* qcauchy(0.975, { scale: 2 }); // 25.41240947234939
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @category Distributions
|
|
33
57
|
*/
|
|
34
58
|
export declare function qcauchy<T extends Vectorizable>(p: T, options?: LocationScaleParams & TailOptions): VectorResult<T>;
|
|
@@ -110,6 +110,14 @@ export function qcauchy1(p, location, scale, lowerTail, logP) {
|
|
|
110
110
|
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
111
111
|
* @param options - `location` and `scale` (see {@link LocationScaleParams}) and `log` (see {@link DensityOptions}).
|
|
112
112
|
* @returns The density (or log density).
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* dcauchy(0); // 0.3183098861837907
|
|
117
|
+
* dcauchy(1, { location: 1, scale: 2 }); // 0.15915494309189535
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @category Distributions
|
|
113
121
|
*/
|
|
114
122
|
export function dcauchy(x, options = {}) {
|
|
115
123
|
const { location = 0, scale = 1, log = false } = options;
|
|
@@ -121,6 +129,14 @@ export function dcauchy(x, options = {}) {
|
|
|
121
129
|
* @param q - Quantile(s): a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
122
130
|
* @param options - `location` and `scale` (see {@link LocationScaleParams}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
123
131
|
* @returns The probability (or log probability).
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```ts
|
|
135
|
+
* pcauchy(1); // 0.75
|
|
136
|
+
* pcauchy(3, { location: 1, scale: 2 }); // 0.75
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* @category Distributions
|
|
124
140
|
*/
|
|
125
141
|
export function pcauchy(q, options = {}) {
|
|
126
142
|
const { location = 0, scale = 1, lowerTail = true, logP = false } = options;
|
|
@@ -132,6 +148,14 @@ export function pcauchy(q, options = {}) {
|
|
|
132
148
|
* @param p - Probability (or log probability with `logP`): a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
133
149
|
* @param options - `location` and `scale` (see {@link LocationScaleParams}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
134
150
|
* @returns The quantile(s).
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* qcauchy(0.75); // 1.0000000000000002
|
|
155
|
+
* qcauchy(0.975, { scale: 2 }); // 25.41240947234939
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @category Distributions
|
|
135
159
|
*/
|
|
136
160
|
export function qcauchy(p, options = {}) {
|
|
137
161
|
const { location = 0, scale = 1, lowerTail = true, logP = false } = options;
|
|
@@ -10,6 +10,14 @@ import type { NoncentralOption } from "../internal/noncentral.js";
|
|
|
10
10
|
* @param df - Degrees of freedom.
|
|
11
11
|
* @param options - `ncp` (see {@link NoncentralOption}) and `log` (see {@link DensityOptions}).
|
|
12
12
|
* @returns The density (or log density).
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* dchisq(1, 3); // 0.24197072451914337
|
|
17
|
+
* dchisq(1, 3, { ncp: 2 }); // 0.12180056753215114
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @category Distributions
|
|
13
21
|
*/
|
|
14
22
|
export declare function dchisq<T extends Vectorizable>(x: T, df: number, options?: DensityOptions & NoncentralOption): VectorResult<T>;
|
|
15
23
|
/**
|
|
@@ -27,6 +35,8 @@ export declare function dchisq<T extends Vectorizable>(x: T, df: number, options
|
|
|
27
35
|
* pchisq(3.84, 1, { lowerTail: false }); // 0.05004352124870517
|
|
28
36
|
* pchisq(5, 3, { ncp: 2 }); // 0.5934051800831556
|
|
29
37
|
* ```
|
|
38
|
+
*
|
|
39
|
+
* @category Distributions
|
|
30
40
|
*/
|
|
31
41
|
export declare function pchisq<T extends Vectorizable>(q: T, df: number, options?: TailOptions & NoncentralOption): VectorResult<T>;
|
|
32
42
|
/**
|
|
@@ -38,5 +48,13 @@ export declare function pchisq<T extends Vectorizable>(q: T, df: number, options
|
|
|
38
48
|
* @param df - Degrees of freedom.
|
|
39
49
|
* @param options - `ncp` (see {@link NoncentralOption}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
40
50
|
* @returns The quantile(s).
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* qchisq(0.95, 1); // 3.841458820694125
|
|
55
|
+
* qchisq(0.05, 3, { lowerTail: false }); // 7.814727903251181
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @category Distributions
|
|
41
59
|
*/
|
|
42
60
|
export declare function qchisq<T extends Vectorizable>(p: T, df: number, options?: TailOptions & NoncentralOption): VectorResult<T>;
|
|
@@ -13,6 +13,14 @@ import { dnchisq1, pnchisq1, qnchisq1 } from "./nchisq.js";
|
|
|
13
13
|
* @param df - Degrees of freedom.
|
|
14
14
|
* @param options - `ncp` (see {@link NoncentralOption}) and `log` (see {@link DensityOptions}).
|
|
15
15
|
* @returns The density (or log density).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* dchisq(1, 3); // 0.24197072451914337
|
|
20
|
+
* dchisq(1, 3, { ncp: 2 }); // 0.12180056753215114
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @category Distributions
|
|
16
24
|
*/
|
|
17
25
|
export function dchisq(x, df, options = {}) {
|
|
18
26
|
const { log = false, ncp } = options;
|
|
@@ -35,6 +43,8 @@ export function dchisq(x, df, options = {}) {
|
|
|
35
43
|
* pchisq(3.84, 1, { lowerTail: false }); // 0.05004352124870517
|
|
36
44
|
* pchisq(5, 3, { ncp: 2 }); // 0.5934051800831556
|
|
37
45
|
* ```
|
|
46
|
+
*
|
|
47
|
+
* @category Distributions
|
|
38
48
|
*/
|
|
39
49
|
export function pchisq(q, df, options = {}) {
|
|
40
50
|
const { lowerTail = true, logP = false, ncp } = options;
|
|
@@ -51,6 +61,14 @@ export function pchisq(q, df, options = {}) {
|
|
|
51
61
|
* @param df - Degrees of freedom.
|
|
52
62
|
* @param options - `ncp` (see {@link NoncentralOption}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
53
63
|
* @returns The quantile(s).
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* qchisq(0.95, 1); // 3.841458820694125
|
|
68
|
+
* qchisq(0.05, 3, { lowerTail: false }); // 7.814727903251181
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
71
|
+
* @category Distributions
|
|
54
72
|
*/
|
|
55
73
|
export function qchisq(p, df, options = {}) {
|
|
56
74
|
const { lowerTail = true, logP = false, ncp } = options;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { type Vectorizable, type VectorResult } from "../internal/vectorize.js";
|
|
2
2
|
import { type DensityOptions, type TailOptions } from "../internal/dpq.js";
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Parameters of the exponential distribution.
|
|
5
|
+
*
|
|
6
|
+
* @category Distributions
|
|
7
|
+
*/
|
|
4
8
|
export interface ExponentialParams {
|
|
5
9
|
/** Rate. Default `1`. */
|
|
6
10
|
rate?: number;
|
|
@@ -14,6 +18,14 @@ export declare function qexp1(p: number, rate: number, lowerTail: boolean, logP:
|
|
|
14
18
|
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
15
19
|
* @param options - `rate` (see {@link ExponentialParams}) and `log` (see {@link DensityOptions}).
|
|
16
20
|
* @returns The density (or log density).
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* dexp(1); // 0.36787944117144233
|
|
25
|
+
* dexp(1, { rate: 2 }); // 0.2706705664732254
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @category Distributions
|
|
17
29
|
*/
|
|
18
30
|
export declare function dexp<T extends Vectorizable>(x: T, options?: ExponentialParams & DensityOptions): VectorResult<T>;
|
|
19
31
|
/**
|
|
@@ -22,6 +34,14 @@ export declare function dexp<T extends Vectorizable>(x: T, options?: Exponential
|
|
|
22
34
|
* @param q - Quantile(s): a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
23
35
|
* @param options - `rate` (see {@link ExponentialParams}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
24
36
|
* @returns The probability (or log probability).
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* pexp(1); // 0.6321205588285577
|
|
41
|
+
* pexp(1, { rate: 2, lowerTail: false }); // 0.1353352832366127
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @category Distributions
|
|
25
45
|
*/
|
|
26
46
|
export declare function pexp<T extends Vectorizable>(q: T, options?: ExponentialParams & TailOptions): VectorResult<T>;
|
|
27
47
|
/**
|
|
@@ -30,5 +50,13 @@ export declare function pexp<T extends Vectorizable>(q: T, options?: Exponential
|
|
|
30
50
|
* @param p - Probability (or log probability with `logP`): a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
31
51
|
* @param options - `rate` (see {@link ExponentialParams}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
32
52
|
* @returns The quantile(s).
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* qexp(0.5, { rate: 2 }); // 0.34657359027997264
|
|
57
|
+
* qexp([0.25, 0.75]); // [0.2876820724517809, 1.3862943611198906]
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @category Distributions
|
|
33
61
|
*/
|
|
34
62
|
export declare function qexp<T extends Vectorizable>(p: T, options?: ExponentialParams & TailOptions): VectorResult<T>;
|
|
@@ -64,6 +64,14 @@ export function qexp1(p, rate, lowerTail, logP) {
|
|
|
64
64
|
* @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
65
65
|
* @param options - `rate` (see {@link ExponentialParams}) and `log` (see {@link DensityOptions}).
|
|
66
66
|
* @returns The density (or log density).
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```ts
|
|
70
|
+
* dexp(1); // 0.36787944117144233
|
|
71
|
+
* dexp(1, { rate: 2 }); // 0.2706705664732254
|
|
72
|
+
* ```
|
|
73
|
+
*
|
|
74
|
+
* @category Distributions
|
|
67
75
|
*/
|
|
68
76
|
export function dexp(x, options = {}) {
|
|
69
77
|
const { rate = 1, log = false } = options;
|
|
@@ -75,6 +83,14 @@ export function dexp(x, options = {}) {
|
|
|
75
83
|
* @param q - Quantile(s): a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
76
84
|
* @param options - `rate` (see {@link ExponentialParams}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
77
85
|
* @returns The probability (or log probability).
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* pexp(1); // 0.6321205588285577
|
|
90
|
+
* pexp(1, { rate: 2, lowerTail: false }); // 0.1353352832366127
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @category Distributions
|
|
78
94
|
*/
|
|
79
95
|
export function pexp(q, options = {}) {
|
|
80
96
|
const { rate = 1, lowerTail = true, logP = false } = options;
|
|
@@ -86,6 +102,14 @@ export function pexp(q, options = {}) {
|
|
|
86
102
|
* @param p - Probability (or log probability with `logP`): a number, `number[]` or `Float64Array`. The result has the same shape.
|
|
87
103
|
* @param options - `rate` (see {@link ExponentialParams}), `lowerTail` and `logP` (see {@link TailOptions}).
|
|
88
104
|
* @returns The quantile(s).
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```ts
|
|
108
|
+
* qexp(0.5, { rate: 2 }); // 0.34657359027997264
|
|
109
|
+
* qexp([0.25, 0.75]); // [0.2876820724517809, 1.3862943611198906]
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @category Distributions
|
|
89
113
|
*/
|
|
90
114
|
export function qexp(p, options = {}) {
|
|
91
115
|
const { rate = 1, lowerTail = true, logP = false } = options;
|