{
  "id": "statistics",
  "version": "40857b844111",
  "status": "published",
  "name": "Statistics Calculator",
  "question": "What are the statistics of my data?",
  "summary": "Computes descriptive statistics of a list of numbers: mean, median, mode, standard deviation, variance, range, quartiles, sum, count, and geometric mean.",
  "category": "statistics",
  "subcategory": "descriptive",
  "url": "https://www.acalculator.org/statistics/statistics-calculator",
  "markdown": "https://www.acalculator.org/statistics/statistics-calculator.md",
  "kind": "function",
  "method": "mean = Σx ÷ n; variance = Σ(x − mean)² ÷ (n − 1) for a sample or ÷ n for a population; SD = √variance; Q1 and Q3 = medians of the lower and upper halves; geometric mean = (x₁ × … × xₙ)^(1/n).",
  "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.",
    "Quartiles are the medians of the lower and upper halves of the sorted list, leaving out the median when n is odd (the TI-84 and Moore and McCabe method).",
    "All results except the standard deviation, standard error, and geometric mean are exact on the decimals you type, then rounded once."
  ],
  "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 (the variance divides by n − 1) or the whole population (divides by n). Pick sample when unsure.",
        "type": "string",
        "enum": [
          "sample",
          "population"
        ]
      }
    }
  },
  "outputs": {
    "mean": {
      "label": "Mean",
      "description": "The sum divided by the count: the average.",
      "format": "number"
    },
    "median": {
      "label": "Median",
      "description": "The middle number when sorted, or the mean of the two middle numbers.",
      "format": "number"
    },
    "mode": {
      "label": "Mode",
      "description": "The value or values that occur most often, or No mode when no value repeats.",
      "format": "text"
    },
    "sd": {
      "label": "Standard deviation",
      "description": "The square root of the variance: how far the numbers typically are from the 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"
    },
    "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"
    },
    "min": {
      "label": "Smallest",
      "description": "The smallest number.",
      "format": "number"
    },
    "max": {
      "label": "Largest",
      "description": "The largest number.",
      "format": "number"
    },
    "range": {
      "label": "Range",
      "description": "The largest number minus the smallest.",
      "format": "number"
    },
    "q1": {
      "label": "First quartile (Q1)",
      "description": "The median of the lower half of the sorted numbers. Shown for 2 or more numbers.",
      "format": "number"
    },
    "q3": {
      "label": "Third quartile (Q3)",
      "description": "The median of the upper half of the sorted numbers. Shown for 2 or more numbers.",
      "format": "number"
    },
    "iqr": {
      "label": "Interquartile range",
      "description": "Q3 minus Q1: the spread of the middle half. Shown for 2 or more numbers.",
      "format": "number"
    },
    "sem": {
      "label": "Standard error of the mean",
      "description": "The sample standard deviation divided by √n. Shown for a sample only.",
      "format": "number"
    },
    "geometricMean": {
      "label": "Geometric mean",
      "description": "The nth root of the product of the numbers. Shown only when every number is above 0.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "data": "10, 12, 23, 23, 16, 23, 21, 16",
      "type": "sample"
    },
    "outputs": {
      "mean": 18,
      "median": 18.5,
      "mode": "23",
      "sd": 5.237229365663817,
      "variance": 27.428571428571427,
      "count": 8,
      "sum": 144,
      "min": 10,
      "max": 23,
      "range": 13,
      "q1": 14,
      "q3": 23,
      "iqr": 9,
      "sem": 1.8516401995451026,
      "geometricMean": 17.252538362424577
    },
    "text": "For 8 numbers: mean 18, median 18.5, standard deviation 5.237229 (Sample)."
  },
  "examples": [
    {
      "given": {
        "data": [
          10,
          12,
          23,
          23,
          16,
          23,
          21,
          16
        ],
        "type": "sample"
      },
      "expect": {
        "mean": 18,
        "median": 18.5,
        "mode": "23",
        "variance": 27.428571428571427,
        "sd": 5.237229365663818,
        "sum": 144,
        "range": 13,
        "q1": 14,
        "q3": 23,
        "iqr": 9,
        "sem": 1.8516401995451028,
        "geometricMean": 17.252538362424577
      },
      "source": "hand calculation in content.mdx: 144 ÷ 8 = 18, SS = 192, 192 ÷ 7 = 27.43; NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.6 Measures of Scale. https://www.itl.nist.gov/div898/handbook/eda/section3/eda356.htm"
    },
    {
      "given": {
        "data": [
          10,
          12,
          23,
          23,
          16,
          23,
          21,
          16
        ],
        "type": "population"
      },
      "expect": {
        "variance": 24,
        "sd": 4.898979485566356,
        "mean": 18
      },
      "source": "hand calculation in content.mdx: 192 ÷ 8 = 24; NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.6 Measures of Scale. https://www.itl.nist.gov/div898/handbook/eda/section3/eda356.htm"
    },
    {
      "given": {
        "data": [
          1,
          11.5,
          6,
          7.2,
          4,
          8,
          9,
          10,
          6.8,
          8.3,
          2,
          2,
          10,
          1
        ],
        "type": "sample"
      },
      "expect": {
        "median": 7,
        "q1": 2,
        "q3": 9,
        "iqr": 7,
        "mode": "1, 2, 10",
        "count": 14
      },
      "source": "OpenStax, Introductory Statistics 2e, §2.3 Measures of the Location of the Data. https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data (14 values: median 7, Q1 = 2, Q3 = 9, IQR = 7)"
    },
    {
      "given": {
        "data": [
          0.1,
          0.2,
          0.3
        ],
        "type": "population"
      },
      "expect": {
        "sum": 0.6,
        "mean": 0.2,
        "variance": 0.006666666666666667,
        "median": 0.2,
        "mode": "No mode"
      },
      "source": "hand calculation in content.mdx: 0.6 ÷ 3 = 0.2, SS = 0.02; NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.1 Measures of Location. https://www.itl.nist.gov/div898/handbook/eda/section3/eda351.htm"
    },
    {
      "given": {
        "data": [
          -5,
          4
        ],
        "type": "sample"
      },
      "expect": {
        "mean": -0.5,
        "median": -0.5,
        "q1": -5,
        "q3": 4,
        "variance": 40.5
      },
      "source": "hand calculation in content.mdx: (−5 + 4) ÷ 2 = −0.5, SS = 40.5; NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.1 Measures of Location. https://www.itl.nist.gov/div898/handbook/eda/section3/eda351.htm"
    }
  ],
  "sources": [
    "NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.1 Measures of Location. https://www.itl.nist.gov/div898/handbook/eda/section3/eda351.htm",
    "NIST/SEMATECH e-Handbook of Statistical Methods, §1.3.5.6 Measures of Scale. https://www.itl.nist.gov/div898/handbook/eda/section3/eda356.htm",
    "OpenStax, Introductory Statistics 2e, §2.3 Measures of the Location of the Data. https://openstax.org/books/introductory-statistics-2e/pages/2-3-measures-of-the-location-of-the-data"
  ],
  "related": [
    "mean-median-mode",
    "standard-deviation",
    "quartile",
    "percentile"
  ],
  "changelog": []
}
