Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python statistics.median_high() Method

Python statistics.median_high() Method

Python statistics Module Python statistics Module

Python statistics.median_high() Used to compute the high median of a given data set.

Syntax

The syntax of the statistics.median_high() method is as follows:



statistics.median_high(data)

Parameter Description:

Return Value

The function computes and returns the high median of the data set as the result.

Example

The following example demonstrates the median_high() function:

Example

import

statistics

data

=

[

1

,

3

,

5

,

7

,

9

]

median

=

statistics.

median_high

(

data

)

print

(

median

)

Output result:



5

In the above example, the given data set is [1, 3, 5, 7, 9], and the median_high() method computes a high median of 5.

The high median is a method of computing the median of a data set that selects the middle value or the larger of the two after sorting. When the number of elements is odd, the high median is the same as the ordinary median; when it is even, the high median selects the larger value.

The median_high() method may be more suitable in certain cases, especially when you want to select the larger value as the median. If you want to select the smaller value as the median, you can use median_low() method.

Python statistics Module Python statistics Module