Reference · Statistics
stats.median_high
signature
stats.median_high(list) -> numWhat it does
The high median of a list of numbers: always one of the data points. With an odd count it is the middle value; with an even count it is the higher of the two middle values, where stats.median would average them. An int list gives an int.
Examples
print(stats.median_high([1, 2, 3, 4]), stats.median_high([1, 3, 2]))print(stats.median_high([1, 2, 4, 4]))output
3 24Edge cases
- One number gives that number.
- The answer is a float only when the list holds a float.
- A list need not be sorted.
print(stats.median_high([7]), stats.median_high([1.0, 2, 3, 4]), stats.median_high([10, 2, 8, 4]))output
7 3.0 8Errors
No data is a runtime error, not an error value: an empty list or null stops the
request. So does an item that is not a number.
this one fails
print(stats.median_high(null))output
line 1: `stats.median_high` requires at least one data pointChaining
let sizes = [8, 2, 4, 6]print(sizes | stats.median_high, sizes | stats.median_low, sizes | stats.median)output
6 4 5.0See also
stats.median, stats.median_low, stats.percentile
Thread
Thread 0 posts
On stats.median_high(): questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.
Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo