
Concept
Median is a statistical concept of finding a middle value from a set of values. It is very useful to understand the skewness and distribution of data. Let’s understand the formula and an example.
Formula
$$ \operatorname{median}(x)=\frac{1}{2}\left(x_{\lfloor(n+1) / 2\rfloor}+x_{\lceil(n+1) / 2\rceil}\right)$$
Here x indicates an index of x from a table, dataset, or simply from a set of values,
n is a number of values in a table, dataset, or set of values.
\( \lfloor … \rfloor \) = symbols denotes floor function
\( \lceil … \rceil \) = symbols denotes ceil function.
Explanation
All the values must be sorted before computing a median.
In the above formula, we are finding the middlemost two values by taking floor value of \( {\lfloor(n+1) / 2\rfloor} \) as an index of first number and ceil value of \( {\lceil(n+1) / 2\rceil} \) as an index of second number.
After getting both values, we will do a summation of both and divide that by 2 to get a median value.
Example
| x |
|---|
| 36 |
| 8 |
| 32 |
| 4 |
| 11 |
| 33 |
| 18 |
| 20 |
| 40 |
| 38 |
| 9 |
| 25 |
| 26 |
| 6 |
| 28 |
| 22 |
| 33 |
| 15 |
After sorting all the values:
4, 6, 8, 9, 11, 15, 18, 20, 22, 25, 26, 28, 32, 33, 33, 36, 38, 40
We have n = 18 number of values.
Putting it in our formula:
$$ \operatorname{median}(x) =\frac{1}{2}\left(x_{\lfloor(n+1) / 2\rfloor}+x_{\lceil(n+1) / 2\rceil}\right)$$
$$ \operatorname{median}(x) =\frac{1}{2}\left(x_{\lfloor(18+1) / 2\rfloor}+x_{\lceil(18+1) / 2\rceil}\right) $$
$$ \operatorname{median}(x) = \frac{1}{2}\left(x_{9}+x_{10}\right) = \frac{1}{2}\left(25 + 26\right) $$
$$ \operatorname{median}(x) = \frac{51}{2} = 25.5 $$
25.5 will be our median of all the values from a table.