BiostatKit / Sample size / Sample size for a proportion
Sample Size Calculator for a Proportion
Find how many participants you need to estimate a prevalence with a chosen margin of error. You get the number, the expected 95% CI, a sentence for your methods section, and the R code.
Your data never leaves your browser. No sign-up, no ads.Result
Participants needed for a single proportion.
Sentence for your manuscript
Written in AMA style from your numbers. Check it against your own study design before you submit.
Reporting checklist
- STROBE 2007 (observational studies): explain how the study size was arrived at (item 10).
- CONSORT 2010 (trials): how the sample size was determined (item 7a). For a prevalence survey, STROBE item 10 applies.
- State the expected proportion, margin of error, confidence level, and where the expected proportion came from (pilot data or a cited study).
Methods wording. The sample size for estimating a single proportion was calculated with BiostatKit [1] using the formula of Cochran [2].
[1] BiostatKit. Sample size calculator for a proportion. Accessed [date]. [URL]
[2] Cochran WG. Sampling Techniques. 3rd ed. New York, NY: Wiley; 1977.
Reproduce it in R
The script is filled in with your numbers. Paste it into R or RStudio and compare.
This calculator was checked against SciPy and statsmodels on 2 reference cases and matched to 4 significant digits. See the verification log.
How the sample size is worked out
What it is
For a prevalence study you choose how precise you want the answer to be. The sample size is the number of participants for which the 95% (or 90%, 99%) CI around the expected proportion has the half-width you asked for.
How this page computes it
n = Z² x p x (1 - p) / d² with p the expected proportion, d the margin of error as a proportion, and Z the normal quantile for the confidence level (1.96 for 95%).
With a population of size N: n' = n / (1 + (n - 1) / N). Both are rounded up to the next whole participant.
Assumptions
- Simple random sampling, so each member of the population has the same chance of selection.
- A normal (Wald) approximation, which works for proportions away from 0% and 100%. For a proportion under about 5% or over 95%, use an exact or Wilson-based method.
- The margin of error is absolute (percentage points), not relative.
Common mistakes
- Forgetting non-response. Divide the result by the expected response rate (for 80%, divide by 0.8).
- Ignoring clustering. With cluster sampling, multiply by the design effect.
- Using this for comparing two groups. That needs a power calculation: see the two-group calculator.
- Mixing 5% and 5 percentage points. A 5% relative margin on a prevalence of 20% is 1 point.
Frequently asked questions
What if I do not know the expected proportion?
Use 50%. It gives the largest sample, so you are safe. A pilot study or a published study in a similar population gives a better, smaller number.
When do I use the finite population correction?
When the sample is more than about 5% of the population, for example 400 of 2,000 hospital patients. For a large or unknown population leave it empty.
Why is the answer rounded up?
A sample of 384.2 people does not exist, and rounding down would leave you with less precision than you planned.
Is my data stored or sent anywhere?
No. All calculations run in your browser tab. Nothing is uploaded, and the page works offline once loaded.
Related calculators: Odds ratio calculator · Sensitivity and specificity calculator