$RandomGeneratorState
gives a representation of the internal state of the default pseudorandom generator.
Details
- $RandomGeneratorState returns a RandomGeneratorState object that can be passed to BlockRandom, SeedRandom and related functions.
Examples
open allclose allApplications (1)
Create a version of BlockRandom that refuses to run if the current random state cannot be restored:
Activate a randomness generation method with no restorable state:
Because this method cannot be seeded, BlockRandom cannot give reproducible results:
The function will refuse to evaluate:
Activate a randomness generation method that possesses a restorable state:
The function restores the random state at the end of each evaluation:
Properties & Relations (4)
$RandomGeneratorState returns a RandomGeneratorState object:
Using RandomInteger, RandomReal and related functions changes $RandomGeneratorState:
Use RandomComplex:
The state has changed as indicated by the new hash:
The value of $RandomGeneratorState can be restored with SeedRandom:
Restoring $RandomGeneratorState after a computation is effectively the same as BlockRandom:
Text
Wolfram Research (2020), $RandomGeneratorState, Wolfram Language function, https://reference.wolfram.com/language/ref/$RandomGeneratorState.html.
CMS
Wolfram Language. 2020. "$RandomGeneratorState." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/$RandomGeneratorState.html.
APA
Wolfram Language. (2020). $RandomGeneratorState. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/$RandomGeneratorState.html