dpnp.random.default_rng

dpnp.random.default_rng(seed=None, *, device=None, sycl_queue=None)[source]

Construct a new dpnp.random.Generator with the default bit generator, dpnp.random.Philox4x3210.

For full documentation refer to numpy.random.default_rng.

Parameters:
seed{None, int, array_like[ints], SeedSequence, BitGenerator, Generator}, optional

The entropy to seed the bit generator with. If None, fresh, unpredictable entropy is pulled from the OS. An int, or the ints of an array_like, must be non-negative and are passed to dpnp.random.SeedSequence. A dpnp.random.BitGenerator is wrapped in a new generator, and a dpnp.random.Generator is returned unaltered.

Default: None.

device{None, string, SyclDevice, SyclQueue, Device}, optional

An array API concept of device where the output array is created. device can be None, a oneAPI filter selector string, an instance of dpctl.SyclDevice corresponding to a non-partitioned SYCL device, an instance of dpctl.SyclQueue, or a dpnp.tensor.Device object returned by dpnp.ndarray.device. Ignored when seed is a bit generator or a generator.

Default: None.

sycl_queue{None, SyclQueue}, optional

A SYCL queue to use for output array allocation and copying. The sycl_queue can be passed as None (the default), which means to get the SYCL queue from device keyword if present or to use a default queue. Ignored when seed is a bit generator or a generator.

Default: None.

Returns:
outGenerator

The initialized generator.

Limitations

NumPy's default bit generator is PCG64, so the same seed gives different values. A NumPy numpy.random.RandomState, numpy.random.BitGenerator or numpy.random.Generator is not accepted as seed and raises TypeError.

Examples

>>> import dpnp as np
>>> rng = np.random.default_rng(12345)
>>> x = rng.random(3)
>>> x.shape, x.device.sycl_device == rng.sycl_device
((3,), True)