Python statistics.median_low() Method
Python statistics.median_low()Used to calculate the low median of a given data set.
Syntax
The syntax of the statistics.median_low() method is as follows:
statistics.median_low(data)
Parameter description:
- data-- An iterable containing numeric values, such as a list or tuple.
Return Value
The function calculates and returns the low median of the data set as the result.
Example
The following example demonstrates the median_low() function:
Example
data = [1, 3, 5, 7, 9]
median = statistics.median_low(data)
print(median)
Output:
5
In the above example, the given data set is [1, 3, 5, 7, 9]. Using the median_low() method, the low median is calculated as 5.
The low median is a method of calculating the median of a data set. It selects the middle value after sorting, or the smaller of the two middle values, as the median. When the number of elements in the data set is odd, the low median is the same as the ordinary median; when the number of elements is even, the low median selects the smaller value.
The median_low() method may be more suitable in some cases, especially when you want to select the smaller value as the median. If you want to select the larger value as the median, you can usemedian_high()method.
Other Extensions
Python statistics Module