public static double quantile(double q,double[] x,int[] indices){
  if (q < 0.0 || q > 1.0)   throw new IllegalArgumentException("Quantile out of range");
  if (q == 0.0) {
    return x[indices[0]] - 1.0;
  }
  return x[indices[(int)Math.ceil(q * indices.length) - 1]];
}

public static double quantile ( double q , double [ ] x , int [ ] indices ) { if ( q < 0.0 || q > 1.0 ) throw new IllegalArgumentException ( "Quantile out of range" ) ; if ( q == 0.0 ) { return x [ indices [ 0 ] ] - 1.0 ; } return x [ indices [ ( int ) Math . ceil ( q * indices . length ) - 1 ] ] ; }
compute the q - th quantile for a distribution of x ( = inverse cdf )
