Last active
May 16, 2018 16:38
-
-
Save sriisking/10716f107ed30f4911639d695e3fbe49 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Here is the python script to calculate the values you are interested in. | |
""" | |
from scipy.stats import ttest_ind_from_stats | |
import numpy as np | |
#We use Welch's t-Test as the sample sizes are different | |
def statistical_significance_welch_ttest(mean1,std1,count1,mean2,std2,count2): | |
t_statistic, p_value = ttest_ind_from_stats(mean1, std1, count1, | |
mean2, std2, count2, | |
equal_var=False) | |
return t_statistic, p_value | |
#Here the pooled standard deviation accounts for unequal sample sizes | |
def effect_size_cohensD(mean1,std1,count1,mean2,std2,count2): | |
cohens_d = (mean1 - mean2) / np.sqrt(((count1 - 1) * std1 ** 2 + (count2 - 1) * std2 ** 2) / (count1 + count2 - 2)) | |
return cohens_d | |
if __name__ == '__main__': | |
mean1 = 845.1; std1 = 46.7;count1 = 32 | |
mean2 =829.1; std2 =33.8; count2 = 53 | |
t_statistic, p_value = statistical_significance_welch_ttest(mean1,std1,count1,mean2,std2,count2) | |
print t_statistic, p_value | |
cohens_d = effect_size_cohensD(mean1, std1, count1, mean2, std2, count2) | |
print cohens_d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment