100 CONST N = 11 110 DEFDBL A-H, O-Z: REM Define everything double precision except the indices. 120 DIM X(N), Y(N) 130 DATA 1981.,1982.,1983.,1984.,1985.,1986.,1987.,1988.,1989.,1990.,1991. 140 DATA 90.08,90.57,90.76,91.30,91.57,92.44,92.87,93.68,93.85,94.49,94.88 150 FOR I = 1 TO N: READ X(I): NEXT I 160 FOR I = 1 TO N: READ Y(I): NEXT I 170 SUMX = 0!: SUMY = 0!: SUMX2 = 0!: SUMXY = 0!: SUMX2 = 0! 180 SIGMAX = 0!: SIGMAY = 0!: SIGMAXY = 0! 190 FOR I = 1 TO N 200 SUMX = SUMX + X(I): SUMY = SUMY + Y(I): SUMX2 = SUMX2 + X(I) * X(I) 210 SUMXY = SUMXY + X(I) * Y(I): SUMY2 = SUMY2 + Y(I) * Y(I) 220 NEXT I 230 DELTA = CDBL(N) * SUMX2 - SUMX * SUMX 240 A = (SUMX2 * SUMY - SUMX * SUMXY) / DELTA 250 B = (CDBL(N) * SUMXY - SUMX * SUMY) / DELTA 260 CLS : PRINT "A (x-intercept) = "; A 270 PRINT "B (slope) = "; B 280 XMU = SUMX / CDBL(N): YMU = SUMY / CDBL(N) 290 FOR I = 1 TO N 300 SIGMAX = SIGMAX + (XMU - X(I)) * (XMU - X(I)) 310 SIGMAY = SIGMAY + (YMU - Y(I)) * (YMU - Y(I)) 320 SIGMAXY = SIGMAXY + (XMU - X(I)) * (YMU - Y(I)) 330 NEXT I 340 R = SIGMAXY / SQR(SIGMAX * SIGMAY) 350 PRINT "Correlation Coefficient r = "; R: SIGMAY = 0! 360 FOR I = 1 TO N 370 SIGMAY = SIGMAY + (Y(I) - A - B * X(I)) ^ 2 380 PRINT USING "#### ##.##### ##.#####"; X(I); Y(I); A + B * X(I) 390 NEXT I 400 SIGMAY = SQR(SIGMAY / (CDBL(N) - 2!)) 410 PRINT "sigma_y (unbiased) = "; SIGMAY 420 PRINT "sigma_x (unbiased) = "; SIGMAY * SQR(SIGMAX / DELTA) 430 END