Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- # Sakari Vaelma
- from random import gauss
- from math import sqrt
- from scipy.stats import ttest_ind
- TESTS = 10000
- NUMBERS_IN_SAMPLE = 100
- def random_normal_sample(count, mean, variance):
- return [gauss(mean, sqrt(variance))
- for n in range(count)]
- print "Percentage of p < 0.05: %.2f" %\
- (len([p for t, p
- in [ttest_ind(random_normal_sample(NUMBERS_IN_SAMPLE, 0, 1),
- random_normal_sample(NUMBERS_IN_SAMPLE, 0, 1))
- for n in range(TESTS)]
- if p < 0.05]) / float(TESTS) * 100)
Advertisement
Add Comment
Please, Sign In to add comment