Last active
August 29, 2015 13:56
-
-
Save bshlgrs/9015672 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sympy.statistics import Normal | |
def getStdDev(distance,confidence,x = Normal(0,1)): | |
"Distance = end point - mean" | |
confidenceDistance = x.confidence(confidence)[1] | |
stddev = confidenceDistance * distance | |
return stddev | |
def confidenceInterval(start,end,confidence): | |
"""If I give a 50 percent chance that my variable x is between 10 and 13, | |
then this function converts that to a Gaussian centered at 11.5 with an | |
appropriate standard deviation.""" | |
mean = 0.5*(end+start) | |
stddev = getStdDev(0.5*(end-start), confidence) | |
return (mean,stddev) | |
print confidenceInterval(300,500,0.8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment