{
  "id": "average",
  "version": "d4e1659fef44",
  "status": "published",
  "name": "Average Calculator",
  "question": "What is the average?",
  "summary": "Computes the average (arithmetic mean) of a list of numbers, with the sum, the count, the median, and the geometric and harmonic means.",
  "category": "statistics",
  "subcategory": "descriptive",
  "url": "https://www.acalculator.org/statistics/average-calculator",
  "markdown": "https://www.acalculator.org/statistics/average-calculator.md",
  "kind": "function",
  "method": "mean = (x₁ + x₂ + … + xₙ) ÷ n",
  "assumptions": [
    "Every number in the list counts once. To give some numbers more weight, use the weighted average calculator.",
    "The median sorts the list and takes the middle number, or the mean of the two middle numbers when the count is even.",
    "The geometric and harmonic means are shown only when every number is above 0."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "data": {
        "title": "Your numbers",
        "description": "The numbers to average, separated by commas, spaces, semicolons, or new lines.",
        "type": "array",
        "items": {
          "type": "number"
        }
      }
    }
  },
  "outputs": {
    "mean": {
      "label": "Average (mean)",
      "description": "The arithmetic mean: the sum of the numbers divided by how many there are.",
      "format": "number"
    },
    "sum": {
      "label": "Sum",
      "description": "All the numbers added up.",
      "format": "number"
    },
    "count": {
      "label": "Count",
      "description": "How many numbers are in the list.",
      "format": "integer"
    },
    "median": {
      "label": "Median",
      "description": "The middle number once the list is sorted, or the mean of the two middle numbers.",
      "format": "number"
    },
    "geometric": {
      "label": "Geometric mean",
      "description": "The n-th root of the product of the n numbers. Shown only when every number is above 0.",
      "format": "number"
    },
    "harmonic": {
      "label": "Harmonic mean",
      "description": "The count divided by the sum of the reciprocals. Shown only when every number is above 0.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "data": "85, 90, 78, 92, 88"
    },
    "outputs": {
      "mean": 86.6,
      "sum": 433,
      "count": 5,
      "median": 88,
      "geometric": 86.45802439151284,
      "harmonic": 86.31176326814145
    },
    "text": "The average of 85, 90, 78, 92, 88 is 86.6."
  },
  "examples": [
    {
      "given": {
        "data": [
          85,
          90,
          78,
          92,
          88
        ]
      },
      "expect": {
        "mean": 86.6,
        "sum": 433,
        "count": 5,
        "median": 88,
        "geometric": 86.45802439151284,
        "harmonic": 86.31176326814145
      },
      "source": "hand calculation in content.mdx: 433 ÷ 5 = 86.6, median 88; geometric and harmonic means from the Python statistics module (geometric_mean, harmonic_mean)"
    },
    {
      "given": {
        "data": [
          10000001,
          10000003,
          10000002
        ]
      },
      "expect": {
        "mean": 10000002,
        "sum": 30000006,
        "median": 10000002
      },
      "source": "NIST StRD univariate dataset NumAcc1: certified sample mean 10000002 (exact)"
    },
    {
      "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
        ]
      },
      "expect": {
        "mean": 2.001856,
        "count": 50
      },
      "source": "NIST StRD univariate dataset Mavro: certified sample mean 2.00185600000000",
      "tolerance": 1e-14
    },
    {
      "given": {
        "data": [
          2,
          8
        ]
      },
      "expect": {
        "mean": 5,
        "geometric": 4,
        "harmonic": 3.2
      },
      "source": "hand calculation in content.mdx: (2 + 8) ÷ 2 = 5; √(2 × 8) = 4; 2 ÷ (1/2 + 1/8) = 3.2"
    },
    {
      "given": {
        "data": [
          -4,
          0,
          7
        ]
      },
      "expect": {
        "mean": 1,
        "median": 0,
        "sum": 3
      },
      "source": "hand calculation in content.mdx: (−4 + 0 + 7) ÷ 3 = 1"
    }
  ],
  "sources": [
    "NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.1, Measures of Location (mean and median). https://www.itl.nist.gov/div898/handbook/eda/section3/eda351.htm",
    "NIST Dataplot Reference Manual, Geometric Mean. https://itl.nist.gov/div898/software/dataplot/refman2/auxillar/geommean.htm",
    "NIST Dataplot Reference Manual, Harmonic Mean. https://www.itl.nist.gov/div898/software/dataplot/refman2/auxillar/harmmean.htm",
    "NIST Statistical Reference Datasets, univariate summary statistics: NumAcc1 and Mavro, certified values. https://www.itl.nist.gov/div898/strd/univ/homepage.html"
  ],
  "related": [
    "weighted-average",
    "standard-deviation"
  ],
  "changelog": []
}
