1 3 PRINT "UNISTA"
  2 5 REM REVISED FEB 5, 1975
  3 6 REM THE SORT USED IN THIS PROGRAM IS SLOW
  4 10 REM:   UNISTA      [DO NOT RESEQUENCE]
  5 12 PRINT "DO YOU WANT INSTURCTIONS?  (YES OR NO)"
  6 13 INPUT Q1$
  7 14 IF Q1$ = "YES" THEN 20
  8 15 IF Q1$ = "yes" THEN 20
  9 16 IF Q1$ = "no" THEN 700
 10 17 IF Q1$ = "NO" THEN 700
 11 18 PRINT "ANSWER EITHER ""YES"" OR ""NO"""
 12 19 GO TO10
 13 20 PRINT "LINE NUMBERS 50-699 ARE FREE FOR USE AS DATA STATEMENTS, AS REQUIRED"
 14 22 PRINT "ALL VALUES FOR ONE VARIABLE ARE GIVE IN DATA STATEMENTS, FOLLOWED BY"
 15 24 PRINT "ALL VALUES FOR A SECOND VARIABLE, AND SO ON."
 16 26 PRINT "THE WAY TO ARRANGE INPUT IS TO PUT ALL VALUES OF VARIABLE 1 AT LINES"
 17 28 PRINT "100-199, ALL FOR VARIABLE 2 AT LINES 200-299, ECT."
 18 30  PRINT "UNISTA ACCEPTS UP TO 300 OBSERVATIONS ON ONE VARIABLE."
 19 32 PRINT
 20 34 STOP
 21 700 PRINT
 22 730 RESET
 23 740 PRINT
 24 750 PRINT"TYPICAL INTERVAL FOR FREQUENCY DISTRIBUTIONS:";
 25 760 PRINT" L,U =";
 26 770 INPUT W1,W2
 27 780 PRINT
 28 790 PRINT
 29 800 DIM X(300),S(4),Y(4),Z(4)
 30 810 DIM C(50),G(50),E(50),F(50)
 31 820 DEF FNR(M)=.001*INT(1000*M+.5)
 32 830 DATA 1E38,0,0,0,0,0,0,0
 33 840 LET I = 0
 34 850 LET I = I+1
 35 860 READ X(I)
 36 870 IF  X(I) <> 1E38 THEN 850
 37 880 LET N1 = I-1
 38 890 LET N = N1-1
 39 900 FOR I=1 TO 4
 40 910 LET S(I) = 0
 41 920 NEXT I
 42 930 FOR I = 1 TO N1
 43 940 LET Y(1) = X(I)
 44 950 LET Y(2) = X(I)^2
 45 960 LET Y(3) = Y(1)*Y(2)
 46 970 LET Y(4) = Y(2)^2
 47 980 FOR J=1 TO 4
 48 990 LET S(J)=S(J)+Y(J)
 49 1000 NEXT J
 50 1010 NEXT I
 51 1020 LET S = S(1)
 52 1030 FOR I = 1 TO 4
 53 1040 LET Y(I)=(1/N1)*S(I)
 54 1050 NEXT I
 55 1060 LET S(2) = Y(2) - Y(1)^2
 56 1070 LET S(3) = Y(3) - 3*Y(1)*Y(2) + 2*Y(1)^3
 57 1080 LET S(4) = Y(4) - 4*Y(3)*Y(1) + 6*Y(2)*Y(1)^2 - 3*Y(1)^4
 58 1090 LET Y(2) = SQR(S(2))
 59 1100 LET Y(3) = S(3) / (S(2)*Y(2))
 60 1110 LET Y(4) = S(4)/S(2)^2 - 3
 61 1120 PRINT
 62 1130 PRINT "S U M M A R Y    S T A T I S T I C S"
 63 1140 PRINT
 64 1150 PRINT"    NUMBER OF VARIATES =";N1
 65 1160 PRINT"       ARITHMETIC MEAN =";Y(1)
 66 1170 PRINT"    STANDARD DEVIATION =";Y(2)
 67 1180 PRINT"              VARIANCE =";S(2)
 68 1190 PRINT"    COEFF OF VAR (PCT) =  ";FNR(100*Y(2)/Y(1))
 69 1200 PRINT"     STANDARD SKEWNESS = ";FNR(Y(3))
 70 1210 PRINT"       STANDARD EXCESS = ";FNR(Y(4))
 71 1220 PRINT
 72 1230 PRINT
 73 1240 REM  SORT
 74 1250 FOR I = 1 TO N
 75 1260 FOR J = I+1 TO N1
 76 1270 IF X(I)<X(J) THEN  1310
 77 1280 LET Y1=X(I)
 78 1290 LET X(I)=X(J)
 79 1300 LET X(J)=Y1
 80 1310 NEXT J
 81 1320 NEXT I
 82 1330 PRINT"O R D E R   S T A T I S T I C S"
 83 1340 PRINT
 84 1350 PRINT"      SMALLEST VARIATE =";X(1)
 85 1360 LET P1=10
 86 1370 GOSUB 2360
 87 1380 LET T1=P2
 88 1390 PRINT"          LOWER DECILE =";T1
 89 1400 LET P1=25
 90 1410 GOSUB 2360
 91 1420 LET T2=P2
 92 1430 PRINT"        FIRST QUARTILE =";T2
 93 1440 LET P1=50
 94 1450 GOSUB 2360
 95 1460 PRINT"                MEDIAN =";P2
 96 1470 LET P5=P2
 97 1480 LET P1=75
 98 1490 GOSUB 2360
 99 1500 LET T3=P2
100 1510 PRINT"        THIRD QUARTILE =";T3
101 1520 LET P1=90
102 1530 GOSUB 2360
103 1540 LET T4=P2
104 1550 PRINT"          UPPER DECILE =";T4
105 1560 PRINT"       LARGEST VARIATE =";X(N1)
106 1570 PRINT
107 1580 LET  U=X(N1)-X(1)
108 1590 PRINT"           TOTAL RANGE =";U
109 1600 PRINT"          DECILE RANGE =";T4-T1
110 1610 PRINT"   SEMI-QUARTILE RANGE =";(T3-T2)/2
111 1620 PRINT"     BOWLEY'S SKEWNESS = ";FNR((T3+T2-2*P5)/(T3-T2))
112 1630 PRINT"      PEARSON SKEWNESS = ";FNR(3*(Y(1)-P5)/Y(2))
113 1640 PRINT
114 1650 PRINT
115 1660 PRINT
116 1670 LET D=ABS(W2-W1)
117 1680 IF D=0 THEN  2510
118 1690 LET  Y1=W1-INT((W1-X(1))/D+ 1.99999)*D
119 1700 LET  L=INT((X(N1)-Y1+.00001)/D)+1
120 1710 IF  L>50  THEN  2450
121 1720 FOR I=1 TO L+2
122 1730 LET  C(I)=Y1+ (I-1)*D
123 1740 LET  F(I)=0
124 1750 LET  E(I)=0
125 1760  NEXT  I
126 1770 PRINT"      F R E Q U E N C Y     D I S T R I B U T I O N"
127 1780 PRINT
128 1790 PRINT"                   UP TO BUT"," ","   PERCENT"
129 1800 PRINT"        FROM     NOT INCLUDING   FREQUENCY","   FREQUENCY"
130 1810 PRINT
131 1820 FOR I = 1 TO N1
132 1830 LET H=INT((1+1E-8)*(X(I)-C(1))/D) + 2
133 1840 LET F(H)=F(H)+1
134 1850 LET E(H)=E(H)+X(I)
135 1860 NEXT I
136 1870 LET  J = 1
137 1880 LET J=J+1
138 1890 LET G(J)=100*F(J)/N1
139 1900 PRINT C(J-1),C(J),F(J),FNR(G(J))
140 1910 IF  J=L+2  THEN  1930
141 1920 GOTO 1880
142 1930 FOR J = 3 TO L+1
143 1940 LET F(J)=F(J-1)+F(J)
144 1950 LET G(J)=100*F(J)/N1
145 1960 LET E(J)=E(J-1)+E(J)
146 1970 NEXT J
147 1980 PRINT
148 1990 PRINT
149 2000 PRINT"      C U M U L A T I V E     D I S T R I B U T I O N"
150 2010 PRINT
151 2020 PRINT"                  NUMBER LESS    % LESS          VARIATE SUM %"
152 2030 PRINT"       VALUE      THAN VALUE     THAN VALUE     LESS THAN VALUE"
153 2040 PRINT
154 2050 LET  J = 1
155 2060 LET J=J+1
156 2070 LET E(J)=100*E(J)/S
157 2080 PRINT C(J),F(J),FNR(G(J)),FNR(E(J))
158 2090 IF  J=L+1  THEN  2110
159 2100 GOTO 2060
160 2110 PRINT
161 2120 PRINT
162 2130 PRINT"O R D E R E D     A R R A Y"
163 2140 PRINT
164 2150 LET M=INT(N1/4-.05)+1
165 2160 LET H=4*(M-1)
166 2170 LET L=N1-H
167 2180 FOR I = 1 TO M-1
168 2190 LET K1=I+M
169 2200 IF L=1 THEN  2230
170 2210 LET K2=I+2*M
171 2220 GOTO 2240
172 2230 LET K2=I+2*M-1
173 2240 IF (L-1)*(L-2)=0 THEN  2270
174 2250 LET K3=I+3*M
175 2260 GOTO 2280
176 2270 LET K3=I+3*M-2/L
177 2280 PRINT X(I),X(K1),X(K2),X(K3)
178 2290 NEXT I
179 2300 FOR I = 2 TO L+1
180 2310 PRINT X((I-1)*M),
181 2320 NEXT I
182 2330 PRINT
183 2340 STOP
184 2350 REM "SUBROUTINE"
185 2360 LET G5 = P1*(N1+1)/100
186 2370 LET  P2 = X(1)
187 2380 IF G5<1 THEN  2440
188 2390 LET P2=X(N1)
189 2400 IF G5>N1 THEN  2440
190 2410 LET Q5 = INT(G5)
191 2420 LET  H5=G5-Q5
192 2430 LET P2=H5*X(Q5+1)+(1-H5)*X(Q5)
193 2440 RETURN
194 2450 PRINT
195 2460 PRINT"INTERVAL IS TOO SMALL.  MAXIMUM IS 50 CLASSES"
196 2470 PRINT"RESPECIFY L,U";
197 2480 INPUT W1,W2
198 2490 GOTO 1640
199 2510 END