.\" @(#)ran.3f 1.5 93/02/01 SMI; from UCB 4.2 .TH RAN 3F "07 July 1995" .SH NAME ran \- return a random number between 0 and 1 .SH SYNOPSIS .\" .IX ran "" \fLran\fR .IX random values .\" .B real function ran (i) .br .B integer*4 i .SH DESCRIPTION Repeated calls to .B ran generate random numbers with a uniform distribution. .\" .SH NOTES .\" .PP See .BR lcrans (3m). .PP The range includes 0.0 and excludes 1.0. The algorithm is a multiplicative, congruential type, general random number generator. In general, the value of .B i is set once during execution of the calling program. The initial value of .B i should be a large odd integer. Each call to .B ran returns the next random number in the sequence. .PP To get a different sequence of random numbers each time you run the calling program, you must set the argument .B i to a different initial value for each run. .sp Usage: .sp .2 .br .in +2 .nf .ft 3 real r, ran integer*4 i i = ... ... r = ran(i) .ft 1 .fi .in -2 .sp Example: .sp .2 demo% .B "cat ran1.f" .br .B "* ran1.f" \ <-- .I Generate random numbers .br .nf .ft 3 integer*4 i, n real r(10) i = 760013 do n = 1, 10 r(n) = ran ( i ) end do write ( *, "( 5 f11.6 )" ) r end .ft 1 .fi .br demo% .B "f77 \-silent ran1.f" .br demo% .B a.out .br .nf 0.222058 0.299851 0.390777 0.607055 0.653188 0.060174 0.149466 0.444353 0.002982 0.976519 .fi .br demo% .SH FILES .BR libF77.a .SH "SEE ALSO" .BR lcrans, .BR addrans, and .BR shufrans in the .I "Numerical Computation Guide"