Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. def bootstrap_test(higher, lower, n=100000):
  2. xs = higher
  3. ys = lower
  4. m = np.mean(xs) - np.mean(ys)
  5. zs = np.concatenate((xs,ys))
  6. boots = np.random.choice(ys, size=(n,len(zs)))
  7. return np.sum(np.mean(boots[:,0:len(xs)], 1) - np.mean(boots[:,len(xs)+1:], 1) > m)
  8.  
  9. # test whether the mean of the array `higher` is higher than the mean of the array `lower`
  10. def bootstrap_pvalue(higher, lower, n=100000):
  11. return bootstrap_test(higher, lower, n=100000) / n
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement