MACE-Bench / code /agmem /stats.py
tirtho149's picture
MACE-Bench release: images, memory banks, captions, predictions, traces, code
c8e03af verified
Raw History Blame Contribute Delete
663 Bytes
"""Exact McNemar test and Holm correction (no SciPy dependency)."""
from __future__ import annotations
from math import comb
def mcnemar_exact(b: int, c: int) -> float:
"""Two-sided exact McNemar p-value from the discordant counts b and c."""
n = b + c
if n == 0:
return 1.0
k = min(b, c)
return min(1.0, 2 * sum(comb(n, i) for i in range(k + 1)) / 2 ** n)
def holm(ps: list[float]) -> list[float]:
order = sorted(range(len(ps)), key=lambda i: ps[i]); out = [0.0] * len(ps); running = 0.0
for rank, i in enumerate(order):
running = max(running, min(1.0, (len(ps) - rank) * ps[i])); out[i] = running
return out