@mark1russell7/rigor-statistics 0.1.25 → 0.1.27

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
@@ -191,7 +191,7 @@ logLoss([{ p: p.a, hit: true }]); // the probability of the obser
191
191
  | `spearman`, `kendallTau`, `ranks` | The rank correlations, with mean ranks for ties. |
192
192
  | `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. |
193
193
  | `optionFloor({ sigma, delta, tests, alpha, power })`, `tQuantile(p, df)` | The fewest values for each of two options, so that one test of a Bonferroni family finds a difference of `delta` with the stated power, from the Student t law. It assumes unpaired groups of equal size and equal `sigma`. The quantile of the Student t law. |
194
- | `normalCdf(x)`, `normalQuantile(p)` | The distribution function of the standard normal law and its quantile (AS 241 of Wichura). Both keep their relative digits in the lower tail, to `p = 1e-300`. |
194
+ | `normalCdf(x)`, `normalQuantile(p)` | The distribution function of the standard normal law and its quantile (AS 241 of Wichura). They come from `rigor-generators`. Both keep their relative digits in the lower tail, to `p = 1e-300`. |
195
195
  | `modeCount(values, { minShare, valleyRatio })` | The count of the modes of a sample, from a kernel density estimate. |
196
196
  | `smoothLawScores(values)`, `bestSmoothLaw(values)` | The mean log density of the uniform, normal, exponential, log-normal and Pareto laws at their fits, and the best of them. |
197
197
  | `brier`, `calibration` | The Brier score of predictions, and the hit rate of each stated level. |
@@ -291,8 +291,6 @@ The tests prove that these functions give the same numbers as the copies in the
291
291
  | `bootstrapMedian` of packing | `bootstrapMedian(sortedValues, { runs, level, seed })`. Give the values sorted, because packing draws from the sorted list. |
292
292
  | `bootstrapMedian` of highways | `bootstrap(values, (s) => quantile(s, 0.5), { runs, level, seed })` |
293
293
  | `bootstrap` of layout-contract | `bootstrapClusters(rows, (r) => r.cluster, statistic, { runs, seed, ends: [0.025, 0.975] })` |
294
- | The stratified bootstrap of `verdict` of layout-contract | `bootstrapStrata(families, meanOfMeans, { runs, seed: deriveSeed(seed, "verdict.stratified"), ends })` |
295
- | The permutation test of `verdict` of layout-contract | `signFlipTest(terms, { exactMax, runs, seed: deriveSeed(seed, "verdict.permutation") })` |
296
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. |
297
295
  | `signTestP` of packing | `signTest(better, worse)` |
298
296
  | `signTestPower` of highways | `signTestPower(n, level)` |
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import "@mark1russell7/rigor-generators";
1
+ import { normalCdf, normalQuantile } from "@mark1russell7/rigor-generators";
2
2
  /**
3
3
  * The descriptive statistics: the mean, the standard deviation, the median, the quantiles and a summary of a list.
4
4
  * Each function throws a RangeError for an empty list or for a value that is NaN. Thus a missing value cannot make a
@@ -1278,20 +1278,6 @@ interface OptionFloorOptions {
1278
1278
  * @returns A whole number of 2 or more.
1279
1279
  */
1280
1280
  export declare function optionFloor(options: OptionFloorOptions): number;
1281
- /**
1282
- * This function gives the distribution function of the standard normal law, `P(Z <= x)`. Its relative error is below
1283
- * 1e-14, also in the lower tail: `normalCdf(-37)` is approximately 5.7e-300, not 0.
1284
- *
1285
- * @param x - A number. `-Infinity` gives 0 and `Infinity` gives 1.
1286
- */
1287
- export declare function normalCdf(x: number): number;
1288
- /**
1289
- * This function gives the quantile of the standard normal law, the `x` with `normalCdf(x) = p`. It uses PPND16 of
1290
- * Wichura (algorithm AS 241). Its relative error is near 1e-16 for each `p` from 1e-300 to 1 - 1e-16.
1291
- *
1292
- * @param p - The share of the law below the result, from 0 to 1. A `p` of 0 gives `-Infinity` and 1 gives `Infinity`.
1293
- */
1294
- export declare function normalQuantile(p: number): number;
1295
1281
  /** One cell of a coverage study: the hits of a method on the true value in `draws` seeded samples of size `sample`. */
1296
1282
  interface CoverageCell {
1297
1283
  /** The name of the cell, for example `"skewed 120/108"`. The result names the rejected cells with it. */
@@ -1652,5 +1638,5 @@ interface BradleyTerryFit {
1652
1638
  * outcome, a bad weight and a bad option.
1653
1639
  */
1654
1640
  export declare function bradleyTerry(items: number, comparisons: readonly PairComparison[], options?: BradleyTerryOptions): BradleyTerryFit;
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 };
1641
+ export { type BinomialSide, type BootstrapOptions, type BradleyTerryFit, type BradleyTerryOptions, type CalibrationLevel, type CategoricalDimension, type CompareOptions, type Comparison, type ContinuousDimension, type Corrected, type CountInterval, type CoverageBar, type CoverageCell, type CoverageMinSample, type CoverageReason, type CoverageStep, type Effect, type EloOptions, type EloUpdate, type Forecast, type Glicko2Game, type Glicko2Options, type Glicko2Rating, type Interval, type Kappa, type LeastSquaresFit, type LeastSquaresOptions, type MedianInterval, type ModeOptions, type NoiseOptions, type NoiseState, type NoiseVerdict, type OptionFloorOptions, type OrdinalDimension, type PairComparison, type PairOutcome, type PairProbabilities, type ParsedResponseRecord, type PermutationOptions, type PermutationResult, type Proportion, type QuantileInterval, type QuantileMethod, type RatingScale, type ResponseAbsentPoint, type ResponseBand, type ResponseCurvePoint, type ResponseData, type ResponseDimension, type ResponseDimensionBase, type ResponseFactor, type ResponseFault, type ResponseFitOptions, type ResponseFold, type ResponseFoldError, type ResponseHeldOutError, type ResponseInputValue, type ResponseMeasure, type ResponseModel, type ResponseModelBase, type ResponsePoint, type ResponseReason, type ResponseRecord, type ResponseSlice, type ResponseSliceOptions, type ResponseSlicePoint, type ResponseSurface, type ResponseSurfaceAbsentPoint, type ResponseSurfaceOptions, type ResponseSurfacePoint, type ResponseTableCell, type ResponseValue, type ResponseViewOptions, type ResponseWhen, type RidgeInput, type RidgeInputBase, type RidgeLevelInput, type RidgeNumberInput, type RidgeOptions, type RidgeRankInput, type RidgeResponseModel, type RidgeTerm, type RunningSummary, type SampleTotalOptions, type SideP, type SignFlipOptions, type SignFlipResult, type SmoothLaw, type SmoothLawScore, type SobolIndex, type SobolIndices, type SobolOptions, type Summary, type TableResponseModel, type TieModel, type TwoSamplePermutationOptions, type TwoSamplePermutationResult, type UStatisticInterval, type UStatisticMean, type UStatisticMethod, type UStatisticOptions, normalCdf, normalQuantile };
1656
1642
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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,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;;;;;;;;;;UCvGrC;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;qBAIE,eAAe;;;;;wBAMZ,aAAa,GAAG,gBAAgB,gBAAgB;;wBAWhD,UAAU,QAAQ,mBAAmB;;;;;wBAUrC,aAAa,GAAG,gBAAgB,GAAG,iBAAiB;;wBAepD,YAAY,GAAG;;;;;wBASf,UAAU,GAAG;;;;;;UCrEZ;;WAEN;;UAGM;;WAEN;;WAEA;;;;;WAKA;;WAEA;;WAEA;;;;;;;;;;;wBAkBK,aAAa,mCAAmC,sBAAsB,UAAS,sBAA2B;UC7BzG;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;;;;WAMT;;;;;WAKA;;;UAIM;;WAEN;;WAEA;;WAEA;;UAGM,iBAAiB,QAAQ;;WAE/B;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;;;;;wBAOK,UAAU,GAAG,eAAe,KAAK,YAAY,iBAAiB,gBAAgB,UAAS,mBAAwB;;;;;;;;wBAsB/G,aAAa,GAAG,GAC9B,YAAY,KACZ,YAAY,KACZ,YAAY,YAAY,KAAK,YAAY,gBACzC,UAAS,mBACR;;;;;;wBAwBa,qBAAqB,8BAA8B,gCAAgC,UAAS,mBAAwB;;;;;;;wBAUpH,sBACd,mCACA,sBACA,U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AEN;;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/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;;;;;;;;;;UCvGrC;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;qBAIE,eAAe;;;;;wBAMZ,aAAa,GAAG,gBAAgB,gBAAgB;;wBAWhD,UAAU,QAAQ,mBAAmB;;;;;wBAUrC,aAAa,GAAG,gBAAgB,GAAG,iBAAiB;;wBAepD,YAAY,GAAG;;;;;w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AAQ;;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;;;;;;;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"}
package/build/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { random } from "@mark1russell7/rigor-generators";
1
+ import { normalCdf, normalQuantile, random } from "@mark1russell7/rigor-generators";
2
2
  // src/describe.ts
3
3
  function checked(name, values) {
4
4
  if (values.length === 0) throw new RangeError(`${name}: the list is empty.`);
@@ -2502,24 +2502,61 @@ function sobolIndices(record, measure, options = {}) {
2502
2502
  function whole$2(name, value) {
2503
2503
  if (!Number.isSafeInteger(value) || value < 0) throw new RangeError(`${name}: ${value} is not a whole number of 0 or more.`);
2504
2504
  }
2505
- /** The log of each binomial term C(n, k) / 2^n, for each k from 0 to n. */
2506
- function halfBinomialLogs(n) {
2507
- const logs = [];
2508
- let logChoose = 0;
2509
- for (let i = 0; i <= n; i++) {
2510
- if (i > 0) logChoose += Math.log((n - i + 1) / i);
2511
- 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
+ }
2512
2517
  }
2513
- 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;
2514
2530
  }
2515
- /** 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
+ */
2516
2538
  function upperTail(k, n) {
2517
2539
  if (k <= 0) return 1;
2518
2540
  if (k > n) return 0;
2519
- const logs = halfBinomialLogs(n).slice(k);
2520
- const top = Math.max(...logs);
2521
- const sum = logs.reduce((s, l) => s + Math.exp(l - top), 0);
2522
- 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);
2523
2560
  }
2524
2561
  /**
2525
2562
  * The sign test of paired results: `better` inputs where the candidate wins and `worse` where it loses. The ties
@@ -2540,7 +2577,15 @@ function signTest(better, worse, sides = 1) {
2540
2577
  */
2541
2578
  function signTestPower(n, level = .05, sides = 2) {
2542
2579
  whole$2("signTestPower", n);
2543
- 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;
2544
2589
  }
2545
2590
  /** The z of a two-sided 95% interval. */
2546
2591
  const Z95 = 1.959963984540054;
@@ -3321,162 +3366,6 @@ function optionFloor(options) {
3321
3366
  }
3322
3367
  throw new RangeError(`optionFloor: no count under 10,000,000 for sigma ${sigma} and delta ${delta}.`);
3323
3368
  }
3324
- // src/normal.ts
3325
- /**
3326
- * The standard normal law: its distribution function `normalCdf` and its quantile `normalQuantile`. The two functions
3327
- * keep their relative digits in the far tails, so a small tail probability does not become 0.
3328
- */
3329
- const SQRT_PI = Math.sqrt(Math.PI);
3330
- /** The series of `erf(z)` with positive terms, `2/√π · e^(-z²) · Σ (2z²)^n · z / (1·3·…·(2n+1))`, for a small `z` of 0 or more. */
3331
- function erfSeries(z) {
3332
- const twoZ2 = 2 * z * z;
3333
- let term = z;
3334
- let sum = z;
3335
- for (let n = 1; n < 500 && term > sum * 1e-17; n++) {
3336
- term *= twoZ2 / (2 * n + 1);
3337
- sum += term;
3338
- }
3339
- return 2 / SQRT_PI * expMinusSquare(z) * sum;
3340
- }
3341
- /**
3342
- * The continued fraction of `erfc(z)`, `e^(-z²)/√π · 1/(z + (1/2)/(z + 1/(z + (3/2)/(z + …))))`, by the method of
3343
- * Lentz, for a `z` of 1.5 or more.
3344
- */
3345
- function erfcFraction(z) {
3346
- const tiny = 1e-300;
3347
- let f = z;
3348
- let c = z;
3349
- let d = 0;
3350
- for (let n = 1; n < 5e3; n++) {
3351
- const a = n / 2;
3352
- d = z + a * d;
3353
- d = 1 / (Math.abs(d) < tiny ? tiny : d);
3354
- c = z + a / c;
3355
- if (Math.abs(c) < tiny) c = tiny;
3356
- const delta = c * d;
3357
- f *= delta;
3358
- if (Math.abs(delta - 1) < 1e-16) break;
3359
- }
3360
- return expMinusSquare(z) / (SQRT_PI * f);
3361
- }
3362
- /**
3363
- * The value of `e^(-z²)` with its relative digits for a large `z`. The rounding of `z²` costs `z²` ulps, so the
3364
- * function splits `z` into `hi + lo`. `hi` has 4 bits after the point, so `hi²` is exact.
3365
- */
3366
- function expMinusSquare(z) {
3367
- const hi = Math.round(z * 16) / 16;
3368
- const lo = z - hi;
3369
- return Math.exp(-hi * hi) * Math.exp(-lo * (z + hi));
3370
- }
3371
- /** The complementary error function `erfc(z) = 1 - erf(z)`, with its relative digits for a large `z`. */
3372
- function erfc(z) {
3373
- if (z < 0) return 2 - erfc(-z);
3374
- return z < 1.5 ? 1 - erfSeries(z) : erfcFraction(z);
3375
- }
3376
- /**
3377
- * This function gives the distribution function of the standard normal law, `P(Z <= x)`. Its relative error is below
3378
- * 1e-14, also in the lower tail: `normalCdf(-37)` is approximately 5.7e-300, not 0.
3379
- *
3380
- * @param x - A number. `-Infinity` gives 0 and `Infinity` gives 1.
3381
- */
3382
- function normalCdf(x) {
3383
- if (Number.isNaN(x)) throw new RangeError("normalCdf: x is NaN.");
3384
- if (x === Number.NEGATIVE_INFINITY) return 0;
3385
- if (x === Number.POSITIVE_INFINITY) return 1;
3386
- return erfc(-x / Math.SQRT2) / 2;
3387
- }
3388
- const A = [
3389
- 3.3871328727963665,
3390
- 133.14166789178438,
3391
- 1971.5909503065513,
3392
- 13731.69376550946,
3393
- 45921.95393154987,
3394
- 67265.7709270087,
3395
- 33430.57558358813,
3396
- 2509.0809287301227
3397
- ];
3398
- const B = [
3399
- 1,
3400
- 42.31333070160091,
3401
- 687.1870074920579,
3402
- 5394.196021424751,
3403
- 21213.794301586597,
3404
- 39307.89580009271,
3405
- 28729.085735721943,
3406
- 5226.495278852854
3407
- ];
3408
- const C = [
3409
- 1.4234371107496835,
3410
- 4.630337846156546,
3411
- 5.769497221460691,
3412
- 3.6478483247632045,
3413
- 1.2704582524523684,
3414
- .2417807251774506,
3415
- .022723844989269184,
3416
- .0007745450142783414
3417
- ];
3418
- const D = [
3419
- 1,
3420
- 2.053191626637759,
3421
- 1.6763848301838038,
3422
- .6897673349851,
3423
- .14810397642748008,
3424
- .015198666563616457,
3425
- .0005475938084995345,
3426
- 1.0507500716444169e-9
3427
- ];
3428
- const E = [
3429
- 6.657904643501103,
3430
- 5.463784911164114,
3431
- 1.7848265399172913,
3432
- .29656057182850487,
3433
- .026532189526576124,
3434
- .0012426609473880784,
3435
- 27115555687434876e-21,
3436
- 2.0103343992922881e-7
3437
- ];
3438
- const F = [
3439
- 1,
3440
- .599832206555888,
3441
- .1369298809227358,
3442
- .014875361290850615,
3443
- .0007868691311456133,
3444
- 18463183175100548e-21,
3445
- 1.421511758316446e-7,
3446
- 20442631033899397e-31
3447
- ];
3448
- /** The value of a polynomial with the coefficients `c[0] + c[1] x + …`, by the rule of Horner. */
3449
- function poly(c, x) {
3450
- let value = 0;
3451
- for (let i = c.length - 1; i >= 0; i--) value = value * x + c[i];
3452
- return value;
3453
- }
3454
- /**
3455
- * This function gives the quantile of the standard normal law, the `x` with `normalCdf(x) = p`. It uses PPND16 of
3456
- * Wichura (algorithm AS 241). Its relative error is near 1e-16 for each `p` from 1e-300 to 1 - 1e-16.
3457
- *
3458
- * @param p - The share of the law below the result, from 0 to 1. A `p` of 0 gives `-Infinity` and 1 gives `Infinity`.
3459
- */
3460
- function normalQuantile(p) {
3461
- if (!(p >= 0 && p <= 1)) throw new RangeError(`normalQuantile: p is from 0 to 1, not ${p}.`);
3462
- if (p === 0) return Number.NEGATIVE_INFINITY;
3463
- if (p === 1) return Number.POSITIVE_INFINITY;
3464
- const q = p - .5;
3465
- if (Math.abs(q) <= .425) {
3466
- const r = .180625 - q * q;
3467
- return q * poly(A, r) / poly(B, r);
3468
- }
3469
- let r = Math.sqrt(-Math.log(q < 0 ? p : 1 - p));
3470
- let value;
3471
- if (r <= 5) {
3472
- r -= 1.6;
3473
- value = poly(C, r) / poly(D, r);
3474
- } else {
3475
- r -= 5;
3476
- value = poly(E, r) / poly(F, r);
3477
- }
3478
- return q < 0 ? -value : value;
3479
- }
3480
3369
  // src/coverage.ts
3481
3370
  /**
3482
3371
  * The rule that finds the smallest sample at which an interval method keeps its level. The input is the hits of the