cupy.random.rand#

cupy.random.rand(*size, **kwarg)[source]#

Returns an array of uniform random values over the interval [0, 1).

Each element of the array is uniformly distributed on the half-open interval [0, 1). All elements are identically and independently distributed (i.i.d.).

Parameters:
  • size (ints) – The shape of the array.

  • dtype – Data type specifier. Only numpy.float32 and numpy.float64 types are allowed. The default is numpy.float64.

Returns:

A random array.

Return type:

cupy.ndarray

See also

numpy.random.rand()

Example

>>> cupy.random.rand(3, 2)
array([[0.86476479, 0.05633727],   # random
       [0.27283185, 0.38255354],   # random
       [0.16592278, 0.75150313]])  # random

>>> cupy.random.rand(3, 2, dtype=cupy.float32)
array([[0.9672306 , 0.9590486 ],                  # random
       [0.6851264 , 0.70457625],                  # random
       [0.22382522, 0.36055237]], dtype=float32)  # random