@mark1russell7/rigor-statistics 0.1.16 → 0.1.17

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
@@ -118,6 +118,8 @@ The default expansion has one product for each pair of levels of two dimensions.
118
118
  | `pairedPermutation(candidate, baseline, options)` | The paired permutation test (random sign flips). It uses the size of each difference. |
119
119
  | `twoSamplePermutation(a, b, options)` | The two-sample permutation test (a split of the pooled values). It reads each split when their count is `runs` or less, so the p is exact. It compares groups of different sizes, and its default statistic is the difference of the medians. |
120
120
  | `wilson(k, n, z)` | The Wilson interval of a proportion. |
121
+ | `wilsonSampleSize(target, expected, z, max)` | The smallest number of trials at which the Wilson lower end reaches the target, at the expected proportion. |
122
+ | `cohenKappa(a, b)` | The agreement of two raters beyond chance (Cohen's kappa), with the observed and the chance agreement. |
121
123
  | `medianInterval(values, level)` | The distribution-free interval of a median, from two order statistics. It gives `low`, `high`, the `rank` of `low` and the `coverage`. |
122
124
  | `quantileInterval(values, p, level)` | The distribution-free interval of a quantile, from two order statistics. A side with no rank is infinite. The values must be independent draws. |
123
125
  | `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. |
package/build/index.d.ts CHANGED
@@ -822,6 +822,28 @@ interface TwoSamplePermutationResult extends PermutationResult {
822
822
  * random splits. A drawn p has noise: a level of 0.001 is 10 counts at 10 000 runs. So give enough runs for a small level.
823
823
  */
824
824
  export declare function twoSamplePermutation(a: readonly number[], b: readonly number[], options?: TwoSamplePermutationOptions): TwoSamplePermutationResult;
825
+ /**
826
+ * The smallest number of trials `n` at which the Wilson lower end reaches `target`, when the true proportion is
827
+ * `expected`. Each `n` takes `round(expected × n)` successes. The function gives `undefined` when `expected` is not
828
+ * above `target`, or when no `n` up to `max` reaches it. An audit of an agreement uses it to fix its size.
829
+ */
830
+ export declare function wilsonSampleSize(target: number, expected: number, z?: number, max?: number): number | undefined;
831
+ /** The agreement of two raters that give one category to each item. */
832
+ interface Kappa {
833
+ /** The number of items. */
834
+ readonly n: number;
835
+ /** The part of the items where the two raters give the same category. */
836
+ readonly observed: number;
837
+ /** The part of agreement that two independent raters with the same frequencies of categories give. */
838
+ readonly chance: number;
839
+ /** Cohen's kappa: `(observed − chance) / (1 − chance)`. It is `undefined` when `chance` is 1. */
840
+ readonly kappa: number | undefined;
841
+ }
842
+ /**
843
+ * Cohen's kappa of two raters (Cohen, 1960). Item `i` has the category `a[i]` from one rater and `b[i]` from the
844
+ * other. Two categories are the same when they are `===`. A kappa of 1 is full agreement, and 0 is the agreement of chance.
845
+ */
846
+ export declare function cohenKappa<T>(a: readonly T[], b: readonly T[]): Kappa;
825
847
  /** The ranks of the values, from 1. Equal values get the mean of their ranks. */
826
848
  export declare function ranks(values: readonly number[]): number[];
827
849
  /**
@@ -1047,5 +1069,5 @@ interface OptionFloorOptions {
1047
1069
  * @returns A whole number of 2 or more.
1048
1070
  */
1049
1071
  export declare function optionFloor(options: OptionFloorOptions): number;
1050
- export type { BootstrapOptions, CalibrationLevel, CategoricalDimension, CompareOptions, Comparison, ContinuousDimension, Corrected, CountInterval, Effect, Forecast, Interval, 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, SideP, SmoothLaw, SmoothLawScore, Summary, TableResponseModel, TwoSamplePermutationOptions, TwoSamplePermutationResult };
1072
+ 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, SideP, SmoothLaw, SmoothLawScore, Summary, TableResponseModel, TwoSamplePermutationOptions, TwoSamplePermutationResult };
1051
1073
  //# 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/rank.ts","../src/discrete.ts","../src/compare.ts","../src/power.ts"],"mappings":";;;;;;KAOY;;wBAmBI,OAAO;wBAIP,KAAK;;;;;wBAgBL,GAAG;;;;;;;wBAgBH,eAAe,iCAAi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ACA;;;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"}
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"],"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;UC/BzG;;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,UAAS,mBAAm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AqBxD;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;wBAUK,iBAAiB,2BAA2B,WAAW,iBAAe;;;;;;wBAsCtE,gBAAgB,WAAW;;UAW1B;WACN;WACA;;WAEA;;;;;;;wBAQK,iBAAiB,WAAW,WAAW,iBAAe;;;;;;wBA2BtD,yBAAyB,mBAAmB,WAAW,iBAAe;UCvKrE;;WAEN;;WAEA;;;;;;WAMA;;;;;;wBAgBK,WAAW,2BAA2B,UAAS;;;;;KASnD;;UAGK;;WAEN;WACA;;WAEA;;WAEA;WACA;;WAEA;WACA,OAAO;;;;;;;;wBASF,aAAa,2BAA2B,UAAS;WAA0B;IAAqC;UAW/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"}
package/build/index.js CHANGED
@@ -2405,6 +2405,46 @@ function twoSamplePermutation(a, b, options = {}) {
2405
2405
  exact: false
2406
2406
  };
2407
2407
  }
2408
+ /**
2409
+ * The smallest number of trials `n` at which the Wilson lower end reaches `target`, when the true proportion is
2410
+ * `expected`. Each `n` takes `round(expected × n)` successes. The function gives `undefined` when `expected` is not
2411
+ * above `target`, or when no `n` up to `max` reaches it. An audit of an agreement uses it to fix its size.
2412
+ */
2413
+ function wilsonSampleSize(target, expected, z = Z95, max = 1e6) {
2414
+ if (!(target >= 0 && target <= 1 && expected >= 0 && expected <= 1)) throw new RangeError(`wilsonSampleSize: target ${target} and expected ${expected} must be from 0 to 1.`);
2415
+ whole$1("wilsonSampleSize", max);
2416
+ if (expected <= target) return void 0;
2417
+ for (let n = 1; n <= max; n++) if (wilson(Math.round(expected * n), n, z).low >= target) return n;
2418
+ }
2419
+ // src/agreement.ts
2420
+ /**
2421
+ * Cohen's kappa of two raters (Cohen, 1960). Item `i` has the category `a[i]` from one rater and `b[i]` from the
2422
+ * other. Two categories are the same when they are `===`. A kappa of 1 is full agreement, and 0 is the agreement of chance.
2423
+ */
2424
+ function cohenKappa(a, b) {
2425
+ if (a.length !== b.length) throw new RangeError(`cohenKappa: the raters have ${a.length} and ${b.length} items.`);
2426
+ const n = a.length;
2427
+ if (n === 0) throw new RangeError("cohenKappa: there are no items.");
2428
+ const countA = /* @__PURE__ */ new Map();
2429
+ const countB = /* @__PURE__ */ new Map();
2430
+ let same = 0;
2431
+ for (let i = 0; i < n; i++) {
2432
+ const x = a[i];
2433
+ const y = b[i];
2434
+ if (x === y) same++;
2435
+ countA.set(x, (countA.get(x) ?? 0) + 1);
2436
+ countB.set(y, (countB.get(y) ?? 0) + 1);
2437
+ }
2438
+ let chance = 0;
2439
+ for (const [category, count] of countA) chance += count / n * ((countB.get(category) ?? 0) / n);
2440
+ const observed = same / n;
2441
+ return {
2442
+ n,
2443
+ observed,
2444
+ chance,
2445
+ kappa: chance === 1 ? void 0 : (observed - chance) / (1 - chance)
2446
+ };
2447
+ }
2408
2448
  // src/rank.ts
2409
2449
  /**
2410
2450
  * Rank correlation: do two measures put the same items in the same order? Use it to test that a cheap proxy (a
@@ -2896,6 +2936,6 @@ function optionFloor(options) {
2896
2936
  }
2897
2937
  throw new RangeError(`optionFloor: no count under 10,000,000 for sigma ${sigma} and delta ${delta}.`);
2898
2938
  }
2899
- export { KENDALL_EXACT, RESPONSE_LAMBDAS, RESPONSE_MAX_POWER, RESPONSE_MAX_TERMS, RESPONSE_RECORDS_SCHEMA, Z95, bestSmoothLaw, binomialInterval, bootstrap, bootstrapClusters, bootstrapLeastSquares, bootstrapMedian, bootstrapMedianRatio, bootstrapTwo, brier, calibration, 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, sd, signTest, signTestPower, sliceResponse, smoothLawScores, sorted, spearman, summarize, surfaceResponse, tQuantile, twoSamplePermutation, whenHolds, wilson };
2939
+ export { KENDALL_EXACT, RESPONSE_LAMBDAS, RESPONSE_MAX_POWER, RESPONSE_MAX_TERMS, RESPONSE_RECORDS_SCHEMA, 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, sd, signTest, signTestPower, sliceResponse, smoothLawScores, sorted, spearman, summarize, surfaceResponse, tQuantile, twoSamplePermutation, whenHolds, wilson, wilsonSampleSize };
2900
2940
 
2901
2941
  //# sourceMappingURL=index.js.map