median property
num
median
The median value. Also the average between medianLow and medianHigh.
- For sets of odd size the median is a single value, that separates the higher half from the lower half of the set. (In this case medianLow and medianHigh are the same value).
- For sets of even size the median is the average of a pair of values, the medianLow and medianHigh values.
Implementation
num get median {
// To avoid any floating point precision loss:
if (medianLow == medianHigh) {
return medianHigh;
}
var median = (medianLow + medianHigh) / 2;
return median;
}