Aperçu
Biostatistique médicale pour tests d'hypothèse, conception d'essais cliniques et analyse de survie. Couvre les t-tests, ANOVA, chi-deux, Fisher exact, Mann-Whitney, Kruskal-Wallis, calcul de la taille d'échantillon, analyse de puissance et correction pour tests multiples.
Installation
uv pip install scipy statsmodels
Tests courants
import numpy as np
from scipy import stats
# Test t sur deux échantillons
t_stat, p = stats.ttest_ind(np.random.normal(100, 15, 30), np.random.normal(110, 15, 30))
# Mann-Whitney
u_stat, p = stats.mannwhitneyu(np.random.normal(100, 15, 30), np.random.normal(110, 15, 30))
# Chi-deux
chi2, p, dof, _ = stats.chi2_contingency(np.array([[30, 10], [20, 40]]))
Taille d'échantillon
from statsmodels.stats.power import TTestIndPower
n = TTestIndPower().solve_power(effect_size=0.5, power=0.80, alpha=0.05)
print(f"N per group: {np.ceil(n):.0f}")