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


Replacements for G05CAF and G05DAF

Like G05CAF, PDA_RAND has a dummy argument demanded by the Fortran standard. It is convenient to set it to zero. Here is an example where two random numbers are drawn from a uniform distribution between 0 and 1. In this example a fixed seed is used, but you could use the computer's clock to create a random seed (see Section [*]).

      INTEGER SEED
      EXTERNAL PDA_RAND
      REAL PDA_RAND, VALUES( 2 )

*  Use a fixed seed of 1.
      SEED = 1
      CALL PDA_RNSED( SEED )

*  Obtain two random numbers from a uniform distribution between 0
*  and 1.
      VALUE( 1 ) = PDA_RAND( 0.0 )
      VALUE( 2 ) = PDA_RAND( 0.0 )

The EXTERNAL statement is recommended, although in many cases it will be unnecessary. To obtain in the range [$a$,$b$] as provided by G05DAF, merely apply the following relationship.


\begin{displaymath}\mbox{random value} = (b - a) * \mbox{ PDA\_RAND}( 0.0 ) + a \end{displaymath}



next up previous 196
Next: Replacement for G05DBF
Up: Pseudo-Random Numbers
Previous: Data type of the 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