Package java.util

Examples of java.util.Random.nextGaussian()


            private Random rand = new Random();
           
            @Override
            public void actuate(AbstractEnvironment2D<AbstractAgent2D<?>> env, AbstractAgent2D<?> agent) {
                this.left += rand.nextGaussian() / 10;
                this.right += rand.nextGaussian() / 10;
               
                this.left *= 0.998;
                this.right *= 0.998;
               
                if (rand.nextDouble() < 0.15) {
View Full Code Here


            runnable.addCollidingAgent(agent, pos, rand.nextDouble() * 360, new Vector2D(agentSize, agentSize));
        }

        startSize = runnable.getAgents().size();
        while (runnable.getAgents().size() < params.getParValueInt("NumberOfInjured") + startSize) {
            Vector2D pos = new Vector2D(rand.nextGaussian(), rand.nextGaussian());
            AbstractDesasterAgent agent = new InjuredAgent(runnable.getAgents().size(), runnable, params, rand);
            agent.implantBrain(new RescueBrain(agent));
            runnable.addCollidingAgent(agent, pos, rand.nextDouble() * 360, new Vector2D(agentSize, agentSize));
        }
       
View Full Code Here

            runnable.addCollidingAgent(agent, pos, rand.nextDouble() * 360, new Vector2D(agentSize, agentSize));
        }

        startSize = runnable.getAgents().size();
        while (runnable.getAgents().size() < params.getParValueInt("NumberOfInjured") + startSize) {
            Vector2D pos = new Vector2D(rand.nextGaussian(), rand.nextGaussian());
            AbstractDesasterAgent agent = new InjuredAgent(runnable.getAgents().size(), runnable, params, rand);
            agent.implantBrain(new RescueBrain(agent));
            runnable.addCollidingAgent(agent, pos, rand.nextDouble() * 360, new Vector2D(agentSize, agentSize));
        }
       
View Full Code Here

    @Test
    public void testGaussian() {
        final Random random = new Random(317780561); // See class javadoc.
        final Statistics statistics = new Statistics(null);
        for (int i=0; i<10000; i++) {
            statistics.accept(random.nextGaussian());
        }
        assertEquals(0, statistics.countNaN());
        assertEquals(10000, statistics.count());
        assertEquals(0, statistics.mean(), 0.01);
        assertEquals(1, statistics.rms (), 0.01);
View Full Code Here

            for (int j=0; j<1000; j++) {
                final double value;
                if (random.nextInt(800) == 0) {
                    value = Double.NaN;
                } else {
                    value = random.nextGaussian() + 10*random.nextDouble();
                }
                global.accept(value);
                block.accept(value);
            }
            byBlock.combine(block);
View Full Code Here

        double nz = Math.round(avgNZero * (rnd.nextGaussian() + 1));
        if (nz < 0) {
          nz = 0;
        }
        for (int j = 1; j < nz; j++) {
          vector.set(rnd.nextInt(n), rnd.nextGaussian() * 25 + 3);
        }
        iw.set(i);
        vw.set(vector);
        w.append(iw, vw);
      }
View Full Code Here

      VectorWritable vw = new VectorWritable();
      int avgNZero = 40;
      int n = 4500000;
      for (int i = 1; i < n; i++) {
        Vector vector = new RandomAccessSparseVector(n);
        double nz = Math.round(avgNZero * (rnd.nextGaussian() + 1));
        if (nz < 0) {
          nz = 0;
        }
        for (int j = 1; j < nz; j++) {
          vector.set(rnd.nextInt(n), rnd.nextGaussian() * 25 + 3);
View Full Code Here

    Random r = RandomUtils.getRandom();
    for (int i = 0; i < nonNullRows; i++) {
      Vector v = new SequentialAccessSparseVector(numCols);
      for (int j = 0; j < entriesPerRow; j++) {
        int col = r.nextInt(numCols);
        double val = r.nextGaussian();
        v.set(col, val * entryMean);
      }
      int c = r.nextInt(numRows);
      if (r.nextBoolean() || numRows == nonNullRows) {
        m.assignRow(numRows == nonNullRows ? i : c, v);
View Full Code Here

    // TODO rejigger tests so that it doesn't expect this particular seed
    Random r = new Random(1234L);
    for(int row = 0; row < numRows; row++) {
      Vector v = new DenseVector(numCols);
      for(int col = 0; col < numCols; col++) {
        double val = r.nextGaussian();
        v.set(col, val);
      }
      v.assign(Functions.MULT, 1/((row + 1) * v.norm(2)));
      matrix.assignRow(row, v);
    }
View Full Code Here

    Random gen = RandomUtils.getRandom();
    for (int row = 0; row < test.rowSize(); row++) {
      int j = gen.nextInt(test.columnSize());
      double old = test.get(row, j);
      double v = gen.nextGaussian();
      test.viewRow(row).set(j, v);
      assertEquals(v, test.get(row, j), 0);
      assertEquals(v, test.viewRow(row).get(j), 0);
      test.set(row, j, old);
      assertEquals(old, test.get(row, j), 0);
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.