If no seed is provided to the random generator (using seed() or manualSeed()), a random seed will be set according to seed() the first time a random number is generated.

Initial seed can be obtained using initialSeed().

Setting a particular seed allows the user to (re)-generate a particular serie of random numbers. Example:

> random.manualSeed(123)
> = random.uniform()
0.69646918727085
> return  random.uniform()
0.71295532141812
> return  random.uniform()
0.28613933874294
> random.manualSeed(123)
> return  random.uniform()
0.69646918727085
> return  random.uniform()
0.71295532141812
> return  random.uniform()
0.28613933874294
> random.manualSeed(random.initialSeed())
> return  random.uniform()
0.69646918727085
> return  random.uniform()
0.71295532141812
> return  random.uniform()
0.28613933874294

Subsections

  1. [number] seed()
  2. manualSeed(number)
  3. initialSeed()