{
  "id": "anova",
  "version": "4b0c346655a3",
  "status": "published",
  "name": "ANOVA Calculator",
  "question": "How do I run a one-way ANOVA?",
  "summary": "Runs a one-way ANOVA on 2 to 6 groups of numbers: the sums of squares, degrees of freedom, mean squares, F statistic, p-value and the critical F at your significance level.",
  "category": "statistics",
  "subcategory": "tests",
  "url": "https://www.acalculator.org/statistics/anova-calculator",
  "markdown": "https://www.acalculator.org/statistics/anova-calculator.md",
  "kind": "function",
  "method": "F = [SST ÷ (k − 1)] ÷ [SSE ÷ (N − k)]; p = P(F(k − 1, N − k) ≥ F).",
  "assumptions": [
    "The groups are independent random samples from normal populations with the same variance.",
    "Empty groups are left out; ANOVA needs at least 2 groups and more values than groups.",
    "The test asks whether all group means are equal; it does not say which ones differ."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "g1": {
        "title": "Group 1",
        "description": "The values of group 1, separated by commas, spaces, semicolons, or new lines.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "g2": {
        "title": "Group 2",
        "description": "The values of group 2, separated by commas, spaces, semicolons, or new lines.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "g3": {
        "title": "Group 3",
        "description": "The values of group 3, if there is one. Leave it empty to use fewer groups.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "g4": {
        "title": "Group 4",
        "description": "The values of group 4, if there is one. Leave it empty to use fewer groups.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "g5": {
        "title": "Group 5",
        "description": "The values of group 5, if there is one. Leave it empty to use fewer groups.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "g6": {
        "title": "Group 6",
        "description": "The values of group 6, if there is one. Leave it empty to use fewer groups.",
        "type": "array",
        "items": {
          "type": "number"
        }
      },
      "alpha": {
        "title": "Significance level (α)",
        "description": "The chance of rejecting equal means when they are equal; 5% is common.",
        "type": "number",
        "x-unit": "percent",
        "minimum": 0.001,
        "maximum": 50
      }
    }
  },
  "outputs": {
    "f": {
      "label": "F statistic",
      "description": "MST ÷ MSE: the variation between group means over the variation within groups.",
      "format": "number"
    },
    "p": {
      "label": "p-value",
      "description": "The chance of an F this large or larger when all group means are equal.",
      "format": "number"
    },
    "decision": {
      "label": "Decision",
      "description": "Whether the p-value is below α: reject or do not reject equal means.",
      "format": "text"
    },
    "critical": {
      "label": "Critical F",
      "description": "The F value with an upper-tail area of α, for k − 1 and N − k degrees of freedom.",
      "format": "number"
    },
    "ssb": {
      "label": "Sum of squares between (SST)",
      "description": "Σ nᵢ (x̄ᵢ − x̄)², the treatment sum of squares.",
      "format": "number"
    },
    "ssw": {
      "label": "Sum of squares within (SSE)",
      "description": "Σ (x − x̄ᵢ)² over every value, the error sum of squares.",
      "format": "number"
    },
    "sst": {
      "label": "Total sum of squares",
      "description": "SST + SSE = Σ (x − x̄)².",
      "format": "number"
    },
    "dfb": {
      "label": "df between",
      "description": "k − 1, for k groups.",
      "format": "integer"
    },
    "dfw": {
      "label": "df within",
      "description": "N − k, for N values in all.",
      "format": "integer"
    },
    "msb": {
      "label": "Mean square between (MST)",
      "description": "SST ÷ (k − 1).",
      "format": "number"
    },
    "msw": {
      "label": "Mean square within (MSE)",
      "description": "SSE ÷ (N − k).",
      "format": "number"
    },
    "means": {
      "label": "Group means",
      "description": "The mean of each group, to 6 significant digits.",
      "format": "text"
    },
    "grand": {
      "label": "Grand mean",
      "description": "The mean of all N values.",
      "format": "number"
    },
    "k": {
      "label": "Groups (k)",
      "description": "How many groups have values.",
      "format": "integer"
    },
    "n": {
      "label": "Values (N)",
      "description": "How many values there are in all.",
      "format": "integer"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "g1": "6.9, 5.4, 5.8, 4.6, 4.0",
      "g2": "8.3, 6.8, 7.8, 9.2, 6.5",
      "g3": "8.0, 10.5, 8.1, 6.9, 9.3",
      "alpha": 5
    },
    "outputs": {
      "f": 9.591107036442805,
      "p": 0.0032482226008593157,
      "decision": "Reject equal means: p < α = 5%",
      "critical": 3.885293834652393,
      "ssb": 27.897333333333307,
      "ssw": 17.451999999999998,
      "sst": 45.349333333333306,
      "dfb": 2,
      "dfw": 12,
      "msb": 13.948666666666654,
      "msw": 1.4543333333333333,
      "means": "Group 1: 5.34; Group 2: 7.72; Group 3: 8.56",
      "grand": 7.206666666666666,
      "k": 3,
      "n": 15
    },
    "text": "F(2, 12) = 9.59111, p = 0.00324822."
  },
  "examples": [
    {
      "given": {
        "g1": [
          6.9,
          5.4,
          5.8,
          4.6,
          4
        ],
        "g2": [
          8.3,
          6.8,
          7.8,
          9.2,
          6.5
        ],
        "g3": [
          8,
          10.5,
          8.1,
          6.9,
          9.3
        ],
        "alpha": 5
      },
      "expect": {
        "f": 9.591107036442809,
        "p": 0.003248222600859304,
        "critical": 3.8852938346523933,
        "ssb": 27.89733333333332,
        "ssw": 17.452,
        "dfb": 2,
        "dfw": 12
      },
      "source": "NIST/SEMATECH e-Handbook of Statistical Methods, §7.4.3.3 The ANOVA table and tests of hypotheses about means (resistor data at three temperatures: SST 27.897, SSE 17.452, df 2 and 12, F = 9.59, p = 0.00325), https://www.itl.nist.gov/div898/handbook/prc/section4/prc433.htm (retrieved 2026-10-02); NIST/SEMATECH e-Handbook of Statistical Methods, §7.4.3.4 One-way ANOVA calculations (SST = Σ Tᵢ² ÷ nᵢ − CM, SSE = SS(Total) − SST, MST = SST ÷ (k − 1), MSE = SSE ÷ (N − k), F = MST ÷ MSE), https://www.itl.nist.gov/div898/handbook/prc/section4/prc434.htm (retrieved 2026-10-02); Python 3: two-pass sums of squares, incomplete beta for p (docs/progress/WP-94/xcheck.py)",
      "tolerance": 1e-9
    },
    {
      "given": {
        "g1": [
          6.9,
          5.4,
          5.8,
          4.6,
          4
        ],
        "g2": [
          8.3,
          6.8,
          7.8,
          9.2,
          6.5
        ],
        "g3": [
          8,
          10.5,
          8.1,
          6.9,
          9.3
        ],
        "alpha": 5
      },
      "expect": {
        "f": 9.59,
        "p": 0.00325,
        "critical": 3.89
      },
      "source": "NIST/SEMATECH e-Handbook of Statistical Methods, §7.4.3.3 The ANOVA table and tests of hypotheses about means (resistor data at three temperatures: SST 27.897, SSE 17.452, df 2 and 12, F = 9.59, p = 0.00325), https://www.itl.nist.gov/div898/handbook/prc/section4/prc433.htm (retrieved 2026-10-02) (rounded to 3 significant digits, so tolerance 2e-3)",
      "tolerance": 0.002
    },
    {
      "given": {
        "g1": [
          1,
          2,
          3
        ],
        "g2": [
          4,
          5,
          6
        ],
        "alpha": 5
      },
      "expect": {
        "f": 13.5,
        "p": 0.021311641128756734,
        "ssb": 13.5,
        "ssw": 4,
        "msw": 1,
        "dfb": 1,
        "dfw": 4,
        "means": "Group 1: 2; Group 2: 5",
        "grand": 3.5
      },
      "source": "hand calculation in content.mdx: means 2 and 5, grand mean 3.5, SST = 3 × 1.5² × 2 = 13.5, SSE = 2 + 2 = 4; NIST/SEMATECH e-Handbook of Statistical Methods, §7.4.3.4 One-way ANOVA calculations (SST = Σ Tᵢ² ÷ nᵢ − CM, SSE = SS(Total) − SST, MST = SST ÷ (k − 1), MSE = SSE ÷ (N − k), F = MST ÷ MSE), https://www.itl.nist.gov/div898/handbook/prc/section4/prc434.htm (retrieved 2026-10-02); Python 3: p from the incomplete beta (docs/progress/WP-94/xcheck.py)"
    }
  ],
  "sources": [
    "NIST/SEMATECH e-Handbook of Statistical Methods, §7.4.3.3 The ANOVA table and tests of hypotheses about means (the resistor example: SST = 27.897, SSE = 17.452, df 2 and 12, F = 9.59, F₀.₀₅; ₂, ₁₂ = 3.89, p = 0.00325). https://www.itl.nist.gov/div898/handbook/prc/section4/prc433.htm (retrieved 2026-10-02)",
    "NIST/SEMATECH e-Handbook of Statistical Methods, §7.4.3.4 One-way ANOVA calculations (CM, SS(Total), SST, SSE, MST, MSE and F). https://www.itl.nist.gov/div898/handbook/prc/section4/prc434.htm (retrieved 2026-10-02)"
  ],
  "related": [
    "t-test",
    "p-value",
    "degrees-of-freedom"
  ],
  "changelog": []
}
