Advertisement
Guest User

P-value generator

a guest
Dec 23rd, 2019
1,124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. import numpy as np
  2. from scipy.stats import ttest_ind
  3.  
  4. # simulated experiments
  5. # two conditions, 50 observations per condition
  6. # standardized effect size randomly chosen between 0 and .5
  7. for i in np.arange(0,10):
  8.     sample_size = 50
  9.     effect_size = np.random.uniform(0,.5,1)
  10.     group_1 = np.random.normal(loc=0.0, scale=1.0, size=sample_size)
  11.     group_2 = np.random.normal(loc=effect_size, scale=1.0, size=sample_size)
  12.     t, p = ttest_ind(group_1, group_2, equal_var=False)
  13.     if p < .05:
  14.         print("p = %g" % (round(p,3)) + '. Statistically significant! #pvalues #nhst #statistics')
  15.     else:
  16.         print("p = %g" % (round(p,3)) + '. Not statistically significant! #pvalues #nhst #statistics')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement