10 PRINT "MANN-WHITNEY U-TEST"
20 PRINT
28 REM - SET MAXIMUM SAMPEL SIZE TO X(m),Y(n)    (WHERE
29 REM - M=MAXIMUM SIZE OF SAMPLE 1, N=MAXIMUM SIZE OF SAMPLE TWO
30 DIM X(25),Y(25)
40 DIM N(2)
49 REM - INPUT THE TWO SAMPELS
50 FOR I=1 TO 2
60 PRINT "SAMPLE";I;":"
70 PRINT "   SIZE";
80 INPUT N(I)
90 FOR J=1 TO N(I)
100 PRINT "   DATA";J;
110 INPUT Y(J)
120 NEXT J
129 REM - SORT EACH SAMPLE
130 FOR J=1 TO N(I)
140 FOR K=1 TO N(I)-J
150 C=Y(K)
160 D=Y(K+1)
170 IF Y(K)<Y(K+1) THEN 200
180 Y(K)=Y(K+1)
190 Y(K+1)=C
200 NEXT K
210 NEXT J
220 PRINT
229 REM - TRANSFER FIRST SAMPLE TO X-ARRAY
230 IF I=2 THEN 270
240 FOR J=1 TO N(1)
250 X(J)=Y(J)
260 NEXT J
270 NEXT I
279 REM - ADD UP RANKS
280 R=1
290 I=0
300 J=0
310 I=I+1
320 J=J+1
330 IF I>N(1) THEN 580
340 IF J>N(2) THEN 620
350 IF X(I)<Y(J) THEN 620
360 IF Y(J)<X(I) THEN 590
369 REM - LINES 370-570 HANDLE EQUAL SCORES FROM BOTH SAMPLES
370 K=2
380 M=I
390 L=J
400 R1=2*R+1
410 R=R+2
420 I=I+1
430 J=J+1
440 IF I>N(1) THEN 480
450 IF X(I)<>X(I-1) THEN 480
460 I=I+1
470 GOTO 510
480 IF J>N(2) THEN 550
490 IF Y(J)<>Y(J-1) THEN 550
500 J=J+1
510 R1=R1+R
520 R=R+1
530 K=K+1
540 GOTO 440
550 X=X+(I-M)*R1/K
560 Y=Y+(J-L)*R1/K
570 GOTO 330
580 IF J>N(2) THEN 660
590 Y=Y+R
600 J=J+1
610 GOTO 640
620 X=X+R
630 I=I+1
640 R=R+1
650 GOTO 330
659 REM - U1=NUMBER OF TIMES SAMPLE 1 SCORES PRECEED SAMPLE 2 SCORES
660 U1=N(1)*N(2)+N(1)*(N(1)+1)/2-X
669 REM - U1=NUMBER OF TIMES SAMPLE 2 SCORES PRECEED SAMPLE 1 SCORES
670 U2=N(1)*N(2)+N(2)*(N(2)+1)/2-Y
680 PRINT
690 PRINT "FIRST SAMPLE PRECEEDING, U =";U1
700 PRINT "SECOND SAMPLE PRECEEDING, U =";U2
710 END
