# [Coco] Tandy Color Computer 3 RND Function

Arthur Flexser flexser at fiu.edu
Thu Mar 26 13:09:27 EDT 2020

```Robert,

The question that arises with your suggested method of assessing the
randomness of the CoCo's RND function (choosing two calls to RND to pick X-
and Y-coordinates and putting a dot on the screen for each pair of
coordinates) that I see is this:  You say the pattern formed "does not look
completely uniform".  But, I wonder if a truly random function would pass
this test?:  There might well be some bunching of points purely due to
chance, with a finite number of dots.  Just like with random coin flips
generating apparently long runs of heads or tails every now and then.

A better test might be to divide the X-axis into some number of intervals
like 50 or so and generate a histogram over some longish interval that
reflects the percentage of values falling within each interval.  The
distribution should approximate a rectangular one.  (There are statistical
tests like the chi-square test that could give an estimate of whether the
obtained distribution deviates significantly from chance.)

Art

On Thu, Mar 26, 2020 at 8:00 AM Robert Gault <robert.gault at att.net> wrote:

> John,
>
> Good information but it does not give a hint about the quality of the Coco
> RND function. That is to
> say you want the probability of any number within the RND function to be
> equal. Not so easy to
> record that information but there is another approach. :)
>
> You can run the following on any Coco by selecting either PMODE or HSCREEN
> graphics.
>
> 10 R=RND(-TIMER)
> 20 WIDTH80:HSCREEN3: REM or PMODE4,1
> 30 R=RND(0):X=R*630:R=RND(0):Y=R*191: REM or 255 AND 191 for PMODE
> 40 HSET(X,Y) :REM  or PSET(X,Y)
> 50 GOTO 30
>
> The above, with a perfect RND function, will eventually completely fill
> the screen with dots and,
> during the filling, show no pattern. I've not let it run long enough on my
> Coco3 to fill the screen
> but the dot density does not look completely uniform, just adequate.
>
> Robert
>
> Melanie and John Mark Mobley wrote:
> > 10 MAX=0:MIN=1
> > 20 FOR X=1 TO 1000
> > 30 R=RND(0)
> > 40 IF R>MAX THEN MAX=R
> > 50 IF R<MIN THEN MIN=R
> > 60 NEXT X
> > 70 PRINT MIN,MAX
> > 80 GOTO 20
> >
> > R is a number between 0 and 1 but never 0 or 1.
> >
> > After about 6 days this is what I found.
> > R=9.38416633E-09 to 0.999999862.
> >
> > R=RND(-TIMER):REM RANDOMIZE THE PSEUDO NUMBER GENERATOR
> > R=RND(-2):REM FIX THE PSEUDO NUMBER GENERATOR TO PATERN 2
> > R=RND(-1.1):REM FIX THE PSEUDO NUMBER GENERATOR TO PATERN 1.1
> > R=RND(-1):REM FIX THE PSEUDO NUMBER GENERATOR TO PATERN 1
> > R=RND(0):REM R=0.000000001 TO 0.999999999
> > R=RND(1):REM R=1
> > R=RND(2):REM R=1 OR 2
> > R=RND(3):REM R=1 TO 3
> >
> > John Mark Mobley
> >
> >
> >
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>
```