Test of Means


Language: GWBasic.

Objective: Test of Means using the t-Student Distribution.


***** Begin of Program Listing *****

10 REM   ***
15 REM   ***    TEST OF MEANS USING THE t DISTRIBUTION
20 REM   ***
35 REM   ***
40 REM   ***                 Developed by
45 REM   ***     Antonio Augusto Gorni - February 24, 1990
50 REM   ***            Lattest Revision: 13/01/1995
55 REM   ***
60 REM   ***                Version 1.1995
65 REM   ***
100 DIM X(34), Y(34), FD(34), A(34), B(34), C(34), R(34)
105 CLS : KEY OFF: SCREEN 1: SCREEN 0: LOCATE 6
110 PRINT STRING$(40, "*"); : PRINT "*"; TAB(40); "*";
120 BF$ = "S   T   U   D   E   N   T": PRINT "*"; TAB((40 - LEN(BF$)) / 2 + 1); BF$; TAB(40); "*"; : PRINT "*"; TAB(40); "*"; : PRINT "*"; TAB(40); "*";
130 BF$ = "Developed by:": PRINT "*"; TAB((40 - LEN(BF$)) / 2 + 1); BF$; TAB(40); "*"; : PRINT "*"; TAB(40); "*";
140 BF$ = "Antonio Augusto GORNI - OTPL": PRINT "*"; TAB((40 - LEN(BF$)) / 2 + 1); BF$; TAB(40); "*"; : PRINT "*"; TAB(40); "*";
150 BF$ = "February 1990": PRINT "*"; TAB((40 - LEN(BF$)) / 2 + 1); BF$; TAB(40); "*"; : PRINT "*"; TAB(40); "*"; : PRINT STRING$(40, "*");
160 FOR I = 1 TO 5000: NEXT I: GOSUB 1380: SCREEN 2: SCREEN 0
170 CLS
180 B$ = CHR$(7): ON ERROR GOTO 1510
190  DIM DADOS(2, 350), VS(2, 30)
200 POKE 1845, 0: CLS : BF$ = "TEST OF MEANS USING THE t DISTRIBUTION": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$
210  LOCATE 7
220  COLOR 7, 0: PRINT TAB(29); "<1> Data Input"
230  PRINT
240  PRINT TAB(29); "<2> Data Correction"
250  PRINT : PRINT TAB(29); "<3> Data Suppression"
260  PRINT
270  PRINT TAB(29); "<4> Data Output"
280  PRINT
290  PRINT TAB(29); "<5> Test of Means"
300 PRINT
310  PRINT TAB(29); "<6> End"
320  LOCATE 21
330  PRINT TAB(29); "Your Choice? "; : COLOR 7, 0: INPUT "", R: IF R < 1 OR R > 7 THEN PRINT B$: GOTO 320
340  ON R GOTO 350, 630, 670, 770, 1100, 1340
350  CLS
360  COLOR 0, 7: BF$ = "DATA INPUT": LOCATE , (80 - LEN(BF$)) / 2 + 1: PRINT BF$
370  LOCATE 7
380  COLOR 7, 0: PRINT TAB(35); "<1> New Data"
390  LOCATE 12
400  PRINT TAB(35); "<2> More Data"
410  LOCATE 19
420  PRINT TAB(35); "Your Choice? "; : INPUT "", RE: IF RE < 1 OR RE > 2 THEN PRINT B$: GOTO 410
430  IF RE = 1 THEN N(1) = 0: N(2) = 0
440  CLS : COLOR 0, 7: BF$ = "INPUT OPTIONS": LOCATE , (80 - LEN(BF$)) / 2 + 1: PRINT BF$
450  LOCATE 7
460  COLOR 7, 0: PRINT TAB(35); "<1> Keyboard"
470  LOCATE 12
480  PRINT TAB(35); "<2> Disk"
490  LOCATE 19
500  PRINT TAB(35); "Your Choice? "; : INPUT "", RE: IF RE < 1 OR RE > 2 THEN PRINT B$: GOTO 490
510  ON RE GOTO 520, 580
520  CLS : BF$ = "INPUT VIA KEYBOARD": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: POKE 1845, 3: LOCATE 7
530 FOR I = 1 TO 2: PRINT : PRINT : PRINT : PRINT "Enter Data of the Point #"; I: PRINT "Write  to Finish."
540 N(I) = N(I) + 1: PRINT : PRINT "#"; N(I); " ==> "; : INPUT "", B1$
550  IF B1$ = "END" THEN N(I) = N(I) - 1: GOTO 570
560 DADOS(I, N(I)) = VAL(B1$): GOTO 540
570 NEXT I: GOTO 200
580  CLS : BF$ = "INPUT VIA DISK": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0
590  LOCATE 10: POKE 1845, 3: PRINT "Input File (? to List Directory)? ": PRINT : INPUT "", AQ$: IF AQ$ = "?" THEN FILES: PRINT : PRINT : INPUT "Press   to Continue...", R$: CLS : GOTO 590
600 AQ$ = AQ$ + ".STD"
610  LOCATE 20: COLOR 31, 0: PRINT "READING "; AQ$: COLOR 7, 0: OPEN "I", #1, AQ$: FOR K = 1 TO 2: INPUT #1, NR(K): FOR I = 1 TO NR(K): INPUT #1, DADOS(K, N(K) + I): NEXT I, K
620  CLOSE #1: FOR I = 1 TO 2: N(I) = N(I) + NR(I): NEXT I: COLOR 7, 0: GOTO 200
630  CLS : BF$ = "DATA CORRECTION": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: PRINT : PRINT : POKE 1845, 3: LOCATE 6
640  INPUT "Data Set Number (=0 to Finish)? ", IC: IF IC = 0 THEN 200
650 INPUT "Point Number? ", ID
660  PRINT : PRINT "X = "; DADOS(IC, ID); TAB(20); : INPUT DADOS(IC, ID): PRINT : PRINT : PRINT : GOTO 640
670  CLS : BF$ = "DATA SUPPRESSION ": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: POKE 1845, 3: ISX = 0: LOCATE 5
680  INPUT "Data Set Number (=0 to Finish)? ", IC: IF IC = 0 THEN 730
690 INPUT "Point Number? ", ID
700  PRINT : PRINT : PRINT DADOS(IC, ID): PRINT : PRINT : PRINT B$; : INPUT "Confirm (Y/N)! ", BF$: PRINT : PRINT : PRINT : IF BF$ = "N" THEN 680
710  IF BF$ <> "Y" THEN 700
720 ISX = ISX + 1: VS(IC, ISX) = IC: GOTO 680
730  IF ISX = 0 THEN 200
740  PRINT : PRINT : PRINT : COLOR 31, 0: PRINT B$; "MAKING SUPPRESSIONS...": COLOR 7, 0: FOR K = 1 TO 2: FOR I = 1 TO ISX - 1: FOR J = I + 1 TO ISX: IF VS(K, J) > VS(K, I) THEN RZ = VS(K, J): VS(K, J) = VS(K, I): VS(K, I) = RZ
750  NEXT J, I, K
760  FOR K = 1 TO 2: FOR J = 1 TO ISX: FOR I = VS(K, J) TO N(K) - 1: DADOS(K, I) = DADOS(K, I + 1): NEXT I: N(K) = N(K) - 1: NEXT J, K: CLS : GOTO 200
770  CLS : COLOR 0, 7: BF$ = "DATA OUTPUT": LOCATE , (80 - LEN(BF$)) / 2 + 1: PRINT BF$: NPONTOS = N(1): IF N(2) > N(1) THEN NPONTOS = N(2)
780  LOCATE 7
790  COLOR 7, 0: PRINT TAB(35); "<1> Screen"
800  LOCATE 11
810  PRINT TAB(35); "<2> Printer"
820  LOCATE 15
830  PRINT TAB(35); "<3> File"
840  LOCATE 21
850  PRINT TAB(35); "Your Choice? "; : INPUT "", RE: IF RE < 1 OR RE > 3 THEN PRINT B$: GOTO 840
860  ON RE GOTO 870, 940, 1040
870  CLS : BF$ = "DATA OUTPUT": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0:    PRINT : PRINT TAB(10); "Data Set #1"; TAB(30); "Data Set #2": PRINT : POKE 1845, 5
880 CL = 0: FOR I = 1 TO NPONTOS: PRINT "#"; I;
890 IF I <= N(1) THEN PRINT TAB(10); DADOS(1, I);
900 IF I <= N(2) THEN PRINT TAB(30); DADOS(2, I)
910 CL = CL + 1
920  IF CL >= 17 AND I < NPONTOS THEN PRINT : COLOR 31, 0: PRINT "Press   to Continue..."; : COLOR 7, 0: CL = 0: INPUT "", R$: LOCATE 5, 1: FOR LIN = 5 TO 24: PRINT STRING$(80, " "): NEXT: LOCATE 5, 1
930  NEXT: PRINT : COLOR 31, 0: INPUT "Press  to Continue.", R$: COLOR 7, 0: CLS : GOTO 200
940  CLS : BF$ = "DATA OUTPUT VIA PRINTER": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: LOCATE 8: POKE 1845, 3
950  PRINT "Enter Data Identification Message."; : PRINT : LINE INPUT "", BF$: PRINT : PRINT : PRINT : PRINT "Prepare Printer, Mark Start of Report;": PRINT "Press  to Continue.": NP = 1
960  PRINT : PRINT : INPUT "Press  to Continue...", R$
970  LPRINT "Data for Test of Means - " + BF$: LPRINT "Page no. "; NP; " *** "; DATE$; ", "; TIME$: LPRINT : LPRINT : LPRINT
980 CL = 0: FOR I = 1 TO NPONTOS: LPRINT "#"; I;
990 IF I <= N(1) THEN LPRINT TAB(10); DADOS(1, I);
1000 IF I <= N(2) THEN LPRINT TAB(30); DADOS(2, I)
1010 CL = CL + 1
1020  IF CL >= 55 AND I < N THEN NP = NP + 1: LPRINT CHR$(12): LPRINT "Data for Test of Means - " + BF$: LPRINT "Pagina no. "; NP: LPRINT : CL = 0
1030  NEXT: LPRINT CHR$(12):     CLS : GOTO 200
1040  CLS : BF$ = "DATA SAVING IN DISK ": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: LOCATE 10: POKE 1845, 3
1050  PRINT "File Name (? to List Directory)? ": PRINT : INPUT "", AQ$: IF AQ$ = "?" THEN FILES: PRINT : PRINT : INPUT "Press  to Continue...", R$: CLS : GOTO 1050
1060 AQ$ = AQ$ + ".STD"
1070 LOCATE 20: COLOR 31, 0: PRINT "Saving in "; AQ$
1080  OPEN "O", #1, AQ$: FOR K = 1 TO 2: WRITE #1, N(K): FOR I = 1 TO N(K): WRITE #1, DADOS(K, I): NEXT I, K: CLOSE #1
1090  COLOR 7, 0: CLS : GOTO 200
1100  CLS : BF$ = "TEST OF MEANS": PRINT TAB((80 - LEN(BF$)) / 2 + 1); : COLOR 0, 7: PRINT BF$: COLOR 7, 0: PRINT : PRINT : POKE 1845, 3
1110 FOR I = 1 TO 2: MEDIA(I) = 0: FOR K = 1 TO N(I): MEDIA(I) = MEDIA(I) + DADOS(I, K): NEXT K: MEDIA(I) = MEDIA(I) / N(I)
1120 DP(I) = 0: FOR K = 1 TO N(I): DP(I) = DP(I) + (DADOS(I, K) - MEDIA(I)) ^ 2: NEXT K: DP(I) = SQR(DP(I) / N(I)): NEXT I
1130 DF = N(1) + N(2) - 2: SIGMA = SQR((N(1) * DP(1) ^ 2 + N(2) * DP(2)) / DF)
1140 T = ABS((MEDIA(1) - MEDIA(2)) / (SIGMA * SQR(1 / N(1) + 1 / N(2))))
1150 FOR I = 1 TO 34: IF DF = X(I) THEN TSTUDENT = Y(X(I)): GOTO 1230
1160 NEXT I
1170 XX = DF
1180 N1 = N - 1
1190  FOR I = 1 TO N1: IF XX <= X(I + 1) GOTO 1210
1200  NEXT
1210 DM = XX - X(I): DP = X(I + 1) - XX: DL = X(I + 1) - X(I): F = FD(I) * DP * (DP * DP / DL - DL) / 6 + FD(I + 1) * DM * (DM * DM / DL - DL) / 6 + Y(I) * DP / DL + Y(I + 1) * DM / DL
1220 TSTUDENT = F
1230 PRINT : PRINT TAB(10); "Set 1"; TAB(45); "Set 2": PRINT : PRINT "No:"; TAB(10); N(1); TAB(45); N(2): PRINT : PRINT "Mean:"; TAB(10); MEDIA(1); TAB(45); MEDIA(2): PRINT : PRINT "S.D.:"; TAB(10); DP(1); TAB(45); DP(2)
1240 PRINT : PRINT : PRINT "Degrees of Freedom: "; DF: PRINT : PRINT "t Table (95% Confidence): "; TAB(35); TSTUDENT: PRINT "t Samples:"; TAB(35); T: PRINT
1250 IF TSTUDENT <= T THEN PRINT "The Samples are Different!" ELSE PRINT "The Samples are not Different!"
1260 LOCATE 22, 1: INPUT "Do You Want to Print Results (Y/N)? ", BF$: IF BF$ <> "Y" AND BF$ <> "N" THEN PRINT B$: GOTO 1260
1270 IF BF$ = "N" THEN 200
1280 PRINT : PRINT : PRINT : PRINT "Prepare Printer;": PRINT "Enter Data Identification Message.": LINE INPUT "", BF$
1290  LPRINT "TEST OF MEANS USING THE t-DISTRIBUTION": LPRINT "Versao 1.1990, IBM-XT *** "; DATE$; ", "; TIME$: LPRINT : LPRINT BF$: LPRINT : LPRINT
1300 LPRINT TAB(10); "Set 1"; TAB(45); "Set 2": LPRINT : LPRINT "Mean:"; TAB(10); MEDIA(1); TAB(45); MEDIA(2): LPRINT : LPRINT "S.D.:"; TAB(10); DP(1); TAB(45); DP(2)
1310 LPRINT : LPRINT : LPRINT "Degrees of Freedom: "; DF: LPRINT : LPRINT "t Table (95% Confidence): "; TAB(35); TSTUDENT: LPRINT "t Samples: "; TAB(35); T: LPRINT
1320 IF TSTUDENT <= T THEN LPRINT "The Samples are Different!" ELSE LPRINT "The Samples are not Different!"
1325 LPRINT : LPRINT : LPRINT
1330 GOTO 200
1340 KEY ON: ON ERROR GOTO 0: CLS : END
1350 REM
1360 REM  *** SUBROTINA DA INTERPOLACAO SPLINE ***
1370 REM
1380  READ N
1390  FOR I = 1 TO N: READ X(I), Y(I): NEXT I
1400  DATA  34
1410  DATA 1,6.31, 2,2.92, 3,2.35, 4,2.13, 5,2.02, 6,1.94, 7,1.90, 8,1.86, 9,1.83, 10,1.81, 11,1.80, 12,1.78, 13,1.77, 14,1.76, 15,1.75, 16,1.75, 17,1.74, 18,1.73, 19,1.73, 20,1.72
1420 DATA 21,1.72, 22,1.72, 23,1.71, 24,1.71, 25,1.71, 26,1.71, 27,1.70, 28,1.70, 29,1.70, 30,1.70, 40,1.68, 60,1.67, 120,1.66, 1000,1.645
1430 LA = 1: N2 = N - 2: N1 = N - 1: C(1) = X(2) - X(1)
1440  FOR I = 2 TO N1: C(I) = X(I + 1) - X(I): A(I) = C(I - 1): B(I) = 2 * (A(I) + C(I)): R(I) = 6 * ((Y(I + 1) - Y(I)) / C(I) - (Y(I) - Y(I - 1)) / C(I - 1)): NEXT
1450 B(2) = B(2) + LA * C(1): B(N1) = B(N1) + LA * C(N1)
1460  FOR I = 3 TO N1: T = A(I) / B(I - 1): B(I) = B(I) - T * C(I - 1): R(I) = R(I) - T * R(I - 1): NEXT
1470 FD(N1) = R(N1) / B(N1)
1480  FOR I = 2 TO N2: NI = N - I: FD(NI) = (R(NI) - C(NI) * FD(NI + 1)) / B(NI): NEXT
1490 FD(1) = LA * FD(2): FD(N) = LA * FD(N1)
1500 RETURN
1510 CLS : LOCATE 12: PRINT B$; "ERROR"; ERR; " IN LINE "; ERL; "!": INPUT "", BF$: GOTO 200

***** End of Program Listing ******


Return to the Software Menu.

Last Update: 27 June 1996
© Antonio Augusto Gorni