## Median

The median is a measure of central tendency used in statistics. It represents the middle value in a dataset when the data has been arranged in order of magnitude (i.e., from smallest to largest, or vice versa). If the dataset contains an odd number of observations, the median is the value exactly in the middle. If the dataset contains an even number of observations, the median is calculated as the average of the two middle values.

For example:

- If you have the dataset [3, 7, 5], the median would be 5 (because 5 is the middle value when the data is sorted as [3, 5, 7]).
- If you have the dataset [3, 7, 5, 9], the median would be 6 (because when the data is sorted as [3, 5, 7, 9], the two middle values are 5 and 7, and the average of 5 and 7 is 6).

The median is particularly useful when dealing with skewed distributions, or when there are extreme values or outliers in the data. This is because the median is not affected by the magnitude of extreme values, unlike the mean, which can be significantly influenced by such values. This makes the median a robust measure of central tendency that provides a more accurate reflection of the “typical” value in such cases.

## Example of the Median

Let’s consider two scenarios:

- Dataset with an Odd Number of Observations

Let’s say we have test scores from seven students: 85, 90, 92, 94, 96, 98, 100.

To find the median, we first arrange the scores in ascending order: 85, 90, 92, 94, 96, 98, 100.

Since the number of scores is odd, the median is the middle value, which in this case is 94. - Dataset with an Even Number of Observations

Let’s say another student takes the test, and we now have eight scores: 85, 90, 92, 94, 96, 98, 100, 102.

Again, we arrange the scores in ascending order: 85, 90, 92, 94, 96, 98, 100, 102.

Since the number of scores is even, the median is the average of the two middle values. The two middle values in this case are 94 and 96. So, the median would be (94 + 96) / 2 = 95.

In these examples, the median gives the “middle” score in the dataset, providing a sense of what a typical score might look like. If the scores were heavily skewed (for example, if one student scored very poorly or exceptionally well compared to others), the median would still provide a good estimate of the typical score, unlike the mean, which could be skewed by such an extreme score.