{"uid":"cap_2EGqVAR3FAV5kXGx1XOAO","slug":"sample-size-calculator-survey-a-b-test-e1ea39e0","name":"Sample Size Calculator (Survey & A/B Test)","description":"Required sample size for a survey (margin of error, optional finite population) or an A/B test (baseline, lift, power).","url":"https://math-stats.x402tookit.com/sample-size?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["mode"],"properties":{"mode":{"type":"string","description":"survey or ab"},"power":{"type":"number","description":"A/B power 0.5 to 0.99 (default 0.8)"},"margin":{"type":"number","description":"Survey margin of error as a fraction, e.g. 0.05"},"target":{"type":"number","description":"A/B rate you want to detect, e.g. 0.12"},"baseline":{"type":"number","description":"A/B baseline conversion rate, e.g. 0.10"},"confidence":{"type":"number","description":"0.80 to 0.999 (default 0.95)"},"population":{"type":"number","description":"Survey population size (optional, for finite correction)"},"proportion":{"type":"number","description":"Expected proportion for a survey (default 0.5)"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"z":{"type":["null","number"]},"asOf":{"type":["null","string"]},"margin":{"type":["null","number"]},"source":{"type":["null","string"]},"reasons":{"type":["array","null"],"items":{"type":"string"}},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"degraded":{"type":["boolean","null"]},"required":{"type":["null","number"]},"confidence":{"type":["null","number"]},"disclaimer":{"type":["null","string"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}},"proportion":{"type":["null","number"]},"finitePopulationApplied":{"type":["boolean","null"]},"unroundedInfinitePopulation":{"type":["null","number"]}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_Y4_lEpxkCVWjE0_KS3nvH","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Calculates the required sample size for a survey (given margin of error) or an A/B test (given baseline conversion rate, target lift, and statistical power).","exampleAgentPrompt":"How many people do I need to survey to get a 5% margin of error at 95% confidence, assuming a 50/50 split, from a population of 20,000?","exampleUseCases":[{"title":"Survey sample size for product feedback poll","prompt":"I'm running a customer satisfaction survey and want a 3% margin of error at 95% confidence. My customer base is about 50,000 people — how many do I need to survey?"},{"title":"A/B test sizing for checkout flow experiment","prompt":"We're planning an A/B test on our checkout page. Our current conversion rate is 8% and we want to detect a lift to 10%. How many users per variant do we need at 95% confidence and 80% power?"},{"title":"High-confidence political poll planning","prompt":"I need to design a political poll with a 2% margin of error and 99% confidence, expecting about 50% support for the candidate. What sample size do I need?"}],"resultDescription":"Returns the required sample size as an integer, along with the z-score used, the effective confidence level, proportion assumption, whether finite population correction was applied, the unrounded infinite-population figure, a plain-English summary, and a disclaimer. For A/B tests, returns the per-variant sample size needed to achieve the requested power and confidence.","failureModes":["Missing required 'mode' parameter returns an error","Invalid mode value (not 'survey' or 'ab') returns a validation error","For survey mode: missing 'margin' parameter causes failure","For ab mode: missing 'baseline' or 'target' parameters causes failure","Out-of-range confidence (outside 0.80–0.999) returns a validation error","Out-of-range power (outside 0.50–0.99) returns a validation error","Baseline and target rates equal (zero lift) may return an error or infinity","Non-positive population size returns a validation error"],"whenToPreferThis":"Use this endpoint when you need to plan a data collection effort — either a survey or a controlled experiment — and want to know how many observations are required before collecting data. It is the right choice when the user is in the design phase, not the analysis phase (for post-collection analysis, use the t-test or A/B test endpoints on this same host). Prefer this over general statistical libraries when you need a fast, no-code, API-accessible answer with finite-population correction support.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-29T13:11:21.245Z","isFirstParty":false,"canonicalSlug":"sample-size-calculator-survey-a-b-test-e1ea39e0"}