1 REM TIMEMOV  
5 CLS  
10 PRINT  "SIMPLE MOVING AVERAGE SMOOTHING PROGRAM  
20 PRINT   
30 PRINT  "THIS PROGRAM COMPUTES AN M-PERIOD MOVING AVERAGE FOR A SET OF  
40 PRINT  "VALUES. M SHOULD BE AN ODD INTEGER,E.G 3,5,7,ETC. THERE SHOULD  
50 PRINT  "BE MORE THAN M OBSERVATIONS TO GET MEANINGFUL RESULTS.  
60 PRINT :INPUT  "PRESS ENTER TO BEGIN.";Z9  
90  Z1$="      ###             #####.## "  
95  Z2$="      ###             #####.##          #####.####"  
100 CLS  
120 PRINT  @  320," "  
130 PRINT  "THIS IS AN M-PERIOD MOVING AVERAGE.WHAT DOES M EQUAL";  
140 INPUT  M  
150 IF  M = INT(M)  AND  M>0  AND  M/2<>INT(M/2)  THEN  GOTO  180  
160 GOSUB 2000 :REM INPUT ERROR SUBROUTINE  
170 GOTO  100  
180 PRINT   
190 PRINT  "GIVE AN UPPER BOUND ON THE NUMBER OF OBSERVATIONS YOU INTEND TO  
200 PRINT  "USE.THIS WILL BE THE GREATEST NUMBER OF OBSERVATIONS POSSIBLE.  
210 INPUT  "NUMBER = ";N  
220 DIM  A(N),S(N)  
225 CLS  
230 PRINT  "INPUT OBSERVATIONS 1 BY 1, PRESSING ENTER AFTER EACH.  
240 PRINT  "INPUT 99999 AND ENTER WHEN DONE."  
250 PRINT   
260 PRINT  "PRESS ENTER TO BEGIN";:INPUT  Z9  
300 CLS  
310 I=0:S=0  
320 PRINT  "OBSERVATION ";I+1;" (99999 TO END)";:INPUT  A(I+1)  
330 IF  A(I+1)=99999  THEN  GOTO  350  
340 I=I+1:GOTO  320  
350 T=(M-1)/2+1  
360 FOR  K=1  TO  M  
370 S=S+A(K)  
380 NEXT  K  
390 S(T)=S/M  
400 FOR  L=1  TO  I-M  
410 S(T+L)=S(T+L-1)+(A(T+L+(M-1)/2) - A(T+L-(M-1)/2-1))/M  
420 NEXT  L  
430 GOSUB  2500  
440 FOR  L= 1  TO  (M-1)/2  
450 PRINT USING  Z1$;L,A(L)  
460 IF  L/14 = INT(L/14)  THEN  GOSUB  3000  
470 NEXT  L  
475 FOR  L=(M-1)/2 +1  TO  I-(M-1)/2-1  
480 PRINT USING  Z2$;L,A(L),S(L)  
490 IF  L/14 = INT(L/14)  THEN  GOSUB  3000  
500 NEXT  L  
510 FOR  L=I-(M-1)/2  TO  I  
520 PRINT USING  Z1$;L,A(L)  
530 IF  L/14=INT(L/14)  THEN  GOSUB  3000  
540 NEXT  L  
550 END  
2000 REM INPUT ERROR SUBROUTINE  
2010 PRINT :PRINT  "INPUT ERROR. TRY AGAIN."  
2020 FOR  I= 1  TO  300:NEXT  I  
2030 RETURN   
2500 REM HEADING SUBROUTINE  
2510 CLS  
2520 PRINT  "OBSERVATION #   OBSERVATION VALUE   SMOOTHED VALUE  
2530 RETURN   
3000 REM FULL SCREEN SUBROUTINE  
3010 INPUT  "TO CONTINUE PRESS ENTER";Z9  
3020 CLS  
3030 GOSUB  2500  
3040 RETURN   

