@@ -0,0 +1,893 @@
+#!/usr/env python%0Afrom math import sqrt%0A%0A%0Adef normal_error(n1, N):%0A    '''Get the normal approximation for the uncertainty%0A    for n1 accepts out of N trials'''%0A    def typecheck(x):%0A        if type(x) not in (type(float()), type(int())):%0A            raise TypeError('Type must be numeric')%0A    if n1 %3E N:%0A        raise ValueError('In reality, n1 must be %3C= N')%0A%0A    p = n1*1./N%0A    err = sqrt(p * (1 - p) / N)%0A    return p, err%0A%0A%0Adef normal_band(n1, N, nstdev=1.):%0A    '''Get the normal approximated confidence%0A    band going out nstdev standard deviations'''%0A    if not all(map(lambda x: type(x) in%0A               (type(float()), type(int())),%0A               %5Bn1, N, nstdev%5D)):%0A        raise TypeError('Inputs must be numeric')%0A    p, sigma = normal_error(n1, N)%0A    return max(0, p - nstdev * sigma), min(1, p + nstdev * sigma)%0A%0A%0Aif __name__ == '__main__':%0A    print normal_band(6, 10, 3.)%0A

add calculator for normal approximation