Let’s say we are given n numbers [x1, x2, x3, … xn]. The mean of those n numbers is given by the formula:
Now, if we sort the numbers, then the number in the middle is the median of the numbers. If n is even and there are two numbers in the middle, then the median is the average of those two numbers in the middle.
And the mode of the given n numbers is the number that appears most of the time.
Let’s look at an example. Let’s say we are given 10 numbers {1, 2, 3, 3, 4, 5, 5, 5, 8, 10} So, the mean of the given numbers is:
The numbers are already in sorted order. So, the median of the numbers is the number in the middle. Now, n is an even number. So, there are two numbers in the middle – 4 and 5. So, the median of the given 10 numbers is the average of 4 and 5, i.e.,
And the mode of the given 10 numbers is the number that appears most of the time. Here, 3 appears twice, and 5 appears thrice. No other number appears more than thrice. So, the mode of the given numbers is 5.
In Python, we can use the numpy module to calculate the mean and median of a given set of numbers. And we can use the statistics module to calculate the mode of a given set of numbers.








































0 Comments