accuracy-claim-kit 0.1.0 → 0.1.1
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/CHANGELOG.md +7 -0
- package/README.md +1 -7
- package/dist/assess.js +41 -33
- package/dist/assess.js.map +1 -1
- package/dist/format.d.ts +11 -0
- package/dist/format.js +36 -0
- package/dist/format.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.1.1] - 2026-11-18
|
|
4
|
+
|
|
5
|
+
Wording fix. No verdict, threshold or API change.
|
|
6
|
+
|
|
7
|
+
- Keep nonzero and imperfect point rates distinct from absolute 0% and 100% in fixed-set statements and explanations, sample advice, and quoted claim values. Add digits only when the usual rounding would reach an endpoint; real endpoints and ordinary formatting stay the same. Verdicts, parsing, precision checks and Wilson bounds are unchanged.
|
|
8
|
+
- Keep printed Wilson limits off false 0% and 100% endpoints by rounding outward with extra digits when needed, up to 15 decimal places, and using words if the limit still rounds to an endpoint.
|
|
9
|
+
|
|
3
10
|
## [0.1.0] - 2026-10-21
|
|
4
11
|
|
|
5
12
|
First release. MIT licensed.
|
package/README.md
CHANGED
|
@@ -12,14 +12,8 @@ Zero runtime dependencies, TypeScript types included, ESM, Node 20 or newer. It
|
|
|
12
12
|
|
|
13
13
|
## Install
|
|
14
14
|
|
|
15
|
-
Not on npm yet: npm publishing is pending, so `npm i accuracy-claim-kit` does not work today. Install from a clone of this repository:
|
|
16
|
-
|
|
17
15
|
```sh
|
|
18
|
-
|
|
19
|
-
cd accuracy-claim-kit
|
|
20
|
-
npm ci && npm run build # once, inside the clone
|
|
21
|
-
cd ../your-project
|
|
22
|
-
npm install ../accuracy-claim-kit
|
|
16
|
+
npm i accuracy-claim-kit
|
|
23
17
|
```
|
|
24
18
|
|
|
25
19
|
ESM only: `import` it. A CommonJS file can `require()` it on Node 20.19 or newer and 22.12 or newer (the releases that can require an ES module); on older Node 20 use `await import('accuracy-claim-kit')`.
|
package/dist/assess.js
CHANGED
|
@@ -2,7 +2,7 @@ import { countDecimals, matchesValue } from './census.js';
|
|
|
2
2
|
import { dayNumber } from './dates.js';
|
|
3
3
|
import { parseDisplayFigure, textFiguresDiffering } from './display.js';
|
|
4
4
|
import { beyondNoise, snapAbsolute, VALUE_NOISE } from './exact.js';
|
|
5
|
-
import { confidenceLabel, decimalCut, maxDisplayDecimals, pctCeil, pctFloor, pctNearest } from './format.js';
|
|
5
|
+
import { confidenceLabel, decimalCut, maxDisplayDecimals, pctBound, pctCeil, pctFloor, pctNearest, pctNumericBound, pctRate } from './format.js';
|
|
6
6
|
import { clip, isRecord, MAX_COUNT, readCount, readFiniteInRange, readLength, assertKnownKeys, assertPlainObject, readOpenUnit, requireRecord, } from './validate.js';
|
|
7
7
|
import { assertPlainText, foldText, MAX_LABEL_LENGTH, MAX_TEXT_LENGTH, mentionsName, readName, shownText } from './text.js';
|
|
8
8
|
import { DEFAULT_CONFIDENCE, wilsonWithZ, zForConfidence, zForTail } from './wilson.js';
|
|
@@ -285,6 +285,10 @@ function observedAdvice(point, successes, n, maxDecimals, higherIsBetter) {
|
|
|
285
285
|
function printAdvice(decimals) {
|
|
286
286
|
return decimals === 0 ? '; print it as a whole percent' : `; print it to at most ${placesWord(decimals)}`;
|
|
287
287
|
}
|
|
288
|
+
/** Trim fixed decimal padding while preserving the exponent of a tiny point rate. */
|
|
289
|
+
function mismatchPercent(proportion) {
|
|
290
|
+
return pctRate(proportion, 3).replace(/(\.\d*?[1-9])0+%$|\.0+%$/, '$1%');
|
|
291
|
+
}
|
|
288
292
|
/**
|
|
289
293
|
* The informational note for a figure in `claim.text` that is not the figure
|
|
290
294
|
* judged (`text-figure-differs`), or null. The text is only scanned: a verdict
|
|
@@ -298,7 +302,7 @@ function textFigureNote(text, claimed, assessed, higherIsBetter) {
|
|
|
298
302
|
return null;
|
|
299
303
|
const shown = differing.slice(0, 3).map((figure) => `"${clip(figure, 40)}"`).join(', ');
|
|
300
304
|
const more = differing.length > 3 ? ` and ${String(differing.length - 3)} more` : '';
|
|
301
|
-
return `claim.text says ${shown}${more}, which is not the figure judged (${
|
|
305
|
+
return `claim.text says ${shown}${more}, which is not the figure judged (${pctRate(assessed, 3)}). The verdict judges value and display, never the wording, so make the text say what was judged.`;
|
|
302
306
|
}
|
|
303
307
|
/**
|
|
304
308
|
* Does this accuracy or error-rate claim have the evidence to carry it?
|
|
@@ -404,7 +408,7 @@ export function assessAccuracyClaim(input, options) {
|
|
|
404
408
|
// Exact: the value must agree with the printed figure to its rounding plus
|
|
405
409
|
// one ulp of the value. No float tolerance is involved.
|
|
406
410
|
if (!figure.consistentWith(judgedValue)) {
|
|
407
|
-
throw new RangeError(`claim.display "${clip(displayRaw, 40)}" (${
|
|
411
|
+
throw new RangeError(`claim.display "${clip(displayRaw, 40)}" (${mismatchPercent(figure.info.figure)}) does not match claim.value ${String(claimed)} (${mismatchPercent(claimed)}): ${figure.mismatchHint}`);
|
|
408
412
|
}
|
|
409
413
|
}
|
|
410
414
|
const displayIsPoint = figure !== undefined && figure.bound === null;
|
|
@@ -678,7 +682,7 @@ export function assessAccuracyClaim(input, options) {
|
|
|
678
682
|
const censusNotes = [];
|
|
679
683
|
let censusVerdict;
|
|
680
684
|
const shown = Math.min(countDecimals(n), 2);
|
|
681
|
-
const exactText =
|
|
685
|
+
const exactText = pctRate(k / n, shown);
|
|
682
686
|
// Every figure the reader can see is judged according to its form: a point
|
|
683
687
|
// or approximate figure must match the count to its digits; a bound is an
|
|
684
688
|
// inequality (strict ones exclude equality); a range and "1 in N" are judged
|
|
@@ -752,9 +756,9 @@ export function assessAccuracyClaim(input, options) {
|
|
|
752
756
|
let verdict;
|
|
753
757
|
const reasons = [];
|
|
754
758
|
const explanation = [];
|
|
755
|
-
const claimedText =
|
|
759
|
+
const claimedText = pctRate(assessed, 3);
|
|
756
760
|
const subject = fromDisplay
|
|
757
|
-
? `The printed figure ${claimedText} (more favorable than the claim value ${
|
|
761
|
+
? `The printed figure ${claimedText} (more favorable than the claim value ${pctRate(claimed, 3)})`
|
|
758
762
|
: `The claimed ${claimedText}`;
|
|
759
763
|
const qualifier = higherIsBetter ? '' : ` ${metricName}`;
|
|
760
764
|
// An honest report of the observed rate: a point figure (not a bound, not 0 or
|
|
@@ -772,8 +776,8 @@ export function assessAccuracyClaim(input, options) {
|
|
|
772
776
|
? matchesValue(judgedValue, successes, n)
|
|
773
777
|
: figure.matchesObserved(successes, n) && (!valueMoreFavorable || matchesValue(judgedValue, successes, n));
|
|
774
778
|
}
|
|
775
|
-
const top =
|
|
776
|
-
const bottom =
|
|
779
|
+
const top = pctBound(w.high, 3, 'ceil');
|
|
780
|
+
const bottom = pctBound(w.low, 3, 'floor');
|
|
777
781
|
const observedText = `${String(successes)} of ${String(n)}`;
|
|
778
782
|
const strictBound = figure !== undefined && figure.strict;
|
|
779
783
|
// A bound claim is supported when it sits on the cautious side of the
|
|
@@ -803,13 +807,12 @@ export function assessAccuracyClaim(input, options) {
|
|
|
803
807
|
else if (higherIsBetter ? assessed > w.high + tolFor(assessed) : assessed < w.low - tolFor(assessed)) {
|
|
804
808
|
verdict = 'contradicted';
|
|
805
809
|
reasons.push('claim-outside-interval');
|
|
806
|
-
//
|
|
807
|
-
// the limit is still on the near side of the claim, so say that instead of printing a bare 100%.
|
|
810
|
+
// For an absolute claim near the interval limit, spell out why the counts rule it out.
|
|
808
811
|
const nearCertain = higherIsBetter
|
|
809
|
-
? successes < n &&
|
|
812
|
+
? absolute && successes < n && pctCeil(w.high, 3) === pctCeil(1, 3)
|
|
810
813
|
? ', which is just under 100% because not every item was counted right'
|
|
811
814
|
: null
|
|
812
|
-
: successes > 0 &&
|
|
815
|
+
: absolute && successes > 0 && pctFloor(w.low, 3) === pctFloor(0, 3)
|
|
813
816
|
? ', which is just above 0% because at least one error was counted'
|
|
814
817
|
: null;
|
|
815
818
|
explanation.push(higherIsBetter
|
|
@@ -832,14 +835,18 @@ export function assessAccuracyClaim(input, options) {
|
|
|
832
835
|
: `${subject}${qualifier} is inside the ${cl} Wilson interval but below its upper end (${top}), which is the least the evidence supports.`;
|
|
833
836
|
// A bound printed rounded to the nearest digit ("99.1%+" from a limit of 99.046%) can land
|
|
834
837
|
// just past the limit; the figure to print is the limit rounded in the cautious direction.
|
|
838
|
+
const allowed = maxDisplayDecimals(w.high - w.low);
|
|
839
|
+
const adviceMaxDecimals = strictPrecision ? allowed : undefined;
|
|
840
|
+
const boundMode = higherIsBetter ? 'floor' : 'ceil';
|
|
835
841
|
const printedDecimals = figure !== undefined && figure.bound !== null ? figure.info.decimals : null;
|
|
836
842
|
if (printedDecimals !== null && figure !== undefined) {
|
|
837
843
|
const oneUnit = 10 ** -(printedDecimals + 2);
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
844
|
+
const shortfall = higherIsBetter ? assessed - w.low : w.high - assessed;
|
|
845
|
+
if (figure.bound === (higherIsBetter ? 'floor' : 'ceiling') && shortfall < oneUnit) {
|
|
846
|
+
const rounded = pctNumericBound(conservativeBound, printedDecimals, boundMode, adviceMaxDecimals);
|
|
847
|
+
if (rounded !== null) {
|
|
848
|
+
sentence += ` The shortfall is within the rounding of the last printed digit, so print the bound rounded ${higherIsBetter ? 'down' : 'up'}: ${rounded}.`;
|
|
849
|
+
}
|
|
843
850
|
}
|
|
844
851
|
}
|
|
845
852
|
// A figure on the cautious side of the observed rate is the usual honest round-down or
|
|
@@ -849,24 +856,23 @@ export function assessAccuracyClaim(input, options) {
|
|
|
849
856
|
// within the precision strictPrecision allows can match it; the bound is printed at the
|
|
850
857
|
// precision the interval permits when strictPrecision or conservative is set.
|
|
851
858
|
if (beyondNoise(w.point, assessed, higherIsBetter)) {
|
|
852
|
-
const allowed = maxDisplayDecimals(w.high - w.low);
|
|
853
859
|
const printDecimals = strictPrecision ? allowed : Math.min(allowed + 2, 5);
|
|
854
860
|
const observedFigure = conservative ? null : observedAdvice(w.point, successes, n, strictPrecision ? allowed : null, higherIsBetter);
|
|
855
|
-
|
|
856
|
-
//
|
|
861
|
+
const observedRate = pctRate(w.point, 3);
|
|
862
|
+
// Repeat the figure only when the advice differs or carries a strict precision limit.
|
|
857
863
|
const observedPart = observedFigure === null
|
|
858
864
|
? ''
|
|
859
|
-
: !strictPrecision && observedFigure ===
|
|
865
|
+
: !strictPrecision && observedFigure === observedRate
|
|
860
866
|
? 'print the observed rate, or '
|
|
861
867
|
: `print the observed rate (${observedFigure}), or `;
|
|
862
|
-
// The bound at the permitted precision is cut in the cautious direction, so it is never
|
|
863
|
-
// beyond the conservative end and always passes as a claim of its own.
|
|
864
868
|
const lead = higherIsBetter
|
|
865
|
-
? ` The figure is also below the observed rate (${observedText}, ${
|
|
866
|
-
: ` The figure is also above the observed rate (${observedText}, ${
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
869
|
+
? ` The figure is also below the observed rate (${observedText}, ${observedRate}): `
|
|
870
|
+
: ` The figure is also above the observed rate (${observedText}, ${observedRate}): `;
|
|
871
|
+
const rounded = pctNumericBound(conservativeBound, printDecimals, boundMode, adviceMaxDecimals);
|
|
872
|
+
const boundPart = rounded === null
|
|
873
|
+
? 'report the counts'
|
|
874
|
+
: `go ${higherIsBetter ? 'down to the lower' : 'up to the upper'} end (${rounded})`;
|
|
875
|
+
sentence += `${lead}${observedPart}${boundPart}.`;
|
|
870
876
|
}
|
|
871
877
|
explanation.push(sentence);
|
|
872
878
|
}
|
|
@@ -898,7 +904,7 @@ export function assessAccuracyClaim(input, options) {
|
|
|
898
904
|
const worse = higherIsBetter ? assessed < wide.low - tolFor(assessed) : assessed > wide.high + tolFor(assessed);
|
|
899
905
|
if (worse) {
|
|
900
906
|
reasons.push('claim-worse-than-counts');
|
|
901
|
-
explanation.push(`${subject} is far less favorable than the counts support (the 99.9% Wilson interval is ${
|
|
907
|
+
explanation.push(`${subject} is far less favorable than the counts support (the 99.9% Wilson interval is ${pctBound(wide.low, 3, 'floor')} to ${pctBound(wide.high, 3, 'ceil')}). If this is a published figure it may be stale or wrong.`);
|
|
902
908
|
}
|
|
903
909
|
}
|
|
904
910
|
// The interval pools the strata as one simple random sample. It is not
|
|
@@ -914,18 +920,20 @@ export function assessAccuracyClaim(input, options) {
|
|
|
914
920
|
explanation.push(textNote);
|
|
915
921
|
}
|
|
916
922
|
// ---- statement ---------------------------------------------------------
|
|
917
|
-
//
|
|
923
|
+
// Use the same printed bound in the headline and the quoted interval.
|
|
918
924
|
const decimals = Math.min(maxDisplayDecimals(w.high - w.low) + 2, 5);
|
|
925
|
+
const statementLow = pctBound(w.low, decimals, 'floor');
|
|
926
|
+
const statementHigh = pctBound(w.high, decimals, 'ceil');
|
|
919
927
|
// The lead names the scope first: the figure is about this sample (or the
|
|
920
928
|
// declared evaluated population), so a pasted headline cannot read as a
|
|
921
929
|
// property of the system.
|
|
922
930
|
const scope = population === undefined ? 'On this sample' : `On this sample of ${population.evaluated}`;
|
|
923
931
|
const headline = higherIsBetter
|
|
924
|
-
? `${scope}, at least ${
|
|
925
|
-
: `${scope}, at most ${
|
|
932
|
+
? `${scope}, at least ${statementLow} ${metricName}`
|
|
933
|
+
: `${scope}, at most ${statementHigh} ${metricName}`;
|
|
926
934
|
const caveat = sampling === 'cross-validation' ? SAMPLING_ERROR_ONLY_CV : SAMPLING_ERROR_ONLY;
|
|
927
935
|
const parts = [
|
|
928
|
-
`${cl} Wilson interval ${
|
|
936
|
+
`${cl} Wilson interval ${statementLow} to ${statementHigh}`,
|
|
929
937
|
`n = ${String(n)}`,
|
|
930
938
|
labelWord,
|
|
931
939
|
SAMPLE_WORD[sampling] ?? 'random sample',
|
package/dist/assess.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assess.js","sourceRoot":"","sources":["../src/assess.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACzD,OAA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AG,EAAE,oBAAoB,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,QAAQ,CAAC,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE;QACpF,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE;QAClB,SAAS;QACT,WAAW,CAAC,QAAQ,CAAC,IAAI,eAAe;KACzC,CAAA;IACD,IAAI,cAAc,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,aAAa,cAAwB,EAAE,CAAC,CAAA;IACrF,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAA;IACjG,CAAC;IACD,OAAO;QACL,OAAO;QACP,OAAO;QACP,WAAW;QACX,MAAM;QACN,OAAO;QACP,aAAa,EAAE,QAAQ;QACvB,CAAC;QACD,KAAK,EAAE,iBAAiB;QACxB,aAAa;QACb,MAAM;QACN,QAAQ;QACR,iBAAiB;QACjB,kBAAkB,EAAE,GAAG,QAAQ,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,MAAM,GAAG,aAAa,EAAE;KACnF,CAAA;AACH,CAAC","sourcesContent":["import type { AgreementStatistic, UndefinedAgreementReason } from './agreement.js'\nimport { countDecimals, matchesValue } from './census.js'\nimport { dayNumber } from './dates.js'\nimport { parseDisplayFigure, textFiguresDiffering } from './display.js'\nimport { beyondNoise, snapAbsolute, VALUE_NOISE } from './exact.js'\nimport type { DisplayFigure } from './display.js'\nimport { confidenceLabel, decimalCut, maxDisplayDecimals, pctCeil, pctFloor, pctNearest } from './format.js'\nimport type {\n AccuracyAssessment,\n AccuracyClaimInput,\n AccuracyVerdict,\n AssessOptions,\n ClaimMetric,\n GateChecks,\n UnsupportedMetric,\n LabelSource,\n ReasonCode,\n SamplingMethod,\n} from './types.js'\nimport {\n clip,\n isRecord,\n MAX_COUNT,\n readCount,\n readFiniteInRange,\n readLength,\n assertKnownKeys,\n assertPlainObject,\n readOpenUnit,\n requireRecord,\n} from './validate.js'\nimport { assertPlainText, foldText, MAX_LABEL_LENGTH, MAX_TEXT_LENGTH, mentionsName, readName, shownText } from './text.js'\nimport { DEFAULT_CONFIDENCE, wilsonWithZ, zForConfidence, zForTail } from './wilson.js'\n\n/** Lowest confidence level `assessAccuracyClaim` accepts. `wilsonInterval` takes any level strictly between 0 and 1. */\nconst MIN_ASSESS_CONFIDENCE = 0.5\n\n/** Smallest sample that gets a verdict unless options.minN says otherwise. */\nexport const DEFAULT_MIN_N = 30\n\n/**\n * Absolute tolerance, as a proportion, when a claim is compared with an\n * interval limit. A claim within this distance of a limit counts as being at\n * the limit, on the claimant's side. It exists only to absorb binary\n * floating-point noise (a claim of exactly 0.98 against a limit that\n * computes to 0.98000000000000001). It is far below the width of any\n * interval met in practice; it can only matter for samples above about 4e12\n * items with a rate within about 1e-12 of 0 or 1, where the interval itself\n * is narrower than the tolerance. A claim of exactly 0 or 1 is absolute and\n * never uses it.\n */\nexport const COMPARISON_TOLERANCE = 1e-12\n\nconst SOURCES: readonly LabelSource[] = ['human', 'automated', 'by-construction', 'model', 'mixed', 'unknown']\nconst SAMPLINGS: readonly SamplingMethod[] = ['random', 'stratified', 'ranked', 'convenience', 'unknown', 'complete', 'held-out-split', 'cross-validation']\nconst METRICS: readonly ClaimMetric[] = [\n 'accuracy',\n 'error-rate',\n 'precision',\n 'recall',\n 'false-positive-rate',\n 'false-negative-rate',\n 'specificity',\n 'npv',\n 'sensitivity',\n 'ppa',\n 'ppv',\n 'npa',\n 'opa',\n]\n/** Metrics the kit knows it cannot judge: they get a refusal, not a throw. */\nconst UNSUPPORTED_METRICS: readonly UnsupportedMetric[] = [\n 'f1', 'auc', 'roc-auc', 'wer', 'cer', 'bleu', 'rouge', 'map', 'composite', 'other',\n]\nconst HIGHER_IS_BETTER: readonly ClaimMetric[] = ['accuracy', 'precision', 'recall', 'specificity', 'npv', 'sensitivity', 'ppa', 'ppv', 'npa', 'opa']\nconst METRIC_PHRASE: Record<ClaimMetric, string> = {\n accuracy: 'accurate',\n 'error-rate': 'error rate',\n precision: 'precision',\n recall: 'recall',\n 'false-positive-rate': 'false-positive rate',\n 'false-negative-rate': 'false-negative rate',\n specificity: 'specificity',\n npv: 'negative predictive value',\n sensitivity: 'sensitivity',\n ppa: 'positive percent agreement',\n ppv: 'positive predictive value',\n npa: 'negative percent agreement',\n opa: 'overall percent agreement',\n}\n/** What a bare value (no display) is read at; nothing was printed, so the text must not say so. */\nconst VALUE_PRECISION = 'the precision of the value (a whole percent at the coarsest)'\nconst SUPPORTED_LIST = 'accuracy, error-rate, precision, recall, false-positive-rate, false-negative-rate, specificity, npv and the diagnostic names sensitivity, ppa, ppv, npa and opa'\n// The keys each caller-supplied object may carry. Anything else is a typo that\n// would silently switch a check off, so it throws.\nconst OPTION_KEYS = ['confidence', 'minN', 'minAgreement', 'maxAgeDays', 'now', 'strictPrecision', 'conservative', 'requireScope'] as const\nconst INPUT_KEYS = ['claim', 'sample', 'provenance', 'sampling', 'strata', 'retractions', 'benchmark', 'population', 'evaluatedAt'] as const\nconst CLAIM_KEYS = ['metric', 'value', 'display', 'text'] as const\nconst SAMPLE_KEYS = ['n', 'correct', 'errors'] as const\nconst STRATUM_KEYS = ['name', 'n', 'correct', 'errors'] as const\nconst PROVENANCE_KEYS = ['source', 'raters', 'agreement'] as const\nconst AGREEMENT_KEYS = ['statistic', 'status', 'value', 'n', 'agreements', 'categories', 'reason'] as const\nconst RETRACTION_KEYS = ['count', 'includedInSample'] as const\nconst BENCHMARK_KEYS = ['name'] as const\nconst POPULATION_KEYS = ['claimed', 'evaluated'] as const\nconst STATISTICS: readonly AgreementStatistic[] = ['percent-agreement', 'cohen-kappa', 'gwet-ac1']\nconst UNDEFINED_REASONS: readonly UndefinedAgreementReason[] = ['no-pairs', 'expected-agreement-is-1', 'single-category']\nconst STATISTIC_LABEL: Record<AgreementStatistic, string> = {\n 'percent-agreement': 'percent agreement',\n 'cohen-kappa': 'Cohen kappa',\n 'gwet-ac1': 'Gwet AC1',\n}\n\nfunction readEnum<T extends string>(value: unknown, allowed: readonly T[], name: string): T {\n if (typeof value !== 'string') throw new TypeError(`${name} must be a string`)\n const found = allowed.find((candidate) => candidate === value)\n if (found === undefined) {\n throw new RangeError(`${name} must be one of ${allowed.join(', ')}; got \"${clip(value)}\"`)\n }\n return found\n}\n\n/**\n * The metric: judged (exact, lower-case name), known-unsupported (refused\n * later; case does not matter, since such a name can only be refused), or\n * unknown (thrown). A judged name in the wrong case is a typo that throws, with\n * the name the caller probably meant.\n */\nfunction readMetric(raw: unknown): { metric: ClaimMetric | UnsupportedMetric; judged: boolean } {\n if (typeof raw !== 'string') throw new TypeError('claim.metric must be a string')\n const supported = METRICS.find((m) => m === raw)\n if (supported !== undefined) return { metric: supported, judged: true }\n const lower = raw.toLowerCase()\n const unsupported = UNSUPPORTED_METRICS.find((m) => m === lower)\n if (unsupported !== undefined) return { metric: unsupported, judged: false }\n const meant = METRICS.find((m) => m === lower)\n const hint = meant === undefined ? '' : `; did you mean \"${meant}\"?`\n throw new RangeError(\n `claim.metric must be one of ${METRICS.join(', ')}, or one of ${UNSUPPORTED_METRICS.join(', ')} (which the kit knows and refuses, in any case); got \"${clip(raw)}\"${hint}`,\n )\n}\n\ninterface Counts {\n n: number\n correct: number\n}\n\n/** Reads {n, correct?, errors?} for the sample; null when no counts were disclosed at all. */\nfunction readSampleCounts(raw: unknown): Counts | null {\n if (raw === undefined) return null\n const rec = requireRecord(raw, 'sample')\n assertKnownKeys(rec, SAMPLE_KEYS, 'sample')\n const nRaw: unknown = rec.n\n const correctRaw: unknown = rec.correct\n const errorsRaw: unknown = rec.errors\n if (nRaw === undefined && correctRaw === undefined && errorsRaw === undefined) return null\n return readCounts({ n: nRaw, correct: correctRaw, errors: errorsRaw }, 'sample')\n}\n\n/** Reads {n, correct?, errors?}; each property once. */\nfunction readCounts(raw: unknown, name: string): Counts {\n const rec = requireRecord(raw, name)\n const nRaw: unknown = rec.n\n const correctRaw: unknown = rec.correct\n const errorsRaw: unknown = rec.errors\n const n = readCount(nRaw, `${name}.n`, 1)\n if (correctRaw === undefined && errorsRaw === undefined) {\n throw new TypeError(`${name} needs correct or errors`)\n }\n const correct = correctRaw === undefined ? undefined : readCount(correctRaw, `${name}.correct`, 0)\n const errors = errorsRaw === undefined ? undefined : readCount(errorsRaw, `${name}.errors`, 0)\n if (correct !== undefined && correct > n) {\n throw new RangeError(`${name}.correct (${String(correct)}) is larger than n (${String(n)})`)\n }\n if (errors !== undefined && errors > n) {\n throw new RangeError(`${name}.errors (${String(errors)}) is larger than n (${String(n)})`)\n }\n if (correct !== undefined && errors !== undefined && correct + errors !== n) {\n throw new RangeError(`${name}.correct + ${name}.errors must equal n`)\n }\n return { n, correct: correct !== undefined ? correct : n - (errors as number) }\n}\n\ninterface Agreement {\n statistic: AgreementStatistic\n value: number | null\n /** Items the statistic was computed on; null for a hand-written {statistic, value}, which is trusted. */\n n: number | null\n}\n\nfunction readAgreement(raw: unknown): Agreement {\n const rec = requireRecord(raw, 'provenance.agreement')\n assertKnownKeys(rec, AGREEMENT_KEYS, 'provenance.agreement')\n const statisticRaw: unknown = rec.statistic\n const statusRaw: unknown = rec.status\n const valueRaw: unknown = rec.value\n const nRaw: unknown = rec.n\n const agreementsRaw: unknown = rec.agreements\n const categoriesRaw: unknown = rec.categories\n const reasonRaw: unknown = rec.reason\n const statistic = readEnum(statisticRaw, STATISTICS, 'provenance.agreement.statistic')\n if (statusRaw !== undefined && statusRaw !== 'defined' && statusRaw !== 'undefined') {\n throw new RangeError('provenance.agreement.status must be \"defined\" or \"undefined\"')\n }\n const n = nRaw === undefined ? null : readCount(nRaw, 'provenance.agreement.n', 0)\n // The keys a kit result carries are allowed so it can be passed straight in; they\n // are not used, but nonsense in them means the object is not what it claims to be.\n const agreements = agreementsRaw === undefined ? null : readCount(agreementsRaw, 'provenance.agreement.agreements', 0)\n if (agreements !== null && n !== null && agreements > n) {\n throw new RangeError(`provenance.agreement.agreements (${String(agreements)}) is larger than provenance.agreement.n (${String(n)})`)\n }\n if (categoriesRaw !== undefined) readCount(categoriesRaw, 'provenance.agreement.categories', 0)\n if (reasonRaw !== undefined) readEnum(reasonRaw, UNDEFINED_REASONS, 'provenance.agreement.reason')\n if (statusRaw === 'undefined') {\n // A statistic that has no value must say so with null; NaN, 0 or text in\n // its place is malformed input, not \"cannot tell\".\n if (valueRaw !== null) {\n const message = 'provenance.agreement.value must be null when status is \"undefined\"'\n throw typeof valueRaw === 'number' ? new RangeError(message) : new TypeError(message)\n }\n return { statistic, value: null, n }\n }\n return { statistic, value: readFiniteInRange(valueRaw, 'provenance.agreement.value', -1, 1), n }\n}\n\ninterface Stratum {\n name: string\n n: number\n correct: number\n}\n\nfunction readStrata(raw: unknown): Stratum[] {\n if (!Array.isArray(raw)) throw new TypeError('strata must be an array')\n const length = readLength((raw as unknown[]).length, 'strata')\n if (length === 0) throw new RangeError('strata must not be empty; leave it out if there are none')\n const out: Stratum[] = []\n const names = new Set<string>()\n for (let i = 0; i < length; i++) {\n const entry: unknown = (raw as unknown[])[i]\n const rec = requireRecord(entry, `strata[${i}]`)\n assertKnownKeys(rec, STRATUM_KEYS, `strata[${i}]`)\n const nameRaw: unknown = rec.name\n if (typeof nameRaw !== 'string') throw new TypeError(`strata[${i}].name must be a string`)\n if (nameRaw === '') throw new RangeError(`strata[${i}].name must not be empty`)\n if (nameRaw.length > MAX_LABEL_LENGTH) {\n throw new RangeError(`strata[${i}].name must be at most ${String(MAX_LABEL_LENGTH)} characters`)\n }\n const name = shownText(nameRaw, `strata[${i}].name`)\n if (name === '') throw new RangeError(`strata[${i}].name must not be blank`)\n if (names.has(name)) throw new RangeError(`strata[${i}].name \"${clip(name)}\" is a duplicate`)\n names.add(name)\n const counts = readCounts(rec, `strata[${i}]`)\n out.push({ name, ...counts })\n }\n return out\n}\n\nconst REFUSAL_PHRASE: Record<string, string> = {\n 'metric-not-supported': 'this kit cannot judge that kind of metric',\n 'n-undisclosed': 'the number of items checked was not disclosed',\n 'no-human-labels': 'the labels were not checked by people',\n 'unknown-label-source': 'nobody has said where the labels came from',\n 'mixed-label-source': 'only some labels came from people and the counts are not split',\n 'ranked-sample': 'the sample was picked by rank, not at random',\n 'convenience-sample': 'the sample was whatever was easy to collect',\n 'unknown-sampling': 'nobody has said how the sample was picked',\n 'sample-too-small': 'the sample is too small',\n 'merged-strata-differ': 'groups with clearly different rates were merged into one number',\n 'retractions-not-included': 'known retractions are not in the counts',\n 'agreement-missing': 'no agreement statistic was supplied for the required agreement check',\n 'agreement-undefined': 'the agreement statistic could not be computed',\n 'agreement-below-minimum': 'the raters agreed less than the required minimum',\n 'agreement-sample-too-small': 'the agreement statistic was computed on too few items',\n 'stratified-without-strata': 'the sample is stratified but the strata were not supplied, so the pooled counts cannot be read as the population rate',\n 'benchmark-unnamed': 'a complete-set or held-out-split claim needs the name of the fixed set',\n 'claim-not-scoped-to-benchmark': 'the claim wording does not name the benchmark, so a benchmark score is standing in for a general claim',\n 'evaluation-date-missing': 'a maximum age was set but the evaluation date was not supplied',\n 'evaluation-stale': 'the evaluation is older than the allowed age',\n 'scope-mismatch': 'the claim covers a different population than the one evaluated',\n 'scope-undeclared': 'the claimed and evaluated populations were not declared',\n}\n\nconst LABEL_WORD: Record<'human' | 'automated' | 'by-construction', string> = {\n human: 'human labels',\n automated: 'automated labels',\n 'by-construction': 'labels fixed by construction',\n}\n\n/** What the interval in a statement does and does not cover, said in the statement itself. */\nconst SAMPLING_ERROR_ONLY = 'the interval covers sampling error only'\nconst SAMPLING_ERROR_ONLY_CV = 'the interval covers sampling error only and is optimistic because cross-validation folds share data'\n\nconst SAMPLE_WORD: Partial<Record<SamplingMethod, string>> = {\n stratified: 'stratified sample, unweighted pooled',\n 'cross-validation': 'cross-validation estimate',\n}\n\n/** \"1 decimal place\", \"2 decimal places\"; whole percents have none. */\nfunction placesWord(decimals: number): string {\n return decimals === 1 ? '1 decimal place' : `${String(decimals)} decimal places`\n}\n/** What a precision limit allows: \"whole percents only\", \"at most 1 decimal place\". */\nfunction supportsWord(decimals: number): string {\n return decimals === 0 ? 'whole percents only' : `at most ${placesWord(decimals)}`\n}\n/**\n * The observed rate as a figure to print that the same assessment would pass as\n * `matches-observed-rate`, or null when none exists. With `maxDecimals` null\n * (the default, where excess precision is only noted) the figure is printed to\n * three decimals, or to as many more as it takes to keep it off 0% and 100%\n * (those are absolute claims a sample cannot show); with a limit (strictPrecision)\n * it must fit that many decimals, and an exact tie may be reached from either\n * neighbor. A candidate is judged by the display parser itself, so it cannot\n * drift from what the assessment accepts.\n */\nfunction observedAdvice(point: number, successes: number, n: number, maxDecimals: number | null, higherIsBetter: boolean): string | null {\n if (point === 0 || point === 1) return null\n const first = maxDecimals === null ? 3 : maxDecimals\n const last = maxDecimals === null ? 12 : maxDecimals\n for (let d = first; d <= last; d++) {\n for (const printed of [pctNearest(point, d), pctFloor(point, d), pctCeil(point, d)]) {\n const figure = parseDisplayFigure(printed, higherIsBetter)\n if (figure.info.figure !== 0 && figure.info.figure !== 1 && figure.matchesObserved(successes, n)) return printed\n }\n }\n return null\n}\n\n/** The statement's advice on how to print the figure. */\nfunction printAdvice(decimals: number): string {\n return decimals === 0 ? '; print it as a whole percent' : `; print it to at most ${placesWord(decimals)}`\n}\n\n/**\n * The informational note for a figure in `claim.text` that is not the figure\n * judged (`text-figure-differs`), or null. The text is only scanned: a verdict\n * is never changed by it.\n */\nfunction textFigureNote(text: string | undefined, claimed: number, assessed: number, higherIsBetter: boolean): string | null {\n if (text === undefined) return null\n const differing = textFiguresDiffering(text, claimed, assessed, higherIsBetter)\n if (differing.length === 0) return null\n const shown = differing.slice(0, 3).map((figure) => `\"${clip(figure, 40)}\"`).join(', ')\n const more = differing.length > 3 ? ` and ${String(differing.length - 3)} more` : ''\n return `claim.text says ${shown}${more}, which is not the figure judged (${pctNearest(assessed, 3)}). The verdict judges value and display, never the wording, so make the text say what was judged.`\n}\n\n/**\n * Does this accuracy or error-rate claim have the evidence to carry it?\n *\n * Pure statistics on the counts you pass in. It never judges whether the\n * labels are right and cannot see how the sample was really drawn; it takes\n * your `provenance` and `sampling` declarations at their word and refuses\n * when they do not support a figure.\n *\n * Verdicts:\n * - refused: a precondition failed. This means \"cannot tell\", not \"false\".\n * - contradicted: the claim is more favorable than the interval's best end.\n * - overstated: inside the interval but more favorable than the observed\n * rate (or, with options.conservative, than the conservative end), or\n * printed with finer precision than the interval allows.\n * - supported: no more favorable than the conservative end, or an honest\n * report of the observed rate to its printed precision.\n *\n * Malformed input throws (TypeError for a wrong type, RangeError for a wrong\n * value); it never returns a verdict. Every input property is read once.\n */\nexport function assessAccuracyClaim(\n input: AccuracyClaimInput,\n options?: AssessOptions,\n): AccuracyAssessment {\n // ---- read and validate everything before judging anything -------------\n if (options !== undefined && !isRecord(options)) {\n throw new TypeError('options must be an object')\n }\n if (options !== undefined) {\n assertPlainObject(options, 'options')\n assertKnownKeys(options, OPTION_KEYS, 'options')\n }\n const confidenceRaw: unknown = options === undefined ? undefined : options.confidence\n const minNRaw: unknown = options === undefined ? undefined : options.minN\n const minAgreementRaw: unknown = options === undefined ? undefined : options.minAgreement\n const confidence =\n confidenceRaw === undefined ? DEFAULT_CONFIDENCE : readOpenUnit(confidenceRaw, 'options.confidence')\n // A level below one half is a typo (0.05 for 0.95): its \"interval\" is narrower\n // than the data's own noise and an \"at least\" statement built on it means nothing.\n if (confidence < MIN_ASSESS_CONFIDENCE) {\n throw new RangeError(`options.confidence must be at least ${String(MIN_ASSESS_CONFIDENCE)} for a verdict (0.95 is the default); got ${String(confidence)}`)\n }\n const z = zForConfidence(confidence)\n const minN = minNRaw === undefined ? DEFAULT_MIN_N : readCount(minNRaw, 'options.minN', 1)\n const minAgreement =\n minAgreementRaw === undefined ? undefined : readFiniteInRange(minAgreementRaw, 'options.minAgreement', -1, 1)\n const maxAgeRaw: unknown = options === undefined ? undefined : options.maxAgeDays\n const nowRaw: unknown = options === undefined ? undefined : options.now\n const requireScopeRaw: unknown = options === undefined ? undefined : options.requireScope\n const conservativeRaw: unknown = options === undefined ? undefined : options.conservative\n const strictPrecisionRaw: unknown = options === undefined ? undefined : options.strictPrecision\n const maxAgeDays = maxAgeRaw === undefined ? undefined : readCount(maxAgeRaw, 'options.maxAgeDays', 0)\n if (maxAgeDays !== undefined && nowRaw === undefined) {\n throw new TypeError('options.now is required with options.maxAgeDays: the kit never reads a clock')\n }\n const nowDay = nowRaw === undefined ? undefined : dayNumber(nowRaw, 'options.now')\n if (requireScopeRaw !== undefined && typeof requireScopeRaw !== 'boolean') {\n throw new TypeError('options.requireScope must be a boolean')\n }\n if (conservativeRaw !== undefined && typeof conservativeRaw !== 'boolean') {\n throw new TypeError('options.conservative must be a boolean')\n }\n if (strictPrecisionRaw !== undefined && typeof strictPrecisionRaw !== 'boolean') {\n throw new TypeError('options.strictPrecision must be a boolean')\n }\n const requireScope = requireScopeRaw === true\n const conservative = conservativeRaw === true\n // Excess printed precision is informational unless asked for, or in conservative mode.\n const strictPrecision = strictPrecisionRaw === true || conservative\n\n const root = requireRecord(input, 'input')\n assertKnownKeys(root, INPUT_KEYS, 'input')\n const claimRaw: unknown = root.claim\n const sampleRaw: unknown = root.sample\n const provenanceRaw: unknown = root.provenance\n const samplingRaw: unknown = root.sampling\n const strataRaw: unknown = root.strata\n const retractionsRaw: unknown = root.retractions\n const benchmarkRaw: unknown = root.benchmark\n const populationRaw: unknown = root.population\n const evaluatedAtRaw: unknown = root.evaluatedAt\n\n const claimRec = requireRecord(claimRaw, 'claim')\n assertKnownKeys(claimRec, CLAIM_KEYS, 'claim')\n const metricRaw: unknown = claimRec.metric\n const valueRaw: unknown = claimRec.value\n const displayRaw: unknown = claimRec.display\n const textRaw: unknown = claimRec.text\n\n // The metric: judged, or known-unsupported (refused below), or a typo (thrown).\n const { metric, judged } = readMetric(metricRaw)\n const higherIsBetter = judged && HIGHER_IS_BETTER.includes(metric as ClaimMetric)\n\n // A value is a proportion from 0 to 1 for a judged metric. An unsupported\n // metric (a word error rate can pass 1) only needs to be a number.\n const claimed = readFiniteInRange(valueRaw, 'claim.value', -Infinity, Infinity)\n // A value within the floating-point noise of 0 or 1 is the absolute claim of 0 or\n // 1 (ten 0.1s added up is 100%, not \"99.99999999999999% so matches 99.5%\"), and\n // that includes a computed value that overshoots by the noise (1.0000000000000002).\n // Further out it is not a proportion. `claimed` stays as supplied for the result;\n // every judgment uses `judgedValue`.\n if (judged && (claimed < -VALUE_NOISE || claimed > 1 + VALUE_NOISE)) {\n throw new RangeError(`claim.value must be a finite number between 0 and 1, got ${String(claimed)}`)\n }\n const judgedValue = judged ? snapAbsolute(claimed) : claimed\n\n if (displayRaw !== undefined && typeof displayRaw !== 'string') throw new TypeError('claim.display must be a string')\n let figure: DisplayFigure | undefined\n if (displayRaw !== undefined && judged) {\n figure = parseDisplayFigure(displayRaw, higherIsBetter)\n // Exact: the value must agree with the printed figure to its rounding plus\n // one ulp of the value. No float tolerance is involved.\n if (!figure.consistentWith(judgedValue)) {\n throw new RangeError(\n `claim.display \"${clip(displayRaw, 40)}\" (${pctNearest(figure.info.figure, 3).replace(/\\.?0+%$/, '%')}) does not match claim.value ${String(claimed)} (${pctNearest(claimed, 3).replace(/\\.?0+%$/, '%')}): ${figure.mismatchHint}`,\n )\n }\n }\n const displayIsPoint = figure !== undefined && figure.bound === null\n const displayDecimals =\n figure !== undefined && figure.info.form !== 'one-in-n' && figure.bound === null ? figure.info.decimals : null\n\n let claimText: string | undefined\n if (textRaw !== undefined) {\n if (typeof textRaw !== 'string') throw new TypeError('claim.text must be a string')\n if (textRaw.length > MAX_TEXT_LENGTH) throw new RangeError(`claim.text must be at most ${String(MAX_TEXT_LENGTH)} characters`)\n assertPlainText(textRaw, 'claim.text', 'put the claim on one line (join the lines with spaces) before passing it')\n claimText = textRaw\n }\n\n const counts = readSampleCounts(sampleRaw)\n\n const provRec = requireRecord(provenanceRaw, 'provenance')\n assertKnownKeys(provRec, PROVENANCE_KEYS, 'provenance')\n const sourceRaw: unknown = provRec.source\n const ratersRaw: unknown = provRec.raters\n const agreementRaw: unknown = provRec.agreement\n const source = readEnum(sourceRaw, SOURCES, 'provenance.source')\n const raters = ratersRaw === undefined ? undefined : readCount(ratersRaw, 'provenance.raters', 1)\n const agreement = agreementRaw === undefined ? undefined : readAgreement(agreementRaw)\n if (agreement !== undefined && raters !== undefined && raters < 2) {\n // Agreement is between raters; one rater cannot have produced it.\n throw new RangeError(`provenance.raters is ${String(raters)} but provenance.agreement was supplied; agreement needs at least 2 raters`)\n }\n\n const sampling = readEnum(samplingRaw, SAMPLINGS, 'sampling')\n const isFixedSet = sampling === 'complete' || sampling === 'held-out-split'\n\n let benchmarkName: string | undefined\n if (benchmarkRaw !== undefined) {\n const rec = requireRecord(benchmarkRaw, 'benchmark')\n assertKnownKeys(rec, BENCHMARK_KEYS, 'benchmark')\n const nameRaw: unknown = rec.name\n benchmarkName = readName(nameRaw, 'benchmark.name')\n if (!isFixedSet) {\n throw new RangeError(\"benchmark is only for sampling: 'complete' or 'held-out-split'\")\n }\n }\n\n let population: { claimed: string; evaluated: string } | undefined\n if (populationRaw !== undefined) {\n const rec = requireRecord(populationRaw, 'population')\n assertKnownKeys(rec, POPULATION_KEYS, 'population')\n const claimedRaw: unknown = rec.claimed\n const evaluatedRaw: unknown = rec.evaluated\n population = {\n claimed: readName(claimedRaw, 'population.claimed'),\n evaluated: readName(evaluatedRaw, 'population.evaluated'),\n }\n }\n\n const evaluatedDay = evaluatedAtRaw === undefined ? undefined : dayNumber(evaluatedAtRaw, 'evaluatedAt')\n if (evaluatedDay !== undefined && nowDay !== undefined && evaluatedDay > nowDay) {\n throw new RangeError('evaluatedAt is after options.now')\n }\n\n const strata = strataRaw === undefined ? undefined : readStrata(strataRaw)\n // The strata's own totals, as text for a refusal that asks for the pooled counts (null when none or too big to say)\n let strataTotals: string | null = null\n if (strata !== undefined) {\n // BigInt: a plain sum can round past 2^53 and falsely equal the total.\n let sumN = 0n\n let sumCorrect = 0n\n for (const s of strata) {\n sumN += BigInt(s.n)\n sumCorrect += BigInt(s.correct)\n }\n if (counts !== null) {\n if (sumN !== BigInt(counts.n) || sumCorrect !== BigInt(counts.correct)) {\n throw new RangeError('strata counts must add up to the sample counts')\n }\n } else if (sumN <= BigInt(MAX_COUNT)) {\n strataTotals = `{ n: ${String(sumN)}, correct: ${String(sumCorrect)} }`\n }\n }\n\n let retractionCount = 0\n let retractionsIncluded = true\n if (retractionsRaw !== undefined) {\n const rec = requireRecord(retractionsRaw, 'retractions')\n assertKnownKeys(rec, RETRACTION_KEYS, 'retractions')\n const countRaw: unknown = rec.count\n const includedRaw: unknown = rec.includedInSample\n retractionCount = readCount(countRaw, 'retractions.count', 0)\n if (typeof includedRaw !== 'boolean') {\n throw new TypeError('retractions.includedInSample must be a boolean')\n }\n retractionsIncluded = includedRaw\n if (retractionsIncluded && counts !== null && retractionCount > counts.n) {\n throw new RangeError('retractions.count is larger than the sample, so it cannot all be included')\n }\n }\n\n // Readers see the printed figure, so the more favorable of the value and the\n // parsed figure is what gets judged. A display that disagrees with the value\n // by more than its own rounding already threw above.\n let assessed = judgedValue\n let fromDisplay = false\n if (figure !== undefined) {\n const shown = figure.info.figure\n // A little noise apart is the same figure (82.7 / 100 against 0.827, 1 - 0.8 against\n // 0.2), not a more favorable one.\n const displayWins = beyondNoise(shown, judgedValue, higherIsBetter)\n if (displayWins) {\n assessed = shown\n fromDisplay = true\n }\n }\n const parsedDisplay = figure === undefined ? null : figure.info\n\n // Which optional checks this call actually ran. A gate that was asked for\n // ('applied') is different from one that was left out ('not-supplied').\n const checks: GateChecks = {\n retractions: retractionsRaw !== undefined ? 'applied' : 'not-supplied',\n scope: population !== undefined ? 'applied' : 'not-supplied',\n age: maxAgeDays !== undefined ? 'applied' : 'not-supplied',\n // applied = a minimum was required, or a statistic with a value and an n had its size checked;\n // a statistic that has no value is never examined unless a minimum asks for it\n agreement:\n minAgreement !== undefined || (agreement !== undefined && agreement.n !== null && agreement.value !== null) ? 'applied' : 'not-supplied',\n // applied = two or more strata could be compared; one stratum has nothing to differ from\n strata: strata !== undefined && strata.length > 1 && !isFixedSet ? 'applied' : 'not-supplied',\n }\n\n // ---- preconditions -----------------------------------------------------\n const refusals: ReasonCode[] = []\n const notes: string[] = []\n const metricWord = String(metric)\n\n if (!judged) {\n refusals.push('metric-not-supported')\n notes.push(`\"${clip(String(metric))}\" is not a proportion of independently checked items. This kit judges ${SUPPORTED_LIST}; for anything else, report the counts and method instead.`)\n }\n\n if (source === 'model') {\n refusals.push('no-human-labels')\n notes.push('The labels came from a model, not from people, so there is no human ground truth to count against.')\n } else if (source === 'unknown') {\n refusals.push('unknown-label-source')\n notes.push('The source of the labels is unknown, so it is not possible to tell whether people checked them.')\n } else if (source === 'mixed') {\n refusals.push('mixed-label-source')\n notes.push('Some labels came from a model. Count only the human-labeled items and assess those as a human sample.')\n }\n\n if (sampling === 'ranked') {\n refusals.push('ranked-sample')\n notes.push('The sample was chosen by rank (for example the top-scored items), which does not represent the rest.')\n } else if (sampling === 'convenience') {\n refusals.push('convenience-sample')\n notes.push('The sample is a convenience sample, so the interval does not describe any larger group.')\n } else if (sampling === 'unknown') {\n refusals.push('unknown-sampling')\n notes.push('How the sample was chosen is unknown, so the interval cannot be read as covering a larger group.')\n }\n\n if (sampling === 'stratified' && strata === undefined) {\n refusals.push('stratified-without-strata')\n notes.push('The sample is stratified but no strata were supplied. The pooled counts are not a simple random sample, so they cannot be read as the population rate; supply the strata.')\n }\n\n if (isFixedSet) {\n if (benchmarkName === undefined) {\n refusals.push('benchmark-unnamed')\n notes.push(\"A complete-set or held-out-split claim must name the fixed set it was measured on (the 'benchmark' field).\")\n } else if (claimText === undefined || !mentionsName(claimText, benchmarkName)) {\n refusals.push('claim-not-scoped-to-benchmark')\n notes.push(`The claim wording does not mention \"${clip(benchmarkName)}\". A score on a fixed set describes that set; word the claim for it, or supply a random sample for a general claim.`)\n }\n }\n\n if (counts === null) {\n refusals.push('n-undisclosed')\n notes.push(\n strataTotals === null\n ? 'The sample counts (n and correct or errors) were not supplied, so there is nothing to weigh the figure against.'\n : `The pooled sample counts (n and correct or errors) were not supplied. The strata hold them: pass sample: ${strataTotals}, their sums, with the strata.`,\n )\n } else if (!isFixedSet && counts.n < minN) {\n refusals.push('sample-too-small')\n notes.push(`The sample has ${String(counts.n)} items, below the minimum of ${String(minN)} needed for a verdict.`)\n }\n\n if (!isFixedSet && strata !== undefined && strata.length > 1) {\n // Bonferroni: split the error budget across the strata so that many\n // strata do not make a refusal likelier by chance alone.\n const zStrata = zForTail((1 - confidence) / (2 * strata.length))\n let highestLow = -Infinity\n let lowestHigh = Infinity\n let highestName = ''\n let lowestName = ''\n for (const s of strata) {\n const w = wilsonWithZ(s.correct, s.n, zStrata)\n if (w.low > highestLow) {\n highestLow = w.low\n highestName = s.name\n }\n if (w.high < lowestHigh) {\n lowestHigh = w.high\n lowestName = s.name\n }\n }\n if (highestLow - lowestHigh > COMPARISON_TOLERANCE) {\n refusals.push('merged-strata-differ')\n notes.push(\n `The strata do not agree: \"${clip(highestName)}\" and \"${clip(lowestName)}\" have intervals that do not overlap, so one combined figure hides a real difference. Report each stratum.`,\n )\n }\n }\n\n if (retractionCount > 0 && !retractionsIncluded) {\n refusals.push('retractions-not-included')\n notes.push(`${String(retractionCount)} retracted item(s) are known but are not counted in the sample.`)\n }\n\n if (maxAgeDays !== undefined && nowDay !== undefined) {\n if (evaluatedDay === undefined) {\n refusals.push('evaluation-date-missing')\n notes.push('A maximum age was set but no evaluation date (evaluatedAt) was supplied.')\n } else if (nowDay - evaluatedDay > maxAgeDays) {\n refusals.push('evaluation-stale')\n notes.push(`The evaluation is ${String(nowDay - evaluatedDay)} days old, over the allowed ${String(maxAgeDays)} days.`)\n }\n }\n\n if (population !== undefined) {\n if (foldText(population.claimed) !== foldText(population.evaluated)) {\n refusals.push('scope-mismatch')\n notes.push(`The claim covers \"${clip(population.claimed)}\" but the evaluation covered \"${clip(population.evaluated)}\".`)\n }\n } else if (requireScope) {\n refusals.push('scope-undeclared')\n notes.push('The claimed and evaluated populations were not declared (population).')\n }\n\n if (minAgreement !== undefined) {\n if (agreement === undefined) {\n refusals.push('agreement-missing')\n notes.push('A minimum agreement was required but no agreement statistic was supplied.')\n } else if (agreement.value === null) {\n refusals.push('agreement-undefined')\n notes.push(`${STATISTIC_LABEL[agreement.statistic]} is undefined for these labels, so the agreement requirement cannot be checked.`)\n } else if (agreement.value + COMPARISON_TOLERANCE < minAgreement) {\n refusals.push('agreement-below-minimum')\n notes.push(\n `${STATISTIC_LABEL[agreement.statistic]} is ${decimalCut(agreement.value, 3, 'down')}, below the required ${decimalCut(minAgreement, 3, 'up')}.`,\n )\n }\n }\n\n // An agreement statistic from a handful of items is noise (kappa of 1.0 from 6\n // pairs), whether or not a minimum is required. A hand-written statistic with\n // no n cannot be checked and is trusted.\n if (agreement !== undefined && agreement.value !== null && agreement.n !== null && agreement.n < minN) {\n refusals.push('agreement-sample-too-small')\n notes.push(`${STATISTIC_LABEL[agreement.statistic]} was computed on ${String(agreement.n)} items, below the minimum of ${String(minN)}, so it says too little about the raters to count.`)\n }\n\n if (refusals.length > 0 || counts === null) {\n const phrases = refusals.map((code) => REFUSAL_PHRASE[code] as string)\n return {\n verdict: 'refused',\n reasons: refusals,\n explanation: notes,\n metric,\n claimed,\n assessedValue: assessed,\n n: counts === null ? null : counts.n,\n basis: 'none',\n parsedDisplay,\n checks,\n interval: null,\n conservativeBound: null,\n suggestedStatement: `No ${metricWord} figure can be supported from this evidence: ${phrases.join('; ')}.`,\n }\n }\n\n const { n, correct } = counts\n const supportedMetric = metric as ClaimMetric\n const successes = higherIsBetter ? correct : n - correct\n const labelWord = LABEL_WORD[source as 'human' | 'automated' | 'by-construction']\n const datePart = evaluatedAtRaw === undefined ? '' : `, evaluated ${evaluatedAtRaw as string}`\n const metricName = METRIC_PHRASE[supportedMetric]\n\n // ---- complete set or held-out split: compare with the exact count ---------\n if (isFixedSet) {\n const k = successes\n const censusReasons: ReasonCode[] = []\n const censusNotes: string[] = []\n let censusVerdict: AccuracyVerdict\n const shown = Math.min(countDecimals(n), 2)\n const exactText = pctNearest(k / n, shown)\n // Every figure the reader can see is judged according to its form: a point\n // or approximate figure must match the count to its digits; a bound is an\n // inequality (strict ones exclude equality); a range and \"1 in N\" are judged\n // at their favorable end / precision band. The value is judged as a point\n // too whenever it is more favorable than the printed figure, or when the\n // printed figure is itself a point figure. 0 and 1 stay exact.\n const form = figure?.info.form\n const pointDisplay = form === 'percent' || form === 'approx'\n const valueMoreFavorable = figure !== undefined && beyondNoise(judgedValue, figure.info.figure, higherIsBetter)\n const displayOk = figure === undefined || figure.satisfiedBy(k, n)\n const valueOk =\n figure === undefined || valueMoreFavorable || pointDisplay ? matchesValue(judgedValue, k, n) : true\n const printedOnly = form === 'floor' || form === 'ceiling' || form === 'range' || form === 'one-in-n'\n const ok = displayOk && valueOk\n if (ok) {\n censusVerdict = 'supported'\n censusReasons.push('census-matches-count')\n censusNotes.push(`The figure ${printedOnly && form !== 'one-in-n' && form !== 'range' ? 'is consistent with' : 'matches'} the exact count (${String(k)} of ${String(n)}, ${exactText}) to ${figure === undefined ? VALUE_PRECISION : 'its printed precision'}.`)\n } else {\n censusVerdict = 'contradicted'\n censusReasons.push('claim-differs-from-count')\n censusNotes.push(`The figure does not match the exact count (${String(k)} of ${String(n)}, ${exactText}). It may be stale or mistyped.`)\n }\n if (figure !== undefined && figure.bandNote !== null) {\n censusNotes[0] = `${censusNotes[0] as string} ${figure.bandNote}`\n }\n let censusPrecisionNote = ''\n if (displayDecimals !== null && displayDecimals > countDecimals(n)) {\n if (strictPrecision && censusVerdict === 'supported') {\n censusReasons.length = 0\n censusNotes.length = 0\n censusVerdict = 'overstated'\n }\n censusReasons.push('precision-too-fine')\n censusNotes.push(`The figure is printed to ${placesWord(displayDecimals)}; ${String(n)} items resolve ${supportsWord(countDecimals(n))}.`)\n censusPrecisionNote = printAdvice(countDecimals(n))\n }\n const censusTextNote = textFigureNote(claimText, judgedValue, assessed, higherIsBetter)\n if (censusTextNote !== null) {\n censusReasons.push('text-figure-differs')\n censusNotes.push(censusTextNote)\n }\n const name = benchmarkName as string\n const counted = higherIsBetter ? `${String(k)} of ${String(n)} correct` : `${String(k)} of ${String(n)} wrong`\n const setWord = sampling === 'held-out-split' ? 'held-out split' : 'complete set'\n return {\n verdict: censusVerdict,\n reasons: censusReasons,\n explanation: censusNotes,\n metric,\n claimed,\n assessedValue: assessed,\n n,\n basis: 'census',\n parsedDisplay,\n checks,\n interval: null,\n conservativeBound: null,\n suggestedStatement: `${counted} on ${name} (${setWord}, ${labelWord}${datePart}): ${exactText} ${metricName === 'accurate' ? 'accuracy' : metricName}. This describes that set only; it is not an estimate for other data${censusPrecisionNote}`,\n }\n }\n\n // ---- the interval and the verdict ------------------------------------\n const w = wilsonWithZ(successes, n, z)\n const interval = { ...w, confidence, z, successes, n }\n const conservativeBound = higherIsBetter ? w.low : w.high\n const cl = confidenceLabel(confidence)\n // The tolerance absorbs binary noise at an interval limit. An exact 0 or 1 is\n // an absolute claim with no noise in it, and must never be excused: at about\n // 4e12 items the limit next to 0 or 1 is closer than the tolerance.\n const tolFor = (x: number): number => (x === 0 || x === 1 ? 0 : COMPARISON_TOLERANCE)\n\n let verdict: AccuracyVerdict\n const reasons: ReasonCode[] = []\n const explanation: string[] = []\n const claimedText = pctNearest(assessed, 3)\n const subject = fromDisplay\n ? `The printed figure ${claimedText} (more favorable than the claim value ${pctNearest(claimed, 3)})`\n : `The claimed ${claimedText}`\n const qualifier = higherIsBetter ? '' : ` ${metricName}`\n\n // An honest report of the observed rate: a point figure (not a bound, not 0 or\n // 100%) equal to successes / n to its printed precision. Never for a bound,\n // and not at all with options.conservative.\n const absolute = assessed === 0 || assessed === 1\n let matchesObserved = false\n if (!conservative && !absolute && (figure === undefined || displayIsPoint)) {\n // The printed figure must match the rate to its own precision; a value that\n // is more favorable than the printed figure must match as well, so a coarse\n // value cannot stand in for a precise print.\n const valueMoreFavorable = figure !== undefined && beyondNoise(judgedValue, figure.info.figure, higherIsBetter)\n matchesObserved =\n figure === undefined\n ? matchesValue(judgedValue, successes, n)\n : figure.matchesObserved(successes, n) && (!valueMoreFavorable || matchesValue(judgedValue, successes, n))\n }\n\n const top = pctCeil(w.high, 3)\n const bottom = pctFloor(w.low, 3)\n const observedText = `${String(successes)} of ${String(n)}`\n const strictBound = figure !== undefined && figure.strict\n // A bound claim is supported when it sits on the cautious side of the\n // interval's conservative end; a strict one (\"over 99%\") needs to clear it.\n // The value and the printed figure are each judged on their own terms: only\n // the printed bound carries the strictness.\n const clears = (x: number, strict: boolean): boolean => {\n const tol = tolFor(x)\n return higherIsBetter ? (strict ? x < w.low - tol : x <= w.low + tol) : strict ? x > w.high + tol : x >= w.high - tol\n }\n const withinBound = clears(judgedValue, false) && (figure === undefined || clears(figure.info.figure, strictBound))\n const matchesText = `matches the observed rate (${observedText}) to ${figure === undefined ? VALUE_PRECISION : 'its printed precision'}. The ${cl} Wilson interval is ${bottom} to ${top}.`\n if (withinBound) {\n verdict = 'supported'\n reasons.push('claim-within-bound')\n explanation.push(\n higherIsBetter\n ? `${subject} is ${strictBound ? 'below' : 'no higher than'} the lower end of the ${cl} Wilson interval (${bottom}).`\n : `${subject}${qualifier} is ${strictBound ? 'above' : 'no lower than'} the upper end of the ${cl} Wilson interval (${top}).`,\n )\n } else if (matchesObserved) {\n // An honest report of the observed rate comes first: a rounded figure can\n // land just outside the interval it was rounded from.\n verdict = 'supported'\n reasons.push('matches-observed-rate')\n explanation.push(`${subject}${qualifier} ${matchesText}`)\n } else if (higherIsBetter ? assessed > w.high + tolFor(assessed) : assessed < w.low - tolFor(assessed)) {\n verdict = 'contradicted'\n reasons.push('claim-outside-interval')\n // At a sample of billions of items one wrong item leaves the limit within a rounding of 100% (or 0%):\n // the limit is still on the near side of the claim, so say that instead of printing a bare 100%.\n const nearCertain = higherIsBetter\n ? successes < n && top === pctCeil(1, 3)\n ? ', which is just under 100% because not every item was counted right'\n : null\n : successes > 0 && bottom === pctFloor(0, 3)\n ? ', which is just above 0% because at least one error was counted'\n : null\n explanation.push(\n higherIsBetter\n ? `${subject} is above the top of the ${cl} Wilson interval${nearCertain ?? ` (${top})`}.`\n : `${subject}${qualifier} is below the bottom of the ${cl} Wilson interval${nearCertain ?? ` (${bottom})`}.`,\n )\n } else {\n verdict = 'overstated'\n reasons.push('claim-beyond-conservative-bound')\n if (absolute) {\n // 100% (or 0%) is certainty: the Wilson interval itself ends at 1 (or 0) when every item agreed,\n // but the conservative limit never establishes it.\n explanation.push(\n higherIsBetter\n ? `${subject} cannot be stated from a sample: even when every item was right (${observedText}), the conservative lower limit cannot establish 100%. The most the evidence supports is ${bottom}, the lower end of the ${cl} Wilson interval.`\n : `${subject}${qualifier} cannot be stated from a sample: even when no item was wrong (${observedText}), the conservative upper limit cannot establish 0%. The least the evidence supports is ${top}, the upper end of the ${cl} Wilson interval.`,\n )\n } else {\n let sentence = higherIsBetter\n ? `${subject} is inside the ${cl} Wilson interval but above its lower end (${bottom}), which is the most the evidence supports.`\n : `${subject}${qualifier} is inside the ${cl} Wilson interval but below its upper end (${top}), which is the least the evidence supports.`\n // A bound printed rounded to the nearest digit (\"99.1%+\" from a limit of 99.046%) can land\n // just past the limit; the figure to print is the limit rounded in the cautious direction.\n const printedDecimals = figure !== undefined && figure.bound !== null ? figure.info.decimals : null\n if (printedDecimals !== null && figure !== undefined) {\n const oneUnit = 10 ** -(printedDecimals + 2)\n if (higherIsBetter && figure.bound === 'floor' && assessed - w.low < oneUnit) {\n sentence += ` The shortfall is within the rounding of the last printed digit, so print the bound rounded down: ${pctFloor(w.low, printedDecimals)}.`\n } else if (!higherIsBetter && figure.bound === 'ceiling' && w.high - assessed < oneUnit) {\n sentence += ` The shortfall is within the rounding of the last printed digit, so print the bound rounded up: ${pctCeil(w.high, printedDecimals)}.`\n }\n }\n // A figure on the cautious side of the observed rate is the usual honest round-down or\n // truncation (99.6 printed as 99): say so, and what to print instead. Only advise a figure the\n // same assessment would pass (see observedAdvice): the observed rate is no way out when it is 0\n // or 100% (a sample cannot show certainty), with options.conservative, or when no display\n // within the precision strictPrecision allows can match it; the bound is printed at the\n // precision the interval permits when strictPrecision or conservative is set.\n if (beyondNoise(w.point, assessed, higherIsBetter)) {\n const allowed = maxDisplayDecimals(w.high - w.low)\n const printDecimals = strictPrecision ? allowed : Math.min(allowed + 2, 5)\n const observedFigure = conservative ? null : observedAdvice(w.point, successes, n, strictPrecision ? allowed : null, higherIsBetter)\n // The default observed figure is the one the sentence already quotes at three decimals;\n // only a different figure (a precision limit, or more digits to keep it off 100%) is spelled out.\n const observedPart =\n observedFigure === null\n ? ''\n : !strictPrecision && observedFigure === pctNearest(w.point, 3)\n ? 'print the observed rate, or '\n : `print the observed rate (${observedFigure}), or `\n // The bound at the permitted precision is cut in the cautious direction, so it is never\n // beyond the conservative end and always passes as a claim of its own.\n const lead = higherIsBetter\n ? ` The figure is also below the observed rate (${observedText}, ${pctNearest(w.point, 3)}): `\n : ` The figure is also above the observed rate (${observedText}, ${pctNearest(w.point, 3)}): `\n sentence += higherIsBetter\n ? `${lead}${observedPart}go down to the lower end (${pctFloor(w.low, printDecimals)}).`\n : `${lead}${observedPart}go up to the upper end (${pctCeil(w.high, printDecimals)}).`\n }\n explanation.push(sentence)\n }\n }\n\n if (figure !== undefined && figure.bandNote !== null) {\n explanation[0] = `${explanation[0] as string} ${figure.bandNote}`\n }\n\n let precisionNote = ''\n if (displayDecimals !== null) {\n const allowed = maxDisplayDecimals(w.high - w.low)\n if (displayDecimals > allowed) {\n const text = `The figure is printed to ${placesWord(displayDecimals)}, but the interval is ${pctNearest(w.high - w.low, 2).replace('%', '')} percentage points wide and supports ${supportsWord(allowed)}.`\n if (strictPrecision && verdict === 'supported') {\n // The value itself is fine; only the printed precision overreaches.\n reasons.length = 0\n explanation.length = 0\n verdict = 'overstated'\n }\n reasons.push('precision-too-fine')\n explanation.push(text)\n precisionNote = printAdvice(allowed)\n }\n }\n\n // A claim far less favorable than the counts (outside the 99.9% interval on\n // the pessimistic side) looks like a stale or mistyped figure. Informational:\n // the verdict is unchanged.\n if (verdict !== 'contradicted') {\n const wide = wilsonWithZ(successes, n, zForConfidence(0.999))\n const worse = higherIsBetter ? assessed < wide.low - tolFor(assessed) : assessed > wide.high + tolFor(assessed)\n if (worse) {\n reasons.push('claim-worse-than-counts')\n explanation.push(\n `${subject} is far less favorable than the counts support (the 99.9% Wilson interval is ${pctFloor(wide.low, 3)} to ${pctCeil(wide.high, 3)}). If this is a published figure it may be stale or wrong.`,\n )\n }\n }\n\n // The interval pools the strata as one simple random sample. It is not\n // reweighted by population share, and the kit has no population shares to\n // reweight with, so a stratified result says so (informational).\n if (sampling === 'stratified') {\n reasons.push('strata-not-reweighted')\n explanation.push('The strata are pooled as one sample and not reweighted by population share, so the interval describes the pooled counts, not the population, unless each stratum was sampled in proportion to its size. Report each stratum, or reweight them yourself.')\n }\n\n const textNote = textFigureNote(claimText, judgedValue, assessed, higherIsBetter)\n if (textNote !== null) {\n reasons.push('text-figure-differs')\n explanation.push(textNote)\n }\n\n // ---- statement ---------------------------------------------------------\n // One precision for the headline bound and the interval it quotes.\n const decimals = Math.min(maxDisplayDecimals(w.high - w.low) + 2, 5)\n // The lead names the scope first: the figure is about this sample (or the\n // declared evaluated population), so a pasted headline cannot read as a\n // property of the system.\n const scope = population === undefined ? 'On this sample' : `On this sample of ${population.evaluated}`\n const headline = higherIsBetter\n ? `${scope}, at least ${pctFloor(w.low, decimals)} ${metricName}`\n : `${scope}, at most ${pctCeil(w.high, decimals)} ${metricName}`\n const caveat = sampling === 'cross-validation' ? SAMPLING_ERROR_ONLY_CV : SAMPLING_ERROR_ONLY\n const parts = [\n `${cl} Wilson interval ${pctFloor(w.low, decimals)} to ${pctCeil(w.high, decimals)}`,\n `n = ${String(n)}`,\n labelWord,\n SAMPLE_WORD[sampling] ?? 'random sample',\n ]\n if (evaluatedAtRaw !== undefined) parts.push(`evaluated ${evaluatedAtRaw as string}`)\n if (agreement !== undefined && agreement.value !== null) {\n parts.push(`${STATISTIC_LABEL[agreement.statistic]} ${decimalCut(agreement.value, 2, 'down')}`)\n }\n return {\n verdict,\n reasons,\n explanation,\n metric,\n claimed,\n assessedValue: assessed,\n n,\n basis: 'wilson-interval',\n parsedDisplay,\n checks,\n interval,\n conservativeBound,\n suggestedStatement: `${headline} (${parts.join(', ')}); ${caveat}${precisionNote}`,\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"assess.js","sourceRoot":"","sources":["../src/assess.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAEnE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,kBAAkB,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAahJ,OAAO,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,aAAa,GACd,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC3H,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEvF,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T,WAAW,CAAC,QAAQ,CAAC,IAAI,eAAe;KACzC,CAAA;IACD,IAAI,cAAc,KAAK,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,aAAa,cAAwB,EAAE,CAAC,CAAA;IACrF,IAAI,SAAS,KAAK,SAAS,IAAI,SAAS,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QACxD,KAAK,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC,CAAA;IACjG,CAAC;IACD,OAAO;QACL,OAAO;QACP,OAAO;QACP,WAAW;QACX,MAAM;QACN,OAAO;QACP,aAAa,EAAE,QAAQ;QACvB,CAAC;QACD,KAAK,EAAE,iBAAiB;QACxB,aAAa;QACb,MAAM;QACN,QAAQ;QACR,iBAAiB;QACjB,kBAAkB,EAAE,GAAG,QAAQ,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,MAAM,GAAG,aAAa,EAAE;KACnF,CAAA;AACH,CAAC","sourcesContent":["import type { AgreementStatistic, UndefinedAgreementReason } from './agreement.js'\nimport { countDecimals, matchesValue } from './census.js'\nimport { dayNumber } from './dates.js'\nimport { parseDisplayFigure, textFiguresDiffering } from './display.js'\nimport { beyondNoise, snapAbsolute, VALUE_NOISE } from './exact.js'\nimport type { DisplayFigure } from './display.js'\nimport { confidenceLabel, decimalCut, maxDisplayDecimals, pctBound, pctCeil, pctFloor, pctNearest, pctNumericBound, pctRate } from './format.js'\nimport type {\n AccuracyAssessment,\n AccuracyClaimInput,\n AccuracyVerdict,\n AssessOptions,\n ClaimMetric,\n GateChecks,\n UnsupportedMetric,\n LabelSource,\n ReasonCode,\n SamplingMethod,\n} from './types.js'\nimport {\n clip,\n isRecord,\n MAX_COUNT,\n readCount,\n readFiniteInRange,\n readLength,\n assertKnownKeys,\n assertPlainObject,\n readOpenUnit,\n requireRecord,\n} from './validate.js'\nimport { assertPlainText, foldText, MAX_LABEL_LENGTH, MAX_TEXT_LENGTH, mentionsName, readName, shownText } from './text.js'\nimport { DEFAULT_CONFIDENCE, wilsonWithZ, zForConfidence, zForTail } from './wilson.js'\n\n/** Lowest confidence level `assessAccuracyClaim` accepts. `wilsonInterval` takes any level strictly between 0 and 1. */\nconst MIN_ASSESS_CONFIDENCE = 0.5\n\n/** Smallest sample that gets a verdict unless options.minN says otherwise. */\nexport const DEFAULT_MIN_N = 30\n\n/**\n * Absolute tolerance, as a proportion, when a claim is compared with an\n * interval limit. A claim within this distance of a limit counts as being at\n * the limit, on the claimant's side. It exists only to absorb binary\n * floating-point noise (a claim of exactly 0.98 against a limit that\n * computes to 0.98000000000000001). It is far below the width of any\n * interval met in practice; it can only matter for samples above about 4e12\n * items with a rate within about 1e-12 of 0 or 1, where the interval itself\n * is narrower than the tolerance. A claim of exactly 0 or 1 is absolute and\n * never uses it.\n */\nexport const COMPARISON_TOLERANCE = 1e-12\n\nconst SOURCES: readonly LabelSource[] = ['human', 'automated', 'by-construction', 'model', 'mixed', 'unknown']\nconst SAMPLINGS: readonly SamplingMethod[] = ['random', 'stratified', 'ranked', 'convenience', 'unknown', 'complete', 'held-out-split', 'cross-validation']\nconst METRICS: readonly ClaimMetric[] = [\n 'accuracy',\n 'error-rate',\n 'precision',\n 'recall',\n 'false-positive-rate',\n 'false-negative-rate',\n 'specificity',\n 'npv',\n 'sensitivity',\n 'ppa',\n 'ppv',\n 'npa',\n 'opa',\n]\n/** Metrics the kit knows it cannot judge: they get a refusal, not a throw. */\nconst UNSUPPORTED_METRICS: readonly UnsupportedMetric[] = [\n 'f1', 'auc', 'roc-auc', 'wer', 'cer', 'bleu', 'rouge', 'map', 'composite', 'other',\n]\nconst HIGHER_IS_BETTER: readonly ClaimMetric[] = ['accuracy', 'precision', 'recall', 'specificity', 'npv', 'sensitivity', 'ppa', 'ppv', 'npa', 'opa']\nconst METRIC_PHRASE: Record<ClaimMetric, string> = {\n accuracy: 'accurate',\n 'error-rate': 'error rate',\n precision: 'precision',\n recall: 'recall',\n 'false-positive-rate': 'false-positive rate',\n 'false-negative-rate': 'false-negative rate',\n specificity: 'specificity',\n npv: 'negative predictive value',\n sensitivity: 'sensitivity',\n ppa: 'positive percent agreement',\n ppv: 'positive predictive value',\n npa: 'negative percent agreement',\n opa: 'overall percent agreement',\n}\n/** What a bare value (no display) is read at; nothing was printed, so the text must not say so. */\nconst VALUE_PRECISION = 'the precision of the value (a whole percent at the coarsest)'\nconst SUPPORTED_LIST = 'accuracy, error-rate, precision, recall, false-positive-rate, false-negative-rate, specificity, npv and the diagnostic names sensitivity, ppa, ppv, npa and opa'\n// The keys each caller-supplied object may carry. Anything else is a typo that\n// would silently switch a check off, so it throws.\nconst OPTION_KEYS = ['confidence', 'minN', 'minAgreement', 'maxAgeDays', 'now', 'strictPrecision', 'conservative', 'requireScope'] as const\nconst INPUT_KEYS = ['claim', 'sample', 'provenance', 'sampling', 'strata', 'retractions', 'benchmark', 'population', 'evaluatedAt'] as const\nconst CLAIM_KEYS = ['metric', 'value', 'display', 'text'] as const\nconst SAMPLE_KEYS = ['n', 'correct', 'errors'] as const\nconst STRATUM_KEYS = ['name', 'n', 'correct', 'errors'] as const\nconst PROVENANCE_KEYS = ['source', 'raters', 'agreement'] as const\nconst AGREEMENT_KEYS = ['statistic', 'status', 'value', 'n', 'agreements', 'categories', 'reason'] as const\nconst RETRACTION_KEYS = ['count', 'includedInSample'] as const\nconst BENCHMARK_KEYS = ['name'] as const\nconst POPULATION_KEYS = ['claimed', 'evaluated'] as const\nconst STATISTICS: readonly AgreementStatistic[] = ['percent-agreement', 'cohen-kappa', 'gwet-ac1']\nconst UNDEFINED_REASONS: readonly UndefinedAgreementReason[] = ['no-pairs', 'expected-agreement-is-1', 'single-category']\nconst STATISTIC_LABEL: Record<AgreementStatistic, string> = {\n 'percent-agreement': 'percent agreement',\n 'cohen-kappa': 'Cohen kappa',\n 'gwet-ac1': 'Gwet AC1',\n}\n\nfunction readEnum<T extends string>(value: unknown, allowed: readonly T[], name: string): T {\n if (typeof value !== 'string') throw new TypeError(`${name} must be a string`)\n const found = allowed.find((candidate) => candidate === value)\n if (found === undefined) {\n throw new RangeError(`${name} must be one of ${allowed.join(', ')}; got \"${clip(value)}\"`)\n }\n return found\n}\n\n/**\n * The metric: judged (exact, lower-case name), known-unsupported (refused\n * later; case does not matter, since such a name can only be refused), or\n * unknown (thrown). A judged name in the wrong case is a typo that throws, with\n * the name the caller probably meant.\n */\nfunction readMetric(raw: unknown): { metric: ClaimMetric | UnsupportedMetric; judged: boolean } {\n if (typeof raw !== 'string') throw new TypeError('claim.metric must be a string')\n const supported = METRICS.find((m) => m === raw)\n if (supported !== undefined) return { metric: supported, judged: true }\n const lower = raw.toLowerCase()\n const unsupported = UNSUPPORTED_METRICS.find((m) => m === lower)\n if (unsupported !== undefined) return { metric: unsupported, judged: false }\n const meant = METRICS.find((m) => m === lower)\n const hint = meant === undefined ? '' : `; did you mean \"${meant}\"?`\n throw new RangeError(\n `claim.metric must be one of ${METRICS.join(', ')}, or one of ${UNSUPPORTED_METRICS.join(', ')} (which the kit knows and refuses, in any case); got \"${clip(raw)}\"${hint}`,\n )\n}\n\ninterface Counts {\n n: number\n correct: number\n}\n\n/** Reads {n, correct?, errors?} for the sample; null when no counts were disclosed at all. */\nfunction readSampleCounts(raw: unknown): Counts | null {\n if (raw === undefined) return null\n const rec = requireRecord(raw, 'sample')\n assertKnownKeys(rec, SAMPLE_KEYS, 'sample')\n const nRaw: unknown = rec.n\n const correctRaw: unknown = rec.correct\n const errorsRaw: unknown = rec.errors\n if (nRaw === undefined && correctRaw === undefined && errorsRaw === undefined) return null\n return readCounts({ n: nRaw, correct: correctRaw, errors: errorsRaw }, 'sample')\n}\n\n/** Reads {n, correct?, errors?}; each property once. */\nfunction readCounts(raw: unknown, name: string): Counts {\n const rec = requireRecord(raw, name)\n const nRaw: unknown = rec.n\n const correctRaw: unknown = rec.correct\n const errorsRaw: unknown = rec.errors\n const n = readCount(nRaw, `${name}.n`, 1)\n if (correctRaw === undefined && errorsRaw === undefined) {\n throw new TypeError(`${name} needs correct or errors`)\n }\n const correct = correctRaw === undefined ? undefined : readCount(correctRaw, `${name}.correct`, 0)\n const errors = errorsRaw === undefined ? undefined : readCount(errorsRaw, `${name}.errors`, 0)\n if (correct !== undefined && correct > n) {\n throw new RangeError(`${name}.correct (${String(correct)}) is larger than n (${String(n)})`)\n }\n if (errors !== undefined && errors > n) {\n throw new RangeError(`${name}.errors (${String(errors)}) is larger than n (${String(n)})`)\n }\n if (correct !== undefined && errors !== undefined && correct + errors !== n) {\n throw new RangeError(`${name}.correct + ${name}.errors must equal n`)\n }\n return { n, correct: correct !== undefined ? correct : n - (errors as number) }\n}\n\ninterface Agreement {\n statistic: AgreementStatistic\n value: number | null\n /** Items the statistic was computed on; null for a hand-written {statistic, value}, which is trusted. */\n n: number | null\n}\n\nfunction readAgreement(raw: unknown): Agreement {\n const rec = requireRecord(raw, 'provenance.agreement')\n assertKnownKeys(rec, AGREEMENT_KEYS, 'provenance.agreement')\n const statisticRaw: unknown = rec.statistic\n const statusRaw: unknown = rec.status\n const valueRaw: unknown = rec.value\n const nRaw: unknown = rec.n\n const agreementsRaw: unknown = rec.agreements\n const categoriesRaw: unknown = rec.categories\n const reasonRaw: unknown = rec.reason\n const statistic = readEnum(statisticRaw, STATISTICS, 'provenance.agreement.statistic')\n if (statusRaw !== undefined && statusRaw !== 'defined' && statusRaw !== 'undefined') {\n throw new RangeError('provenance.agreement.status must be \"defined\" or \"undefined\"')\n }\n const n = nRaw === undefined ? null : readCount(nRaw, 'provenance.agreement.n', 0)\n // The keys a kit result carries are allowed so it can be passed straight in; they\n // are not used, but nonsense in them means the object is not what it claims to be.\n const agreements = agreementsRaw === undefined ? null : readCount(agreementsRaw, 'provenance.agreement.agreements', 0)\n if (agreements !== null && n !== null && agreements > n) {\n throw new RangeError(`provenance.agreement.agreements (${String(agreements)}) is larger than provenance.agreement.n (${String(n)})`)\n }\n if (categoriesRaw !== undefined) readCount(categoriesRaw, 'provenance.agreement.categories', 0)\n if (reasonRaw !== undefined) readEnum(reasonRaw, UNDEFINED_REASONS, 'provenance.agreement.reason')\n if (statusRaw === 'undefined') {\n // A statistic that has no value must say so with null; NaN, 0 or text in\n // its place is malformed input, not \"cannot tell\".\n if (valueRaw !== null) {\n const message = 'provenance.agreement.value must be null when status is \"undefined\"'\n throw typeof valueRaw === 'number' ? new RangeError(message) : new TypeError(message)\n }\n return { statistic, value: null, n }\n }\n return { statistic, value: readFiniteInRange(valueRaw, 'provenance.agreement.value', -1, 1), n }\n}\n\ninterface Stratum {\n name: string\n n: number\n correct: number\n}\n\nfunction readStrata(raw: unknown): Stratum[] {\n if (!Array.isArray(raw)) throw new TypeError('strata must be an array')\n const length = readLength((raw as unknown[]).length, 'strata')\n if (length === 0) throw new RangeError('strata must not be empty; leave it out if there are none')\n const out: Stratum[] = []\n const names = new Set<string>()\n for (let i = 0; i < length; i++) {\n const entry: unknown = (raw as unknown[])[i]\n const rec = requireRecord(entry, `strata[${i}]`)\n assertKnownKeys(rec, STRATUM_KEYS, `strata[${i}]`)\n const nameRaw: unknown = rec.name\n if (typeof nameRaw !== 'string') throw new TypeError(`strata[${i}].name must be a string`)\n if (nameRaw === '') throw new RangeError(`strata[${i}].name must not be empty`)\n if (nameRaw.length > MAX_LABEL_LENGTH) {\n throw new RangeError(`strata[${i}].name must be at most ${String(MAX_LABEL_LENGTH)} characters`)\n }\n const name = shownText(nameRaw, `strata[${i}].name`)\n if (name === '') throw new RangeError(`strata[${i}].name must not be blank`)\n if (names.has(name)) throw new RangeError(`strata[${i}].name \"${clip(name)}\" is a duplicate`)\n names.add(name)\n const counts = readCounts(rec, `strata[${i}]`)\n out.push({ name, ...counts })\n }\n return out\n}\n\nconst REFUSAL_PHRASE: Record<string, string> = {\n 'metric-not-supported': 'this kit cannot judge that kind of metric',\n 'n-undisclosed': 'the number of items checked was not disclosed',\n 'no-human-labels': 'the labels were not checked by people',\n 'unknown-label-source': 'nobody has said where the labels came from',\n 'mixed-label-source': 'only some labels came from people and the counts are not split',\n 'ranked-sample': 'the sample was picked by rank, not at random',\n 'convenience-sample': 'the sample was whatever was easy to collect',\n 'unknown-sampling': 'nobody has said how the sample was picked',\n 'sample-too-small': 'the sample is too small',\n 'merged-strata-differ': 'groups with clearly different rates were merged into one number',\n 'retractions-not-included': 'known retractions are not in the counts',\n 'agreement-missing': 'no agreement statistic was supplied for the required agreement check',\n 'agreement-undefined': 'the agreement statistic could not be computed',\n 'agreement-below-minimum': 'the raters agreed less than the required minimum',\n 'agreement-sample-too-small': 'the agreement statistic was computed on too few items',\n 'stratified-without-strata': 'the sample is stratified but the strata were not supplied, so the pooled counts cannot be read as the population rate',\n 'benchmark-unnamed': 'a complete-set or held-out-split claim needs the name of the fixed set',\n 'claim-not-scoped-to-benchmark': 'the claim wording does not name the benchmark, so a benchmark score is standing in for a general claim',\n 'evaluation-date-missing': 'a maximum age was set but the evaluation date was not supplied',\n 'evaluation-stale': 'the evaluation is older than the allowed age',\n 'scope-mismatch': 'the claim covers a different population than the one evaluated',\n 'scope-undeclared': 'the claimed and evaluated populations were not declared',\n}\n\nconst LABEL_WORD: Record<'human' | 'automated' | 'by-construction', string> = {\n human: 'human labels',\n automated: 'automated labels',\n 'by-construction': 'labels fixed by construction',\n}\n\n/** What the interval in a statement does and does not cover, said in the statement itself. */\nconst SAMPLING_ERROR_ONLY = 'the interval covers sampling error only'\nconst SAMPLING_ERROR_ONLY_CV = 'the interval covers sampling error only and is optimistic because cross-validation folds share data'\n\nconst SAMPLE_WORD: Partial<Record<SamplingMethod, string>> = {\n stratified: 'stratified sample, unweighted pooled',\n 'cross-validation': 'cross-validation estimate',\n}\n\n/** \"1 decimal place\", \"2 decimal places\"; whole percents have none. */\nfunction placesWord(decimals: number): string {\n return decimals === 1 ? '1 decimal place' : `${String(decimals)} decimal places`\n}\n/** What a precision limit allows: \"whole percents only\", \"at most 1 decimal place\". */\nfunction supportsWord(decimals: number): string {\n return decimals === 0 ? 'whole percents only' : `at most ${placesWord(decimals)}`\n}\n/**\n * The observed rate as a figure to print that the same assessment would pass as\n * `matches-observed-rate`, or null when none exists. With `maxDecimals` null\n * (the default, where excess precision is only noted) the figure is printed to\n * three decimals, or to as many more as it takes to keep it off 0% and 100%\n * (those are absolute claims a sample cannot show); with a limit (strictPrecision)\n * it must fit that many decimals, and an exact tie may be reached from either\n * neighbor. A candidate is judged by the display parser itself, so it cannot\n * drift from what the assessment accepts.\n */\nfunction observedAdvice(point: number, successes: number, n: number, maxDecimals: number | null, higherIsBetter: boolean): string | null {\n if (point === 0 || point === 1) return null\n const first = maxDecimals === null ? 3 : maxDecimals\n const last = maxDecimals === null ? 12 : maxDecimals\n for (let d = first; d <= last; d++) {\n for (const printed of [pctNearest(point, d), pctFloor(point, d), pctCeil(point, d)]) {\n const figure = parseDisplayFigure(printed, higherIsBetter)\n if (figure.info.figure !== 0 && figure.info.figure !== 1 && figure.matchesObserved(successes, n)) return printed\n }\n }\n return null\n}\n\n/** The statement's advice on how to print the figure. */\nfunction printAdvice(decimals: number): string {\n return decimals === 0 ? '; print it as a whole percent' : `; print it to at most ${placesWord(decimals)}`\n}\n\n/** Trim fixed decimal padding while preserving the exponent of a tiny point rate. */\nfunction mismatchPercent(proportion: number): string {\n return pctRate(proportion, 3).replace(/(\\.\\d*?[1-9])0+%$|\\.0+%$/, '$1%')\n}\n\n/**\n * The informational note for a figure in `claim.text` that is not the figure\n * judged (`text-figure-differs`), or null. The text is only scanned: a verdict\n * is never changed by it.\n */\nfunction textFigureNote(text: string | undefined, claimed: number, assessed: number, higherIsBetter: boolean): string | null {\n if (text === undefined) return null\n const differing = textFiguresDiffering(text, claimed, assessed, higherIsBetter)\n if (differing.length === 0) return null\n const shown = differing.slice(0, 3).map((figure) => `\"${clip(figure, 40)}\"`).join(', ')\n const more = differing.length > 3 ? ` and ${String(differing.length - 3)} more` : ''\n return `claim.text says ${shown}${more}, which is not the figure judged (${pctRate(assessed, 3)}). The verdict judges value and display, never the wording, so make the text say what was judged.`\n}\n\n/**\n * Does this accuracy or error-rate claim have the evidence to carry it?\n *\n * Pure statistics on the counts you pass in. It never judges whether the\n * labels are right and cannot see how the sample was really drawn; it takes\n * your `provenance` and `sampling` declarations at their word and refuses\n * when they do not support a figure.\n *\n * Verdicts:\n * - refused: a precondition failed. This means \"cannot tell\", not \"false\".\n * - contradicted: the claim is more favorable than the interval's best end.\n * - overstated: inside the interval but more favorable than the observed\n * rate (or, with options.conservative, than the conservative end), or\n * printed with finer precision than the interval allows.\n * - supported: no more favorable than the conservative end, or an honest\n * report of the observed rate to its printed precision.\n *\n * Malformed input throws (TypeError for a wrong type, RangeError for a wrong\n * value); it never returns a verdict. Every input property is read once.\n */\nexport function assessAccuracyClaim(\n input: AccuracyClaimInput,\n options?: AssessOptions,\n): AccuracyAssessment {\n // ---- read and validate everything before judging anything -------------\n if (options !== undefined && !isRecord(options)) {\n throw new TypeError('options must be an object')\n }\n if (options !== undefined) {\n assertPlainObject(options, 'options')\n assertKnownKeys(options, OPTION_KEYS, 'options')\n }\n const confidenceRaw: unknown = options === undefined ? undefined : options.confidence\n const minNRaw: unknown = options === undefined ? undefined : options.minN\n const minAgreementRaw: unknown = options === undefined ? undefined : options.minAgreement\n const confidence =\n confidenceRaw === undefined ? DEFAULT_CONFIDENCE : readOpenUnit(confidenceRaw, 'options.confidence')\n // A level below one half is a typo (0.05 for 0.95): its \"interval\" is narrower\n // than the data's own noise and an \"at least\" statement built on it means nothing.\n if (confidence < MIN_ASSESS_CONFIDENCE) {\n throw new RangeError(`options.confidence must be at least ${String(MIN_ASSESS_CONFIDENCE)} for a verdict (0.95 is the default); got ${String(confidence)}`)\n }\n const z = zForConfidence(confidence)\n const minN = minNRaw === undefined ? DEFAULT_MIN_N : readCount(minNRaw, 'options.minN', 1)\n const minAgreement =\n minAgreementRaw === undefined ? undefined : readFiniteInRange(minAgreementRaw, 'options.minAgreement', -1, 1)\n const maxAgeRaw: unknown = options === undefined ? undefined : options.maxAgeDays\n const nowRaw: unknown = options === undefined ? undefined : options.now\n const requireScopeRaw: unknown = options === undefined ? undefined : options.requireScope\n const conservativeRaw: unknown = options === undefined ? undefined : options.conservative\n const strictPrecisionRaw: unknown = options === undefined ? undefined : options.strictPrecision\n const maxAgeDays = maxAgeRaw === undefined ? undefined : readCount(maxAgeRaw, 'options.maxAgeDays', 0)\n if (maxAgeDays !== undefined && nowRaw === undefined) {\n throw new TypeError('options.now is required with options.maxAgeDays: the kit never reads a clock')\n }\n const nowDay = nowRaw === undefined ? undefined : dayNumber(nowRaw, 'options.now')\n if (requireScopeRaw !== undefined && typeof requireScopeRaw !== 'boolean') {\n throw new TypeError('options.requireScope must be a boolean')\n }\n if (conservativeRaw !== undefined && typeof conservativeRaw !== 'boolean') {\n throw new TypeError('options.conservative must be a boolean')\n }\n if (strictPrecisionRaw !== undefined && typeof strictPrecisionRaw !== 'boolean') {\n throw new TypeError('options.strictPrecision must be a boolean')\n }\n const requireScope = requireScopeRaw === true\n const conservative = conservativeRaw === true\n // Excess printed precision is informational unless asked for, or in conservative mode.\n const strictPrecision = strictPrecisionRaw === true || conservative\n\n const root = requireRecord(input, 'input')\n assertKnownKeys(root, INPUT_KEYS, 'input')\n const claimRaw: unknown = root.claim\n const sampleRaw: unknown = root.sample\n const provenanceRaw: unknown = root.provenance\n const samplingRaw: unknown = root.sampling\n const strataRaw: unknown = root.strata\n const retractionsRaw: unknown = root.retractions\n const benchmarkRaw: unknown = root.benchmark\n const populationRaw: unknown = root.population\n const evaluatedAtRaw: unknown = root.evaluatedAt\n\n const claimRec = requireRecord(claimRaw, 'claim')\n assertKnownKeys(claimRec, CLAIM_KEYS, 'claim')\n const metricRaw: unknown = claimRec.metric\n const valueRaw: unknown = claimRec.value\n const displayRaw: unknown = claimRec.display\n const textRaw: unknown = claimRec.text\n\n // The metric: judged, or known-unsupported (refused below), or a typo (thrown).\n const { metric, judged } = readMetric(metricRaw)\n const higherIsBetter = judged && HIGHER_IS_BETTER.includes(metric as ClaimMetric)\n\n // A value is a proportion from 0 to 1 for a judged metric. An unsupported\n // metric (a word error rate can pass 1) only needs to be a number.\n const claimed = readFiniteInRange(valueRaw, 'claim.value', -Infinity, Infinity)\n // A value within the floating-point noise of 0 or 1 is the absolute claim of 0 or\n // 1 (ten 0.1s added up is 100%, not \"99.99999999999999% so matches 99.5%\"), and\n // that includes a computed value that overshoots by the noise (1.0000000000000002).\n // Further out it is not a proportion. `claimed` stays as supplied for the result;\n // every judgment uses `judgedValue`.\n if (judged && (claimed < -VALUE_NOISE || claimed > 1 + VALUE_NOISE)) {\n throw new RangeError(`claim.value must be a finite number between 0 and 1, got ${String(claimed)}`)\n }\n const judgedValue = judged ? snapAbsolute(claimed) : claimed\n\n if (displayRaw !== undefined && typeof displayRaw !== 'string') throw new TypeError('claim.display must be a string')\n let figure: DisplayFigure | undefined\n if (displayRaw !== undefined && judged) {\n figure = parseDisplayFigure(displayRaw, higherIsBetter)\n // Exact: the value must agree with the printed figure to its rounding plus\n // one ulp of the value. No float tolerance is involved.\n if (!figure.consistentWith(judgedValue)) {\n throw new RangeError(\n `claim.display \"${clip(displayRaw, 40)}\" (${mismatchPercent(figure.info.figure)}) does not match claim.value ${String(claimed)} (${mismatchPercent(claimed)}): ${figure.mismatchHint}`,\n )\n }\n }\n const displayIsPoint = figure !== undefined && figure.bound === null\n const displayDecimals =\n figure !== undefined && figure.info.form !== 'one-in-n' && figure.bound === null ? figure.info.decimals : null\n\n let claimText: string | undefined\n if (textRaw !== undefined) {\n if (typeof textRaw !== 'string') throw new TypeError('claim.text must be a string')\n if (textRaw.length > MAX_TEXT_LENGTH) throw new RangeError(`claim.text must be at most ${String(MAX_TEXT_LENGTH)} characters`)\n assertPlainText(textRaw, 'claim.text', 'put the claim on one line (join the lines with spaces) before passing it')\n claimText = textRaw\n }\n\n const counts = readSampleCounts(sampleRaw)\n\n const provRec = requireRecord(provenanceRaw, 'provenance')\n assertKnownKeys(provRec, PROVENANCE_KEYS, 'provenance')\n const sourceRaw: unknown = provRec.source\n const ratersRaw: unknown = provRec.raters\n const agreementRaw: unknown = provRec.agreement\n const source = readEnum(sourceRaw, SOURCES, 'provenance.source')\n const raters = ratersRaw === undefined ? undefined : readCount(ratersRaw, 'provenance.raters', 1)\n const agreement = agreementRaw === undefined ? undefined : readAgreement(agreementRaw)\n if (agreement !== undefined && raters !== undefined && raters < 2) {\n // Agreement is between raters; one rater cannot have produced it.\n throw new RangeError(`provenance.raters is ${String(raters)} but provenance.agreement was supplied; agreement needs at least 2 raters`)\n }\n\n const sampling = readEnum(samplingRaw, SAMPLINGS, 'sampling')\n const isFixedSet = sampling === 'complete' || sampling === 'held-out-split'\n\n let benchmarkName: string | undefined\n if (benchmarkRaw !== undefined) {\n const rec = requireRecord(benchmarkRaw, 'benchmark')\n assertKnownKeys(rec, BENCHMARK_KEYS, 'benchmark')\n const nameRaw: unknown = rec.name\n benchmarkName = readName(nameRaw, 'benchmark.name')\n if (!isFixedSet) {\n throw new RangeError(\"benchmark is only for sampling: 'complete' or 'held-out-split'\")\n }\n }\n\n let population: { claimed: string; evaluated: string } | undefined\n if (populationRaw !== undefined) {\n const rec = requireRecord(populationRaw, 'population')\n assertKnownKeys(rec, POPULATION_KEYS, 'population')\n const claimedRaw: unknown = rec.claimed\n const evaluatedRaw: unknown = rec.evaluated\n population = {\n claimed: readName(claimedRaw, 'population.claimed'),\n evaluated: readName(evaluatedRaw, 'population.evaluated'),\n }\n }\n\n const evaluatedDay = evaluatedAtRaw === undefined ? undefined : dayNumber(evaluatedAtRaw, 'evaluatedAt')\n if (evaluatedDay !== undefined && nowDay !== undefined && evaluatedDay > nowDay) {\n throw new RangeError('evaluatedAt is after options.now')\n }\n\n const strata = strataRaw === undefined ? undefined : readStrata(strataRaw)\n // The strata's own totals, as text for a refusal that asks for the pooled counts (null when none or too big to say)\n let strataTotals: string | null = null\n if (strata !== undefined) {\n // BigInt: a plain sum can round past 2^53 and falsely equal the total.\n let sumN = 0n\n let sumCorrect = 0n\n for (const s of strata) {\n sumN += BigInt(s.n)\n sumCorrect += BigInt(s.correct)\n }\n if (counts !== null) {\n if (sumN !== BigInt(counts.n) || sumCorrect !== BigInt(counts.correct)) {\n throw new RangeError('strata counts must add up to the sample counts')\n }\n } else if (sumN <= BigInt(MAX_COUNT)) {\n strataTotals = `{ n: ${String(sumN)}, correct: ${String(sumCorrect)} }`\n }\n }\n\n let retractionCount = 0\n let retractionsIncluded = true\n if (retractionsRaw !== undefined) {\n const rec = requireRecord(retractionsRaw, 'retractions')\n assertKnownKeys(rec, RETRACTION_KEYS, 'retractions')\n const countRaw: unknown = rec.count\n const includedRaw: unknown = rec.includedInSample\n retractionCount = readCount(countRaw, 'retractions.count', 0)\n if (typeof includedRaw !== 'boolean') {\n throw new TypeError('retractions.includedInSample must be a boolean')\n }\n retractionsIncluded = includedRaw\n if (retractionsIncluded && counts !== null && retractionCount > counts.n) {\n throw new RangeError('retractions.count is larger than the sample, so it cannot all be included')\n }\n }\n\n // Readers see the printed figure, so the more favorable of the value and the\n // parsed figure is what gets judged. A display that disagrees with the value\n // by more than its own rounding already threw above.\n let assessed = judgedValue\n let fromDisplay = false\n if (figure !== undefined) {\n const shown = figure.info.figure\n // A little noise apart is the same figure (82.7 / 100 against 0.827, 1 - 0.8 against\n // 0.2), not a more favorable one.\n const displayWins = beyondNoise(shown, judgedValue, higherIsBetter)\n if (displayWins) {\n assessed = shown\n fromDisplay = true\n }\n }\n const parsedDisplay = figure === undefined ? null : figure.info\n\n // Which optional checks this call actually ran. A gate that was asked for\n // ('applied') is different from one that was left out ('not-supplied').\n const checks: GateChecks = {\n retractions: retractionsRaw !== undefined ? 'applied' : 'not-supplied',\n scope: population !== undefined ? 'applied' : 'not-supplied',\n age: maxAgeDays !== undefined ? 'applied' : 'not-supplied',\n // applied = a minimum was required, or a statistic with a value and an n had its size checked;\n // a statistic that has no value is never examined unless a minimum asks for it\n agreement:\n minAgreement !== undefined || (agreement !== undefined && agreement.n !== null && agreement.value !== null) ? 'applied' : 'not-supplied',\n // applied = two or more strata could be compared; one stratum has nothing to differ from\n strata: strata !== undefined && strata.length > 1 && !isFixedSet ? 'applied' : 'not-supplied',\n }\n\n // ---- preconditions -----------------------------------------------------\n const refusals: ReasonCode[] = []\n const notes: string[] = []\n const metricWord = String(metric)\n\n if (!judged) {\n refusals.push('metric-not-supported')\n notes.push(`\"${clip(String(metric))}\" is not a proportion of independently checked items. This kit judges ${SUPPORTED_LIST}; for anything else, report the counts and method instead.`)\n }\n\n if (source === 'model') {\n refusals.push('no-human-labels')\n notes.push('The labels came from a model, not from people, so there is no human ground truth to count against.')\n } else if (source === 'unknown') {\n refusals.push('unknown-label-source')\n notes.push('The source of the labels is unknown, so it is not possible to tell whether people checked them.')\n } else if (source === 'mixed') {\n refusals.push('mixed-label-source')\n notes.push('Some labels came from a model. Count only the human-labeled items and assess those as a human sample.')\n }\n\n if (sampling === 'ranked') {\n refusals.push('ranked-sample')\n notes.push('The sample was chosen by rank (for example the top-scored items), which does not represent the rest.')\n } else if (sampling === 'convenience') {\n refusals.push('convenience-sample')\n notes.push('The sample is a convenience sample, so the interval does not describe any larger group.')\n } else if (sampling === 'unknown') {\n refusals.push('unknown-sampling')\n notes.push('How the sample was chosen is unknown, so the interval cannot be read as covering a larger group.')\n }\n\n if (sampling === 'stratified' && strata === undefined) {\n refusals.push('stratified-without-strata')\n notes.push('The sample is stratified but no strata were supplied. The pooled counts are not a simple random sample, so they cannot be read as the population rate; supply the strata.')\n }\n\n if (isFixedSet) {\n if (benchmarkName === undefined) {\n refusals.push('benchmark-unnamed')\n notes.push(\"A complete-set or held-out-split claim must name the fixed set it was measured on (the 'benchmark' field).\")\n } else if (claimText === undefined || !mentionsName(claimText, benchmarkName)) {\n refusals.push('claim-not-scoped-to-benchmark')\n notes.push(`The claim wording does not mention \"${clip(benchmarkName)}\". A score on a fixed set describes that set; word the claim for it, or supply a random sample for a general claim.`)\n }\n }\n\n if (counts === null) {\n refusals.push('n-undisclosed')\n notes.push(\n strataTotals === null\n ? 'The sample counts (n and correct or errors) were not supplied, so there is nothing to weigh the figure against.'\n : `The pooled sample counts (n and correct or errors) were not supplied. The strata hold them: pass sample: ${strataTotals}, their sums, with the strata.`,\n )\n } else if (!isFixedSet && counts.n < minN) {\n refusals.push('sample-too-small')\n notes.push(`The sample has ${String(counts.n)} items, below the minimum of ${String(minN)} needed for a verdict.`)\n }\n\n if (!isFixedSet && strata !== undefined && strata.length > 1) {\n // Bonferroni: split the error budget across the strata so that many\n // strata do not make a refusal likelier by chance alone.\n const zStrata = zForTail((1 - confidence) / (2 * strata.length))\n let highestLow = -Infinity\n let lowestHigh = Infinity\n let highestName = ''\n let lowestName = ''\n for (const s of strata) {\n const w = wilsonWithZ(s.correct, s.n, zStrata)\n if (w.low > highestLow) {\n highestLow = w.low\n highestName = s.name\n }\n if (w.high < lowestHigh) {\n lowestHigh = w.high\n lowestName = s.name\n }\n }\n if (highestLow - lowestHigh > COMPARISON_TOLERANCE) {\n refusals.push('merged-strata-differ')\n notes.push(\n `The strata do not agree: \"${clip(highestName)}\" and \"${clip(lowestName)}\" have intervals that do not overlap, so one combined figure hides a real difference. Report each stratum.`,\n )\n }\n }\n\n if (retractionCount > 0 && !retractionsIncluded) {\n refusals.push('retractions-not-included')\n notes.push(`${String(retractionCount)} retracted item(s) are known but are not counted in the sample.`)\n }\n\n if (maxAgeDays !== undefined && nowDay !== undefined) {\n if (evaluatedDay === undefined) {\n refusals.push('evaluation-date-missing')\n notes.push('A maximum age was set but no evaluation date (evaluatedAt) was supplied.')\n } else if (nowDay - evaluatedDay > maxAgeDays) {\n refusals.push('evaluation-stale')\n notes.push(`The evaluation is ${String(nowDay - evaluatedDay)} days old, over the allowed ${String(maxAgeDays)} days.`)\n }\n }\n\n if (population !== undefined) {\n if (foldText(population.claimed) !== foldText(population.evaluated)) {\n refusals.push('scope-mismatch')\n notes.push(`The claim covers \"${clip(population.claimed)}\" but the evaluation covered \"${clip(population.evaluated)}\".`)\n }\n } else if (requireScope) {\n refusals.push('scope-undeclared')\n notes.push('The claimed and evaluated populations were not declared (population).')\n }\n\n if (minAgreement !== undefined) {\n if (agreement === undefined) {\n refusals.push('agreement-missing')\n notes.push('A minimum agreement was required but no agreement statistic was supplied.')\n } else if (agreement.value === null) {\n refusals.push('agreement-undefined')\n notes.push(`${STATISTIC_LABEL[agreement.statistic]} is undefined for these labels, so the agreement requirement cannot be checked.`)\n } else if (agreement.value + COMPARISON_TOLERANCE < minAgreement) {\n refusals.push('agreement-below-minimum')\n notes.push(\n `${STATISTIC_LABEL[agreement.statistic]} is ${decimalCut(agreement.value, 3, 'down')}, below the required ${decimalCut(minAgreement, 3, 'up')}.`,\n )\n }\n }\n\n // An agreement statistic from a handful of items is noise (kappa of 1.0 from 6\n // pairs), whether or not a minimum is required. A hand-written statistic with\n // no n cannot be checked and is trusted.\n if (agreement !== undefined && agreement.value !== null && agreement.n !== null && agreement.n < minN) {\n refusals.push('agreement-sample-too-small')\n notes.push(`${STATISTIC_LABEL[agreement.statistic]} was computed on ${String(agreement.n)} items, below the minimum of ${String(minN)}, so it says too little about the raters to count.`)\n }\n\n if (refusals.length > 0 || counts === null) {\n const phrases = refusals.map((code) => REFUSAL_PHRASE[code] as string)\n return {\n verdict: 'refused',\n reasons: refusals,\n explanation: notes,\n metric,\n claimed,\n assessedValue: assessed,\n n: counts === null ? null : counts.n,\n basis: 'none',\n parsedDisplay,\n checks,\n interval: null,\n conservativeBound: null,\n suggestedStatement: `No ${metricWord} figure can be supported from this evidence: ${phrases.join('; ')}.`,\n }\n }\n\n const { n, correct } = counts\n const supportedMetric = metric as ClaimMetric\n const successes = higherIsBetter ? correct : n - correct\n const labelWord = LABEL_WORD[source as 'human' | 'automated' | 'by-construction']\n const datePart = evaluatedAtRaw === undefined ? '' : `, evaluated ${evaluatedAtRaw as string}`\n const metricName = METRIC_PHRASE[supportedMetric]\n\n // ---- complete set or held-out split: compare with the exact count ---------\n if (isFixedSet) {\n const k = successes\n const censusReasons: ReasonCode[] = []\n const censusNotes: string[] = []\n let censusVerdict: AccuracyVerdict\n const shown = Math.min(countDecimals(n), 2)\n const exactText = pctRate(k / n, shown)\n // Every figure the reader can see is judged according to its form: a point\n // or approximate figure must match the count to its digits; a bound is an\n // inequality (strict ones exclude equality); a range and \"1 in N\" are judged\n // at their favorable end / precision band. The value is judged as a point\n // too whenever it is more favorable than the printed figure, or when the\n // printed figure is itself a point figure. 0 and 1 stay exact.\n const form = figure?.info.form\n const pointDisplay = form === 'percent' || form === 'approx'\n const valueMoreFavorable = figure !== undefined && beyondNoise(judgedValue, figure.info.figure, higherIsBetter)\n const displayOk = figure === undefined || figure.satisfiedBy(k, n)\n const valueOk =\n figure === undefined || valueMoreFavorable || pointDisplay ? matchesValue(judgedValue, k, n) : true\n const printedOnly = form === 'floor' || form === 'ceiling' || form === 'range' || form === 'one-in-n'\n const ok = displayOk && valueOk\n if (ok) {\n censusVerdict = 'supported'\n censusReasons.push('census-matches-count')\n censusNotes.push(`The figure ${printedOnly && form !== 'one-in-n' && form !== 'range' ? 'is consistent with' : 'matches'} the exact count (${String(k)} of ${String(n)}, ${exactText}) to ${figure === undefined ? VALUE_PRECISION : 'its printed precision'}.`)\n } else {\n censusVerdict = 'contradicted'\n censusReasons.push('claim-differs-from-count')\n censusNotes.push(`The figure does not match the exact count (${String(k)} of ${String(n)}, ${exactText}). It may be stale or mistyped.`)\n }\n if (figure !== undefined && figure.bandNote !== null) {\n censusNotes[0] = `${censusNotes[0] as string} ${figure.bandNote}`\n }\n let censusPrecisionNote = ''\n if (displayDecimals !== null && displayDecimals > countDecimals(n)) {\n if (strictPrecision && censusVerdict === 'supported') {\n censusReasons.length = 0\n censusNotes.length = 0\n censusVerdict = 'overstated'\n }\n censusReasons.push('precision-too-fine')\n censusNotes.push(`The figure is printed to ${placesWord(displayDecimals)}; ${String(n)} items resolve ${supportsWord(countDecimals(n))}.`)\n censusPrecisionNote = printAdvice(countDecimals(n))\n }\n const censusTextNote = textFigureNote(claimText, judgedValue, assessed, higherIsBetter)\n if (censusTextNote !== null) {\n censusReasons.push('text-figure-differs')\n censusNotes.push(censusTextNote)\n }\n const name = benchmarkName as string\n const counted = higherIsBetter ? `${String(k)} of ${String(n)} correct` : `${String(k)} of ${String(n)} wrong`\n const setWord = sampling === 'held-out-split' ? 'held-out split' : 'complete set'\n return {\n verdict: censusVerdict,\n reasons: censusReasons,\n explanation: censusNotes,\n metric,\n claimed,\n assessedValue: assessed,\n n,\n basis: 'census',\n parsedDisplay,\n checks,\n interval: null,\n conservativeBound: null,\n suggestedStatement: `${counted} on ${name} (${setWord}, ${labelWord}${datePart}): ${exactText} ${metricName === 'accurate' ? 'accuracy' : metricName}. This describes that set only; it is not an estimate for other data${censusPrecisionNote}`,\n }\n }\n\n // ---- the interval and the verdict ------------------------------------\n const w = wilsonWithZ(successes, n, z)\n const interval = { ...w, confidence, z, successes, n }\n const conservativeBound = higherIsBetter ? w.low : w.high\n const cl = confidenceLabel(confidence)\n // The tolerance absorbs binary noise at an interval limit. An exact 0 or 1 is\n // an absolute claim with no noise in it, and must never be excused: at about\n // 4e12 items the limit next to 0 or 1 is closer than the tolerance.\n const tolFor = (x: number): number => (x === 0 || x === 1 ? 0 : COMPARISON_TOLERANCE)\n\n let verdict: AccuracyVerdict\n const reasons: ReasonCode[] = []\n const explanation: string[] = []\n const claimedText = pctRate(assessed, 3)\n const subject = fromDisplay\n ? `The printed figure ${claimedText} (more favorable than the claim value ${pctRate(claimed, 3)})`\n : `The claimed ${claimedText}`\n const qualifier = higherIsBetter ? '' : ` ${metricName}`\n\n // An honest report of the observed rate: a point figure (not a bound, not 0 or\n // 100%) equal to successes / n to its printed precision. Never for a bound,\n // and not at all with options.conservative.\n const absolute = assessed === 0 || assessed === 1\n let matchesObserved = false\n if (!conservative && !absolute && (figure === undefined || displayIsPoint)) {\n // The printed figure must match the rate to its own precision; a value that\n // is more favorable than the printed figure must match as well, so a coarse\n // value cannot stand in for a precise print.\n const valueMoreFavorable = figure !== undefined && beyondNoise(judgedValue, figure.info.figure, higherIsBetter)\n matchesObserved =\n figure === undefined\n ? matchesValue(judgedValue, successes, n)\n : figure.matchesObserved(successes, n) && (!valueMoreFavorable || matchesValue(judgedValue, successes, n))\n }\n\n const top = pctBound(w.high, 3, 'ceil')\n const bottom = pctBound(w.low, 3, 'floor')\n const observedText = `${String(successes)} of ${String(n)}`\n const strictBound = figure !== undefined && figure.strict\n // A bound claim is supported when it sits on the cautious side of the\n // interval's conservative end; a strict one (\"over 99%\") needs to clear it.\n // The value and the printed figure are each judged on their own terms: only\n // the printed bound carries the strictness.\n const clears = (x: number, strict: boolean): boolean => {\n const tol = tolFor(x)\n return higherIsBetter ? (strict ? x < w.low - tol : x <= w.low + tol) : strict ? x > w.high + tol : x >= w.high - tol\n }\n const withinBound = clears(judgedValue, false) && (figure === undefined || clears(figure.info.figure, strictBound))\n const matchesText = `matches the observed rate (${observedText}) to ${figure === undefined ? VALUE_PRECISION : 'its printed precision'}. The ${cl} Wilson interval is ${bottom} to ${top}.`\n if (withinBound) {\n verdict = 'supported'\n reasons.push('claim-within-bound')\n explanation.push(\n higherIsBetter\n ? `${subject} is ${strictBound ? 'below' : 'no higher than'} the lower end of the ${cl} Wilson interval (${bottom}).`\n : `${subject}${qualifier} is ${strictBound ? 'above' : 'no lower than'} the upper end of the ${cl} Wilson interval (${top}).`,\n )\n } else if (matchesObserved) {\n // An honest report of the observed rate comes first: a rounded figure can\n // land just outside the interval it was rounded from.\n verdict = 'supported'\n reasons.push('matches-observed-rate')\n explanation.push(`${subject}${qualifier} ${matchesText}`)\n } else if (higherIsBetter ? assessed > w.high + tolFor(assessed) : assessed < w.low - tolFor(assessed)) {\n verdict = 'contradicted'\n reasons.push('claim-outside-interval')\n // For an absolute claim near the interval limit, spell out why the counts rule it out.\n const nearCertain = higherIsBetter\n ? absolute && successes < n && pctCeil(w.high, 3) === pctCeil(1, 3)\n ? ', which is just under 100% because not every item was counted right'\n : null\n : absolute && successes > 0 && pctFloor(w.low, 3) === pctFloor(0, 3)\n ? ', which is just above 0% because at least one error was counted'\n : null\n explanation.push(\n higherIsBetter\n ? `${subject} is above the top of the ${cl} Wilson interval${nearCertain ?? ` (${top})`}.`\n : `${subject}${qualifier} is below the bottom of the ${cl} Wilson interval${nearCertain ?? ` (${bottom})`}.`,\n )\n } else {\n verdict = 'overstated'\n reasons.push('claim-beyond-conservative-bound')\n if (absolute) {\n // 100% (or 0%) is certainty: the Wilson interval itself ends at 1 (or 0) when every item agreed,\n // but the conservative limit never establishes it.\n explanation.push(\n higherIsBetter\n ? `${subject} cannot be stated from a sample: even when every item was right (${observedText}), the conservative lower limit cannot establish 100%. The most the evidence supports is ${bottom}, the lower end of the ${cl} Wilson interval.`\n : `${subject}${qualifier} cannot be stated from a sample: even when no item was wrong (${observedText}), the conservative upper limit cannot establish 0%. The least the evidence supports is ${top}, the upper end of the ${cl} Wilson interval.`,\n )\n } else {\n let sentence = higherIsBetter\n ? `${subject} is inside the ${cl} Wilson interval but above its lower end (${bottom}), which is the most the evidence supports.`\n : `${subject}${qualifier} is inside the ${cl} Wilson interval but below its upper end (${top}), which is the least the evidence supports.`\n // A bound printed rounded to the nearest digit (\"99.1%+\" from a limit of 99.046%) can land\n // just past the limit; the figure to print is the limit rounded in the cautious direction.\n const allowed = maxDisplayDecimals(w.high - w.low)\n const adviceMaxDecimals = strictPrecision ? allowed : undefined\n const boundMode = higherIsBetter ? 'floor' : 'ceil'\n const printedDecimals = figure !== undefined && figure.bound !== null ? figure.info.decimals : null\n if (printedDecimals !== null && figure !== undefined) {\n const oneUnit = 10 ** -(printedDecimals + 2)\n const shortfall = higherIsBetter ? assessed - w.low : w.high - assessed\n if (figure.bound === (higherIsBetter ? 'floor' : 'ceiling') && shortfall < oneUnit) {\n const rounded = pctNumericBound(conservativeBound, printedDecimals, boundMode, adviceMaxDecimals)\n if (rounded !== null) {\n sentence += ` The shortfall is within the rounding of the last printed digit, so print the bound rounded ${higherIsBetter ? 'down' : 'up'}: ${rounded}.`\n }\n }\n }\n // A figure on the cautious side of the observed rate is the usual honest round-down or\n // truncation (99.6 printed as 99): say so, and what to print instead. Only advise a figure the\n // same assessment would pass (see observedAdvice): the observed rate is no way out when it is 0\n // or 100% (a sample cannot show certainty), with options.conservative, or when no display\n // within the precision strictPrecision allows can match it; the bound is printed at the\n // precision the interval permits when strictPrecision or conservative is set.\n if (beyondNoise(w.point, assessed, higherIsBetter)) {\n const printDecimals = strictPrecision ? allowed : Math.min(allowed + 2, 5)\n const observedFigure = conservative ? null : observedAdvice(w.point, successes, n, strictPrecision ? allowed : null, higherIsBetter)\n const observedRate = pctRate(w.point, 3)\n // Repeat the figure only when the advice differs or carries a strict precision limit.\n const observedPart =\n observedFigure === null\n ? ''\n : !strictPrecision && observedFigure === observedRate\n ? 'print the observed rate, or '\n : `print the observed rate (${observedFigure}), or `\n const lead = higherIsBetter\n ? ` The figure is also below the observed rate (${observedText}, ${observedRate}): `\n : ` The figure is also above the observed rate (${observedText}, ${observedRate}): `\n const rounded = pctNumericBound(conservativeBound, printDecimals, boundMode, adviceMaxDecimals)\n const boundPart = rounded === null\n ? 'report the counts'\n : `go ${higherIsBetter ? 'down to the lower' : 'up to the upper'} end (${rounded})`\n sentence += `${lead}${observedPart}${boundPart}.`\n }\n explanation.push(sentence)\n }\n }\n\n if (figure !== undefined && figure.bandNote !== null) {\n explanation[0] = `${explanation[0] as string} ${figure.bandNote}`\n }\n\n let precisionNote = ''\n if (displayDecimals !== null) {\n const allowed = maxDisplayDecimals(w.high - w.low)\n if (displayDecimals > allowed) {\n const text = `The figure is printed to ${placesWord(displayDecimals)}, but the interval is ${pctNearest(w.high - w.low, 2).replace('%', '')} percentage points wide and supports ${supportsWord(allowed)}.`\n if (strictPrecision && verdict === 'supported') {\n // The value itself is fine; only the printed precision overreaches.\n reasons.length = 0\n explanation.length = 0\n verdict = 'overstated'\n }\n reasons.push('precision-too-fine')\n explanation.push(text)\n precisionNote = printAdvice(allowed)\n }\n }\n\n // A claim far less favorable than the counts (outside the 99.9% interval on\n // the pessimistic side) looks like a stale or mistyped figure. Informational:\n // the verdict is unchanged.\n if (verdict !== 'contradicted') {\n const wide = wilsonWithZ(successes, n, zForConfidence(0.999))\n const worse = higherIsBetter ? assessed < wide.low - tolFor(assessed) : assessed > wide.high + tolFor(assessed)\n if (worse) {\n reasons.push('claim-worse-than-counts')\n explanation.push(\n `${subject} is far less favorable than the counts support (the 99.9% Wilson interval is ${pctBound(wide.low, 3, 'floor')} to ${pctBound(wide.high, 3, 'ceil')}). If this is a published figure it may be stale or wrong.`,\n )\n }\n }\n\n // The interval pools the strata as one simple random sample. It is not\n // reweighted by population share, and the kit has no population shares to\n // reweight with, so a stratified result says so (informational).\n if (sampling === 'stratified') {\n reasons.push('strata-not-reweighted')\n explanation.push('The strata are pooled as one sample and not reweighted by population share, so the interval describes the pooled counts, not the population, unless each stratum was sampled in proportion to its size. Report each stratum, or reweight them yourself.')\n }\n\n const textNote = textFigureNote(claimText, judgedValue, assessed, higherIsBetter)\n if (textNote !== null) {\n reasons.push('text-figure-differs')\n explanation.push(textNote)\n }\n\n // ---- statement ---------------------------------------------------------\n // Use the same printed bound in the headline and the quoted interval.\n const decimals = Math.min(maxDisplayDecimals(w.high - w.low) + 2, 5)\n const statementLow = pctBound(w.low, decimals, 'floor')\n const statementHigh = pctBound(w.high, decimals, 'ceil')\n // The lead names the scope first: the figure is about this sample (or the\n // declared evaluated population), so a pasted headline cannot read as a\n // property of the system.\n const scope = population === undefined ? 'On this sample' : `On this sample of ${population.evaluated}`\n const headline = higherIsBetter\n ? `${scope}, at least ${statementLow} ${metricName}`\n : `${scope}, at most ${statementHigh} ${metricName}`\n const caveat = sampling === 'cross-validation' ? SAMPLING_ERROR_ONLY_CV : SAMPLING_ERROR_ONLY\n const parts = [\n `${cl} Wilson interval ${statementLow} to ${statementHigh}`,\n `n = ${String(n)}`,\n labelWord,\n SAMPLE_WORD[sampling] ?? 'random sample',\n ]\n if (evaluatedAtRaw !== undefined) parts.push(`evaluated ${evaluatedAtRaw as string}`)\n if (agreement !== undefined && agreement.value !== null) {\n parts.push(`${STATISTIC_LABEL[agreement.statistic]} ${decimalCut(agreement.value, 2, 'down')}`)\n }\n return {\n verdict,\n reasons,\n explanation,\n metric,\n claimed,\n assessedValue: assessed,\n n,\n basis: 'wilson-interval',\n parsedDisplay,\n checks,\n interval,\n conservativeBound,\n suggestedStatement: `${headline} (${parts.join(', ')}); ${caveat}${precisionNote}`,\n }\n}\n"]}
|
package/dist/format.d.ts
CHANGED
|
@@ -2,8 +2,19 @@
|
|
|
2
2
|
export declare function pctFloor(proportion: number, decimals: number): string;
|
|
3
3
|
/** A proportion as a percent, rounded up to `decimals` places. */
|
|
4
4
|
export declare function pctCeil(proportion: number, decimals: number): string;
|
|
5
|
+
/** An interval limit rounded outward, with extra places only to avoid a false endpoint. */
|
|
6
|
+
export declare function pctBound(proportion: number, decimals: number, mode: 'floor' | 'ceil'): string;
|
|
7
|
+
/** The same outward rounding for advice that needs a numeric figure within a precision limit. */
|
|
8
|
+
export declare function pctNumericBound(proportion: number, decimals: number, mode: 'floor' | 'ceil', maxDecimals?: number): string | null;
|
|
5
9
|
/** Nearest, for figures that are not bounds (the claim itself, a width). */
|
|
6
10
|
export declare function pctNearest(proportion: number, decimals: number): string;
|
|
11
|
+
/**
|
|
12
|
+
* A point rate for explanatory wording. Keep the usual precision unless it
|
|
13
|
+
* would turn an interior rate into an absolute 0% or 100%; then add only the
|
|
14
|
+
* digits needed to distinguish it. This does not set claim precision or format
|
|
15
|
+
* bounds, which must still round in their cautious direction.
|
|
16
|
+
*/
|
|
17
|
+
export declare function pctRate(proportion: number, decimals: number): string;
|
|
7
18
|
/**
|
|
8
19
|
* A number to `decimals` places, cut in a chosen direction instead of rounded to
|
|
9
20
|
* the nearest, from the digits it is written with (0.57 is 0.57, not 0.5699...):
|
package/dist/format.js
CHANGED
|
@@ -42,10 +42,46 @@ export function pctCeil(proportion, decimals) {
|
|
|
42
42
|
checkProportion(proportion, decimals);
|
|
43
43
|
return render(scaledUnits(proportion, decimals, 'ceil'), decimals);
|
|
44
44
|
}
|
|
45
|
+
/** An interval limit rounded outward, with extra places only to avoid a false endpoint. */
|
|
46
|
+
export function pctBound(proportion, decimals, mode) {
|
|
47
|
+
return pctNumericBound(proportion, decimals, mode) ?? (mode === 'floor' ? 'just above 0%' : 'just under 100%');
|
|
48
|
+
}
|
|
49
|
+
/** The same outward rounding for advice that needs a numeric figure within a precision limit. */
|
|
50
|
+
export function pctNumericBound(proportion, decimals, mode, maxDecimals = Math.max(decimals, 15)) {
|
|
51
|
+
checkProportion(proportion, decimals);
|
|
52
|
+
for (let d = decimals; d <= maxDecimals; d++) {
|
|
53
|
+
const units = scaledUnits(proportion, d, mode);
|
|
54
|
+
if (proportion === 0 || proportion === 1)
|
|
55
|
+
return render(units, d);
|
|
56
|
+
const interior = mode === 'floor' ? units > 0n : units < 100n * 10n ** BigInt(d);
|
|
57
|
+
if (interior)
|
|
58
|
+
return render(units, d);
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
45
62
|
/** Nearest, for figures that are not bounds (the claim itself, a width). */
|
|
46
63
|
export function pctNearest(proportion, decimals) {
|
|
47
64
|
return `${(proportion * 100).toFixed(decimals)}%`;
|
|
48
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* A point rate for explanatory wording. Keep the usual precision unless it
|
|
68
|
+
* would turn an interior rate into an absolute 0% or 100%; then add only the
|
|
69
|
+
* digits needed to distinguish it. This does not set claim precision or format
|
|
70
|
+
* bounds, which must still round in their cautious direction.
|
|
71
|
+
*/
|
|
72
|
+
export function pctRate(proportion, decimals) {
|
|
73
|
+
if (proportion === 0 || proportion === 1)
|
|
74
|
+
return pctNearest(proportion, decimals);
|
|
75
|
+
for (let d = decimals; d <= 20; d++) {
|
|
76
|
+
const text = pctNearest(proportion, d);
|
|
77
|
+
const shown = parseFloat(text);
|
|
78
|
+
if (shown > 0 && shown < 100)
|
|
79
|
+
return text;
|
|
80
|
+
}
|
|
81
|
+
// A positive caller-supplied point may be smaller than fixed notation can
|
|
82
|
+
// show. Counts cannot reach this case (n is at most MAX_SAFE_INTEGER).
|
|
83
|
+
return `${(proportion * 100).toExponential()}%`;
|
|
84
|
+
}
|
|
49
85
|
/**
|
|
50
86
|
* A number to `decimals` places, cut in a chosen direction instead of rounded to
|
|
51
87
|
* the nearest, from the digits it is written with (0.57 is 0.57, not 0.5699...):
|
package/dist/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,6EAA6E;AAC7E,6EAA6E;AAC7E,gFAAgF;AAChF,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAE3E,2EAA2E;AAC3E,SAAS,WAAW,CAAC,CAAS,EAAE,QAAgB,EAAE,IAAsB;IACtE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;IAC7C,MAAM,SAAS,GAAG,QAAQ,GAAG,IAAI,GAAG,GAAG,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAA;IAC3D,IAAI,QAAQ,IAAI,CAAC;QAAE,OAAO,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAA;IACvD,MAAM,WAAW,GAAG,EAAE,IAAI,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC3C,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAA;IACxC,OAAO,IAAI,KAAK,MAAM,IAAI,SAAS,GAAG,WAAW,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAA;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AAG,MAAM,CAAC,MAAM,IAAK,MAAM,CAAC,CAAC,GAAG,CAAC,CAAY,IAAI,SAAS,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAAE,CAAC,IAAI,CAAC,CAAA;IAC5F,OAAO,CAAC,CAAA;AACV,CAAC","sourcesContent":["import { shortestWithinNoise, valueDigits } from './census.js'\nimport { splitDouble } from './exact.js'\n\n// Number formatting for statements. Bounds are rounded in the direction that\n// never makes the evidence look better than it is: a lower limit is floored,\n// an upper limit is ceiled. The rounding is exact: the double is split into its\n// integer mantissa and power of two and the scaled value is floored or ceiled\n// with BigInt arithmetic, so a printed figure can never sit on the wrong side\n// of the number it describes (no fixed slack, no floating-point multiply).\n\n/** floor or ceil of x * 100 * 10^decimals for a finite x >= 0, exactly. */\nfunction scaledUnits(x: number, decimals: number, mode: 'floor' | 'ceil'): bigint {\n const { mantissa, exponent } = splitDouble(x)\n const numerator = mantissa * 100n * 10n ** BigInt(decimals)\n if (exponent >= 0) return numerator << BigInt(exponent)\n const denominator = 1n << BigInt(-exponent)\n const quotient = numerator / denominator\n return mode === 'ceil' && numerator % denominator !== 0n ? quotient + 1n : quotient\n}\n\nfunction render(units: bigint, decimals: number): string {\n if (decimals === 0) return `${String(units)}%`\n const scale = 10n ** BigInt(decimals)\n const whole = units / scale\n const fraction = String(units % scale).padStart(decimals, '0')\n return `${String(whole)}.${fraction}%`\n}\n\nfunction checkProportion(x: number, decimals: number): void {\n if (typeof x !== 'number' || !Number.isFinite(x) || x < 0 || x > 1) {\n throw new RangeError(`proportion must be a finite number from 0 to 1, got ${String(x)}`)\n }\n if (!Number.isInteger(decimals) || decimals < 0 || decimals > 20) {\n throw new RangeError('decimals must be a whole number from 0 to 20')\n }\n}\n\n/** A proportion as a percent, rounded down to `decimals` places. */\nexport function pctFloor(proportion: number, decimals: number): string {\n checkProportion(proportion, decimals)\n return render(scaledUnits(proportion, decimals, 'floor'), decimals)\n}\n\n/** A proportion as a percent, rounded up to `decimals` places. */\nexport function pctCeil(proportion: number, decimals: number): string {\n checkProportion(proportion, decimals)\n return render(scaledUnits(proportion, decimals, 'ceil'), decimals)\n}\n\n/** Nearest, for figures that are not bounds (the claim itself, a width). */\nexport function pctNearest(proportion: number, decimals: number): string {\n return `${(proportion * 100).toFixed(decimals)}%`\n}\n\n/**\n * A number to `decimals` places, cut in a chosen direction instead of rounded to\n * the nearest, from the digits it is written with (0.57 is 0.57, not 0.5699...):\n * 'down' never shows more than the number (0.9996 is 0.99, -0.456 is -0.46),\n * 'up' never shows less (a required minimum of 0.8004 is 0.801).\n */\nexport function decimalCut(x: number, decimals: number, direction: 'down' | 'up'): string {\n const negative = x < 0\n const { digits, scale } = valueDigits(Math.abs(x))\n let units: bigint\n if (scale <= decimals) {\n units = digits * 10n ** BigInt(decimals - scale)\n } else {\n const unit = 10n ** BigInt(scale - decimals)\n const rest = digits % unit\n // the size of a negative number grows when it is cut down, a positive one when it is cut up\n const grows = negative ? direction === 'down' : direction === 'up'\n units = digits / unit + (grows && rest !== 0n ? 1n : 0n)\n }\n const whole = units / 10n ** BigInt(decimals)\n const fraction = decimals === 0 ? '' : `.${String(units % 10n ** BigInt(decimals)).padStart(decimals, '0')}`\n return `${negative && units !== 0n ? '-' : ''}${String(whole)}${fraction}`\n}\n\n/**\n * A confidence level as a percent label, rounded down to at most 9 decimals\n * and never 100%. It works on the shortest decimal text of the number within\n * float noise (0.95 reads \"95%\", not \"94.999999999%\", and 1 - 0.07 reads \"93%\"),\n * so a level a person typed or computed keeps the digits they meant.\n */\nexport function confidenceLabel(confidence: number): string {\n // 1 - 0.07 is 0.9299999999999999: the level a person wrote, 93%, is the shortest decimal within\n // float noise of it. A level that noise would carry up to 1 keeps its own digits (never 100%).\n const nearest = shortestWithinNoise(confidence)\n let text = Number(nearest) < 1 ? nearest : String(confidence)\n const at = text.indexOf('e')\n if (at >= 0) {\n // 1.5e-7 is 0.00000015: expand the digits the number is written with, never the binary expansion\n const exponent = Number(text.slice(at + 1))\n const mantissa = text.slice(0, at).replace('.', '')\n text = `0.${'0'.repeat(Math.max(0, -exponent - 1))}${mantissa}`\n }\n const digits = text.slice(2) // after \"0.\"\n const whole = Number(digits.slice(0, 2).padEnd(2, '0')) // percent, integer part\n const fraction = digits.slice(2, 11).replace(/0+$/, '')\n if (whole === 0 && fraction === '') return 'under 0.000000001%'\n return `${String(whole)}${fraction === '' ? '' : `.${fraction}`}%`\n}\n\nconst LEVELS = [1, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 1e-7, 1e-8, 1e-9, 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15]\n\n/**\n * Most decimals a percent figure can print before its last digit is finer\n * than one tenth of the interval width. A figure with D decimals has a last\n * digit worth 10^-D percentage points; it is supported while\n * 10^-D >= (width in percentage points) / 10. Whole-percent figures (0\n * decimals) are always allowed. `width` is the interval width as a\n * proportion (high - low).\n */\nexport function maxDisplayDecimals(width: number): number {\n if (typeof width !== 'number') throw new TypeError('width must be a number')\n if (!Number.isFinite(width) || width < 0 || width > 1) {\n throw new RangeError(`width must be a finite number from 0 to 1, got ${String(width)}`)\n }\n const unitFloor = (width * 100) / 10\n let d = 0\n // A relative slack of 1e-12 makes \"exactly one tenth\" count as supported.\n while (d + 1 < LEVELS.length && (LEVELS[d + 1] as number) >= unitFloor * (1 - 1e-12)) d += 1\n return d\n}\n"]}
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,6EAA6E;AAC7E,6EAA6E;AAC7E,gFAAgF;AAChF,8EAA8E;AAC9E,8EAA8E;AAC9E,2EAA2E;AAE3E,2EAA2E;AAC3E,SAAS,WAAW,CAAC,CAAS,EAAE,QAAgB,EAAE,IAAsB;IACtE,MAAM,EAAE,QAAQ,EAAE,QAAQ,E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C,GAAG,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,GAAG,CAAA;AACpE,CAAC;AAED,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;AAE3H;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAa;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC,CAAA;IAC5E,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,UAAU,CAAC,kDAAkD,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACzF,CAAC;IACD,MAAM,SAAS,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,EAAE,CAAA;IACpC,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,0EAA0E;IAC1E,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,IAAK,MAAM,CAAC,CAAC,GAAG,CAAC,CAAY,IAAI,SAAS,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;QAAE,CAAC,IAAI,CAAC,CAAA;IAC5F,OAAO,CAAC,CAAA;AACV,CAAC","sourcesContent":["import { shortestWithinNoise, valueDigits } from './census.js'\nimport { splitDouble } from './exact.js'\n\n// Number formatting for statements. Bounds are rounded in the direction that\n// never makes the evidence look better than it is: a lower limit is floored,\n// an upper limit is ceiled. The rounding is exact: the double is split into its\n// integer mantissa and power of two and the scaled value is floored or ceiled\n// with BigInt arithmetic, so a printed figure can never sit on the wrong side\n// of the number it describes (no fixed slack, no floating-point multiply).\n\n/** floor or ceil of x * 100 * 10^decimals for a finite x >= 0, exactly. */\nfunction scaledUnits(x: number, decimals: number, mode: 'floor' | 'ceil'): bigint {\n const { mantissa, exponent } = splitDouble(x)\n const numerator = mantissa * 100n * 10n ** BigInt(decimals)\n if (exponent >= 0) return numerator << BigInt(exponent)\n const denominator = 1n << BigInt(-exponent)\n const quotient = numerator / denominator\n return mode === 'ceil' && numerator % denominator !== 0n ? quotient + 1n : quotient\n}\n\nfunction render(units: bigint, decimals: number): string {\n if (decimals === 0) return `${String(units)}%`\n const scale = 10n ** BigInt(decimals)\n const whole = units / scale\n const fraction = String(units % scale).padStart(decimals, '0')\n return `${String(whole)}.${fraction}%`\n}\n\nfunction checkProportion(x: number, decimals: number): void {\n if (typeof x !== 'number' || !Number.isFinite(x) || x < 0 || x > 1) {\n throw new RangeError(`proportion must be a finite number from 0 to 1, got ${String(x)}`)\n }\n if (!Number.isInteger(decimals) || decimals < 0 || decimals > 20) {\n throw new RangeError('decimals must be a whole number from 0 to 20')\n }\n}\n\n/** A proportion as a percent, rounded down to `decimals` places. */\nexport function pctFloor(proportion: number, decimals: number): string {\n checkProportion(proportion, decimals)\n return render(scaledUnits(proportion, decimals, 'floor'), decimals)\n}\n\n/** A proportion as a percent, rounded up to `decimals` places. */\nexport function pctCeil(proportion: number, decimals: number): string {\n checkProportion(proportion, decimals)\n return render(scaledUnits(proportion, decimals, 'ceil'), decimals)\n}\n\n/** An interval limit rounded outward, with extra places only to avoid a false endpoint. */\nexport function pctBound(proportion: number, decimals: number, mode: 'floor' | 'ceil'): string {\n return pctNumericBound(proportion, decimals, mode) ?? (mode === 'floor' ? 'just above 0%' : 'just under 100%')\n}\n\n/** The same outward rounding for advice that needs a numeric figure within a precision limit. */\nexport function pctNumericBound(proportion: number, decimals: number, mode: 'floor' | 'ceil', maxDecimals = Math.max(decimals, 15)): string | null {\n checkProportion(proportion, decimals)\n for (let d = decimals; d <= maxDecimals; d++) {\n const units = scaledUnits(proportion, d, mode)\n if (proportion === 0 || proportion === 1) return render(units, d)\n const interior = mode === 'floor' ? units > 0n : units < 100n * 10n ** BigInt(d)\n if (interior) return render(units, d)\n }\n return null\n}\n\n/** Nearest, for figures that are not bounds (the claim itself, a width). */\nexport function pctNearest(proportion: number, decimals: number): string {\n return `${(proportion * 100).toFixed(decimals)}%`\n}\n\n/**\n * A point rate for explanatory wording. Keep the usual precision unless it\n * would turn an interior rate into an absolute 0% or 100%; then add only the\n * digits needed to distinguish it. This does not set claim precision or format\n * bounds, which must still round in their cautious direction.\n */\nexport function pctRate(proportion: number, decimals: number): string {\n if (proportion === 0 || proportion === 1) return pctNearest(proportion, decimals)\n for (let d = decimals; d <= 20; d++) {\n const text = pctNearest(proportion, d)\n const shown = parseFloat(text)\n if (shown > 0 && shown < 100) return text\n }\n // A positive caller-supplied point may be smaller than fixed notation can\n // show. Counts cannot reach this case (n is at most MAX_SAFE_INTEGER).\n return `${(proportion * 100).toExponential()}%`\n}\n\n/**\n * A number to `decimals` places, cut in a chosen direction instead of rounded to\n * the nearest, from the digits it is written with (0.57 is 0.57, not 0.5699...):\n * 'down' never shows more than the number (0.9996 is 0.99, -0.456 is -0.46),\n * 'up' never shows less (a required minimum of 0.8004 is 0.801).\n */\nexport function decimalCut(x: number, decimals: number, direction: 'down' | 'up'): string {\n const negative = x < 0\n const { digits, scale } = valueDigits(Math.abs(x))\n let units: bigint\n if (scale <= decimals) {\n units = digits * 10n ** BigInt(decimals - scale)\n } else {\n const unit = 10n ** BigInt(scale - decimals)\n const rest = digits % unit\n // the size of a negative number grows when it is cut down, a positive one when it is cut up\n const grows = negative ? direction === 'down' : direction === 'up'\n units = digits / unit + (grows && rest !== 0n ? 1n : 0n)\n }\n const whole = units / 10n ** BigInt(decimals)\n const fraction = decimals === 0 ? '' : `.${String(units % 10n ** BigInt(decimals)).padStart(decimals, '0')}`\n return `${negative && units !== 0n ? '-' : ''}${String(whole)}${fraction}`\n}\n\n/**\n * A confidence level as a percent label, rounded down to at most 9 decimals\n * and never 100%. It works on the shortest decimal text of the number within\n * float noise (0.95 reads \"95%\", not \"94.999999999%\", and 1 - 0.07 reads \"93%\"),\n * so a level a person typed or computed keeps the digits they meant.\n */\nexport function confidenceLabel(confidence: number): string {\n // 1 - 0.07 is 0.9299999999999999: the level a person wrote, 93%, is the shortest decimal within\n // float noise of it. A level that noise would carry up to 1 keeps its own digits (never 100%).\n const nearest = shortestWithinNoise(confidence)\n let text = Number(nearest) < 1 ? nearest : String(confidence)\n const at = text.indexOf('e')\n if (at >= 0) {\n // 1.5e-7 is 0.00000015: expand the digits the number is written with, never the binary expansion\n const exponent = Number(text.slice(at + 1))\n const mantissa = text.slice(0, at).replace('.', '')\n text = `0.${'0'.repeat(Math.max(0, -exponent - 1))}${mantissa}`\n }\n const digits = text.slice(2) // after \"0.\"\n const whole = Number(digits.slice(0, 2).padEnd(2, '0')) // percent, integer part\n const fraction = digits.slice(2, 11).replace(/0+$/, '')\n if (whole === 0 && fraction === '') return 'under 0.000000001%'\n return `${String(whole)}${fraction === '' ? '' : `.${fraction}`}%`\n}\n\nconst LEVELS = [1, 0.1, 0.01, 0.001, 0.0001, 0.00001, 0.000001, 1e-7, 1e-8, 1e-9, 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15]\n\n/**\n * Most decimals a percent figure can print before its last digit is finer\n * than one tenth of the interval width. A figure with D decimals has a last\n * digit worth 10^-D percentage points; it is supported while\n * 10^-D >= (width in percentage points) / 10. Whole-percent figures (0\n * decimals) are always allowed. `width` is the interval width as a\n * proportion (high - low).\n */\nexport function maxDisplayDecimals(width: number): number {\n if (typeof width !== 'number') throw new TypeError('width must be a number')\n if (!Number.isFinite(width) || width < 0 || width > 1) {\n throw new RangeError(`width must be a finite number from 0 to 1, got ${String(width)}`)\n }\n const unitFloor = (width * 100) / 10\n let d = 0\n // A relative slack of 1e-12 makes \"exactly one tenth\" count as supported.\n while (d + 1 < LEVELS.length && (LEVELS[d + 1] as number) >= unitFloor * (1 - 1e-12)) d += 1\n return d\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "accuracy-claim-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Does this accuracy or error-rate number have the evidence to carry it? Wilson intervals, inter-rater agreement (percent agreement, Cohen's kappa, Gwet's AC1) and a refuse-or-judge verdict on a claimed figure, computed from caller-supplied counts. Zero-dependency, offline TypeScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accuracy",
|