Looking for “runs” in random numbers will also disclose non random effects. The following program counts how often the next random number is larger than the one before… or smaller. Note that about half the time the direction of change is different between adjacent random number sets.
5 DIM d(20)
10 LET wl=0
20 LET n=0
30 LET yl=50
40 FOR x=1 TO 1000
50 LET y=RND*100
60 IF (y<yl) THEN LET w=1
70 IF (y>=yl) THEN LET w=0
80 IF (w=wl) THEN GO TO 120
90 LET d(n+1)=d(n+1)+1
100 LET n=0
110 GO TO 140
120 LET n=n+1
140 LET yl=y
142 LET wl=w
150 NEXT x
152 FOR i=1 TO 20
160 PRINT i-1,d(i)
170 NEXT i
180 STOP
0 417 1 167 2 69 3 9 4 1 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 0 17 0 18 0 19 0
The pattern of such changes in sign is also an indicator of non- randomness. The bar graph below shows the pattern of succesive runs. It shows runs of 0,1,2,3,4, and one case of 5 .
Note that there is no apparent pattern.
10 LET wl=0
20 LET n=0
30 LET yl=50
40 FOR x=1 TO 255
50 LET y=RND*100
60 IF (y<yl) THEN LET w=1
70 IF (y>=yl) THEN LET w=0
80 IF (w=wl) THEN GO TO 120
90 PLOT x,0
92 DRAW 0,20*n
100 LET n=0
110 GO TO 140
120 LET n=n+1
140 LET yl=y
142 LET wl=w
150 NEXT x
180 STOP

R.A. Schrack
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.