DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(gawk.info.gz) Cliff Random Function

Info Catalog (gawk.info.gz) Round Function (gawk.info.gz) General Functions (gawk.info.gz) Ordinal Functions
 
 The Cliff Random Number Generator
 ---------------------------------
 
    The Cliff random number generator(1) is a very simple random number
 generator that "passes the noise sphere test for randomness by showing
 no structure."  It is easily programmed, in less than 10 lines of `awk'
 code:
 
      # cliff_rand.awk --- generate Cliff random numbers
      BEGIN { _cliff_seed = 0.1 }
      
      function cliff_rand()
      {
          _cliff_seed = (100 * log(_cliff_seed)) % 1
          if (_cliff_seed < 0)
              _cliff_seed = - _cliff_seed
          return _cliff_seed
      }
 
    This algorithm requires an initial "seed" of 0.1.  Each new value
 uses the current seed as input for the calculation.  If the built-in
 `rand' function ( Numeric Functions) isn't random enough, you
 might try using this function instead.
 
    ---------- Footnotes ----------
 
    (1) `http://mathworld.wolfram.com/CliffRandomNumberGenerator.hmtl'
 
Info Catalog (gawk.info.gz) Round Function (gawk.info.gz) General Functions (gawk.info.gz) Ordinal Functions
automatically generated byinfo2html