Some Randoms methods for doubles.

This commit is contained in:
David Hoover
2011-09-02 13:13:18 -07:00
parent 316dea118d
commit ab23b714e0
@@ -93,6 +93,26 @@ public class Randoms
return low + (_r.nextFloat() * (high - low)); return low + (_r.nextFloat() * (high - low));
} }
/**
* Returns a pseudorandom, uniformly distributed <code>double</code> value between
* <code>0.0</code> (inclusive) and the <code>high</code> (exclusive).
*
* @param high the high value limiting the random number sought.
*/
public double getDouble (double high)
{
return _r.nextDouble() * high;
}
/**
* Returns a pseudorandom, uniformly distributed <code>double</code> value between
* <code>low</code> (inclusive) and <code>high</code> (exclusive).
*/
public double getInRange (double low, double high)
{
return low + (_r.nextDouble() * (high - low));
}
/** /**
* Returns true approximately one in <code>n</code> times. * Returns true approximately one in <code>n</code> times.
* *