RandomEngine engine = new DRand(); Poisson poisson = new Poisson(lambda, engine); int poissonObs = poisson.nextInt(); Normal normal = new Normal(mean, variance, engine); double normalObs = normal.nextDouble();
/** * Constructs and returns a random number generator with the given seed. * @param seed should not be 0, in such a case <tt>DRand.DEFAULT_SEED</tt> is substituted. */ public DRand(int seed) { setSeed(seed); } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); float tmpElement; float[] 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; } } /**
/** * Constructs and returns a random number generator with the given seed. * @param seed should not be 0, in such a case <tt>DRand.DEFAULT_SEED</tt> is substituted. */ public DRand(int seed) { setSeed(seed); } /**
/** * 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.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.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; } } /**
/** * Constructs and returns a random number generator with the given seed. * * @param seed * should not be 0, in such a case <tt>DRand.DEFAULT_SEED</tt> is * substituted. */ public DRand(int seed) { setSeed(seed); }
/** * 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) { // overridden for performance only. if (size==0) return; checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); long tmpElement; long[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); float tmpElement; float[] 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; } } /**
/** * 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.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); byte tmpElement; byte[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); int tmpElement; int[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) return; checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); long tmpElement; long[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); boolean tmpElement; boolean[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); char tmpElement; char[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); short tmpElement; short[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); byte tmpElement; byte[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); int tmpElement; int[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); char tmpElement; char[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); double tmpElement; double[] 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; } } /**
/** * 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) { // overridden for performance only. if (size==0) {return;} checkRangeFromTo(from, to, size); cern.jet.random.Uniform gen = new cern.jet.random.Uniform(new cern.jet.random.engine.DRand(new java.util.Date())); short tmpElement; short[] 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; } } /**