These subroutines generate vector x of uniform (0,1)
pseudo-random numbers, using the multiplicative congruential method with a
user-specified seed.
| x | seed | Subroutine |
| Short-precision real | Long-precision real | SURAND |
| Long-precision real | Long-precision real | DURAND |
| Fortran | CALL SURAND | DURAND (seed, n, x) |
| C and C++ | surand | durand (seed, n, x); |
| PL/I | CALL SURAND | DURAND (seed, n, x); |
In your C program, argument seed must be passed by reference.
The uniform (0,1) pseudo-random numbers are generated as follows, using the multiplicative congruential method:
where:
See references [76] and [80]. If n is 0, no computation is performed, and the initial seed is unchanged.
None
This example shows a call to SURAND to generate 10 random numbers.
SEED N X
| | |
CALL SURAND( SEED , 10 , X )
SEED = 80629.0
SEED = 759150100.0
X = (0.6310323,
0.7603202,
0.7015232,
0.5014868,
0.4895853,
0.4602344,
0.1603608,
0.1832564,
0.9899062,
0.3535068)
This example shows a call to DURAND to generate 10 random numbers.
SEED N X
| | |
CALL DURAND( SEED , 10 , X )
SEED = 80629.0
SEED = 759150100.0
X = (0.6310323270182275,
0.7603201953509451,
0.7015232633340746,
0.5014868557925740,
0.4895853057920864,
0.4602344475967038,
0.1603607578018497,
0.1832563756887132,
0.9899062002030695,
0.3535068129904134)