resets the pseudorandom generator, using n as a seed.


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[n] to make sure you get the same sequence of pseudorandom numbers on different occasions.
  • SeedRandom affects RandomInteger, RandomReal, RandomComplex, RandomPrime, RandomChoice, RandomSample, and RandomVariate.
  • 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.
  • 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)
    "Legacy"default generators from before Version 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.


open allclose all

Basic Examples  (1)

Use SeedRandom to make random numbers repeatable:

Scope  (2)

The seed can be a string:

SeedRandom affects all random generators:

Options  (2)

Method  (2)

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:

Applications  (2)

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:

Introduced in 1988
Updated in 2007