randomSeedGet¶
Retrieves the current value of the seed used in the IMSL random number generators.
Synopsis¶
randomSeedGet ( )
Return Value¶
The value of the seed.
Description¶
The 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 randomSeedSet
to reset the seed.
Example¶
This example illustrates the statements required to restart a simulation
using randomSeedGet
and randomSeedSet. Also,
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.math.randomSeedGet import randomSeedGet
from pyimsl.math.randomSeedSet import randomSeedSet
from pyimsl.math.randomUniform import randomUniform
from pyimsl.math.writeMatrix import writeMatrix
seed = 123457
n_random = 5
randomSeedSet(seed)
r1 = randomUniform(n_random)
writeMatrix("First Group of Random Numbers", r1)
seed = randomSeedGet()
randomSeedSet(seed)
r2 = randomUniform(n_random)
writeMatrix("Second Group of Random Numbers", r2)
randomSeedSet(123457)
r = randomUniform(2 * n_random)
writeMatrix("Both Groups of Random Numbers", r)
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 Numbers
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