ReplayablePseudoRandom { public float nextFloat() { int randMax = Integer.MAX_VALUE; return (float) (this.random() / (double) randMax) / 2; } ReplayablePseudoRandom();  ReplayablePseudoRandom(double seed); double random(); int nextInt(int bound); double nextDouble(); boolean nextBoolean(); float nextFloat(); double getSeed(); void setSeed(double seed);  }
@Test public void nextFloatTestDistribution() { int[] res = new int[10]; int error = 0; for (int i = 0; i < 1000; i++) { float number = random.nextFloat(); if (number > 1.0f) { error++; } else if (number < 0.1f) { res[0]++; } else if (number < 0.2f) { res[1]++; } else if (number < 0.3f) { res[2]++; } else if (number < 0.4f) { res[3]++; } else if (number < 0.5f) { res[4]++; } else if (number < 0.6f) { res[5]++; } else if (number < 0.7f) { res[6]++; } else if (number < 0.8f) { res[7]++; } else if (number < 0.9f) { res[8]++; } else if (number < 1.0f) { res[9]++; } } assertTrue(res[0] / 1000d > 0.05); assertTrue(res[1] / 1000d > 0.05); assertTrue(res[2] / 1000d > 0.05); assertTrue(res[3] / 1000d > 0.05); assertTrue(res[4] / 1000d > 0.05); assertTrue(res[5] / 1000d > 0.05); assertTrue(res[6] / 1000d > 0.05); assertTrue(res[7] / 1000d > 0.05); assertTrue(res[8] / 1000d > 0.05); assertTrue(res[9] / 1000d > 0.05); assertEquals(0, error); }