Previous Up Next

20.1.5  Median

Although the average of a list of numbers typically means the mean, there are other notions of “average”. Another such notion is the median; the median of a list of numbers is the middle number when they are listed in numeric order. For example, the median of the list [1,2,5,7,20] is simply 5. If the length of a list of numbers is even, the median is the mean of the two middle numbers; for example, the median of [1,2,5,7,20,21] is (5+7)/2=6.

The median function finds the median of a list.

Examples

median([1,2,5,7,20])
     
5           
median([1,2,5,7,20],[5,3,2,1,2])
     
2           

since the median of 1,1,1,1,1,2,2,2,5,5,7,20,20 is 2.


Previous Up Next