This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

SeedRandom

SeedRandom[n]
resets the pseudorandom generator, using n as a seed.
SeedRandom
resets the generator, using as a seed the time of day and certain attributes of the current Mathematica session.
  • You can use SeedRandom[n] to make sure you get the same sequence of pseudorandom numbers on different occasions.
  • SeedRandom[Method->"method"] specifies what method should be used for the pseudorandom generator.
  • SeedRandom[n, Method->"method"] resets the generator, specifying both a seed and the method to use.
  • Typical possible methods include:
"Congruential"linear congruential generator (low-quality randomness)
"ExtendedCA"extended cellular automaton generator (default)
"Legacy"default generators from before Mathematica 6.0
"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.
Use SeedRandom to make random numbers repeatable:
Use SeedRandom to make random numbers repeatable:
In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
The seed can be a string:
SeedRandom affects all random generators:
Switch to the Mersenne twister generator:
Random numbers are now generated using it:
A specific seed will affect the current Mersenne twister generator:
Give a seed to all initialized generators:
Reproduce a part of a computation that uses randomness:
Write a function that uses randomness, but returns predictable results:
Using the function again with more points just adds the additional points:
New in 1 | Last modified in 6