{"success":true,"version":"v1","request":{"tool":"get_calculator_schema","calculator_id":"sample-size"},"result":{"entity_type":"calculator","id":"sample-size","calculator_id":"sample-size","canonical_url":"https://tttkmbb.com/statistics/sample-size","name":"Sample Size Calculator","title":"Sample Size Calculator for Surveys – Required n for a Margin of Error and Confidence Level","category":"statistics","category_name":"Statistics & Probability","tool_name":"calculate_sample_size","featured_mcp_tool":false,"description":"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.","use_when":"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)).","inputs":[{"name":"confidence_level_percent","label":"Confidence level","type":"number","unit":"%","required":false,"default":95,"exclusive_min":0,"exclusive_max":100,"description":"Confidence level in percent (commonly 90, 95 or 99). Determines the critical z value.","example":95},{"name":"margin_of_error_percent","label":"Margin of error","type":"number","unit":"%","required":true,"max":50,"exclusive_min":0,"description":"Acceptable half-width of the confidence interval, in percentage points (5 means ±5 %).","example":5},{"name":"expected_proportion_percent","label":"Expected proportion","type":"number","unit":"%","required":false,"default":50,"min":1,"max":99,"description":"Anticipated percentage with the attribute. 50 % is the conservative choice giving the largest sample.","example":50},{"name":"population_size","label":"Population size","type":"integer","required":false,"min":2,"description":"Optional total population size N. When given, the finite population correction is applied; omit for large or unknown populations.","example":1000}],"outputs":[{"name":"z_value","label":"Critical z","type":"number","decimals":4,"description":"Two-sided normal critical value for the confidence level."},{"name":"sample_size","label":"Required sample size","type":"integer","decimals":4,"description":"Minimum number of respondents, rounded up; includes the finite population correction when population_size is given."},{"name":"sample_size_infinite_population","label":"Sample size (infinite population)","type":"integer","decimals":4,"description":"n0 = z² p (1 − p) / e², rounded up, before any finite population correction."}],"input_schema":{"type":"object","properties":{"confidence_level_percent":{"description":"Confidence level in percent (commonly 90, 95 or 99). Determines the critical z value. Unit: %.","type":"number","exclusiveMinimum":0,"exclusiveMaximum":100,"default":95,"examples":[95],"x-unit":"%"},"margin_of_error_percent":{"description":"Acceptable half-width of the confidence interval, in percentage points (5 means ±5 %). Unit: %.","type":"number","maximum":50,"exclusiveMinimum":0,"examples":[5],"x-unit":"%"},"expected_proportion_percent":{"description":"Anticipated percentage with the attribute. 50 % is the conservative choice giving the largest sample. Unit: %.","type":"number","minimum":1,"maximum":99,"default":50,"examples":[50],"x-unit":"%"},"population_size":{"description":"Optional total population size N. When given, the finite population correction is applied; omit for large or unknown populations.","type":"integer","minimum":2,"examples":[1000]}},"additionalProperties":false,"required":["margin_of_error_percent"]},"output_schema":{"type":"object","properties":{"z_value":{"description":"Two-sided normal critical value for the confidence level.","type":"number"},"sample_size":{"description":"Minimum number of respondents, rounded up; includes the finite population correction when population_size is given.","type":"integer"},"sample_size_infinite_population":{"description":"n0 = z² p (1 − p) / e², rounded up, before any finite population correction.","type":"integer"}}},"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","method":"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.","sources":[{"name":"NIST/SEMATECH e-Handbook of Statistical Methods, 7.2.4.2 Sample sizes required (proportions)","url":"https://www.itl.nist.gov/div898/handbook/prc/section2/prc242.htm","type":"government","retrieved_at":"2026-09-23"},{"name":"Wikipedia – Sample size determination","url":"https://en.wikipedia.org/wiki/Sample_size_determination","type":"reference","retrieved_at":"2026-09-23"}],"freshness":{"type":"static","max_age_seconds":null,"note":"Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output."},"examples":[{"name":"95 %, ±5 %, p = 50 %","inputs":{"confidence_level_percent":95,"margin_of_error_percent":5,"expected_proportion_percent":50},"expected":{"z_value":1.96,"sample_size":385,"sample_size_infinite_population":385},"url":"https://tttkmbb.com/api/v1/calculate/sample-size?confidence_level_percent=95&margin_of_error_percent=5&expected_proportion_percent=50"},{"name":"Same, population of 1,000","inputs":{"confidence_level_percent":95,"margin_of_error_percent":5,"expected_proportion_percent":50,"population_size":1000},"expected":{"sample_size":278,"sample_size_infinite_population":385},"url":"https://tttkmbb.com/api/v1/calculate/sample-size?confidence_level_percent=95&margin_of_error_percent=5&expected_proportion_percent=50&population_size=1000"}],"faq":[{"q":"Why is 385 the usual answer?","a":"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."},{"q":"Does the sample size depend on the population size?","a":"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."},{"q":"What about non-response?","a":"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)."}],"tags":["sample size","survey sample size","how many respondents","cochran formula","finite population correction"],"related":[{"calculator_id":"margin-of-error","reason":"Margin of error of a sample you already have."},{"calculator_id":"confidence-interval","reason":"Interval for a mean from a sample."}],"links":{"html":"https://tttkmbb.com/statistics/sample-size","markdown":"https://tttkmbb.com/statistics/sample-size.md","json":"https://tttkmbb.com/statistics/sample-size.json","api":"https://tttkmbb.com/api/v1/calculate/sample-size","schema":"https://tttkmbb.com/api/v1/calculators/sample-size","openapi":"https://tttkmbb.com/openapi.json","mcp":"https://tttkmbb.com/mcp"},"version":"v1","updated_at":"2026-09-23"},"timestamp":"2026-09-23T23:23:13Z"}