Planning instead of hoping

Sample size calculation happens before data collection, and its purpose is narrow: to decide how many observations are needed so that, if an effect of a given size really exists, the study has a decent chance of detecting it. Two quantities drive the answer — the effect size you want to detect, and the error rates you tolerate. Smaller effects need more data, and the relationship is quadratic: halving the effect roughly quadruples the sample. α is the false-positive risk you accept, and power (1 − β) is the chance of finding a genuinely present effect, with 0.80 the customary floor. The means mode returns participants per group; the proportion mode returns a total.

The two calculations

Two means solves the two-sample t-test exactly. The normal approximation 2 (z₁₋α/tails + z_power)² / d² is only the starting estimate — it is optimistic, because it ignores the fact that the critical value comes from the t distribution and that the t distribution's degrees of freedom depend on n. The tool therefore evaluates the actual power of the test at each candidate n, using the noncentral t distribution, and returns the smallest group size whose achieved power reaches the target. The α term of the starting estimate is 1.960 for α = 0.05 two-sided, 2.576 for α = 0.01 two-sided or 1.645 for α = 0.05 one-sided; the power term is 0.842 for 80%, 1.282 for 90% and 1.645 for 95%. The critical t value actually used, with its df, and the power achieved at the returned n are both printed.

One proportion uses a different formula for the margin of error around an estimated percentage: n = z² p (1 − p) / e², with z = 1.960 at 95% confidence and 2.576 at 99%. Because p(1 − p) peaks at p = 0.50, an expected proportion of 50% gives the largest, safest sample.

Worked values from this calculator

With α = 0.05 two-sided and 80% power, an expected d of 0.20 needs 394 per group (788 in total); d = 0.50 needs 64 per group (128 total); d = 0.80 needs 26 per group (52 total); and d = 1.00 needs 17 per group. The error rates move the medium-effect case substantially: d = 0.50 at 80% power needs 64 per group, but a one-sided α = 0.05 needs 51, α = 0.01 two-sided needs 96, and 90% power needs 86. The proportion mode at 95% confidence gives 385 respondents for an expected 50% at ±5%, and 1068 at ±3%.

These are the figures R's power.t.test and G*Power return for the same specifications, which is the check worth making: sample-size tools that stop at the normal approximation are typically one to three participants light, and at α = 0.01 the gap is wide enough to matter.

Caveats before you commit to a number

Practical questions

Which d should I enter?

The smallest effect that would matter, not the largest you hope for: if prior work suggests 0.50 but the smallest meaningful difference is 0.35, plan for 0.35.

My field says "at least 30 per group". Is that enough?

They ignore the effect size, the main thing determining whether a study can detect anything; a fixed number works only if the effect is large.

Why does the proportion mode give one number rather than per-group figures?

Because there is only one group — the formula sizes a single survey estimate.

Can I use this to decide whether a result I already have is significant?

No — planning answers a question about the future. If the data are collected, run the appropriate analysis and report the effect size with its interval.