## org.apache.mahout.common
Class RandomUtils

    java.lang.Object
      org.apache.mahout.common.RandomUtils

    public final class RandomUtils

extends Object

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

### MAX_INT_SMALLER_TWIN_PRIME

    public static final int MAX_INT_SMALLER_TWIN_PRIME

  The largest prime less than 231-1 that is the smaller of a twin prime pair.

  See Also:
    Constant Field Values

Method Detail

### useTestSeed

    public static void useTestSeed()

### getRandom

    public static RandomWrapper getRandom()

### getRandom

    public static Random getRandom(long seed)

### hashDouble

    public static int hashDouble(double value)

  Returns:
    what `Double.hashCode()` would return for the same value

### hashFloat

    public static int hashFloat(float value)

  Returns:
    what `Float.hashCode()` would return for the same value

### nextTwinPrime

    public 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.

Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.