ANOVA (one-way)
Why ANOVA
If you compare 3+ groups with many t-tests, you increase false positives.
ANOVA tests:
- H0: all group means are equal
- H1: at least one mean differs
Example
One-way ANOVA
import numpy as np
from scipy import stats
A = np.array([10, 12, 11, 13, 12])
B = np.array([7, 8, 9, 8, 7])
C = np.array([14, 15, 13, 16, 14])
f_stat, p = stats.f_oneway(A, B, C)
print("F:", f_stat)
print("p:", p)One-way ANOVA
import numpy as np
from scipy import stats
A = np.array([10, 12, 11, 13, 12])
B = np.array([7, 8, 9, 8, 7])
C = np.array([14, 15, 13, 16, 14])
f_stat, p = stats.f_oneway(A, B, C)
print("F:", f_stat)
print("p:", p)If ANOVA is significant
ANOVA says โsome difference existsโ but not where.
Next steps:
- Post-hoc tests (e.g., Tukey HSD)
- Pairwise comparisons with correction
Assumptions
- Independence
- Normality within groups (approx)
- Homogeneity of variances
If variances differ a lot, consider Welch ANOVA or non-parametric alternatives.
If this helped you, consider buying me a coffee โ
Buy me a coffeeWas this page helpful?
Let us know how we did
