Summary and Practical Guide to Hypothesis Testing › scipy.stats Quick Reference

Michael BrenndoerferJanuary 10, 20261 min read
Machine Learning from ScratchAll chapters
Part 2 of 15Hypothesis Testing
Chapter 22Summary and Practical Guide to Hypothesis Testing › scipy.stats Quick Reference
Reading section 9 of 12 · scipy.stats Quick Reference · 1 minSection 9 of 12 · 1 min

Section 9 of 12 · 1 min read

Summary and Practical Guide to Hypothesis Testing › scipy.stats Quick ReferenceSection view · Sections in this chapter9 / 12 ↓
Reading tools Definitions, links & notes

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Notes & comments

Testing Functions

PythonIn [17]
CollapseExpand
from scipy import stats

# One-sample tests
stats.ttest_1samp(sample, popmean)  # One-sample t-test
stats.shapiro(sample)  # Normality test

# Two-sample tests
stats.ttest_ind(a, b, equal_var=True)  # Pooled t-test
stats.ttest_ind(a, b, equal_var=False)  # Welch's t-test
stats.ttest_rel(a, b)  # Paired t-test
stats.levene(a, b)  # Equal variance test

# Multiple groups
stats.f_oneway(g1, g2, g3, ...)  # One-way ANOVA
stats.tukey_hsd(g1, g2, g3, ...)  # Tukey post-hoc
stats.dunnett(t1, t2, control=ctrl)  # Dunnett post-hoc

# Multiple comparison corrections
stats.false_discovery_control(pvals, method="bh")  # BH correction
stats.false_discovery_control(pvals, method="by")  # BY correction

Distribution Functions

PythonIn [19]
CollapseExpand
# For manual calculations
stats.norm.ppf(0.975)  # Z critical value (two-tailed, α=0.05)
stats.t.ppf(0.975, df)  # t critical value
stats.f.ppf(0.95, df1, df2)  # F critical value

# P-values from test statistics
stats.norm.sf(z) * 2  # Two-tailed p from z
stats.t.sf(t, df) * 2  # Two-tailed p from t
stats.f.sf(f, df1, df2)  # Upper-tail p from F

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy