next up previous 196
Next: Data type of the random numbers
Up: Pseudo-Random Numbers
Previous: Pseudo-Random Numbers


Setting the seed (replacements for G05CBF and G05CCF)

Before any random numbers can be selected, a seed must be set using PDA_RNSED. The integer seed should satisfy the relationship


\begin{displaymath}{\rm seed} = 4 * k + 1 \end{displaymath}

where $k$ is a non-negative integer. A fixed seed gives rise to a reproducible sequence of pseudo-random numbers.

For a non-repeatable sequence, there is no equivalent to NAG routine G05CCF because the system clock used to create the seed is not accessible portably in Fortran, and PDA is independent of other libraries. However, the following code has the desired effect.

      INTEGER SEED, STATUS, TICKS, PID
      INCLUDE 'PRM_PAR'

      CALL PSX_TIME( TICKS, STATUS )
      CALL PSX_GETPID( PID, STATUS )
      SEED = TICKS + PID
      SEED = MOD( SEED, VAL__MAXI / 4 ) * 4 + 1
      SEED = MOD( SEED, 2**28 )

      CALL PDA_RNSED( SEED )

PSX_TIME returns the time in units of clock ticks since some arbitrary time. See SUN/121 for more details and linking instructions. The above code also permits storage of the chosen seed.


next up previous 196
Next: Data type of the random numbers
Up: Pseudo-Random Numbers
Previous: Pseudo-Random Numbers

PDA [1ex
Starlink User Note 194
H. Meyerdierks, D. Berry, P. W. Draper, G. Privett, M. Currie
12th October 2005
E-mail:ussc@star.rl.ac.uk

Copyright © 2009 Science and Technology Facilities Council