BASIC program to demo moving averages

When noise makes it very difficult to recognize patterns, a moving average may help. Usually the data points are weighted to make one or two more important than the others. A typical formula is:
moving average = (a + 2 b + c) / 4
The 4 comes from the sum of one a, two b's, and one c.

Please download this program, pop into Qbasic, and delete extraneous text. To see effects of changing noise, see Command 70. To weight differently, see Command 120.

10 REM demo of moving averages, H. Bungay, 7Nov97
20 X = 0
30 SCREEN 9
32 PRINT "Blue line is noisy data, red line is moving average."
40 X = X + .35
50 IF X > 58 THEN X = 0: CLS
60 Y1 = 80 + 70 * SIN(X)
70 Y = Y1 + 120 * (RND - .5): ' change multiplier to change noise
80 LINE (10 * (X - .35) + 9.649999, 260 - A)-(10 * X + 10, 260 - Y), 1
90 C = B
100 B = A
110 A = Y
120 M = (A + 2 * B + C) / 4
130 LINE (10 * (X - .35) + 9.399999, 260 - MO)-(10 * X + 9.649999, 260 - M), 4
140 MO = M
150 LOCATE 2, 1
160 INPUT "Hold down the ENTER key "; A$
170 GOTO 40