Uncommons Maths is a java library with nice math utilities and random number generators. This requires the library uncommons-maths-1.2.2.jar to be in classpath. The following example shows using ContinuousUniformGenerator class.
package com.bethecoder.tutorials.uncommons; import java.util.Random; import org.uncommons.maths.random.ContinuousUniformGenerator; public class ContinuousUniformGeneratorTest { /** * @param args */ public static void main(String[] args) { ContinuousUniformGenerator rand = new ContinuousUniformGenerator(20.1d, 40.2d, new Random()); for (int i = 0 ; i < 10 ; i ++) { System.out.println(rand.nextValue()); } } }
31.03947101851942 39.33441276686378 33.44549261658027 26.914675517092455 40.06865495560609 31.059009192570944 23.04258787216547 39.6308736768093 23.00314913162588 38.26408576173208