public double nextDouble(double a){
  double u, v, p, q;
  int k;
  if (a != a_prev) {
    a_prev=a;
    if (a < 0.97)     t=-a / Math.log(1.0 - a);
 else     h=Math.log(1.0 - a);
  }
  u=randomGenerator.raw();
  if (a < 0.97) {
    k=1;
    p=t;
    while (u > p) {
      u-=p;
      k++;
      p*=a * (k - 1.0) / (double)k;
    }
    return k;
  }
  if (u > a)   return 1;
  u=randomGenerator.raw();
  v=u;
  q=1.0 - Math.exp(v * h);
  if (u <= q * q) {
    k=(int)(1 + Math.log(u) / Math.log(q));
    return k;
  }
  if (u > q)   return 1;
  return 2;
}

public double nextDouble ( double a ) { double u , v , p , q ; int k ; if ( a != a_prev ) { a_prev = a ; if ( a < 0.97 ) t = - a / Math . log ( 1.0 - a ) ; else h = Math . log ( 1.0 - a ) ; } u = randomGenerator . raw ( ) ; if ( a < 0.97 ) { k = 1 ; p = t ; while ( u > p ) { u -= p ; k ++ ; p *= a * ( k - 1.0 ) / ( double ) k ; } return k ; } if ( u > a ) return 1 ; u = randomGenerator . raw ( ) ; v = u ; q = 1.0 - Math . exp ( v * h ) ; if ( u <= q * q ) { k = ( int ) ( 1 + Math . log ( u ) / Math . log ( q ) ) ; return k ; } if ( u > q ) return 1 ; return 2 ; }
returns a random number from the distribution ; bypasses the internal state .
