dpnp.random.Generator.random

method

Generator.random(size=None, dtype=None, out=None, *, usm_type=None)[source]

Return random floats in the half-open interval [0.0, 1.0).

For full documentation refer to numpy.random.Generator.random.

Parameters:
size{None, int, tuple of ints}, optional

Output shape. With None, a zero-dimensional array is returned.

Default: None.

dtype{None, dtype}, optional

The data type of the output, dpnp.float32 or dpnp.float64.

Default: None, which means the default floating-point type of the device.

out{None, dpnp.ndarray, usm_ndarray}, optional

A C- or F-contiguous array to fill, of the data type dtype and on the SYCL queue of the generator. If size is given as well, it must be the shape of out.

Default: None.

usm_type{None, "device", "shared", "host"}, optional

The type of SYCL USM allocation for the output array. Ignored when out is given.

Default: None, which means "device".

Returns:
outdpnp.ndarray

The samples, or out when it is given.

Limitations

dtype defaults to the default floating-point type of the device, and usm_type is not in NumPy's signature.

Examples

>>> import dpnp as np
>>> rng = np.random.default_rng(42)
>>> x = rng.random((2, 3))
>>> x.shape, bool(((0 <= x) & (x < 1)).all())
((2, 3), True)