private int nextInt(double theMean){
  double xm=theMean;
  double g=this.cached_g;
  if (xm == -1.0)   return 0;
  if (xm < SWITCH_MEAN) {
    int poisson=-1;
    double product=1;
    do {
      poisson++;
      product*=randomGenerator.raw();
    }
 while (product >= g);
    return poisson;
  }
 else   if (xm < MEAN_MAX) {
    double t;
    double em;
    double sq=this.cached_sq;
    double alxm=this.cached_alxm;
    RandomEngine rand=this.randomGenerator;
    do {
      double y;
      do {
        y=Math.tan(Math.PI * rand.raw());
        em=sq * y + xm;
      }
 while (em < 0.0);
      em=(double)(int)(em);
      t=0.9 * (1.0 + y * y) * Math.exp(em * alxm - logGamma(em + 1.0) - g);
    }
 while (rand.raw() > t);
    return (int)em;
  }
 else {
    return (int)xm;
  }
}

private int nextInt ( double theMean ) { double xm = theMean ; double g = this . cached_g ; if ( xm == - 1.0 ) return 0 ; if ( xm < SWITCH_MEAN ) { int poisson = - 1 ; double product = 1 ; do { poisson ++ ; product *= randomGenerator . raw ( ) ; } while ( product >= g ) ; return poisson ; } else if ( xm < MEAN_MAX ) { double t ; double em ; double sq = this . cached_sq ; double alxm = this . cached_alxm ; RandomEngine rand = this . randomGenerator ; do { double y ; do { y = Math . tan ( Math . PI * rand . raw ( ) ) ; em = sq * y + xm ; } while ( em < 0.0 ) ; em = ( double ) ( int ) ( em ) ; t = 0.9 * ( 1.0 + y * y ) * Math . exp ( em * alxm - logGamma ( em + 1.0 ) - g ) ; } while ( rand . raw ( ) > t ) ; return ( int ) em ; } else { return ( int ) xm ; } }
returns a random number from the distribution ; bypasses the internal state .
