I'm trying to run a T-Test to check if there is a significant difference between two samples for a given KPI. I'm running this python code:
population_control = 18917
population_treatment = 169996
stddev_control = 3.7944261452602888
stddev_treatment = 3.8521668798017057
avg_control = 2.906
avg_treatment = 2.921
import scipy.stats
rvs1 = scipy.stats.norm.rvs(loc=avg_control,scale=stddev_control,size=population_control)
rvs2 = scipy.stats.norm.rvs(loc=avg_treatment,scale=stddev_treatment,size=population_treatment)
t_score, pvalue = scipy.stats.ttest_ind(rvs1, rvs2, equal_var = False)
print(pvalue)
But I don't understand why the output changes from one execution to another, for the same input info. Sometimes I have a p-value < 0.05 (significant), sometimes it's way higher.
Also, when I put a np.random.seed(12345678)
, I always have the same p-value, but it makes me doubt about what I'm doing.
Do you have any idea in mind ? Thanks a lot.