Hey guys i am developing with Delphi 10 Seattle. And i actually need help at getting a Median of an Array eg :
allitems: array[1..500] of Double;
I gave the value of each arrayitem in the array in a procedure. So i got an array of 500 doubles with values in it and want to get the Median out of this 500 values. First of all i guess i have to sort the array from low to high values and after it getting the median. So How can i sort the array first and get the median after sorting ?
The Median of an even number of elements is defined as the mean of the center elements:
var
allitems : TArray<double>;
TArray.Sort<double>(allitems);
median := (allitems[249] + allitems[250]) / 2; // TArray<double> starts with index 0