next up previous contents index
Next: Miscellaneous Up: Miscellaneous CCATSL routines Previous: Disk files   Contents   Index


Random Numbers

CCATSL provides three functions for controlling the generation of pseudo-random numbers. RandomCL returns a random number distributed uniformly on $[0,1)$, RandomIntCL returns a random integer uniformly distributed on the set  $\{1,2,\ldots{},n\}$ for specified $n\ge 2$, and SetRandomCL allows you to change the current state of the random number generator, useful if you want to ensure your program uses the same sequence of random number each time it is run.


RandomCL

This routine returns a random number uniformly distributed on $[0,1)$.

  
double u;
...
u=RandomCL();    /* get a U[0,1) rv */


RandomIntCL

This routine returns a random integer uniformly distributed on the set  $1,2,\ldots{},n$ for specified $n\ge 2$.

  int RandomIntCL ( int n);

  n The size of the set


SetRandomCL

This routine allows you to change the current state of the random number generator. If it is not called, the program will generate the same sequence of random numbers each time it is run

  void SetRandomCL ( int seed);

  seed If seed>0, this will set the seed for subsequent random number generations. If seed<0, the random number generator will be seeded using a number derived from the current time. Used this way, we can ensure that successive runs of a program use independent sequences of random numbers.


next up previous contents index
Next: Miscellaneous Up: Miscellaneous CCATSL routines Previous: Disk files   Contents   Index
CATAM admin 2010-02-23