{
  "schemaVersion": 1,
  "manifestRevision": 2,
  "compatibility": {
    "change": "backward-compatible-addition",
    "preservedCollections": ["chiSquareCases", "fisherCases", "somersDCases"],
    "addedCollections": ["browserEngineCases"]
  },
  "generatedAt": "2026-08-01",
  "referenceImplementation": {
    "name": "SciPy",
    "version": "1.18.0",
    "documentation": "https://docs.scipy.org/doc/scipy/reference/stats.html"
  },
  "tolerance": {
    "absolute": 1e-14,
    "relative": 1e-10
  },
  "scope": {
    "claim": "Selected known-answer parity evidence for the browser statistical engine; not certification or independent human review.",
    "limitations": [
      "The selected cases do not cover every statistic, input shape, numerical edge case, export, or interface.",
      "The cases assume nonnegative frequency-count tables with positive row and column margins.",
      "Ordinal measures depend on the supplied row and column category order.",
      "The checks do not provide complex-survey variance estimation or establish that a statistic is appropriate for a particular study."
    ]
  },
  "chiSquareCases": [
    {
      "id": "pearson-2x2-balanced-margins",
      "label": "Pearson chi-square, 2×2 balanced margins",
      "table": [[20, 30], [30, 20]],
      "options": {
        "correction": false
      },
      "expected": {
        "chiSquare": 4.0,
        "degreesOfFreedom": 1,
        "pValue": 0.045500263896358445,
        "cramersV": 0.2,
        "expectedFrequencies": [[25.0, 25.0], [25.0, 25.0]]
      }
    },
    {
      "id": "pearson-3x3",
      "label": "Pearson chi-square, 3×3 table",
      "table": [[50, 10, 5], [20, 30, 10], [5, 15, 25]],
      "options": {
        "correction": false
      },
      "expected": {
        "chiSquare": 67.86901061901062,
        "degreesOfFreedom": 4,
        "pValue": 6.392727550331958e-14,
        "cramersV": 0.4467826508658736,
        "expectedFrequencies": [
          [28.676470588235293, 21.029411764705884, 15.294117647058824],
          [26.470588235294116, 19.41176470588235, 14.117647058823529],
          [19.852941176470587, 14.558823529411764, 10.588235294117647]
        ]
      }
    }
  ],
  "fisherCases": [
    {
      "id": "fisher-lady-tasting-tea",
      "label": "Fisher's exact test, classic 2×2 table",
      "table": [[3, 1], [1, 3]],
      "options": {
        "alternative": "two-sided"
      },
      "expected": {
        "oddsRatio": 9.0,
        "pValue": 0.48571428571428565
      }
    },
    {
      "id": "fisher-equal-central-modes",
      "label": "Fisher's exact test, equal-probability central modes",
      "table": [[20000, 19999], [19999, 20000]],
      "options": {
        "alternative": "two-sided"
      },
      "expected": {
        "oddsRatio": 1.0001000075005,
        "pValue": 1.0
      }
    },
    {
      "id": "fisher-zero-cell",
      "label": "Fisher's exact test, zero cell",
      "table": [[0, 5], [10, 15]],
      "options": {
        "alternative": "two-sided"
      },
      "expected": {
        "oddsRatio": 0.0,
        "pValue": 0.14003620900172625
      }
    },
    {
      "id": "fisher-skewed-margins",
      "label": "Fisher's exact test, skewed margins",
      "table": [[1, 99], [8, 92]],
      "options": {
        "alternative": "two-sided"
      },
      "expected": {
        "oddsRatio": 0.11616161616161616,
        "pValue": 0.03489915197211575
      }
    }
  ],
  "somersDCases": [
    {
      "id": "somers-d-hotel-satisfaction",
      "label": "Somers' d, SciPy hotel-cleanliness example",
      "table": [[27, 25, 14, 7, 0], [7, 14, 18, 35, 12], [1, 3, 2, 7, 17]],
      "expected": {
        "columnGivenRow": 0.6032766111513396,
        "rowGivenColumn": 0.47045951859956237,
        "symmetric": 0.528653579218719,
        "symmetricDerivation": "harmonic mean of the two directional SciPy statistics"
      }
    }
  ],
  "browserEngineCases": [
    {
      "id": "yates-2x2-scipy",
      "label": "Yates continuity-corrected chi-square, 2x2 table",
      "statistic": "chiSquareYates",
      "table": [[12, 5], [29, 2]],
      "provenance": {
        "kind": "package",
        "implementation": "SciPy",
        "version": "1.18.0",
        "method": "scipy.stats.chi2_contingency(table, correction=True)",
        "reference": "https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chi2_contingency.html"
      },
      "expected": {
        "chiSquare": 2.9860164364723074,
        "degreesOfFreedom": 1,
        "pValue": 0.08398654171499194
      }
    },
    {
      "id": "likelihood-ratio-g-3x3-scipy",
      "label": "Likelihood-ratio G-test, 3x3 table",
      "statistic": "likelihoodRatioG",
      "table": [[50, 10, 5], [20, 30, 10], [5, 15, 25]],
      "provenance": {
        "kind": "package",
        "implementation": "SciPy",
        "version": "1.18.0",
        "method": "scipy.stats.chi2_contingency(table, correction=False, lambda_='log-likelihood')",
        "reference": "https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chi2_contingency.html"
      },
      "expected": {
        "gStatistic": 67.6208218591658,
        "degreesOfFreedom": 4,
        "pValue": 7.211643546156626e-14
      }
    },
    {
      "id": "woolf-odds-ratio-ci-positive-cells",
      "label": "Sample odds ratio with Woolf 95% confidence interval",
      "statistic": "woolfOddsRatio",
      "table": [[40, 10], [10, 40]],
      "provenance": {
        "kind": "transparent-formula",
        "implementation": "Python standard-library math",
        "version": "3.13.13",
        "method": "OR=(a*d)/(b*c); CI=exp(log(OR) +/- 1.96*sqrt(1/a+1/b+1/c+1/d))",
        "reference": "Formula and fixed 1.96 normal critical value are embedded here and recomputed independently in the Python parity test."
      },
      "expected": {
        "oddsRatio": 16.0,
        "ciLower": 6.004977581622392,
        "ciUpper": 42.63129987087067
      }
    },
    {
      "id": "signed-phi-negative-association",
      "label": "Signed phi coefficient, negative association",
      "statistic": "signedPhi",
      "table": [[5, 50], [50, 5]],
      "provenance": {
        "kind": "transparent-formula",
        "implementation": "Python standard-library math",
        "version": "3.13.13",
        "method": "phi=(a*d-b*c)/sqrt((a+b)*(c+d)*(a+c)*(b+d))",
        "reference": "Formula is embedded here and recomputed independently in the Python parity test."
      },
      "expected": {
        "phi": -0.8181818181818182
      }
    },
    {
      "id": "pearson-contingency-coefficient-3x3",
      "label": "Pearson contingency coefficient, 3x3 table",
      "statistic": "pearsonContingencyCoefficient",
      "table": [[50, 10, 5], [20, 30, 10], [5, 15, 25]],
      "provenance": {
        "kind": "mixed-package-formula",
        "implementation": "SciPy 1.18.0 plus Python standard-library math",
        "version": "1.18.0",
        "method": "chi2=scipy.stats.chi2_contingency(table, correction=False).statistic; C=sqrt(chi2/(chi2+N))",
        "reference": "https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.chi2_contingency.html"
      },
      "expected": {
        "contingencyCoefficient": 0.5341544194663255
      }
    },
    {
      "id": "goodman-kruskal-lambda-pooled-3x3",
      "label": "Goodman-Kruskal pooled lambda, 3x3 table",
      "statistic": "goodmanKruskalLambdaPooled",
      "table": [[30, 2, 3], [4, 20, 6], [8, 5, 22]],
      "provenance": {
        "kind": "transparent-formula",
        "implementation": "NumPy",
        "version": "2.5.1",
        "method": "pooled=(sum(column maxima)+sum(row maxima)-max(row totals)-max(column totals))/(2*N-max(row totals)-max(column totals)); directional lambdas use their corresponding proportional error reduction",
        "reference": "Formula is embedded here and recomputed independently from marginal and modal counts in the Python parity test."
      },
      "expected": {
        "symmetric": 0.5447154471544715,
        "rowDependent": 0.5692307692307692,
        "colDependent": 0.5172413793103449
      }
    },
    {
      "id": "goodman-kruskal-gamma-ordinal-3x3",
      "label": "Goodman-Kruskal gamma, ordinal 3x3 table",
      "statistic": "goodmanKruskalGamma",
      "table": [[30, 10, 5], [10, 20, 10], [5, 10, 30]],
      "provenance": {
        "kind": "transparent-formula",
        "implementation": "Python standard-library arithmetic",
        "version": "3.13.13",
        "method": "gamma=(concordant-discordant)/(concordant+discordant), with pair counts recomputed by direct four-loop enumeration",
        "reference": "Formula and direct enumeration method are embedded here and recomputed independently in the Python parity test."
      },
      "expected": {
        "gamma": 0.696969696969697
      }
    },
    {
      "id": "kendall-tau-b-c-rectangular",
      "label": "Kendall tau-b and Stuart tau-c, ordinal 2x4 table",
      "statistic": "kendallTauBandC",
      "table": [[20, 10, 5, 2], [5, 10, 20, 30]],
      "provenance": {
        "kind": "transparent-formula",
        "implementation": "Python standard-library arithmetic",
        "version": "3.13.13",
        "method": "tau_b=(C-D)/sqrt((C+D+T_row)*(C+D+T_col)); tau_c=2*m*(C-D)/(N^2*(m-1)); pair and tie counts use direct enumeration",
        "reference": "Formulas and direct enumeration method are embedded here and recomputed independently in the Python parity test."
      },
      "expected": {
        "kendallTauB": 0.542832333958778,
        "kendallTauC": 0.6362937331795463
      }
    },
    {
      "id": "theil-u-pooled-asymmetric-3x2",
      "label": "Pooled and directional Theil uncertainty coefficients",
      "statistic": "theilsUPooled",
      "table": [[30, 5], [10, 5], [5, 45]],
      "provenance": {
        "kind": "transparent-formula",
        "implementation": "NumPy plus Python standard-library math",
        "version": "2.5.1",
        "method": "I=H(row)+H(column)-H(joint); U(row|column)=I/H(row); U(column|row)=I/H(column); pooled U=2*I/(H(row)+H(column))",
        "reference": "Natural-log entropy formulas are embedded here and recomputed independently in the Python parity test."
      },
      "expected": {
        "symmetric": 0.3398072062852704,
        "rowGivenCol": 0.2869872040282851,
        "colGivenRow": 0.41645593107319956
      }
    },
    {
      "id": "adjusted-standardized-residuals-3x3",
      "label": "Adjusted standardized residuals, 3x3 table",
      "statistic": "adjustedStandardizedResiduals",
      "table": [[50, 10, 5], [20, 30, 10], [5, 15, 25]],
      "provenance": {
        "kind": "transparent-formula",
        "implementation": "NumPy",
        "version": "2.5.1",
        "method": "r_ij=(O_ij-E_ij)/sqrt(E_ij*(1-R_i/N)*(1-C_j/N)), where E_ij=R_i*C_j/N",
        "reference": "Formula is embedded here and vectorized independently in the Python parity test."
      },
      "expected": {
        "residuals": [
          [6.777799374399998, -3.720866942175243, -3.830094678535809],
          [-2.0914753180106986, 3.632408916720151, -1.557933303179625],
          [-5.200344867856302, 0.163943497448759, 5.906464660549895]
        ]
      }
    }
  ]
}
