@numero-uno-jpn/rstats 0.11.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.
Files changed (269) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.ja.md +5 -4
  3. package/README.md +6 -4
  4. package/dist/chunks/{chunk-YSWGDOWK.js → chunk-2X7JYQBI.js} +2 -2
  5. package/dist/chunks/{chunk-F5EDJFEO.js → chunk-36GVER3O.js} +2 -2
  6. package/dist/chunks/{chunk-7GQMKH3Z.js → chunk-3WUXRSM6.js} +1 -1
  7. package/dist/chunks/{chunk-JWBO5WVN.js → chunk-6I6QKTFK.js} +2 -2
  8. package/dist/chunks/{chunk-EZWBRCJL.js → chunk-ETOEZTGL.js} +1 -1
  9. package/dist/chunks/{chunk-VJ4BDBMU.js → chunk-FVPDVRJQ.js} +2 -2
  10. package/dist/chunks/{chunk-EZAFN5CD.js → chunk-GG4BJMJW.js} +1 -1
  11. package/dist/chunks/{chunk-5WDJPHYY.js → chunk-HITD7CX6.js} +1 -1
  12. package/dist/chunks/{chunk-Y5PYRAYP.js → chunk-KK4GE65D.js} +2 -2
  13. package/dist/chunks/{chunk-AHHS6AC4.js → chunk-LAUYSGV4.js} +2 -2
  14. package/dist/chunks/{chunk-ALM3VHFP.js → chunk-M6GDXKKS.js} +1 -1
  15. package/dist/chunks/{chunk-C5XTWMGB.js → chunk-PHHUHR7T.js} +1 -1
  16. package/dist/chunks/{chunk-TOGXTCZO.js → chunk-WQPFDDIY.js} +2 -2
  17. package/dist/chunks/{chunk-CGBNKHNZ.js → chunk-X2AWQSVS.js} +2 -2
  18. package/dist/chunks/{chunk-Y5CNQ266.js → chunk-ZRJQD7VS.js} +2 -2
  19. package/dist/data/grouping.d.ts +33 -12
  20. package/dist/data/grouping.js +2 -0
  21. package/dist/descriptive/basic.d.ts +130 -17
  22. package/dist/descriptive/basic.js +115 -14
  23. package/dist/descriptive/cov.d.ts +22 -12
  24. package/dist/descriptive/dataFrames.d.ts +39 -11
  25. package/dist/descriptive/dataFrames.js +14 -6
  26. package/dist/descriptive/factanal.d.ts +26 -6
  27. package/dist/descriptive/factanal.js +7 -3
  28. package/dist/descriptive/hist.d.ts +27 -6
  29. package/dist/descriptive/hist.js +9 -3
  30. package/dist/descriptive/missing.d.ts +13 -6
  31. package/dist/descriptive/missing.js +4 -2
  32. package/dist/descriptive/moments.d.ts +91 -13
  33. package/dist/descriptive/moments.js +66 -9
  34. package/dist/descriptive/omega.d.ts +28 -6
  35. package/dist/descriptive/omega.js +16 -4
  36. package/dist/descriptive/pivot.d.ts +22 -6
  37. package/dist/descriptive/pivot.js +7 -3
  38. package/dist/descriptive/quantile.d.ts +33 -5
  39. package/dist/descriptive/quantile.js +20 -2
  40. package/dist/descriptive/rank.d.ts +12 -2
  41. package/dist/descriptive/rank.js +2 -0
  42. package/dist/descriptive/table.d.ts +55 -7
  43. package/dist/descriptive/table.js +38 -4
  44. package/dist/descriptive.js +2 -2
  45. package/dist/distributions/arcsine.d.ts +40 -5
  46. package/dist/distributions/arcsine.js +35 -4
  47. package/dist/distributions/beta.d.ts +12 -0
  48. package/dist/distributions/beta.js +12 -0
  49. package/dist/distributions/binomial.d.ts +18 -0
  50. package/dist/distributions/binomial.js +18 -0
  51. package/dist/distributions/bvnorm.d.ts +4 -1
  52. package/dist/distributions/bvnorm.js +4 -1
  53. package/dist/distributions/cauchy.d.ts +24 -0
  54. package/dist/distributions/cauchy.js +24 -0
  55. package/dist/distributions/chisq.d.ts +18 -0
  56. package/dist/distributions/chisq.js +18 -0
  57. package/dist/distributions/exponential.d.ts +29 -1
  58. package/dist/distributions/exponential.js +24 -0
  59. package/dist/distributions/f.d.ts +18 -0
  60. package/dist/distributions/f.js +18 -0
  61. package/dist/distributions/gamma.d.ts +20 -0
  62. package/dist/distributions/gamma.js +18 -0
  63. package/dist/distributions/geometric.d.ts +24 -0
  64. package/dist/distributions/geometric.js +24 -0
  65. package/dist/distributions/hypergeometric.d.ts +24 -0
  66. package/dist/distributions/hypergeometric.js +24 -0
  67. package/dist/distributions/invgamma.d.ts +32 -4
  68. package/dist/distributions/invgamma.js +27 -3
  69. package/dist/distributions/kumaraswamy.d.ts +31 -3
  70. package/dist/distributions/kumaraswamy.js +31 -3
  71. package/dist/distributions/laplace.d.ts +36 -4
  72. package/dist/distributions/laplace.js +31 -3
  73. package/dist/distributions/logistic.d.ts +29 -1
  74. package/dist/distributions/logistic.js +24 -0
  75. package/dist/distributions/lognormal.d.ts +29 -1
  76. package/dist/distributions/lognormal.js +24 -0
  77. package/dist/distributions/multinomial.d.ts +7 -1
  78. package/dist/distributions/multinomial.js +2 -0
  79. package/dist/distributions/negbinomial.d.ts +29 -1
  80. package/dist/distributions/negbinomial.js +24 -0
  81. package/dist/distributions/normal.d.ts +11 -1
  82. package/dist/distributions/normal.js +6 -0
  83. package/dist/distributions/pareto.d.ts +36 -4
  84. package/dist/distributions/pareto.js +31 -3
  85. package/dist/distributions/poisson.d.ts +18 -0
  86. package/dist/distributions/poisson.js +18 -0
  87. package/dist/distributions/signrank.d.ts +24 -0
  88. package/dist/distributions/signrank.js +24 -0
  89. package/dist/distributions/summary.d.ts +20 -2
  90. package/dist/distributions/summary.js +4 -0
  91. package/dist/distributions/t.d.ts +18 -0
  92. package/dist/distributions/t.js +18 -0
  93. package/dist/distributions/triangular.d.ts +36 -4
  94. package/dist/distributions/triangular.js +31 -3
  95. package/dist/distributions/tukey.d.ts +15 -1
  96. package/dist/distributions/tukey.js +10 -0
  97. package/dist/distributions/uniform.d.ts +29 -1
  98. package/dist/distributions/uniform.js +24 -0
  99. package/dist/distributions/weibull.d.ts +29 -1
  100. package/dist/distributions/weibull.js +24 -0
  101. package/dist/distributions/wilcox.d.ts +24 -0
  102. package/dist/distributions/wilcox.js +24 -0
  103. package/dist/distributions.js +2 -2
  104. package/dist/entries/descriptive.d.ts +1 -1
  105. package/dist/entries/numerics.d.ts +1 -1
  106. package/dist/entries/tests.js +1 -1
  107. package/dist/htest/agreement.d.ts +61 -23
  108. package/dist/htest/agreement.js +19 -9
  109. package/dist/htest/ansariTest.d.ts +8 -2
  110. package/dist/htest/aov.d.ts +43 -10
  111. package/dist/htest/aov.js +17 -3
  112. package/dist/htest/binomTest.d.ts +12 -2
  113. package/dist/htest/binomTest.js +2 -0
  114. package/dist/htest/brunnerMunzelTest.d.ts +9 -3
  115. package/dist/htest/brunnerMunzelTest.js +4 -2
  116. package/dist/htest/chisqTest.d.ts +19 -3
  117. package/dist/htest/cor.d.ts +20 -4
  118. package/dist/htest/effectSize.d.ts +70 -12
  119. package/dist/htest/effectSize.js +40 -7
  120. package/dist/htest/fisherTest.d.ts +9 -1
  121. package/dist/htest/fisherTest.js +2 -0
  122. package/dist/htest/groups.d.ts +5 -1
  123. package/dist/htest/ksTest.d.ts +20 -3
  124. package/dist/htest/leveneTest.d.ts +15 -4
  125. package/dist/htest/leveneTest.js +5 -2
  126. package/dist/htest/mantelhaenTest.d.ts +25 -3
  127. package/dist/htest/mantelhaenTest.js +15 -1
  128. package/dist/htest/mcnemarTest.d.ts +14 -4
  129. package/dist/htest/mcnemarTest.js +4 -2
  130. package/dist/htest/multipleComparisons.d.ts +173 -29
  131. package/dist/htest/multipleComparisons.js +123 -19
  132. package/dist/htest/normalityTests.d.ts +56 -9
  133. package/dist/htest/normalityTests.js +40 -6
  134. package/dist/htest/onewayTest.d.ts +32 -3
  135. package/dist/htest/onewayTest.js +10 -0
  136. package/dist/htest/pAdjust.d.ts +9 -1
  137. package/dist/htest/pAdjust.js +2 -0
  138. package/dist/htest/pairwise.d.ts +50 -5
  139. package/dist/htest/pairwise.js +25 -0
  140. package/dist/htest/poissonTest.d.ts +12 -2
  141. package/dist/htest/poissonTest.js +2 -0
  142. package/dist/htest/polycor.d.ts +29 -10
  143. package/dist/htest/power.d.ts +60 -6
  144. package/dist/htest/power.js +6 -0
  145. package/dist/htest/propTest.d.ts +13 -2
  146. package/dist/htest/propTest.js +2 -0
  147. package/dist/htest/pwr.d.ts +286 -36
  148. package/dist/htest/pwr.js +116 -15
  149. package/dist/htest/rankTests.d.ts +80 -12
  150. package/dist/htest/rankTests.js +11 -2
  151. package/dist/htest/tTest.d.ts +13 -3
  152. package/dist/htest/trendTests.d.ts +29 -8
  153. package/dist/htest/trendTests.js +8 -4
  154. package/dist/htest/types.d.ts +14 -2
  155. package/dist/htest/varTest.d.ts +25 -8
  156. package/dist/htest/wilcoxTest.d.ts +10 -2
  157. package/dist/internal/dpq.d.ts +4 -0
  158. package/dist/internal/noncentral.d.ts +2 -0
  159. package/dist/internal/vectorize.d.ts +4 -0
  160. package/dist/linalg/basic.d.ts +39 -5
  161. package/dist/linalg/basic.js +15 -0
  162. package/dist/linalg/chol.d.ts +26 -5
  163. package/dist/linalg/chol.js +7 -0
  164. package/dist/linalg/eigen.d.ts +16 -7
  165. package/dist/linalg/eigen.js +6 -5
  166. package/dist/linalg/expm.d.ts +15 -5
  167. package/dist/linalg/expm.js +5 -3
  168. package/dist/linalg/kappa.d.ts +21 -1
  169. package/dist/linalg/kappa.js +16 -0
  170. package/dist/linalg/lu.d.ts +30 -6
  171. package/dist/linalg/lu.js +15 -3
  172. package/dist/linalg/matrix.d.ts +4 -0
  173. package/dist/linalg/norm.d.ts +16 -1
  174. package/dist/linalg/norm.js +9 -0
  175. package/dist/linalg/ops.d.ts +156 -35
  176. package/dist/linalg/ops.js +96 -15
  177. package/dist/linalg/qr.d.ts +87 -12
  178. package/dist/linalg/qr.js +31 -0
  179. package/dist/linalg/schur.d.ts +8 -2
  180. package/dist/linalg/schur.js +3 -1
  181. package/dist/linalg/solve.d.ts +42 -6
  182. package/dist/linalg/solve.js +22 -0
  183. package/dist/linalg/svd.d.ts +12 -2
  184. package/dist/linalg/svd.js +2 -0
  185. package/dist/linalg.js +2 -2
  186. package/dist/models/anovaSequential.d.ts +26 -4
  187. package/dist/models/anovaSequential.js +3 -1
  188. package/dist/models/aovEz.d.ts +29 -6
  189. package/dist/models/aovEz.js +5 -2
  190. package/dist/models/aovStrata.d.ts +12 -2
  191. package/dist/models/carAnova.d.ts +9 -3
  192. package/dist/models/carAnova.js +4 -2
  193. package/dist/models/coxph.d.ts +33 -7
  194. package/dist/models/coxph.js +8 -3
  195. package/dist/models/glm.d.ts +128 -21
  196. package/dist/models/glm.js +71 -14
  197. package/dist/models/glmAnova.d.ts +30 -5
  198. package/dist/models/glmAnova.js +15 -2
  199. package/dist/models/glmConfint.d.ts +16 -2
  200. package/dist/models/glmConfint.js +9 -1
  201. package/dist/models/glmFamily.d.ts +27 -5
  202. package/dist/models/lm.d.ts +75 -17
  203. package/dist/models/lm.js +22 -4
  204. package/dist/models/mauchly.d.ts +20 -5
  205. package/dist/models/mauchly.js +7 -3
  206. package/dist/models/modelFrame.d.ts +5 -1
  207. package/dist/models/modelMatrix.d.ts +18 -4
  208. package/dist/models/modelMatrix.js +3 -1
  209. package/dist/models/survival.d.ts +41 -9
  210. package/dist/models/survival.js +10 -4
  211. package/dist/numerics/deriv.d.ts +21 -6
  212. package/dist/numerics/deriv.js +16 -5
  213. package/dist/numerics/integrate.d.ts +37 -7
  214. package/dist/numerics/integrate.js +8 -2
  215. package/dist/numerics/interp.d.ts +63 -12
  216. package/dist/numerics/interp.js +30 -6
  217. package/dist/numerics/ode.d.ts +15 -5
  218. package/dist/numerics/ode.js +5 -3
  219. package/dist/numerics.js +2 -2
  220. package/dist/optim/optim.d.ts +32 -8
  221. package/dist/optim/optim.js +8 -4
  222. package/dist/random/beta.d.ts +8 -0
  223. package/dist/random/beta.js +8 -0
  224. package/dist/random/binomial.d.ts +16 -0
  225. package/dist/random/binomial.js +16 -0
  226. package/dist/random/continuous.d.ts +51 -0
  227. package/dist/random/continuous.js +51 -0
  228. package/dist/random/extra.d.ts +66 -6
  229. package/dist/random/extra.js +66 -6
  230. package/dist/random/gamma.d.ts +33 -0
  231. package/dist/random/gamma.js +33 -0
  232. package/dist/random/hyper.d.ts +8 -0
  233. package/dist/random/hyper.js +8 -0
  234. package/dist/random/poisson.d.ts +25 -0
  235. package/dist/random/poisson.js +25 -0
  236. package/dist/random/r2dtable.d.ts +2 -0
  237. package/dist/random/r2dtable.js +2 -0
  238. package/dist/random/rank.d.ts +16 -0
  239. package/dist/random/rank.js +16 -0
  240. package/dist/random/rng.d.ts +49 -6
  241. package/dist/random/rng.js +29 -2
  242. package/dist/random/sample.d.ts +10 -2
  243. package/dist/random/sample.js +5 -1
  244. package/dist/random/streams.d.ts +13 -0
  245. package/dist/random/streams.js +13 -0
  246. package/dist/rstats.js +1 -1
  247. package/dist/special/besselIK.d.ts +11 -3
  248. package/dist/special/besselIK.js +6 -2
  249. package/dist/special/besselJY.d.ts +6 -2
  250. package/dist/special/besselJY.js +6 -2
  251. package/dist/special/beta.d.ts +16 -2
  252. package/dist/special/beta.js +16 -2
  253. package/dist/special/choose.d.ts +13 -5
  254. package/dist/special/choose.js +13 -5
  255. package/dist/special/erf.d.ts +8 -3
  256. package/dist/special/erf.js +8 -3
  257. package/dist/special/extra.d.ts +30 -10
  258. package/dist/special/extra.js +25 -9
  259. package/dist/special/gamma.d.ts +18 -2
  260. package/dist/special/gamma.js +18 -2
  261. package/dist/special/log1p.d.ts +16 -7
  262. package/dist/special/log1p.js +16 -7
  263. package/dist/special/psigamma.d.ts +9 -3
  264. package/dist/special/psigamma.js +9 -3
  265. package/dist/special/rCompatible.d.ts +5 -1
  266. package/dist/special.js +2 -2
  267. package/dist/tests.js +2 -2
  268. package/llms.txt +2 -0
  269. package/package.json +1 -1
@@ -55,21 +55,49 @@ export function qpareto1(p, a, b, lowerTail, logP) {
55
55
  return b * Math.exp(-lu / a);
56
56
  }
57
57
  /**
58
- * Density of the Pareto distribution. Equivalent to `extraDistr::dpareto(x, a = 1, b = 1, log = FALSE)`.
58
+ * Density of the Pareto distribution. Equivalent to `extraDistr::dpareto(x, a = 1, b = 1, log = FALSE)` in R.
59
59
  *
60
60
  * @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
61
61
  * @param options - `a` and `b` (see {@link ParetoParams}) and `log` (see {@link DensityOptions}).
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * dpareto(2); // 0.25
66
+ * dpareto(3, { a: 2, b: 1.5 }); // 0.16666666666666666
67
+ * ```
68
+ *
69
+ * @category Distributions
62
70
  */
63
71
  export function dpareto(x, options = {}) {
64
72
  const { a = 1, b = 1, log = false } = options;
65
73
  return vectorize(x, (v) => dpareto1(v, a, b, log));
66
74
  }
67
- /** Distribution function of the Pareto distribution. Equivalent to `extraDistr::ppareto(q, a = 1, b = 1, lower.tail, log.p)`. */
75
+ /**
76
+ * Distribution function of the Pareto distribution. Equivalent to `extraDistr::ppareto(q, a = 1, b = 1, lower.tail, log.p)` in R.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * ppareto(2); // 0.5
81
+ * ppareto(3, { a: 2, b: 1.5 }); // 0.75
82
+ * ```
83
+ *
84
+ * @category Distributions
85
+ */
68
86
  export function ppareto(q, options = {}) {
69
87
  const { a = 1, b = 1, lowerTail = true, logP = false } = options;
70
88
  return vectorize(q, (v) => ppareto1(v, a, b, lowerTail, logP));
71
89
  }
72
- /** Quantile function of the Pareto distribution. Equivalent to `extraDistr::qpareto(p, a = 1, b = 1, lower.tail, log.p)`. */
90
+ /**
91
+ * Quantile function of the Pareto distribution. Equivalent to `extraDistr::qpareto(p, a = 1, b = 1, lower.tail, log.p)` in R.
92
+ *
93
+ * @example
94
+ * ```ts
95
+ * qpareto(0.5); // 2
96
+ * qpareto(0.9, { a: 2, b: 1.5 }); // 4.74341649025257
97
+ * ```
98
+ *
99
+ * @category Distributions
100
+ */
73
101
  export function qpareto(p, options = {}) {
74
102
  const { a = 1, b = 1, lowerTail = true, logP = false } = options;
75
103
  return vectorize(p, (v) => qpareto1(v, a, b, lowerTail, logP));
@@ -13,6 +13,14 @@ export declare function qpois1(p: number, lambda: number, lowerTail: boolean, lo
13
13
  * @param lambda - Mean.
14
14
  * @param options - `log` (see {@link DensityOptions}).
15
15
  * @returns The probability (or log probability).
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * dpois(2, 3); // 0.22404180765538775
20
+ * dpois([0, 1, 2], 3); // [0.049787068367863944, 0.14936120510359185, 0.22404180765538775]
21
+ * ```
22
+ *
23
+ * @category Distributions
16
24
  */
17
25
  export declare function dpois<T extends Vectorizable>(x: T, lambda: number, options?: DensityOptions): VectorResult<T>;
18
26
  /**
@@ -28,6 +36,8 @@ export declare function dpois<T extends Vectorizable>(x: T, lambda: number, opti
28
36
  * ppois(2, 3); // 0.4231900811268436
29
37
  * ppois(5, 3, { lowerTail: false }); // P[X > 5] = 0.08391794203130346
30
38
  * ```
39
+ *
40
+ * @category Distributions
31
41
  */
32
42
  export declare function ppois<T extends Vectorizable>(q: T, lambda: number, options?: TailOptions): VectorResult<T>;
33
43
  /**
@@ -37,5 +47,13 @@ export declare function ppois<T extends Vectorizable>(q: T, lambda: number, opti
37
47
  * @param lambda - Mean.
38
48
  * @param options - `lowerTail` and `logP` (see {@link TailOptions}).
39
49
  * @returns The quantile(s).
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * qpois(0.5, 3); // 3
54
+ * qpois([0.05, 0.95], 3); // [1, 6]
55
+ * ```
56
+ *
57
+ * @category Distributions
40
58
  */
41
59
  export declare function qpois<T extends Vectorizable>(p: T, lambda: number, options?: TailOptions): VectorResult<T>;
@@ -67,6 +67,14 @@ export function qpois1(p, lambda, lowerTail, logP) {
67
67
  * @param lambda - Mean.
68
68
  * @param options - `log` (see {@link DensityOptions}).
69
69
  * @returns The probability (or log probability).
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * dpois(2, 3); // 0.22404180765538775
74
+ * dpois([0, 1, 2], 3); // [0.049787068367863944, 0.14936120510359185, 0.22404180765538775]
75
+ * ```
76
+ *
77
+ * @category Distributions
70
78
  */
71
79
  export function dpois(x, lambda, options = {}) {
72
80
  const log = options.log ?? false;
@@ -85,6 +93,8 @@ export function dpois(x, lambda, options = {}) {
85
93
  * ppois(2, 3); // 0.4231900811268436
86
94
  * ppois(5, 3, { lowerTail: false }); // P[X > 5] = 0.08391794203130346
87
95
  * ```
96
+ *
97
+ * @category Distributions
88
98
  */
89
99
  export function ppois(q, lambda, options = {}) {
90
100
  const { lowerTail = true, logP = false } = options;
@@ -97,6 +107,14 @@ export function ppois(q, lambda, options = {}) {
97
107
  * @param lambda - Mean.
98
108
  * @param options - `lowerTail` and `logP` (see {@link TailOptions}).
99
109
  * @returns The quantile(s).
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * qpois(0.5, 3); // 3
114
+ * qpois([0.05, 0.95], 3); // [1, 6]
115
+ * ```
116
+ *
117
+ * @category Distributions
100
118
  */
101
119
  export function qpois(p, lambda, options = {}) {
102
120
  const { lowerTail = true, logP = false } = options;
@@ -12,6 +12,14 @@ export declare function qsignrank1(p: number, n: number, lowerTail: boolean, log
12
12
  * @param n - Number of observations.
13
13
  * @param options - `log` (see {@link DensityOptions}).
14
14
  * @returns The probability (or log probability).
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * dsignrank(5, 10); // 0.0029296875
19
+ * dsignrank([0, 1, 2], 4); // [0.0625, 0.0625, 0.0625]
20
+ * ```
21
+ *
22
+ * @category Distributions
15
23
  */
16
24
  export declare function dsignrank<T extends Vectorizable>(x: T, n: number, options?: DensityOptions): VectorResult<T>;
17
25
  /**
@@ -23,6 +31,14 @@ export declare function dsignrank<T extends Vectorizable>(x: T, n: number, optio
23
31
  * @param n - Number of observations.
24
32
  * @param options - `lowerTail` and `logP` (see {@link TailOptions}).
25
33
  * @returns The probability (or log probability).
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * psignrank(10, 10); // 0.0419921875
38
+ * psignrank(40, 10, { lowerTail: false }); // 0.0966796875
39
+ * ```
40
+ *
41
+ * @category Distributions
26
42
  */
27
43
  export declare function psignrank<T extends Vectorizable>(q: T, n: number, options?: TailOptions): VectorResult<T>;
28
44
  /**
@@ -34,5 +50,13 @@ export declare function psignrank<T extends Vectorizable>(q: T, n: number, optio
34
50
  * @param n - Number of observations.
35
51
  * @param options - `lowerTail` and `logP` (see {@link TailOptions}).
36
52
  * @returns The quantile(s).
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * qsignrank(0.025, 10); // 9
57
+ * qsignrank([0.25, 0.75], 10); // [21, 34]
58
+ * ```
59
+ *
60
+ * @category Distributions
37
61
  */
38
62
  export declare function qsignrank<T extends Vectorizable>(p: T, n: number, options?: TailOptions): VectorResult<T>;
@@ -181,6 +181,14 @@ export function qsignrank1(p, n, lowerTail, logP) {
181
181
  * @param n - Number of observations.
182
182
  * @param options - `log` (see {@link DensityOptions}).
183
183
  * @returns The probability (or log probability).
184
+ *
185
+ * @example
186
+ * ```ts
187
+ * dsignrank(5, 10); // 0.0029296875
188
+ * dsignrank([0, 1, 2], 4); // [0.0625, 0.0625, 0.0625]
189
+ * ```
190
+ *
191
+ * @category Distributions
184
192
  */
185
193
  export function dsignrank(x, n, options = {}) {
186
194
  const log = options.log ?? false;
@@ -195,6 +203,14 @@ export function dsignrank(x, n, options = {}) {
195
203
  * @param n - Number of observations.
196
204
  * @param options - `lowerTail` and `logP` (see {@link TailOptions}).
197
205
  * @returns The probability (or log probability).
206
+ *
207
+ * @example
208
+ * ```ts
209
+ * psignrank(10, 10); // 0.0419921875
210
+ * psignrank(40, 10, { lowerTail: false }); // 0.0966796875
211
+ * ```
212
+ *
213
+ * @category Distributions
198
214
  */
199
215
  export function psignrank(q, n, options = {}) {
200
216
  const { lowerTail = true, logP = false } = options;
@@ -209,6 +225,14 @@ export function psignrank(q, n, options = {}) {
209
225
  * @param n - Number of observations.
210
226
  * @param options - `lowerTail` and `logP` (see {@link TailOptions}).
211
227
  * @returns The quantile(s).
228
+ *
229
+ * @example
230
+ * ```ts
231
+ * qsignrank(0.025, 10); // 9
232
+ * qsignrank([0.25, 0.75], 10); // [21, 34]
233
+ * ```
234
+ *
235
+ * @category Distributions
212
236
  */
213
237
  export function qsignrank(p, n, options = {}) {
214
238
  const { lowerTail = true, logP = false } = options;
@@ -1,25 +1,43 @@
1
- /** Result of {@link distSummary}. */
1
+ /**
2
+ * Result of {@link distSummary}.
3
+ *
4
+ * @category Distributions
5
+ */
2
6
  export interface DistSummary {
7
+ /** Mean (NaN when it does not exist, `Infinity` when it is infinite). */
3
8
  mean: number;
9
+ /** Variance (NaN when it does not exist, `Infinity` when it is infinite). */
4
10
  variance: number;
11
+ /** Standard deviation, the square root of the variance. */
5
12
  sd: number;
13
+ /** Median: the q function at 0.5 (for discrete distributions the smallest x with F(x) >= 0.5). */
6
14
  median: number;
15
+ /** Mode: the maximum of the density (NaN when it is not unique; the larger of two adjacent modes). */
7
16
  mode: number;
17
+ /** Skewness, E[(X - mean)^3] / sd^3. */
8
18
  skewness: number;
9
19
  /** Excess kurtosis (0 for the normal distribution). */
10
20
  kurtosis: number;
11
21
  }
12
- /** Distributions known to {@link distSummary} (the names of their d/p/q/r functions). */
22
+ /**
23
+ * Distributions known to {@link distSummary} (the names of their d/p/q/r functions).
24
+ *
25
+ * @category Distributions
26
+ */
13
27
  export type DistName = "norm" | "lnorm" | "unif" | "exp" | "gamma" | "chisq" | "beta" | "t" | "f" | "cauchy" | "weibull" | "logis" | "binom" | "pois" | "geom" | "nbinom" | "hyper" | "invgamma" | "kumar" | "pareto" | "triang" | "laplace" | "arcsine";
14
28
  /**
15
29
  * Mean, variance, standard deviation, median, mode, skewness and excess kurtosis of a distribution, given by the
16
30
  * name of its d/p/q/r functions and their parameters (with the same names and defaults; `gamma` takes `rate` or
17
31
  * `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout.
32
+ * Not an R function. R has no function for these summaries; the R references are closed forms checked against
33
+ * numerical moments.
18
34
  *
19
35
  * @example
20
36
  * ```ts
21
37
  * distSummary("gamma", { shape: 2.5, rate: 2 }); // { mean: 1.25, variance: 0.625, ..., mode: 0.75, kurtosis: 2.4 }
22
38
  * distSummary("binom", { size: 9, prob: 0.5 }).mode; // 5 (4 and 5 are equally likely: the larger)
23
39
  * ```
40
+ *
41
+ * @category Distributions
24
42
  */
25
43
  export declare function distSummary(distribution: DistName, params?: Record<string, number | undefined>): DistSummary;
@@ -66,12 +66,16 @@ const has = (o, k) => o[k] !== undefined;
66
66
  * Mean, variance, standard deviation, median, mode, skewness and excess kurtosis of a distribution, given by the
67
67
  * name of its d/p/q/r functions and their parameters (with the same names and defaults; `gamma` takes `rate` or
68
68
  * `scale`, `nbinom` takes `prob` or `mu`). Invalid parameters give NaN throughout.
69
+ * Not an R function. R has no function for these summaries; the R references are closed forms checked against
70
+ * numerical moments.
69
71
  *
70
72
  * @example
71
73
  * ```ts
72
74
  * distSummary("gamma", { shape: 2.5, rate: 2 }); // { mean: 1.25, variance: 0.625, ..., mode: 0.75, kurtosis: 2.4 }
73
75
  * distSummary("binom", { size: 9, prob: 0.5 }).mode; // 5 (4 and 5 are equally likely: the larger)
74
76
  * ```
77
+ *
78
+ * @category Distributions
75
79
  */
76
80
  export function distSummary(distribution, params = {}) {
77
81
  const P = params;
@@ -17,6 +17,14 @@ export declare function qt1(p: number, df: number, lowerTail: boolean, logP: boo
17
17
  * @param df - Degrees of freedom.
18
18
  * @param options - `ncp` (see {@link NoncentralOption}) and `log` (see {@link DensityOptions}).
19
19
  * @returns The density (or log density).
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * dt(0, 5); // 0.37960668982249446
24
+ * dt(1, 5, { ncp: 1 }); // 0.36232483923371867
25
+ * ```
26
+ *
27
+ * @category Distributions
20
28
  */
21
29
  export declare function dt<T extends Vectorizable>(x: T, df: number, options?: DensityOptions & NoncentralOption): VectorResult<T>;
22
30
  /**
@@ -34,6 +42,8 @@ export declare function dt<T extends Vectorizable>(x: T, df: number, options?: D
34
42
  * pt(2.1, 10, { lowerTail: false }); // 0.031038622101109286
35
43
  * pt(1, 5, { ncp: 1 }); // 0.48092614124210525
36
44
  * ```
45
+ *
46
+ * @category Distributions
37
47
  */
38
48
  export declare function pt<T extends Vectorizable>(q: T, df: number, options?: TailOptions & NoncentralOption): VectorResult<T>;
39
49
  /**
@@ -45,5 +55,13 @@ export declare function pt<T extends Vectorizable>(q: T, df: number, options?: T
45
55
  * @param df - Degrees of freedom.
46
56
  * @param options - `ncp` (see {@link NoncentralOption}), `lowerTail` and `logP` (see {@link TailOptions}).
47
57
  * @returns The quantile(s).
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * qt(0.975, 10); // 2.228138851986274
62
+ * qt([0.025, 0.975], 5); // [-2.5705818356363155, 2.5705818356363146]
63
+ * ```
64
+ *
65
+ * @category Distributions
48
66
  */
49
67
  export declare function qt<T extends Vectorizable>(p: T, df: number, options?: TailOptions & NoncentralOption): VectorResult<T>;
@@ -188,6 +188,14 @@ export function qt1(p, df, lowerTail, logP) {
188
188
  * @param df - Degrees of freedom.
189
189
  * @param options - `ncp` (see {@link NoncentralOption}) and `log` (see {@link DensityOptions}).
190
190
  * @returns The density (or log density).
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * dt(0, 5); // 0.37960668982249446
195
+ * dt(1, 5, { ncp: 1 }); // 0.36232483923371867
196
+ * ```
197
+ *
198
+ * @category Distributions
191
199
  */
192
200
  export function dt(x, df, options = {}) {
193
201
  const { log = false, ncp } = options;
@@ -210,6 +218,8 @@ export function dt(x, df, options = {}) {
210
218
  * pt(2.1, 10, { lowerTail: false }); // 0.031038622101109286
211
219
  * pt(1, 5, { ncp: 1 }); // 0.48092614124210525
212
220
  * ```
221
+ *
222
+ * @category Distributions
213
223
  */
214
224
  export function pt(q, df, options = {}) {
215
225
  const { lowerTail = true, logP = false, ncp } = options;
@@ -226,6 +236,14 @@ export function pt(q, df, options = {}) {
226
236
  * @param df - Degrees of freedom.
227
237
  * @param options - `ncp` (see {@link NoncentralOption}), `lowerTail` and `logP` (see {@link TailOptions}).
228
238
  * @returns The quantile(s).
239
+ *
240
+ * @example
241
+ * ```ts
242
+ * qt(0.975, 10); // 2.228138851986274
243
+ * qt([0.025, 0.975], 5); // [-2.5705818356363155, 2.5705818356363146]
244
+ * ```
245
+ *
246
+ * @category Distributions
229
247
  */
230
248
  export function qt(p, df, options = {}) {
231
249
  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
- /** Limits and mode of the triangular distribution. */
3
+ /**
4
+ * Limits and mode of the triangular distribution.
5
+ *
6
+ * @category Distributions
7
+ */
4
8
  export interface TriangParams {
5
9
  /** Minimum. Default `-1`. */
6
10
  a?: number;
@@ -13,13 +17,41 @@ export declare function dtriang1(x: number, a: number, b: number, c: number, log
13
17
  export declare function ptriang1(q: number, a: number, b: number, c: number, lowerTail: boolean, logP: boolean): number;
14
18
  export declare function qtriang1(p: number, a: number, b: number, c: number, lowerTail: boolean, logP: boolean): number;
15
19
  /**
16
- * Density of the triangular distribution. Equivalent to `extraDistr::dtriang(x, a = -1, b = 1, c = (a + b)/2, log = FALSE)`.
20
+ * Density of the triangular distribution. Equivalent to `extraDistr::dtriang(x, a = -1, b = 1, c = (a + b)/2, log = FALSE)` in R.
17
21
  *
18
22
  * @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
19
23
  * @param options - `a`, `b` and `c` (see {@link TriangParams}) and `log` (see {@link DensityOptions}).
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * dtriang(0); // 1
28
+ * dtriang(1, { a: 0, b: 4, c: 1 }); // 0.5
29
+ * ```
30
+ *
31
+ * @category Distributions
20
32
  */
21
33
  export declare function dtriang<T extends Vectorizable>(x: T, options?: TriangParams & DensityOptions): VectorResult<T>;
22
- /** Distribution function of the triangular distribution. Equivalent to `extraDistr::ptriang(q, a, b, c, lower.tail, log.p)`. */
34
+ /**
35
+ * Distribution function of the triangular distribution. Equivalent to `extraDistr::ptriang(q, a, b, c, lower.tail, log.p)` in R.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * ptriang(0); // 0.5
40
+ * ptriang(2, { a: 0, b: 4, c: 1 }); // 0.6666666666666667
41
+ * ```
42
+ *
43
+ * @category Distributions
44
+ */
23
45
  export declare function ptriang<T extends Vectorizable>(q: T, options?: TriangParams & TailOptions): VectorResult<T>;
24
- /** Quantile function of the triangular distribution. Equivalent to `extraDistr::qtriang(p, a, b, c, lower.tail, log.p)`. */
46
+ /**
47
+ * Quantile function of the triangular distribution. Equivalent to `extraDistr::qtriang(p, a, b, c, lower.tail, log.p)` in R.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * qtriang(0.5); // 0
52
+ * qtriang(0.9, { a: 0, b: 4, c: 1 }); // 2.904554884989668
53
+ * ```
54
+ *
55
+ * @category Distributions
56
+ */
25
57
  export declare function qtriang<T extends Vectorizable>(p: T, options?: TriangParams & TailOptions): VectorResult<T>;
@@ -63,23 +63,51 @@ export function qtriang1(p, a, b, c, lowerTail, logP) {
63
63
  return b - Math.sqrt(upper * w * (b - c));
64
64
  }
65
65
  /**
66
- * Density of the triangular distribution. Equivalent to `extraDistr::dtriang(x, a = -1, b = 1, c = (a + b)/2, log = FALSE)`.
66
+ * Density of the triangular distribution. Equivalent to `extraDistr::dtriang(x, a = -1, b = 1, c = (a + b)/2, log = FALSE)` in R.
67
67
  *
68
68
  * @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
69
69
  * @param options - `a`, `b` and `c` (see {@link TriangParams}) and `log` (see {@link DensityOptions}).
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * dtriang(0); // 1
74
+ * dtriang(1, { a: 0, b: 4, c: 1 }); // 0.5
75
+ * ```
76
+ *
77
+ * @category Distributions
70
78
  */
71
79
  export function dtriang(x, options = {}) {
72
80
  const { a = -1, b = 1, log = false } = options;
73
81
  const c = options.c ?? (a + b) / 2;
74
82
  return vectorize(x, (v) => dtriang1(v, a, b, c, log));
75
83
  }
76
- /** Distribution function of the triangular distribution. Equivalent to `extraDistr::ptriang(q, a, b, c, lower.tail, log.p)`. */
84
+ /**
85
+ * Distribution function of the triangular distribution. Equivalent to `extraDistr::ptriang(q, a, b, c, lower.tail, log.p)` in R.
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * ptriang(0); // 0.5
90
+ * ptriang(2, { a: 0, b: 4, c: 1 }); // 0.6666666666666667
91
+ * ```
92
+ *
93
+ * @category Distributions
94
+ */
77
95
  export function ptriang(q, options = {}) {
78
96
  const { a = -1, b = 1, lowerTail = true, logP = false } = options;
79
97
  const c = options.c ?? (a + b) / 2;
80
98
  return vectorize(q, (v) => ptriang1(v, a, b, c, lowerTail, logP));
81
99
  }
82
- /** Quantile function of the triangular distribution. Equivalent to `extraDistr::qtriang(p, a, b, c, lower.tail, log.p)`. */
100
+ /**
101
+ * Quantile function of the triangular distribution. Equivalent to `extraDistr::qtriang(p, a, b, c, lower.tail, log.p)` in R.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * qtriang(0.5); // 0
106
+ * qtriang(0.9, { a: 0, b: 4, c: 1 }); // 2.904554884989668
107
+ * ```
108
+ *
109
+ * @category Distributions
110
+ */
83
111
  export function qtriang(p, options = {}) {
84
112
  const { a = -1, b = 1, lowerTail = true, logP = false } = options;
85
113
  const c = options.c ?? (a + b) / 2;
@@ -1,6 +1,10 @@
1
1
  import { type Vectorizable, type VectorResult } from "../internal/vectorize.js";
2
2
  import { type TailOptions } from "../internal/dpq.js";
3
- /** Options for {@link ptukey} and {@link qtukey}. */
3
+ /**
4
+ * Options for {@link ptukey} and {@link qtukey}.
5
+ *
6
+ * @category Distributions
7
+ */
4
8
  export interface TukeyOptions extends TailOptions {
5
9
  /** Number of groups whose ranges are compared; the statistic is the maximum of that many ranges. Default `1`. */
6
10
  nranges?: number;
@@ -27,6 +31,8 @@ export declare function qtukey1(p: number, k: number, df: number, r: number, low
27
31
  * ptukey(3.5, 3, 12); // 0.9300045147248135
28
32
  * ptukey(3.5, 3, 12, { lowerTail: false }); // 0.06999548527518648
29
33
  * ```
34
+ *
35
+ * @category Distributions
30
36
  */
31
37
  export declare function ptukey<T extends Vectorizable>(q: T, nmeans: number, df: number, options?: TukeyOptions): VectorResult<T>;
32
38
  /**
@@ -39,5 +45,13 @@ export declare function ptukey<T extends Vectorizable>(q: T, nmeans: number, df:
39
45
  * @param df - Degrees of freedom of the standard deviation estimate.
40
46
  * @param options - `nranges`, `lowerTail` and `logP` (see {@link TukeyOptions}).
41
47
  * @returns The quantile(s).
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * qtukey(0.95, 3, 12); // 3.7729289657270084
52
+ * qtukey(0.95, 4, 20); // 3.958293560945357
53
+ * ```
54
+ *
55
+ * @category Distributions
42
56
  */
43
57
  export declare function qtukey<T extends Vectorizable>(p: T, nmeans: number, df: number, options?: TukeyOptions): VectorResult<T>;
@@ -963,6 +963,8 @@ function brent(f, a, b, fa, fb) {
963
963
  * ptukey(3.5, 3, 12); // 0.9300045147248135
964
964
  * ptukey(3.5, 3, 12, { lowerTail: false }); // 0.06999548527518648
965
965
  * ```
966
+ *
967
+ * @category Distributions
966
968
  */
967
969
  export function ptukey(q, nmeans, df, options = {}) {
968
970
  const { nranges = 1, lowerTail = true, logP = false } = options;
@@ -978,6 +980,14 @@ export function ptukey(q, nmeans, df, options = {}) {
978
980
  * @param df - Degrees of freedom of the standard deviation estimate.
979
981
  * @param options - `nranges`, `lowerTail` and `logP` (see {@link TukeyOptions}).
980
982
  * @returns The quantile(s).
983
+ *
984
+ * @example
985
+ * ```ts
986
+ * qtukey(0.95, 3, 12); // 3.7729289657270084
987
+ * qtukey(0.95, 4, 20); // 3.958293560945357
988
+ * ```
989
+ *
990
+ * @category Distributions
981
991
  */
982
992
  export function qtukey(p, nmeans, df, options = {}) {
983
993
  const { nranges = 1, lowerTail = true, logP = false } = 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
- /** Parameters of the uniform distribution. */
3
+ /**
4
+ * Parameters of the uniform distribution.
5
+ *
6
+ * @category Distributions
7
+ */
4
8
  export interface UniformParams {
5
9
  /** Lower limit. Default `0`. */
6
10
  min?: number;
@@ -16,6 +20,14 @@ export declare function qunif1(p: number, min: number, max: number, lowerTail: b
16
20
  * @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
17
21
  * @param options - `min` and `max` (see {@link UniformParams}) and `log` (see {@link DensityOptions}).
18
22
  * @returns The density (or log density).
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * dunif(0.5); // 1
27
+ * dunif([1, 3], { min: 0, max: 2 }); // [0.5, 0]
28
+ * ```
29
+ *
30
+ * @category Distributions
19
31
  */
20
32
  export declare function dunif<T extends Vectorizable>(x: T, options?: UniformParams & DensityOptions): VectorResult<T>;
21
33
  /**
@@ -24,6 +36,14 @@ export declare function dunif<T extends Vectorizable>(x: T, options?: UniformPar
24
36
  * @param q - Quantile(s): a number, `number[]` or `Float64Array`. The result has the same shape.
25
37
  * @param options - `min` and `max` (see {@link UniformParams}), `lowerTail` and `logP` (see {@link TailOptions}).
26
38
  * @returns The probability (or log probability).
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * punif(0.3); // 0.3
43
+ * punif(1.5, { min: 1, max: 3 }); // 0.25
44
+ * ```
45
+ *
46
+ * @category Distributions
27
47
  */
28
48
  export declare function punif<T extends Vectorizable>(q: T, options?: UniformParams & TailOptions): VectorResult<T>;
29
49
  /**
@@ -32,5 +52,13 @@ export declare function punif<T extends Vectorizable>(q: T, options?: UniformPar
32
52
  * @param p - Probability (or log probability with `logP`): a number, `number[]` or `Float64Array`. The result has the same shape.
33
53
  * @param options - `min` and `max` (see {@link UniformParams}), `lowerTail` and `logP` (see {@link TailOptions}).
34
54
  * @returns The quantile(s).
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * qunif(0.25); // 0.25
59
+ * qunif([0.1, 0.9], { min: -1, max: 1 }); // [-0.8, 0.8]
60
+ * ```
61
+ *
62
+ * @category Distributions
35
63
  */
36
64
  export declare function qunif<T extends Vectorizable>(p: T, options?: UniformParams & TailOptions): VectorResult<T>;
@@ -61,6 +61,14 @@ export function qunif1(p, min, max, lowerTail, logP) {
61
61
  * @param x - Value(s) at which to evaluate: a number, `number[]` or `Float64Array`. The result has the same shape.
62
62
  * @param options - `min` and `max` (see {@link UniformParams}) and `log` (see {@link DensityOptions}).
63
63
  * @returns The density (or log density).
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * dunif(0.5); // 1
68
+ * dunif([1, 3], { min: 0, max: 2 }); // [0.5, 0]
69
+ * ```
70
+ *
71
+ * @category Distributions
64
72
  */
65
73
  export function dunif(x, options = {}) {
66
74
  const { min = 0, max = 1, log = false } = options;
@@ -72,6 +80,14 @@ export function dunif(x, options = {}) {
72
80
  * @param q - Quantile(s): a number, `number[]` or `Float64Array`. The result has the same shape.
73
81
  * @param options - `min` and `max` (see {@link UniformParams}), `lowerTail` and `logP` (see {@link TailOptions}).
74
82
  * @returns The probability (or log probability).
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * punif(0.3); // 0.3
87
+ * punif(1.5, { min: 1, max: 3 }); // 0.25
88
+ * ```
89
+ *
90
+ * @category Distributions
75
91
  */
76
92
  export function punif(q, options = {}) {
77
93
  const { min = 0, max = 1, lowerTail = true, logP = false } = options;
@@ -83,6 +99,14 @@ export function punif(q, options = {}) {
83
99
  * @param p - Probability (or log probability with `logP`): a number, `number[]` or `Float64Array`. The result has the same shape.
84
100
  * @param options - `min` and `max` (see {@link UniformParams}), `lowerTail` and `logP` (see {@link TailOptions}).
85
101
  * @returns The quantile(s).
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * qunif(0.25); // 0.25
106
+ * qunif([0.1, 0.9], { min: -1, max: 1 }); // [-0.8, 0.8]
107
+ * ```
108
+ *
109
+ * @category Distributions
86
110
  */
87
111
  export function qunif(p, options = {}) {
88
112
  const { min = 0, max = 1, lowerTail = true, logP = false } = options;