Package java.util

Examples of java.util.Random.nextDouble()


            int totalListenersFailures = 0;

            Random random = new Random(42);
            ExaminedListener[] examinedListeners = new ExaminedListener[1000];
            for (int i = 0; i < examinedListeners.length; ++i) {
                boolean fail = random.nextDouble() >= 0.5d;
                if (fail) {
                    ++totalListenersFailures;
                }
                examinedListeners[i] = new ExaminedListener(fail);
            }
View Full Code Here


      writer.addRow(new DoubleRow(values[i]));
    }

    // The second compression block is random doubles
    for (int i = 0; i < 32768; i++) {
      values[i + 32768] = rand.nextDouble();
      writer.addRow(new DoubleRow(values[i + 32768]));
    }

    // The third compression block is all 0's
    // (important so it compresses to the same size as the first)
View Full Code Here

      writer.addRow(new DoubleRow(values[i + 32768 + 32768]));
    }

    // The fourth compression block is random
    for (int i = 0; i < 32768; i++) {
      values[i + 32768 + 32768 + 32768] = rand.nextDouble();
      writer.addRow(new DoubleRow(values[i + 32768 + 32768 + 32768]));
    }

    writer.close();
    OrcConf.setIntVar(conf, OrcConf.ConfVars.HIVE_ORC_READ_COMPRESSION_STRIDES, 2);
View Full Code Here

      intValues[2*i+1] = rand.nextLong();
      stringValues[2*i] = words[rand.nextInt(words.length)];
      stringValues[2*i+1] = words[rand.nextInt(words.length)];
    }
    for(int i=0; i < count; ++i) {
      doubleValues[i] = rand.nextDouble();
      byte[] buf = new byte[20];
      rand.nextBytes(buf);
      byteValues[i] = new BytesWritable(buf);
    }
    for(int i=0; i < count; ++i) {
View Full Code Here

      intValues[2*i+1] = rand.nextLong();
      stringValues[2*i] = words[rand.nextInt(words.length)];
      stringValues[2*i+1] = words[rand.nextInt(words.length)];
    }
    for(int i=0; i < count; ++i) {
      doubleValues[i] = rand.nextDouble();
      byte[] buf = new byte[20];
      rand.nextBytes(buf);
      byteValues[i] = new BytesWritable(buf);
    }
    for(int i=0; i < count; ++i) {
View Full Code Here

             * First random determines +/-, second random determines how far to
             * go in that direction. -cgs
             */
            Random random = getRandomNumberGenerator();
            double variance = (random.nextBoolean() ? collisionAvoidanceFactor : -collisionAvoidanceFactor)
                              * random.nextDouble();
            redeliveryDelayResult += redeliveryDelayResult * variance;
        }

        // ensure the calculated result is not bigger than the max delay (if configured)
        if (maximumRedeliveryDelay > 0 && redeliveryDelayResult > maximumRedeliveryDelay) {
View Full Code Here

          if (game.player.dead) offs = 0.5;
          for (int i = 0; i < pixels.length; i++) {
            double xp = ((i % width) - viewport.width / 2.0) / width * 2;
            double yp = ((i / width) - viewport.height / 2.0) / viewport.height * 2;

            if (random.nextDouble() + offs < Math.sqrt(xp * xp + yp * yp)) pixels[i] = (random.nextInt(5) / 4) * 0x550000;
          }
        }
      }

      draw(Art.panel, 0, height - PANEL_HEIGHT, 0, 0, width, PANEL_HEIGHT, Art.getCol(0x707070));
View Full Code Here

                double shearX = 0.0;
                double shearY = 0.0;
                if (config.getTextShear() > 0.0)
                {
                    Random ran = new Random();
                    shearX = ran.nextDouble() * config.getTextShear();
                    shearY = ran.nextDouble() * config.getTextShear();
                }
                CharAttributes cf = new CharAttributes(chars[i], fontName, dRotation, rise, shearX, shearY);
                charAttsList.add(cf);
                text = new TextLayout(chars[i] + "", getFont(fontName),
View Full Code Here

                double shearY = 0.0;
                if (config.getTextShear() > 0.0)
                {
                    Random ran = new Random();
                    shearX = ran.nextDouble() * config.getTextShear();
                    shearY = ran.nextDouble() * config.getTextShear();
                }
                CharAttributes cf = new CharAttributes(chars[i], fontName, dRotation, rise, shearX, shearY);
                charAttsList.add(cf);
                text = new TextLayout(chars[i] + "", getFont(fontName),
                        new FontRenderContext(null, config.isFontAntialiasing(), false));
View Full Code Here

    private static double[] createRealData(final int n) {
        final Random random = new Random(SEED);
        final double[] data = new double[n];
        for (int i = 0; i < n; i++) {
            data[i] = 2.0 * random.nextDouble() - 1.0;
        }
        return data;
    }

    /** Naive implementation of DFT, for reference. */
 
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.