VF_randomVD_randomVE_random
VCF_randomVCD_randomVCE_random
VI_randomVBI_randomVSI_randomVLI_randomVQI_random
VU_randomVUB_randomVUS_randomVUL_randomVUI_random
FunctionHigh-quality random numbers
Syntax C/C++#include <VFstd.h>
long VF_random( fVector X, ui siz, long seed, float MinVal, float MaxVal );
C++ VecObj#include <OptiVec.h>
long vector<T>::random( long seed, T MinVal, T MaxVal );
Pascal/Delphiuses VFstd;
function VF_random( X:fVector; size:UInt; seed:LongInt; MinVal, MaxVal:Single ): LongInt;
DescriptionThe X vector is filled with a sequence of random numbers. Within the ranges defined by MinVal and MaxVal, and within the restrictions of floating-point representation, all numbers are equally probable (including the extreme values themselves), i.e., so-called "uniform deviates" are produced. The parameter seed may be any number. Successive calls to one and the same of these functions will yield identical sequences, if seed is chosen equal; if seed is chosen differently for successive calls, the results will be uncorrelated.

Internally, these functions employ a 32-bit integer random number generator by H.W.Lewis, with additional steps (so-called "Bays-Durham shuffle") to break sequential correlations. This ensures very good randomness, far superior to simpler generators (like the rand function of C/C++ compilers or the random function of Pascal/Delphi).

A long value is returned which may be used as new seed for subsequent calls.

Error handlingnone
Return valuelast 32-bit random number generated; this may be used as a new seed value for future calls.
See alsoVF_noise,   rand,   srand (C/C++ only),  random

VectorLib Table of Contents  OptiVec home