{
  "id": "standard-deviation",
  "version": "5ae197ec2205",
  "status": "published",
  "name": "Standard Deviation Calculator",
  "question": "What is the standard deviation?",
  "summary": "Computes the sample or population standard deviation of a list of numbers, with the variance, mean, standard error of the mean, and coefficient of variation.",
  "category": "statistics",
  "subcategory": "descriptive",
  "url": "https://www.acalculator.org/statistics/standard-deviation-calculator",
  "markdown": "https://www.acalculator.org/statistics/standard-deviation-calculator.md",
  "kind": "function",
  "method": "Sample: s = √(Σ(x − mean)² ÷ (n − 1)); population: σ = √(Σ(x − mean)² ÷ n); standard error = s ÷ √n; coefficient of variation = SD ÷ mean × 100%.",
  "assumptions": [
    "A sample divides the sum of squares by n − 1 (Bessel’s correction) and needs at least 2 numbers. A population divides by n.",
    "The mean is found first, then the squared differences from it are added up (the two-pass method).",
    "The standard error of the mean is shown for a sample only. The coefficient of variation is shown only when the mean is above 0."
  ],
  "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"
        }
      },
      "type": {
        "title": "Your numbers are a",
        "description": "A sample from a larger group (divide by n − 1) or the whole population (divide by n). Pick sample when unsure.",
        "type": "string",
        "enum": [
          "sample",
          "population"
        ]
      }
    }
  },
  "outputs": {
    "sd": {
      "label": "Standard deviation",
      "description": "The square root of the variance: how far the numbers typically are from their mean.",
      "format": "number"
    },
    "variance": {
      "label": "Variance",
      "description": "The sum of squared differences from the mean, divided by n − 1 (sample) or n (population).",
      "format": "number"
    },
    "mean": {
      "label": "Mean",
      "description": "The sum divided by the count.",
      "format": "number"
    },
    "count": {
      "label": "Count (n)",
      "description": "How many numbers are in the list.",
      "format": "integer"
    },
    "sum": {
      "label": "Sum",
      "description": "All the numbers added up.",
      "format": "number"
    },
    "sumOfSquares": {
      "label": "Sum of squares",
      "description": "The squared differences from the mean, added up: Σ(x − mean)².",
      "format": "number"
    },
    "sem": {
      "label": "Standard error of the mean",
      "description": "The sample standard deviation divided by √n. Shown for a sample only.",
      "format": "number"
    },
    "cv": {
      "label": "Coefficient of variation",
      "description": "The standard deviation as a percent of the mean. Shown only when the mean is above 0.",
      "format": "percent"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "data": "2, 4, 4, 4, 5, 5, 7, 9",
      "type": "sample"
    },
    "outputs": {
      "sd": 2.138089935299395,
      "variance": 4.571428571428571,
      "mean": 5,
      "count": 8,
      "sum": 40,
      "sumOfSquares": 32,
      "sem": 0.7559289460184544,
      "cv": 42.76179870598791
    },
    "text": "Sample standard deviation of 2, 4, 4, 4, 5, 5, 7, 9: 2.13809, with a mean of 5."
  },
  "examples": [
    {
      "given": {
        "data": [
          2,
          4,
          4,
          4,
          5,
          5,
          7,
          9
        ],
        "type": "sample"
      },
      "expect": {
        "sd": 2.138089935299395,
        "variance": 4.571428571428571,
        "mean": 5,
        "sumOfSquares": 32,
        "sem": 0.7559289460184544,
        "cv": 42.76179870598791
      },
      "source": "hand calculation in content.mdx: SS = 32, 32 ÷ 7 = 4.5714, √4.5714 = 2.1381; Python statistics.stdev"
    },
    {
      "given": {
        "data": [
          2,
          4,
          4,
          4,
          5,
          5,
          7,
          9
        ],
        "type": "population"
      },
      "expect": {
        "sd": 2,
        "variance": 4,
        "mean": 5,
        "cv": 40
      },
      "source": "hand calculation in content.mdx: 32 ÷ 8 = 4, √4 = 2; Python statistics.pstdev"
    },
    {
      "given": {
        "data": [
          10000001,
          10000003,
          10000002
        ],
        "type": "sample"
      },
      "expect": {
        "sd": 1,
        "variance": 1,
        "mean": 10000002,
        "sem": 0.5773502691896258
      },
      "source": "NIST StRD univariate dataset NumAcc1: certified sample standard deviation 1 (exact); SEM = 1 ÷ √3"
    },
    {
      "given": {
        "data": [
          2.0018,
          2.0017,
          2.0018,
          2.0019,
          2.0018,
          2.0017,
          2.0015,
          2.0014,
          2.0015,
          2.0015,
          2.0017,
          2.0018,
          2.0018,
          2.0019,
          2.0019,
          2.0021,
          2.002,
          2.0016,
          2.0014,
          2.0013,
          2.0013,
          2.0015,
          2.0015,
          2.0016,
          2.0015,
          2.0014,
          2.0013,
          2.0014,
          2.0015,
          2.0014,
          2.0015,
          2.0016,
          2.0015,
          2.0016,
          2.0019,
          2.002,
          2.002,
          2.0021,
          2.0022,
          2.0023,
          2.0024,
          2.0025,
          2.0027,
          2.0026,
          2.0026,
          2.0026,
          2.0027,
          2.0026,
          2.0025,
          2.0024
        ],
        "type": "sample"
      },
      "expect": {
        "sd": 0.000429123454003053,
        "mean": 2.001856
      },
      "source": "NIST StRD univariate dataset Mavro: certified sample standard deviation 0.000429123454003053 (15 digits; the data are stored as binary doubles, so the tolerance is 1e-12; Python statistics.stdev agrees to 7.5e-14)",
      "tolerance": 1e-12
    },
    {
      "given": {
        "data": [
          7
        ],
        "type": "population"
      },
      "expect": {
        "sd": 0,
        "variance": 0,
        "mean": 7
      },
      "source": "hand calculation in content.mdx: the only difference from the mean is 0"
    }
  ],
  "sources": [
    "NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.6, Measures of Scale (variance and standard deviation). https://www.itl.nist.gov/div898/handbook/eda/section3/eda356.htm",
    "NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.2, Confidence Limits for the Mean (s ÷ √N). https://www.itl.nist.gov/div898/handbook/eda/section3/eda352.htm",
    "NIST Dataplot Reference Manual, Coefficient of Variation. https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/coefvari.htm",
    "NIST Statistical Reference Datasets, univariate summary statistics: NumAcc1 and Mavro, certified values. https://www.itl.nist.gov/div898/strd/univ/homepage.html"
  ],
  "related": [
    "average",
    "z-score",
    "weighted-average"
  ],
  "changelog": []
}
