MF_random MD_random ME_random
MCF_random MCD_random MCE_random
MI_randomMBI_randomMSI_randomMLI_randomMQI_random
MU_randomMUB_randomMUS_randomMUL_randomMUQ_random;
Functionfill a matrix with high-quality random numbers
Syntax C/C++#include <MFstd.h>
long MF_random( fMatrix MA, ui ht, ui len, long seed, float MinVal, float MaxVal );
C++ MatObj#include <OptiVec.h>
long matrix<T>::random( const long& seed, const T& MinVal, const T& MaxVal );
Pascal/Delphiuses MFstd;
  function MF_random( MA:fMatrix; ht, len:UIntSize; seed:LongInt; MinVal, MaxVal:Single ): LongInt;
DescriptionThe matrix MA is filled with 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_random,   chapter 3

MatrixLib Table of Contents  OptiVec home