Created
July 3, 2018 05:54
-
-
Save ksamson/15b3945fc4fbc818773882a73e228597 to your computer and use it in GitHub Desktop.
Confidence Interval python implementation based on http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
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 math | |
import scipy.stats as st | |
def ci_lower_bound(pos, n, confidence=None, z=None): | |
if n == 0: | |
return 0 | |
if z is None: | |
z = st.norm.ppf(1 - (1 - confidence) / 2) | |
phat = 1.0 * pos / n | |
return (phat + z * z / (2 * n) - z * math.sqrt((phat * (1 - phat) + z * z / (4 * n)) / n)) / (1 + z * z / n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment