57. Statistics: Confidence Interval for a single proportion

This post is also available as a PDF and as a Jupyter Notebook

We can use statsmodels to calculate the confidence interval of the proportion of given ’successes’ from a number of trials. This may the frequency of occurrence of a gene, the intention to vote in a particular way, etc.


import statsmodels.stats.proportion as smp

# e.g. 35 out of a sample 120 (29.2%) people have a particular gene type.
# What are the 95% confidence intervals on the proportion?

lower, upper = smp.proportion_confint (35, 120, alpha=0.05, method='normal')

print ('Lower confidence interval:', lower)
print ('Upper confidence interval:', upper)

OUT:

Lower confidence interval: 0.21034248403748906
Upper confidence interval: 0.3729908492958443

One thought on “57. Statistics: Confidence Interval for a single proportion

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s