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

Function median_low

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

Return the low median of numeric data. When the number of data points is odd, the middle value is returned. When it is even, the smaller of the two middle values is returned. >>> median_low([1, 3, 5]) 3 >>> median_low([1, 3, 5, 7]) 3

(data)

Source from the content-addressed store, hash-verified

571
572
573def median_low(data):
574 """Return the low median of numeric data.
575
576 When the number of data points is odd, the middle value is returned.
577 When it is even, the smaller of the two middle values is returned.
578
579 >>> median_low([1, 3, 5])
580 3
581 >>> median_low([1, 3, 5, 7])
582 3
583
584 """
585 data = sorted(data)
586 n = len(data)
587 if n == 0:
588 raise StatisticsError("no median for empty data")
589 if n % 2 == 1:
590 return data[n // 2]
591 else:
592 return data[n // 2 - 1]
593
594
595def median_high(data):

Callers

nothing calls this directly

Calls 2

sortedFunction · 0.85
StatisticsErrorClass · 0.85

Tested by

no test coverage detected