Here is CODAP’s source code for the computation:
/**
* Get the quantile
* @param iArray Sorted array of finite numeric values (no non-numeric or missing values allowed)
* @param iQuantile {Number} quantile [0.0-1.0] to calculate, e.g. first quartile = 0.25
* @return {Number} median value or undefined if ioArray.length===0
*/
quantileOfSortedArray: function (iSortedArray, iQuantile) {
var lastIndex = iSortedArray.length - 1,
i = lastIndex * iQuantile, // quantile's numeric-real index in 0-(n-1) array
i1 = Math.floor(i),
i2 = Math.ceil(i),
fraction = i - i1;
if (i < 0) {
return undefined; // length === 0, or iQuantile < 0.0
} else if (i >= lastIndex) {
return iSortedArray[lastIndex]; // iQuantile >= 1.0
} else if (i === i1) {
return iSortedArray[i1]; // quantile falls on data value exactly
} else {
// quantile between two data values;
// note that quantile algorithms vary on method used to get value here, there is no fixed standard.
return (iSortedArray[i2] * fraction + iSortedArray[i1] * (1.0 - fraction));
}
},
As you can see in the last line, when desired quantile falls between two values, the returned value is the lower value plus the fraction of the distance between it and the next value.