@numero-uno-jpn/rstats 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.ja.md +44 -13
  3. package/README.md +43 -11
  4. package/dist/chunks/{chunk-VJ4BDBMU.js → chunk-3VMBBQLV.js} +2 -2
  5. package/dist/chunks/chunk-4OKAZJJG.js +3 -0
  6. package/dist/chunks/{chunk-EZAFN5CD.js → chunk-6BH65HGN.js} +1 -1
  7. package/dist/chunks/chunk-ATC4F4BX.js +2 -0
  8. package/dist/chunks/{chunk-JWBO5WVN.js → chunk-EDH53DXN.js} +2 -2
  9. package/dist/chunks/{chunk-Y5CNQ266.js → chunk-EZ2KD5NA.js} +2 -2
  10. package/dist/chunks/{chunk-Y5PYRAYP.js → chunk-GSPOO2G3.js} +2 -2
  11. package/dist/chunks/{chunk-F5EDJFEO.js → chunk-K7AZ65H7.js} +2 -2
  12. package/dist/chunks/{chunk-YSWGDOWK.js → chunk-LEIH4U5X.js} +2 -2
  13. package/dist/chunks/{chunk-EZWBRCJL.js → chunk-OX3SBG5X.js} +1 -1
  14. package/dist/chunks/chunk-SGZQDJRR.js +2 -0
  15. package/dist/chunks/{chunk-C5XTWMGB.js → chunk-UH2N3ZQW.js} +1 -1
  16. package/dist/chunks/chunk-UV2MZYDQ.js +2 -0
  17. package/dist/chunks/{chunk-TOGXTCZO.js → chunk-VQHEOBTM.js} +2 -2
  18. package/dist/chunks/chunk-WJQZZYOI.js +2 -0
  19. package/dist/chunks/chunk-WKEFHOFR.js +2 -0
  20. package/dist/chunks/{chunk-CGBNKHNZ.js → chunk-WXC25OPJ.js} +2 -2
  21. package/dist/chunks/{chunk-5WDJPHYY.js → chunk-XJQKSR52.js} +1 -1
  22. package/dist/data/grouping.d.ts +39 -15
  23. package/dist/data/grouping.js +21 -22
  24. package/dist/descriptive/basic.d.ts +130 -17
  25. package/dist/descriptive/basic.js +115 -14
  26. package/dist/descriptive/cov.d.ts +22 -12
  27. package/dist/descriptive/dataFrames.d.ts +39 -11
  28. package/dist/descriptive/dataFrames.js +14 -6
  29. package/dist/descriptive/factanal.d.ts +26 -6
  30. package/dist/descriptive/factanal.js +7 -3
  31. package/dist/descriptive/hist.d.ts +27 -6
  32. package/dist/descriptive/hist.js +9 -3
  33. package/dist/descriptive/missing.d.ts +13 -6
  34. package/dist/descriptive/missing.js +4 -2
  35. package/dist/descriptive/moments.d.ts +91 -13
  36. package/dist/descriptive/moments.js +66 -9
  37. package/dist/descriptive/omega.d.ts +28 -6
  38. package/dist/descriptive/omega.js +16 -4
  39. package/dist/descriptive/pivot.d.ts +22 -6
  40. package/dist/descriptive/pivot.js +7 -3
  41. package/dist/descriptive/quantile.d.ts +33 -5
  42. package/dist/descriptive/quantile.js +20 -2
  43. package/dist/descriptive/rank.d.ts +12 -2
  44. package/dist/descriptive/rank.js +2 -0
  45. package/dist/descriptive/table.d.ts +55 -7
  46. package/dist/descriptive/table.js +38 -4
  47. package/dist/descriptive.js +2 -2
  48. package/dist/distributions/arcsine.d.ts +40 -5
  49. package/dist/distributions/arcsine.js +35 -4
  50. package/dist/distributions/beta.d.ts +12 -0
  51. package/dist/distributions/beta.js +12 -0
  52. package/dist/distributions/binomial.d.ts +18 -0
  53. package/dist/distributions/binomial.js +18 -0
  54. package/dist/distributions/bvnorm.d.ts +4 -1
  55. package/dist/distributions/bvnorm.js +4 -1
  56. package/dist/distributions/cauchy.d.ts +24 -0
  57. package/dist/distributions/cauchy.js +24 -0
  58. package/dist/distributions/chisq.d.ts +18 -0
  59. package/dist/distributions/chisq.js +18 -0
  60. package/dist/distributions/exponential.d.ts +29 -1
  61. package/dist/distributions/exponential.js +24 -0
  62. package/dist/distributions/f.d.ts +18 -0
  63. package/dist/distributions/f.js +18 -0
  64. package/dist/distributions/gamma.d.ts +20 -0
  65. package/dist/distributions/gamma.js +18 -0
  66. package/dist/distributions/geometric.d.ts +24 -0
  67. package/dist/distributions/geometric.js +24 -0
  68. package/dist/distributions/hypergeometric.d.ts +24 -0
  69. package/dist/distributions/hypergeometric.js +24 -0
  70. package/dist/distributions/invgamma.d.ts +32 -4
  71. package/dist/distributions/invgamma.js +27 -3
  72. package/dist/distributions/kumaraswamy.d.ts +31 -3
  73. package/dist/distributions/kumaraswamy.js +31 -3
  74. package/dist/distributions/laplace.d.ts +36 -4
  75. package/dist/distributions/laplace.js +31 -3
  76. package/dist/distributions/logistic.d.ts +29 -1
  77. package/dist/distributions/logistic.js +24 -0
  78. package/dist/distributions/lognormal.d.ts +29 -1
  79. package/dist/distributions/lognormal.js +24 -0
  80. package/dist/distributions/multinomial.d.ts +7 -1
  81. package/dist/distributions/multinomial.js +2 -0
  82. package/dist/distributions/negbinomial.d.ts +29 -1
  83. package/dist/distributions/negbinomial.js +24 -0
  84. package/dist/distributions/normal.d.ts +11 -1
  85. package/dist/distributions/normal.js +6 -0
  86. package/dist/distributions/pareto.d.ts +36 -4
  87. package/dist/distributions/pareto.js +31 -3
  88. package/dist/distributions/poisson.d.ts +18 -0
  89. package/dist/distributions/poisson.js +18 -0
  90. package/dist/distributions/signrank.d.ts +24 -0
  91. package/dist/distributions/signrank.js +24 -0
  92. package/dist/distributions/summary.d.ts +20 -2
  93. package/dist/distributions/summary.js +4 -0
  94. package/dist/distributions/t.d.ts +18 -0
  95. package/dist/distributions/t.js +18 -0
  96. package/dist/distributions/triangular.d.ts +36 -4
  97. package/dist/distributions/triangular.js +31 -3
  98. package/dist/distributions/tukey.d.ts +15 -1
  99. package/dist/distributions/tukey.js +10 -0
  100. package/dist/distributions/uniform.d.ts +29 -1
  101. package/dist/distributions/uniform.js +24 -0
  102. package/dist/distributions/weibull.d.ts +29 -1
  103. package/dist/distributions/weibull.js +24 -0
  104. package/dist/distributions/wilcox.d.ts +24 -0
  105. package/dist/distributions/wilcox.js +24 -0
  106. package/dist/distributions.js +2 -2
  107. package/dist/entries/descriptive.d.ts +1 -1
  108. package/dist/entries/mixed.d.ts +1 -0
  109. package/dist/entries/mixed.js +2 -0
  110. package/dist/entries/numerics.d.ts +1 -1
  111. package/dist/entries/tests.js +1 -1
  112. package/dist/htest/agreement.d.ts +61 -23
  113. package/dist/htest/agreement.js +19 -9
  114. package/dist/htest/ansariTest.d.ts +8 -2
  115. package/dist/htest/aov.d.ts +43 -10
  116. package/dist/htest/aov.js +17 -3
  117. package/dist/htest/binomTest.d.ts +12 -2
  118. package/dist/htest/binomTest.js +2 -0
  119. package/dist/htest/brunnerMunzelTest.d.ts +9 -3
  120. package/dist/htest/brunnerMunzelTest.js +4 -2
  121. package/dist/htest/chisqTest.d.ts +19 -3
  122. package/dist/htest/cor.d.ts +20 -4
  123. package/dist/htest/effectSize.d.ts +70 -12
  124. package/dist/htest/effectSize.js +40 -7
  125. package/dist/htest/fisherTest.d.ts +9 -1
  126. package/dist/htest/fisherTest.js +2 -0
  127. package/dist/htest/groups.d.ts +5 -1
  128. package/dist/htest/ksTest.d.ts +20 -3
  129. package/dist/htest/leveneTest.d.ts +15 -4
  130. package/dist/htest/leveneTest.js +5 -2
  131. package/dist/htest/mantelhaenTest.d.ts +25 -3
  132. package/dist/htest/mantelhaenTest.js +15 -1
  133. package/dist/htest/mcnemarTest.d.ts +14 -4
  134. package/dist/htest/mcnemarTest.js +4 -2
  135. package/dist/htest/multipleComparisons.d.ts +173 -29
  136. package/dist/htest/multipleComparisons.js +123 -19
  137. package/dist/htest/normalityTests.d.ts +56 -9
  138. package/dist/htest/normalityTests.js +40 -6
  139. package/dist/htest/onewayTest.d.ts +32 -3
  140. package/dist/htest/onewayTest.js +10 -0
  141. package/dist/htest/pAdjust.d.ts +9 -1
  142. package/dist/htest/pAdjust.js +2 -0
  143. package/dist/htest/pairwise.d.ts +50 -5
  144. package/dist/htest/pairwise.js +25 -0
  145. package/dist/htest/poissonTest.d.ts +12 -2
  146. package/dist/htest/poissonTest.js +2 -0
  147. package/dist/htest/polycor.d.ts +29 -10
  148. package/dist/htest/power.d.ts +60 -6
  149. package/dist/htest/power.js +6 -0
  150. package/dist/htest/propTest.d.ts +13 -2
  151. package/dist/htest/propTest.js +2 -0
  152. package/dist/htest/pwr.d.ts +286 -36
  153. package/dist/htest/pwr.js +116 -15
  154. package/dist/htest/rankTests.d.ts +80 -12
  155. package/dist/htest/rankTests.js +11 -2
  156. package/dist/htest/tTest.d.ts +13 -3
  157. package/dist/htest/testFormula.js +6 -3
  158. package/dist/htest/trendTests.d.ts +29 -8
  159. package/dist/htest/trendTests.js +8 -4
  160. package/dist/htest/types.d.ts +14 -2
  161. package/dist/htest/varTest.d.ts +25 -8
  162. package/dist/htest/wilcoxTest.d.ts +10 -2
  163. package/dist/internal/dpq.d.ts +4 -0
  164. package/dist/internal/noncentral.d.ts +2 -0
  165. package/dist/internal/vectorize.d.ts +4 -0
  166. package/dist/linalg/basic.d.ts +39 -5
  167. package/dist/linalg/basic.js +15 -0
  168. package/dist/linalg/chol.d.ts +26 -5
  169. package/dist/linalg/chol.js +7 -0
  170. package/dist/linalg/eigen.d.ts +16 -7
  171. package/dist/linalg/eigen.js +6 -5
  172. package/dist/linalg/expm.d.ts +15 -5
  173. package/dist/linalg/expm.js +5 -3
  174. package/dist/linalg/kappa.d.ts +21 -1
  175. package/dist/linalg/kappa.js +16 -0
  176. package/dist/linalg/lu.d.ts +30 -6
  177. package/dist/linalg/lu.js +15 -3
  178. package/dist/linalg/matrix.d.ts +4 -0
  179. package/dist/linalg/norm.d.ts +16 -1
  180. package/dist/linalg/norm.js +9 -0
  181. package/dist/linalg/ops.d.ts +156 -35
  182. package/dist/linalg/ops.js +96 -15
  183. package/dist/linalg/qr.d.ts +87 -12
  184. package/dist/linalg/qr.js +31 -0
  185. package/dist/linalg/schur.d.ts +8 -2
  186. package/dist/linalg/schur.js +3 -1
  187. package/dist/linalg/solve.d.ts +42 -6
  188. package/dist/linalg/solve.js +22 -0
  189. package/dist/linalg/svd.d.ts +12 -2
  190. package/dist/linalg/svd.js +2 -0
  191. package/dist/linalg.js +2 -2
  192. package/dist/mixed.js +3 -0
  193. package/dist/models/anovaSequential.d.ts +26 -4
  194. package/dist/models/anovaSequential.js +3 -1
  195. package/dist/models/aovEz.d.ts +29 -6
  196. package/dist/models/aovEz.js +5 -2
  197. package/dist/models/aovStrata.d.ts +13 -3
  198. package/dist/models/aovStrata.js +5 -1
  199. package/dist/models/carAnova.d.ts +9 -3
  200. package/dist/models/carAnova.js +4 -2
  201. package/dist/models/coxph.d.ts +33 -7
  202. package/dist/models/coxph.js +8 -3
  203. package/dist/models/formula.d.ts +26 -1
  204. package/dist/models/formula.js +125 -9
  205. package/dist/models/glm.d.ts +128 -21
  206. package/dist/models/glm.js +71 -14
  207. package/dist/models/glmAnova.d.ts +30 -5
  208. package/dist/models/glmAnova.js +15 -2
  209. package/dist/models/glmConfint.d.ts +16 -2
  210. package/dist/models/glmConfint.js +9 -1
  211. package/dist/models/glmFamily.d.ts +27 -5
  212. package/dist/models/lm.d.ts +77 -19
  213. package/dist/models/lm.js +22 -4
  214. package/dist/models/lmer.d.ts +162 -0
  215. package/dist/models/lmer.js +457 -0
  216. package/dist/models/mauchly.d.ts +20 -5
  217. package/dist/models/mauchly.js +7 -3
  218. package/dist/models/mixedDeviance.d.ts +44 -0
  219. package/dist/models/mixedDeviance.js +872 -0
  220. package/dist/models/mixedStructure.d.ts +82 -0
  221. package/dist/models/mixedStructure.js +309 -0
  222. package/dist/models/modelFrame.d.ts +17 -2
  223. package/dist/models/modelFrame.js +36 -21
  224. package/dist/models/modelMatrix.d.ts +33 -8
  225. package/dist/models/modelMatrix.js +21 -5
  226. package/dist/models/survival.d.ts +41 -9
  227. package/dist/models/survival.js +10 -4
  228. package/dist/numerics/deriv.d.ts +21 -6
  229. package/dist/numerics/deriv.js +16 -5
  230. package/dist/numerics/integrate.d.ts +37 -7
  231. package/dist/numerics/integrate.js +8 -2
  232. package/dist/numerics/interp.d.ts +63 -12
  233. package/dist/numerics/interp.js +30 -6
  234. package/dist/numerics/ode.d.ts +15 -5
  235. package/dist/numerics/ode.js +5 -3
  236. package/dist/numerics.js +2 -2
  237. package/dist/optim/optim.d.ts +32 -8
  238. package/dist/optim/optim.js +8 -4
  239. package/dist/random/beta.d.ts +8 -0
  240. package/dist/random/beta.js +8 -0
  241. package/dist/random/binomial.d.ts +16 -0
  242. package/dist/random/binomial.js +16 -0
  243. package/dist/random/continuous.d.ts +51 -0
  244. package/dist/random/continuous.js +51 -0
  245. package/dist/random/extra.d.ts +66 -6
  246. package/dist/random/extra.js +66 -6
  247. package/dist/random/gamma.d.ts +33 -0
  248. package/dist/random/gamma.js +33 -0
  249. package/dist/random/hyper.d.ts +8 -0
  250. package/dist/random/hyper.js +8 -0
  251. package/dist/random/poisson.d.ts +25 -0
  252. package/dist/random/poisson.js +25 -0
  253. package/dist/random/r2dtable.d.ts +2 -0
  254. package/dist/random/r2dtable.js +2 -0
  255. package/dist/random/rank.d.ts +16 -0
  256. package/dist/random/rank.js +16 -0
  257. package/dist/random/rng.d.ts +49 -6
  258. package/dist/random/rng.js +29 -2
  259. package/dist/random/sample.d.ts +10 -2
  260. package/dist/random/sample.js +5 -1
  261. package/dist/random/streams.d.ts +13 -0
  262. package/dist/random/streams.js +13 -0
  263. package/dist/rstats.js +14 -14
  264. package/dist/special/besselIK.d.ts +11 -3
  265. package/dist/special/besselIK.js +6 -2
  266. package/dist/special/besselJY.d.ts +6 -2
  267. package/dist/special/besselJY.js +6 -2
  268. package/dist/special/beta.d.ts +16 -2
  269. package/dist/special/beta.js +16 -2
  270. package/dist/special/choose.d.ts +13 -5
  271. package/dist/special/choose.js +13 -5
  272. package/dist/special/erf.d.ts +8 -3
  273. package/dist/special/erf.js +8 -3
  274. package/dist/special/extra.d.ts +30 -10
  275. package/dist/special/extra.js +25 -9
  276. package/dist/special/gamma.d.ts +18 -2
  277. package/dist/special/gamma.js +18 -2
  278. package/dist/special/log1p.d.ts +16 -7
  279. package/dist/special/log1p.js +16 -7
  280. package/dist/special/psigamma.d.ts +9 -3
  281. package/dist/special/psigamma.js +9 -3
  282. package/dist/special/rCompatible.d.ts +5 -1
  283. package/dist/special.js +2 -2
  284. package/dist/tests.js +12 -12
  285. package/llms.txt +13 -3
  286. package/package.json +5 -1
  287. package/dist/chunks/chunk-7GQMKH3Z.js +0 -2
  288. package/dist/chunks/chunk-AHHS6AC4.js +0 -3
  289. package/dist/chunks/chunk-ALM3VHFP.js +0 -2
@@ -1,10 +1,18 @@
1
1
  import type { GroupLabel } from "../htest/groups.js";
2
- /** Options for {@link survdiff}. */
2
+ /**
3
+ * Options for {@link survdiff}.
4
+ *
5
+ * @category Survival analysis
6
+ */
3
7
  export interface SurvdiffOptions {
4
8
  /** Exponent of the weights S(t-)^rho (pooled Kaplan-Meier estimate just before each event time). Default 0. */
5
9
  rho?: number;
6
10
  }
7
- /** Result of {@link survdiff}. */
11
+ /**
12
+ * Result of {@link survdiff}.
13
+ *
14
+ * @category Survival analysis
15
+ */
8
16
  export interface SurvdiffResult {
9
17
  /** Number of observations per group */
10
18
  n: number[];
@@ -21,9 +29,17 @@ export interface SurvdiffResult {
21
29
  /** Upper chi-squared tail on (number of groups with a positive expected count) - 1 degrees of freedom */
22
30
  pvalue: number;
23
31
  }
24
- /** Confidence interval type of {@link survfit}. */
32
+ /**
33
+ * Confidence interval type of {@link survfit}.
34
+ *
35
+ * @category Survival analysis
36
+ */
25
37
  export type SurvfitConfType = "log" | "plain" | "log-log";
26
- /** Options for {@link survfit}. */
38
+ /**
39
+ * Options for {@link survfit}.
40
+ *
41
+ * @category Survival analysis
42
+ */
27
43
  export interface SurvfitOptions {
28
44
  /** Group labels, one per observation: one curve per group. Omitted: a single curve. */
29
45
  group?: readonly GroupLabel[];
@@ -32,19 +48,29 @@ export interface SurvfitOptions {
32
48
  /** Confidence level. Default 0.95. */
33
49
  confInt?: number;
34
50
  }
35
- /** Result of {@link survfit}: the rows of R's `summary(fit, censored = TRUE)` and the medians. */
51
+ /**
52
+ * Result of {@link survfit}: the rows of R's `summary(fit, censored = TRUE)` and the medians.
53
+ *
54
+ * @category Survival analysis
55
+ */
36
56
  export interface SurvfitResult {
37
57
  /** Stratum of each row (`"group=<label>"`, or `"all"` for a single curve) */
38
58
  strata: string[];
59
+ /** Time of each row (the distinct times of the stratum, censored ones included) */
39
60
  time: number[];
61
+ /** Number at risk just before the time (R's `n.risk`) */
40
62
  nRisk: number[];
63
+ /** Number of events at the time (R's `n.event`) */
41
64
  nEvent: number[];
65
+ /** Number censored at the time (R's `n.censor`) */
42
66
  nCensor: number[];
43
67
  /** Kaplan-Meier estimate S(t) */
44
68
  surv: number[];
45
69
  /** Standard error of S(t) (S times the standard error of log S) */
46
70
  stdErr: number[];
71
+ /** Lower limit of the pointwise confidence interval of S(t) */
47
72
  lower: number[];
73
+ /** Upper limit of the pointwise confidence interval of S(t) */
48
74
  upper: number[];
49
75
  /** Per stratum, [median, lower limit, upper limit] (NaN for R's NA) */
50
76
  median: number[][];
@@ -53,7 +79,7 @@ export interface SurvfitResult {
53
79
  }
54
80
  /**
55
81
  * Test of the difference between survival curves: the G-rho family of Harrington and Fleming, the log-rank test for
56
- * `rho = 0`. Equivalent to R's `survdiff(Surv(time, status) ~ group, rho = rho)` (package survival).
82
+ * `rho = 0`. Equivalent to R's `survival::survdiff()`. As `survdiff(Surv(time, status) ~ group, rho = rho)`.
57
83
  *
58
84
  * Rows with a missing time, status or group are dropped.
59
85
  *
@@ -64,14 +90,18 @@ export interface SurvfitResult {
64
90
  *
65
91
  * @example
66
92
  * ```ts
67
- * survdiff([1, 2, 3, 4, 5, 6], [1, 1, 0, 1, 1, 1], ["a", "b", "a", "b", "a", "b"]).chisq;
93
+ * const r = survdiff([1, 2, 3, 4, 5, 6], [1, 1, 0, 1, 1, 1], ["a", "b", "a", "b", "a", "b"]);
94
+ * r.chisq; // 0.073903
95
+ * r.pvalue; // 0.78574
68
96
  * ```
97
+ *
98
+ * @category Survival analysis
69
99
  */
70
100
  export declare function survdiff(time: readonly number[], status: readonly number[], group: readonly (GroupLabel | null)[], options?: SurvdiffOptions): SurvdiffResult;
71
101
  /**
72
102
  * Kaplan-Meier estimate of the survival function with Greenwood's standard error and pointwise confidence intervals.
73
- * Equivalent to R's `summary(survfit(Surv(time, status) ~ group, conf.type, conf.int), censored = TRUE)` (package
74
- * survival), with the medians and their confidence limits of `summary(fit)$table`.
103
+ * Equivalent to R's `survival::survfit()`. As `summary(survfit(Surv(time, status) ~ group, conf.type, conf.int),
104
+ * censored = TRUE)`, with the medians and their confidence limits of `summary(fit)$table`.
75
105
  *
76
106
  * Rows with a missing time, status or group are dropped.
77
107
  *
@@ -83,5 +113,7 @@ export declare function survdiff(time: readonly number[], status: readonly numbe
83
113
  * ```ts
84
114
  * survfit([1, 2, 2, 3, 4], [1, 1, 0, 1, 0]).surv; // [0.8, 0.6, 0.3, 0.3]
85
115
  * ```
116
+ *
117
+ * @category Survival analysis
86
118
  */
87
119
  export declare function survfit(time: readonly number[], status: readonly number[], options?: SurvfitOptions): SurvfitResult;
@@ -43,7 +43,7 @@ function prepare(time, status, group) {
43
43
  }
44
44
  /**
45
45
  * Test of the difference between survival curves: the G-rho family of Harrington and Fleming, the log-rank test for
46
- * `rho = 0`. Equivalent to R's `survdiff(Surv(time, status) ~ group, rho = rho)` (package survival).
46
+ * `rho = 0`. Equivalent to R's `survival::survdiff()`. As `survdiff(Surv(time, status) ~ group, rho = rho)`.
47
47
  *
48
48
  * Rows with a missing time, status or group are dropped.
49
49
  *
@@ -54,8 +54,12 @@ function prepare(time, status, group) {
54
54
  *
55
55
  * @example
56
56
  * ```ts
57
- * survdiff([1, 2, 3, 4, 5, 6], [1, 1, 0, 1, 1, 1], ["a", "b", "a", "b", "a", "b"]).chisq;
57
+ * const r = survdiff([1, 2, 3, 4, 5, 6], [1, 1, 0, 1, 1, 1], ["a", "b", "a", "b", "a", "b"]);
58
+ * r.chisq; // 0.073903
59
+ * r.pvalue; // 0.78574
58
60
  * ```
61
+ *
62
+ * @category Survival analysis
59
63
  */
60
64
  export function survdiff(time, status, group, options = {}) {
61
65
  const { rho = 0 } = options;
@@ -144,8 +148,8 @@ function curveMedian(time, nEvent, curve) {
144
148
  }
145
149
  /**
146
150
  * Kaplan-Meier estimate of the survival function with Greenwood's standard error and pointwise confidence intervals.
147
- * Equivalent to R's `summary(survfit(Surv(time, status) ~ group, conf.type, conf.int), censored = TRUE)` (package
148
- * survival), with the medians and their confidence limits of `summary(fit)$table`.
151
+ * Equivalent to R's `survival::survfit()`. As `summary(survfit(Surv(time, status) ~ group, conf.type, conf.int),
152
+ * censored = TRUE)`, with the medians and their confidence limits of `summary(fit)$table`.
149
153
  *
150
154
  * Rows with a missing time, status or group are dropped.
151
155
  *
@@ -157,6 +161,8 @@ function curveMedian(time, nEvent, curve) {
157
161
  * ```ts
158
162
  * survfit([1, 2, 2, 3, 4], [1, 1, 0, 1, 0]).surv; // [0.8, 0.6, 0.3, 0.3]
159
163
  * ```
164
+ *
165
+ * @category Survival analysis
160
166
  */
161
167
  export function survfit(time, status, options = {}) {
162
168
  const { group, confType = "log", confInt = 0.95 } = options;
@@ -1,4 +1,8 @@
1
- /** Options for {@link grad}, {@link jacobian} and {@link hessian}. */
1
+ /**
2
+ * Options for {@link grad}, {@link jacobian} and {@link hessian}.
3
+ *
4
+ * @category Numerical methods
5
+ */
2
6
  export interface DerivOptions {
3
7
  /** `"Richardson"` (default) or `"simple"` (forward difference; not for `hessian`). */
4
8
  method?: "Richardson" | "simple";
@@ -12,26 +16,37 @@ export interface DerivOptions {
12
16
  r?: number;
13
17
  }
14
18
  /**
15
- * Gradient of a scalar function of a vector. Equivalent to `numDeriv::grad(func, x, method)`.
19
+ * Gradient of a scalar function of a vector. Equivalent to `numDeriv::grad(func, x, method)` in R.
16
20
  *
17
21
  * @example
18
22
  * ```ts
19
- * grad((x) => x[0]! ** 2 + Math.sin(x[1]!), [1, 0]); // ≈ [2, 1]
23
+ * grad((x) => x[0]! ** 2 + Math.sin(x[1]!), [1, 0]); // [2, 1]
20
24
  * ```
25
+ *
26
+ * @category Numerical methods
21
27
  */
22
28
  export declare function grad(func: (x: number[]) => number, x: readonly number[], options?: DerivOptions): number[];
23
29
  /**
24
30
  * Jacobian of a vector function of a vector: row i holds the derivatives of the i-th value. Equivalent to
25
- * `numDeriv::jacobian(func, x, method)`.
31
+ * `numDeriv::jacobian(func, x, method)` in R.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * jacobian((x) => [x[0]! * x[1]!, x[0]! + 2 * x[1]!], [2, 3]); // [[3, 2], [1, 2]]
36
+ * ```
37
+ *
38
+ * @category Numerical methods
26
39
  */
27
40
  export declare function jacobian(func: (x: number[]) => readonly number[], x: readonly number[], options?: DerivOptions): number[][];
28
41
  /**
29
42
  * Hessian matrix of a scalar function of a vector, by Richardson extrapolation (Bates and Watts). Equivalent to
30
- * `numDeriv::hessian(func, x)`.
43
+ * `numDeriv::hessian(func, x)` in R.
31
44
  *
32
45
  * @example
33
46
  * ```ts
34
- * hessian((x) => x[0]! ** 2 * x[1]!, [1, 2]); // ≈ [[4, 2], [2, 0]]
47
+ * hessian((x) => x[0]! ** 2 * x[1]! ** 2, [1, 2]); // [[8, 8], [8, 2]]
35
48
  * ```
49
+ *
50
+ * @category Numerical methods
36
51
  */
37
52
  export declare function hessian(func: (x: number[]) => number, x: readonly number[], options?: DerivOptions): number[][];
@@ -38,12 +38,14 @@ function method(options) {
38
38
  return m;
39
39
  }
40
40
  /**
41
- * Gradient of a scalar function of a vector. Equivalent to `numDeriv::grad(func, x, method)`.
41
+ * Gradient of a scalar function of a vector. Equivalent to `numDeriv::grad(func, x, method)` in R.
42
42
  *
43
43
  * @example
44
44
  * ```ts
45
- * grad((x) => x[0]! ** 2 + Math.sin(x[1]!), [1, 0]); // ≈ [2, 1]
45
+ * grad((x) => x[0]! ** 2 + Math.sin(x[1]!), [1, 0]); // [2, 1]
46
46
  * ```
47
+ *
48
+ * @category Numerical methods
47
49
  */
48
50
  export function grad(func, x, options = {}) {
49
51
  const xs = [...x];
@@ -74,7 +76,14 @@ export function grad(func, x, options = {}) {
74
76
  }
75
77
  /**
76
78
  * Jacobian of a vector function of a vector: row i holds the derivatives of the i-th value. Equivalent to
77
- * `numDeriv::jacobian(func, x, method)`.
79
+ * `numDeriv::jacobian(func, x, method)` in R.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * jacobian((x) => [x[0]! * x[1]!, x[0]! + 2 * x[1]!], [2, 3]); // [[3, 2], [1, 2]]
84
+ * ```
85
+ *
86
+ * @category Numerical methods
78
87
  */
79
88
  export function jacobian(func, x, options = {}) {
80
89
  const xs = [...x];
@@ -105,12 +114,14 @@ export function jacobian(func, x, options = {}) {
105
114
  }
106
115
  /**
107
116
  * Hessian matrix of a scalar function of a vector, by Richardson extrapolation (Bates and Watts). Equivalent to
108
- * `numDeriv::hessian(func, x)`.
117
+ * `numDeriv::hessian(func, x)` in R.
109
118
  *
110
119
  * @example
111
120
  * ```ts
112
- * hessian((x) => x[0]! ** 2 * x[1]!, [1, 2]); // ≈ [[4, 2], [2, 0]]
121
+ * hessian((x) => x[0]! ** 2 * x[1]! ** 2, [1, 2]); // [[8, 8], [8, 2]]
113
122
  * ```
123
+ *
124
+ * @category Numerical methods
114
125
  */
115
126
  export function hessian(func, x, options = {}) {
116
127
  if ((options.method ?? "Richardson") !== "Richardson")
@@ -1,4 +1,8 @@
1
- /** Options for {@link integrate}. */
1
+ /**
2
+ * Options for {@link integrate}.
3
+ *
4
+ * @category Numerical methods
5
+ */
2
6
  export interface IntegrateOptions {
3
7
  /** Maximum number of subintervals. Default `100`. */
4
8
  subdivisions?: number;
@@ -9,8 +13,13 @@ export interface IntegrateOptions {
9
13
  /** Throw when QUADPACK reports a problem (default `true`); otherwise return the result with its code. */
10
14
  stopOnError?: boolean;
11
15
  }
12
- /** Result of {@link integrate}. */
16
+ /**
17
+ * Result of {@link integrate}.
18
+ *
19
+ * @category Numerical methods
20
+ */
13
21
  export interface IntegrateResult {
22
+ /** The estimate of the integral. */
14
23
  value: number;
15
24
  /** Estimate of the absolute error. */
16
25
  absError: number;
@@ -27,11 +36,17 @@ export interface IntegrateResult {
27
36
  *
28
37
  * @example
29
38
  * ```ts
30
- * integrate((x) => Math.exp(-x * x / 2), -Infinity, Infinity).value; // 2.5066282746310002 (sqrt(2 pi))
39
+ * integrate((x) => Math.exp(-x * x / 2), -Infinity, Infinity).value; // 2.506628274115034 (sqrt(2 pi) = 2.5066282746310002)
31
40
  * ```
41
+ *
42
+ * @category Numerical methods
32
43
  */
33
44
  export declare function integrate(f: (x: number) => number, lower: number, upper: number, options?: IntegrateOptions): IntegrateResult;
34
- /** Options for {@link optimize}. */
45
+ /**
46
+ * Options for {@link optimize}.
47
+ *
48
+ * @category Numerical methods
49
+ */
35
50
  export interface OptimizeOptions {
36
51
  /** Maximise instead of minimise. Default `false`. */
37
52
  maximum?: boolean;
@@ -40,19 +55,27 @@ export interface OptimizeOptions {
40
55
  }
41
56
  /**
42
57
  * Minimum (or maximum) of a function of one variable on an interval, by Brent's golden-section and parabolic
43
- * search. Equivalent to R's `optimize()`: `optimum` is the location (R's `minimum`/`maximum`) and `objective` the
58
+ * search. Equivalent to R's `optimize()`. `optimum` is the location (R's `minimum`/`maximum`) and `objective` the
44
59
  * function there. `lower` must be less than `upper`, as in R.
45
60
  *
46
61
  * @example
47
62
  * ```ts
48
63
  * optimize((x) => (x - 1 / 3) ** 2, 0, 1).optimum; // 0.3333333333333333
49
64
  * ```
65
+ *
66
+ * @category Numerical methods
50
67
  */
51
68
  export declare function optimize(f: (x: number) => number, lower: number, upper: number, options?: OptimizeOptions): {
69
+ /** Location of the minimum or maximum (R's `minimum` or `maximum`). */
52
70
  optimum: number;
71
+ /** Value of the function there. */
53
72
  objective: number;
54
73
  };
55
- /** Options for {@link uniroot}. */
74
+ /**
75
+ * Options for {@link uniroot}.
76
+ *
77
+ * @category Numerical methods
78
+ */
56
79
  export interface UnirootOptions {
57
80
  /** Accuracy. Default `eps^0.25`. */
58
81
  tol?: number;
@@ -68,8 +91,13 @@ export interface UnirootOptions {
68
91
  /** f(upper), when already known. */
69
92
  fUpper?: number;
70
93
  }
71
- /** Result of {@link uniroot}. */
94
+ /**
95
+ * Result of {@link uniroot}.
96
+ *
97
+ * @category Numerical methods
98
+ */
72
99
  export interface UnirootResult {
100
+ /** The root found. */
73
101
  root: number;
74
102
  /** f at the root. */
75
103
  fRoot: number;
@@ -87,5 +115,7 @@ export interface UnirootResult {
87
115
  * ```ts
88
116
  * uniroot((x) => x * x - 2, 0, 2, { tol: 1e-12 }).root; // 1.4142135623731364
89
117
  * ```
118
+ *
119
+ * @category Numerical methods
90
120
  */
91
121
  export declare function uniroot(f: (x: number) => number, lower: number, upper: number, options?: UnirootOptions): UnirootResult;
@@ -25,8 +25,10 @@ const TOL = Number.EPSILON ** 0.25;
25
25
  *
26
26
  * @example
27
27
  * ```ts
28
- * integrate((x) => Math.exp(-x * x / 2), -Infinity, Infinity).value; // 2.5066282746310002 (sqrt(2 pi))
28
+ * integrate((x) => Math.exp(-x * x / 2), -Infinity, Infinity).value; // 2.506628274115034 (sqrt(2 pi) = 2.5066282746310002)
29
29
  * ```
30
+ *
31
+ * @category Numerical methods
30
32
  */
31
33
  export function integrate(f, lower, upper, options = {}) {
32
34
  const limit = options.subdivisions ?? 100;
@@ -59,13 +61,15 @@ export function integrate(f, lower, upper, options = {}) {
59
61
  }
60
62
  /**
61
63
  * Minimum (or maximum) of a function of one variable on an interval, by Brent's golden-section and parabolic
62
- * search. Equivalent to R's `optimize()`: `optimum` is the location (R's `minimum`/`maximum`) and `objective` the
64
+ * search. Equivalent to R's `optimize()`. `optimum` is the location (R's `minimum`/`maximum`) and `objective` the
63
65
  * function there. `lower` must be less than `upper`, as in R.
64
66
  *
65
67
  * @example
66
68
  * ```ts
67
69
  * optimize((x) => (x - 1 / 3) ** 2, 0, 1).optimum; // 0.3333333333333333
68
70
  * ```
71
+ *
72
+ * @category Numerical methods
69
73
  */
70
74
  export function optimize(f, lower, upper, options = {}) {
71
75
  const maximum = options.maximum ?? false;
@@ -82,6 +86,8 @@ export function optimize(f, lower, upper, options = {}) {
82
86
  * ```ts
83
87
  * uniroot((x) => x * x - 2, 0, 2, { tol: 1e-12 }).root; // 1.4142135623731364
84
88
  * ```
89
+ *
90
+ * @category Numerical methods
85
91
  */
86
92
  export function uniroot(f, lower, upper, options = {}) {
87
93
  const tol = options.tol ?? TOL;
@@ -1,6 +1,16 @@
1
1
  import type { Sample } from "../htest/types.js";
2
- type Ties = "mean" | "min" | "max" | ((v: number[]) => number);
3
- /** Options for {@link approx}. */
2
+ /**
3
+ * How equal `x` values are merged before interpolating (R's `ties`): `"mean"`, `"min"` or `"max"` of their `y`, or a
4
+ * function of their `y` values.
5
+ *
6
+ * @category Numerical methods
7
+ */
8
+ export type Ties = "mean" | "min" | "max" | ((v: number[]) => number);
9
+ /**
10
+ * Options for {@link approx}.
11
+ *
12
+ * @category Numerical methods
13
+ */
4
14
  export interface ApproxOptions {
5
15
  /** Points to interpolate at. Default: `n` equally spaced points over the range of `x`. */
6
16
  xout?: Sample;
@@ -26,20 +36,34 @@ export interface ApproxOptions {
26
36
  * ```ts
27
37
  * approx([1, 2, 3], [10, 20, 40], { xout: [1.5, 2.5] }).y; // [15, 30]
28
38
  * ```
39
+ *
40
+ * @category Numerical methods
29
41
  */
30
42
  export declare function approx(x: Sample, y: Sample, options?: ApproxOptions): {
43
+ /** The points interpolated at (`xout`, or the equally spaced points). */
31
44
  x: number[];
45
+ /** The interpolated values, one per point of `x`. */
32
46
  y: number[];
33
47
  };
34
- /** Cubic spline method. */
48
+ /**
49
+ * Cubic spline method.
50
+ *
51
+ * @category Numerical methods
52
+ */
35
53
  export type SplineMethod = "fmm" | "natural" | "periodic" | "hyman";
36
- /** Options for {@link spline}. */
54
+ /**
55
+ * Options for {@link spline}.
56
+ *
57
+ * @category Numerical methods
58
+ */
37
59
  export interface SplineOptions {
38
60
  /** Number of equally spaced points from `xmin` to `xmax`. Default `3 * x.length`. */
39
61
  n?: number;
40
62
  /** `"fmm"` (default), `"natural"`, `"periodic"` or `"hyman"`. */
41
63
  method?: SplineMethod;
64
+ /** Left end of the equally spaced points. Default: the smallest `x`. */
42
65
  xmin?: number;
66
+ /** Right end of the equally spaced points. Default: the largest `x`. */
43
67
  xmax?: number;
44
68
  /** Points to interpolate at (then `n`, `xmin` and `xmax` are not used). */
45
69
  xout?: Sample;
@@ -53,12 +77,20 @@ export interface SplineOptions {
53
77
  * ```ts
54
78
  * spline([1, 2, 3, 4], [1, 4, 9, 16], { xout: [2.5] }).y; // [6.25]
55
79
  * ```
80
+ *
81
+ * @category Numerical methods
56
82
  */
57
83
  export declare function spline(x: Sample, y: Sample, options?: SplineOptions): {
84
+ /** The points interpolated at (`xout`, or the equally spaced points). */
58
85
  x: number[];
86
+ /** The interpolated values, one per point of `x`. */
59
87
  y: number[];
60
88
  };
61
- /** Options for {@link splinefun}. */
89
+ /**
90
+ * Options for {@link splinefun}.
91
+ *
92
+ * @category Numerical methods
93
+ */
62
94
  export interface SplinefunOptions {
63
95
  /** `"fmm"` (default), `"natural"`, `"periodic"`, `"monoH.FC"` or `"hyman"`. */
64
96
  method?: SplineMethod | "monoH.FC";
@@ -67,7 +99,7 @@ export interface SplinefunOptions {
67
99
  }
68
100
  /**
69
101
  * The cubic spline through the points, as a function of `x` and the order of derivative (0 to 3; a fraction is
70
- * truncated, as R does). Equivalent to R's `splinefun()`, except that the third derivative of `"monoH.FC"` is the
102
+ * truncated, as R does). Equivalent to R's `splinefun()`. Except that the third derivative of `"monoH.FC"` is the
71
103
  * exact one (see {@link splinefunH}).
72
104
  *
73
105
  * @example
@@ -76,28 +108,47 @@ export interface SplinefunOptions {
76
108
  * s([2.5]); // [6.25]
77
109
  * s([2.5], 1); // [5]
78
110
  * ```
111
+ *
112
+ * @category Numerical methods
79
113
  */
80
114
  export declare function splinefun(x: Sample, y: Sample, options?: SplinefunOptions): (xq: Sample, deriv?: number) => number[];
81
115
  /**
82
116
  * The cubic Hermite spline with values `y` and slopes `m` at the points `x`, as a function of `x` and the order of
83
- * derivative (0 to 3; a fraction is truncated, as R does); linear outside the data. Equivalent to R's `splinefunH()`,
84
- * except for the third derivative: on [x_i, x_{i+1}] it is the exact (6 m_i + 6 m_{i+1} - 12 delta) / h^2, with
117
+ * derivative (0 to 3; a fraction is truncated, as R does); linear outside the data. Equivalent to R's `splinefunH()`.
118
+ * Except for the third derivative: on [x_i, x_{i+1}] it is the exact (6 m_i + 6 m_{i+1} - 12 delta) / h^2, with
85
119
  * h = x_{i+1} - x_i and delta = (y_{i+1} - y_i) / h, where R divides by h only once (the two agree when h = 1).
86
120
  *
87
121
  * @example
88
122
  * ```ts
89
123
  * splinefunH([0, 2], [0, 0], [1, 1])([1], 3); // [3] (R: 6)
90
124
  * ```
125
+ *
126
+ * @category Numerical methods
91
127
  */
92
128
  export declare function splinefunH(x: Sample, y: Sample, m: Sample): (xq: Sample, deriv?: number) => number[];
93
129
  /**
94
- * Lagrange interpolation in barycentric form through the points (xi, yi). Equivalent to `pracma::barylag()`; the
95
- * points must lie within the range of the nodes.
130
+ * Lagrange interpolation in barycentric form through the points (xi, yi). Equivalent to `pracma::barylag()` in R.
131
+ * The points must lie within the range of the nodes.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * barylag([0, 1, 2], [1, 3, 7], [0.5, 1.5]); // [1.75, 4.75]
136
+ * ```
137
+ *
138
+ * @category Numerical methods
96
139
  */
97
140
  export declare function barylag(xi: Sample, yi: Sample, x: Sample): number[];
98
141
  /**
99
142
  * The polynomial of degree 2n - 1 through n points with given values and derivatives (global Hermite
100
- * interpolation, jStat's hermite), evaluated at `x`. Computed by divided differences on the doubled nodes.
143
+ * interpolation, jStat's hermite), evaluated at `x`. Not an R function. Neither base R nor the recommended packages
144
+ * have it (for piecewise cubic Hermite interpolation, see {@link splinefunH}). Computed by divided differences on
145
+ * the doubled nodes.
146
+ *
147
+ * @example
148
+ * ```ts
149
+ * hermiteInterp([0, 1], [0, 1], [0, 0], [0.25, 0.5]); // [0.15625, 0.5]
150
+ * ```
151
+ *
152
+ * @category Numerical methods
101
153
  */
102
154
  export declare function hermiteInterp(xi: Sample, yi: Sample, di: Sample, x: Sample): number[];
103
- export {};
@@ -62,6 +62,8 @@ function stepAt(Y, i, f) {
62
62
  * ```ts
63
63
  * approx([1, 2, 3], [10, 20, 40], { xout: [1.5, 2.5] }).y; // [15, 30]
64
64
  * ```
65
+ *
66
+ * @category Numerical methods
65
67
  */
66
68
  export function approx(x, y, options = {}) {
67
69
  const { method = "linear", n = 50, f = 0, rule = 1, ties = "mean" } = options;
@@ -370,6 +372,8 @@ function evalCubic(sp, xq, deriv0) {
370
372
  * ```ts
371
373
  * spline([1, 2, 3, 4], [1, 4, 9, 16], { xout: [2.5] }).y; // [6.25]
372
374
  * ```
375
+ *
376
+ * @category Numerical methods
373
377
  */
374
378
  export function spline(x, y, options = {}) {
375
379
  const { method = "fmm", ties = "mean" } = options;
@@ -389,7 +393,7 @@ export function spline(x, y, options = {}) {
389
393
  }
390
394
  /**
391
395
  * The cubic spline through the points, as a function of `x` and the order of derivative (0 to 3; a fraction is
392
- * truncated, as R does). Equivalent to R's `splinefun()`, except that the third derivative of `"monoH.FC"` is the
396
+ * truncated, as R does). Equivalent to R's `splinefun()`. Except that the third derivative of `"monoH.FC"` is the
393
397
  * exact one (see {@link splinefunH}).
394
398
  *
395
399
  * @example
@@ -398,6 +402,8 @@ export function spline(x, y, options = {}) {
398
402
  * s([2.5]); // [6.25]
399
403
  * s([2.5], 1); // [5]
400
404
  * ```
405
+ *
406
+ * @category Numerical methods
401
407
  */
402
408
  export function splinefun(x, y, options = {}) {
403
409
  const { method = "fmm", ties = "mean" } = options;
@@ -484,14 +490,16 @@ function evalHermite(x, y, m, xq, deriv0) {
484
490
  }
485
491
  /**
486
492
  * The cubic Hermite spline with values `y` and slopes `m` at the points `x`, as a function of `x` and the order of
487
- * derivative (0 to 3; a fraction is truncated, as R does); linear outside the data. Equivalent to R's `splinefunH()`,
488
- * except for the third derivative: on [x_i, x_{i+1}] it is the exact (6 m_i + 6 m_{i+1} - 12 delta) / h^2, with
493
+ * derivative (0 to 3; a fraction is truncated, as R does); linear outside the data. Equivalent to R's `splinefunH()`.
494
+ * Except for the third derivative: on [x_i, x_{i+1}] it is the exact (6 m_i + 6 m_{i+1} - 12 delta) / h^2, with
489
495
  * h = x_{i+1} - x_i and delta = (y_{i+1} - y_i) / h, where R divides by h only once (the two agree when h = 1).
490
496
  *
491
497
  * @example
492
498
  * ```ts
493
499
  * splinefunH([0, 2], [0, 0], [1, 1])([1], 3); // [3] (R: 6)
494
500
  * ```
501
+ *
502
+ * @category Numerical methods
495
503
  */
496
504
  export function splinefunH(x, y, m) {
497
505
  const n = x.length;
@@ -507,8 +515,15 @@ export function splinefunH(x, y, m) {
507
515
  return (xq, deriv = 0) => evalHermite(X, Y, M, xq, deriv);
508
516
  }
509
517
  /**
510
- * Lagrange interpolation in barycentric form through the points (xi, yi). Equivalent to `pracma::barylag()`; the
511
- * points must lie within the range of the nodes.
518
+ * Lagrange interpolation in barycentric form through the points (xi, yi). Equivalent to `pracma::barylag()` in R.
519
+ * The points must lie within the range of the nodes.
520
+ *
521
+ * @example
522
+ * ```ts
523
+ * barylag([0, 1, 2], [1, 3, 7], [0.5, 1.5]); // [1.75, 4.75]
524
+ * ```
525
+ *
526
+ * @category Numerical methods
512
527
  */
513
528
  export function barylag(xi, yi, x) {
514
529
  const X = Array.from(xi);
@@ -546,7 +561,16 @@ export function barylag(xi, yi, x) {
546
561
  }
547
562
  /**
548
563
  * The polynomial of degree 2n - 1 through n points with given values and derivatives (global Hermite
549
- * interpolation, jStat's hermite), evaluated at `x`. Computed by divided differences on the doubled nodes.
564
+ * interpolation, jStat's hermite), evaluated at `x`. Not an R function. Neither base R nor the recommended packages
565
+ * have it (for piecewise cubic Hermite interpolation, see {@link splinefunH}). Computed by divided differences on
566
+ * the doubled nodes.
567
+ *
568
+ * @example
569
+ * ```ts
570
+ * hermiteInterp([0, 1], [0, 1], [0, 0], [0.25, 0.5]); // [0.15625, 0.5]
571
+ * ```
572
+ *
573
+ * @category Numerical methods
550
574
  */
551
575
  export function hermiteInterp(xi, yi, di, x) {
552
576
  const X = Array.from(xi);
@@ -1,14 +1,22 @@
1
- /** Derivative of the state: `func(t, y, parms)` returns dy/dt (one value per state variable). */
1
+ /**
2
+ * Derivative of the state: `func(t, y, parms)` returns dy/dt (one value per state variable).
3
+ *
4
+ * @category Numerical methods
5
+ */
2
6
  export type OdeFunc = (t: number, y: number[], parms: number[]) => readonly number[];
3
- /** Options for {@link ode}. */
7
+ /**
8
+ * Options for {@link ode}.
9
+ *
10
+ * @category Numerical methods
11
+ */
4
12
  export interface OdeOptions {
5
13
  /** `"euler"`, `"rk2"` (Heun) or `"rk4"` (classical Runge-Kutta, default). */
6
14
  method?: "euler" | "rk2" | "rk4";
7
15
  }
8
16
  /**
9
17
  * Solve the initial value problem y' = func(t, y, parms), y(times[0]) = y, with one fixed step per interval of
10
- * `times`. Equivalent to `deSolve::ode(y, times, func, parms, method)` for `"euler"` and `"rk4"`; for `"rk2"`, to
11
- * `deSolve::ode(..., method = rkMethod("rk2"))` (or `deSolve::rk(..., method = "rk2")`), since deSolve's `ode()`
18
+ * `times`. Equivalent to `deSolve::ode(y, times, func, parms, method)` in R. That is for `"euler"` and `"rk4"`; for
19
+ * `"rk2"`, it is `deSolve::ode(..., method = rkMethod("rk2"))` (or `deSolve::rk(..., method = "rk2")`), since deSolve's `ode()`
12
20
  * does not accept `method = "rk2"`.
13
21
  *
14
22
  * @returns One row per time: `[t, y1, y2, ...]`.
@@ -17,7 +25,9 @@ export interface OdeOptions {
17
25
  * ```ts
18
26
  * // exponential decay y' = -0.7 y
19
27
  * const out = ode([1], [0, 0.5, 1], (t, y, p) => [-p[0]! * y[0]!], [0.7], { method: "rk4" });
20
- * out[2]; // [1, 0.4965...]
28
+ * out[2]; // [1, 0.49664] (exp(-0.7) = 0.49659)
21
29
  * ```
30
+ *
31
+ * @category Numerical methods
22
32
  */
23
33
  export declare function ode(y: readonly number[], times: readonly number[], func: OdeFunc, parms?: readonly number[], options?: OdeOptions): number[][];