Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ran(3F) — Sun WorkShop 5.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

RAN(3F)

NAME

ran − return a random number between 0 and 1

SYNOPSIS

real function ran (i)
integer∗4 i

DESCRIPTION

Repeated calls to ran generate random numbers with a uniform distribution. 

NOTES

See lcrans(3m). 

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 i is set once during execution of the calling program.  The initial value of i should be a large odd integer.  Each call to ran returns the next random number in the sequence. 

To get a different sequence of random numbers each time you run the calling program, you must set the argument i to a different initial value for each run.  Usage:

real  r, ran
integer∗4 i
i = ...
     ...
r = ran(i)

Example: demo% cat ran1.f
∗ ran1.f         <-- Generate random numbers

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

demo% f77 −silent ran1.f
demo% a.out

   0.222058 0.299851 0.390777 0.607055 0.653188
   0.060174 0.149466 0.444353 0.002982 0.976519

demo%

FILES

libF77.a

SEE ALSO

lcrans, addrans, and shufrans in the Numerical Computation Guide

SunOS 5.0  —  Last change: 07 July 1995

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026