Record given numeric sequence. Follow her ascending. In the set from left to right the numbers must be from smallest to largest.
If the number contains an odd number of numbers, the median should take the value exactly in the middle of the set. For example, a numeric sequence: 400 250 640 700 900 100 300 170 550. In this set the numbers are not in order. After sort in ascending order so we get the following number: 100 170 250 300 400 550 640 700 900. As can be seen, the sequence consists of 9 values. The median of the numerical set in this case will be number 400. From his position on one side all numbers are more median, and on the other – not less.
When considering the values of the even-numbered sequence, the Central will be not one but two numbers: m and k. Find these numbers also after arranging the set in ascending order. The median of this case will be the average of the data rate values. Calculate it by the formula (m + k)/2. For example, in the sorted series 200 400 600 4000 30000 50000 number 600 and 4000 occupy a Central position. Therefore, the median of a numerical sequence will be the following value: (600 + 4000)/2 = 2300.
If the value set contains a large amount of data manually is rather difficult to sort and determine the center of the range. Using a small program you can easily find the median of a sequence of numbers of any dimension. Example code in Pascal:
var M_ss: array[1..200] of integer;
med: real;
k, i, j: integer;
(*Sort the numbers in ascending order*)
for j:=1 to 200-1 do
for i:=1 to 200-j do
if M_ss[i] > M_ss[i+1] then
(*Finding the median*)
if (length(M_ss) mod 2)=0 then
med:=( M_ss[trunc(length(M_ss))] + M_ss[trunc(length(M_ss))+1])/2
Med in a variable contains the median value of the specified numeric array M_ss.