Package org.apache.commons.math3.random

Examples of org.apache.commons.math3.random.RandomGenerator.nextDouble()


        final UnivariateDifferentiableFunction id =
                FunctionUtils.compose((UnivariateDifferentiableFunction) g, (UnivariateDifferentiableFunction) f);
        for (int maxOrder = 0; maxOrder < 6; ++maxOrder) {
            double max = 0;
            for (int i = 0; i < 10; i++) {
                final double x = lo + random.nextDouble() * (hi - lo);
                final DerivativeStructure dsX = new DerivativeStructure(1, maxOrder, 0, x);
                max = FastMath.max(max, FastMath.abs(dsX.getPartialDerivative(maxOrder) -
                                                     id.value(dsX).getPartialDerivative(maxOrder)));
                Assert.assertEquals(dsX.getPartialDerivative(maxOrder),
                                    id.value(dsX).getPartialDerivative(maxOrder),
View Full Code Here


        // Assume model has 16 observations (will use Longley data).  Start by generating
        // non-constant variances for the 16 error terms.
        final int nObs = 16;
        double[] sigma = new double[nObs];
        for (int i = 0; i < nObs; i++) {
            sigma[i] = 10 * rg.nextDouble();
        }
       
        // Now generate 1000 error vectors to use to estimate the covariance matrix
        // Columns are draws on N(0, sigma[col])
        final int numSeeds = 1000;
View Full Code Here

    simulator.addTickListener(new TickListener() {
      @Override
      public void tick(TimeLapse time) {
        if (time.getStartTime() > endTime) {
          simulator.stop();
        } else if (rng.nextDouble() < .007) {
          simulator.register(new Customer(
              roadModel.getRandomPosition(rng), roadModel
                  .getRandomPosition(rng), SERVICE_DURATION, SERVICE_DURATION,
              1 + rng.nextInt(3)));
        }
View Full Code Here

      final List<Double> newTs = newArrayList();
      for (final double l : ts) {
        newTs.add(l);
        newTs.add(Math.min(999, Math.max(0, l
            + DoubleMath.roundToLong((rng.nextDouble() * 6d) - 3d,
                RoundingMode.HALF_EVEN))));
      }
      times.add(asTimesDouble(1000, newTs));
    }

View Full Code Here

      final List<Double> newTs = newArrayList();
      System.out.println("num events: " + ts.size());
      for (final double l : ts) {
        newTs.add(l);
        newTs.add(Math.min(999, Math.max(0, l
            + DoubleMath.roundToLong((rng.nextDouble() * 2d) - 1d,
                RoundingMode.HALF_EVEN))));
        newTs.add(Math.min(999, Math.max(0, l
            + DoubleMath.roundToLong((rng.nextDouble() * 2d) - 1d,
                RoundingMode.HALF_EVEN))));
      }
View Full Code Here

        newTs.add(l);
        newTs.add(Math.min(999, Math.max(0, l
            + DoubleMath.roundToLong((rng.nextDouble() * 2d) - 1d,
                RoundingMode.HALF_EVEN))));
        newTs.add(Math.min(999, Math.max(0, l
            + DoubleMath.roundToLong((rng.nextDouble() * 2d) - 1d,
                RoundingMode.HALF_EVEN))));
      }
      times.add(asTimesDouble(1000, newTs));
    }

View Full Code Here

      final List<Double> additions = newArrayList();
      for (int i = 0; i < ts.size(); i++) {

        if (i % 3 == 0) {
          for (int j = 0; j < k; j++) {
            additions.add(ts.get(i) + (rng.nextDouble() * 10));
          }
        }
      }
      ts.addAll(additions);
      Collections.sort(ts);
View Full Code Here

    for (final int events : numEvents) {
      // repetitions
      for (int j = 0; j < repetitions; j++) {
        final List<Double> scenario = newArrayList();
        for (int i = 0; i < events; i++) {
          scenario.add(rng.nextDouble() * startLengthOfDay);
        }
        Collections.sort(scenario);
        double dod = -1;
        for (final double dayLength : lengthsOfDay) {
          final List<Double> cur = newArrayList();
View Full Code Here

    for (final int num : numEvents) {
      for (int j = 0; j < repetitions; j++) {
        final List<Double> scenario = newArrayList();
        for (int i = 0; i < num; i++) {
          scenario.add(rng.nextDouble() * lengthOfDay);
        }
        Collections.sort(scenario);

        final double curDod = measureDynamism(scenario, lengthOfDay);

View Full Code Here

        depotLocation, endTime, serviceTime, 30, vehicleSpeed);
    final RandomGenerator rng = new MersenneTwister(123);
    for (int i = 0; i < 10000; i++) {
      final Point p1 = new Point(6, 6);
      final Point p2 = new Point(4, 4);
      final List<TimeWindow> tws = twg.generate(DoubleMath.roundToLong(rng
          .nextDouble() * 120, RoundingMode.HALF_DOWN), p1, p2, rng);
      assertTrue(tws.toString(), tws.get(0).end <= tws.get(1).end
          + travelTime(p1, p2, vehicleSpeed) + serviceTime);
      assertTrue(tws.toString() + " tt: " + travelTime(p1, p2, vehicleSpeed), tws.get(0).begin
          + travelTime(p1, p2, vehicleSpeed) + serviceTime <= tws.get(1).begin);
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.