{
  "id": "variance",
  "version": "f4b6a4742679",
  "status": "published",
  "name": "Variance Calculator",
  "question": "What is the variance of my data?",
  "summary": "Computes the sample and population variance and standard deviation of a list of numbers, with the mean and the sum of squares.",
  "category": "statistics",
  "subcategory": "descriptive",
  "url": "https://www.acalculator.org/statistics/variance-calculator",
  "markdown": "https://www.acalculator.org/statistics/variance-calculator.md",
  "kind": "function",
  "method": "s² = Σ(x − mean)² ÷ (n − 1); σ² = Σ(x − mean)² ÷ n; each standard deviation is the square root of its variance.",
  "assumptions": [
    "Sample variance uses Bessel’s correction (divides by n − 1). Use it when the numbers are a sample from a larger group.",
    "Population variance divides by n. Use it when the numbers are the whole group.",
    "The list needs at least 2 numbers, because the sample variance of one number is not defined."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "input": {
        "title": "Your numbers",
        "description": "The numbers, separated by commas, spaces, semicolons, or new lines. At least 2.",
        "type": "array",
        "items": {
          "type": "number"
        }
      }
    }
  },
  "outputs": {
    "sampleVariance": {
      "label": "Sample variance (s²)",
      "description": "The sum of squared differences from the mean divided by n − 1.",
      "format": "number"
    },
    "sampleSd": {
      "label": "Sample standard deviation (s)",
      "description": "The square root of the sample variance.",
      "format": "number"
    },
    "populationVariance": {
      "label": "Population variance (σ²)",
      "description": "The sum of squared differences from the mean divided by n.",
      "format": "number"
    },
    "populationSd": {
      "label": "Population standard deviation (σ)",
      "description": "The square root of the population variance.",
      "format": "number"
    },
    "mean": {
      "label": "Mean",
      "description": "The sum divided by the count.",
      "format": "number"
    },
    "sumOfSquares": {
      "label": "Sum of squares",
      "description": "The sum of the squared differences from the mean, Σ(x − mean)².",
      "format": "number"
    },
    "count": {
      "label": "Count",
      "description": "How many numbers are in the list.",
      "format": "integer"
    },
    "sum": {
      "label": "Sum",
      "description": "All the numbers added up.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "input": "1, 2, 3, 4, 5, 6, 7, 8, 9, 10"
    },
    "outputs": {
      "sampleVariance": 9.166666666666666,
      "sampleSd": 3.0276503540974917,
      "populationVariance": 8.25,
      "populationSd": 2.8722813232690143,
      "mean": 5.5,
      "sumOfSquares": 82.5,
      "count": 10,
      "sum": 55
    },
    "text": "For 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, the sample variance is 9.166667 (s = 3.02765) and the population variance is 8.25 (σ = 2.872281)."
  },
  "examples": [
    {
      "given": {
        "input": [
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9,
          10
        ]
      },
      "expect": {
        "sampleVariance": 9.166666666666666,
        "sampleSd": 3.0276503540974917,
        "populationVariance": 8.25,
        "populationSd": 2.8722813232690143,
        "mean": 5.5,
        "sumOfSquares": 82.5
      },
      "source": "hand calculation in content.mdx: SS = 82.5, 82.5 ÷ 9 and 82.5 ÷ 10; Python statistics.variance, stdev, pvariance, pstdev agree; NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.6 Measures of Scale (variance, standard deviation, average absolute deviation). https://www.itl.nist.gov/div898/handbook/eda/section3/eda356.htm"
    },
    {
      "given": {
        "input": [
          2,
          4,
          4,
          4,
          5,
          5,
          7,
          9
        ]
      },
      "expect": {
        "populationVariance": 4,
        "populationSd": 2,
        "sampleVariance": 4.571428571428571,
        "sampleSd": 2.138089935299395,
        "sumOfSquares": 32
      },
      "source": "hand calculation in content.mdx: mean 5, SS = 32, 32 ÷ 8 = 4, 32 ÷ 7 = 4.5714…; Python statistics.pstdev gives 2.0; NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.6 Measures of Scale (variance, standard deviation, average absolute deviation). https://www.itl.nist.gov/div898/handbook/eda/section3/eda356.htm"
    },
    {
      "given": {
        "input": [
          5,
          5,
          5,
          5
        ]
      },
      "expect": {
        "sampleVariance": 0,
        "populationVariance": 0,
        "sampleSd": 0,
        "populationSd": 0
      },
      "source": "hand calculation in content.mdx: every difference from the mean is 0; NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.6 Measures of Scale (variance, standard deviation, average absolute deviation). https://www.itl.nist.gov/div898/handbook/eda/section3/eda356.htm"
    }
  ],
  "sources": [
    "NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.6 Measures of Scale (variance, standard deviation, average absolute deviation). https://www.itl.nist.gov/div898/handbook/eda/section3/eda356.htm",
    "OpenStax, Introductory Statistics 2e, §2.7 Measures of the Spread of the Data (standard deviation and variance). https://openstax.org/books/introductory-statistics-2e/pages/2-7-measures-of-the-spread-of-the-data"
  ],
  "related": [],
  "changelog": [
    {
      "date": "2026-09-29",
      "note": "Worked examples name a published reference for their rule."
    }
  ]
}
