Skip to content

Instantly share code, notes, and snippets.

@chand1012
Last active May 1, 2017 02:48
Show Gist options
  • Save chand1012/34d6fefb03b1136a769489f236192c61 to your computer and use it in GitHub Desktop.
Save chand1012/34d6fefb03b1136a769489f236192c61 to your computer and use it in GitHub Desktop.
confidence calculator
from math import sqrt
print("Calculating confidence of 95%")
avg = float(input("Enter average of the data:"))
n = int(input("Enter number of items:"))
sd = float(input("Enter standard devation:"))
z = 1.96
conf_high = avg + z * (sd/sqrt(n))
conf_low = avg - z * (sd/sqrt(n))
st_err = (sd/sqrt(n))
print("Confidence high: {}".format(conf_high))
print("Confidence low: {}".format(conf_low))
print("Standard Error of the mean: {}".format(st_err))
print("With 95 percent confidence we have determined that the\nmean of the data is between\n{} and {}".format(conf_low, conf_high))
@chand1012
Copy link
Author

Execute this program online here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment