From the course: Programming Foundations: Numerical Mathematics and Calculations

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Calculating the median

Calculating the median

- [Instructor] Another kind of average is median, often spoken in news. For example, the median household income in US was $70,000 in 2021. How is it calculated? It is calculated in two steps. The first step includes sorting the list of numbers in ascending order. The second step has branching depending on if the length of the list of numbers is odd or even number. If it is odd, then the median is the number in the middle of the list. If it is even, then we calculate the median by taking the mean of the two middle numbers. Let's see how to calculate it in an example. Suppose we have the age of employees listed below. We'll arrange them in ascending order. We have seven elements in the list so the length of the list is seven. It's an odd number, then the median is the number in the middle of the list. That's, in our case, 42. What would our median be if it would leave out the last number, 58, from the list? In…

Contents