{
  "id": "sum-of-squares",
  "version": "0cb14887b3a3",
  "status": "published",
  "name": "Sum of Squares Calculator",
  "question": "What is the sum of squares?",
  "summary": "Computes the sum of squares of a list of numbers: the sum of squared deviations from the mean, Σ(x − x̄)², and the sum of the squared values, Σx², with the variance.",
  "category": "statistics",
  "subcategory": "descriptive",
  "url": "https://www.acalculator.org/statistics/sum-of-squares-calculator",
  "markdown": "https://www.acalculator.org/statistics/sum-of-squares-calculator.md",
  "kind": "function",
  "method": "x̄ = Σx ÷ n; SS = Σ(x − x̄)² = Σx² − (Σx)² ÷ n; s² = SS ÷ (n − 1); σ² = SS ÷ n.",
  "assumptions": [
    "The numbers are exact decimals as typed; sums and the mean are exact, rounded once for display.",
    "The sample variance needs at least 2 numbers."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "data": {
        "title": "Your numbers",
        "description": "The numbers, separated by commas, spaces, semicolons, or new lines.",
        "type": "array",
        "items": {
          "type": "number"
        }
      }
    }
  },
  "outputs": {
    "ss": {
      "label": "Sum of squares (SS)",
      "description": "The sum of the squared deviations from the mean, Σ(x − x̄)².",
      "format": "number"
    },
    "sumSquares": {
      "label": "Sum of squared values (Σx²)",
      "description": "Each number squared, then added up.",
      "format": "number"
    },
    "sum": {
      "label": "Sum (Σx)",
      "description": "All the numbers added up.",
      "format": "number"
    },
    "mean": {
      "label": "Mean (x̄)",
      "description": "The sum divided by the count.",
      "format": "number"
    },
    "sampleVariance": {
      "label": "Sample variance (s²)",
      "description": "The sum of squares divided by n − 1. It needs at least 2 numbers.",
      "format": "number"
    },
    "populationVariance": {
      "label": "Population variance (σ²)",
      "description": "The sum of squares divided by n.",
      "format": "number"
    },
    "n": {
      "label": "Count (n)",
      "description": "How many numbers are in the list.",
      "format": "integer"
    },
    "steps": {
      "label": "Steps",
      "description": "The working, step by step.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "data": "2, 4, 4, 4, 5, 5, 7, 9"
    },
    "outputs": {
      "ss": 32,
      "sumSquares": 232,
      "sum": 40,
      "mean": 5,
      "sampleVariance": 4.571428571428571,
      "populationVariance": 4,
      "n": 8,
      "steps": "The mean is x̄ = 40 ÷ 8 = 5; Subtract the mean from each number and square it: 9, 1, 1, 1, 0, 0, 4, 16; Add the squares: SS = Σ(x − x̄)² = 32; For comparison, Σx² = 232, and Σx² − (Σx)² ÷ n = 232 − 1600 ÷ 8 = 32"
    },
    "text": "The sum of squares of the 8 numbers is 32, around a mean of 5."
  },
  "examples": [
    {
      "given": {
        "data": [
          2,
          4,
          4,
          4,
          5,
          5,
          7,
          9
        ]
      },
      "expect": {
        "ss": 32,
        "sumSquares": 232,
        "sum": 40,
        "mean": 5,
        "sampleVariance": 4.571428571428571,
        "populationVariance": 4,
        "n": 8
      },
      "source": "hand calculation in content.mdx: x̄ = 40 ÷ 8 = 5; squared deviations 9, 1, 1, 1, 0, 0, 4, 16 add to 32; Σx² = 232 = 32 + 40² ÷ 8; OpenStax, Introductory Statistics 2e, §2.7 Measures of the Spread of the Data (deviation x − x̄; sample variance s² = Σ(x − x̄)² ÷ (n − 1)), https://openstax.org/books/introductory-statistics-2e/pages/2-7-measures-of-the-spread-of-the-data (retrieved 2026-10-05); Python 3: statistics.pvariance × 8"
    },
    {
      "given": {
        "data": [
          0.1,
          0.2,
          0.3
        ]
      },
      "expect": {
        "ss": 0.02,
        "sumSquares": 0.14,
        "mean": 0.2,
        "sampleVariance": 0.01
      },
      "source": "hand calculation in content.mdx: x̄ = 0.2; (−0.1)² + 0² + 0.1² = 0.02; Σx² = 0.01 + 0.04 + 0.09 = 0.14; OpenStax, Introductory Statistics 2e, §2.7 Measures of the Spread of the Data (deviation x − x̄; sample variance s² = Σ(x − x̄)² ÷ (n − 1)), https://openstax.org/books/introductory-statistics-2e/pages/2-7-measures-of-the-spread-of-the-data (retrieved 2026-10-05); Python 3: fractions.Fraction"
    },
    {
      "given": {
        "data": [
          -3,
          5
        ]
      },
      "expect": {
        "ss": 32,
        "sumSquares": 34,
        "mean": 1,
        "sampleVariance": 32,
        "populationVariance": 16
      },
      "source": "hand calculation in content.mdx: x̄ = 1; (−4)² + 4² = 32; 9 + 25 = 34; OpenStax, Introductory Statistics 2e, §2.7 Measures of the Spread of the Data (deviation x − x̄; sample variance s² = Σ(x − x̄)² ÷ (n − 1)), https://openstax.org/books/introductory-statistics-2e/pages/2-7-measures-of-the-spread-of-the-data (retrieved 2026-10-05)"
    }
  ],
  "sources": [
    "OpenStax, Introductory Statistics 2e, §2.7 Measures of the Spread of the Data: deviation x − x̄, sample variance s² = Σ(x − x̄)² ÷ (n − 1) and population variance σ² = Σ(x − μ)² ÷ N. https://openstax.org/books/introductory-statistics-2e/pages/2-7-measures-of-the-spread-of-the-data (retrieved 2026-10-05)"
  ],
  "related": [
    "variance",
    "standard-deviation",
    "mean-absolute-deviation"
  ],
  "changelog": []
}
