Skip to content

samplesize-copilot

Sample-size and power calculations for clinical and applied research.

A Python package + Claude Code plugin implementing 234 sample-size and power-calculation methods, validated against worked examples from established statistical references.

CI License: Apache 2.0 Python Methods Tests

What's here

  • 234 methods spanning means, proportions, correlation, survival, ANOVA/GLM, ROC/diagnostic accuracy, group-sequential, cluster-randomized, cross-over, Phase II clinical trials, and specialty designs.
  • 819 worked-example fixture tests — every method has at least two pinned reference examples with documented tolerances.
  • Doctor integrity gate — 9 cross-checks on the method registry, callable imports, fixture references, plugin manifest, and reporting templates.
  • Audit log — every calculation writes a JSON record with inputs, outputs, library versions, and method citation.

Installation

pip install -e .

(PyPI release pending.)

Quick start

from samplesize.tests.one_mean import one_sample_t

result = one_sample_t(
    mu0=0.0,
    mu1=0.5,
    sigma=1.0,
    alpha=0.05,
    power=0.80,
    sides=2,
    solve_for="n",
)
print(result["n"], result["achieved_power"])

CLI:

samplesize list
samplesize calc one_sample_t mu0=0 mu1=0.5 sigma=1 alpha=0.05 power=0.80 sides=2
samplesize doctor

Where to go next

License

Apache License 2.0 — see LICENSE.

Acknowledgments

Calculator implementations follow the worked formulas from standard power-analysis references — Cohen (1988), Schoenfeld (1981), Hsieh & Lavori (2000), Donner & Klar (1996), Wang & Tsiatis (1987), Hanley & McNeil (1982), Bonett & Wright (2000), Simon (1989), Flack et al. (1988), and many others cited per-method in the calculator source.