Datalens.ai
← All algorithms

STATISTICS

Arithmetic Mean

Average of a set of numeric observations.

Example of usage

mean([2, 4, 6]) = 4

Usage / limitations

+Use when: Summarise the centre of numeric data.

−Limitations: Sensitive to extreme outliers.

Mathematical formula

mean = sum(x_i) / n
Sample dataShow
{
  "variable": "patient_wait_times",
  "domain": "Hospital outpatient waiting-time analysis",
  "feature_names": [
    "wait_minutes"
  ],
  "records": [
    {
      "wait_minutes": 12
    },
    {
      "wait_minutes": 16
    },
    {
      "wait_minutes": 18
    },
    {
      "wait_minutes": 20
    },
    {
      "wait_minutes": 24
    },
    {
      "wait_minutes": 30
    },
    {
      "wait_minutes": 34
    },
    {
      "wait_minutes": 40
    }
  ]
}

Code example (Python)

# DataLens.ai example — Arithmetic Mean
# Domain: hospital outpatient waiting-time analysis.
# Sample data are included by Copy input + code + test.
import numpy as np
from statistics import mean

# Extract named waiting-time observations into a numeric array.
values = np.array([row["wait_minutes"] for row in patient_wait_times["records"]], dtype=float)

# Apply this statistical method to the observations.
result = mean(values)

# Verify the calculated statistic against a mathematical property.
assert abs(result - 24.25) < 1e-10
print("Expected output verified")