SeedRandom
✖
SeedRandom
resets the generator, using as a seed the time of day and certain attributes of the current Wolfram System session.
Details and Options

- You can use SeedRandom[s] to make sure you get the same sequence of pseudorandom numbers on different occasions.
- SeedRandom affects RandomInteger, RandomReal, RandomComplex, RandomPrime, RandomChoice, RandomSample, and RandomVariate.
- Possible settings for the seed s include:
-
RandomGeneratorState[…] a RandomGeneratorState object n an integer "seed" a string Automatic automatically choose whether to reseed based on options - SeedRandom returns a RandomGeneratorState that for deterministic generators can be used as a seed in order to reproduce random sequences.
- SeedRandom[Method->"method"] specifies what method should be used for the pseudorandom generator. If "method" has been previously used, this form does not reseed it.
- SeedRandom[n,Method->"method"] resets the generator, specifying both a seed and the method to use.
- SeedRandom[n] affects only the current generator; SeedRandom[n,Method->All] affects all generators for which seeds have been given.
- Typical possible methods include:
-
"Congruential" linear congruential generator (low-quality randomness) "ExtendedCA" extended cellular automaton generator (default) "OpenSSL" OpenSSL cryptographically secure generator "MersenneTwister" Mersenne twister shift register generator "MKL" Intel MKL generator (Intel-based systems) "Rule30CA" Wolfram Rule 30 generator - Different methods may give sequences with different levels of randomness.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Use SeedRandom to make random numbers repeatable:

https://wolfram.com/xid/0i1irpdba-xg2


https://wolfram.com/xid/0i1irpdba-kqj

Scope (3)Survey of the scope of standard use cases

https://wolfram.com/xid/0i1irpdba-gwu

Reseed the current random number generator:

https://wolfram.com/xid/0i1irpdba-vle14k

Create a sequence of 5 random reals:

https://wolfram.com/xid/0i1irpdba-6it8xp

Reseed using the RandomGeneratorState object returned by SeedRandom:

https://wolfram.com/xid/0i1irpdba-n1ipya

The sequence of random real numbers is reproduced:

https://wolfram.com/xid/0i1irpdba-gvl4ht

SeedRandom affects all random generators:

https://wolfram.com/xid/0i1irpdba-yp5


https://wolfram.com/xid/0i1irpdba-uyh

Options (2)Common values & functionality for each option
Method (2)
Switch to the Mersenne twister generator:

https://wolfram.com/xid/0i1irpdba-dp2m4b

Random numbers are now generated using it:

https://wolfram.com/xid/0i1irpdba-ieeqsj

A specific seed will affect the current Mersenne twister generator:

https://wolfram.com/xid/0i1irpdba-bw1c3j

Give a seed to all initialized generators:

https://wolfram.com/xid/0i1irpdba-b25860


Applications (2)Sample problems that can be solved with this function
Reproduce a part of a computation that uses randomness:

https://wolfram.com/xid/0i1irpdba-dlilav


https://wolfram.com/xid/0i1irpdba-c6ezbe


https://wolfram.com/xid/0i1irpdba-j1ygok

Write a function that uses randomness, but returns predictable results:

https://wolfram.com/xid/0i1irpdba-hq4qp7

https://wolfram.com/xid/0i1irpdba-rc9lnp

https://wolfram.com/xid/0i1irpdba-denwar

Using the function again with more points just adds the additional points:

https://wolfram.com/xid/0i1irpdba-j378f9

Properties & Relations (4)Properties of the function, and connections to other functions
SeedRandom returns a RandomGeneratorState object with the new state:

https://wolfram.com/xid/0i1irpdba-9csrlu

When a RandomGeneratorState object is used as a seed, explicit Method options are ignored:

https://wolfram.com/xid/0i1irpdba-c2myn3


The state prior to seeding can be obtained from $RandomGeneratorState:

https://wolfram.com/xid/0i1irpdba-1is60e


https://wolfram.com/xid/0i1irpdba-73407x

Generate a new seed and and use the new state:

https://wolfram.com/xid/0i1irpdba-nmczcf

Seeding with the saved state reproduces the original sequence:

https://wolfram.com/xid/0i1irpdba-qepnp8

BlockRandom effectively saves the random generator state and restores it at the end of the computation:

https://wolfram.com/xid/0i1irpdba-llu


https://wolfram.com/xid/0i1irpdba-txb

Wolfram Research (1988), SeedRandom, Wolfram Language function, https://reference.wolfram.com/language/ref/SeedRandom.html (updated 2020).
Text
Wolfram Research (1988), SeedRandom, Wolfram Language function, https://reference.wolfram.com/language/ref/SeedRandom.html (updated 2020).
Wolfram Research (1988), SeedRandom, Wolfram Language function, https://reference.wolfram.com/language/ref/SeedRandom.html (updated 2020).
CMS
Wolfram Language. 1988. "SeedRandom." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/SeedRandom.html.
Wolfram Language. 1988. "SeedRandom." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/SeedRandom.html.
APA
Wolfram Language. (1988). SeedRandom. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SeedRandom.html
Wolfram Language. (1988). SeedRandom. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SeedRandom.html
BibTeX
@misc{reference.wolfram_2025_seedrandom, author="Wolfram Research", title="{SeedRandom}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/SeedRandom.html}", note=[Accessed: 30-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_seedrandom, organization={Wolfram Research}, title={SeedRandom}, year={2020}, url={https://reference.wolfram.com/language/ref/SeedRandom.html}, note=[Accessed: 30-May-2025
]}