Confidence Interval for a Proportion Calculator
Updated How we review
Offline — showing the version cached on .
Unresolved errors (0)
Results
Observed proportion is 0.20000. Lower confidence limit is 0.07135. Upper confidence limit is 0.40103. Margin of error is 0.16484.
- Observed proportion
- Lower confidence limit
- Upper confidence limit
- Margin of error
Your recent calculations
Stored only on this device.
| Solved for | Number of observed events | Sample size | Confidence level | Observed proportion | Lower confidence limit | Upper confidence limit | Margin of error |
|---|
* computed under superseded data
How to use this calculator
- Enter Number of observed eventsEnter the number of observed events as events_observed. This is the event count found in the sample. 1
- Enter Sample sizeEnter the total sample as sample_size. It supplies the N denominator used for the observed proportion. 1
- Enter Confidence levelEnter confidence_level as a percentage. The source expresses interval confidence as 100(1-alpha) %. 1
- Read Margin of error
What this calculates
Use this calculator to estimate an observed proportion and its lower and upper confidence limits. Enter observed events, sample size, and confidence level. It reports the proportion, interval limits, and margin of error. 1
An exact method based on the binomial distribution supports the interval. The source describes limits for a proportion p using p_L and p_U. The calculation moves from short formulas to named stages and complete definitions. 1
Understand the interval
An interval has a lower confidence limit and an upper confidence limit. The source denotes them p_L and p_U. It describes (p_L, p_U) as an exact 100(1-alpha) % confidence interval for p. 1
The source uses p for the proportion under study. It uses p-hat for the observed proportion. The calculator exposes that quantity as observed_proportion. 1
Supply the observations
Calculation starts with observed data. The source describes sampled units and defective events as a setting for a proportion. A selected confidence level sets the stated confidence percentage. 1
Read the computed fields
The returned panel separates the observed quantity, interval endpoints, and margin. Its output names are observed_proportion, lower_bound, upper_bound, and margin_of_error. These are computed results rather than fields you enter. 1
The lower and upper values are the interval endpoints. margin_of_error describes the distance between those endpoints through the displayed calculation. Each output comes from the entered values and the page formulas. 1
Follow the calculation path
Calculate the observed proportion as N_d/N. Find the upper limit p_U by solving the binomial equation. Its sum from k = 0 through N_d equals α/2. Then find the lower limit p_L by solving the other equation. Its sum from k = 0 through N_d − 1 equals 1 − α/2. 1
Why the limits use separate equations
The source obtains p_U by solving a binomial equation. It obtains p_L through a related equation with a different summation endpoint and target. The displayed calculation keeps these limits as separate outputs. 1
Worked examples
Worked example — four observed events in twenty sampled units at ninety percent confidence: Observed proportion 0.20000
See inputs and calculation
Starting values
- Number of observed events
- 4
- Sample size
- 20
- Confidence level
- 90 %
- Observed proportion: 0.20000
Show arithmetic
4 / 20Full branch logic
4 / 20 - Lower confidence limit: 0.07135
Show arithmetic
4 * f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1)) / (4 * f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1)) + 20 - 4 + 1)Full branch logic
4 == 0 ? 0 : 4 * (4 == 0 ? 0 : f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1))) / (4 * (4 == 0 ? 0 : f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1))) + 20 - 4 + 1) - Upper confidence limit: 0.40103
Show arithmetic
(4 + 1) * f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4)) / (20 - 4 + (4 + 1) * f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4)))Full branch logic
4 == 20 ? 1 : (4 + 1) * (4 == 20 ? 0 : f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4))) / (20 - 4 + (4 + 1) * (4 == 20 ? 0 : f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4)))) - Margin of error: 0.16484
Show arithmetic
((4 + 1) * f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4)) / (20 - 4 + (4 + 1) * f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4))) - 4 * f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1)) / (4 * f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1)) + 20 - 4 + 1)) / 2Full branch logic
((4 == 20 ? 1 : (4 + 1) * (4 == 20 ? 0 : f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4))) / (20 - 4 + (4 + 1) * (4 == 20 ? 0 : f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4))))) - (4 == 0 ? 0 : 4 * (4 == 0 ? 0 : f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1))) / (4 * (4 == 0 ? 0 : f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1))) + 20 - 4 + 1))) / 2
Original example and source context
For the source example, sample 20 units and find 4 defective, giving an estimated proportion defective of 0.20. It reports p_L = 0.071354 and p_U = 0.401029, so the 90% confidence interval is (0.071, 0.400). 1
Key facts
- The lower-bound formula has an explicit branch for events_observed == 0. 1 1
- The upper-bound formula has an explicit branch for events_observed == sample_size. 1 1
- margin_of_error is calculated from the difference between the returned bounds. 1 1
- The source's exact method is based on the binomial distribution. 1 1
How this is calculated
Use the exact two-sided binomial method to estimate the observed proportion from the number of observed events and sample size, then report the lower and upper confidence limits at the chosen confidence level. The margin of error is half the interval width.
Observed proportion
p_hat- p_hat = Observed proportion
- alpha = Significance level
- p_L = Lower confidence limit
- p_U = Upper confidence limit
- margin = Margin of error
- events_observed = Number of observed events ()
- sample_size = Sample size ()
- confidence_level = Confidence level (%)
- observed_proportion = Observed proportion
- lower_bound = Lower confidence limit
- upper_bound = Upper confidence limit
- margin_of_error = Margin of error
- f_ppf = the F value with these degrees of freedom having this probability at or below it
Understand each part
These names are shorthand for the exact calculations below, not different formulas.
- Observed proportion (p_hat)
The observed event count divided by the sample size.
See the definition of p_hat
events_observed / sample_size - Significance level (alpha)
The portion outside the selected two-sided confidence level.
See the definition of alpha
1 - confidence_level / 100 - Lower confidence limit (p_L)
The lower confidence limit of the exact interval.
See the definition of p_L
lower_bound - Upper confidence limit (p_U)
The upper confidence limit of the exact interval.
See the definition of p_U
upper_bound - Margin of error (margin)
Half the distance between the exact lower and upper confidence limits.
See the definition of margin
(p_U - p_L) / 2
Follow the calculation with your values
- Observed proportion: 0.20000
Show arithmetic
4 / 20Full branch logic
4 / 20 - Lower confidence limit: 0.07135
Show arithmetic
4 * f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1)) / (4 * f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1)) + 20 - 4 + 1)Full branch logic
4 == 0 ? 0 : 4 * (4 == 0 ? 0 : f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1))) / (4 * (4 == 0 ? 0 : f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1))) + 20 - 4 + 1) - Upper confidence limit: 0.40103
Show arithmetic
(4 + 1) * f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4)) / (20 - 4 + (4 + 1) * f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4)))Full branch logic
4 == 20 ? 1 : (4 + 1) * (4 == 20 ? 0 : f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4))) / (20 - 4 + (4 + 1) * (4 == 20 ? 0 : f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4)))) - Margin of error: 0.16484
Show arithmetic
((4 + 1) * f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4)) / (20 - 4 + (4 + 1) * f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4))) - 4 * f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1)) / (4 * f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1)) + 20 - 4 + 1)) / 2Full branch logic
((4 == 20 ? 1 : (4 + 1) * (4 == 20 ? 0 : f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4))) / (20 - 4 + (4 + 1) * (4 == 20 ? 0 : f_ppf(1 - (1 - 90 / 100) / 2, 2 * (4 + 1), 2 * (20 - 4))))) - (4 == 0 ? 0 : 4 * (4 == 0 ? 0 : f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1))) / (4 * (4 == 0 ? 0 : f_ppf((1 - 90 / 100) / 2, 2 * 4, 2 * (20 - 4 + 1))) + 20 - 4 + 1))) / 2
Full formulas, symbols and sources
observed_proportion = events_observed / sample_size
Lower confidence limit
lower_bound = events_observed == 0 ? 0 : events_observed * (events_observed == 0 ? 0 : f_ppf((1 - confidence_level / 100) / 2, 2 * events_observed, 2 * (sample_size - events_observed + 1))) / (events_observed * (events_observed == 0 ? 0 : f_ppf((1 - confidence_level / 100) / 2, 2 * events_observed, 2 * (sample_size - events_observed + 1))) + sample_size - events_observed + 1)
Upper confidence limit
upper_bound = events_observed == sample_size ? 1 : (events_observed + 1) * (events_observed == sample_size ? 0 : f_ppf(1 - (1 - confidence_level / 100) / 2, 2 * (events_observed + 1), 2 * (sample_size - events_observed))) / (sample_size - events_observed + (events_observed + 1) * (events_observed == sample_size ? 0 : f_ppf(1 - (1 - confidence_level / 100) / 2, 2 * (events_observed + 1), 2 * (sample_size - events_observed))))
Margin of error
margin_of_error = (upper_bound - lower_bound) / 2
- events_observed
- Number of observed events ()
- sample_size
- Sample size ()
- confidence_level
- Confidence level (%)
- observed_proportion
- Observed proportion
- lower_bound
- Lower confidence limit
- upper_bound
- Upper confidence limit
- margin_of_error
- Margin of error
- f_ppf
- the F value with these degrees of freedom having this probability at or below it
Frequently asked questions
Why might the interval not be symmetric?
What happens when no events are observed?
What happens when every sampled unit is an event?
What does f_ppf mean here?
What does the source mean by F?
How does the confidence percentage connect with alpha?
When is the margin of error calculated?
Limitations & common mistakes
- The page's choice limits events_observed to 0 through 1000; these edges are page limits, not formula limits.
- The page's choice limits sample_size to 1 through 10000; these edges are page limits, not formula limits.
- The page's choice limits confidence_level to 1 through 99.999 %; these edges are page limits, not formula limits.
- Outside these page choices, the calculator refuses to answer.
- Use an exact method based on the binomial distribution to obtain the confidence interval for the proportion.
- The results are computed from the numbers you enter and are only as exact as those numbers; they are not a substitute for a measurement or a professional's judgement where one is required.
Formula, sources, and review
This calculation follows the formula published on this page and rests on 1 cited sources, listed under Sources below. Last checked .
Sources & methodology
| Constant | Value | Unit | Source |
|---|---|---|---|
| confidence_interval_for_proportion_c1 | 2 | 1 |