@mark1russell7/rigor-statistics 0.1.24 → 0.1.26

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
@@ -160,6 +160,7 @@ logLoss([{ p: p.a, hit: true }]); // the probability of the obser
160
160
  | Function | What it gives |
161
161
  | --- | --- |
162
162
  | `mean`, `sd`, `median`, `summarize` | The descriptive statistics. `sd` is the sample standard deviation. |
163
+ | `runningOf`, `addToRunning`, `mergeRunning`, `runningMean`, `runningSd` | A running summary of a stream: the count, the sum, the extremes and the spread, one value at a time. `mergeRunning` joins the summaries of two parts. `runningMean` gives exactly `mean` of the values. |
163
164
  | `quantile(values, p, method)`, `quantileSorted` | The `p` quantile, with the `"linear"` method (type 7, the default), the `"nearest-rank"` method (type 1) or the `"higher"` method (`sorted[Math.ceil(p * (n - 1))]`, as NumPy). |
164
165
  | `bootstrap(data, statistic, options)` | A percentile bootstrap interval of any statistic. The options are `runs`, `level` or `ends`, `seed`, `method` and `against`. |
165
166
  | The option `against` | The interval also gives `pAbove` and `pBelow`, the bootstrap p of each side of the value, from the same draws. The smallest p is 1 / (`finite` + 1). Give `holm` enough runs: with m tests at level a, `runs` is more than m / a. |
@@ -290,8 +291,6 @@ The tests prove that these functions give the same numbers as the copies in the
290
291
  | `bootstrapMedian` of packing | `bootstrapMedian(sortedValues, { runs, level, seed })`. Give the values sorted, because packing draws from the sorted list. |
291
292
  | `bootstrapMedian` of highways | `bootstrap(values, (s) => quantile(s, 0.5), { runs, level, seed })` |
292
293
  | `bootstrap` of layout-contract | `bootstrapClusters(rows, (r) => r.cluster, statistic, { runs, seed, ends: [0.025, 0.975] })` |
293
- | The stratified bootstrap of `verdict` of layout-contract | `bootstrapStrata(families, meanOfMeans, { runs, seed: deriveSeed(seed, "verdict.stratified"), ends })` |
294
- | The permutation test of `verdict` of layout-contract | `signFlipTest(terms, { exactMax, runs, seed: deriveSeed(seed, "verdict.permutation") })` |
295
294
  | `normalQuantile` of lag (Acklam, relative error below 1.2e-9) | `normalQuantile(p)`. The values change by 1.2e-9 or less, because the new function is more exact. A `p` out of 0 to 1 throws. |
296
295
  | `signTestP` of packing | `signTest(better, worse)` |
297
296
  | `signTestPower` of highways | `signTestPower(n, level)` |
@@ -299,6 +298,7 @@ The tests prove that these functions give the same numbers as the copies in the
299
298
  | `spearman` of the highways backtest, `kendallTau` of highways | `spearman`, `kendallTau` |
300
299
  | `medianInterval` of the harness and kind of systems | `medianInterval(sortedValues)`, with `low` and `high` |
301
300
  | The binomial band of `targetConnections` and `negativeBinomial` of the cells of systems | `binomialInterval(n, p, cover)` and `negativeBinomialInterval(successes, p, cover)` |
301
+ | `summarizingNumber` of collections (`count`, `sum`, `min`, `max`, `average`) | `addToRunning` in the accumulator, then `n`, `sum`, `min`, `max` and `runningMean`. The average was `sum / count`, so the bits stay. |
302
302
 
303
303
  A copy that gives NaN, 0 or `undefined` for an empty list must test the list at the call, because these functions throw.
304
304
 
package/build/index.d.ts CHANGED
@@ -45,6 +45,48 @@ interface Summary {
45
45
  readonly iqr: number;
46
46
  }
47
47
  export declare function summarize(values: readonly number[]): Summary;
48
+ /**
49
+ * The running summary: the count, the sum, the extremes and the spread of a stream of values, one value at a time.
50
+ * A collector, a reducer or a parallel job adds each value, or merges two summaries. The summary agrees with the
51
+ * functions of a list: `runningMean` gives exactly `mean` of the values, and `runningSd` gives `sd` to a tolerance.
52
+ */
53
+ /**
54
+ * A running summary of the values that were added. The record is immutable, so a fold can keep each step. The empty
55
+ * summary is `EMPTY_RUNNING`.
56
+ */
57
+ interface RunningSummary {
58
+ /** The count of the values. */
59
+ readonly n: number;
60
+ /** The sum of the values, added in their order. */
61
+ readonly sum: number;
62
+ /** The smallest value, or `Infinity` for no value. */
63
+ readonly min: number;
64
+ /** The largest value, or `-Infinity` for no value. */
65
+ readonly max: number;
66
+ /** The sum of the squares of the differences from the mean (Welford). `runningSd` reads it. */
67
+ readonly m2: number;
68
+ }
69
+ /** The summary of no value. It is the unit of `mergeRunning`. */
70
+ export declare const EMPTY_RUNNING: RunningSummary;
71
+ /**
72
+ * This function gives the summary with one more value. It throws a RangeError for NaN, as the functions of a list do.
73
+ * The mean of each step is `sum / n`, so the mean of the fold is the mean of the list.
74
+ */
75
+ export declare function addToRunning(s: RunningSummary, value: number): RunningSummary;
76
+ /** This function gives the summary of the values of a list or another iterable, in their order. */
77
+ export declare function runningOf(values: Iterable<number>): RunningSummary;
78
+ /**
79
+ * This function gives the summary of the values of two summaries (Chan, Golub and LeVeque, 1979). Thus parallel jobs
80
+ * can each summarize a part. The sum of the merge adds the two sums, so it can differ from the fold in the last bits.
81
+ */
82
+ export declare function mergeRunning(a: RunningSummary, b: RunningSummary): RunningSummary;
83
+ /** This function gives the mean of the values: `sum / n`. It throws a RangeError for the empty summary. */
84
+ export declare function runningMean(s: RunningSummary): number;
85
+ /**
86
+ * This function gives the sample standard deviation of the values (the divisor is n - 1). It needs 2 values or more.
87
+ * Equal values give exactly 0, as `sd` gives. A rounding error cannot make the result NaN.
88
+ */
89
+ export declare function runningSd(s: RunningSummary): number;
48
90
  /**
49
91
  * Ordinary least squares with a Householder QR decomposition. The QR decomposition does not square the condition
50
92
  * number of the design, as the normal equations do. A design without full rank gives NaN coefficients and does not
@@ -1610,5 +1652,5 @@ interface BradleyTerryFit {
1610
1652
  * outcome, a bad weight and a bad option.
1611
1653
  */
1612
1654
  export declare function bradleyTerry(items: number, comparisons: readonly PairComparison[], options?: BradleyTerryOptions): BradleyTerryFit;
1613
- export type { BinomialSide, BootstrapOptions, BradleyTerryFit, BradleyTerryOptions, CalibrationLevel, CategoricalDimension, CompareOptions, Comparison, ContinuousDimension, Corrected, CountInterval, CoverageBar, CoverageCell, CoverageMinSample, CoverageReason, CoverageStep, Effect, EloOptions, EloUpdate, Forecast, Glicko2Game, Glicko2Options, Glicko2Rating, Interval, Kappa, LeastSquaresFit, LeastSquaresOptions, MedianInterval, ModeOptions, NoiseOptions, NoiseState, NoiseVerdict, OptionFloorOptions, OrdinalDimension, PairComparison, PairOutcome, PairProbabilities, ParsedResponseRecord, PermutationOptions, PermutationResult, Proportion, QuantileInterval, QuantileMethod, RatingScale, 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, SignFlipOptions, SignFlipResult, SmoothLaw, SmoothLawScore, SobolIndex, SobolIndices, SobolOptions, Summary, TableResponseModel, TieModel, TwoSamplePermutationOptions, TwoSamplePermutationResult, UStatisticInterval, UStatisticMean, UStatisticMethod, UStatisticOptions };
1655
+ export type { BinomialSide, BootstrapOptions, BradleyTerryFit, BradleyTerryOptions, CalibrationLevel, CategoricalDimension, CompareOptions, Comparison, ContinuousDimension, Corrected, CountInterval, CoverageBar, CoverageCell, CoverageMinSample, CoverageReason, CoverageStep, Effect, EloOptions, EloUpdate, Forecast, Glicko2Game, Glicko2Options, Glicko2Rating, Interval, Kappa, LeastSquaresFit, LeastSquaresOptions, MedianInterval, ModeOptions, NoiseOptions, NoiseState, NoiseVerdict, OptionFloorOptions, OrdinalDimension, PairComparison, PairOutcome, PairProbabilities, ParsedResponseRecord, PermutationOptions, PermutationResult, Proportion, QuantileInterval, QuantileMethod, RatingScale, 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, RunningSummary, SampleTotalOptions, SideP, SignFlipOptions, SignFlipResult, SmoothLaw, SmoothLawScore, SobolIndex, SobolIndices, SobolOptions, Summary, TableResponseModel, TieModel, TwoSamplePermutationOptions, TwoSamplePermutationResult, UStatisticInterval, UStatisticMean, UStatisticMethod, UStatisticOptions };
1614
1656
  //# 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/response-sobol.ts","../src/tests.ts","../src/agreement.ts","../src/rank.ts","../src/discrete.ts","../src/compare.ts","../src/power.ts","../src/normal.ts","../src/coverage.ts","../src/u-statistic.ts","../src/rating.ts","../src/bradley-terry.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,4BAA4B;;;;;;UC3GrC;;WAEN;;UAGM;;WAEN;;WAEA;;;;;WAKA;;WAEA;;WAEA;;;;;;;;;;;wBAkBK,aAAa,mCAAmC,sBAAsB,UAAS,sBAA2B;UC7BzG;;WAEN;;WAEA;;WAEA;;WAEA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A;;WAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAmFK,mBAAmB,2BAA2B,SAAS,oBAAoB;;;;;;;UCrI1E;;WAEN;;WAEA;;WAEA;;;UAIM,mBAAmB;;WAEzB;;;UAIM;;WAEN;;WAEA;;WAEA;;;;;;wBAyBK,YAAY,YAAY,YAAY,UAAS;;;;;;wBAY7C,UAAU,YAAY,YAAY,eAAe,UAAS,aAAkB;;UAU3E;WACN;;WAEA;;WAEA;;;UAIM;WACN;WACA;;WAEA;;;UAIM;;WAEN;;WAEA;;;;;;;wBAmBK,cAAc,QAAQ,eAAe,gBAAgB,eAAe,UAAS,iBAAsB;;;;;wBAuEnG,YAAY,QAAQ,gBAAgB;;UAQnC;;WAEN;;WAEA;;WAEA;;;;;;;wBAuBK,kBAAkB,YAAY,YAAY,eAAU;;;;;wBAWpD,iBAAiB,kBAAkB,UAAS;;wBAO5C,iBAAiB,gBAAgB,UAAS;;KCtO9C;;UAGK;WACN;WACA;WACA,SAAS;;WAET;;;KAIC;;UAGK;;WAEN;;WAEA;;;;;WAKA,OAAO;;;;;WAKP;;WAEA;;WAEA;;;UAIM;;WAEN;;;;;WAKA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;wBA6CK,aAAa,eAAe,sBAAsB,kBAAkB,UAAS,sBAA2B"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/describe.ts","../src/running.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/response-sobol.ts","../src/tests.ts","../src/agreement.ts","../src/rank.ts","../src/discrete.ts","../src/compare.ts","../src/power.ts","../src/normal.ts","../src/coverage.ts","../src/u-statistic.ts","../src/rating.ts","../src/bradley-terry.ts"],"mappings":";;;;;;;KAOY;;wBAmBI,OAAO;wBAIP,KAAK;;;;;wBAgBL,GAA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CtO9C;;UAGK;WACN;WACA;WACA,SAAS;;WAET;;;KAIC;;UAGK;;WAEN;;WAEA;;;;;WAKA,OAAO;;;;;WAKP;;WAEA;;WAEA;;;UAIM;;WAEN;;;;;WAKA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;wBA6CK,aAAa,eAAe,sBAAsB,kBAAkB,UAAS,sBAA2B"}
package/build/index.js CHANGED
@@ -84,6 +84,76 @@ function summarize(values) {
84
84
  iqr: q3 - q1
85
85
  };
86
86
  }
87
+ // src/running.ts
88
+ /** The summary of no value. It is the unit of `mergeRunning`. */
89
+ const EMPTY_RUNNING = Object.freeze({
90
+ n: 0,
91
+ sum: 0,
92
+ min: Infinity,
93
+ max: -Infinity,
94
+ m2: 0
95
+ });
96
+ /**
97
+ * This function gives the summary with one more value. It throws a RangeError for NaN, as the functions of a list do.
98
+ * The mean of each step is `sum / n`, so the mean of the fold is the mean of the list.
99
+ */
100
+ function addToRunning(s, value) {
101
+ if (Number.isNaN(value)) throw new RangeError("addToRunning: the value is NaN.");
102
+ const sum = s.sum + value;
103
+ if (s.n === 0) return {
104
+ n: 1,
105
+ sum,
106
+ min: value,
107
+ max: value,
108
+ m2: 0
109
+ };
110
+ const n = s.n + 1;
111
+ const m2 = s.m2 + (value - s.sum / s.n) * (value - sum / n);
112
+ return {
113
+ n,
114
+ sum,
115
+ min: Math.min(s.min, value),
116
+ max: Math.max(s.max, value),
117
+ m2
118
+ };
119
+ }
120
+ /** This function gives the summary of the values of a list or another iterable, in their order. */
121
+ function runningOf(values) {
122
+ let s = EMPTY_RUNNING;
123
+ for (const v of values) s = addToRunning(s, v);
124
+ return s;
125
+ }
126
+ /**
127
+ * This function gives the summary of the values of two summaries (Chan, Golub and LeVeque, 1979). Thus parallel jobs
128
+ * can each summarize a part. The sum of the merge adds the two sums, so it can differ from the fold in the last bits.
129
+ */
130
+ function mergeRunning(a, b) {
131
+ if (a.n === 0) return b;
132
+ if (b.n === 0) return a;
133
+ const n = a.n + b.n;
134
+ const delta = b.sum / b.n - a.sum / a.n;
135
+ return {
136
+ n,
137
+ sum: a.sum + b.sum,
138
+ min: Math.min(a.min, b.min),
139
+ max: Math.max(a.max, b.max),
140
+ m2: a.m2 + b.m2 + delta * delta * a.n / n * b.n
141
+ };
142
+ }
143
+ /** This function gives the mean of the values: `sum / n`. It throws a RangeError for the empty summary. */
144
+ function runningMean(s) {
145
+ if (s.n === 0) throw new RangeError("runningMean: the summary is empty.");
146
+ return s.sum / s.n;
147
+ }
148
+ /**
149
+ * This function gives the sample standard deviation of the values (the divisor is n - 1). It needs 2 values or more.
150
+ * Equal values give exactly 0, as `sd` gives. A rounding error cannot make the result NaN.
151
+ */
152
+ function runningSd(s) {
153
+ if (s.n < 2) throw new RangeError("runningSd: the summary needs 2 values or more.");
154
+ if (s.min === s.max) return 0;
155
+ return Math.sqrt(Math.max(0, s.m2) / (s.n - 1));
156
+ }
87
157
  // src/regression.ts
88
158
  /**
89
159
  * The relative tolerance of the rank test. A column is dependent when the part of it that is orthogonal to the
@@ -2432,24 +2502,61 @@ function sobolIndices(record, measure, options = {}) {
2432
2502
  function whole$2(name, value) {
2433
2503
  if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`${name}: ${value} is not a whole number of 0 or more.`);
2434
2504
  }
2435
- /** The log of each binomial term C(n, k) / 2^n, for each k from 0 to n. */
2436
- function halfBinomialLogs(n) {
2437
- const logs = [];
2438
- let logChoose = 0;
2439
- for (let i = 0; i <= n; i++) {
2440
- if (i > 0) logChoose += Math.log((n - i + 1) / i);
2441
- logs.push(logChoose - n * Math.LN2);
2505
+ const TWO_512 = 2 ** 512;
2506
+ /** C(n, k) / 2^n, as one product of min(k, n - k) ratios, with the powers of 2 kept apart so that no step overflows. */
2507
+ function halfBinomial(k, n) {
2508
+ const m = Math.min(k, n - k);
2509
+ let value = 1;
2510
+ let exponent = -n;
2511
+ for (let i = 1; i <= m; i++) {
2512
+ value *= (n - m + i) / i;
2513
+ if (value > TWO_512) {
2514
+ value /= TWO_512;
2515
+ exponent += 512;
2516
+ }
2442
2517
  }
2443
- return logs;
2518
+ for (; exponent < -512; exponent += 512) value /= TWO_512;
2519
+ return value * 2 ** exponent;
2520
+ }
2521
+ /** The largest n for which the tail is an exact sum of whole numbers. Above it, the sum is in floating point. */
2522
+ const SIGN_TEST_EXACT_LIMIT = 4096;
2523
+ /** num / 2^n as the nearest double: one rounding, also when num has more than 1024 bits. */
2524
+ function overPowerOfTwo(num, n) {
2525
+ const shift = Math.max(0, num.toString(2).length - 1e3);
2526
+ let value = Number(num >> BigInt(shift));
2527
+ let exponent = shift - n;
2528
+ for (; exponent < -512; exponent += 512) value /= TWO_512;
2529
+ return value * 2 ** exponent;
2444
2530
  }
2445
- /** P(X >= k) for X ~ Binomial(n, 1/2), summed from the largest term so that a small tail keeps its digits. */
2531
+ /**
2532
+ * P(X >= k) for X ~ Binomial(n, 1/2). For n up to SIGN_TEST_EXACT_LIMIT it adds C(n, i) as whole numbers (BigInt),
2533
+ * so the only error is the last rounding to a double. Above the limit and above the middle, it adds the terms as
2534
+ * ratios of term k in linear space. At or below the middle, it gives 1 - P(X >= n - k + 1), by symmetry. (An earlier form added
2535
+ * logs and called Math.exp, and its error grew with n: up to 2.5e-14 for n <= 80, rigor#158. The floating-point
2536
+ * form above the limit was at most 1.1e-14 relative at n = 4097 and 5000, above 2^-1000.)
2537
+ */
2446
2538
  function upperTail(k, n) {
2447
2539
  if (k <= 0) return 1;
2448
2540
  if (k > n) return 0;
2449
- const logs = halfBinomialLogs(n).slice(k);
2450
- const top = Math.max(...logs);
2451
- const sum = logs.reduce((s, l) => s + Math.exp(l - top), 0);
2452
- return Math.min(1, Math.exp(top) * sum);
2541
+ if (n <= SIGN_TEST_EXACT_LIMIT) {
2542
+ const big = BigInt(n);
2543
+ let term = 1n;
2544
+ for (let i = 1n; i <= BigInt(k); i++) term = term * (big - i + 1n) / i;
2545
+ let sum = 0n;
2546
+ for (let i = BigInt(k); i <= big; i++) {
2547
+ sum += term;
2548
+ term = term * (big - i) / (i + 1n);
2549
+ }
2550
+ return Math.min(1, overPowerOfTwo(sum, n));
2551
+ }
2552
+ if (2 * k <= n) return 1 - upperTail(n - k + 1, n);
2553
+ let ratio = 1;
2554
+ let sum = 1;
2555
+ for (let i = k; i < n && ratio > 0; i++) {
2556
+ ratio *= (n - i) / (i + 1);
2557
+ sum += ratio;
2558
+ }
2559
+ return Math.min(1, halfBinomial(k, n) * sum);
2453
2560
  }
2454
2561
  /**
2455
2562
  * The sign test of paired results: `better` inputs where the candidate wins and `worse` where it loses. The ties
@@ -2470,7 +2577,15 @@ function signTest(better, worse, sides = 1) {
2470
2577
  */
2471
2578
  function signTestPower(n, level = .05, sides = 2) {
2472
2579
  whole$2("signTestPower", n);
2473
- for (let k = Math.ceil(n / 2); k <= n; k++) if (signTest(k, n - k, sides) < level) return k;
2580
+ if (n === 0 || signTest(n, 0, sides) >= level) return void 0;
2581
+ let low = Math.ceil(n / 2);
2582
+ let high = n;
2583
+ while (low < high) {
2584
+ const middle = Math.floor((low + high) / 2);
2585
+ if (signTest(middle, n - middle, sides) < level) high = middle;
2586
+ else low = middle + 1;
2587
+ }
2588
+ return low;
2474
2589
  }
2475
2590
  /** The z of a two-sided 95% interval. */
2476
2591
  const Z95 = 1.959963984540054;
@@ -4097,6 +4212,6 @@ function inverseDiagonal(hessian, k) {
4097
4212
  }
4098
4213
  return out;
4099
4214
  }
4100
- export { KENDALL_EXACT, RESPONSE_LAMBDAS, RESPONSE_MAX_POWER, RESPONSE_MAX_TERMS, RESPONSE_RECORDS_SCHEMA, SIGN_FLIP_EXACT_LIMIT, SIGN_FLIP_EXACT_MAX, U_STATISTIC_TIGHT_MIN_SAMPLE, Z95, bestSmoothLaw, binomialInterval, binomialTest, bootstrap, bootstrapClusters, bootstrapLeastSquares, bootstrapMedian, bootstrapMedianRatio, bootstrapStrata, bootstrapTwo, bradleyTerry, brier, calibration, cohenKappa, compareRatios, coverageMinSample, eloExpected, eloUpdate, fitResponse, glicko2Idle, glicko2Update, heldOutError, heldOutErrorAt, holm, kendallTau, leastSquares, logLoss, mean, median, medianInterval, modeCount, negativeBinomialInterval, noiseFloor, noiseVerdict, normalCdf, normalQuantile, optionFloor, pairProbabilities, pairedPermutation, parseResponseRecord, partialConjunction, predictResponse, quantile, quantileInterval, quantileSamples, quantileSorted, ranks, ratingToStrength, responseCells, ridgeSolve, sampleTotalInterval, sd, signFlipTest, signTest, signTestPower, sliceResponse, smoothLawScores, sobolIndices, sorted, spearman, strengthToRating, summarize, surfaceResponse, tQuantile, twoSamplePermutation, uStatisticInterval, whenHolds, wilson, wilsonSampleSize };
4215
+ export { EMPTY_RUNNING, KENDALL_EXACT, RESPONSE_LAMBDAS, RESPONSE_MAX_POWER, RESPONSE_MAX_TERMS, RESPONSE_RECORDS_SCHEMA, SIGN_FLIP_EXACT_LIMIT, SIGN_FLIP_EXACT_MAX, U_STATISTIC_TIGHT_MIN_SAMPLE, Z95, addToRunning, bestSmoothLaw, binomialInterval, binomialTest, bootstrap, bootstrapClusters, bootstrapLeastSquares, bootstrapMedian, bootstrapMedianRatio, bootstrapStrata, bootstrapTwo, bradleyTerry, brier, calibration, cohenKappa, compareRatios, coverageMinSample, eloExpected, eloUpdate, fitResponse, glicko2Idle, glicko2Update, heldOutError, heldOutErrorAt, holm, kendallTau, leastSquares, logLoss, mean, median, medianInterval, mergeRunning, modeCount, negativeBinomialInterval, noiseFloor, noiseVerdict, normalCdf, normalQuantile, optionFloor, pairProbabilities, pairedPermutation, parseResponseRecord, partialConjunction, predictResponse, quantile, quantileInterval, quantileSamples, quantileSorted, ranks, ratingToStrength, responseCells, ridgeSolve, runningMean, runningOf, runningSd, sampleTotalInterval, sd, signFlipTest, signTest, signTestPower, sliceResponse, smoothLawScores, sobolIndices, sorted, spearman, strengthToRating, summarize, surfaceResponse, tQuantile, twoSamplePermutation, uStatisticInterval, whenHolds, wilson, wilsonSampleSize };
4101
4216
 
4102
4217
  //# sourceMappingURL=index.js.map