public double nextDouble(double alpha,double beta){
  double a=alpha;
  double b=beta;
  if ((a_setup != a) || (b_setup != b)) {
    double mpa, mmb, mode;
    double amb;
    double a_, b_, a_1, b_1, pl;
    double help_1, help_2;
    amb=a * a - b * b;
    samb=Math.sqrt(amb);
    mode=b / samb;
    help_1=a * Math.sqrt(2.0 * samb + 1.0);
    help_2=b * (samb + 1.0);
    mpa=(help_2 + help_1) / amb;
    mmb=(help_2 - help_1) / amb;
    a_=mpa - mode;
    b_=-mmb + mode;
    hr=-1.0 / (-a * mpa / Math.sqrt(1.0 + mpa * mpa) + b);
    hl=1.0 / (-a * mmb / Math.sqrt(1.0 + mmb * mmb) + b);
    a_1=a_ - hr;
    b_1=b_ - hl;
    mmb_1=mode - b_1;
    mpa_1=mode + a_1;
    s=(a_ + b_);
    pm=(a_1 + b_1) / s;
    pr=hr / s;
    pmr=pm + pr;
    a_setup=a;
    b_setup=b;
  }
  for (; ; ) {
    u=randomGenerator.raw();
    v=randomGenerator.raw();
    if (u <= pm) {
      x=mmb_1 + u * s;
      if (Math.log(v) <= (-a * Math.sqrt(1.0 + x * x) + b * x + samb))       break;
    }
 else {
      if (u <= pmr) {
        e=-Math.log((u - pm) / pr);
        x=mpa_1 + hr * e;
        if ((Math.log(v) - e) <= (-a * Math.sqrt(1.0 + x * x) + b * x + samb))         break;
      }
 else {
        e=Math.log((u - pmr) / (1.0 - pmr));
        x=mmb_1 + hl * e;
        if ((Math.log(v) + e) <= (-a * Math.sqrt(1.0 + x * x) + b * x + samb))         break;
      }
    }
  }
  return (x);
}

public double nextDouble ( double alpha , double beta ) { double a = alpha ; double b = beta ; if ( ( a_setup != a ) || ( b_setup != b ) ) { double mpa , mmb , mode ; double amb ; double a_ , b_ , a_1 , b_1 , pl ; double help_1 , help_2 ; amb = a * a - b * b ; samb = Math . sqrt ( amb ) ; mode = b / samb ; help_1 = a * Math . sqrt ( 2.0 * samb + 1.0 ) ; help_2 = b * ( samb + 1.0 ) ; mpa = ( help_2 + help_1 ) / amb ; mmb = ( help_2 - help_1 ) / amb ; a_ = mpa - mode ; b_ = - mmb + mode ; hr = - 1.0 / ( - a * mpa / Math . sqrt ( 1.0 + mpa * mpa ) + b ) ; hl = 1.0 / ( - a * mmb / Math . sqrt ( 1.0 + mmb * mmb ) + b ) ; a_1 = a_ - hr ; b_1 = b_ - hl ; mmb_1 = mode - b_1 ; mpa_1 = mode + a_1 ; s = ( a_ + b_ ) ; pm = ( a_1 + b_1 ) / s ; pr = hr / s ; pmr = pm + pr ; a_setup = a ; b_setup = b ; } for ( ; ; ) { u = randomGenerator . raw ( ) ; v = randomGenerator . raw ( ) ; if ( u <= pm ) { x = mmb_1 + u * s ; if ( Math . log ( v ) <= ( - a * Math . sqrt ( 1.0 + x * x ) + b * x + samb ) ) break ; } else { if ( u <= pmr ) { e = - Math . log ( ( u - pm ) / pr ) ; x = mpa_1 + hr * e ; if ( ( Math . log ( v ) - e ) <= ( - a * Math . sqrt ( 1.0 + x * x ) + b * x + samb ) ) break ; } else { e = Math . log ( ( u - pmr ) / ( 1.0 - pmr ) ) ; x = mmb_1 + hl * e ; if ( ( Math . log ( v ) + e ) <= ( - a * Math . sqrt ( 1.0 + x * x ) + b * x + samb ) ) break ; } } } return ( x ) ; }
returns a hyperbolic distributed random number ; bypasses the internal state .
