Created
January 18, 2015 15:53
-
-
Save komiya-atsushi/1e362e00a4e6792a9611 to your computer and use it in GitHub Desktop.
statsmodels を使って二項比率の信頼区間を求めるデモプログラム。
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
# Requirements: | |
# pip install statsmodel pandas numpy scipy | |
from statsmodels.stats import proportion as prop | |
def demo(num_clicks, num_impressions): | |
alpha = 0.05 | |
methods = [ | |
'normal', | |
'beta', | |
'wilson', | |
'agresti_coull' | |
] | |
print "---" | |
for method in methods: | |
print '%s: %s' % (method, prop.proportion_confint(num_clicks, num_impressions, alpha, method)) | |
if __name__ == '__main__': | |
demo(5, 1000) | |
demo(0, 1000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment