Interface Random

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      long getPosition()
      This method returns number of elements consumed
      long getSeed()
      Gets the long seed of the underlying random number generator.
      org.bytedeco.javacpp.Pointer getStatePointer()
      This method returns pointer to RNG state structure.
      boolean nextBoolean()
      Returns the next pseudorandom, uniformly distributed boolean value from this random number generator's sequence.
      void nextBytes​(byte[] bytes)
      Generates random bytes and places them into a user-supplied byte array.
      double nextDouble()
      Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.
      INDArray nextDouble​(char order, int[] shape)
      Generate a uniform number ndarray of the specified shape and order
      INDArray nextDouble​(char order, long[] shape)  
      INDArray nextDouble​(int[] shape)
      Generate a uniform number ndarray of the specified shape
      INDArray nextDouble​(long[] shape)  
      float nextFloat()
      Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence.
      INDArray nextFloat​(char order, int[] shape)
      Generate a uniform number ndarray of the specified shape
      INDArray nextFloat​(char order, long[] shape)  
      INDArray nextFloat​(int[] shape)
      Generate a uniform number ndarray of the specified shape
      INDArray nextFloat​(long[] shape)  
      double nextGaussian()
      Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.
      INDArray nextGaussian​(char order, int[] shape)
      Generate a gaussian number ndarray of the specified shape and order
      INDArray nextGaussian​(char order, long[] shape)  
      INDArray nextGaussian​(int[] shape)
      Generate a gaussian number ndarray of the specified shape
      INDArray nextGaussian​(long[] shape)  
      int nextInt()
      Returns the next pseudorandom, uniformly distributed int value from this random number generator's sequence.
      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.
      INDArray nextInt​(int[] shape)
      Generate a random set of integers of the specified shape.
      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.
      INDArray nextInt​(int n, int[] shape)
      Generate a random set of integers of the specified shape.
      INDArray nextInt​(int n, long[] shape)  
      INDArray nextInt​(long[] shape)  
      long nextLong()
      Returns the next pseudorandom, uniformly distributed long value from this random number generator's sequence.
      long nodeState()  
      void reSeed()
      This method is similar to setSeed() but it doesn't really touches underlying buffer, if any.
      void reSeed​(long seed)
      This method is similar to setSeed() but it doesn't really touches underlying buffer, if any.
      long rootState()  
      void setSeed​(int seed)
      Sets the seed of the underlying random number generator using an int seed.
      void setSeed​(int[] seed)
      Sets the seed of the underlying random number generator using an int seed.
      void setSeed​(long seed)
      Sets the seed of the underlying random number generator using a long seed.
      void setStates​(long rootState, long nodeState)  
    • Method Detail

      • setSeed

        void setSeed​(int seed)
        Sets the seed of the underlying random number generator using an int seed.

        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 an int seed.

        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 a long seed.

        Sequences of values generated starting with the same seeds should be identical.

        Parameters:
        seed - the seed value
      • getSeed

        long getSeed()
        Gets the long seed 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 distributed int value 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 int value 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 distributed long value 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 long value from this random number generator's sequence
      • nextBoolean

        boolean nextBoolean()
        Returns the next pseudorandom, uniformly distributed boolean value from this random number generator's sequence.
        Returns:
        the next pseudorandom, uniformly distributed boolean value from this random number generator's sequence
      • nextFloat

        float nextFloat()
        Returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence.
        Returns:
        the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator's sequence
      • nextDouble

        double nextDouble()
        Returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence.
        Returns:
        the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator's sequence
      • nextGaussian

        double nextGaussian()
        Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator's sequence.
        Returns:
        the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from 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 array
        shape - 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 array
        shape - 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 generate
        n - 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)