Anaconda Enterprise: Documentation

# cuRAND

Provides pseudo-random number generator (PRNG) and quasi-random generator (QRNG). See NVIDIA cuRAND.

## class PRNG

class `accelerate.cuda.rand.``PRNG`(*args, **kws)

  cuRAND pseudo random number generator

  Parameters:

  - rndtype – Algorithm type. All possible values are listed as class attributes of this class, e.g. TEST, DEFAULT, XORWOW, MRG32K3A, MTGP32.
  - seed – Seed for the RNG.
  - offset – Offset to the random number stream.
  - stream – CUDA stream.

  Example:

      >>> from accelerate.cuda import rand
      >>> from numpy import empty
      >>> prng = rand.PRNG(rndtype=rand.PRNG.XORWOW)
      >>> r = empty(10)
      >>> prng.uniform(r)
      >>> r
      array([ ... ])

  `lognormal`(ary, mean, sigma, size=None)
    Generate floating point random number sampled
      from a log-normal distribution and fill into ary.

    Parameters:

    - ary – Numpy array or cuda device array.
    - mean – Center of the distribution.
    - sigma – Standard deviation of the distribution.
    - size – Number of samples. Default to array size.

  `normal`(ary, mean, sigma, size=None)

    Generate floating point random number sampled from a normal distribution and fill into ary.

    Parameters:

    - ary – Numpy array or cuda device array.
    - mean – Center of the distribution.
    - sigma – Standard deviation of the distribution.
    - size – Number of samples. Default to array size.

  `poisson`(ary, lmbd, size=None)

    Generate floating point random number sampled from a poisson distribution and fill into ary.

    Parameters:

    - ary – Numpy array or cuda device array.
    - lmbda – Lambda for the distribution.
    - size – Number of samples. Default to array size.

  `uniform`(ary, size=None)
    Generate floating point random number sampled
      from a uniform distribution and fill into ary.

    Parameters:

    - ary – Numpy array or cuda device array.
    - size – Number of samples. Default to array size.

  `seed`

    Mutatable attribute for the seed for the RNG

## class QRNG

class `accelerate.cuda.rand.``QRNG`(*args, **kws)

  cuRAND quasi random number generator

  Parameters:

  - rndtype – Algorithm type. Also control output data type. All possible values are listed as class attributes of this class, e.g. TEST, DEFAULT, SOBOL32, SCRAMBLED_SOBOL32, SOBOL64, SCRAMABLED_SOBOL64.
  - ndim – Number of dimension for the QRNG.
  - offset – Offset to the random number stream.
  - stream – CUDA stream.

  `generate`(ary, size=None)

    Generate quasi random number in ary.

    Parameters:

    - ary – Numpy array or cuda device array.
    - size – Number of samples; Default to array size. Must be multiple of ndim.

  `ndim`

    Mutatable attribute for number of dimension for the QRNG.

## Top Level PRNG Functions

Simple interface to the PRNG methods.

Note

This methods automatically create a PRNG object.

`accelerate.cuda.rand.``uniform`(size, dtype=<type 'float'>, device=False)

  Generate floating point random number sampled from a uniform distribution

  Parameters:

  - size – Number of samples.
  - dtype – np.float32 or np.float64.
  - device – Set to True to return a device array instead or numpy array.

  Returns: | A numpy array or a device array.

      >>> from accelerate.cuda import rand
      >>> rand.uniform(size=10)
      array([...])

  See also

  `accelerate.cuda.rand.PRNG.uniform()`

`accelerate.cuda.rand.``normal`(mean, sigma, size, dtype=<type 'float'>, device=False)

  Generate floating point random number sampled from a normal distribution

  Parameters:

  - mean – Center point of the distribution.
  - sigma – Standard deviation of the distribution.
  - size – — Number of samples.
  - dtype – np.float32 or np.float64.
  - device – Set to True to return a device array instead or ndarray.

  Returns: | A numpy array or a device array.

      >>> from accelerate.cuda import rand
      >>> rand.normal(mean=0, sigma=1, size=10)
      array([...])

  See also

  `accelerate.cuda.rand.PRNG.normal()`

`accelerate.cuda.rand.``lognormal`(mean, sigma, size, dtype=<type 'float'>, device=False)

  Generate floating point random number sampled from a log-normal distribution.

  Parameters:

  - mean – Center point of the distribution.
  - sigma – Standard deviation of the distribution.
  - size – Number of samples.
  - dtype – np.float32 or np.float64.
  - device – set to True to return a device array instead or ndarray.

  Returns: | A numpy array or a device array.

      >>> from accelerate.cuda import rand
      >>> rand.lognormal(mean=0, sigma=1, size=10)
      array([...])

  See also

  `accelerate.cuda.rand.PRNG.lognormal()`

`accelerate.cuda.rand.``poisson`(lmbd, size, device=False)

  Generate int32 random number sampled from a poisson distribution.

  Parameters:

  - lmbda – Lambda of the distribution.
  - size – Number of samples
  - device – Set to True to return a device array instead or ndarray.

  Returns: | A numpy array or a device array.

      >>> from accelerate.cuda import rand
      >>> rand.poisson(lmbd=1, size=10)
      array([...], dtype=uint32)

  See also

  `accelerate.cuda.rand.PRNG.poisson()`

## Top Level QRNG Functions

Simple interface to the QRNG methods.

Note

This methods automatically create a QRNG object.

`accelerate.cuda.rand.``quasi`(size, bits=32, nd=1, device=False)

  Generate quasi random number using SOBOL{bits} RNG type.

  Parameters:

  - size – Number of samples.
  - bits – Bit length of output element; e.g. 32 or 64.
  - nd – Number of dimension .
  - device – Set to True to return a device array instead or ndarray.

  Returns: | A numpy array or a device array.

      >>> from accelerate.cuda import rand
      >>> rand.quasi(10)
      array([...], dtype=uint32)

  See also

  `accelerate.cuda.rand.QRNG.generate()`