       ͻ
        Lesson 4 Part 140  F-PC 3.5 Tutorial by Jack Brown 
       ͼ

 Ŀ
   Some comments on your random case study of lesson 4 part 130 
 

There are three random number generators provided in part 13.
There is a fourth random number generatorin the file RAND3.SEQ
that comes with the file SMILEY(35).ZIP

Compile the code provided lesson 4 part 13 and then execute:

CHOOSE BRAND  RANDPLOT <enter>   \ For Brodie's random plot.
CHOOSE TRAND  RANDPLOT <enter>   \ For Tracy's  random plot.
CHOOSE LRAND  RANDPLOT <enter>   \ For Lehmer's random plot.

This demo should convince you of the power of human intuition and the
old saying a picture is worth 24000 dots certainly holds true.  At first
the displays being generated should all look pretty random.

If at any time you want to halt the display for closer or more detailed
inspection just press any key.  If at this point you decide to abort the
continued display of random dots just press the <enter> key.  Pressing
any key other than <enter> after a temporary halt will cause the
accumulation of more random dots.

There are an number of points to consider while watching the different
displays that are generated.

1) If we have a good random number generator then each point on the
screen should have an equal chance to be picked ( displayed as a white
dot).

2) If any random number generator is run long enough...( 10 min to  1
hour ) then evenutally the entire screen will turn white as every pixel
will eventually be lite up.

3) You would think that the more complex Lehmer's generator and that in
the file RAND3.SEQ should be better simply because someone spent more
time on them and there is more code required in their implementation.

4) You would think that a random number generator published in a text
book would have been tested and found not to be lacking in a significant
way.

5) Note that Lehmer's is the only one that generates 32 bit random
numbers directly and hence will be found to be slower because we are
essentially generating a 32 bit random number and truncating it to 16
bits with the word LRAND.

ķ
 Problem 4.22 
Ľ
a) Investigate the interesting double number words in the file
DMULDIV.SEQ and the graphics files CGA.SEQ and VGA.SEQ
b) Decide on the basis of the pictorial displays just which random
number generators have serious faults.  I beleive that some of those
four are so bad that they should absolutely never be used for anything!
Your mission is to find out which should never be used!

            Ŀ
              Comments on the the file DMULDIV.SEQ 
            

This file provides some some useful double number arithmetic operators.

For multiplying two unsigned 32-bit double numbers and yielding an
unsigned 64-bit quad presion result:

UMD* ( ud1 ud2 -- uq )  \ uq is the unsigned 64 bit product.

For multiplying two signed 32-bit numbers and yielding a 32-bit signed
product:

D* ( d1 d2 -- dn ) \ dn is the signed 32 bit product of d1 and d2.

Also provided are some mixed precision division operators:

For dividing and unsigned 64-bit dividend by an unsigned 32-bit divisor
to yield an unsigned 32-bit quotient and unsigned 32-bit remainder:

UMD/MOD ( uqdividend uddivisor -- udremainder udquotient )

NOTE: the stack comment in the 2.15 version of the file is wrong!
In that file  the remainder and quotient are reversed.

In the case study we gave the definitions for the unsigned operators
UD/MOD  UD/ and UDMOD.

We also would like to have signed version of these operators that
conform to signed floored symmetric 32-bit division.  In particular we
need the following:

D/MOD ( ddividend ddivisor -- dremainder dquotient )
D/    ( ddividend ddivisor -- dquotient )
DMOD  ( ddividend ddivisor -- dremainder )

ķ
  Problem 4.23 
Ľ
Write definitions for the above signed division operators.  Make sure
they conform to symmetric floored division rules!

Ŀ
  Please move to Lesson 4 Part 150 

