Statistical Tests in Python
Python provides statistical testing through scipy and statsmodels.
T-tests
ttest_ind for independent samples: ttest_ind(group1, group2). ttest_rel for paired samples.
One-sample t-test: ttest_1samp(data, popmean). Returns statistic and p-value.
ANOVA
f_oneway for one-way ANOVA: f_oneway(*groups). Returns F-statistic and p-value.
For two-way, use statsmodels: sm.stats.anova_lm(model).
Correlation
pearsonr for Pearson correlation: pearsonr(x, y). Returns correlation and p-value.
spearmanr for Spearman correlation. kendalltau for Kendall's tau.
Key Takeaways
- scipy.stats provides basic statistical tests
- t-tests compare means
- ANOVA compares multiple group means