Find the median of a data set by sorting the values and selecting the middle element (odd count) or averaging the two middle elements (even count).

median Sort the data. For n values: - n odd: median = value at position (n+1)/2 - n even: median = average of positions n/2 and n/2+1

Example

Sort the data and choose the middle value.

highlighted = computed this step

Step 1 — Data

List the data values.

posx1327324955\begin{array}{cc}\text{pos} & \text{x} \\ 1 & 3 \\ 2 & 7 \\ 3 & 2 \\ 4 & 9 \\ 5 & 5\end{array}

Step 2 — Sort

Sort the data from least to greatest.

posx1223354759\begin{array}{cc}\text{pos} & \text{x} \\ 1 & \hlmath{2} \\ 2 & \hlmath{3} \\ 3 & \hlmath{5} \\ 4 & \hlmath{7} \\ 5 & \hlmath{9}\end{array}
Sorted data2pos 13pos 25pos 37pos 49pos 5

Step 3 — Middle position

Find the middle position.

p=(5+1)/2=3p=( 5 + 1 )/ 2 = \hl{3}
Position 3 is the middle2pos 13pos 25pos 37pos 49pos 5middle

Step 4 — Read the middle value

Read the value at the middle position.

middlevalue=5middle value= \hl{5}
Middle value is 52pos 13pos 25pos 37pos 49pos 5middle

Step 5 — Median

The median is the middle value.

median=5median= \hl{5}
Middle value is 52pos 13pos 25pos 37pos 49pos 5middle