MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / mean

Function mean

tools/python-3.11.9-amd64/Lib/statistics.py:414–433  ·  view source on GitHub ↗

Return the sample arithmetic mean of data. >>> mean([1, 2, 3, 4, 4]) 2.8 >>> from fractions import Fraction as F >>> mean([F(3, 7), F(1, 21), F(5, 3), F(1, 3)]) Fraction(13, 21) >>> from decimal import Decimal as D >>> mean([D("0.5"), D("0.75"), D("0.625"), D

(data)

Source from the content-addressed store, hash-verified

412# === Measures of central tendency (averages) ===
413
414def mean(data):
415 """Return the sample arithmetic mean of data.
416
417 >>> mean([1, 2, 3, 4, 4])
418 2.8
419
420 >>> from fractions import Fraction as F
421 >>> mean([F(3, 7), F(1, 21), F(5, 3), F(1, 3)])
422 Fraction(13, 21)
423
424 >>> from decimal import Decimal as D
425 >>> mean([D("0.5"), D("0.75"), D("0.625"), D("0.375")])
426 Decimal('0.5625')
427
428 If ``data`` is empty, StatisticsError will be raised.
429 """
430 T, total, n = _sum(data)
431 if n < 1:
432 raise StatisticsError('mean requires at least one data point')
433 return _convert(total / n, T)
434
435
436def fmean(data, weights=None):

Callers 1

_test_generatorFunction · 0.90

Calls 3

_sumFunction · 0.85
StatisticsErrorClass · 0.85
_convertFunction · 0.70

Tested by

no test coverage detected