Demos and Usage of java.util.Random.nextDouble()


   1: public class RandomDoubles {
   2:   private static Random rand = new Random(47);
   3:         ...
   4:   public double next() { return rand.nextDouble(); }
   5:   public static void main(String[] args) {
   6:     RandomDoubles rd = new RandomDoubles();
   7:     for(int i = 0; i < 7; i ++)

View Full Code Here
   1: package org.apache.commons.math.random;
   2:         ...
   3: import java.util.Random;
   4: 
   5:         ...
   6:     private static final long serialVersionUID = -9161426374178114548L;
   7:     private Random random = new Random();
   8:     
   9:         ...
  10:     public double nextDouble() {
  11:         return random.nextDouble();

View Full Code Here
   1: 
   2: import java.util.Random;
   3: import net.i2p.I2PAppContext;
   4:         ...
   5:     private class DummyRandomSource extends RandomSource {
   6:         private Random _prng;
   7:         public DummyRandomSource(I2PAppContext context) {
   8:         ...
   9:             super(context);
  10:             _prng = new Random();
  11:         }
  12:         ...
  13:         public void nextBytes(byte buf[]) { _prng.nextBytes(buf); }
  14:         public double nextDouble() { return _prng.nextDouble(); }

View Full Code Here
   1: 
   2: import java.util.Random;
   3: 
   4:         ...
   5: 
   6:     private final Random random = new Random(0);
   7: 
   8:         ...
   9:     private boolean getRandom(double probability) {
  10:         return random.nextDouble() < probability;
  11:     }

View Full Code Here
   1: 
   2: import java.util.Random;
   3: import javax.vecmath.Point3d;
   4:         ...
   5:     public void testFit() {
   6:         final Random  rd = new Random(457821698762354L);
   7:         final Plane plan = new Plane();
   8:         ...
   9:         final Point3d P1 = new Point3d(100*rd.nextDouble()+25, 100*rd.nextDouble()+25, Math.rint(100*rd.nextDouble()+40));
  10:         ...
  11:         final Point3d P2 = new Point3d(100*rd.nextDouble()+25, 100*rd.nextDouble()+25, Math.rint(100*rd.nextDouble()+40));

View Full Code Here
   1: import java.util.Date;
   2: import java.util.Random;
   3: 
   4:         ...
   5:    private static final long startTime = System.currentTimeMillis();
   6:    private static final Random rnd = new Random();
   7: 
   8:         ...
   9:    protected static final double random() {
  10:       return rnd.nextDouble();
  11:    }
  12:         ...
  13:    protected static final double random(int ub) {
  14:       return rnd.nextDouble()*ub;

View Full Code Here
   1: import java.util.Date;
   2: import java.util.Random;
   3: import Synchronization.*;
   4:         ...
   5:    private static final long startTime = System.currentTimeMillis();
   6:    private static final Random rnd = new Random();
   7: 
   8:         ...
   9:    protected static final double random() {
  10:       return rnd.nextDouble();
  11:    }
  12:         ...
  13:    protected static final double random(int ub) {
  14:       return rnd.nextDouble()*ub;

View Full Code Here
   1: package de.uniwue.ki.util.math;
   2: import java.util.Random;
   3: 
   4:         ...
   5: public final class RandomDistributionHelper implements IRandomWrapper {
   6:     private final Random _random;
   7: 
   8:         ...
   9:     public RandomDistributionHelper(Random random) {
  10:         super();
  11:         ...
  12:     public synchronized double nextDouble() {
  13:         return _random.nextDouble();

View Full Code Here
   1: 
   2:         Random random = new Random();   
   3: 
   4:         ...
   5:         {
   6:             length = GridSimStandardPE.toMIs(random.nextDouble()*output_size);
   7: 
   8:         ...
   9:             file_size = (long) GridSimRandom.real(100, min_range, max_range, 
  10:                                     random.nextDouble());
  11: 
  12:         ...
  13:             output_size = (long) GridSimRandom.real(250, min_range, max_range,
  14:                                     random.nextDouble());

View Full Code Here
   1: import java.awt.geom.Point2D;
   2: import java.util.Random;
   3: 
   4:         ...
   5:     public void testPlaneFit() {
   6:         final Random  rd = new Random(457821698762354L);
   7:         final Plane plan = new Plane();
   8:         ...
   9:         final Point3d P1 = new Point3d(100*rd.nextDouble()+25, 100*rd.nextDouble()+25, Math.rint(100*rd.nextDouble()+40));
  10:         ...
  11:         final Point3d P2 = new Point3d(100*rd.nextDouble()+25, 100*rd.nextDouble()+25, Math.rint(100*rd.nextDouble()+40));

View Full Code Here
   1: import java.io.UnsupportedEncodingException;
   2: import java.util.Random;
   3: 
   4:         ...
   5:     private EntryBinding dataBinding = null;
   6:     private Random generator = new Random();
   7:     private boolean passTxn = false;
   8:         ...
   9:                         PayloadData pd = new PayloadData(i+j, getName(), 
  10:                             generator.nextDouble());
  11:                         DatabaseEntry data = new DatabaseEntry();

View Full Code Here
   1: 
   2:   private Random rand;
   3: 
   4:         ...
   5: 
   6:     rand = new Random();
   7: 
   8:         ...
   9:   {
  10:     float x = (float)((rand.nextDouble() * floorLen)-floorLen/2);
  11:         ...
  12:     float z = (float)((rand.nextDouble() * floorLen)-floorLen/2);

View Full Code Here
   1:         long seed = 11L*13*17*19*23+1;
   2:         Random random = new Random(seed);
   3: 
   4:         ...
   5:         {
   6:             length = GridSimStandardPE.toMIs(random.nextDouble()*50);
   7: 
   8:         ...
   9:             file_size = (long) GridSimRandom.real(100, 0.10, 0.40,
  10:                                     random.nextDouble());
  11: 
  12:         ...
  13:             output_size = (long) GridSimRandom.real(250, 0.10, 0.50,
  14:                                     random.nextDouble());

View Full Code Here
   1:   private Cells cells;
   2:   private Random random;
   3:   
   4:         ...
   5:     cells = new Cells();
   6:     random = new FastRandom(0);
   7:   }
   8:         ...
   9:     random.setSeed(id[0]);
  10:     random.nextDouble();
  11:         ...
  12:     cell = random.nextDouble();

View Full Code Here
   1:   }
   2:   private static Random r = new Random();
   3:   public static class RandBooleanGenerator 
   4:         ...
   5:   implements DoubleGenerator {
   6:     public double next() {return r.nextDouble();}
   7:   }

View Full Code Here