TUdataRnd1 TCL UTILITIES USER MANUAL TUdataRnd1
SYNOPSIS
Return 1 or more random numbers within a specified range
PACKAGE
TCLUTILS
NAME
TUdataRnd1
USAGE
set rV  [TUdataRnd1  D nE RnG {MaX}]
INPUT DEFINITIONS
D - Output data (array)
nE - The number values to produce.
RnG - Value range
P - Produce positive values
N - Produce negative values
PN
NP - Produce positive and negative values
MaX - Optional maximum generated random number. Positive/Negative values will be generated between -MaX and MaX. Default is 1.0.
RETURN DEFINITION
rV - Returns the first random value in the array D
DESCRIPTION
TUdataRnd1 generates nE random values and returns them in the variable D. D is an array if more than one value is being returned. The values are generated between -MaX and 0.0, 0.0 and MaX, or -MaX and MaX depending on whether RnG is N, P, or PN/NP respectively.

The algorithm used to produce the random values is:
Rnd1Seed = (1027 * Rnd1Seed) % 1048576
V = Rnd1Seed / 1048576.0
      
Rnd1Seed is declared global and if not set externally is in initialized to 566378.
ERRORS
None Generated
C BACKING
Yes
EXAMPLE(S)
# SET up an array of 10 random values from -5 to 5

TUdataRnd1 A 10 NP 5.0

for { set I 0 } { $I < 10 } { incr I } {
   puts stderr "Value $I : [format %.4f $A($I)]"  
}

> Value 0 : -3.6197
> Value 1 : 1.8935
> Value 2 : 0.8894
> Value 3 : 2.6337
> Value 4 : 0.3638
> Value 5 : -3.2152
> Value 6 : -3.4099
> Value 7 : 0.9428
> Value 8 : -0.7699
> Value 9 : 2.4959

      
June 5, 2003