@ac-kit/math-stats 0.5.0 → 0.7.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 (165) hide show
  1. package/CHANGELOG.md +205 -0
  2. package/README.md +86 -6
  3. package/dist/_digamma.d.ts +10 -0
  4. package/dist/_digamma.d.ts.map +1 -0
  5. package/dist/_digamma.js +38 -0
  6. package/dist/_digamma.js.map +1 -0
  7. package/dist/_dilogarithm.d.ts +14 -0
  8. package/dist/_dilogarithm.d.ts.map +1 -0
  9. package/dist/_dilogarithm.js +77 -0
  10. package/dist/_dilogarithm.js.map +1 -0
  11. package/dist/_histogram-rules.d.ts +15 -0
  12. package/dist/_histogram-rules.d.ts.map +1 -0
  13. package/dist/_histogram-rules.js +208 -0
  14. package/dist/_histogram-rules.js.map +1 -0
  15. package/dist/_incomplete-gamma-shape-derivative.d.ts +17 -0
  16. package/dist/_incomplete-gamma-shape-derivative.d.ts.map +1 -0
  17. package/dist/_incomplete-gamma-shape-derivative.js +90 -0
  18. package/dist/_incomplete-gamma-shape-derivative.js.map +1 -0
  19. package/dist/_logistic.d.ts +14 -0
  20. package/dist/_logistic.d.ts.map +1 -0
  21. package/dist/_logistic.js +29 -0
  22. package/dist/_logistic.js.map +1 -0
  23. package/dist/_normal-tail.d.ts +43 -0
  24. package/dist/_normal-tail.d.ts.map +1 -0
  25. package/dist/_normal-tail.js +124 -0
  26. package/dist/_normal-tail.js.map +1 -0
  27. package/dist/_rank-test.d.ts +71 -0
  28. package/dist/_rank-test.d.ts.map +1 -0
  29. package/dist/_rank-test.js +130 -0
  30. package/dist/_rank-test.js.map +1 -0
  31. package/dist/average.js +2 -2
  32. package/dist/average.js.map +1 -1
  33. package/dist/bootstrap.d.ts +67 -0
  34. package/dist/bootstrap.d.ts.map +1 -0
  35. package/dist/bootstrap.js +154 -0
  36. package/dist/bootstrap.js.map +1 -0
  37. package/dist/censored-logistic-distribution.d.ts +23 -0
  38. package/dist/censored-logistic-distribution.d.ts.map +1 -0
  39. package/dist/censored-logistic-distribution.js +63 -0
  40. package/dist/censored-logistic-distribution.js.map +1 -0
  41. package/dist/censored-shifted-gamma-distribution.d.ts +23 -0
  42. package/dist/censored-shifted-gamma-distribution.d.ts.map +1 -0
  43. package/dist/censored-shifted-gamma-distribution.js +73 -0
  44. package/dist/censored-shifted-gamma-distribution.js.map +1 -0
  45. package/dist/confidence-interval.d.ts +53 -0
  46. package/dist/confidence-interval.d.ts.map +1 -1
  47. package/dist/confidence-interval.js +73 -0
  48. package/dist/confidence-interval.js.map +1 -1
  49. package/dist/correlation.d.ts +41 -0
  50. package/dist/correlation.d.ts.map +1 -1
  51. package/dist/correlation.js +168 -2
  52. package/dist/correlation.js.map +1 -1
  53. package/dist/descriptive.d.ts +129 -0
  54. package/dist/descriptive.d.ts.map +1 -0
  55. package/dist/descriptive.js +289 -0
  56. package/dist/descriptive.js.map +1 -0
  57. package/dist/forecast/_forecast-checks.d.ts +30 -0
  58. package/dist/forecast/_forecast-checks.d.ts.map +1 -0
  59. package/dist/forecast/_forecast-checks.js +119 -0
  60. package/dist/forecast/_forecast-checks.js.map +1 -0
  61. package/dist/forecast/_score-kernels.d.ts +63 -0
  62. package/dist/forecast/_score-kernels.d.ts.map +1 -0
  63. package/dist/forecast/_score-kernels.js +264 -0
  64. package/dist/forecast/_score-kernels.js.map +1 -0
  65. package/dist/forecast/brier-score.d.ts +102 -0
  66. package/dist/forecast/brier-score.d.ts.map +1 -0
  67. package/dist/forecast/brier-score.js +163 -0
  68. package/dist/forecast/brier-score.js.map +1 -0
  69. package/dist/forecast/crps-closed-form.d.ts +64 -0
  70. package/dist/forecast/crps-closed-form.d.ts.map +1 -0
  71. package/dist/forecast/crps-closed-form.js +106 -0
  72. package/dist/forecast/crps-closed-form.js.map +1 -0
  73. package/dist/forecast/crps-ensemble.d.ts +53 -0
  74. package/dist/forecast/crps-ensemble.d.ts.map +1 -0
  75. package/dist/forecast/crps-ensemble.js +121 -0
  76. package/dist/forecast/crps-ensemble.js.map +1 -0
  77. package/dist/forecast/emos.d.ts +158 -0
  78. package/dist/forecast/emos.d.ts.map +1 -0
  79. package/dist/forecast/emos.js +397 -0
  80. package/dist/forecast/emos.js.map +1 -0
  81. package/dist/forecast/exceedance-probability.d.ts +54 -0
  82. package/dist/forecast/exceedance-probability.d.ts.map +1 -0
  83. package/dist/forecast/exceedance-probability.js +125 -0
  84. package/dist/forecast/exceedance-probability.js.map +1 -0
  85. package/dist/forecast/log-score.d.ts +18 -0
  86. package/dist/forecast/log-score.d.ts.map +1 -0
  87. package/dist/forecast/log-score.js +19 -0
  88. package/dist/forecast/log-score.js.map +1 -0
  89. package/dist/forecast/logistic-regression.d.ts +123 -0
  90. package/dist/forecast/logistic-regression.d.ts.map +1 -0
  91. package/dist/forecast/logistic-regression.js +282 -0
  92. package/dist/forecast/logistic-regression.js.map +1 -0
  93. package/dist/forecast/rank-histogram.d.ts +32 -0
  94. package/dist/forecast/rank-histogram.d.ts.map +1 -0
  95. package/dist/forecast/rank-histogram.js +63 -0
  96. package/dist/forecast/rank-histogram.js.map +1 -0
  97. package/dist/forecast/reliability-diagram.d.ts +70 -0
  98. package/dist/forecast/reliability-diagram.d.ts.map +1 -0
  99. package/dist/forecast/reliability-diagram.js +126 -0
  100. package/dist/forecast/reliability-diagram.js.map +1 -0
  101. package/dist/forecast/roc-curve.d.ts +58 -0
  102. package/dist/forecast/roc-curve.d.ts.map +1 -0
  103. package/dist/forecast/roc-curve.js +124 -0
  104. package/dist/forecast/roc-curve.js.map +1 -0
  105. package/dist/hierarchical-cluster.d.ts.map +1 -1
  106. package/dist/hierarchical-cluster.js +10 -5
  107. package/dist/hierarchical-cluster.js.map +1 -1
  108. package/dist/histogram-edges.d.ts +92 -0
  109. package/dist/histogram-edges.d.ts.map +1 -0
  110. package/dist/histogram-edges.js +325 -0
  111. package/dist/histogram-edges.js.map +1 -0
  112. package/dist/histogram.d.ts +55 -21
  113. package/dist/histogram.d.ts.map +1 -1
  114. package/dist/histogram.js +56 -83
  115. package/dist/histogram.js.map +1 -1
  116. package/dist/index.d.ts +23 -0
  117. package/dist/index.d.ts.map +1 -1
  118. package/dist/index.js +23 -0
  119. package/dist/index.js.map +1 -1
  120. package/dist/kmeans.d.ts.map +1 -1
  121. package/dist/kmeans.js +11 -6
  122. package/dist/kmeans.js.map +1 -1
  123. package/dist/kmedoids.js +2 -1
  124. package/dist/kmedoids.js.map +1 -1
  125. package/dist/mann-whitney-u.d.ts +27 -0
  126. package/dist/mann-whitney-u.d.ts.map +1 -0
  127. package/dist/mann-whitney-u.js +94 -0
  128. package/dist/mann-whitney-u.js.map +1 -0
  129. package/dist/multiple-regression.d.ts +123 -0
  130. package/dist/multiple-regression.d.ts.map +1 -0
  131. package/dist/multiple-regression.js +208 -0
  132. package/dist/multiple-regression.js.map +1 -0
  133. package/dist/principal-components.d.ts +66 -0
  134. package/dist/principal-components.d.ts.map +1 -0
  135. package/dist/principal-components.js +105 -0
  136. package/dist/principal-components.js.map +1 -0
  137. package/dist/quantile.d.ts +113 -5
  138. package/dist/quantile.d.ts.map +1 -1
  139. package/dist/quantile.js +318 -19
  140. package/dist/quantile.js.map +1 -1
  141. package/dist/regression.d.ts +46 -0
  142. package/dist/regression.d.ts.map +1 -1
  143. package/dist/regression.js +99 -1
  144. package/dist/regression.js.map +1 -1
  145. package/dist/running-statistics.d.ts +103 -0
  146. package/dist/running-statistics.d.ts.map +1 -0
  147. package/dist/running-statistics.js +283 -0
  148. package/dist/running-statistics.js.map +1 -0
  149. package/dist/sample.d.ts +29 -0
  150. package/dist/sample.d.ts.map +1 -0
  151. package/dist/sample.js +39 -0
  152. package/dist/sample.js.map +1 -0
  153. package/dist/t-digest.d.ts +136 -0
  154. package/dist/t-digest.d.ts.map +1 -0
  155. package/dist/t-digest.js +424 -0
  156. package/dist/t-digest.js.map +1 -0
  157. package/dist/truncated-normal-distribution.d.ts +28 -0
  158. package/dist/truncated-normal-distribution.d.ts.map +1 -0
  159. package/dist/truncated-normal-distribution.js +198 -0
  160. package/dist/truncated-normal-distribution.js.map +1 -0
  161. package/dist/wilcoxon-signed-rank.d.ts +42 -0
  162. package/dist/wilcoxon-signed-rank.d.ts.map +1 -0
  163. package/dist/wilcoxon-signed-rank.js +117 -0
  164. package/dist/wilcoxon-signed-rank.js.map +1 -0
  165. package/package.json +14 -10
package/CHANGELOG.md CHANGED
@@ -1,5 +1,210 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5c203e7: New descriptive statistics, accumulated exactly: `interquartileRange`,
8
+ `covariance`, `covarianceMatrix` (a `@ac-kit/math-linear` `Matrix`),
9
+ `rSquared`, `rootMeanSquareError`, `weightedMean`, `weightedVariance` and
10
+ `weightedStandardDeviation` (frequency or reliability weights), `standardize`,
11
+ `normalize`, `movingAverage`, `exponentialSmoothing` and the streaming
12
+ `ExponentialMovingAverage` (from `alpha` or a `halfLife`).
13
+ - 5c203e7: Calibration and verification of probabilistic forecasts, and three predictive
14
+ laws. `@ac-kit/math-stats` now depends on `@ac-kit/math-linear`.
15
+
16
+ - `exceedanceProbability(members, threshold, { weights, inclusive,
17
+ plottingPosition })`: the weighted share of ensemble members beyond the
18
+ threshold, or the probability through plotting positions (`"weibull"`,
19
+ `"blom"`, `"cunnane"`, `"gringorten"`, `"tukey"`, `"hazen"` or a constant in
20
+ `[0, ½]`), never `0` or `1` beyond the members. `NaN` members are missing.
21
+ - `logisticRegression(design: Matrix, outcomes, { weights, offset, penalty:
22
+ "none" | "ridge" | "firth", ridge, unpenalized, tolerance, maxIterations,
23
+ signal })`: binary or proportion outcomes by IRLS over a pivoted QR; returns
24
+ the coefficients (`0` for an aliased column), covariance, standard errors,
25
+ fitted probabilities, deviance, log likelihood, penalised log likelihood,
26
+ rank, iterations, `converged` and `separated`. Matches statsmodels' GLM
27
+ without a penalty.
28
+ - `emosFit({ location, scale }, observations, { family, criterion, scaleLink,
29
+ bound, weights, shift, start, tolerance, maxIterations, signal })`: ensemble
30
+ model output statistics for `"normal"`, `"truncated-normal"`,
31
+ `"censored-logistic"` and `"censored-shifted-gamma"` laws, by minimum CRPS or
32
+ maximum likelihood, the scale through `"variance"` (`c + d·S²`) or `"log"`
33
+ links; `start` restarts from a previous model. `emosPredict(model, location,
34
+ scale)` returns the predictive `Distribution`.
35
+ - `brierScore`, `brierSkillScore` (against the sample climatology, a fixed
36
+ probability or reference forecasts), `brierScoreDecomposition` (reliability,
37
+ resolution, uncertainty and Stephenson's within-bin terms, adding up to the
38
+ score exactly), `reliabilityDiagram` (columnar, Bröcker–Smith consistency
39
+ bars from a `RandomFn`), `rankHistogram(members: Matrix, observations)`
40
+ (ties ranked at random), `rocCurve` (columnar, at every forecast value or
41
+ given `thresholds`, with its Mann–Whitney area).
42
+ - `crpsEnsemble(members, observation, { estimator: "nrg" | "fair" | "pwm",
43
+ weights, sorted })`, which allocates no buffer per call; closed-form
44
+ `crpsNormal`, `crpsTruncatedNormal`, `crpsCensoredLogistic`,
45
+ `crpsCensoredShiftedGamma`; `logScore(distribution, observation)`, the point
46
+ mass at a censoring bound.
47
+ - `truncatedNormalDistribution(mean, standardDeviation, lower, upper)`,
48
+ accurate hundreds of standard deviations into a tail;
49
+ `censoredLogisticDistribution(location, scale, lower)` and
50
+ `censoredShiftedGammaDistribution(shape, scale, shift, lower)`, whose
51
+ `density` at the bound is the point mass there.
52
+
53
+ Every score throws a `RangeError` for mismatched lengths, probabilities or
54
+ outcomes outside `[0, 1]`, and invalid weights.
55
+ - 5c203e7: - `quantile(sorted, fraction, { method, from, to })` and `writeQuantile` take
56
+ a `method` (`QuantileMethod`): the nine Hyndman–Fan estimators under
57
+ NumPy's names (`"inverted-cdf"` … `"normal-unbiased"`) and NumPy's
58
+ `"lower"`, `"higher"`, `"nearest"` and `"midpoint"`; `"linear"` (type 7)
59
+ stays the default and the positional `from, to` form is unchanged.
60
+ - `sampleQuantile(values, fraction, { method })` takes the sample in any order
61
+ (O(n) selection) and `sampleQuantiles(values, fractions, { method })`
62
+ several fractions in one sort; a `NaN` in the sample gives `NaN`.
63
+ - `multipleRegression(design: Matrix, y, { weights, rankTolerance })`:
64
+ ordinary or weighted least squares over `@ac-kit/math-linear`'s pivoted
65
+ `QrDecomposition`, with coefficients, covariance, standard errors, t tests,
66
+ R² (uncentred without a constant column), adjusted R², the overall F test,
67
+ fitted values, residuals, leverages, log likelihood, AIC and BIC; aliased
68
+ columns get a `0` coefficient and `NaN` statistics. Matches statsmodels'
69
+ `OLS` and `WLS`.
70
+ - `linearRegression(x, y, { weights, rankTolerance })`: the least-squares
71
+ line with SciPy's `linregress` inference (`slope`, `intercept`, their
72
+ standard errors, `correlation`) and every `multipleRegression` field,
73
+ accurate for `x` far from the origin.
74
+ - 5c203e7: - `spearmanCorrelation(x, y)` (Pearson's coefficient of average ranks) and
75
+ `kendallTau(x, y)` (τ_b, tie-corrected, O(n log n)), ranking through
76
+ `@ac-kit/algo`'s `rankBy`.
77
+ - `mannWhitneyU(a, b, options)` and `wilcoxonSignedRank(sample, other,
78
+ options)` (paired sample or hypothesised median; `zeroMethod` `"wilcox"`,
79
+ `"pratt"` or `"zsplit"`): one- or two-sided p-values, exact permutation
80
+ distributions conditional on ties and zeros below 50 observations per
81
+ sample, the tie-corrected normal approximation with continuity correction
82
+ otherwise (`method` and `continuity` choose).
83
+ - `bootstrap(values, statistic, options)`: percentile, basic or BCa (default)
84
+ intervals with standard error, bias and the resampled statistics, from an
85
+ injectable `RandomFn`.
86
+ - `confidenceInterval(values, level, options)`: Student's t for the mean,
87
+ order statistics for the median, or the bootstrap for any statistic.
88
+ - `sample(distribution, count, random)` and `sampleInto(out, distribution,
89
+ random)`.
90
+ - `TDigest`: mergeable streaming quantile and CDF estimates (`add`, `merge`,
91
+ `quantile`, `cdf`, `centroids`, `fromCentroids`), k₂ scale by default.
92
+ - `principalComponents(data, options)`: PCA of a `Matrix` through the SVD,
93
+ optionally on standardised variables, with loadings, scores and explained
94
+ variance.
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [5c203e7]
99
+ - Updated dependencies [5c203e7]
100
+ - Updated dependencies [5c203e7]
101
+ - Updated dependencies [5c203e7]
102
+ - Updated dependencies [5c203e7]
103
+ - Updated dependencies [5c203e7]
104
+ - Updated dependencies [5c203e7]
105
+ - Updated dependencies [5c203e7]
106
+ - Updated dependencies [5c203e7]
107
+ - Updated dependencies [5c203e7]
108
+ - Updated dependencies [5c203e7]
109
+ - Updated dependencies [5c203e7]
110
+ - Updated dependencies [5c203e7]
111
+ - Updated dependencies [5c203e7]
112
+ - Updated dependencies [5c203e7]
113
+ - Updated dependencies [5c203e7]
114
+ - Updated dependencies [5c203e7]
115
+ - Updated dependencies [5c203e7]
116
+ - Updated dependencies [5c203e7]
117
+ - Updated dependencies [5c203e7]
118
+ - @ac-kit/algo@0.7.0
119
+ - @ac-kit/core@0.14.0
120
+ - @ac-kit/data@0.6.0
121
+ - @ac-kit/math-analysis@0.3.0
122
+ - @ac-kit/math-linear@0.5.0
123
+ - @ac-kit/math-scalar@0.5.0
124
+ - @ac-kit/math-random@0.4.2
125
+
126
+ ## 0.6.0
127
+
128
+ ### Minor Changes
129
+
130
+ - 0b4fe43: `histogramEdges(values, options)` gives a histogram's bin edges: NumPy's
131
+ `histogram_bin_edges` equal bins from the low end of the range to the high end,
132
+ or with `nice: true` Vega's round edges, on the multiples of a width of 1, 2 or
133
+ 5 times a power of ten. The width comes from a `rule` (default `"auto"`), a
134
+ `width` or a `count`, with at most `maxCount` bins, over `range` or the extent
135
+ of the finite values; `NaN` and ±Infinity are ignored, an empty sample covers
136
+ `[0, 1]`, a single value is widened by a half (by its own magnitude with
137
+ `nice`), and where a rule finds no width though the values spread (a zero
138
+ interquartile range) Sturges' width stands in instead of NumPy's single bin.
139
+ Edges are finite and strictly ascending, at least two around the values (a
140
+ single value under a `nice` width finer than the doubles there gets the value
141
+ and the next double); the last bin is closed.
142
+
143
+ `HistogramBinRule` and `histogramBinWidth` add NumPy's other rules: `"auto"`,
144
+ `"doane"`, `"rice"`, `"sqrt"` and `"stone"`, checked against NumPy 2.5.
145
+ `histogramBinWidth` and `histogram` accept any `ArrayLike<number>` (a typed
146
+ array is read as is), and `histogram(values, edges, { lastClosed: true })`
147
+ counts a value equal to the last edge in the last bin, as `histogramEdges`' bins
148
+ and NumPy's are.
149
+ - 0b4fe43: `RunningStatistics` accumulates the count, mean, variance, minimum and maximum
150
+ of numbers added one at a time (`add`), by range (`addRange`) or by indexed
151
+ range of a column (`addIndexed`), without copying them. `NaN` is ignored. The
152
+ variance is Welford's single-pass update, so a mean far above the spread loses
153
+ no precision, and `merge` combines partitions exactly as if their numbers had
154
+ been added to one accumulator. `sampleVariance` is `NaN` below two numbers,
155
+ where the function of the same name answers `0`. Its getters read each
156
+ statistic; `writeMean`, `writeMin`, `writeMax` and the variance and standard
157
+ deviation writers put it in an output array (a `Float64Array` or a `number[]`)
158
+ instead, without allocating, even once both kinds have been written.
159
+
160
+ `quantile(sorted, fraction, from, to)` reads the sorted range `[from, to)` in
161
+ place, one group's slice of a shared buffer, and throws a `RangeError` for a
162
+ range outside the array. `writeQuantile(target, index, sorted, fraction, from,
163
+ to)` writes the same quantile into `target[index]` without allocating.
164
+
165
+ ### Patch Changes
166
+
167
+ - Updated dependencies [0b4fe43]
168
+ - Updated dependencies [0b4fe43]
169
+ - Updated dependencies [0b4fe43]
170
+ - Updated dependencies [0b4fe43]
171
+ - Updated dependencies [0b4fe43]
172
+ - Updated dependencies [0b4fe43]
173
+ - Updated dependencies [0b4fe43]
174
+ - Updated dependencies [0b4fe43]
175
+ - Updated dependencies [0b4fe43]
176
+ - Updated dependencies [0b4fe43]
177
+ - Updated dependencies [0b4fe43]
178
+ - Updated dependencies [0b4fe43]
179
+ - Updated dependencies [0b4fe43]
180
+ - Updated dependencies [0b4fe43]
181
+ - Updated dependencies [0b4fe43]
182
+ - Updated dependencies [0b4fe43]
183
+ - Updated dependencies [0b4fe43]
184
+ - Updated dependencies [0b4fe43]
185
+ - Updated dependencies [0b4fe43]
186
+ - Updated dependencies [0b4fe43]
187
+ - Updated dependencies [0b4fe43]
188
+ - Updated dependencies [0b4fe43]
189
+ - Updated dependencies [0b4fe43]
190
+ - Updated dependencies [0b4fe43]
191
+ - Updated dependencies [0b4fe43]
192
+ - Updated dependencies [0b4fe43]
193
+ - Updated dependencies [0b4fe43]
194
+ - Updated dependencies [0b4fe43]
195
+ - Updated dependencies [0b4fe43]
196
+ - Updated dependencies [0b4fe43]
197
+ - Updated dependencies [0b4fe43]
198
+ - Updated dependencies [0b4fe43]
199
+ - Updated dependencies [0b4fe43]
200
+ - Updated dependencies [0b4fe43]
201
+ - @ac-kit/algo@0.6.0
202
+ - @ac-kit/core@0.13.0
203
+ - @ac-kit/data@0.5.0
204
+ - @ac-kit/math-analysis@0.2.0
205
+ - @ac-kit/math-scalar@0.4.0
206
+ - @ac-kit/math-random@0.4.1
207
+
3
208
  ## 0.5.0
4
209
 
5
210
  ### Minor Changes
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @ac-kit/math-stats
2
2
 
3
- Descriptive statistics, probability distributions and statistical inference over
4
- samples of `number`.
3
+ Descriptive statistics, probability distributions, statistical inference and
4
+ probabilistic-forecast verification over samples of `number`.
5
5
 
6
6
  ## Scope
7
7
 
@@ -17,6 +17,22 @@ distribution parameter, or a model.
17
17
  | `geometricMean(values)` | `n`-th root of the product; for ratios and growth rates |
18
18
  | `harmonicMean(values)` | Reciprocal of the mean of reciprocals; for rates over a fixed distance |
19
19
  | `midrange(values)` | `(min + max) / 2` |
20
+ | `weightedMean`, `weightedVariance`, `weightedStandardDeviation` | Weighted moments, frequency or reliability weights |
21
+ | `interquartileRange(values)` | `Q₃ − Q₁`, type-7 quartiles |
22
+ | `covariance(x, y)`, `covarianceMatrix(columns)` | Sample covariance, and the `k × k` `Matrix` of it |
23
+ | `rSquared`, `rootMeanSquareError` | Goodness of fit of any predictions |
24
+ | `standardize`, `normalize` | z-scores; min–max onto `[0, 1]` |
25
+ | `movingAverage`, `exponentialSmoothing`, `ExponentialMovingAverage` | Trailing mean, exponential smoothing, and its streaming form |
26
+ | `spearmanCorrelation`, `kendallTau` | Rank correlations: Spearman's ρ over average ranks, Kendall's τ_b in O(n log n) |
27
+ | `mannWhitneyU`, `wilcoxonSignedRank` | Rank-sum and signed-rank tests, exact under ties and zeros or asymptotic |
28
+ | `bootstrap(values, statistic, options)` | Percentile, basic or BCa bootstrap interval for any statistic |
29
+ | `confidenceInterval(values, level, options)` | Student's t for the mean, order statistics for the median, the bootstrap for any statistic |
30
+ | `sample`, `sampleInto` | Reproducible draws from a `Distribution` |
31
+ | `TDigest` | Mergeable streaming quantiles, accurate in the tails (k₁, k₂, k₃ scales) |
32
+ | `principalComponents(data, options)` | PCA through the SVD: loadings, scores, explained variance |
33
+ | `quantile(sorted, p, { method })`, `sampleQuantile`, `sampleQuantiles` | Sample quantiles by the nine Hyndman–Fan methods and NumPy's four others; sorted input, or any order by selection |
34
+ | `linearRegression(x, y, options)` | Least-squares line with SciPy's `linregress` and R's `lm` inference: standard errors, t tests, R², residuals |
35
+ | `multipleRegression(design, y, options)` | OLS or WLS over a pivoted QR: coefficients, covariance, t and F tests, adjusted R², leverages, AIC/BIC, aliased columns |
20
36
 
21
37
  ## Which mean
22
38
 
@@ -46,12 +62,14 @@ on its upper one. Infinities land in the outer bins; `NaN` is not counted.
46
62
  import { histogram } from "@ac-kit/math-stats";
47
63
 
48
64
  histogram([-5, 0, 9, 10, 19, 20, 500], [0, 10, 20]); // [1, 2, 2, 2]
65
+ histogram([-5, 0, 9, 10, 19, 20, 500], [0, 10, 20], { lastClosed: true }); // [1, 2, 3, 1]
49
66
  ```
50
67
 
51
- `histogramBinWidth(values, rule)` gives the bin width of a rule of thumb —
52
- `"sturges"`, `"scott"` or `"freedman-diaconis"`, as in NumPy's
53
- `histogram_bin_edges` — over the finite values, or `NaN` for fewer than two of
54
- them or zero spread. O(n), O(n log n) for Freedman–Diaconis.
68
+ `histogramBinWidth(values, rule)` gives the bin width of a rule of thumb, as in
69
+ NumPy's `histogram_bin_edges`: `"auto"` (NumPy's default), `"freedman-diaconis"`,
70
+ `"scott"`, `"sturges"`, `"doane"`, `"rice"`, `"sqrt"` or `"stone"`, over the
71
+ finite values, or `NaN` for fewer than two of them or zero spread. O(n), O(n
72
+ log n) for Freedman–Diaconis and `"auto"`, O(n · max(100, √n)) for Stone.
55
73
 
56
74
  ```ts
57
75
  import { histogramBinWidth } from "@ac-kit/math-stats";
@@ -59,6 +77,23 @@ import { histogramBinWidth } from "@ac-kit/math-stats";
59
77
  histogramBinWidth([1, 2, 3, 4, 5, 6, 7, 8], "sturges"); // 1.75
60
78
  ```
61
79
 
80
+ `histogramEdges(values, options)` gives the edges themselves, from a `rule`
81
+ (default `"auto"`), a `width` or a `count`, at most `maxCount` bins, over
82
+ `range` or the extent of the finite values. By default they are NumPy's equal
83
+ bins from the low end to the high end; `nice: true` puts them on the multiples
84
+ of a 1, 2 or 5 width instead, as Vega's `bin` does. `NaN` and the infinities
85
+ are ignored, an empty sample covers `[0, 1]`, a single value is widened, and
86
+ where a rule finds no width (a zero interquartile range) Sturges' stands in.
87
+ Its last bin is closed, as `histogram` counts with `lastClosed`.
88
+
89
+ ```ts
90
+ import { histogram, histogramEdges } from "@ac-kit/math-stats";
91
+
92
+ const values = [0.13, 4.2, 9.7, 5];
93
+ const edges = histogramEdges(values, { count: 4, nice: true }); // [0, 5, 10]
94
+ histogram(values, edges, { lastClosed: true }); // [0, 2, 2, 0]
95
+ ```
96
+
62
97
  ## Two groups in a sample
63
98
 
64
99
  `hartiganDip(sorted)` is Hartigan's dip: how far the sample's distribution
@@ -111,6 +146,26 @@ recent.push(sample);
111
146
  const threshold = recent.median() * 1.5;
112
147
  ```
113
148
 
149
+ ## Running statistics
150
+
151
+ `RunningStatistics` keeps the count, mean, variance, minimum and maximum of
152
+ numbers added one at a time, or by range of a column, without copying them. It
153
+ uses Welford's update, so a mean far above the spread (`1e9 + 0.1`) loses
154
+ nothing, and partitions `merge` as if added to one accumulator.
155
+
156
+ ```ts
157
+ import { RunningStatistics } from "@ac-kit/math-stats";
158
+
159
+ const group = new RunningStatistics().addIndexed(column, rows, from, to);
160
+ group.sampleStandardDeviation;
161
+ ```
162
+
163
+ Its `write…` methods put a statistic in an output array rather than returning
164
+ it, as `writeQuantile(target, index, sorted, fraction, from, to)` does for
165
+ `quantile`: a double returned by a call the engine does not inline is boxed,
166
+ one written to an array is not, so a column of per-group results fills without
167
+ allocating.
168
+
114
169
  ## Distributions
115
170
 
116
171
  Every family is a factory returning a `Distribution` — `density`, `cdf`,
@@ -123,6 +178,8 @@ Every family is a factory returning a `Distribution` — `density`, `cdf`,
123
178
  | `gammaDistribution`, `chiSquaredDistribution` | `geometricDistribution` |
124
179
  | `studentTDistribution`, `betaDistribution` | `negativeBinomialDistribution` |
125
180
  | `fDistribution` | `hypergeometricDistribution` |
181
+ | `truncatedNormalDistribution` | |
182
+ | `censoredLogisticDistribution`, `censoredShiftedGammaDistribution` (with a point mass at the bound) | |
126
183
 
127
184
  **`survival` is not a convenience over `1 - cdf(x)`.** It is the member the rest
128
185
  is built around: a p-value _is_ an upper tail, and `1 - cdf(x)` is exactly `0`
@@ -167,6 +224,29 @@ to five groups, a nominal 95 % interval holds the true value 97–100 % of the
167
224
  time. Near-nominal coverage is reached with heterogeneous groups from about
168
225
  nine up.
169
226
 
227
+ ## Probabilistic forecasts
228
+
229
+ Calibration and verification of ensemble and probability forecasts
230
+ (`src/forecast/`).
231
+
232
+ | Symbol | Description |
233
+ | --- | --- |
234
+ | `exceedanceProbability(members, threshold, options)` | `P(X > t)` of an ensemble: the share of members, or through plotting positions (Weibull, Tukey, Gringorten, Hazen, …), weighted members, `inclusive` |
235
+ | `logisticRegression(design, outcomes, options)` | IRLS over a pivoted QR: weights, offset, no penalty, ridge or Firth's; coefficients, covariance, deviance, `converged`, `separated` |
236
+ | `emosFit(predictors, observations, options)`, `emosPredict(model, location, scale)` | Ensemble model output statistics: normal, truncated normal, censored logistic or censored shifted gamma, by minimum CRPS or log score (BFGS on analytic gradients), warm start from yesterday's model |
237
+ | `brierScore`, `brierSkillScore`, `brierScoreDecomposition` | The score, its skill against climatology or a reference, and its exact decomposition (Murphy plus Stephenson's within-bin terms) |
238
+ | `reliabilityDiagram(probabilities, outcomes, options)` | Columnar diagram with Bröcker–Smith consistency bars from a seeded `RandomFn` |
239
+ | `rankHistogram(members, observations, options)` | Talagrand histogram, ties ranked at random |
240
+ | `crpsEnsemble(members, observation, { estimator })` | CRPS of an ensemble: `"nrg"`, `"fair"` or `"pwm"`, weighted |
241
+ | `crpsNormal`, `crpsTruncatedNormal`, `crpsCensoredLogistic`, `crpsCensoredShiftedGamma` | Closed-form CRPS of each EMOS family |
242
+ | `logScore(distribution, observation)` | `−ln f(y)`, the point mass at a censoring bound |
243
+ | `rocCurve(probabilities, outcomes, options)` | Columnar ROC curve at every forecast value or given thresholds, with its Mann–Whitney area |
244
+
245
+ Every score takes case weights and throws a `RangeError` for mismatched lengths
246
+ or probabilities outside `[0, 1]`. The oracles (statsmodels, properscoring,
247
+ SciPy, mpmath) are recorded in `src/forecast/__fixtures__/` by
248
+ `scripts/record-forecast-oracles.py`.
249
+
170
250
  ## Usage
171
251
 
172
252
  ```ts
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The digamma function `ψ(x) = Γ′(x) / Γ(x)` for `x > 0`: the recurrence `ψ(x)
3
+ * = ψ(x + 1) − 1/x` up to `x ≥ 10`, then the asymptotic series `ln x − 1/(2x) −
4
+ * Σ B₂ₙ / (2n·x²ⁿ)` to seven terms, whose truncation error there is below
5
+ * `2⁻⁵³`. Absolute error a few ulps of `max(1, |ψ(x)|)`.
6
+ *
7
+ * @returns `ψ(x)`; `NaN` for `x ≤ 0` or `NaN`, `+∞` at `+∞`.
8
+ */
9
+ export declare function digamma_(x: number): number;
10
+ //# sourceMappingURL=_digamma.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_digamma.d.ts","sourceRoot":"","sources":["../src/_digamma.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAiC1C"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The digamma function `ψ(x) = Γ′(x) / Γ(x)` for `x > 0`: the recurrence `ψ(x)
3
+ * = ψ(x + 1) − 1/x` up to `x ≥ 10`, then the asymptotic series `ln x − 1/(2x) −
4
+ * Σ B₂ₙ / (2n·x²ⁿ)` to seven terms, whose truncation error there is below
5
+ * `2⁻⁵³`. Absolute error a few ulps of `max(1, |ψ(x)|)`.
6
+ *
7
+ * @returns `ψ(x)`; `NaN` for `x ≤ 0` or `NaN`, `+∞` at `+∞`.
8
+ */
9
+ export function digamma_(x) {
10
+ if (!(x > 0)) {
11
+ return Number.NaN;
12
+ }
13
+ if (x === Number.POSITIVE_INFINITY) {
14
+ return x;
15
+ }
16
+ let shift = 0;
17
+ let value = x;
18
+ while (value < 10) {
19
+ shift += 1 / value;
20
+ value += 1;
21
+ }
22
+ const inverse = 1 / value;
23
+ const inverseSquare = inverse * inverse;
24
+ // Bernoulli numbers B₂ₙ / 2n, n = 1 … 7, by Horner in 1/x².
25
+ const series = inverseSquare *
26
+ (1 / 12 -
27
+ inverseSquare *
28
+ (1 / 120 -
29
+ inverseSquare *
30
+ (1 / 252 -
31
+ inverseSquare *
32
+ (1 / 240 -
33
+ inverseSquare *
34
+ (1 / 132 -
35
+ inverseSquare * (691 / 32760 - inverseSquare / 12))))));
36
+ return Math.log(value) - 0.5 * inverse - series - shift;
37
+ }
38
+ //# sourceMappingURL=_digamma.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_digamma.js","sourceRoot":"","sources":["../src/_digamma.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAS;IACjC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACd,OAAO,MAAM,CAAC,GAAG,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,KAAK,MAAM,CAAC,iBAAiB,EAAE,CAAC;QACpC,OAAO,CAAC,CAAC;IACV,CAAC;IAED,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,EAAE,EAAE,CAAC;QACnB,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC;QACnB,KAAK,IAAI,CAAC,CAAC;IACZ,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC;IAC1B,MAAM,aAAa,GAAG,OAAO,GAAG,OAAO,CAAC;IACxC,4DAA4D;IAC5D,MAAM,MAAM,GACX,aAAa;QACb,CAAC,CAAC,GAAG,EAAE;YACN,aAAa;gBACZ,CAAC,CAAC,GAAG,GAAG;oBACP,aAAa;wBACZ,CAAC,CAAC,GAAG,GAAG;4BACP,aAAa;gCACZ,CAAC,CAAC,GAAG,GAAG;oCACP,aAAa;wCACZ,CAAC,CAAC,GAAG,GAAG;4CACP,aAAa,GAAG,CAAC,GAAG,GAAG,KAAM,GAAG,aAAa,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEnE,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AACzD,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The dilogarithm `Li₂(x) = −∫₀ˣ ln(1 − t)/t dt` for real `x ≤ 1`, reduced to
3
+ * `|x| ≤ ½` by the inversion and Landen identities ('t Hooft and Veltman 1979).
4
+ * Absolute error a few ulps of `max(1, |Li₂(x)|)`.
5
+ */
6
+ export declare function dilogarithm_(x: number): number;
7
+ /**
8
+ * The complete Fermi–Dirac integral of order one, `F₁(c) = ∫₀^∞ t / (1 + eᵗ⁻ᶜ)
9
+ * dt = −Li₂(−eᶜ)`: the second partial moment of the logistic distribution.
10
+ * Positive, `≈ eᶜ` far below zero and `≈ c²/2 + π²/6` far above, without
11
+ * overflow on either side.
12
+ */
13
+ export declare function fermiDirac1_(c: number): number;
14
+ //# sourceMappingURL=_dilogarithm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dilogarithm.d.ts","sourceRoot":"","sources":["../src/_dilogarithm.ts"],"names":[],"mappings":"AAmCA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CA8B9C;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAS9C"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Coefficients `Bₙ / (n + 1)!` of `Li₂(x) = Σ Bₙ·uⁿ⁺¹ / (n + 1)!`, `u = −ln(1 −
3
+ * x)`, for n = 0, 1, 2, 4, …, 18 (the odd Bernoulli numbers past B₁ vanish).
4
+ * With `|x| ≤ ½`, `|u| ≤ ln 2` and the next term is below 10⁻²⁰.
5
+ */
6
+ const BERNOULLI_ = [
7
+ 1,
8
+ -0.25,
9
+ 1 / 36,
10
+ -1 / 3600,
11
+ 1 / 211680,
12
+ -1 / 10886400,
13
+ 1 / 526901760,
14
+ -4.064761645144226e-11,
15
+ 8.921691020456453e-13,
16
+ -1.993929586072108e-14,
17
+ 4.518980029619919e-16,
18
+ ];
19
+ const PI_SQUARED_OVER_SIX_ = (Math.PI * Math.PI) / 6;
20
+ /** `Li₂(x)` for `|x| ≤ ½`, by the Bernoulli series in `−ln(1 − x)`. */
21
+ function dilogarithmSmall_(x) {
22
+ const u = -Math.log1p(-x);
23
+ const uSquare = u * u;
24
+ // Terms n = 0 and 1 are u and −u²/4; the even ones follow in u².
25
+ let sum = 0;
26
+ for (let index = BERNOULLI_.length - 1; index >= 2; index--) {
27
+ sum = sum * uSquare + BERNOULLI_[index];
28
+ }
29
+ return u + uSquare * (-0.25 + u * sum);
30
+ }
31
+ /**
32
+ * The dilogarithm `Li₂(x) = −∫₀ˣ ln(1 − t)/t dt` for real `x ≤ 1`, reduced to
33
+ * `|x| ≤ ½` by the inversion and Landen identities ('t Hooft and Veltman 1979).
34
+ * Absolute error a few ulps of `max(1, |Li₂(x)|)`.
35
+ */
36
+ export function dilogarithm_(x) {
37
+ if (x !== x || x > 1) {
38
+ return Number.NaN;
39
+ }
40
+ if (x === 1) {
41
+ return PI_SQUARED_OVER_SIX_;
42
+ }
43
+ if (x < -1) {
44
+ // Li₂(x) = −π²/6 − ½ ln²(−x) − Li₂(1/x).
45
+ const logarithm = Math.log(-x);
46
+ return (-PI_SQUARED_OVER_SIX_ - 0.5 * logarithm * logarithm - dilogarithm_(1 / x));
47
+ }
48
+ if (x < -0.5) {
49
+ // Landen: Li₂(x) = −Li₂(x / (x − 1)) − ½ ln²(1 − x), the argument in [⅓, ½].
50
+ const logarithm = Math.log1p(-x);
51
+ return -dilogarithmSmall_(x / (x - 1)) - 0.5 * logarithm * logarithm;
52
+ }
53
+ if (x <= 0.5) {
54
+ return dilogarithmSmall_(x);
55
+ }
56
+ // Euler's reflection: Li₂(x) = π²/6 − ln x · ln(1 − x) − Li₂(1 − x).
57
+ return (PI_SQUARED_OVER_SIX_ -
58
+ Math.log(x) * Math.log1p(-x) -
59
+ dilogarithmSmall_(1 - x));
60
+ }
61
+ /**
62
+ * The complete Fermi–Dirac integral of order one, `F₁(c) = ∫₀^∞ t / (1 + eᵗ⁻ᶜ)
63
+ * dt = −Li₂(−eᶜ)`: the second partial moment of the logistic distribution.
64
+ * Positive, `≈ eᶜ` far below zero and `≈ c²/2 + π²/6` far above, without
65
+ * overflow on either side.
66
+ */
67
+ export function fermiDirac1_(c) {
68
+ if (c !== c) {
69
+ return c;
70
+ }
71
+ if (c <= 0) {
72
+ return -dilogarithm_(-Math.exp(c));
73
+ }
74
+ // −Li₂(−eᶜ) = π²/6 + c²/2 + Li₂(−e⁻ᶜ) by the inversion identity.
75
+ return PI_SQUARED_OVER_SIX_ + 0.5 * c * c + dilogarithm_(-Math.exp(-c));
76
+ }
77
+ //# sourceMappingURL=_dilogarithm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dilogarithm.js","sourceRoot":"","sources":["../src/_dilogarithm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,GAAG;IAClB,CAAC;IACD,CAAC,IAAI;IACL,CAAC,GAAG,EAAE;IACN,CAAC,CAAC,GAAG,IAAI;IACT,CAAC,GAAG,MAAO;IACX,CAAC,CAAC,GAAG,QAAU;IACf,CAAC,GAAG,SAAW;IACf,CAAC,qBAAqB;IACtB,qBAAqB;IACrB,CAAC,qBAAqB;IACtB,qBAAqB;CACrB,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AAErD,uEAAuE;AACvE,SAAS,iBAAiB,CAAC,CAAS;IACnC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1B,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;IACtB,iEAAiE;IACjE,IAAI,GAAG,GAAG,CAAC,CAAC;IAEZ,KAAK,IAAI,KAAK,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7D,GAAG,GAAG,GAAG,GAAG,OAAO,GAAG,UAAU,CAAC,KAAK,CAAE,CAAC;IAC1C,CAAC;IAED,OAAO,CAAC,GAAG,OAAO,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC;AACxC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,CAAS;IACrC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,GAAG,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACb,OAAO,oBAAoB,CAAC;IAC7B,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;QACZ,yCAAyC;QACzC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE/B,OAAO,CACN,CAAC,oBAAoB,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CACzE,CAAC;IACH,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QACd,6EAA6E;QAC7E,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,SAAS,GAAG,SAAS,CAAC;IACtE,CAAC;IACD,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACd,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,qEAAqE;IACrE,OAAO,CACN,oBAAoB;QACpB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC5B,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,CACxB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,CAAS;IACrC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACb,OAAO,CAAC,CAAC;IACV,CAAC;IACD,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACZ,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IACD,iEAAiE;IACjE,OAAO,oBAAoB,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzE,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { HistogramBinRule } from "./histogram.js";
2
+ export declare function differenceOver_(high: number, low: number, divisor: number): number;
3
+ /**
4
+ * Edge `index` of `bins` equal bins over `[low, high]`, as NumPy's `linspace`
5
+ * computes it (`index · step + low`, the last edge `high` itself); a span past
6
+ * `Number.MAX_VALUE` is halved first, exactly.
7
+ */
8
+ export declare function linspaceEdge_(low: number, high: number, bins: number, index: number): number;
9
+ /**
10
+ * The width `rule` gives the values of `values` within `[low, high]` (finite
11
+ * bounds), as NumPy's estimator of that name does, or `NaN` where NumPy's is 0
12
+ * (fewer than two values, no spread) and for an unknown rule.
13
+ */
14
+ export declare function ruleWidth_(values: ArrayLike<number>, rule: HistogramBinRule, low: number, high: number): number;
15
+ //# sourceMappingURL=_histogram-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_histogram-rules.d.ts","sourceRoot":"","sources":["../src/_histogram-rules.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAMvD,wBAAgB,eAAe,CAC9B,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GACb,MAAM,CAMR;AAoCD;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACX,MAAM,CAaR;AAwED;;;;GAIG;AACH,wBAAgB,UAAU,CACzB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACV,MAAM,CA+GR"}