The median is the middle point in a dataset—half of the data points are smaller than the median and half of the data points are larger.
To find the median:
• Arrange the data points from smallest to largest.
• If the number of data points is odd,
the median is the middle data point in the list.
• If the number of data points is even,
the median is the average of the two middle data points in the list.
We can use statistics.median() to evaluate the median of a data points
or we can build a median function by your own.
Example 1
Find the median of this data:
111, 444, 222, 555, 000
Put the data in order first:
000, 111, 222, 444, 555
There is an odd number of data points, so the median is the middle data point.
000, 111, 222, 444, 555
The median is 222.
Example 2
Find the median of this data:
10, 40, 20, 50
Put the data in order first:
10, 20, 40, 50
There is an even number of data points, so the median is the average of the middle two data points.
10, 20, 40, 50
Median = (20+40)/2 = 30