statistics.median_high

Full name
statistics.median_high
Library
statistics
Syntax

statistics.median_high(data)

Description

The statistics.median_high function returns the median of the elements in data. For its calculation, the ordered elements are considered: If the number of elements is odd, the function returns the value that occupies the central position. If the number of elements is even, the highest value of the two closest to the center position is returned.

Parameters
  • data: Sequence or iterable from whose elements you want to calculate the median.
Result

The statistics.median_high function returns an integer or real number.

Examples

We can obtain the median of the numbers contained in a list with the following code:

statistics.median_high([1, 3, 6, 11, 11])
6

In this case, the number of elements is odd, so the function returns the value that occupies the central position if we consider them ordered (in the example the values are already ordered to make its interpretation easier).

If the number of elements is even, the highest value of the two closest to the central position is returned (the values 3 and 4 in the following example):

statistics.median_high([1, 3, 4, 11])
4
Submitted by admin on Sun, 03/28/2021 - 10:23