Skip to content

Instantly share code, notes, and snippets.

Created September 28, 2015 09:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/29eaa6844c6242bedc47 to your computer and use it in GitHub Desktop.
Save anonymous/29eaa6844c6242bedc47 to your computer and use it in GitHub Desktop.
from scipy.stats import norm
BOXES_IN_TEST = 5000
def box(sigma):
return [norm(loc=310 / 12., scale=sigma).rvs() for i in range(12)]
def trials(sigma_range):
for sigma in sigma_range:
boxes = map(sum, [box(sigma) for i in range(BOXES_IN_TEST)])
outliers = sum(map(lambda weight: 1 if weight > 317 or weight < 303 else 0, boxes))
outliers /= float(BOXES_IN_TEST)
if outliers < 0.1:
print 'Stdev {} is acceptable: {} of samples are out of the interval'.format(sigma, outliers)
if __name__ == '__main__':
test_range = [x / 100. for x in range(100, 300)]
trials(test_range)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment