███╗ ███╗ ██████╗ ██████╗
████╗ ████║ ██╔════╝ ██╔══██╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔████╔██║ ██║ ██║ ██║██╔═══██╗██║ ██║██╔════╝██╔══██╗
██║╚██╔╝██║ ██║ ██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██║ ╚═╝ ██║ ██║ ██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ██║ ╚██████╗ ██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
Power analysis by simulation — any design from t-test to mixed models, in your browser, on your desktop, or in Python and R.
Why MCPower?
- MCPower covers anything from ANOVA to generalized linear to mixed models. Analytical power formulas exist for a few textbook designs and are correct only when all their assumptions are met (they aren't). Monte Carlo is the ground truth they approximate.
- Fast enough to mean it. A purpose-built engine, hundreds to thousands of times faster per fit than simr, simglm, or Superpower, and 60–1,200× faster than a hand-optimized R/Python loop — a full sample-size search (ten candidate n × 10,000 simulations) runs in seconds, not hours or even days for mixed models. Speed stops being the reason to avoid simulation.
- Robustness built in. Stress-tests your design against the messy, non-ideal data that formulas assume away, so you catch under-powering before you collect.
- Easy, and everywhere. A few-line API across four bindings — Python, R, desktop app, browser. Free and open source.
Install
pip install mcpower
Plotting is an optional extra: pip install mcpower[plot] (needed for save_plot() and inline Jupyter plots).
numpy and pandas are not required — they're accepted only as optional input formats for upload_data() and set_correlations() (plain Python lists and dicts work everywhere). Install them with pip install mcpower[optional] if you want to pass arrays or DataFrames.
Quickstart
from mcpower import MCPower
# Clinical trial testing a new therapy vs control.
# Research question: Does the new therapy improve patient outcomes?
# Define the model with an R-style formula.
model = MCPower("patient_outcome = treatment + baseline_score")
# Expected effect sizes (standardised).
# treatment=0.5 → therapy shifts outcomes by 0.5 SD (a medium effect).
# baseline_score=0.3 → baseline moderately predicts the outcome.
model.set_effects("treatment=0.5, baseline_score=0.3")
# Variable types — treatment is binary (0=control, 1=therapy).
model.set_variable_type("treatment=binary")
# Power at N=120, targeting the treatment test.
# One row per effect with Power, 95% CI, and a ✓/✗ marker against target power.
model.find_power(sample_size=120, target_test="treatment")
More examples
Sample size search:
from mcpower import MCPower
# Educational intervention study.
# Research question: What N do we need to detect the intervention effect?
model = MCPower("test_score = intervention + prior_knowledge + motivation")
model.set_effects("intervention=0.4, prior_knowledge=0.35, motivation=0.3")
# Variable types — intervention is binary (0=control, 1=intervention).
model.set_variable_type("intervention=binary")
# Sweep a grid and report the smallest N that reaches target power.
model.find_sample_size(target_test="intervention", from_size=30, to_size=300, by=10)
Mixed-effects / LME (clustered data):
from mcpower import MCPower
# Education study where students are nested in classrooms.
# Research question: Does a teaching method raise test scores, accounting for
# the fact that students in the same classroom are correlated?
# Declare a mixed model. The (1|classroom) term adds a random intercept per
# classroom; family="lme" fits it by maximum likelihood (MLE estimator).
model = MCPower("score = teaching_method + prior_gpa + (1|classroom)", family="lme")
model.set_variable_type("teaching_method=binary")
model.set_effects("teaching_method=0.4, prior_gpa=0.18")
# Describe the clustering: ICC=0.15 (15% of variance is between-classroom)
# across 30 classrooms. At N=300 that is 10 students per classroom.
model.set_cluster("classroom", ICC=0.15, n_clusters=30)
# Power at N=300 for the fixed effects.
model.find_power(sample_size=300, target_test="teaching_method, prior_gpa")
See examples/ (01–11) and the Python tutorial for interactions, correlations, factors/ANOVA, logistic regression, your-own-data upload, custom scenarios, and plotting.
API at a glance
Two entry points, a fluent set_* chain:
| Call | What it does |
|---|---|
MCPower("y = x1 + x2", family="ols") |
Define the model (R-style formula; family ∈ "ols"/"logit"/"probit"/"poisson"/"lme") |
.set_effects("x1=0.5, x2=0.3") |
Standardised effect sizes |
.set_variable_type("x1=binary, g=(factor,3)") |
Predictor distributions |
.set_correlations("corr(x1, x2)=0.3") |
Correlations between predictors |
.set_cluster("group", ICC=0.2, n_clusters=20) |
Random-effects structure (family="lme") |
.set_baseline_probability(0.3) |
Event rate at reference (family="logit") |
.upload_data(df) |
Use your own data instead of synthetic |
.get_effects_from_data("y") |
Borrow starting effect sizes from uploaded data (approximate) |
.set_seed(2137) · .set_alpha(0.05) · .set_power(80) · .set_simulations(n) |
Tuning knobs |
.find_power(sample_size=200, target_test="all") |
Power at a fixed N |
.find_sample_size(target_test="x1", from_size=50, to_size=400) |
Smallest N for target power |
All set_* methods chain and return self; add scenarios=True to either find_* for optimistic/realistic/doomer robustness.
Docs
Full documentation: https://docs.mcpower.app.
Citation & License
GPL v3. If you use MCPower in research, please cite:
Lenartowicz, P. (2025). MCPower: Monte Carlo Power Analysis for Complex Statistical Models [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.16502734
@software{mcpower2025,
author = {Lenartowicz, Pawe{\l}},
title = {{MCPower}: Monte Carlo Power Analysis for Complex Statistical Models},
year = {2025},
publisher = {Zenodo},
doi = {10.5281/zenodo.16502734},
url = {https://doi.org/10.5281/zenodo.16502734}
}
Paweł Lenartowicz — Freestyler Scientist · GitHub · ORCID
Metadata
Release files for mcpower 1.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcpower-1.4.1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for mcpower-1.4.1-cp310-abi3-win_amd64.whl |
| mcpower-1.4.1-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details for mcpower-1.4.1-cp310-abi3-manylinux_2_28_x86_64.whl |
| mcpower-1.4.1-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for mcpower-1.4.1-cp310-abi3-macosx_11_0_arm64.whl |
Total release size: 12.8 MB
Release files / mcpower-1.4.1-cp310-abi3-win_amd64.whl
| Download URL | mcpower-1.4.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 4.4 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
b4265b70e18752ab410ba988c601b131a6f0b326913c446e5741d8a6c243503a
|
|
BLAKE2b-256 checksum How to use checksums |
f151472d5b0005a00001606e820f3e52d811ae132caa84587b9ea3b92c3fc40a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / mcpower-1.4.1-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | mcpower-1.4.1-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.7 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7c16905fb6a95b6169c34f4e97fd797fea008ff209516984c425b293f7d23e94
|
|
BLAKE2b-256 checksum How to use checksums |
7665eddd3dc09829fdb4ba66fe5cb54b0eeb296e3699cd7f3bf4daa66d0b35ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logRelease files / mcpower-1.4.1-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | mcpower-1.4.1-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
28915d8343d86f83c6abe2b2cd18735c20fc0eba654009eaeaa92fc79427cd56
|
|
BLAKE2b-256 checksum How to use checksums |
6c9d3981eb3cfecd8d02b0f16e332060d4ceeae4c558e4a0f4f1c4e9e909d161
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logSecurity for mcpower 1.4.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 3 files in this release have been uploaded with provenance metadata.
Attestation for mcpower-1.4.1-cp310-abi3-win_amd64.whl
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 22, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.