RAN69069(3dxml) — Subroutines
Name
ran69069 − Routine to generate single precision random numbers using a=69069 and m=2∗∗32
FORMAT
RAN69069 (s)
Function Value
ran69069real∗4
The uniform[0,1] value returned.
Arguments
sinteger∗4
On input, a seed s being set initially or left unchanged from a previous iteration.
On exit, the updated seed.
Description
The RAN69069 routine computes updated seeds using the linear multiplicative algorithm as follows:
s = 69069∗s+1, mod 2∗∗32
and returns s∗2.0∗∗(-32), as its uniform [0,1] output.
The following code example simulates a random walk using RAN69069. A particle starts at (0,0) and proceeds N., E., S., or W. with probability 0.25 each.
Example
integer ix,iy,i,j,iseed,nsteps,nwalks
real∗4 x
c random walk: go N E S W each with probability 0.25
nsteps = 1000000
nwalks = 10
iseed = 1234
do j=1,nwalks
ix=0
iy=0
do i = 1, nsteps
x=ran69069(iseed)
if(x.le.0.25)then
ix=ix+1
else if(x.le.0.5)then
iy=iy+1
else if(x.le.0.75)then
ix=ix-1
else
iy=iy-1
end if
end do
print∗,’final position ’,ix,iy
end do
end