private static double median(double min, double max, int n) 
  {
    // get random value in [0.0, 1.0)
    double t = (new Random()).nextDouble();
    
    double retval;
    if (t > 0.5) {
      retval = java.lang.Math.log(1.0-(2.0*(M_E12-1)*(t-0.5)/M_E12))/12.0;   
    } else {
      retval = -java.lang.Math.log(1.0-(2.0*(M_E12-1)*t/M_E12))/12.0;
    }
    // We now have something distributed on (-1.0,1.0)
    retval = (retval+1.0) * (max-min)/2.0;
    retval = retval + min;
    return retval;
  }