objectif
Comparer des distributions sans hypothèse de normalité.
code minimal
from scipy import stats
import numpy as np
rng = np.random.default_rng(0)
a = rng.normal(size=50)
b = rng.normal(loc=0.5, size=50)
u = stats.mannwhitneyu(a, b, alternative="two-sided")
print(u.pvalue <= 1.0)
utilisation
from scipy import stats
x = np.random.default_rng(1).normal(size=100)
print(stats.kstest(x, "norm").pvalue <= 1.0)
variante(s) utile(s)
from scipy import stats
print(stats.ks_2samp([1,2,3], [1,2,4]).statistic >= 0.0)
notes
- KS mesure l’écart des CDF cumulées.