/** * Returns a uniformly distributed random number in the open interval * <tt>(from,to)</tt> (excluding <tt>from</tt> and <tt>to</tt>). Pre * conditions: <tt>from <= to</tt>. */ public static double staticNextDoubleFromTo(double from, double to) { synchronized (shared) { return shared.nextDoubleFromTo(from, to); } }
/** * Returns a uniformly distributed random number in the open interval * <tt>(from,to)</tt> (excluding <tt>from</tt> and <tt>to</tt>). Pre * conditions: <tt>from <= to</tt>. */ public static double staticNextDoubleFromTo(double from, double to) { synchronized (shared) { return shared.nextDoubleFromTo(from, to); } }
/** * Returns a uniformly distributed random number in the open interval * <tt>(from,to)</tt> (excluding <tt>from</tt> and <tt>to</tt>). Pre * conditions: <tt>from <= to</tt>. */ public float nextFloatFromTo(float from, float to) { return (float) nextDoubleFromTo(from, to); }
/** * Returns a uniformly distributed random number in the open interval * <tt>(from,to)</tt> (excluding <tt>from</tt> and <tt>to</tt>). Pre * conditions: <tt>from <= to</tt>. */ public float nextFloatFromTo(float from, float to) { return (float) nextDoubleFromTo(from, to); }
/** * Returns a mean-squared random number from the distribution; bypasses the * internal state. * * @param cut * </tt>cut==Double.NEGATIVE_INFINITY</tt> indicates "don't cut". */ public double nextDouble(double mean, double gamma, double cut) { if (gamma == 0.0) return mean; if (cut == Double.NEGATIVE_INFINITY) { // don't cut double val = Math.atan(-mean / gamma); double rval = this.uniform.nextDoubleFromTo(val, Math.PI / 2.0); double displ = gamma * Math.tan(rval); return Math.sqrt(mean * mean + mean * displ); } else { double tmp = Math.max(0.0, mean - cut); double lower = Math.atan((tmp * tmp - mean * mean) / (mean * gamma)); double upper = Math.atan(((mean + cut) * (mean + cut) - mean * mean) / (mean * gamma)); double rval = this.uniform.nextDoubleFromTo(lower, upper); double displ = gamma * Math.tan(rval); return Math.sqrt(Math.max(0.0, mean * mean + mean * displ)); } }
/** * Returns a mean-squared random number from the distribution; bypasses the * internal state. * * @param cut * </tt>cut==Double.NEGATIVE_INFINITY</tt> indicates "don't cut". */ public double nextDouble(double mean, double gamma, double cut) { if (gamma == 0.0) return mean; if (cut == Double.NEGATIVE_INFINITY) { // don't cut double val = Math.atan(-mean / gamma); double rval = this.uniform.nextDoubleFromTo(val, Math.PI / 2.0); double displ = gamma * Math.tan(rval); return Math.sqrt(mean * mean + mean * displ); } else { double tmp = Math.max(0.0, mean - cut); double lower = Math.atan((tmp * tmp - mean * mean) / (mean * gamma)); double upper = Math.atan(((mean + cut) * (mean + cut) - mean * mean) / (mean * gamma)); double rval = this.uniform.nextDoubleFromTo(lower, upper); double displ = gamma * Math.tan(rval); return Math.sqrt(Math.max(0.0, mean * mean + mean * displ)); } }
return from + (long) (nextDoubleFromTo(0.0, to - from + 1)); return from + (long) (nextDoubleFromTo(0.0, diff)); return ((i1 & 0xFFFFFFFFL) << 32) | (i2 & 0xFFFFFFFFL); random = Math.round(nextDoubleFromTo(from, to + 1)); if (random > to) random = from; } else { random = Math.round(nextDoubleFromTo(from - 1, to)); if (random < from) random = to;
return from + (long) (nextDoubleFromTo(0.0, to - from + 1)); return from + (long) (nextDoubleFromTo(0.0, diff)); return ((i1 & 0xFFFFFFFFL) << 32) | (i2 & 0xFFFFFFFFL); random = Math.round(nextDoubleFromTo(from, to + 1)); if (random > to) random = from; } else { random = Math.round(nextDoubleFromTo(from - 1, to)); if (random < from) random = to;