# Sample Size Calculator (Survey & A/B Test)

> Sample Size Calculator (Survey & A/B Test) is a paid API for AI agents from math-stats.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-29).

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).

## Facts

- Endpoint: GET https://math-stats.x402tookit.com/sample-size?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-29
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/sample-size-calculator-survey-a-b-test-e1ea39e0
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_2EGqVAR3FAV5kXGx1XOAO

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability sample-size-calculator-survey-a-b-test-e1ea39e0
```

Example prompt: 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?

## When to prefer this

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.

## Known failure modes

- 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

## How this service works

Required sample size for a survey (margin of error, optional finite population) or an A/B test (baseline, lift, power).

## Output

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.

## Request schema (JSON Schema)

```json
{
 "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":
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/sample-size-calculator-survey-a-b-test-e1ea39e0/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from math-stats.x402tookit.com](https://www.zero.xyz/host/math-stats.x402tookit.com/llms.txt)
