@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.
Files changed (280) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.ja.md +13 -9
  3. package/README.md +13 -8
  4. package/dist/chunks/{chunk-QJJWGNJP.js → chunk-2X7JYQBI.js} +2 -2
  5. package/dist/chunks/{chunk-O6PT7IVU.js → chunk-36GVER3O.js} +2 -2
  6. package/dist/chunks/{chunk-EWC6I75B.js → chunk-3WUXRSM6.js} +1 -1
  7. package/dist/chunks/{chunk-4NM37MGA.js → chunk-6I6QKTFK.js} +2 -2
  8. package/dist/chunks/{chunk-2XKG3DX4.js → chunk-ETOEZTGL.js} +1 -1
  9. package/dist/chunks/{chunk-IT354SHV.js → chunk-FVPDVRJQ.js} +2 -2
  10. package/dist/chunks/{chunk-QULPY6YM.js → chunk-GG4BJMJW.js} +1 -1
  11. package/dist/chunks/{chunk-7HPVUVZB.js → chunk-HITD7CX6.js} +1 -1
  12. package/dist/chunks/{chunk-LIMZKONM.js → chunk-KK4GE65D.js} +2 -2
  13. package/dist/chunks/chunk-LAUYSGV4.js +3 -0
  14. package/dist/chunks/chunk-M6GDXKKS.js +2 -0
  15. package/dist/chunks/{chunk-QFULZNHL.js → chunk-PHHUHR7T.js} +1 -1
  16. package/dist/chunks/{chunk-ENL43FNO.js → chunk-WQPFDDIY.js} +2 -2
  17. package/dist/chunks/chunk-X2AWQSVS.js +2 -0
  18. package/dist/chunks/{chunk-ZRIM4R4A.js → chunk-ZRJQD7VS.js} +2 -2
  19. package/dist/data/grouping.d.ts +100 -0
  20. package/dist/data/grouping.js +264 -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 +138 -0
  25. package/dist/descriptive/dataFrames.js +400 -0
  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 +42 -0
  31. package/dist/descriptive/missing.js +52 -0
  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 +105 -0
  37. package/dist/descriptive/pivot.js +347 -0
  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 +5 -1
  105. package/dist/entries/descriptive.js +4 -0
  106. package/dist/entries/numerics.d.ts +1 -1
  107. package/dist/entries/tests.js +1 -1
  108. package/dist/htest/agreement.d.ts +61 -23
  109. package/dist/htest/agreement.js +19 -9
  110. package/dist/htest/ansariTest.d.ts +19 -1
  111. package/dist/htest/ansariTest.js +5 -17
  112. package/dist/htest/aov.d.ts +43 -10
  113. package/dist/htest/aov.js +17 -3
  114. package/dist/htest/binomTest.d.ts +12 -2
  115. package/dist/htest/binomTest.js +2 -0
  116. package/dist/htest/brunnerMunzelTest.d.ts +9 -3
  117. package/dist/htest/brunnerMunzelTest.js +4 -2
  118. package/dist/htest/chisqTest.d.ts +19 -3
  119. package/dist/htest/cor.d.ts +31 -3
  120. package/dist/htest/cor.js +9 -27
  121. package/dist/htest/effectSize.d.ts +70 -12
  122. package/dist/htest/effectSize.js +40 -7
  123. package/dist/htest/fisherTest.d.ts +9 -1
  124. package/dist/htest/fisherTest.js +2 -0
  125. package/dist/htest/groups.d.ts +5 -1
  126. package/dist/htest/ksTest.d.ts +32 -2
  127. package/dist/htest/ksTest.js +5 -8
  128. package/dist/htest/leveneTest.d.ts +15 -4
  129. package/dist/htest/leveneTest.js +5 -2
  130. package/dist/htest/mantelhaenTest.d.ts +25 -3
  131. package/dist/htest/mantelhaenTest.js +15 -1
  132. package/dist/htest/mcnemarTest.d.ts +14 -4
  133. package/dist/htest/mcnemarTest.js +4 -2
  134. package/dist/htest/multipleComparisons.d.ts +173 -29
  135. package/dist/htest/multipleComparisons.js +123 -19
  136. package/dist/htest/normalityTests.d.ts +56 -9
  137. package/dist/htest/normalityTests.js +40 -6
  138. package/dist/htest/onewayTest.d.ts +45 -2
  139. package/dist/htest/onewayTest.js +15 -7
  140. package/dist/htest/pAdjust.d.ts +9 -1
  141. package/dist/htest/pAdjust.js +2 -0
  142. package/dist/htest/pairwise.d.ts +50 -5
  143. package/dist/htest/pairwise.js +25 -0
  144. package/dist/htest/poissonTest.d.ts +12 -2
  145. package/dist/htest/poissonTest.js +2 -0
  146. package/dist/htest/polycor.d.ts +29 -10
  147. package/dist/htest/power.d.ts +60 -6
  148. package/dist/htest/power.js +6 -0
  149. package/dist/htest/propTest.d.ts +13 -2
  150. package/dist/htest/propTest.js +2 -0
  151. package/dist/htest/pwr.d.ts +286 -36
  152. package/dist/htest/pwr.js +116 -15
  153. package/dist/htest/rankTests.d.ts +132 -7
  154. package/dist/htest/rankTests.js +30 -33
  155. package/dist/htest/tTest.d.ts +32 -2
  156. package/dist/htest/tTest.js +19 -24
  157. package/dist/htest/testFormula.d.ts +57 -0
  158. package/dist/htest/testFormula.js +171 -0
  159. package/dist/htest/trendTests.d.ts +29 -8
  160. package/dist/htest/trendTests.js +8 -4
  161. package/dist/htest/types.d.ts +14 -2
  162. package/dist/htest/varTest.d.ts +46 -6
  163. package/dist/htest/varTest.js +11 -21
  164. package/dist/htest/wilcoxTest.d.ts +23 -1
  165. package/dist/htest/wilcoxTest.js +9 -24
  166. package/dist/internal/dpq.d.ts +4 -0
  167. package/dist/internal/noncentral.d.ts +2 -0
  168. package/dist/internal/vectorize.d.ts +4 -0
  169. package/dist/linalg/basic.d.ts +39 -5
  170. package/dist/linalg/basic.js +15 -0
  171. package/dist/linalg/chol.d.ts +26 -5
  172. package/dist/linalg/chol.js +7 -0
  173. package/dist/linalg/eigen.d.ts +16 -7
  174. package/dist/linalg/eigen.js +6 -5
  175. package/dist/linalg/expm.d.ts +15 -5
  176. package/dist/linalg/expm.js +5 -3
  177. package/dist/linalg/kappa.d.ts +21 -1
  178. package/dist/linalg/kappa.js +16 -0
  179. package/dist/linalg/lu.d.ts +30 -6
  180. package/dist/linalg/lu.js +15 -3
  181. package/dist/linalg/matrix.d.ts +4 -0
  182. package/dist/linalg/norm.d.ts +16 -1
  183. package/dist/linalg/norm.js +9 -0
  184. package/dist/linalg/ops.d.ts +168 -36
  185. package/dist/linalg/ops.js +116 -20
  186. package/dist/linalg/qr.d.ts +87 -12
  187. package/dist/linalg/qr.js +31 -0
  188. package/dist/linalg/schur.d.ts +8 -2
  189. package/dist/linalg/schur.js +3 -1
  190. package/dist/linalg/solve.d.ts +42 -6
  191. package/dist/linalg/solve.js +22 -0
  192. package/dist/linalg/svd.d.ts +12 -2
  193. package/dist/linalg/svd.js +2 -0
  194. package/dist/linalg.js +2 -2
  195. package/dist/models/anovaSequential.d.ts +26 -4
  196. package/dist/models/anovaSequential.js +3 -1
  197. package/dist/models/aovEz.d.ts +29 -6
  198. package/dist/models/aovEz.js +5 -2
  199. package/dist/models/aovStrata.d.ts +12 -2
  200. package/dist/models/carAnova.d.ts +9 -3
  201. package/dist/models/carAnova.js +4 -2
  202. package/dist/models/coxph.d.ts +33 -7
  203. package/dist/models/coxph.js +8 -3
  204. package/dist/models/glm.d.ts +128 -21
  205. package/dist/models/glm.js +71 -14
  206. package/dist/models/glmAnova.d.ts +30 -5
  207. package/dist/models/glmAnova.js +15 -2
  208. package/dist/models/glmConfint.d.ts +16 -2
  209. package/dist/models/glmConfint.js +9 -1
  210. package/dist/models/glmFamily.d.ts +27 -5
  211. package/dist/models/lm.d.ts +75 -17
  212. package/dist/models/lm.js +22 -4
  213. package/dist/models/mauchly.d.ts +20 -5
  214. package/dist/models/mauchly.js +7 -3
  215. package/dist/models/modelFrame.d.ts +5 -1
  216. package/dist/models/modelMatrix.d.ts +18 -4
  217. package/dist/models/modelMatrix.js +3 -1
  218. package/dist/models/survival.d.ts +41 -9
  219. package/dist/models/survival.js +10 -4
  220. package/dist/numerics/deriv.d.ts +21 -6
  221. package/dist/numerics/deriv.js +16 -5
  222. package/dist/numerics/integrate.d.ts +37 -7
  223. package/dist/numerics/integrate.js +8 -2
  224. package/dist/numerics/interp.d.ts +63 -12
  225. package/dist/numerics/interp.js +30 -6
  226. package/dist/numerics/ode.d.ts +15 -5
  227. package/dist/numerics/ode.js +5 -3
  228. package/dist/numerics.js +2 -2
  229. package/dist/optim/optim.d.ts +32 -8
  230. package/dist/optim/optim.js +8 -4
  231. package/dist/random/beta.d.ts +8 -0
  232. package/dist/random/beta.js +8 -0
  233. package/dist/random/binomial.d.ts +16 -0
  234. package/dist/random/binomial.js +16 -0
  235. package/dist/random/continuous.d.ts +51 -0
  236. package/dist/random/continuous.js +51 -0
  237. package/dist/random/extra.d.ts +66 -6
  238. package/dist/random/extra.js +66 -6
  239. package/dist/random/gamma.d.ts +33 -0
  240. package/dist/random/gamma.js +33 -0
  241. package/dist/random/hyper.d.ts +8 -0
  242. package/dist/random/hyper.js +8 -0
  243. package/dist/random/poisson.d.ts +25 -0
  244. package/dist/random/poisson.js +25 -0
  245. package/dist/random/r2dtable.d.ts +2 -0
  246. package/dist/random/r2dtable.js +2 -0
  247. package/dist/random/rank.d.ts +16 -0
  248. package/dist/random/rank.js +16 -0
  249. package/dist/random/rng.d.ts +49 -6
  250. package/dist/random/rng.js +29 -2
  251. package/dist/random/sample.d.ts +10 -2
  252. package/dist/random/sample.js +5 -1
  253. package/dist/random/streams.d.ts +13 -0
  254. package/dist/random/streams.js +13 -0
  255. package/dist/rstats.js +14 -14
  256. package/dist/special/besselIK.d.ts +11 -3
  257. package/dist/special/besselIK.js +6 -2
  258. package/dist/special/besselJY.d.ts +6 -2
  259. package/dist/special/besselJY.js +6 -2
  260. package/dist/special/beta.d.ts +16 -2
  261. package/dist/special/beta.js +16 -2
  262. package/dist/special/choose.d.ts +13 -5
  263. package/dist/special/choose.js +13 -5
  264. package/dist/special/erf.d.ts +8 -3
  265. package/dist/special/erf.js +8 -3
  266. package/dist/special/extra.d.ts +30 -10
  267. package/dist/special/extra.js +25 -9
  268. package/dist/special/gamma.d.ts +18 -2
  269. package/dist/special/gamma.js +18 -2
  270. package/dist/special/log1p.d.ts +16 -7
  271. package/dist/special/log1p.js +16 -7
  272. package/dist/special/psigamma.d.ts +9 -3
  273. package/dist/special/psigamma.js +9 -3
  274. package/dist/special/rCompatible.d.ts +5 -1
  275. package/dist/special.js +2 -2
  276. package/dist/tests.js +12 -13
  277. package/llms.txt +14 -0
  278. package/package.json +1 -1
  279. package/dist/chunks/chunk-AECGWZHD.js +0 -2
  280. package/dist/chunks/chunk-XWTZ4RTR.js +0 -2
@@ -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;
@@ -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 Weibull distribution (besides the positional `shape`). */
3
+ /**
4
+ * Parameters of the Weibull distribution (besides the positional `shape`).
5
+ *
6
+ * @category Distributions
7
+ */
4
8
  export interface WeibullParams {
5
9
  /** Scale. Default `1`. */
6
10
  scale?: number;
@@ -15,6 +19,14 @@ export declare function qweibull1(p: number, shape: number, scale: number, lower
15
19
  * @param shape - Shape parameter.
16
20
  * @param options - `scale` (see {@link WeibullParams}) and `log` (see {@link DensityOptions}).
17
21
  * @returns The density (or log density).
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * dweibull(1, 2); // 0.7357588823428847
26
+ * dweibull(1, 2, { scale: 3 }); // 0.1988531815143044
27
+ * ```
28
+ *
29
+ * @category Distributions
18
30
  */
19
31
  export declare function dweibull<T extends Vectorizable>(x: T, shape: number, options?: WeibullParams & DensityOptions): VectorResult<T>;
20
32
  /**
@@ -24,6 +36,14 @@ export declare function dweibull<T extends Vectorizable>(x: T, shape: number, op
24
36
  * @param shape - Shape parameter.
25
37
  * @param options - `scale` (see {@link WeibullParams}), `lowerTail` and `logP` (see {@link TailOptions}).
26
38
  * @returns The probability (or log probability).
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * pweibull(1, 2); // 0.6321205588285577
43
+ * pweibull(2, 1.5, { scale: 3 }); // 0.41977020402532716
44
+ * ```
45
+ *
46
+ * @category Distributions
27
47
  */
28
48
  export declare function pweibull<T extends Vectorizable>(q: T, shape: number, options?: WeibullParams & TailOptions): VectorResult<T>;
29
49
  /**
@@ -33,5 +53,13 @@ export declare function pweibull<T extends Vectorizable>(q: T, shape: number, op
33
53
  * @param shape - Shape parameter.
34
54
  * @param options - `scale` (see {@link WeibullParams}), `lowerTail` and `logP` (see {@link TailOptions}).
35
55
  * @returns The quantile(s).
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * qweibull(0.5, 2); // 0.8325546111576977
60
+ * qweibull(0.9, 1.5, { scale: 3 }); // 5.231164540789235
61
+ * ```
62
+ *
63
+ * @category Distributions
36
64
  */
37
65
  export declare function qweibull<T extends Vectorizable>(p: T, shape: number, options?: WeibullParams & TailOptions): VectorResult<T>;
@@ -94,6 +94,14 @@ export function qweibull1(p, shape, scale, lowerTail, logP) {
94
94
  * @param shape - Shape parameter.
95
95
  * @param options - `scale` (see {@link WeibullParams}) and `log` (see {@link DensityOptions}).
96
96
  * @returns The density (or log density).
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * dweibull(1, 2); // 0.7357588823428847
101
+ * dweibull(1, 2, { scale: 3 }); // 0.1988531815143044
102
+ * ```
103
+ *
104
+ * @category Distributions
97
105
  */
98
106
  export function dweibull(x, shape, options = {}) {
99
107
  const { scale = 1, log = false } = options;
@@ -106,6 +114,14 @@ export function dweibull(x, shape, options = {}) {
106
114
  * @param shape - Shape parameter.
107
115
  * @param options - `scale` (see {@link WeibullParams}), `lowerTail` and `logP` (see {@link TailOptions}).
108
116
  * @returns The probability (or log probability).
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * pweibull(1, 2); // 0.6321205588285577
121
+ * pweibull(2, 1.5, { scale: 3 }); // 0.41977020402532716
122
+ * ```
123
+ *
124
+ * @category Distributions
109
125
  */
110
126
  export function pweibull(q, shape, options = {}) {
111
127
  const { scale = 1, lowerTail = true, logP = false } = options;
@@ -118,6 +134,14 @@ export function pweibull(q, shape, options = {}) {
118
134
  * @param shape - Shape parameter.
119
135
  * @param options - `scale` (see {@link WeibullParams}), `lowerTail` and `logP` (see {@link TailOptions}).
120
136
  * @returns The quantile(s).
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * qweibull(0.5, 2); // 0.8325546111576977
141
+ * qweibull(0.9, 1.5, { scale: 3 }); // 5.231164540789235
142
+ * ```
143
+ *
144
+ * @category Distributions
121
145
  */
122
146
  export function qweibull(p, shape, options = {}) {
123
147
  const { scale = 1, lowerTail = true, logP = false } = options;
@@ -15,6 +15,14 @@ export declare function qwilcox1(p: number, m: number, n: number, lowerTail: boo
15
15
  * @param n - Size of the second sample.
16
16
  * @param options - `log` (see {@link DensityOptions}).
17
17
  * @returns The probability (or log probability).
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * dwilcox(5, 4, 6); // 0.02857142857142857
22
+ * dwilcox([0, 1, 2], 3, 4); // [0.02857142857142857, 0.02857142857142857, 0.05714285714285714]
23
+ * ```
24
+ *
25
+ * @category Distributions
18
26
  */
19
27
  export declare function dwilcox<T extends Vectorizable>(x: T, m: number, n: number, options?: DensityOptions): VectorResult<T>;
20
28
  /**
@@ -29,6 +37,14 @@ export declare function dwilcox<T extends Vectorizable>(x: T, m: number, n: numb
29
37
  * @param n - Size of the second sample.
30
38
  * @param options - `lowerTail` and `logP` (see {@link TailOptions}).
31
39
  * @returns The probability (or log probability).
40
+ *
41
+ * @example
42
+ * ```ts
43
+ * pwilcox(5, 4, 6); // 0.08571428571428572
44
+ * pwilcox(18, 4, 6, { lowerTail: false }); // 0.08571428571428572
45
+ * ```
46
+ *
47
+ * @category Distributions
32
48
  */
33
49
  export declare function pwilcox<T extends Vectorizable>(q: T, m: number, n: number, options?: TailOptions): VectorResult<T>;
34
50
  /**
@@ -43,5 +59,13 @@ export declare function pwilcox<T extends Vectorizable>(q: T, m: number, n: numb
43
59
  * @param n - Size of the second sample.
44
60
  * @param options - `lowerTail` and `logP` (see {@link TailOptions}).
45
61
  * @returns The quantile(s).
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * qwilcox(0.025, 4, 6); // 3
66
+ * qwilcox([0.25, 0.75], 4, 6); // [9, 15]
67
+ * ```
68
+ *
69
+ * @category Distributions
46
70
  */
47
71
  export declare function qwilcox<T extends Vectorizable>(p: T, m: number, n: number, options?: TailOptions): VectorResult<T>;
@@ -229,6 +229,14 @@ export function qwilcox1(p, m, n, lowerTail, logP) {
229
229
  * @param n - Size of the second sample.
230
230
  * @param options - `log` (see {@link DensityOptions}).
231
231
  * @returns The probability (or log probability).
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * dwilcox(5, 4, 6); // 0.02857142857142857
236
+ * dwilcox([0, 1, 2], 3, 4); // [0.02857142857142857, 0.02857142857142857, 0.05714285714285714]
237
+ * ```
238
+ *
239
+ * @category Distributions
232
240
  */
233
241
  export function dwilcox(x, m, n, options = {}) {
234
242
  const log = options.log ?? false;
@@ -246,6 +254,14 @@ export function dwilcox(x, m, n, options = {}) {
246
254
  * @param n - Size of the second sample.
247
255
  * @param options - `lowerTail` and `logP` (see {@link TailOptions}).
248
256
  * @returns The probability (or log probability).
257
+ *
258
+ * @example
259
+ * ```ts
260
+ * pwilcox(5, 4, 6); // 0.08571428571428572
261
+ * pwilcox(18, 4, 6, { lowerTail: false }); // 0.08571428571428572
262
+ * ```
263
+ *
264
+ * @category Distributions
249
265
  */
250
266
  export function pwilcox(q, m, n, options = {}) {
251
267
  const { lowerTail = true, logP = false } = options;
@@ -263,6 +279,14 @@ export function pwilcox(q, m, n, options = {}) {
263
279
  * @param n - Size of the second sample.
264
280
  * @param options - `lowerTail` and `logP` (see {@link TailOptions}).
265
281
  * @returns The quantile(s).
282
+ *
283
+ * @example
284
+ * ```ts
285
+ * qwilcox(0.025, 4, 6); // 3
286
+ * qwilcox([0.25, 0.75], 4, 6); // [9, 15]
287
+ * ```
288
+ *
289
+ * @category Distributions
266
290
  */
267
291
  export function qwilcox(p, m, n, options = {}) {
268
292
  const { lowerTail = true, logP = false } = options;