t test 2 samples (independent samples) assuming unequal variance - mauriceling/mauriceling.github.io GitHub Wiki

Purpose: To test whether the means of populations where 2 samples were drawn from are equal, without assuming that their variances are equal.

Null hypothesis: Mean of Population A = Mean of Population B

Alternate hypothesis: Mean of Population A ≠ Mean of Population B

Note: This is also known as Welch’s t-test.

Code:

>>> from scipy import stats
>>> X1 = [9.07, 8.97, 6.41, 3.03, 1.19, 2.67, 2.81, 9.2]
>>> X2 = [3.82, 8.26, 5.99, 3.81, 1.07, 5.06, 5.66, 4.47]
>>> result = stats.ttest_ind(X1, X2, equal_var=False)
>>> print("t = %.3f" % result.statistic)
t = 0.466
>>> print("p-value = %.3f" % result.pvalue)
p-value = 0.650