dpnp.random.default_rng¶
- dpnp.random.default_rng(seed=None, *, device=None, sycl_queue=None)[source]¶
Construct a new
dpnp.random.Generatorwith 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 todpnp.random.SeedSequence. Adpnp.random.BitGeneratoris wrapped in a new generator, and adpnp.random.Generatoris 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 ofdpctl.SyclDevicecorresponding to a non-partitioned SYCL device, an instance ofdpctl.SyclQueue, or adpnp.tensor.Deviceobject returned bydpnp.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.BitGeneratorornumpy.random.Generatoris not accepted as seed and raisesTypeError.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)