Sample size calculation starts from the end: how close must the estimate be, and how confident must you be? Those two choices, the margin of error and the confidence level, plus an expectation of variability, determine n. For a proportion the formula is z squared times p times (1 minus p), divided by the margin squared. With 95 percent confidence, the cautious p of 0.5, and a 5-point margin, the answer is 385, a number printed in every research methods book because it is the default survey of the English-speaking world. Tighten the margin to 3 points and the requirement jumps past 1,000. Precision is bought at a steepening price, because the margin sits squared in the denominator. Run the same formula in reverse and it audits other people’s polls: given the sample size they used, it tells you the margin their survey actually achieved.
For estimating a mean, the expected standard deviation takes the role of p. Measuring something wildly variable, like household incomes, demands far more data than measuring something steady, like adult heights, for the same precision. A small pilot study often exists just to estimate this variability before the real sample size is set. Guessing too low on variability is the classic planning error: the study finishes, the interval comes out wider than promised, and the conclusion dissolves into maybe. Conservative inputs cost money; optimistic inputs cost the whole study. The same logic governs experiments through power calculations, where the variability and the smallest effect worth detecting together decide how many subjects a trial must recruit before it begins.
The formula's answer is a minimum, so it is always rounded up, never down. Real life then adds corrections: expected non-response means inviting more people than the target n, and sampling a large share of a small population earns a finite population correction that reduces the requirement. Subgroups matter too: if results must be reported separately for four regions, each region needs its own adequate sample, quietly quadrupling the budget. The calculator below handles the core formula for proportions and means; treat its answer as the floor, then plan for the messiness of actual humans. A sample that is large but badly drawn is worse than a smaller honest one, because size cannot repair a broken sampling method.