|Function||High-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 );
function VF_random( X:fVector; size:UIntSize; seed:LongInt; MinVal, MaxVal:Single ): LongInt;
|Description||The 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 random number generator by H.W.Lewis. The smaller data types use a 32-bit generator, while the larger types use a 64-bit version. Additional steps (so-called "Bays-Durham shuffle") are taken to break sequential correlations. This ensures very good randomness. However, as this algorithm is well-known and its state can be inferred from a given series of output numbers, these functions are not suitable for cryptographic applications.
A long value is returned which may be used as new seed for subsequent calls.
|Return value||last 32-bit random number generated; this may be used as a new seed value for future calls.|
|See also||VF_noise, rand, srand (C/C++ only), random|
VectorLib Table of Contents OptiVec home