Skip to content

Instantly share code, notes, and snippets.

@komiya-atsushi
Created January 18, 2015 15:53
Show Gist options
  • Save komiya-atsushi/1e362e00a4e6792a9611 to your computer and use it in GitHub Desktop.
Save komiya-atsushi/1e362e00a4e6792a9611 to your computer and use it in GitHub Desktop.
statsmodels を使って二項比率の信頼区間を求めるデモプログラム。
# 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