summaryrefslogtreecommitdiff
path: root/doc/release/upcoming_changes/23195.improvement.rst
blob: 38b33e849ef673fe25ce49b19cdddc6deba8cca1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Ability to directly spawn random number generators
--------------------------------------------------
`numpy.random.Generator.spawn` now allows to directly spawn new
independent child generators via the `numpy.random.SeedSequence.spawn`
mechanism.
`numpy.random.BitGenerator.spawn` does the same for the underlying
bit generator.

Additionally, `numpy.random.BitGenerator.seed_seq` now gives direct
access to the seed sequence used for initializing the bit generator.
This allows for example::

    seed = 0x2e09b90939db40c400f8f22dae617151
    rng = np.random.default_rng(seed)
    child_rng1, child_rng2 = rng.spawn(2)

    # safely use rng, child_rng1, and child_rng2

Previously, this was hard to do without passing the ``SeedSequence``
explicitly.  Please see `numpy.random.SeedSequence` for more information.