Package org.nd4j.linalg.api.rng
Interface Random
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
DefaultRandom
public interface Random extends AutoCloseable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description longgetPosition()This method returns number of elements consumedlonggetSeed()Gets thelongseed of the underlying random number generator.org.bytedeco.javacpp.PointergetStatePointer()This method returns pointer to RNG state structure.booleannextBoolean()Returns the next pseudorandom, uniformly distributedbooleanvalue from this random number generator's sequence.voidnextBytes(byte[] bytes)Generates random bytes and places them into a user-supplied byte array.doublenextDouble()Returns the next pseudorandom, uniformly distributeddoublevalue between0.0and1.0from this random number generator's sequence.INDArraynextDouble(char order, int[] shape)Generate a uniform number ndarray of the specified shape and orderINDArraynextDouble(char order, long[] shape)INDArraynextDouble(int[] shape)Generate a uniform number ndarray of the specified shapeINDArraynextDouble(long[] shape)floatnextFloat()Returns the next pseudorandom, uniformly distributedfloatvalue between0.0and1.0from this random number generator's sequence.INDArraynextFloat(char order, int[] shape)Generate a uniform number ndarray of the specified shapeINDArraynextFloat(char order, long[] shape)INDArraynextFloat(int[] shape)Generate a uniform number ndarray of the specified shapeINDArraynextFloat(long[] shape)doublenextGaussian()Returns the next pseudorandom, Gaussian ("normally") distributeddoublevalue with mean0.0and standard deviation1.0from this random number generator's sequence.INDArraynextGaussian(char order, int[] shape)Generate a gaussian number ndarray of the specified shape and orderINDArraynextGaussian(char order, long[] shape)INDArraynextGaussian(int[] shape)Generate a gaussian number ndarray of the specified shapeINDArraynextGaussian(long[] shape)intnextInt()Returns the next pseudorandom, uniformly distributedintvalue from this random number generator's sequence.intnextInt(int n)Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.INDArraynextInt(int[] shape)Generate a random set of integers of the specified shape.intnextInt(int a, int n)Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.INDArraynextInt(int n, int[] shape)Generate a random set of integers of the specified shape.INDArraynextInt(int n, long[] shape)INDArraynextInt(long[] shape)longnextLong()Returns the next pseudorandom, uniformly distributedlongvalue from this random number generator's sequence.longnodeState()voidreSeed()This method is similar to setSeed() but it doesn't really touches underlying buffer, if any.voidreSeed(long seed)This method is similar to setSeed() but it doesn't really touches underlying buffer, if any.longrootState()voidsetSeed(int seed)Sets the seed of the underlying random number generator using anintseed.voidsetSeed(int[] seed)Sets the seed of the underlying random number generator using anintseed.voidsetSeed(long seed)Sets the seed of the underlying random number generator using alongseed.voidsetStates(long rootState, long nodeState)-
Methods inherited from interface java.lang.AutoCloseable
close
-
-
-
-
Method Detail
-
setSeed
void setSeed(int seed)
Sets the seed of the underlying random number generator using anintseed.Sequences of values generated starting with the same seeds should be identical.
- Parameters:
seed- the seed value
-
setSeed
void setSeed(int[] seed)
Sets the seed of the underlying random number generator using anintseed.Sequences of values generated starting with the same seeds should be identical.
- Parameters:
seed- the seed value
-
setSeed
void setSeed(long seed)
Sets the seed of the underlying random number generator using alongseed.Sequences of values generated starting with the same seeds should be identical.
- Parameters:
seed- the seed value
-
getSeed
long getSeed()
Gets thelongseed of the underlying random number generator.- Returns:
- the seed value
-
nextBytes
void nextBytes(byte[] bytes)
Generates random bytes and places them into a user-supplied byte array. The number of random bytes produced is equal to the length of the byte array.- Parameters:
bytes- the non-null byte array in which to put the random bytes
-
nextInt
int nextInt()
Returns the next pseudorandom, uniformly distributedintvalue from this random number generator's sequence. All 232 possible int values should be produced with (approximately) equal probability.- Returns:
- the next pseudorandom, uniformly distributed
intvalue from this random number generator's sequence
-
nextInt
int nextInt(int n)
Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.- Parameters:
n- the bound on the random number to be returned. Must be positive.- Returns:
- a pseudorandom, uniformly distributed int value between 0 (inclusive) and n (exclusive).
- Throws:
IllegalArgumentException- if n is not positive.
-
nextInt
int nextInt(int a, int n)Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.- Parameters:
n- the bound on the random number to be returned. Must be positive.- Returns:
- a pseudorandom, uniformly distributed int value between 0 (inclusive) and n (exclusive).
- Throws:
IllegalArgumentException- if n is not positive.
-
nextLong
long nextLong()
Returns the next pseudorandom, uniformly distributedlongvalue from this random number generator's sequence. All 264 possible long values should be produced with (approximately) equal probability.- Returns:
- the next pseudorandom, uniformly distributed
longvalue from this random number generator's sequence
-
nextBoolean
boolean nextBoolean()
Returns the next pseudorandom, uniformly distributedbooleanvalue from this random number generator's sequence.- Returns:
- the next pseudorandom, uniformly distributed
booleanvalue from this random number generator's sequence
-
nextFloat
float nextFloat()
Returns the next pseudorandom, uniformly distributedfloatvalue between0.0and1.0from this random number generator's sequence.- Returns:
- the next pseudorandom, uniformly distributed
floatvalue between0.0and1.0from this random number generator's sequence
-
nextDouble
double nextDouble()
Returns the next pseudorandom, uniformly distributeddoublevalue between0.0and1.0from this random number generator's sequence.- Returns:
- the next pseudorandom, uniformly distributed
doublevalue between0.0and1.0from this random number generator's sequence
-
nextGaussian
double nextGaussian()
Returns the next pseudorandom, Gaussian ("normally") distributeddoublevalue with mean0.0and standard deviation1.0from this random number generator's sequence.- Returns:
- the next pseudorandom, Gaussian ("normally") distributed
doublevalue with mean0.0and standard deviation1.0from this random number generator's sequence
-
nextGaussian
INDArray nextGaussian(int[] shape)
Generate a gaussian number ndarray of the specified shape- Parameters:
shape- the shape to generate- Returns:
- the generated gaussian numbers
-
nextGaussian
INDArray nextGaussian(long[] shape)
-
nextGaussian
INDArray nextGaussian(char order, int[] shape)
Generate a gaussian number ndarray of the specified shape and order- Parameters:
order- the order of the output arrayshape- the shape to generate- Returns:
- the generated gaussian numbers
-
nextGaussian
INDArray nextGaussian(char order, long[] shape)
-
nextDouble
INDArray nextDouble(int[] shape)
Generate a uniform number ndarray of the specified shape- Parameters:
shape- the shape to generate- Returns:
- the generated gaussian numbers
-
nextDouble
INDArray nextDouble(long[] shape)
-
nextDouble
INDArray nextDouble(char order, int[] shape)
Generate a uniform number ndarray of the specified shape and order- Parameters:
order- order of the output arrayshape- the shape to generate- Returns:
- the generated gaussian numbers
-
nextDouble
INDArray nextDouble(char order, long[] shape)
-
nextFloat
INDArray nextFloat(int[] shape)
Generate a uniform number ndarray of the specified shape- Parameters:
shape- the shape to generate- Returns:
- the generated uniform numbers
-
nextFloat
INDArray nextFloat(long[] shape)
-
nextFloat
INDArray nextFloat(char order, int[] shape)
Generate a uniform number ndarray of the specified shape- Parameters:
shape- the shape to generate- Returns:
- the generated uniform numbers
-
nextFloat
INDArray nextFloat(char order, long[] shape)
-
nextInt
INDArray nextInt(int[] shape)
Generate a random set of integers of the specified shape. Note that these integers will not actually be integers but floats that happen to be whole numbers. The reason for this is due to ints having the same space usage as floats. This also plays nice with blas. If the data opType is set to double, then these will be whole doubles.- Parameters:
shape- the shape to generate- Returns:
- the ndarray with the shape of only integers.
-
nextInt
INDArray nextInt(long[] shape)
-
nextInt
INDArray nextInt(int n, int[] shape)
Generate a random set of integers of the specified shape. Note that these integers will not actually be integers but floats that happen to be whole numbers. The reason for this is due to ints having the same space usage as floats. This also plays nice with blas. If the data opType is set to double, then these will be whole doubles.- Parameters:
shape- the shape to generaten- the max number to generate trod a- Returns:
- the ndarray with the shape of only integers.
-
nextInt
INDArray nextInt(int n, long[] shape)
-
getStatePointer
org.bytedeco.javacpp.Pointer getStatePointer()
This method returns pointer to RNG state structure. Please note: DefaultRandom implementation returns NULL here, making it impossible to use with RandomOps- Returns:
-
getPosition
long getPosition()
This method returns number of elements consumed- Returns:
-
reSeed
void reSeed()
This method is similar to setSeed() but it doesn't really touches underlying buffer, if any. So it acts as additional modifier to current RNG state. System.currentTimeMillis() will be used as modifier. PLEASE NOTE: Never use this method unless you're 100% sure what it does and why you would need it.
-
reSeed
void reSeed(long seed)
This method is similar to setSeed() but it doesn't really touches underlying buffer, if any. So it acts as additional modifier to current RNG state. PLEASE NOTE: Never use this method unless you're 100% sure what it does and why you would need it.- Parameters:
seed-
-
rootState
long rootState()
-
nodeState
long nodeState()
-
setStates
void setStates(long rootState, long nodeState)
-
-