/** * Constructs a mean-squared BreitWigner distribution. * * @param cut * </tt>cut==Double.NEGATIVE_INFINITY</tt> indicates "don't cut". */ public BreitWignerMeanSquare(double mean, double gamma, double cut, DoubleRandomEngine randomGenerator) { super(mean, gamma, cut, randomGenerator); this.uniform = new DoubleUniform(randomGenerator); }
/** * Returns a uniformly distributed random <tt>boolean</tt>. */ public static boolean staticNextBoolean() { synchronized (shared) { return shared.nextBoolean(); } }
/** * Returns a uniformly distributed random number in the open interval * <tt>(0,1)</tt> (excluding <tt>0</tt> and <tt>1</tt>). */ public static double staticNextDouble() { synchronized (shared) { return shared.nextDouble(); } }
/** * Constructs a uniform distribution with the given minimum and maximum. */ public DoubleUniform(double min, double max, DoubleRandomEngine randomGenerator) { setRandomGenerator(randomGenerator); setState(min, max); }
return from + (long) (nextDoubleFromTo(0.0, to - from + 1)); return from + (long) (nextDoubleFromTo(0.0, diff)); if (to == Long.MAX_VALUE) { int i1 = nextIntFromTo(Integer.MIN_VALUE, Integer.MAX_VALUE); int i2 = nextIntFromTo(Integer.MIN_VALUE, Integer.MAX_VALUE); 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;
/** * Randomly permutes the part of the receiver between <code>from</code> * (inclusive) and <code>to</code> (inclusive). * * @param from * the index of the first element (inclusive) to be permuted. * @param to * the index of the last element (inclusive) to be permuted. * @exception IndexOutOfBoundsException * index is out of range ( * <tt>size()>0 && (from<0 || from>to || to>=size())</tt> * ). */ public void shuffleFromTo(int from, int to) { if (size == 0) return; checkRangeFromTo(from, to, size); cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); Object tmpElement; Object[] theElements = elements; int random; for (int i = from; i < to; i++) { random = gen.nextIntFromTo(i, to); // swap(i, random) tmpElement = theElements[random]; theElements[random] = theElements[i]; theElements[i] = tmpElement; } }
/** * Returns a uniformly distributed random number in the closed interval * <tt>[from,to]</tt> (including <tt>from</tt> and <tt>to</tt>). Pre * conditions: <tt>from <= to</tt>. */ public static int staticNextIntFromTo(int from, int to) { synchronized (shared) { return shared.nextIntFromTo(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); } }
/** * Sets the internal state. */ public void setState(double min, double max) { if (max < min) { setState(max, min); return; } this.min = min; this.max = max; }
/** * Returns a deep copy of the receiver. */ public Object clone() { WeightedDoubleRandomSampler copy = (WeightedDoubleRandomSampler) super.clone(); copy.generator = (DoubleUniform) this.generator.clone(); return copy; }
/** * 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 float staticNextFloatFromTo(float from, float to) { synchronized (shared) { return shared.nextFloatFromTo(from, to); } }
/** * Returns a uniformly distributed random number in the closed interval * <tt>[from,to]</tt> (including <tt>from</tt> and <tt>to</tt>). Pre * conditions: <tt>from <= to</tt>. */ public static long staticNextLongFromTo(long from, long to) { synchronized (shared) { return shared.nextLongFromTo(from, to); } }
/** * Sets the uniform random number generation engine shared by all * <b>static</b> methods. * * @param randomGenerator * the new uniform random number generation engine to be shared. */ public static void staticSetRandomEngine(DoubleRandomEngine randomGenerator) { synchronized (shared) { shared.setRandomGenerator(randomGenerator); } }
cern.jet.random.tdouble.DoubleUniform gen = new cern.jet.random.tdouble.DoubleUniform( new cern.jet.random.tdouble.engine.DRand(new java.util.Date())); char tmpElement; int random; for (int i = from; i < to; i++) { random = gen.nextIntFromTo(i, to);
/** * Returns a uniformly distributed random number in the closed interval * <tt>[from,to]</tt> (including <tt>from</tt> and <tt>to</tt>). Pre * conditions: <tt>from <= to</tt>. */ public static int staticNextIntFromTo(int from, int to) { synchronized (shared) { return shared.nextIntFromTo(from, to); } }
/** * Constructs a uniform distribution with the given minimum and maximum. */ public DoubleUniform(double min, double max, DoubleRandomEngine randomGenerator) { setRandomGenerator(randomGenerator); setState(min, max); }
return from + (long) (nextDoubleFromTo(0.0, to - from + 1)); return from + (long) (nextDoubleFromTo(0.0, diff)); if (to == Long.MAX_VALUE) { int i1 = nextIntFromTo(Integer.MIN_VALUE, Integer.MAX_VALUE); int i2 = nextIntFromTo(Integer.MIN_VALUE, Integer.MAX_VALUE); 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;
/** * 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); }
/** * Sets the internal state. */ public void setState(double min, double max) { if (max < min) { setState(max, min); return; } this.min = min; this.max = max; }
/** * Returns a deep copy of the receiver. */ public Object clone() { WeightedDoubleRandomSampler copy = (WeightedDoubleRandomSampler) super.clone(); copy.generator = (DoubleUniform) this.generator.clone(); return copy; }