Statistics

Sample Size Calculator for Surveys, t-Tests, Proportions and Correlations

Work out how many people, plants, patients or samples your study needs before you collect a single data point. Pick your design, enter a few numbers and get a sample size you can justify in your proposal.

100% freeNo sign-upRuns in your browser
Sample Size Calculator🔒 Your data never leaves your device

How to use the sample size calculator

  1. Choose the tab that matches your design: a survey, two groups (independent t-test), a paired / one-sample design, two proportions or a correlation.
  2. Set the confidence level (usually 95%) and, for tests, the power (usually 80% or 90%).
  3. Enter the expected effect: a margin of error for surveys, Cohen’s d for means, two percentages for proportions, or r for correlations. Take these from a pilot study or similar published papers.
  4. Add the dropout or non-response you expect. The tool inflates the sample so you still have enough complete data at the end.
  5. Click Calculate and copy the ready-made sentence into the methods section of your proposal or thesis.

Why sample size matters

A study that is too small can miss a real effect, and a reviewer will ask why you didn’t calculate power first. A study that is too big wastes money, time and, in medical or animal work, raises ethical questions. A clear sample size calculation shows your supervisor and funders that you planned properly. It is one of the first things examiners look for in a PhD research proposal.

The formulas behind the calculator

Survey sample size (Cochran’s formula)

n₀ = z² × p × (1 − p) / e² n = n₀ / (1 + (n₀ − 1) / N) ← finite population correction

Here z is 1.96 for 95% confidence, p is the expected proportion and e is the margin of error. With p = 50% and e = 5%, you need 385 people for a large population, the number you see in many theses.

Two independent groups (t-test)

n per group = 2 (z₁₋α/₂ + z₁₋β)² / d² + z₁₋α/₂² / 4

The last term is a small correction that brings the normal-based formula very close to the exact t-test answer from G*Power. For d = 0.5, α = .05 and 80% power, it gives 64 per group, the same as G*Power.

Two proportions, paired designs and correlations

For two proportions we use the classic formula with a pooled variance under the null hypothesis. For paired data we use the effect size of the differences (dz). For correlations we use Fisher’s z transformation. All three are standard textbook formulas, so a reviewer can check them easily.

Where do I get the effect size? Use, in this order: (1) your own pilot data, (2) a meta-analysis or similar published study, (3) the smallest effect that would matter in practice. Only use Cohen’s “medium = 0.5” when you truly have nothing else, and say so. You can compute an effect size from published means with our effect size calculator.
Learn the statistics behind these numbers. Codanics has free statistics, R and Python lessons on YouTube and full courses for researchers.

Frequently asked questions

What sample size do I need for a survey?

For a large population, 95% confidence, a ±5% margin of error and an expected proportion of 50%, you need 385 responses. If your population is small (for example 500 students), the finite population correction lowers this to about 218. Then add extra for people who will not respond.

What is a good power for a study?

80% power is the common minimum, which means a 20% chance of missing a real effect. Many funders and clinical trials now ask for 90%. Higher power needs a larger sample.

Is this the same as G*Power?

For t-tests the results match G*Power to within one participant because we add a small correction to the normal-based formula. For proportions and correlations we use the standard normal approximations, which can differ from exact methods by one or two participants.

Why should I use 50% as the expected proportion?

Because p × (1 − p) is largest at 50%, so it gives the most conservative (largest) sample size. If earlier studies show the true proportion is around 20%, you can use that and you will need fewer people.

How do I adjust for dropout?

Divide the required sample by (1 − dropout rate). If you need 100 participants and expect 20% dropout, recruit 100 / 0.8 = 125. The calculator does this for you when you enter a dropout percentage.

Does my data leave my computer?

No. All calculations run in your web browser with JavaScript. Nothing is sent to Codanics or anyone else.

More free tools

See all Codanics tools →

Made by Dr. Muhammad Aammar Tufail, Codanics. Found a bug or have an idea for a new tool? Tell us on the WhatsApp channel or in the YouTube comments. Results are for learning and planning; check important analyses with a statistician or your supervisor.