T-tests are used to assess if there is a significant difference between the means of two variables and determine if they belong to the same distribution.
It is a two-tailed test.
The ttest_ind()
function takes two samples of the same size and returns a tuple containing the t-statistic and p-value.
Determine if the given values, v1 and v2, come from the same distribution.
import numpy as np from scipy.stats import ttest_ind v1 = np.random.normal(size=100) v2 = np.random.normal(size=100) res = ttest_ind(v1, v2) print(res) |
Ttest_indResult(statistic=0.40833510339674095, pvalue=0.68346891833752133) |
To return only the p-value, use the pvalue
property.
… res = ttest_ind(v1, v2).pvalue print(res) |
0.68346891833752133 |