/** * Constructs a poisson distribution. Example: mean=1.0. */ public PoissonSlow(double mean, DoubleRandomEngine randomGenerator) { setRandomGenerator(randomGenerator); setMean(mean); }
/** * Sets the mean. */ public void setMean(double mean) { if (mean != this.mean) { this.mean = mean; if (mean == -1.0) return; // not defined if (mean < SWITCH_MEAN) { this.cached_g = Math.exp(-mean); } else { this.cached_sq = Math.sqrt(2.0 * mean); this.cached_alxm = Math.log(mean); this.cached_g = mean * cached_alxm - logGamma(mean + 1.0); } } }
/** * Returns a random number from the distribution. */ public int nextInt() { return nextInt(this.mean); }
/** * Sets the uniform random number generated shared by all <b>static</b> * methods. * * @param randomGenerator * the new uniform random number generator to be shared. */ private static void xstaticSetRandomGenerator(DoubleRandomEngine randomGenerator) { synchronized (shared) { shared.setRandomGenerator(randomGenerator); } } }
/** * Sets the mean. */ public void setMean(double mean) { if (mean != this.mean) { this.mean = mean; if (mean == -1.0) return; // not defined if (mean < SWITCH_MEAN) { this.cached_g = Math.exp(-mean); } else { this.cached_sq = Math.sqrt(2.0 * mean); this.cached_alxm = Math.log(mean); this.cached_g = mean * cached_alxm - logGamma(mean + 1.0); } } }
/** * Returns a random number from the distribution. */ public int nextInt() { return nextInt(this.mean); }
/** * Sets the uniform random number generated shared by all <b>static</b> * methods. * * @param randomGenerator * the new uniform random number generator to be shared. */ private static void xstaticSetRandomGenerator(DoubleRandomEngine randomGenerator) { synchronized (shared) { shared.setRandomGenerator(randomGenerator); } } }
/** * Constructs a poisson distribution. Example: mean=1.0. */ public PoissonSlow(double mean, DoubleRandomEngine randomGenerator) { setRandomGenerator(randomGenerator); setMean(mean); }
em = (int) (em); // faster than em = Math.floor(em); t = 0.9 * (1.0 + y * y) * Math.exp(em * alxm - logGamma(em + 1.0) - g); } while (rand.raw() > t); return (int) em;
em = (int) (em); // faster than em = Math.floor(em); t = 0.9 * (1.0 + y * y) * Math.exp(em * alxm - logGamma(em + 1.0) - g); } while (rand.raw() > t); return (int) em;