public static double nextErlang(double variance,double mean,RandomEngine randomGenerator){
  int k=(int)((mean * mean) / variance + 0.5);
  k=(k > 0) ? k : 1;
  double a=k / mean;
  double prod=1.0;
  for (int i=0; i < k; i++)   prod*=randomGenerator.raw();
  return -Math.log(prod) / a;
}

public static double nextErlang ( double variance , double mean , RandomEngine randomGenerator ) { int k = ( int ) ( ( mean * mean ) / variance + 0.5 ) ; k = ( k > 0 ) ? k : 1 ; double a = k / mean ; double prod = 1.0 ; for ( int i = 0 ; i < k ; i ++ ) prod *= randomGenerator . raw ( ) ; return - Math . log ( prod ) / a ; }
returns an erlang distributed random number with the given variance and mean .
