Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap1_198111 - decus/20-0020/stat11.sta
There are 2 other files named stat11.sta in the archive. Click here to see a list.
100'  NAME--STAT11
110'
120'  DESCRIPTION--COMPUTES THE SPEARMAN RANK CORRELATION COEFFICIENT
130'  FOR TWO SERIES OF DATA.
140'
150'  SOURCE--UNKNOWN
160'
170'  INSTRUCTIONS--PUT DATA IN LINE 900 AND FOLLOWING.
180'  ENTER DATA IN THE FOLLOWING ORDER: FIRST THE COMMON LENGTH
190'  OF EACH SERIES, THEN THE ELEMENTS OF THE SERIES BY GROUPS
200'  THAT IS X1,Y1,X2,Y2,....ETC.
210'  SAMPLE DATA IS IN LINE 900.
220'
230'
240'  *  *  *  *  *  *  *   MAIN PROGRAM   *  *  *  *  *  *  *  *
250'
260   DIM A(100), B(100)
270   READ N
280  FOR I = 1 TO N
290      READ A(I), B(I)
300  NEXT I
310  FOR I = 1 TO N - 1
320     LET X = A(1)
330     LET Y = B(1)
340     LET Q = 1
350     FOR J = 2 TO N - I + 1
360        IF X >= A(J) THEN 400
370        LET X = A(J)
380        LET Y = B(J)
390        LET Q = J
400     NEXT J
410     IF Q = J THEN 460
420     LET A(Q) = A(J)
430     LET A(J) = X
440     LET B(Q) = B(J)
450     LET B(J) = Y
460  NEXT I
470  REM NOW WE REPLACE THE ELEMENT BY ITS AVERAGE RANK
480  FOR I = 1 TO N
490     LET X = A(I)
500     FOR J = I + 1 TO N
510        IF X <> A(J) THEN 540
520     NEXT J
530     LET J = N + 1
540     LET Z = (J + I - 1)/2
550     FOR K = I TO J - 1
560        LET A(K) = Z
570     NEXT K
580     LET I = J - 1
590  NEXT I
600  IF P = 1 THEN 690
610  REM NOW WE INTERCHANGE A AND B AND SORT AGAIN.
620  FOR I = 1 TO N
630     LET T = A(I)
640     LET A(I) = B(I)
650     LET B(I) = T
660  NEXT I
670  LET P = 1
680  GO TO 310
690  REM NOW WE START COMPUTING THE CORRELATION COEFFICIENT.
700  FOR I = 1 TO N
710     LET S1 = S1 + A(I) * A(I)
720     LET S2 = S2 + B(I) * B(I)
730     LET S3 = S3 + A(I) * B(I)
740  NEXT I
750  LET S = N * N * (N+1) * (N+1) / 4
760  LET D1 = N * S1 - S
770  LET D2 = N * S2 - S
780  LET D = D1 * D2
790  IF D <> 0 THEN 820
800  LET R = 0
810  GO TO 830
820  LET R = (N * S3 - S)/SQR(D)
830  PRINT "SPEARMAN RANK CORRELATION COEFFICIENT"
840  PRINT "  R = ";R
850  STOP
900  DATA  5, 480, 56, 500, 61, 520, 78, 540, 71, 56, 82
910END