randomSeedGet

Retrieves the current value of the seed used in the random number generators.

Synopsis

randomSeedGet ( )

Return Value

The value of the seed.

Description

Function randomSeedGet retrieves the current value of the “seed” used in the random number generators. A reason for doing this would be to restart a simulation, using function randomSeedSet to reset the seed.

Example

This example illustrates the statements required to restart a simulation using randomSeedGet and randomSeedSet. The example shows that restarting the sequence of random numbers at the value of the seed last generated is the same as generating the random numbers all at once.

from numpy import *
from pyimsl.stat.randomSeedGet import randomSeedGet
from pyimsl.stat.randomSeedSet import randomSeedSet
from pyimsl.stat.randomUniform import randomUniform
from pyimsl.stat.writeMatrix import writeMatrix

n_random = 5
seed = 123457
randomSeedSet(seed)
r1 = randomUniform(n_random)
writeMatrix("First group of random numbers", r1)
seed2 = randomSeedGet()

randomSeedSet(seed2)
r2 = randomUniform(n_random)
writeMatrix("Second group of random numbers", r2)

randomSeedSet(123457)
r3 = randomUniform(2 * n_random)
writeMatrix("Both groups of random number", r3)

Output

 
                 First group of random numbers
          1            2            3            4            5
     0.9662       0.2607       0.7663       0.5693       0.8448
 
                Second group of random numbers
          1            2            3            4            5
     0.0443       0.9872       0.6014       0.8964       0.3809
 
                        Both groups of random number
          1            2            3            4            5            6
     0.9662       0.2607       0.7663       0.5693       0.8448       0.0443
 
          7            8            9           10
     0.9872       0.6014       0.8964       0.3809