@mark1russell7/rigor-statistics 0.1.19 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -112,7 +112,7 @@ The default expansion has one product for each pair of levels of two dimensions.
112
112
  | `bootstrapTwo(a, b, statistic, options)` | A bootstrap interval of a statistic of two independent samples, for example two arms of a benchmark. Each run draws all of `a`, then all of `b`. |
113
113
  | `bootstrapMedianRatio(numerator, denominator, options)` | The interval of `median(numerator) / median(denominator)`. It is the uncertainty of the ratio, not the spread of the samples. |
114
114
  | `sampleTotalInterval(values, { population, scale })` | The interval of the total of a population from a uniform sample of `m` of its `n` items without replacement. The deviations get the finite population correction `sqrt(1 - m / n)`. `scale` is `n / m` by default. When `m` is `n`, the interval is the estimate. For a small `m`, the interval is too narrow: at `m = 8` of `n = 40`, the coverage is 0.865. For a total over pairs, use `uStatisticInterval`. |
115
- | `uStatisticInterval(totals, { order, population, method, level, range })` | The interval of a total over all sets of `r` units of a population, for example the crossings of all pairs. The input is the total of each unit of a sample without replacement. The estimate is `S * C(n, r) / C(m, r)`. The method `"conservative"` uses the Hoeffding bound of a U-statistic with `floor(m / r)` draws and the `range` of the kernel. It holds at each `m`. The method `"tight"` uses the jackknife variance times `1 - m / n`, and the t quantile with `m - 1` degrees of freedom. This variance is exact for a linear kernel and larger for others. When all the totals are equal, the method `"tight"` uses the method `"conservative"`, or it throws without `range`. The result gives the `method` that it used. At `m = 8`, the coverage of `"tight"` is 0.885 to 0.915 for a skewed kernel. The method `"auto"` needs `range`. It uses `"tight"` from `m = U_STATISTIC_TIGHT_MIN_SAMPLE`. No measured `m` gets 0.95 in each cell, so this constant is infinite. |
115
+ | `uStatisticInterval(totals, { order, population, method, level, range })` | The interval of a total over all sets of `r` units of a population, for example the crossings of all pairs. The input is the total of each unit of a sample without replacement. The estimate is `S * C(n, r) / C(m, r)`. The method `"conservative"` uses the Hoeffding bound of a U-statistic with `floor(m / r)` draws and the `range` of the kernel. It holds at each `m`. The method `"tight"` uses the jackknife variance times `1 - m / n`, and the t quantile with `m - 1` degrees of freedom. This variance is exact for a linear kernel and larger for others. When all the totals are equal, the method `"tight"` uses the method `"conservative"`, or it throws without `range`. The result gives the `method` that it used. At `m = 8`, the coverage of `"tight"` is 0.885 to 0.915 for a skewed kernel. The method `"auto"` needs `range`. It uses `"tight"` from `m = U_STATISTIC_TIGHT_MIN_SAMPLE`. The calibration study `u-statistic-interval` sets this constant with `coverageMinSample`. Until a run of the study gives a value, it is infinite. |
116
116
  | `leastSquares(x, y, { intercept })` | The ordinary least-squares fit of `y` on the rows of `x`, with a QR decomposition. It gives the coefficients, `residualSd`, `r2`, `n` and `k`. A singular design gives NaN coefficients. |
117
117
  | `bootstrapLeastSquares(x, y, options)` | One bootstrap interval for each coefficient of `leastSquares`, from the same draws of whole rows. A singular draw does not count. |
118
118
  | `ridgeSolve(gram, moment, lambda, { free })` | The ridge coefficients from the normal equations `X'X` and `X'y`, with a Cholesky factorization. The `free` coefficients have no penalty. A matrix that is not positive definite gives NaN coefficients. |
@@ -127,6 +127,8 @@ The default expansion has one product for each pair of levels of two dimensions.
127
127
  | `quantileSamples(p, level)` | The fewest independent values that give a quantile an upper bound. At the level 0.95: 72 values for p95, 368 for p99 and 3,688 for p99.9. |
128
128
  | `binomialInterval(n, p, level)`, `negativeBinomialInterval(successes, p, level)` | The central interval of a binomial count, and of a count of failures before `successes` successes. Each tail outside holds `(1 - level) / 2` or less. |
129
129
  | `holm(pValues, level)` | The Holm correction of a family of tests. |
130
+ | `binomialTest(k, n, p, side)` | The p of the exact one-sided binomial test of `k` successes in `n` trials. The side `"less"` gives `P(X <= k)`, and `"greater"` gives `P(X >= k)`. |
131
+ | `coverageMinSample(cells, { level, alpha, pooledLow })` | The smallest sample size `m` from which an interval method keeps its level, from the hits of seeded cells. A size qualifies when the cells with a sample of that size or more pass two tests. No cell rejects `level` in `binomialTest` after `holm` at `alpha`, and the `wilson` lower end of the pooled hits is `pooledLow` or more. The set is closed upward: the result is the smallest `m` such that each size of `m` or more qualifies. `blocking` gives the largest size that fails. When the largest size fails, the result is `Infinity`. Fix the bar before the run. |
130
132
  | `partialConjunction(pValues, need)` | The p of the claim that at least `need` of these tests have a real effect. |
131
133
  | `spearman`, `kendallTau`, `ranks` | The rank correlations, with mean ranks for ties. |
132
134
  | `compareRatios`, `noiseFloor`, `noiseVerdict` | The comparison with a baseline, the noise floor of the 5-seed rule with a margin of practical effect, and the state of a difference over the seeds. |
package/build/index.d.ts CHANGED
@@ -938,6 +938,23 @@ interface CountInterval {
938
938
  * or less. The two tails are separate sums, so that a small upper tail keeps its digits.
939
939
  */
940
940
  export declare function binomialInterval(n: number, p: number, level?: number): CountInterval;
941
+ /** The side of `binomialTest`: `"less"` gives `P(X <= k)`, and `"greater"` gives `P(X >= k)`. */
942
+ type BinomialSide = "less" | "greater";
943
+ /**
944
+ * This function gives the p of the exact one-sided binomial test of `k` successes in `n` trials, with
945
+ * X ~ Binomial(n, p). The side `"less"` gives `P(X <= k)`. A small value rejects the claim "the chance is `p` or
946
+ * more". The side `"greater"` gives `P(X >= k)`. A small value rejects the claim "the chance is `p` or less".
947
+ *
948
+ * The sum starts at the largest term of the tail, so a small tail keeps its digits. At `p = 1/2`, the side
949
+ * `"greater"` is equal to the one-sided `signTest(k, n - k)`.
950
+ *
951
+ * @param k - The count of successes, a whole number from 0 to `n`.
952
+ * @param n - The count of trials, a whole number of 0 or more.
953
+ * @param p - The chance of a success under the claim, from 0 to 1.
954
+ * @param side - The side of the tail.
955
+ * @returns The p of the test, from 0 to 1.
956
+ */
957
+ export declare function binomialTest(k: number, n: number, p: number, side: BinomialSide): number;
941
958
  /**
942
959
  * The central interval of a negative binomial count. X is the count of failures before `successes` successes, and
943
960
  * `p` is the chance of a success at each try. `low` is the smallest k with P(X <= k) > (1 - level) / 2.
@@ -1090,12 +1107,92 @@ interface OptionFloorOptions {
1090
1107
  * @returns A whole number of 2 or more.
1091
1108
  */
1092
1109
  export declare function optionFloor(options: OptionFloorOptions): number;
1110
+ /** One cell of a coverage study: the hits of a method on the true value in `draws` seeded samples of size `sample`. */
1111
+ interface CoverageCell {
1112
+ /** The name of the cell, for example `"skewed 120/108"`. The result names the rejected cells with it. */
1113
+ readonly name: string;
1114
+ /** The sample size `m` of the cell, a whole number of 1 or more. */
1115
+ readonly sample: number;
1116
+ /** The count of samples whose interval holds the true value, a whole number from 0 to `draws`. */
1117
+ readonly hits: number;
1118
+ /** The count of samples of the cell, a whole number of 1 or more. */
1119
+ readonly draws: number;
1120
+ }
1121
+ /** The bar of `coverageMinSample`. Fix it before the run, and do not change it after the run. */
1122
+ interface CoverageBar {
1123
+ /** The coverage that the method claims, for example 0.95. Each cell has a one-sided exact binomial test of it. */
1124
+ readonly level: number;
1125
+ /** The level of the Holm family of the cell tests, for example 0.05. */
1126
+ readonly alpha: number;
1127
+ /** The smallest Wilson lower end of the pooled coverage, for example 0.94. */
1128
+ readonly pooledLow: number;
1129
+ /** The z of the Wilson interval. The default is `Z95`. */
1130
+ readonly z?: number;
1131
+ }
1132
+ /** The reason of one step: `"qualifies"`, or the test or tests that failed. */
1133
+ type CoverageReason = "qualifies" | "cell-rejected" | "pooled-low" | "cell-rejected-and-pooled-low";
1134
+ /** The result of the bar at one sample size `m`, over each cell with a sample of `m` or more. */
1135
+ interface CoverageStep {
1136
+ /** The sample size `m` of the step. */
1137
+ readonly sample: number;
1138
+ /** The count of cells with a sample of `m` or more. */
1139
+ readonly cells: number;
1140
+ /** The names of the cells that reject the coverage `level`, after the Holm correction. */
1141
+ readonly rejected: readonly string[];
1142
+ /** The smallest Holm-adjusted p of the cells of the step. */
1143
+ readonly smallestAdjusted: number;
1144
+ /** The sum of the hits of the cells of the step. */
1145
+ readonly hits: number;
1146
+ /** The sum of the draws of the cells of the step. */
1147
+ readonly draws: number;
1148
+ /** The Wilson interval of the pooled coverage `hits / draws`. */
1149
+ readonly pooled: Proportion;
1150
+ /** The sample size `m` passes the two tests of the bar. */
1151
+ readonly qualifies: boolean;
1152
+ readonly reason: CoverageReason;
1153
+ }
1154
+ /** The result of `coverageMinSample`. */
1155
+ interface CoverageMinSample {
1156
+ /**
1157
+ * The smallest sample size `m` of the cells such that each size of `m` or more passes the bar. It is infinite when
1158
+ * the largest size fails.
1159
+ */
1160
+ readonly minSample: number;
1161
+ /** The largest sample size that fails the bar. It blocks each smaller size. The result has no `blocking` when each size passes. */
1162
+ readonly blocking?: number;
1163
+ /** One step for each sample size of the cells, from the smallest to the largest. */
1164
+ readonly steps: readonly CoverageStep[];
1165
+ }
1166
+ /**
1167
+ * This function applies a fixed bar of coverage to the cells of a study. It gives the smallest sample size `m` from
1168
+ * which an interval method keeps its level. The method qualifies at `m` when the cells with a sample of `m` or more
1169
+ * pass two tests:
1170
+ *
1171
+ * 1. No cell rejects the coverage `level`. Each cell has the exact one-sided binomial test `P(X <= hits)`, with
1172
+ * X ~ Binomial(draws, level). The family of these tests gets the Holm correction at `alpha`.
1173
+ * 2. The Wilson lower end of the pooled coverage, the sum of the hits over the sum of the draws, is `pooledLow`
1174
+ * or more.
1175
+ *
1176
+ * Each step tells the result of the two tests at its `m`. A step does not depend on the steps of other sizes. At a
1177
+ * small `m`, the pool also holds the cells of the larger sizes. Thus a small `m` can pass while a larger `m` fails
1178
+ * alone, for example near `m = n`.
1179
+ *
1180
+ * Thus the set of sizes is closed upward. The result is the smallest `m` of the cells such that each size of `m` or
1181
+ * more qualifies. The field `blocking` gives the largest size that fails. When the largest size fails, the result is
1182
+ * infinite.
1183
+ *
1184
+ * @param cells - The hits and the draws of each cell. Each cell has its own sample size.
1185
+ * @param bar - The level, the alpha of the Holm family and the pooled lower end.
1186
+ * @returns The smallest size from which each size qualifies, the size that blocks, and the result at each size.
1187
+ */
1188
+ export declare function coverageMinSample(cells: readonly CoverageCell[], bar: CoverageBar): CoverageMinSample;
1093
1189
  /** The methods of `uStatisticInterval`. The method `"auto"` selects one of the other two for each sample. */
1094
1190
  type UStatisticMethod = "conservative" | "tight" | "auto";
1095
1191
  /**
1096
- * The smallest sample `m` at which the method `"auto"` uses the method `"tight"`. The value comes from the pinned
1097
- * counts of the tests. No measured `m` obeys the rule, so the value is infinite. The TSDoc of `uStatisticInterval`
1098
- * gives the rule and the counts.
1192
+ * The smallest sample `m` at which the method `"auto"` uses the method `"tight"`. The calibration study
1193
+ * `u-statistic-interval` gives the value with `coverageMinSample`. The value is the smallest `m` of the grid such that
1194
+ * each `m` of the grid from this value up passes the bar. Until a run of the study gives a value, the value is
1195
+ * infinite. The TSDoc of `uStatisticInterval` gives the bar of the study.
1099
1196
  */
1100
1197
  export declare const U_STATISTIC_TIGHT_MIN_SAMPLE: number;
1101
1198
  /** The options of `uStatisticInterval`. */
@@ -1196,10 +1293,20 @@ interface UStatisticInterval {
1196
1293
  * The method `"auto"` needs `range`. It uses the method `"tight"` when `m` is `U_STATISTIC_TIGHT_MIN_SAMPLE` or more
1197
1294
  * and the variance is more than 0. Otherwise, it uses the method `"conservative"`.
1198
1295
  *
1199
- * The rule for `U_STATISTIC_TIGHT_MIN_SAMPLE` is the smallest `m` of the table with 190 of 200 or more in each cell.
1200
- * No `m` of the table obeys the rule. The last `m` with a count below 190 is 108, the largest `m` of the table. The
1201
- * table has no larger `m`, so the constant is infinite. Thus the method `"auto"` uses the method `"conservative"` at
1202
- * each `m` less than `n`.
1296
+ * The calibration study `u-statistic-interval` sets `U_STATISTIC_TIGHT_MIN_SAMPLE`. Its bar was fixed before its run.
1297
+ * The study draws 1000 samples in each cell of the 3 kernels and the 17 cells of the table. The method `"tight"`
1298
+ * qualifies at `m` when the cells with a sample of `m` or more pass two tests.
1299
+ *
1300
+ * First, no cell rejects the coverage 0.95 in a one-sided exact binomial test at alpha 0.05, with the Holm
1301
+ * correction over these cells. Second, the Wilson lower end of the pooled coverage of these cells is 0.94 or more.
1302
+ * `coverageMinSample` applies this bar.
1303
+ *
1304
+ * The set of sizes is closed upward. The constant is the smallest `m` of the grid such that each `m` of the grid from
1305
+ * this value up qualifies. A small `m` pools the good cells of the larger sizes, so it can pass while a larger `m`
1306
+ * fails alone. The upward rule keeps the method `"auto"` away from a size that failed.
1307
+ *
1308
+ * When the largest `m` fails, the constant is infinite. Until a run of the study gives a value, the constant is infinite. Thus the method `"auto"`
1309
+ * uses the method `"conservative"` at each `m` less than `n`.
1203
1310
  *
1204
1311
  * With `range`, the interval of the mean stays in `[a, b]`, and each total is in the range of a sum of
1205
1312
  * `C(m - 1, r - 1)` kernel values.
@@ -1209,5 +1316,5 @@ interface UStatisticInterval {
1209
1316
  * @returns The estimate and the interval of the total, and of the mean of the kernel.
1210
1317
  */
1211
1318
  export declare function uStatisticInterval(totals: readonly number[], options: UStatisticOptions): UStatisticInterval;
1212
- export type { BootstrapOptions, CalibrationLevel, CategoricalDimension, CompareOptions, Comparison, ContinuousDimension, Corrected, CountInterval, Effect, Forecast, Interval, Kappa, LeastSquaresFit, LeastSquaresOptions, MedianInterval, ModeOptions, NoiseOptions, NoiseState, NoiseVerdict, OptionFloorOptions, OrdinalDimension, ParsedResponseRecord, PermutationOptions, PermutationResult, Proportion, QuantileInterval, QuantileMethod, ResponseAbsentPoint, ResponseBand, ResponseCurvePoint, ResponseData, ResponseDimension, ResponseDimensionBase, ResponseFactor, ResponseFault, ResponseFitOptions, ResponseFold, ResponseFoldError, ResponseHeldOutError, ResponseInputValue, ResponseMeasure, ResponseModel, ResponseModelBase, ResponsePoint, ResponseReason, ResponseRecord, ResponseSlice, ResponseSliceOptions, ResponseSlicePoint, ResponseSurface, ResponseSurfaceAbsentPoint, ResponseSurfaceOptions, ResponseSurfacePoint, ResponseTableCell, ResponseValue, ResponseViewOptions, ResponseWhen, RidgeInput, RidgeInputBase, RidgeLevelInput, RidgeNumberInput, RidgeOptions, RidgeRankInput, RidgeResponseModel, RidgeTerm, SampleTotalOptions, SideP, SmoothLaw, SmoothLawScore, Summary, TableResponseModel, TwoSamplePermutationOptions, TwoSamplePermutationResult, UStatisticInterval, UStatisticMean, UStatisticMethod, UStatisticOptions };
1319
+ export type { BinomialSide, BootstrapOptions, CalibrationLevel, CategoricalDimension, CompareOptions, Comparison, ContinuousDimension, Corrected, CountInterval, CoverageBar, CoverageCell, CoverageMinSample, CoverageReason, CoverageStep, Effect, Forecast, Interval, Kappa, LeastSquaresFit, LeastSquaresOptions, MedianInterval, ModeOptions, NoiseOptions, NoiseState, NoiseVerdict, OptionFloorOptions, OrdinalDimension, ParsedResponseRecord, PermutationOptions, PermutationResult, Proportion, QuantileInterval, QuantileMethod, ResponseAbsentPoint, ResponseBand, ResponseCurvePoint, ResponseData, ResponseDimension, ResponseDimensionBase, ResponseFactor, ResponseFault, ResponseFitOptions, ResponseFold, ResponseFoldError, ResponseHeldOutError, ResponseInputValue, ResponseMeasure, ResponseModel, ResponseModelBase, ResponsePoint, ResponseReason, ResponseRecord, ResponseSlice, ResponseSliceOptions, ResponseSlicePoint, ResponseSurface, ResponseSurfaceAbsentPoint, ResponseSurfaceOptions, ResponseSurfacePoint, ResponseTableCell, ResponseValue, ResponseViewOptions, ResponseWhen, RidgeInput, RidgeInputBase, RidgeLevelInput, RidgeNumberInput, RidgeOptions, RidgeRankInput, RidgeResponseModel, RidgeTerm, SampleTotalOptions, SideP, SmoothLaw, SmoothLawScore, Summary, TableResponseModel, TwoSamplePermutationOptions, TwoSamplePermutationResult, UStatisticInterval, UStatisticMean, UStatisticMethod, UStatisticOptions };
1213
1320
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/describe.ts","../src/regression.ts","../src/bootstrap.ts","../src/distribution.ts","../src/ridge.ts","../src/response.ts","../src/response-parse.ts","../src/response-fit.ts","../src/tests.ts","../src/agreement.ts","../src/rank.ts","../src/discrete.ts","../src/compare.ts","../src/power.ts","../src/u-statistic.ts"],"mappings":";;;;;;KAOY;;wBAmBI,OAAO;wBAIP,KAAK;;;;;wBAgBL,GAAG;;;;;;;wBAgBH,eAAe,iCAAiC,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G;;WAEN;;WAEA;;WAEA;;;UAIM;WACN;WACA;;WAEA;;WAEA;;UAGM;;WAEN;WACA;;WAEA;;WAEA;;WAEA;;WAEA,QAAQ;;WAER;;WAEA;;WAEA;WACA,cAAc;;WAEd;WACA,cAAc;;;;;;;;wBAST,cAAc,2BAA2B,UAAS,iBAAsB;;UA6CvE;WACN;WACA;;;wBASK,MAAM,oBAAoB;;UAQzB;WACN;WACA;WACA;;WAEA;;WAEA,UAAU;;;wBAIL,YAAY,oBAAoB,aAAa;;;;;;;wBChJ7C,UAAU,WAAW;;UAgBpB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;;;;;wBAiBK,YAAY,SAAS;;KC9FzB;;;;;;qBAOC;;UAGI;;WAEN;;WAEA;;WAEA,QAAQ;;WAER;;WAEA,kBAAkB,aAAa;;;UAIzB;;WAEN;WACA;WACA;;;UAIM;;WAEN;WACA;WACA;WACA;;WAEA;;WAEA,WAAW;;WAEX,MAAM;;WAEN;;WAEA;;WAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAyEK,mBAAmB,2BAA2B,SAAS,oBAAoB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/describe.ts","../src/regression.ts","../src/bootstrap.ts","../src/distribution.ts","../src/ridge.ts","../src/response.ts","../src/response-parse.ts","../src/response-fit.ts","../src/tests.ts","../src/agreement.ts","../src/rank.ts","../src/discrete.ts","../src/compare.ts","../src/power.ts","../src/coverage.ts","../src/u-statistic.ts"],"mappings":";;;;;;KAOY;;wBAmBI,OAAO;wBAIP,KAAK;;;;;wBAgBL,GAAG;;;;;;;wBAgBH,eAAe,iCAAiC,WAAW,SAAQ;;wBAkBnE,SAAS,2BAA2B,WAAW,SAAQ;;;;;wBASvD,OAAO;;UAQN;WACN;WACA;;WAEA;WACA;;WAEA;WACA;;WAEA;WACA;;WAEA;;wBAGK,UAAU,4BAA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WAEA;;WAEA;;WAEA,QAAQ;;WAER;;WAEA;;WAEA;WACA,cAAc;;WAEd;WACA,cAAc;;;;;;;;wBAST,cAAc,2BAA2B,UAAS,iBAAsB;;UA6CvE;WACN;WACA;;;wBASK,MAAM,oBAAoB;;UAQzB;WACN;WACA;WACA;;WAEA;;WAEA,UAAU;;;wBAIL,YAAY,oBAAoB,aAAa;;;;;;;wBChJ7C,UAAU,WAAW;;UAgBpB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;;;;;wBAiBK,YAAY,SAAS;;UC7FpB;;WAEN;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;;KAIC;;UAGK;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA,QAAQ;;WAER;WACA,QAAQ;;;UAIF;;;;;WAKN;;WAEA;;WAEA,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;wBA6BX,kBAAkB,gBAAgB,gBAAgB,KAAK,cAAc;;KCvFzE;;;;;;;qBAQC;;UAGI;;WAEN;;WAEA;;WAEA,QAAQ;;WAER;;WAEA,kBAAkB,aAAa;;;UAIzB;;WAEN;WACA;WACA;;;UAIM;;WAEN;WACA;WACA;WACA;;WAEA;;WAEA,WAAW;;WAEX,MAAM;;WAEN;;WAEA;;WAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmFK,mBAAmB,2BAA2B,SAAS,oBAAoB"}
package/build/index.js CHANGED
@@ -2247,7 +2247,7 @@ function fitResponse(data, options = {}) {
2247
2247
  * The tests of a difference: the sign test, the paired permutation test, the Wilson interval of a proportion and
2248
2248
  * the Holm correction for several tests.
2249
2249
  */
2250
- function whole$1(name, value) {
2250
+ function whole$2(name, value) {
2251
2251
  if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`${name}: ${value} is not a whole number of 0 or more.`);
2252
2252
  }
2253
2253
  /** The log of each binomial term C(n, k) / 2^n, for each k from 0 to n. */
@@ -2275,8 +2275,8 @@ function upperTail(k, n) {
2275
2275
  * two times the tail of the larger count, at most 1. The one-sided p is equal to `signTestP` of packing.
2276
2276
  */
2277
2277
  function signTest(better, worse, sides = 1) {
2278
- whole$1("signTest", better);
2279
- whole$1("signTest", worse);
2278
+ whole$2("signTest", better);
2279
+ whole$2("signTest", worse);
2280
2280
  const n = better + worse;
2281
2281
  if (n === 0) return 1;
2282
2282
  if (sides === 1) return upperTail(better, n);
@@ -2287,7 +2287,7 @@ function signTest(better, worse, sides = 1) {
2287
2287
  * n wins out of n are not enough. Use it before a run, to know how many inputs a claim needs.
2288
2288
  */
2289
2289
  function signTestPower(n, level = .05, sides = 2) {
2290
- whole$1("signTestPower", n);
2290
+ whole$2("signTestPower", n);
2291
2291
  for (let k = Math.ceil(n / 2); k <= n; k++) if (signTest(k, n - k, sides) < level) return k;
2292
2292
  }
2293
2293
  /** The z of a two-sided 95% interval. */
@@ -2297,8 +2297,8 @@ const Z95 = 1.959963984540054;
2297
2297
  * a proportion near 0 or 1, where the normal interval does not. For n = 0 the interval is 0 to 1.
2298
2298
  */
2299
2299
  function wilson(k, n, z = Z95) {
2300
- whole$1("wilson", k);
2301
- whole$1("wilson", n);
2300
+ whole$2("wilson", k);
2301
+ whole$2("wilson", n);
2302
2302
  if (k > n) throw new RangeError(`wilson: k ${k} is more than n ${n}.`);
2303
2303
  if (n === 0) return {
2304
2304
  low: 0,
@@ -2345,7 +2345,7 @@ function holm(pValues, level = .05) {
2345
2345
  */
2346
2346
  function partialConjunction(pValues, need) {
2347
2347
  for (const p of pValues) if (!(p >= 0 && p <= 1)) throw new RangeError(`partialConjunction: each p is from 0 to 1, not ${p}.`);
2348
- whole$1("partialConjunction", need);
2348
+ whole$2("partialConjunction", need);
2349
2349
  const m = pValues.length;
2350
2350
  if (need < 1 || need > m) throw new RangeError(`partialConjunction: need is from 1 to the count of tests ${m}, not ${need}.`);
2351
2351
  const sorted = [...pValues].sort((a, b) => a - b);
@@ -2448,7 +2448,7 @@ function twoSamplePermutation(a, b, options = {}) {
2448
2448
  */
2449
2449
  function wilsonSampleSize(target, expected, z = Z95, max = 1e6) {
2450
2450
  if (!(target >= 0 && target <= 1 && expected >= 0 && expected <= 1)) throw new RangeError(`wilsonSampleSize: target ${target} and expected ${expected} must be from 0 to 1.`);
2451
- whole$1("wilsonSampleSize", max);
2451
+ whole$2("wilsonSampleSize", max);
2452
2452
  if (expected <= target) return void 0;
2453
2453
  for (let n = 1; n <= max; n++) if (wilson(Math.round(expected * n), n, z).low >= target) return n;
2454
2454
  }
@@ -2566,7 +2566,7 @@ function kendallTau(a, b, seed = 1) {
2566
2566
  * The intervals that come from a discrete distribution. The interval of a median or of a quantile comes from the order
2567
2567
  * statistics. The central interval of a count comes from a binomial or a negative binomial distribution.
2568
2568
  */
2569
- function whole(name, value) {
2569
+ function whole$1(name, value) {
2570
2570
  if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`${name}: ${value} is not a whole number of 0 or more.`);
2571
2571
  }
2572
2572
  function levelOf(name, level) {
@@ -2675,7 +2675,7 @@ function quantileSamples(p, level = .95) {
2675
2675
  * or less. The two tails are separate sums, so that a small upper tail keeps its digits.
2676
2676
  */
2677
2677
  function binomialInterval(n, p, level = .95) {
2678
- whole("binomialInterval", n);
2678
+ whole$1("binomialInterval", n);
2679
2679
  if (!(p >= 0 && p <= 1)) throw new RangeError(`binomialInterval: p is from 0 to 1, not ${p}.`);
2680
2680
  const tail = levelOf("binomialInterval", level);
2681
2681
  const terms = binomialTerms(n, p);
@@ -2700,12 +2700,47 @@ function binomialInterval(n, p, level = .95) {
2700
2700
  };
2701
2701
  }
2702
2702
  /**
2703
+ * This function gives the p of the exact one-sided binomial test of `k` successes in `n` trials, with
2704
+ * X ~ Binomial(n, p). The side `"less"` gives `P(X <= k)`. A small value rejects the claim "the chance is `p` or
2705
+ * more". The side `"greater"` gives `P(X >= k)`. A small value rejects the claim "the chance is `p` or less".
2706
+ *
2707
+ * The sum starts at the largest term of the tail, so a small tail keeps its digits. At `p = 1/2`, the side
2708
+ * `"greater"` is equal to the one-sided `signTest(k, n - k)`.
2709
+ *
2710
+ * @param k - The count of successes, a whole number from 0 to `n`.
2711
+ * @param n - The count of trials, a whole number of 0 or more.
2712
+ * @param p - The chance of a success under the claim, from 0 to 1.
2713
+ * @param side - The side of the tail.
2714
+ * @returns The p of the test, from 0 to 1.
2715
+ */
2716
+ function binomialTest(k, n, p, side) {
2717
+ whole$1("binomialTest", k);
2718
+ whole$1("binomialTest", n);
2719
+ if (k > n) throw new RangeError(`binomialTest: k ${k} is more than n ${n}.`);
2720
+ if (!(p >= 0 && p <= 1)) throw new RangeError(`binomialTest: p is from 0 to 1, not ${p}.`);
2721
+ if (side !== "less" && side !== "greater") throw new RangeError(`binomialTest: side is "less" or "greater", not ${String(side)}.`);
2722
+ const [from, to] = side === "less" ? [0, k] : [k, n];
2723
+ if (from === 0 && to === n) return 1;
2724
+ if (p === 0) return from === 0 ? 1 : 0;
2725
+ if (p === 1) return to === n ? 1 : 0;
2726
+ const [logP, logQ] = [Math.log(p), Math.log1p(-p)];
2727
+ const logs = [];
2728
+ let logChoose = 0;
2729
+ for (let i = 0; i <= to; i++) {
2730
+ if (i > 0) logChoose += Math.log((n - i + 1) / i);
2731
+ if (i >= from) logs.push(logChoose + i * logP + (n - i) * logQ);
2732
+ }
2733
+ const top = Math.max(...logs);
2734
+ const sum = logs.reduce((s, l) => s + Math.exp(l - top), 0);
2735
+ return Math.min(1, Math.exp(top) * sum);
2736
+ }
2737
+ /**
2703
2738
  * The central interval of a negative binomial count. X is the count of failures before `successes` successes, and
2704
2739
  * `p` is the chance of a success at each try. `low` is the smallest k with P(X <= k) > (1 - level) / 2.
2705
2740
  * `high` is the smallest k with P(X <= k) >= 1 - (1 - level) / 2.
2706
2741
  */
2707
2742
  function negativeBinomialInterval(successes, p, level = .95) {
2708
- whole("negativeBinomialInterval", successes);
2743
+ whole$1("negativeBinomialInterval", successes);
2709
2744
  if (!(p > 0 && p <= 1)) throw new RangeError(`negativeBinomialInterval: p is more than 0 and 1 or less, not ${p}.`);
2710
2745
  const tail = levelOf("negativeBinomialInterval", level);
2711
2746
  const logQ = Math.log1p(-p);
@@ -2972,15 +3007,109 @@ function optionFloor(options) {
2972
3007
  }
2973
3008
  throw new RangeError(`optionFloor: no count under 10,000,000 for sigma ${sigma} and delta ${delta}.`);
2974
3009
  }
3010
+ // src/coverage.ts
3011
+ /**
3012
+ * The rule that finds the smallest sample at which an interval method keeps its level. The input is the hits of the
3013
+ * method on the true value in seeded cells. The bar is fixed before the run.
3014
+ */
3015
+ function whole(name, value, min) {
3016
+ if (!Number.isSafeInteger(value) || value < min) throw new RangeError(`coverageMinSample: ${name} is a whole number of ${min} or more, not ${value}.`);
3017
+ }
3018
+ /**
3019
+ * This function applies a fixed bar of coverage to the cells of a study. It gives the smallest sample size `m` from
3020
+ * which an interval method keeps its level. The method qualifies at `m` when the cells with a sample of `m` or more
3021
+ * pass two tests:
3022
+ *
3023
+ * 1. No cell rejects the coverage `level`. Each cell has the exact one-sided binomial test `P(X <= hits)`, with
3024
+ * X ~ Binomial(draws, level). The family of these tests gets the Holm correction at `alpha`.
3025
+ * 2. The Wilson lower end of the pooled coverage, the sum of the hits over the sum of the draws, is `pooledLow`
3026
+ * or more.
3027
+ *
3028
+ * Each step tells the result of the two tests at its `m`. A step does not depend on the steps of other sizes. At a
3029
+ * small `m`, the pool also holds the cells of the larger sizes. Thus a small `m` can pass while a larger `m` fails
3030
+ * alone, for example near `m = n`.
3031
+ *
3032
+ * Thus the set of sizes is closed upward. The result is the smallest `m` of the cells such that each size of `m` or
3033
+ * more qualifies. The field `blocking` gives the largest size that fails. When the largest size fails, the result is
3034
+ * infinite.
3035
+ *
3036
+ * @param cells - The hits and the draws of each cell. Each cell has its own sample size.
3037
+ * @param bar - The level, the alpha of the Holm family and the pooled lower end.
3038
+ * @returns The smallest size from which each size qualifies, the size that blocks, and the result at each size.
3039
+ */
3040
+ function coverageMinSample(cells, bar) {
3041
+ const { level, alpha, pooledLow } = bar;
3042
+ const z = bar.z ?? 1.959963984540054;
3043
+ if (!(level > 0 && level < 1)) throw new RangeError(`coverageMinSample: level is more than 0 and less than 1, not ${level}.`);
3044
+ if (!(alpha > 0 && alpha < 1)) throw new RangeError(`coverageMinSample: alpha is more than 0 and less than 1, not ${alpha}.`);
3045
+ if (!(pooledLow >= 0 && pooledLow <= 1)) throw new RangeError(`coverageMinSample: pooledLow is from 0 to 1, not ${pooledLow}.`);
3046
+ if (!(z > 0 && Number.isFinite(z))) throw new RangeError(`coverageMinSample: z is a finite number more than 0, not ${z}.`);
3047
+ for (const cell of cells) {
3048
+ whole("sample", cell.sample, 1);
3049
+ whole("draws", cell.draws, 1);
3050
+ whole("hits", cell.hits, 0);
3051
+ if (cell.hits > cell.draws) throw new RangeError(`coverageMinSample: the hits ${cell.hits} of the cell ${cell.name} are more than its draws ${cell.draws}.`);
3052
+ }
3053
+ const p = cells.map((cell) => binomialTest(cell.hits, cell.draws, level, "less"));
3054
+ const steps = [...new Set(cells.map((cell) => cell.sample))].sort((a, b) => a - b).map((m) => {
3055
+ const at = cells.map((cell, i) => ({
3056
+ cell,
3057
+ p: p[i]
3058
+ })).filter(({ cell }) => cell.sample >= m);
3059
+ const corrected = holm(at.map(({ p: value }) => value), alpha);
3060
+ const rejected = at.filter((_, i) => corrected[i]?.reject === true).map(({ cell }) => cell.name);
3061
+ const smallestAdjusted = Math.min(...corrected.map((c) => c.adjusted));
3062
+ let hits = 0;
3063
+ let draws = 0;
3064
+ for (const { cell } of at) {
3065
+ hits += cell.hits;
3066
+ draws += cell.draws;
3067
+ }
3068
+ const pooled = wilson(hits, draws, z);
3069
+ const cellOk = rejected.length === 0;
3070
+ const pooledOk = pooled.low >= pooledLow;
3071
+ const reason = cellOk ? pooledOk ? "qualifies" : "pooled-low" : pooledOk ? "cell-rejected" : "cell-rejected-and-pooled-low";
3072
+ return {
3073
+ sample: m,
3074
+ cells: at.length,
3075
+ rejected,
3076
+ smallestAdjusted,
3077
+ hits,
3078
+ draws,
3079
+ pooled,
3080
+ qualifies: cellOk && pooledOk,
3081
+ reason
3082
+ };
3083
+ });
3084
+ let minSample = Number.POSITIVE_INFINITY;
3085
+ let blocking;
3086
+ for (let i = steps.length - 1; i >= 0; i--) {
3087
+ const step = steps[i];
3088
+ if (!step.qualifies) {
3089
+ blocking = step.sample;
3090
+ break;
3091
+ }
3092
+ minSample = step.sample;
3093
+ }
3094
+ return blocking === void 0 ? {
3095
+ minSample,
3096
+ steps
3097
+ } : {
3098
+ minSample,
3099
+ blocking,
3100
+ steps
3101
+ };
3102
+ }
2975
3103
  // src/u-statistic.ts
2976
3104
  /**
2977
3105
  * The interval of a U-statistic from a uniform sample of `m` of `n` units, drawn without replacement. A kernel `h`
2978
3106
  * gives a value to each set of `r` units. The total of the population is the sum of `h` over all its sets of `r`.
2979
3107
  */
2980
3108
  /**
2981
- * The smallest sample `m` at which the method `"auto"` uses the method `"tight"`. The value comes from the pinned
2982
- * counts of the tests. No measured `m` obeys the rule, so the value is infinite. The TSDoc of `uStatisticInterval`
2983
- * gives the rule and the counts.
3109
+ * The smallest sample `m` at which the method `"auto"` uses the method `"tight"`. The calibration study
3110
+ * `u-statistic-interval` gives the value with `coverageMinSample`. The value is the smallest `m` of the grid such that
3111
+ * each `m` of the grid from this value up passes the bar. Until a run of the study gives a value, the value is
3112
+ * infinite. The TSDoc of `uStatisticInterval` gives the bar of the study.
2984
3113
  */
2985
3114
  const U_STATISTIC_TIGHT_MIN_SAMPLE = Number.POSITIVE_INFINITY;
2986
3115
  /**
@@ -3041,10 +3170,20 @@ const U_STATISTIC_TIGHT_MIN_SAMPLE = Number.POSITIVE_INFINITY;
3041
3170
  * The method `"auto"` needs `range`. It uses the method `"tight"` when `m` is `U_STATISTIC_TIGHT_MIN_SAMPLE` or more
3042
3171
  * and the variance is more than 0. Otherwise, it uses the method `"conservative"`.
3043
3172
  *
3044
- * The rule for `U_STATISTIC_TIGHT_MIN_SAMPLE` is the smallest `m` of the table with 190 of 200 or more in each cell.
3045
- * No `m` of the table obeys the rule. The last `m` with a count below 190 is 108, the largest `m` of the table. The
3046
- * table has no larger `m`, so the constant is infinite. Thus the method `"auto"` uses the method `"conservative"` at
3047
- * each `m` less than `n`.
3173
+ * The calibration study `u-statistic-interval` sets `U_STATISTIC_TIGHT_MIN_SAMPLE`. Its bar was fixed before its run.
3174
+ * The study draws 1000 samples in each cell of the 3 kernels and the 17 cells of the table. The method `"tight"`
3175
+ * qualifies at `m` when the cells with a sample of `m` or more pass two tests.
3176
+ *
3177
+ * First, no cell rejects the coverage 0.95 in a one-sided exact binomial test at alpha 0.05, with the Holm
3178
+ * correction over these cells. Second, the Wilson lower end of the pooled coverage of these cells is 0.94 or more.
3179
+ * `coverageMinSample` applies this bar.
3180
+ *
3181
+ * The set of sizes is closed upward. The constant is the smallest `m` of the grid such that each `m` of the grid from
3182
+ * this value up qualifies. A small `m` pools the good cells of the larger sizes, so it can pass while a larger `m`
3183
+ * fails alone. The upward rule keeps the method `"auto"` away from a size that failed.
3184
+ *
3185
+ * When the largest `m` fails, the constant is infinite. Until a run of the study gives a value, the constant is infinite. Thus the method `"auto"`
3186
+ * uses the method `"conservative"` at each `m` less than `n`.
3048
3187
  *
3049
3188
  * With `range`, the interval of the mean stays in `[a, b]`, and each total is in the range of a sum of
3050
3189
  * `C(m - 1, r - 1)` kernel values.
@@ -3148,6 +3287,6 @@ function choose(n, k) {
3148
3287
  for (let j = 0; j < k; j++) c = c * (n - j) / (j + 1);
3149
3288
  return c;
3150
3289
  }
3151
- export { KENDALL_EXACT, RESPONSE_LAMBDAS, RESPONSE_MAX_POWER, RESPONSE_MAX_TERMS, RESPONSE_RECORDS_SCHEMA, U_STATISTIC_TIGHT_MIN_SAMPLE, Z95, bestSmoothLaw, binomialInterval, bootstrap, bootstrapClusters, bootstrapLeastSquares, bootstrapMedian, bootstrapMedianRatio, bootstrapTwo, brier, calibration, cohenKappa, compareRatios, fitResponse, heldOutError, heldOutErrorAt, holm, kendallTau, leastSquares, mean, median, medianInterval, modeCount, negativeBinomialInterval, noiseFloor, noiseVerdict, optionFloor, pairedPermutation, parseResponseRecord, partialConjunction, predictResponse, quantile, quantileInterval, quantileSamples, quantileSorted, ranks, responseCells, ridgeSolve, sampleTotalInterval, sd, signTest, signTestPower, sliceResponse, smoothLawScores, sorted, spearman, summarize, surfaceResponse, tQuantile, twoSamplePermutation, uStatisticInterval, whenHolds, wilson, wilsonSampleSize };
3290
+ export { KENDALL_EXACT, RESPONSE_LAMBDAS, RESPONSE_MAX_POWER, RESPONSE_MAX_TERMS, RESPONSE_RECORDS_SCHEMA, U_STATISTIC_TIGHT_MIN_SAMPLE, Z95, bestSmoothLaw, binomialInterval, binomialTest, bootstrap, bootstrapClusters, bootstrapLeastSquares, bootstrapMedian, bootstrapMedianRatio, bootstrapTwo, brier, calibration, cohenKappa, compareRatios, coverageMinSample, fitResponse, heldOutError, heldOutErrorAt, holm, kendallTau, leastSquares, mean, median, medianInterval, modeCount, negativeBinomialInterval, noiseFloor, noiseVerdict, optionFloor, pairedPermutation, parseResponseRecord, partialConjunction, predictResponse, quantile, quantileInterval, quantileSamples, quantileSorted, ranks, responseCells, ridgeSolve, sampleTotalInterval, sd, signTest, signTestPower, sliceResponse, smoothLawScores, sorted, spearman, summarize, surfaceResponse, tQuantile, twoSamplePermutation, uStatisticInterval, whenHolds, wilson, wilsonSampleSize };
3152
3291
 
3153
3292
  //# sourceMappingURL=index.js.map