Skip to main content
Glama

sample-size-mcp

How many test cases do you need to trust that model A is really better than model B?

Usually more than you'd think: telling 82% from 78% takes about 1,500 cases if the models' errors are unrelated. If both models run on the same test set, and they usually make the same mistakes, the number can drop to about 500. This tool does the math. You can use it as a CLI or as an MCP server, so an agent can check an eval before trusting it.

CLI

uv run evalsize n 0.82 0.78                     # cases needed (same test set for both models)
uv run evalsize n 0.82 0.78 --discordance 0.10  # ...when the models disagree on 10% of cases
uv run evalsize n 0.82 0.78 --unpaired          # each model gets its own sample
uv run evalsize gap 500 0.78                    # smallest win 500 cases can detect
uv run evalsize compare 500 --a-only 41 --b-only 22 --both 360   # is this result real?
$ uv run evalsize n 0.82 0.78 --discordance 0.10
489 test cases (shared by both models)
  to detect 82.0% vs 78.0% (gap 4.0%) at alpha=0.05, power=80%
  discordance 10.0% (given); ~49 cases will carry the signal

$ uv run evalsize compare 500 --a-only 41 --b-only 22 --both 360
A 80.2% vs B 76.4%: gap +3.8%, 95% CI [+0.7%, +6.9%], p=0.0226 -> SIGNIFICANT

All commands accept --alpha (false-positive rate, default 0.05) and --power (the chance of detecting a real gap, default 0.8).

Related MCP server: agent-eval

MCP server

{
  "mcpServers": {
    "eval-sample-size": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/fayehall-ai/sample-size-mcp", "sample-size-mcp"]
    }
  }
}

Or with Claude Code: claude mcp add eval-sample-size -- uvx --from git+https://github.com/fayehall-ai/sample-size-mcp sample-size-mcp

Tools: eval_sample_size, eval_min_detectable_gap, eval_compare_paired, eval_compare_unpaired.

The statistics

Paired (the default) means both models are scored on the same cases. Cases where both models are right, or both wrong, tell you nothing about which model is better. Only the cases where they disagree count, so the required sample size depends on discordance: the fraction of cases where exactly one model is right. This tool uses McNemar's test, with sample size from Connor (1987):

n = (z_{α/2}·√ψ + z_β·√(ψ − δ²))² / δ²       ψ = discordance, δ = accuracy gap

If you don't pass a discordance, the tool assumes the models' errors are independent, ψ = a(1−b) + b(1−a). That's the worst realistic case, and it needs about as many cases as the unpaired design. Real models usually fail on the same hard cases, so the true discordance is lower and you need fewer cases. Run a small pilot (~100 cases), measure how often the models disagree, and pass that number. This is usually the biggest lever you have.

Unpaired means each model is scored on its own random sample. This uses the two-proportion z-test (Fleiss formula, no continuity correction), and n is the number of cases per model.

Checking results: compare / eval_compare_paired uses the exact McNemar (binomial) test, with a Wald confidence interval on the gap.

Tests include a Monte Carlo check that the recommended n actually gives about 80% power. Run them with uv run pytest.

Caveats

  • Every test case counts as independent. If your cases come in clusters (several prompts per document, or several samples per prompt), you need more cases than this says.

  • Each test is a single comparison. If you compare many models or checkpoints, divide alpha by the number of comparisons (Bonferroni correction).

  • For accuracies close to 0 or 1, or very small samples, the normal approximation becomes rough.

Available Tools

4 tools
eval_compare_pairedA

Is A's win over B on a shared test set statistically real?

n: total cases; a_only: A right & B wrong; b_only: B right & A wrong;
both: both right. Returns exact McNemar p-value and a CI on the gap.

Inputs: n (required), both (required), a_only (required), b_only (required), +1 more.

eval_compare_unpairedC

Is A's win over B real when each was scored on a different sample? Two-proportion z-test with a CI on the gap.

Inputs: n_a (required), n_b (required), correct_a (required), correct_b (required), +1 more.

eval_min_detectable_gapC

Smallest accuracy improvement over baseline_acc that an eval with n test cases can reliably detect. Use this to sanity-check an existing eval set.

Inputs: n (required), baseline_acc (required), alpha, power, +2 more.

eval_sample_sizeA

How many test cases are needed to trust that model A's accuracy really differs from model B's.

acc_a, acc_b: expected accuracies as proportions (e.g. 0.82, 0.78).
paired: True if both models run on the same test cases (usual case).
discordance: paired only -- fraction of cases where exactly one model is
  right. Measure it from a pilot run if you can; default assumes
  independent errors, which overestimates n for similar models.

Inputs: acc_a (required), acc_b (required), alpha, power, +2 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a clearly distinct statistical purpose: planning sample size, checking minimum detectable gap, paired comparison, and unpaired comparison. The paired vs. unpaired tests are explicitly distinguished by name and description, leaving little room for misselection.

    Naming Consistency4/5

    All tools share the eval_ prefix and snake_case formatting, which provides a predictable namespace. However, the suffixes mix verb-led names (eval_compare_paired) with noun phrases (eval_sample_size, eval_min_detectable_gap), a minor inconsistency.

    Tool Count5/5

    Four tools is well-scoped for a focused eval-statistics utility. Each tool covers a distinct and necessary part of sample-size planning and model comparison, with no redundant entries.

    Completeness5/5

    The surface covers the key lifecycle for eval statistical planning: determining required sample size, assessing detectable gaps, and comparing models under both paired and unpaired designs. No obvious gaps remain for the stated purpose.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Eval-integrity statistics for AI benchmark claims — multiple-testing correction, power/MDE for model gaps, judge-bias and leaderboard-rank checks. Catches a benchmark number that won't survive a second look.
      9
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      MCP server exposing statistical regression testing for LLM agents as a "run" tool: p-value, effect size, and confidence interval on whether agent behavior actually changed.
      1
      68 PyPI
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides a virtual statistician for AI agents, offering real statistical methods such as design of experiments, hypothesis testing, regression, and process control. It includes an advisor tool to recommend appropriate analyses and generates plain-language interpretations of results.
      MIT
    • A
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables statistical A/B testing by computing Welch's two-sample t-test, Satterthwaite degrees of freedom, and two-tailed p-values, alongside time-series forecasting, anomaly detection, regression, and PCA through MCP tools.
      MIT