Squared Differences Simulation

Prerequisites
prerequisites

The middle number minimizes the sum of the absolute deviations. If you have 7 numbers, say 0, 1, 2, 5, 6, 9, and 12, then the middle number is the fourth highest which is 5. Therefore 5 is the value that minimizes the sum of the absolute deviations. This middle number is called the median. If you have an even number of numbers such as the four numbers: 2, 4, 6, and 9, then any value between 4 and 6 will give you the same minimum sum of the absolute deviations. By convention, we define the median as the average of the two numbers closest the middle (2 and 4 in this case). So the median of the numbers 2, 4, 6, and 9 is 5.