$RandomGeneratorState

$RandomGeneratorState

gives a representation of the internal state of the default pseudorandom generator.

Details

Examples

open allclose all

Basic Examples  (1)

Get the current state of the pseudorandom generator:

Applications  (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:

Hence the following result matches the previous result:

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:

Wolfram Research (2020), $RandomGeneratorState, Wolfram Language function, https://reference.wolfram.com/language/ref/$RandomGeneratorState.html.

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

BibTeX

@misc{reference.wolfram_2024_$randomgeneratorstate, author="Wolfram Research", title="{$RandomGeneratorState}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/$RandomGeneratorState.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_$randomgeneratorstate, organization={Wolfram Research}, title={$RandomGeneratorState}, year={2020}, url={https://reference.wolfram.com/language/ref/$RandomGeneratorState.html}, note=[Accessed: 22-November-2024 ]}