MathUtils { public static int random(final int min, final int max) { assert min <= max; return RANDOM.nextInt(max - min) + min; } private  MathUtils(); static double findMin(@Nonnull final double[] a); static double findMax(@Nonnull final double[] a); static boolean isAlmostZero(final double x); static boolean isAlmostEqual(final double x, final double y); static boolean isBetween(final int value, final int min, final int max); static boolean isBetween(final double value, final double min, final double max); static int limitTo(final int value, final int min, final int max); static double limitTo(final double value, final double min, final double max); static int random(final int min, final int max); static void setRandomSeed(final long seed); static double wrapValueToWithinLimits(
            final double value,
            final int limit); static final double EPSILON; }
@Test public void testRandom() { LOG.info("testRandom"); MathUtils.setRandomSeed(12121212); final int min = 10; final int max = 20; Assert.assertEquals(11, MathUtils.random(min, max)); Assert.assertEquals(16, MathUtils.random(min, max)); for (int i = 0; i < 1000; ++i) { final int r = MathUtils.random(min, max); Assert.assertTrue((min <= r) && (r <= max)); } final double[] b1 = {-1, 2, 3}; final double[] b2 = {3, -1, 2}; final double[] b3 = {2, 3, -1}; Assert.assertTrue("Max should be 3", Double.compare(MathUtils.findMax(b1), 3.0) == 0); Assert.assertTrue("Max should be 3", Double.compare(MathUtils.findMax(b2), 3.0) == 0); Assert.assertTrue("Max should be 3", Double.compare(MathUtils.findMax(b3), 3.0) == 0); }