On this page
statistics.mean
Prev: statistics.linear_regression | Up: statistics | Next: statistics.median
Rel: statistics.correlation, statistics.covariance, statistics.fmean, statistics.geometric_mean
Ref: docs.python.org — statistics.mean
Tags: #public #python3 #stdlib #statistics
Import
import statistics
from statistics import mean
Signature & Overview
statistics.mean(data)
Return the sample arithmetic mean of data.
Usage
from decimal import Decimal
import statistics
assert statistics.mean([1, 2, 3, 4]) == 2.5
assert statistics.mean([Decimal('1.5'), Decimal('2.5')]) == Decimal('2.0')
Gotchas
- Preserves
DecimalandFractionprecision; usefmean()when speed on floats matters.
REPL Inspect
from statistics import mean
help(mean)
Linked from
Related notes
- tuts/python3/stdlib_module/statistics/linear_regression Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/median Linked here; links to this page; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/statistics/correlation Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/covariance Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/fmean Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/geometric_mean Linked here; shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/harmonic_mean shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/kde shared tags: #statistics, #stdlib
- tuts/python3/stdlib_module/statistics/kde_random shared tags: #statistics, #stdlib