I'm giving a sorted array of 24 numbers to d3.quantile
and asking it to calculate the first quartile value. Since the array can be split evenly into four groups of 6 values, my assumption was that the result would be the mean of arr[5] and arr[6], but that's not what I got.
var arr = [89.7, 93.2, 94, 94.3, 94.5, 95.4, 95.9, 96.1, 96.4, 96.5, 96.9, 96.9, 97.3, 97.6, 97.6, 97.6, 97.8, 98.3, 98.3, 98.4, 98.5, 98.5, 98.6, 98.6];
var myAssumption = (arr[5] + arr[6]) / 2; // 95.65
var d3Result = d3.quantile(arr, 0.25); // 95.775
Does the d3 quantile function use some more complex algorithm? This Wikipedia article lists several options, but I'm not sure which is being used (or why one algorithm is preferable to another).