handle double.NaN as quantile value (ported from java lib)