Random Graph

The random graph provides a way to link the random number generators of multiple objects in order to set global seeds for reproducibility.

class RandomNode(mother_node=None, seed=None)[source]

Bases: object

Random Node within a random dependency graph.

Parameters:
  • mother_node (RandomNode | None) – Mother node of this random node. By default, nodes are considered to be roots.

  • seed (int | None) – Random seed used to initialize the pseudo-random number generator.

class RandomRealization(seed)[source]

Bases: Serializable

Realization of a random node.

Parameters:

seed (int) – Seed with which to initialize the random number generator.

classmethod Deserialize(process)[source]

Deserialize an object’s state.

Objects cannot be deserialized directly, instead a Factory must be instructed to carry out the deserialization process.

Parameters:

process (DeserializationProcess) – The current stage of the deserialization process. This object is generated by the Factory and provides an interface to deserialization methods supporting multiple backends.

Return type:

RandomRealization

Returns:

The deserialized object.

generator()[source]

Initialize a new generator from the realized random seed.

Returns: A new numpy generator object.

Return type:

Generator

serialize(process)[source]

Serialize this object’s state.

Objects cannot be serialized directly, instead a Factory must be instructed to carry out the serialization process.

Parameters:

process (SerializationProcess) – The current stage of the serialization process. This object is generated by the Factory and provides an interface to serialization methods supporting multiple backends.

Return type:

None

property seed: int

Seed of the random realization.

Returns: A signed integer representing the random seed.