gawk: Cliff Random Function

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