|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.common.RandomUtils
public final class RandomUtils
The source of random stuff for the whole project. This lets us make all randomness in the project predictable, if desired, for when we run unit tests, which should be repeatable.
Field Summary | |
---|---|
static int |
MAX_INT_SMALLER_TWIN_PRIME
The largest prime less than 231-1 that is the smaller of a twin prime pair. |
Method Summary | |
---|---|
static RandomWrapper |
getRandom()
|
static Random |
getRandom(long seed)
|
static int |
hashDouble(double value)
|
static int |
hashFloat(float value)
|
static int |
nextTwinPrime(int n)
Finds next-largest "twin primes": numbers p and p+2 such that both are prime. |
static void |
useTestSeed()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MAX_INT_SMALLER_TWIN_PRIME
Method Detail |
---|
public static void useTestSeed()
public static RandomWrapper getRandom()
public static Random getRandom(long seed)
public static int hashDouble(double value)
Double.hashCode()
would return for the same valuepublic static int hashFloat(float value)
Float.hashCode()
would return for the same valuepublic static int nextTwinPrime(int n)
Finds next-largest "twin primes": numbers p and p+2 such that both are prime. Finds the smallest such p such that the smaller twin, p, is greater than or equal to n. Returns p+2, the larger of the two twins.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |