dpnp.random.Generator.normal

method

Generator.normal(loc=0.0, scale=1.0, size=None, dtype=None, *, usm_type=None)[source]

Draw samples from a normal (Gaussian) distribution.

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

Parameters:
loc{float, array_like of floats, dpnp.ndarray, usm_ndarray}, optional

The mean of the distribution.

Default: 0.0.

scale{float, array_like of floats, dpnp.ndarray, usm_ndarray}, optional

The standard deviation of the distribution, non-negative.

Default: 1.0.

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

Output shape. With None, the broadcast shape of loc and scale.

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.

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. The samples are drawn as in standard_normal().

Examples

>>> import dpnp as np
>>> rng = np.random.default_rng(42)
>>> x = rng.normal(np.array([0.0, 10.0]), 1.0, size=(10**5, 2))
>>> m = x.mean(axis=0)
>>> bool(abs(m[0]) < 0.05), bool(abs(m[1] - 10) < 0.05)
(True, True)