Maths

Sample Size Calculator

Find how many people to survey for a given confidence level and margin of error.

By Nitin Raturi · Last reviewed

Your survey

How to use the Sample Size Calculator

Find how many people to survey to estimate a percentage within a chosen margin.

  1. Enter the confidence level.
  2. Enter the margin of error you can accept.
  3. Enter the expected proportion, or keep 50%.
  4. Read the number of completed responses you need.

Good to know

  • OpenStax's 90%, ±3-point example needs 752 people.
  • Plan for non-responses: invite more people than the answer.

For estimating a percentage from a large population.

Confidence level

How sure you want to be that the true value lies within your margin of error.

How to fill it in

  • Enter a percentage from 50 to 99.99. 95% is the usual choice.

Example

95% confidence uses z = 1.959964.

Margin of error

How close, in percentage points, the survey result should be to the true value.

How to fill it in

  • Enter 0.1 to 50 points. Halving it needs about four times the people.

Example

±5 points needs 385 people; ±3 points needs 1,068.

Expected proportion

Your best guess at the answer, such as the share who will say yes.

How to fill it in

  • Enter 1% to 99%. If you have no idea, keep 50%: it gives the safest, largest sample.

Example

Expecting 20% instead of 50% cuts the sample to 246.

Keep in mind: Assumes a simple random sample from a large population.

Sample size

385 people

To be 95% confident of being within ±5 points, survey 385 people: 1.959964² × 0.5 × 0.5 ÷ 0.05² = 384.145882, rounded up.

Critical value (z)
1.959964
Before rounding
384.145882

n = z² p (1 − p) ÷ E², rounded up. Simple random sample, large population, completed responses.

How this calculator works

  1. Step 1ConfidencezThe normal critical value for your confidence level.
  2. Step 2Variabilityp (1 − p)Largest at 50%, the safe default.
  3. Step 3Sample sizez² p(1 − p) ÷ E²Rounded up to a whole person.

The sample size is how many completed responses you need so a survey percentage lands within your margin of error, at your chosen confidence.

The calculator works out the critical value z exactly for any confidence level, so you are not limited to the usual 90%, 95% and 99%.

Worked example: OpenStax Example 8.14

90% confidence, within ±3 points
Sample size
n = z² p (1 − p) ÷ E²
  • zCritical value at 90% 1.644854
  • pExpected proportion 0.5
  • EMargin of error 0.03
  1. z²1.644854²2.705543
  2. Before rounding2.705543 × 0.25 ÷ 0.0009751.539848
  3. Sample sizeround up752 people

OpenStax rounds z to 1.645 and gets 751.7; both round up to the book’s answer of 752 people.

How the choices change the size

  • 95%, ±5 points385
  • 99%, ±5 points664
  • 95%, ±3 points1,068
People needed, by confidence and margin (p = 50%)

Read the result

The answer counts completed responses. If only half of those you ask reply, invite about twice as many.

Expecting a lopsided result needs fewer people: at 20% rather than 50%, the 95%, ±5-point survey needs 246.

Assumptions and limits

  • Random sampleEveryone has an equal chance of selection.
  • Large populationNo finite-population correction is applied.
  • A proportionFor percentages, not averages of measurements.
  • Not biasA bigger sample cannot fix a biased question or list.

Sample size and margin of error are two sides of the same survey question.

Once you have results, the confidence interval calculator gives the margin of error for a mean or proportion. The z-score calculator explains the critical values behind each confidence level.

Common mistakes

  • Mistake: Entering the margin as 0.05.

    Instead: Enter percentage points: 5 for ±5%.

  • Mistake: Rounding the answer down.

    Instead: Always round up, or the margin is wider than asked.

  • Mistake: Ignoring non-responses.

    Instead: Invite more people so enough complete the survey.

Checking the method

Every golden case is re-worked with Python's NormalDist, and OpenStax Example 8.14 is reproduced.

An independent script finds z with a different algorithm (Wichura’s AS241) and checks each size and the published answer of 752.

Read how we test our calculators, or browse more maths calculators.

Frequently asked questions

What sample size do I need for 95% confidence and a 5% margin?

385 completed responses, assuming p = 50% and a large population.

What is the sample size formula?

n = z² p (1 − p) ÷ E², rounded up. At 95%, z = 1.959964.

Why use 50% for the expected proportion?

p (1 − p) is largest at 50%, so it gives the safest size. At 20% you would need 246 instead of 385.

How does the margin of error change the size?

Halving the margin roughly quadruples the sample: ±3 points at 95% needs 1,068.

Does this match textbook examples?

Yes. OpenStax Introductory Statistics Example 8.14 (90%, ±3 points) gives 752, as this calculator does.

Sources and methodology

The formulas are standard time-value-of-money results. We check every figure against golden values worked out independently, by closed form and by month-by-month simulation; see the methodology.

Written and maintained by Nitin Raturi, a software engineer (about the author). Last reviewed 4 Nov 2026; next review due by . Found an error? Tell us.

Changelog

  • : Initial release.