dpnp.random.Generator.uniform¶
method
- Generator.uniform(low=0.0, high=1.0, size=None, dtype=None, *, usm_type=None)[source]¶
Draw samples from a uniform distribution over [low, high).
For full documentation refer to
numpy.random.Generator.uniform.- Parameters:
- low{float, array_like of floats, dpnp.ndarray, usm_ndarray}, optional
The lower bound of the output interval.
Default:
0.0.- high{float, array_like of floats, dpnp.ndarray, usm_ndarray}, optional
The upper bound of the output interval.
Default:
1.0.- size{None, int, tuple of ints}, optional
Output shape. With
None, the broadcast shape of low and high.Default:
None.- dtype{None, dtype}, optional
The data type of the output,
dpnp.float32ordpnp.float64.Default:
None, which means the default floating-point type of the device.- usm_type{None, "device", "shared", "host"}, optional
The type of SYCL USM allocation for the output array.
Default:
None, which means the USM type of the array parameters, or"device"when there are none.
- Returns:
- outdpnp.ndarray
The samples.
Limitations
dtype and usm_type are not in NumPy's signature. A high - low range that overflows dtype raises
OverflowError, as it does in float64.Examples
>>> import dpnp as np >>> rng = np.random.default_rng(42) >>> x = rng.uniform(-1, 0, 1000) >>> bool(((-1 <= x) & (x < 0)).all()) True