CALCULATORCASTLE

Sample Size Calculator

Determine the required sample size for statistical studies.

About

Sample Size Calculator

Statistics infers things about a population by studying a finite number of individuals drawn from it, on the assumption that the sample resembles the whole. Suppose some proportion p of a population has a particular attribute and the remaining 1 − p does not: p might be the share with brown hair, with the rest black, blond or red. To estimate p, take a sample of n individuals and compute the sample proportion, .

Unless you survey everyone, p̂ almost certainly will not equal p. It suffers from sampling noise, meaning it depends on which particular individuals happened to be picked. What sampling statistics can do is put a bound on that gap. This calculator answers the two practical questions that follow: how many responses you need to hit a given bound, and what bound you already have from a sample you collected.

Statistics of a random sample

The estimate p̂ is good but imperfect. The Central Limit Theorem says it is approximately normally distributed with mean p and variance p(1 − p)/n, and that single fact is what every number on this page rests on.

Read the variance carefully, because it explains the whole economics of surveying. It is inversely proportional to n, so the estimate tightens as the sample grows, but the margin of error depends on the square root of the variance. Error therefore falls with 1 ÷ √n. Quadrupling your sample halves the margin of error. Cutting the error to a tenth needs a hundred times the data. That relationship, more than cost or effort, is why national polls settle around a thousand respondents rather than ten thousand.

The normal approximation needs a reasonable count in both categories. The usual rule of thumb is that np and n(1 − p) should each be at least 5, and some texts insist on 10. With a proportion near 0 or 1, or a small sample, the interval this page produces (the Wald interval) is known to be too narrow and can even run past 0% or 100%. Statisticians reach for the Wilson score interval or the Agresti-Coull adjustment in those cases, which is worth knowing before you report that 2% of 40 people said yes.

Confidence level

The confidence level measures how certain you are that a sample reflects the population within your chosen interval. The common choices are 90%, 95% and 99%, each with a corresponding z score. Given that a survey is repeated many times, the confidence level is the percentage of those repeats whose interval would contain the true value.

Confidence levelz score (±)
0.701.04
0.751.15
0.801.28
0.851.44
0.921.75
0.951.96
0.962.05
0.982.33
0.992.58
0.9993.29
0.99993.89
0.999994.42

Higher confidence is not free. Moving from 95% to 99% multiplies the z score from 1.96 to 2.58, which widens the interval by about 32%, and holding the interval fixed instead means roughly 73% more responses. Pick the level the decision actually needs.

Confidence interval

A confidence interval is an estimated range of likely values for a population parameter, such as 40 ± 2 or 40 ± 5%. At the 95% level, if the same population were sampled many times and an interval computed each time, about 95% of those intervals would contain the true parameter. The 95% describes the reliability of the procedure, not any one interval: once computed, an interval either contains the parameter or it does not.

Several equations exist depending on whether the standard deviation is known and how small the sample is. This page computes the interval for a proportion, using:

Unlimited population :
CI = ± z × p(1 − p)n
Finite population :
CI= ± z × (1 − )n × NnN − 1

where z is the z score, is the population proportion, n and n′ are sample size, and N is the population size.

A population here is any set of elements relevant to the question: employees at a company, people in an age group, books in a library. The second equation adjusts for a finite one. The (N − n)/(N − 1) term is the finite population correction factor, and it is needed because individuals in a sample cannot be treated as independent when the pool is small. If a study picks 10 people from a room of 100 with ages 1 to 100 and one of them is aged 100, the next person picked is more likely to be younger. In practice the correction barely moves the answer once the sample is under about 5% of the population, which is why national polls ignore it entirely.

Worked example: 120 people work at Company Q and 85 drink coffee daily. The 99% confidence interval for the true proportion of daily coffee drinkers is:

CI = ± z × p(1 − p)n
CI = 85120 ± 2.58 × 85120(1 − 85120)120
CI = 0.70833 ± 0.107
= 70.833% ± 10.71%

Sample size calculation

Sample size is the number of observations that should go into a statistical sample. To find it, take the confidence interval equation, set the term to the right of the ± sign equal to your margin of error ε, and solve for n.

Unlimited population :
n = z2 × (1 − )ε2
Finite population :
n= n1 + z2(1 − )ε2N

where z is the z score, ε is the margin of error, N is the population size and is the population proportion.

Worked example: estimate the proportion of US supermarket shoppers who identify as vegan, with 95% confidence and a 5% margin of error. Assume a population proportion of 0.5 and an unlimited population size.

n = z2 × (1 − )ε2
n = 1.962 × 0.5(1 − 0.5)0.052 = 384.16

So at least 385 people are needed. Some studies put the vegan share of the US population near 6%, and using 0.06 for p̂ instead of 0.5 drops the requirement to 87. If 40 of 500 shoppers entering on a given day were vegan, p̂ would be 0.08.

That difference is worth dwelling on. The product p̂(1 − p̂) is largest at exactly 0.5, where it equals 0.25, and it falls away symmetrically towards either end. Using 50% therefore gives the largest sample any proportion could require, which is why it is the safe default when you have no prior estimate. If you do have a credible one, using it can cut the survey by more than half.

What the margin of error does not cover

Every formula on this page describes sampling error alone: the variation that comes from measuring some people rather than all of them. It assumes the sample was drawn at random and that everyone approached responded. Real surveys break both assumptions.

The 1936 Literary Digest poll is the standing example. It collected 2.4 million responses, one of the largest political surveys ever run, and predicted Alf Landon would beat Franklin Roosevelt. Roosevelt won 46 of 48 states. The sample came from telephone directories and car registrations during the Depression, so it skewed wealthy, and only about a quarter of those contacted replied. George Gallup called the election correctly the same year with roughly 50,000 people. No sample size fixes a biased frame, and the margin of error will not warn you, because it cannot see the problem.

Two more practical cautions. A quoted margin of error normally applies to the full sample at p = 50%; any subgroup you break out has a much larger one, since n for that group is far smaller. And surveys using clustering or weighting carry a design effect that inflates the variance, often needing 1.5 to 2 times the responses this calculator suggests for the same precision.

Beyond proportions

These formulas answer questions of the form "what share of the population does X". For a continuous measurement such as average height or spend, the sample size needed is n = (zσ/ε)², where σ is the standard deviation of the measurement and ε is the margin of error in the same units. That requires an estimate of σ up front, usually from a pilot study or from earlier work.

One more useful shortcut for rare events: if something does not occur at all in n trials, the upper bound of the 95% confidence interval for its rate is about 3/n. Seeing no side effects in 300 patients is consistent with a true rate as high as 1 in 100. It is called the rule of three, and it saves a great deal of misplaced confidence about events that simply have not happened yet.

Common questions

Frequently asked questions

For a large or unknown population at 95% confidence with a 5% margin of error, 385. That figure assumes a 50% population proportion, which is the most demanding case. Tightening the margin to 3% raises it to 1,068 and 1% raises it to 9,604, because the requirement grows with the square of the precision you want.

Use 50%. The term p(1 − p) in the formula peaks at exactly 0.5, so that assumption produces the largest sample any true proportion could need and can never leave you short. If you have a credible prior estimate, use it instead: at 6% the same survey needs 87 responses rather than 385.

When your population is genuinely limited and your sample is a meaningful slice of it, say surveying 400 of a a company with 1,000 staff. Leave it blank for anything effectively unlimited, such as all shoppers in a country. The finite population correction changes little once the sample is under about 5% of the population.

The margin of error is the width of the range, the ±5% part. The confidence level is how often that range would capture the truth if you repeated the study, the 95% part. They trade against each other: at a fixed sample size, demanding more confidence forces a wider range.

Barely, which surprises most people. At 95% confidence and 5% margin of error you need 370 responses from a population of 10,000 and 385 from an unlimited population. Past a few thousand, the population size stops mattering almost entirely and only the sample size drives precision.

Convention rather than mathematics. It traces to Ronald Fisher treating a 1-in-20 result as a convenient marker of significance in the 1920s, and it stuck across most fields. Physics uses far stricter thresholds, around five standard deviations for a discovery claim. Pick the level that suits the cost of being wrong.

No, and this is the most consequential limitation. It measures sampling error only, assuming a genuine random sample with full response. The 1936 Literary Digest poll had 2.4 million responses and still called the election wrong, because the sample was drawn from telephone and car owners during the Depression. A larger biased sample is just a more precisely wrong answer.

It gets unreliable. The normal approximation used here wants np and n(1 − p) to be at least 5, and near 0% or 100% the interval is too narrow and can run past the 0 to 100 range. Use the Wilson score interval or the Agresti-Coull adjustment there. For an event that never occurred in n trials, the rule of three gives an upper bound of roughly 3/n.