10 PRINT "PROGRAM FILE 135: SERIAL TEST FOR RANDOMNESS."
20 PRINT "    ANSI STANDARD 8.4"
30 PRINT
40 PRINT "SECTION 135.1: SERIAL TEST FOR RANDOMNESS."
50 PRINT
60 PRINT "THIS PROGRAM TESTS WHETHER PAIRS OF ADJACENT NUMBERS FROM"
70 PRINT "THE RND FUNCTION ARE EQUALLY DISTRIBUTED AMONG CATEGORIES"
80 PRINT "BASED ON THEIR VALUES. THE TEST ASSIGNS A PAIR TO ONE OF"
90 PRINT "121 CATEGORIES BASED ON WHICH 11TH OF THE SEGMENT FROM 0"
100 PRINT "TO 1 EACH MEMBER OF THE PAIR FALLS WITHIN. CHI-SQUARE IS"
110 PRINT "COMPUTED AND DISPLAYED AS THE RESULT."
120 PRINT
130 PRINT "***** THIS TEST IS INFORMATIVE ONLY *****"
140 PRINT
150 PRINT "                 BEGIN TEST"
160 DIM C(121)
170 REM SET PARTITION OF 0-1 SEGMENT
180 LET D=11
190 REM FOR PAIRS OF NUMBERS, ARE #PARTITIONS^2 CATEGORIES
200 LET D2=D*D
210 FOR I=1 TO D2
220 LET C(I)=0
230 NEXT I
240 REM EXPECT 20 IN EACH CATEGORY
250 LET N=20*D2
260 FOR N1=1 TO N
270 LET X=RND
280 LET Y=RND
290 LET I=(D*INT(D*X))+INT(D*Y)+1
300 LET C(I)=C(I)+1
310 NEXT N1
320 LET S=0
330 PRINT
340 PRINT "1ST OF PAIR","2ND OF PAIR","ACTUAL COUNT"
350 PRINT "(EXPECTED COUNT = 20)"
360 PRINT
370 FOR I=1 TO D2
380 LET I9=I-1
390 LET I1=INT(I9/D)
400 LET I2=I9 - (D*I1) + 1
410 LET I1=I1+1
420 PRINT I1,I2,C(I)
430 LET S=S + (D2*C(I)*C(I))
440 NEXT I
450 LET V=(S/N) - N
460 PRINT
470 PRINT "FOR 120 D.F., SHOULD HAVE 95.70 <= CHI-SQ <= 146.57"
480 PRINT "(5% TAIL AT EACH END)."
490 PRINT
500 PRINT "ACTUAL CHI-SQ = ";V
510 PRINT
520 IF V<95.70 THEN 560
530 IF V>146.57 THEN 560
540 PRINT "*** INFORMATIVE TEST PASSED ***"
550 GOTO 570
560 PRINT "*** INFORMATIVE TEST FAILED ***"
570 REM DONE
580 PRINT
590 PRINT "                  END TEST"
600 PRINT
610 PRINT "END PROGRAM 135"
620 END
