Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Statistical hypothesis testing, power analysis, and significance reporting
.claude/skills/brycewang-stanford-hypothesis-testing-guide/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-05 | ✗→✓ | ▲ Improved | 108% | 0% |
| case-23 | ✗→✓ | ▲ Improved | 115% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 94% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 101% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 81% | 0% |
Hypothesis testing is the backbone of empirical research. It provides a principled framework for deciding whether observed differences in data reflect genuine effects or merely random variation. Misuse of hypothesis tests -- p-hacking, ignoring assumptions, confusing statistical and practical significance -- is a leading cause of irreproducible findings.
This guide covers the core hypothesis testing framework, the most commonly used tests across disciplines, assumption checking, effect size reporting, power analysis for sample size planning, and multiple comparison corrections. Each test is accompanied by Python code using scipy, statsmodels, and pingouin, ready to integrate into research workflows.
The goal is not just to help you run tests, but to help you run the right test correctly and report results following modern standards (APA 7th edition, journal best practices).
| Error Type | Definition | Probability | |-----------|-----------|-------------| | Type I (False Positive) | Reject H0 when it is true | alpha (usually 0.05) | | Type II (False Negative) | Fail to reject H0 when it is false | beta (usually 0.20) | | Power | Probability of correctly detecting an effect | 1 - beta (target: 0.80) |
| Research Question | Data Type | Groups | Test | |-------------------|-----------|--------|------| | Two group means differ? | Continuous, normal | 2 independent | Independent t-test | | Before/after difference? | Continuous, normal | 2 paired | Paired t-test | | Multiple group means differ? | Continuous, normal | 3+ independent | One-way ANOVA | | Two group medians differ? | Ordinal / non-normal | 2 independent | Mann-Whitney U | | Before/after (non-normal)? | Ordinal / non-normal | 2 paired | Wilcoxon signed-rank | | Multiple groups (non-normal)? | Ordinal / non-normal | 3+ independent | Kruskal-Wallis | | Association between categories? | Categorical | 2 variables | Chi-square test | | Correlation? | Continuous | 2 variables | Pearson or Spearman |
pythonfrom scipy import stats import numpy as np import pingouin as pg # Generate example data control = np.random.normal(50, 10, n=30) treatment = np.random.normal(55, 10, n=30) # Check normality assumption stat_c, p_c = stats.shapiro(control) stat_t, p_t = stats.shapiro(treatment) print(f"Normality p-values: control={p_c:.3f}, treatment={p_t:.3f}") # Check homogeneity of variance stat_l, p_l = stats.levene(control, treatment) print(f"Levene's test p={p_l:.3f}") # Run t-test t_stat, p_val = stats.ttest_ind(control, treatment, equal_var=(p_l > 0.05)) # Effect size (Cohen's d) cohens_d = (treatment.mean() - control.mean()) / np.sqrt( ((len(control)-1)*control.var() + (len(treatment)-1)*treatment.var()) / (len(control) + len(treatment) - 2) ) print(f"t={t_stat:.3f}, p={p_val:.4f}, Cohen's d={cohens_d:.3f}")
pythonimport pandas as pd df = pd.DataFrame({ 'score': np.concatenate([ np.random.normal(50, 10, 30), np.random.normal(55, 10, 30), np.random.normal(60, 10, 30) ]), 'group': np.repeat(['A', 'B', 'C'], 30) }) # ANOVA aov = pg.anova(data=df, dv='score', between='group', detailed=True) print(aov) # Post-hoc pairwise comparisons (Tukey HSD) posthoc = pg.pairwise_tukey(data=df, dv='score', between='group') print(posthoc[['A', 'B', 'diff', 'p-tukey', 'hedges']])
python# Contingency table observed = pd.DataFrame( [[45, 30], [25, 50]], index=['Method A', 'Method B'], columns=['Success', 'Failure'] ) chi2, p, dof, expected = stats.chi2_contingency(observed) cramers_v = np.sqrt(chi2 / (observed.values.sum() * (min(observed.shape) - 1))) print(f"chi2={chi2:.3f}, p={p:.4f}, Cramer's V={cramers_v:.3f}")
Power analysis answers: "How many participants do I need?"
pythonfrom statsmodels.stats.power import TTestIndPower, FTestAnovaPower # For a two-sample t-test analysis = TTestIndPower() # Calculate required sample size n = analysis.solve_power( effect_size=0.5, # Cohen's d (medium effect) alpha=0.05, power=0.80, ratio=1.0, # Equal group sizes alternative='two-sided' ) print(f"Required n per group: {int(np.ceil(n))}") # Power curve import matplotlib.pyplot as plt sample_sizes = np.arange(10, 200, 5) powers = [analysis.power(effect_size=0.5, nobs1=n, ratio=1.0, alpha=0.05) for n in sample_sizes] fig, ax = plt.subplots() ax.plot(sample_sizes, powers) ax.axhline(0.8, color='red', linestyle='--', label='Power = 0.80') ax.set_xlabel('Sample Size per Group') ax.set_ylabel('Statistical Power') ax.legend() fig.savefig('power_curve.pdf')
| Effect Size | Small | Medium | Large | |-------------|-------|--------|-------| | Cohen's d (t-test) | 0.2 | 0.5 | 0.8 | | eta-squared (ANOVA) | 0.01 | 0.06 | 0.14 | | Cramer's V (chi-square) | 0.1 | 0.3 | 0.5 | | Pearson r (correlation) | 0.1 | 0.3 | 0.5 |
When running multiple tests, the family-wise error rate inflates. Use corrections:
pythonfrom statsmodels.stats.multitest import multipletests p_values = [0.01, 0.04, 0.03, 0.08, 0.002] # Bonferroni (conservative) reject_bonf, pvals_bonf, _, _ = multipletests(p_values, method='bonferroni') # Benjamini-Hochberg FDR (less conservative) reject_bh, pvals_bh, _, _ = multipletests(p_values, method='fdr_bh') for i, p in enumerate(p_values): print(f"p={p:.3f} | Bonferroni: {pvals_bonf[i]:.3f} ({reject_bonf[i]}) " f"| BH-FDR: {pvals_bh[i]:.3f} ({reject_bh[i]})")
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 15,373 | 34,779 | +126% | 1 | 1 | 0% | 3,407 | 5,808 | +70% | 0 | 0 | — |
case-02 | pass→pass | 16,491 | 21,210 | +29% | 1 | 1 | 0% | 3,317 | 6,444 | +94% | 0 | 0 | — |
case-03 | pass→pass | 11,272 | 10,893 | -3% | 1 | 1 | 0% | 2,200 | 4,414 | +101% | 0 | 0 | — |
case-04 | pass→pass | 13,796 | 13,567 | -2% | 1 | 1 | 0% | 2,799 | 5,056 | +81% | 0 | 0 | — |
case-05 | fail→pass | 11,174 | 11,650 | +4% | 1 | 1 | 0% | 2,210 | 4,598 | +108% | 0 | 0 | — |
case-06 | pass→pass | 14,636 | 13,300 | -9% | 1 | 1 | 0% | 3,091 | 5,219 | +69% | 0 | 0 | — |
case-07 | pass→pass | 13,520 | 13,740 | +2% | 1 | 1 | 0% | 2,521 | 4,794 | +90% | 0 | 0 | — |
case-08 | pass→pass | 10,061 | 8,267 | -18% | 1 | 1 | 0% | 1,644 | 3,688 | +124% | 0 | 0 | — |
case-09 | pass→pass | 8,885 | 6,916 | -22% | 1 | 1 | 0% | 1,441 | 3,586 | +149% | 0 | 0 | — |
case-10 | pass→pass | 8,468 | 9,312 | +10% | 1 | 1 | 0% | 1,379 | 4,013 | +191% | 0 | 0 | — |
case-11 | pass→pass | 8,417 | 9,983 | +19% | 1 | 1 | 0% | 1,737 | 4,263 | +145% | 0 | 0 | — |
case-12 | pass→pass | 9,028 | 3,062 | -66% | 1 | 1 | 0% | 1,720 | 2,899 | +69% | 0 | 0 | — |
case-13 | pass→pass | 17,802 | 18,039 | +1% | 1 | 1 | 0% | 3,036 | 5,585 | +84% | 0 | 0 | — |
case-14 | pass→pass | 10,203 | 11,303 | +11% | 1 | 1 | 0% | 1,621 | 4,129 | +155% | 0 | 0 | — |
case-15 | pass→pass | 8,241 | 11,522 | +40% | 1 | 1 | 0% | 1,212 | 4,207 | +247% | 0 | 0 | — |
case-16 | pass→pass | 14,988 | 14,802 | -1% | 1 | 1 | 0% | 2,456 | 4,644 | +89% | 0 | 0 | — |
case-17 | pass→pass | 11,909 | 13,452 | +13% | 1 | 1 | 0% | 1,905 | 4,530 | +138% | 0 | 0 | — |
case-18 | pass→pass | 12,363 | 10,110 | -18% | 1 | 1 | 0% | 2,408 | 4,347 | +81% | 0 | 0 | — |
case-19 | pass→pass | 4,941 | 7,625 | +54% | 1 | 1 | 0% | 844 | 3,767 | +346% | 0 | 0 | — |
case-20 | pass→pass | 6,069 | 7,389 | +22% | 1 | 1 | 0% | 1,057 | 3,676 | +248% | 0 | 0 | — |
case-21 | pass→pass | 12,267 | 12,185 | -1% | 1 | 1 | 0% | 2,290 | 4,598 | +101% | 0 | 0 | — |
case-22 | pass→pass | 10,082 | 9,869 | -2% | 1 | 1 | 0% | 2,041 | 4,387 | +115% | 0 | 0 | — |
case-23 | fail→pass | 13,359 | 17,284 | +29% | 1 | 1 | 0% | 2,605 | 5,610 | +115% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.