{
  "id": "margin-of-error",
  "version": "db2cab927d5c",
  "status": "published",
  "name": "Margin of Error Calculator",
  "question": "What is my margin of error?",
  "summary": "Computes the margin of error of a survey percentage, z × √(p(1 − p) ÷ n), or of a mean, z × σ ÷ √n or t × s ÷ √n, at any confidence level.",
  "category": "statistics",
  "subcategory": "tests",
  "url": "https://www.acalculator.org/statistics/margin-of-error-calculator",
  "markdown": "https://www.acalculator.org/statistics/margin-of-error-calculator.md",
  "kind": "function",
  "method": "Percentage: z × √(p̂(1 − p̂) ÷ n); mean: z × σ ÷ √n, or t(n − 1) × s ÷ √n.",
  "assumptions": [
    "A simple random sample from a population much larger than the sample (no finite-population correction).",
    "The percentage margin uses the normal approximation, which needs enough successes and failures (n p̂ and n(1 − p̂) of 10 or more is a common rule); it gives 0 at 0% and 100%.",
    "The margin covers random sampling error only, not bias from who answered or how the question was asked."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "type": {
        "title": "Margin of error for a",
        "description": "A percentage (a proportion, as in a poll) or a mean.",
        "type": "string",
        "enum": [
          "proportion",
          "mean"
        ]
      },
      "p": {
        "title": "Sample percentage (p̂)",
        "description": "The share of the sample with the answer, as a percent. Use 50% when you do not know it yet; it gives the largest margin.",
        "type": "number",
        "x-unit": "percent",
        "minimum": 0,
        "maximum": 100
      },
      "sd": {
        "title": "Standard deviation",
        "description": "The population σ when it is known, or the sample standard deviation s.",
        "type": "number",
        "minimum": 0,
        "maximum": 1e+300
      },
      "sigma": {
        "title": "Standard deviation is",
        "description": "Known σ uses the normal z value; from the sample uses Student’s t with n − 1 degrees of freedom.",
        "type": "string",
        "enum": [
          "known",
          "sample"
        ]
      },
      "n": {
        "title": "Sample size (n)",
        "description": "How many people or items are in the sample.",
        "type": "integer",
        "minimum": 2,
        "maximum": 1000000000000
      },
      "cl": {
        "title": "Confidence level",
        "description": "How sure you want to be that the interval holds the true value; 95% is common.",
        "type": "number",
        "x-unit": "percent",
        "minimum": 50,
        "maximum": 99.9999
      }
    }
  },
  "outputs": {
    "margin": {
      "label": "Margin of error (±)",
      "description": "Critical value × standard error: in percentage points for a percentage, in the data’s units for a mean.",
      "format": "number"
    },
    "text": {
      "label": "In words",
      "description": "The margin of error with its unit, to 6 significant digits.",
      "format": "text"
    },
    "se": {
      "label": "Standard error",
      "description": "√(p(1 − p) ÷ n) in percentage points, or σ ÷ √n (s ÷ √n).",
      "format": "number"
    },
    "critical": {
      "label": "Critical value",
      "description": "z (or t with n − 1 degrees of freedom) with an upper-tail area of (1 − confidence) ÷ 2.",
      "format": "number"
    },
    "lower": {
      "label": "Interval low",
      "description": "p̂ − margin, in percent (for a percentage).",
      "format": "percent"
    },
    "upper": {
      "label": "Interval high",
      "description": "p̂ + margin, in percent (for a percentage).",
      "format": "percent"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "type": "proportion",
      "p": 50,
      "sd": 15,
      "sigma": "known",
      "n": 1000,
      "cl": 95
    },
    "outputs": {
      "margin": 3.098975161522808,
      "text": "±3.09898 percentage points",
      "se": 1.5811388300841895,
      "critical": 1.9599639845400543,
      "lower": 46.90102483847719,
      "upper": 53.09897516152281
    },
    "text": "The margin of error is ±3.09898 percentage points at 95% confidence."
  },
  "examples": [
    {
      "given": {
        "type": "proportion",
        "p": 50,
        "n": 1000,
        "cl": 95
      },
      "expect": {
        "margin": 3.0989751615228065,
        "se": 1.5811388300841895,
        "critical": 1.9599639845400534
      },
      "source": "hand calculation in content.mdx: 1.959964 × √(0.25 ÷ 1000); NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.4.1 Confidence intervals (the normal approximation p̂ ± z₁₋α/₂ √(p̂(1 − p̂) ÷ n)), https://www.itl.nist.gov/div898/handbook/prc/section2/prc241.htm (retrieved 2026-10-02); Python 3: statistics.NormalDist().inv_cdf(0.975)"
    },
    {
      "given": {
        "type": "proportion",
        "p": 84.2,
        "n": 500,
        "cl": 95
      },
      "expect": {
        "margin": 3.19703711479821
      },
      "source": "OpenStax, Introductory Statistics 2e, §8.3 A Population Proportion, Example 8.10 (n = 500, p′ = 0.842, 95%: EBP = 0.032), https://openstax.org/books/introductory-statistics-2e/pages/8-3-a-population-proportion (retrieved 2026-10-02) (EBP rounded to 0.032, so tolerance 2e-2)",
      "tolerance": 0.02
    },
    {
      "given": {
        "type": "mean",
        "sigma": "known",
        "sd": 3,
        "n": 36,
        "cl": 90
      },
      "expect": {
        "margin": 0.8224268134757358,
        "se": 0.5
      },
      "source": "OpenStax, Introductory Statistics 2e, §8.1 A Single Population Mean using the Normal Distribution, Example 8.2 (σ = 3, n = 36, 90%: EBM = 1.645 × 0.5 = 0.8225), https://openstax.org/books/introductory-statistics-2e/pages/8-1-a-single-population-mean-using-the-normal-distribution (retrieved 2026-10-02) (the book rounds z to 1.645; the exact z gives 0.822427); Python 3: NormalDist().inv_cdf(0.95) × 0.5"
    },
    {
      "given": {
        "type": "mean",
        "sigma": "sample",
        "sd": 10,
        "n": 25,
        "cl": 95
      },
      "expect": {
        "margin": 4.12779712325605,
        "critical": 2.063898561628025
      },
      "source": "hand calculation in content.mdx: t₀.₀₂₅,₂₄ = 2.0639, s ÷ √n = 2; NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.2 Confidence Limits for the Mean (Ȳ ± t₁₋α/₂,N−1 s ÷ √N), https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm (retrieved 2026-10-02); Python 3: t quantile by bisection on the incomplete beta"
    }
  ],
  "sources": [
    "NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.4.1 Confidence intervals (the normal approximation for a proportion, p̂ ± z₁₋α/₂ √(p̂(1 − p̂) ÷ n)). https://www.itl.nist.gov/div898/handbook/prc/section2/prc241.htm (retrieved 2026-10-02)",
    "NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.2 Confidence Limits for the Mean (Ȳ ± t s ÷ √N with N − 1 degrees of freedom). https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm (retrieved 2026-10-02)",
    "OpenStax, Introductory Statistics 2e, §8.3 A Population Proportion (Example 8.10: n = 500, p′ = 0.842, 95% confidence, EBP = 0.032). https://openstax.org/books/introductory-statistics-2e/pages/8-3-a-population-proportion (retrieved 2026-10-02)",
    "OpenStax, Introductory Statistics 2e, §8.1 A Single Population Mean using the Normal Distribution (Example 8.2: σ = 3, n = 36, 90% confidence, EBM = 0.8225). https://openstax.org/books/introductory-statistics-2e/pages/8-1-a-single-population-mean-using-the-normal-distribution (retrieved 2026-10-02)"
  ],
  "related": [
    "sample-size",
    "standard-error",
    "z-score"
  ],
  "changelog": []
}
