CFOG's PIP, June 1986, Volume 4 No. 8, Whole No. 44, page 2

Mc Enroe on MBASIC: Mean and Standard Deviation -- a Short Program

On occasion I've had to teach large sections (i.e., 150+ students) of "Intro to American Government" at Cal State, L.A., and have to resort to multiple- choice exams. I needed some kind of statistical program to help a little in trying to convert raw scores into percentages for grading purposes.

(There's a "Mean, Variance, and Standard Deviation" model in Robert H. Flast's 54 Supercalc Models [Osborne/McGraw-Hill], but it will accept only 52 entries, and the model listing takes up 4 pages of the text.) This is a short program, and will, take 201 entries (which could be enlarged by increasing the DIM). Only problem with it is that if you make a mistake in entering a score, you have to restart, listing each one from the beginning.

1 '******************************
2 '******************************
3 '
5 'filename "MEAN-SD.BAS" to compute
6 'THE MEAN AND STANDARD DEVIATION
7 'from Tom McEnroe, OKOK, with thanks
to Tony Horaites,
8 'Student Asst., CSLA. 1984, 1986.
10 DIM X(200)
20 INPUT "HOW MANY CASES";N
30 INPUT "WHAT IS THE NAME OF THE
VARIABLE";A$
40 PRINT "ENTER EACH VALUE ONE AT A
TIME"
45 '
50 FOR I = 1 TO N
60 INPUT X(I)
70 SM=SM+X(I)
80 NEXT I
90 MN=SM/N
100 FOR I = 1 TO N
110 Y=(X(I)-MN)^2
120 SS=SS+Y
130 NEXT I
140 SD=SQR(SS/N)
150 PRINT "FOR THE VARIABLE ";A$
160 PRINT "THE MEAN IS ";MN; "THE
STANDARD DEVIATION IS";SD
170 END