Вот один пример t-теста:
from scipy.stats import ttest_1samp
import numpy as np
ages = [32., 34., 29., 29., 22., 39., 38., 37.,38, 36, 30, 26, 22, 22.]
ages_mean = np.mean(ages)
ages_std = np.std(ages, ddof=1)
print(ages_mean)
print(ages_std)
ttest, pval = ttest_1samp(ages, 30)
print("ttest: ", ttest)
print("p_value: ", pval)
#31.0
#6.2634470725607025
#ttest: 0.5973799001456603
#p_value: 0.5605155888171379
# check analytically:
my_ttest = (ages_mean - 30.0)/(ages_std/np.sqrt(len(ages)))
print(t)
#0.5973799001456603
проверьте значение p_value
по определению p_value = P(t>=0.59) = 1 - P(t<=.59).
Используя Z-таблицу, мы получили p_value = 1 - 0.7224 = 0.2776 # 0.56!!!