This is a pre-release version (2.5.0.dev0+git20251130.2de293a). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / random / _generator / Generator / spawn

cython_function_or_method

numpy.random._generator:Generator.spawn

Signature

def   spawn ( n_children )

Summary

Create new independent child generators.

Extended Summary

See seedsequence-spawn for additional notes on spawning children.

Parameters

n_children : int

Returns

child_generators : list of Generators

Raises

: TypeError

When the underlying SeedSequence does not implement spawning.

Examples

Starting from a seeded default generator:
entropy = 0x3034c61a9ae04ff8cb62ab8ec2c4b501
rng = np.random.default_rng(entropy)
Create two new generators for example for parallel execution:
child_rng1, child_rng2 = rng.spawn(2)
Drawn numbers from each are independent but derived from the initial seeding entropy:
rng.uniform(), child_rng1.uniform(), child_rng2.uniform()
It is safe to spawn additional children from the original ``rng`` or the children:
more_child_rngs = rng.spawn(20)
nested_spawn = child_rng1.spawn(20)

See also

bit_generator

The bit generator instance used by the generator.

random.BitGenerator.spawn

Equivalent method on the bit generator and seed sequence.

random.SeedSequence.spawn

Equivalent method on the bit generator and seed sequence.

Aliases

  • numpy.random.Generator.spawn

Referenced by