← retour aux snippets

scipy.stats: ttests

Tests t univariés et à deux échantillons.

python stats #scipy#ttest#stats

objectif

Tests t univariés et à deux échantillons.

code minimal

from scipy import stats
import numpy as np
x = np.array([1,2,3])
print(stats.ttest_1samp(x, popmean=2).pvalue <= 1.0)

utilisation

from scipy import stats
print(stats.ttest_ind([1,2,3], [2,3,4], equal_var=False).statistic is not None)

variante(s) utile(s)

from scipy import stats
print(stats.ttest_rel([1,2,3],[1,2,4]).pvalue <= 1.0)

notes

  • Vérifier hypothèses: normalité, variance, appariement.