Class RTS_RandomDrawing

java.lang.Object
simula.runtime.RTS_RandomDrawing

public abstract class RTS_RandomDrawing extends Object

Utility class RandomDrawing.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
  • Field Details

    • TWO_POW_31

      private static final int TWO_POW_31
      Utility constant: 2**31
      See Also:
    • TWO_POW_31M1D

      private static final double TWO_POW_31M1D
      Utility constant: 2**31 - 1
      See Also:
    • MULTIPLIER

      private static final int MULTIPLIER
      Utility constant: 5**(2*6+1)
      See Also:
  • Constructor Details

    • RTS_RandomDrawing

      private RTS_RandomDrawing()
      Default constructor
  • Method Details

    • basicDRAW

      public static double basicDRAW(RTS_NAME<Integer> U)

      Procedure basicDRAW.

      The routine will replace the value of the specified integer variable U
      by a new value according to an implementation defined algorithm, which
      satisfy the condition stated in the Simula standard 9.9.1
      
      For positive values of U a linear congruential sequence:
      
      		U(i+1) = remainder ((U(i) * 5**(2*p+1)) // 2**n)
      
      is used with n=31 and p=6: 5**(2*6+1) = 1220703125.
      
      The returned real number is computed as U(i+1) / (2**n-1)
      
      
      If U is negative a socalled "antithetic drawing" should be obtained by
      computing U' and val' from -U in the same manner as for positive U.
      
      The new values will then be
      
      		U' = remainder (( -U(i) * 5**(2*p+1)) // 2**n )
      		U(i+1) = - U'
      		return val' = 1.0 - U' / (2**n-1)
      
      In this case the new value of U will also be negative,
      while the returned real still lies in the interval <0,1>.
      
      If the initial U is zero, U is replaced by System.currentTimeMillis()
      Then U is forced to be an odd number by: U = U | 1
      
      See: Donald E. Knuth, The Art of Computer Programming, Volume 2,
           Seminumerical Algorithms, Section 3.2.1.
      
      Parameters:
      U - The pseudo random number (seed) by name.
      Returns:
      Returns the next pseudorandom, uniformly distributed value between 0.0 and 1.0