Basic Statistics Program

Author(s): Imre Auersbacher
Publication: LISTing Newsletter
Date: December 1997
Pages: 9

Food for your TS-2068

The topic this month is mathematics. In particular, the program listed below performs basic statistical analysis for ungrouped data. Statistics, as you all know, is the collection and study of numerical facts or data and their interpretation in mathematical terms. Whether you are analyzing the results of a laboratory experiment or just examining student test scores, the following program should be quite useful.

To use this statistic program, just enter all of your data values. The computer will handle any number of data points, whether you have just two or even 10,000 of them. After feeding in all the data, enter the letter “S” or “Q” (for stop or quit). The computer will then output the following statistical parameters:

1) the number of data points,
2) the minimum data value,
3) the maximum value,
4) the sum of all values,
5) the arithmetic mean or average,
6) the sum of the squares,
7) the variance,
8) the standard deviation, and
9) the variation coefficient.

The first several quantities are simple and self-explanatory. The variance, standard deviation, and variation coefficient are basically measures of the scatter of data about their mean value.

   2 REM  Basic STATISTICS  2068
4 REM By I. Auersbacher 1985
10 ON ERR GO TO 900: LET ss=0: LET sum=0: LET s=-987.1234: LET q=s: LET n=0: BEEP 0.05,23
12 BORDER 5: POKE 23609,10
14 PRINT PAPER 6;" Basic Statistics Package 2068 ": PRINT
16 PRINT "Enter Data points:"
18 PRINT : PRINT "x=";
20 INPUT x: IF x=s THEN BEEP 0.5,-15: BEEP 0.6,-20: GO TO 20
22 PRINT x,: LET max=x: LET min=x: GO SUB 60
25 PRINT "x=";: INPUT x: IF x=s THEN PRINT "S": GO TO 100
30 PRINT x,: GO SUB 50
35 GO TO 25
50 IF x> max THEN LET max=x
55 IF x< min THEN LET min=x
60 LET sum=sum+x: LET ss=ss+x*x: LET n=n+1: RETURN
100 LET ave=sum/n
110 LET var=(ss-(sum*sum)/n)/n
120 LET std=SQR (var*n/(n-1))
130 LET vc=std/ave: BEEP .1,22
200 CLS : PRINT PAPER 6;AT 1,2;"** Solution **": PRINT
210 PRINT "Number/points: ";n
220 PRINT "Minimum value: ";min
230 PRINT "Maximum value: ";max
240 PRINT "Sum of values: ";sum
250 PRINT "Average value: ";ave
260 PRINT "Sum / squares: ";ss
270 PRINT "Variance : ";var
280 PRINT "Std Deviation: ";std
290 PRINT "V Coefficient: ";vc
300 PRINT : PRINT : PRINT TAB 1 PAPER 6;"** End Solution **"
310 ON ERR RESET : STOP : STOP
900 ON ERR RESET
910 BEEP 0.5,-15: BEEP 0.6,-20
920 ON ERR GO TO 900
930 ON ERR CONTINUE

A sample program is given below.

 Basic Statistics Package 2068

 Enter Data points:

 x=102.76            x=110.77
 x=99.76             x=101.88
 x=100               x=113.45
 x=97.55             x=115.11
 x=103.33            x=109.99
 x=99.99             x=107.13
 x=112               x=stop



   ** Solution **

 Number/points:  13
 Minimum value:  97.55
 Maximum value:  115.11
 Sum of values:  1373.72
 Average value:  105.67077
 Sum / squares:  145592.15
 Variance     :  33.084346
 Std Deviation:  5.9867666
 V Coefficient:  .056654898

  ** End Solution **

I. Auersbacher
[address omitted]
Belleville, NJ 07109 CTM

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.