{
  "id": "hypothesis-test",
  "version": "50972ea1c8c0",
  "status": "published",
  "name": "Hypothesis Test Calculator",
  "question": "Hypothesis testing: do I reject H₀?",
  "summary": "Runs a z or t hypothesis test for one mean, two means, one proportion or two proportions from summary numbers, and compares the p-value with your significance level to reject or keep H₀.",
  "category": "statistics",
  "subcategory": "tests",
  "url": "https://www.acalculator.org/statistics/hypothesis-test-calculator",
  "markdown": "https://www.acalculator.org/statistics/hypothesis-test-calculator.md",
  "kind": "function",
  "method": "Compute z or t as on the test statistic page; p-value by the tail of H₁; critical value z or t at α (two-tailed: α ÷ 2 in each tail); reject H₀ when p < α.",
  "assumptions": [
    "Random, independent samples. t tests assume roughly normal data or large samples; the proportion tests use the normal approximation.",
    "The two-means and two-proportions tests compare the difference with 0.",
    "A p-value equal to α does not reject H₀."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "test": {
        "title": "Test",
        "description": "Which hypothesis test to run.",
        "type": "string",
        "enum": [
          "z",
          "t",
          "two",
          "prop",
          "twoprop"
        ]
      },
      "tail": {
        "title": "Alternative hypothesis H₁",
        "description": "Two-tailed (≠), left-tailed (<) or right-tailed (>).",
        "type": "string",
        "enum": [
          "two",
          "left",
          "right"
        ]
      },
      "alpha": {
        "title": "Significance level (α)",
        "description": "The chance of rejecting a true H₀ that you accept, often 0.05.",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 0.5
      },
      "m1": {
        "title": "Sample mean x̄₁",
        "description": "The mean of the (first) sample.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "mu": {
        "title": "Hypothesized mean μ₀",
        "description": "The population mean under H₀.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "sd1": {
        "title": "Standard deviation",
        "description": "σ for a z test; the sample standard deviation s for a t test.",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 1000000000000
      },
      "n1": {
        "title": "Sample size n₁",
        "description": "How many observations are in the (first) sample.",
        "type": "integer",
        "minimum": 1,
        "maximum": 1000000000
      },
      "m2": {
        "title": "Sample mean x̄₂",
        "description": "The mean of the second sample.",
        "type": "number",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "sd2": {
        "title": "Standard deviation s₂",
        "description": "The standard deviation of the second sample.",
        "type": "number",
        "exclusiveMinimum": 0,
        "maximum": 1000000000000
      },
      "n2": {
        "title": "Sample size n₂",
        "description": "How many observations are in the second sample.",
        "type": "integer",
        "minimum": 1,
        "maximum": 1000000000
      },
      "var": {
        "title": "Variances",
        "description": "Welch’s test for unequal variances, or the pooled test for equal variances.",
        "type": "string",
        "enum": [
          "welch",
          "pooled"
        ]
      },
      "x1": {
        "title": "Successes x₁",
        "description": "How many of the (first) sample have the trait.",
        "type": "integer",
        "minimum": 0,
        "maximum": 1000000000
      },
      "p0": {
        "title": "Hypothesized proportion p₀",
        "description": "The population proportion under H₀, between 0 and 1.",
        "type": "number",
        "exclusiveMinimum": 0,
        "exclusiveMaximum": 1
      },
      "x2": {
        "title": "Successes x₂",
        "description": "How many of the second sample have the trait.",
        "type": "integer",
        "minimum": 0,
        "maximum": 1000000000
      }
    }
  },
  "outputs": {
    "decision": {
      "label": "Decision",
      "description": "Reject H₀ when the p-value is less than α; otherwise do not reject H₀.",
      "format": "text"
    },
    "p": {
      "label": "p-value",
      "description": "The chance of a statistic at least this extreme in the direction of H₁, if H₀ holds.",
      "format": "number"
    },
    "statistic": {
      "label": "Test statistic",
      "description": "The estimate minus the null value, divided by its standard error.",
      "format": "number"
    },
    "critical": {
      "label": "Critical value",
      "description": "The statistic beyond which H₀ is rejected at α, to 4 decimals.",
      "format": "text"
    },
    "kind": {
      "label": "Statistic",
      "description": "z (standard normal) or t (Student’s t).",
      "format": "text"
    },
    "df": {
      "label": "Degrees of freedom",
      "description": "For t: n − 1, n₁ + n₂ − 2 (pooled) or the Welch–Satterthwaite value.",
      "format": "number"
    },
    "se": {
      "label": "Standard error",
      "description": "The standard error of the estimate under H₀.",
      "format": "number"
    },
    "estimate": {
      "label": "Estimate",
      "description": "x̄, x̄₁ − x̄₂, p̂ or p̂₁ − p̂₂.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "test": "t",
      "tail": "two",
      "alpha": 0.05,
      "m1": 53.7,
      "mu": 50,
      "sd1": 6.567,
      "n1": 10,
      "m2": 30.48101,
      "sd2": 6.10771,
      "n2": 79,
      "var": "welch",
      "x1": 26,
      "p0": 0.1,
      "x2": 30
    },
    "outputs": {
      "decision": "Do not reject H₀: the p-value is not less than α = 0.05",
      "p": 0.10848447147266906,
      "statistic": 1.7817005242306996,
      "critical": "±2.2622",
      "kind": "t",
      "df": 9,
      "se": 2.0766677394325748,
      "estimate": 53.7
    },
    "text": "Do not reject H₀: the p-value is not less than α = 0.05. The test statistic is t = 1.7817, with a p-value of 0.1085."
  },
  "examples": [
    {
      "given": {
        "test": "t",
        "tail": "two",
        "alpha": 0.05,
        "m1": 53.7,
        "mu": 50,
        "sd1": 6.567,
        "n1": 10
      },
      "expect": {
        "decision": "Do not reject H₀: the p-value is not less than α = 0.05",
        "statistic": 1.7817005242306996,
        "df": 9,
        "critical": "±2.2622"
      },
      "source": "NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.2 Are the data consistent with the assumed process mean? (t = (Ȳ − μ₀) ÷ (s ÷ √N), N − 1 df; 10 wafers, mean 53.7, s 6.567, μ₀ 50: t = 1.782, below the critical 2.262 at α = 0.05, so H₀ is not rejected), https://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm (retrieved 2026-10-05); OpenStax, Introductory Statistics 2e, §9.4 Rare Events, the Sample, and the Decision and Conclusion (reject H₀ when the p-value is less than α; otherwise do not reject H₀), https://openstax.org/books/introductory-statistics-2e/pages/9-4-rare-events-the-sample-decision-and-conclusion (retrieved 2026-10-05); Python 3: (53.7 − 50) ÷ (6.567 ÷ √10) with 53.7 − 50 as a Fraction",
      "tolerance": 1e-12
    },
    {
      "given": {
        "test": "prop",
        "tail": "right",
        "alpha": 0.05,
        "x1": 26,
        "n1": 200,
        "p0": 0.1
      },
      "expect": {
        "decision": "Do not reject H₀: the p-value is not less than α = 0.05",
        "statistic": 1.414213562373095,
        "p": 0.07864960352514258,
        "critical": "1.6449",
        "estimate": 0.13
      },
      "source": "NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.4 Does the proportion of defectives meet requirements? (z = (p̂ − p₀) ÷ √(p₀(1 − p₀) ÷ N); 26 of 200, p₀ 0.10: z = 1.414, below the critical 1.645 at α = 0.05), https://www.itl.nist.gov/div898/handbook/prc/section2/prc24.htm (retrieved 2026-10-05); OpenStax, Introductory Statistics 2e, §9.4 Rare Events, the Sample, and the Decision and Conclusion (reject H₀ when the p-value is less than α; otherwise do not reject H₀), https://openstax.org/books/introductory-statistics-2e/pages/9-4-rare-events-the-sample-decision-and-conclusion (retrieved 2026-10-05); Python 3: 0.5 × math.erfc(z ÷ √2) with z = 0.03 ÷ √0.00045",
      "tolerance": 1e-12
    },
    {
      "given": {
        "test": "two",
        "tail": "two",
        "alpha": 0.05,
        "var": "pooled",
        "m1": 20.14458,
        "sd1": 6.4147,
        "n1": 249,
        "m2": 30.48101,
        "sd2": 6.10771,
        "n2": 79
      },
      "expect": {
        "decision": "Reject H₀: the p-value is less than α = 0.05",
        "statistic": -12.620585000444757,
        "df": 326,
        "critical": "±1.9673"
      },
      "source": "NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.3 Two-Sample t-Test for Equal Means (pooled T = −12.62059 with 326 df; critical 1.9673 at α = 0.05, so H₀ is rejected), https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm (retrieved 2026-10-05); OpenStax, Introductory Statistics 2e, §9.4 Rare Events, the Sample, and the Decision and Conclusion (reject H₀ when the p-value is less than α; otherwise do not reject H₀), https://openstax.org/books/introductory-statistics-2e/pages/9-4-rare-events-the-sample-decision-and-conclusion (retrieved 2026-10-05)",
      "tolerance": 1e-9
    },
    {
      "given": {
        "test": "z",
        "tail": "left",
        "alpha": 0.05,
        "m1": 97,
        "mu": 100,
        "sd1": 15,
        "n1": 100
      },
      "expect": {
        "decision": "Reject H₀: the p-value is less than α = 0.05",
        "statistic": -2,
        "p": 0.022750131948179216,
        "critical": "−1.6449"
      },
      "source": "OpenStax, Introductory Statistics 2e, §9.4 Rare Events, the Sample, and the Decision and Conclusion (reject H₀ when the p-value is less than α; otherwise do not reject H₀), https://openstax.org/books/introductory-statistics-2e/pages/9-4-rare-events-the-sample-decision-and-conclusion (retrieved 2026-10-05); hand calculation in content.mdx: z = (97 − 100) ÷ (15 ÷ 10) = −2, p = Φ(−2) = 0.02275 < 0.05; Python 3: 0.5 × math.erfc(2 ÷ √2)"
    }
  ],
  "sources": [
    "NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.2 Are the data consistent with the assumed process mean?: t = (Ȳ − μ₀) ÷ (s ÷ √N) with N − 1 df; the wafer example gives t = 1.782 against a critical 2.262. https://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm (retrieved 2026-10-05)",
    "NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.4 Does the proportion of defectives meet requirements?: z = (p̂ − p₀) ÷ √(p₀(1 − p₀) ÷ N); 26 of 200 against p₀ = 0.10 gives z = 1.414. https://www.itl.nist.gov/div898/handbook/prc/section2/prc24.htm (retrieved 2026-10-05)",
    "NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.3 Two-Sample t-Test for Equal Means: pooled and Welch statistics and degrees of freedom; the car mileage example gives T = −12.62 with 326 df. https://www.itl.nist.gov/div898/handbook/eda/section3/eda353.htm (retrieved 2026-10-05)",
    "NIST/SEMATECH e-Handbook of Statistical Methods, §7.3.3 How can we determine whether two processes produce the same proportion of defectives?: z for two proportions with the pooled p̂. https://www.itl.nist.gov/div898/handbook/prc/section3/prc33.htm (retrieved 2026-10-05)",
    "OpenStax, Introductory Statistics 2e, §9.4 Rare Events, the Sample, and the Decision and Conclusion: reject H₀ when the p-value is less than α; otherwise do not reject H₀. https://openstax.org/books/introductory-statistics-2e/pages/9-4-rare-events-the-sample-decision-and-conclusion (retrieved 2026-10-05)"
  ],
  "related": [
    "test-statistic",
    "p-value",
    "critical-value",
    "t-test"
  ],
  "changelog": []
}
