static double computeQuantile ( double lo , double hi , double row , double nrows , double prob , QuantileModel . CombineMethod method ) { if ( lo == hi ) return lo ; // Equal; pick either if ( method == null ) method = QuantileModel . CombineMethod . INTERPOLATE ; switch ( method ) { case INTERPOLATE : return linearInterpolate ( lo , hi , row , nrows , prob ) ; case AVERAGE : return 0.5 * ( hi + lo ) ; case LOW : return lo ; case HIGH : return hi ; default : Log . info ( "Unknown even sample size quantile combination type: " + method + ". Doing linear interpolation." ) ; return linearInterpolate ( lo , hi , row , nrows , prob ) ; } }
Compute the correct final quantile from these 4 values . If the lo and hi elements are equal use them . However if they differ then there is no single value which exactly matches the desired quantile . There are several well - accepted definitions in this case - including picking either the lo or the hi or averaging them or doing a linear interpolation .