HomeStatistics & Probability › Sample Size Calculator

Sample Size Calculator

Computes the number of respondents needed to estimate a population proportion within a given margin of error at a given confidence level (Cochran's formula), with an optional finite population correction.

When to use

You are planning a survey, poll or A/B test on a proportion and need to know how many people to sample for a target margin of error.

Do not use when: You already have a sample and want its margin of error (use margin-of-error), or you are estimating a mean rather than a proportion (the formula would need the standard deviation instead of p(1 − p)).

Formula

n0 = z² · p · (1 − p) / e², with p = expected_proportion_percent/100 and e = margin_of_error_percent/100; with population_size N: n = n0 / (1 + (n0 − 1) / N); both rounded up

Cochran's sample-size formula for a proportion with the normal approximation. The finite population correction is applied to the unrounded n0 (as in most survey references); rounding n0 first would occasionally add one respondent.

Inputs

ParameterTypeUnitRequiredDescription
confidence_level_percentnumber%default 95Confidence level in percent (commonly 90, 95 or 99). Determines the critical z value. Range: > 0
margin_of_error_percentnumber%yesAcceptable half-width of the confidence interval, in percentage points (5 means ±5 %). Range: > 0, ≤ 50
expected_proportion_percentnumber%default 50Anticipated percentage with the attribute. 50 % is the conservative choice giving the largest sample. Range: ≥ 1, ≤ 99
population_sizeintegernoOptional total population size N. When given, the finite population correction is applied; omit for large or unknown populations. Range: ≥ 2

Outputs

OutputTypeUnitDescription
z_valuenumberTwo-sided normal critical value for the confidence level.
sample_sizeintegerMinimum number of respondents, rounded up; includes the finite population correction when population_size is given.
sample_size_infinite_populationintegern0 = z² p (1 − p) / e², rounded up, before any finite population correction.

Example

95 %, ±5 %, p = 50 %: {"confidence_level_percent":95,"margin_of_error_percent":5,"expected_proportion_percent":50}{"z_value":1.96,"sample_size":385,"sample_size_infinite_population":385}

Same, population of 1,000: {"confidence_level_percent":95,"margin_of_error_percent":5,"expected_proportion_percent":50,"population_size":1000}{"sample_size":278,"sample_size_infinite_population":385}

GET https://tttkmbb.com/api/v1/calculate/sample-size?confidence_level_percent=95&margin_of_error_percent=5&expected_proportion_percent=50

Machine access

Sources

FAQ

Why is 385 the usual answer?

At 95 % confidence, ±5 % margin and p = 50 %: 1.96² × 0.25 / 0.05² = 384.16, rounded up to 385. Halving the margin to ±2.5 % quadruples the sample to 1,537.

Does the sample size depend on the population size?

Only when the sample is a noticeable fraction of the population. For a population of 1,000 the correction reduces 385 to 278; for populations above about 100,000 it changes almost nothing.

What about non-response?

The result is the number of completed responses. Divide by the expected response rate to get the number of invitations (e.g. 385 / 0.2 = 1,925 for a 20 % response rate).

Related calculators