Data Science ยท Chapter 19 of 43
Hypothesis Testing
A hypothesis test asks: is the difference I see REAL or just random chance?
Set a NULL hypothesis (no effect), compute a p-value, and reject the null if p < ฮฑ (usually 0.05).
Example 1 (python)
from scipy import stats
group_a = [72, 75, 71, 78, 80]
group_b = [68, 70, 72, 65, 69]
t, p = stats.ttest_ind(group_a, group_b)
print(round(p, 4))Output
0.0034p < 0.05 โ reject the null.
Example 2 (python)
# A/B tests: is the new button better than the old one?Classic industry use of hypothesis tests.
Key points
- Null hypothesis: no effect.
- p-value: chance of seeing the data if null is true.
- ฮฑ (alpha): threshold, commonly 0.05.
- p < ฮฑ โ reject the null.
๐ก Note: A significant p-value does NOT mean the effect is large or important โ always report effect size too.
