Created
September 29, 2020 21:00
-
-
Save SaraM92/a5805985b39bac32b191c5eacbca6a8f 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
#Import needed libraries | |
import numpy as np | |
import scipy.stats | |
#build a function that calculates the confidence interval | |
def mean_confidence_interval(data, confidence=0.95): | |
a = 1.0 * np.array(data) | |
n = len(a) | |
m, se = np.mean(a), scipy.stats.sem(a) | |
h = se * scipy.stats.t.ppf((1 + confidence) / 2., n-1) | |
return m, m-h, m+h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment