Package java.util

Examples of java.util.Random.nextDouble()


    Stopwatch.p();
    SparseMatrix A = Matrix.sparse(4000, 10000);
    Random rand = new Random(1);
    for (int i = 0; i < A.rowCount(); i++) {
      for (int j = 0; j < A.columnCount(); j++) {
        if (rand.nextDouble() > 0.2) continue;
        A.put(i, j, rand.nextDouble() * 23);
      }
    }
    SingularValues singular = new SingularValues(A, 10).decompose();
    Stopwatch.p();
View Full Code Here


    SparseMatrix A = Matrix.sparse(4000, 10000);
    Random rand = new Random(1);
    for (int i = 0; i < A.rowCount(); i++) {
      for (int j = 0; j < A.columnCount(); j++) {
        if (rand.nextDouble() > 0.2) continue;
        A.put(i, j, rand.nextDouble() * 23);
      }
    }
    SingularValues singular = new SingularValues(A, 10).decompose();
    Stopwatch.p();
    Out.puts(singular.value);
View Full Code Here

    managerUnderTest.addStrategy(mockedStrategy1, 0.2);
    managerUnderTest.addStrategy(mockedStrategy2, 0.8);
   
    Random mockedRandom = mock(Random.class);
    managerUnderTest.setRandom(mockedRandom);
    stub(mockedRandom.nextDouble()).toReturn(0.1);
   
    assertThat(managerUnderTest.getRandomStrategy(), is(mockedStrategy1));
   
  }
 
View Full Code Here

    managerUnderTest.addStrategy(mockedStrategy1, 0.2);
    managerUnderTest.addStrategy(mockedStrategy2, 0.8);
   
    Random mockedRandom = mock(Random.class);
    managerUnderTest.setRandom(mockedRandom);
    when(mockedRandom.nextDouble()).thenReturn(0.5);
   
    assertThat(managerUnderTest.getRandomStrategy(), is(mockedStrategy2));
   
  }
 
View Full Code Here

    managerUnderTest.addStrategy(mockedStrategy1, 0.2);
    managerUnderTest.addStrategy(mockedStrategy2, 0.8);
   
    Random mockedRandom = mock(Random.class);
    managerUnderTest.setRandom(mockedRandom);
    when(mockedRandom.nextDouble()).thenReturn(0.0);
   
    assertThat(managerUnderTest.getRandomStrategy(), is(mockedStrategy1));
   
  }
 
View Full Code Here

    public void fillRandoms() {
        Random random = new Random();
        for (int i = 0; i < TOTAL_RECORDS; i++) {
            for (int j = 0; j < NUM_ENTRIES_PER_RECORD; j++) {
                RANDOM_LONGS[i][j] = random.nextLong();
                RANDOM_DOUBLES[i][j] = random.nextDouble() * 1e10;
            }
            RANDOM_LONGS[i][0] = Long.MIN_VALUE;
            RANDOM_LONGS[i][1] = Long.MAX_VALUE;
            RANDOM_LONGS[i][2] = 0;
            RANDOM_DOUBLES[i][0] = 0;
View Full Code Here

          continue;
        }
       
        for (int i = 0; i < POINTS_PER_BOX; ++i) {
         
          double x = box.minX + boxSize * rand.nextDouble();
          double z = box.minZ + boxSize * rand.nextDouble();
         
          VectorXZ v = new VectorXZ(x, z);
         
          if (polygonWithHolesXZ.contains(v)) {
View Full Code Here

        }
       
        for (int i = 0; i < POINTS_PER_BOX; ++i) {
         
          double x = box.minX + boxSize * rand.nextDouble();
          double z = box.minZ + boxSize * rand.nextDouble();
         
          VectorXZ v = new VectorXZ(x, z);
         
          if (polygonWithHolesXZ.contains(v)) {
           
View Full Code Here

                // Write a new event. The minimum that you must set on an event is the stanza it is supposed to
                // go to (which you can skip if your modular input is not single instance, and the data of the
                // event.
                Event event = new Event();
                event.setStanza(inputName);
                event.setData("number=" + (randomGenerator.nextDouble() * (max - min) + min));

                try {
                    ew.writeEvent(event);
                } catch (MalformedDataException e) {
                    ew.synchronizedLog(EventWriter.ERROR, "MalformedDataException in writing event to input" +
View Full Code Here

        String msg;
        for(String func: mathFuncs) {
            evalFunc = (EvalFunc<Double>) Class.forName(udfPackage + func).newInstance();
            tup = TupleFactory.getInstance().newTuple(1);
            // double value between 0.0 and 1.0
            input = generator.nextDouble();
            tup.set(0, input);
            mathMethod = Math.class.getDeclaredMethod(func.toLowerCase(), double.class);
            actual = evalFunc.exec(tup);
            expected = (Double)mathMethod.invoke(null, input);
            msg = "[Testing " + func + " on input: " + input + " ( (actual) " + actual + " == " + expected + " (expected) )]";
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.