Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap1_198111 - decus/20-0020/statea.dem
There are 2 other files named statea.dem in the archive. Click here to see a list.
100'  NAME--STATEACH
110'
120'  DESCRIPTION--TEACH PROGRAM ON COMPUTATION OF BASIC STATISTICS
130'
140'  SOURCE--UNKNOWN
150'
160'  INSTRUCTIONS--TYPE "LIST" AND FOLLOW INSTRUCTIONS.
170'
180'
190'  *  *  *  *  *  *  MAIN PROGRAM  *  *  *  *  *  *  *  *  *
200'
210     NOW THAT YOU UNDERSTAND HOW TO WORK WITH DATA ARRAYED IN
220 MATRICES, CONSIDER SOME OF THE INFORMATION HOU MIGHT LIKE TO KNOW
230 ABOUT THE COLLECTION OF NUMBERS IN A GIVEN ROW OR COLUMN.  YOU HAVE 
240 ALREADY FOUND THE BIGGEST ELEMENT IN A ROW AND THE AVERAGE OF
250 THE ROW.  WHAT ELSE WOULD BE INTERESTING TO KNOW?
260   
270  
280   ***MEAN, VARIANCE, AND STANDARD DEVIATION***
290 
300     ONE OF THE MOST INTERESTING PIECES OF INFORMATION TO KNOW ABOUT
310 A SET OF NUMBERS IS THE STANDARD DEVIATION--A MEASURE  OF HOW THE 
320 NUMBERS DEVIATE OR SPREAD OUT AROUND THE AVRAGE NUMBER(THE MEAN)
330  
340     FOR EXAMPLE, IF THE SET OF DATA IS (3,3,3,3,3) THEN THE MEAN
350 IS  3 AND THE STANDARD DEVIATION IS ZERO BECAUSE THE NUMBERS DON'T
360 DEVIATE AT ALL FROM THE MEAN.  THE NUMBERS HAVE NO SPREAD ABOUT THE
370 MEAN.  HOWEVER, IF YOUR SET OF DATA IS (1,2,3,4,5) THE STANDARD
380 DEVIATION IS  1.41421  . . . BUT WHAT IS THE STANDARD DEVIATION?
390  
400     WELL THE STANDARD DEVIATION IS THE SQUARE ROOT OF THE VARIANCE.
410 BUT WHAT IS THE VARIANCE?  
420  
430     WELL THE VARIANCE IS SORT OF THE AVERAGE DISTANCE AWAY FROM THE
440 MEAN.  WE WILL CONCENTRATE ON FINDING OUT HOW IT IS COMPUTED AND
450 SEE WHAT THE PHRASE "SORT OF AVERAGE DISTANCE" REALLY MEANS.
460  
470     TO COMPUTE THE VARIANCE YOU MUST:
480  
490          FIRST COMPUTE THE MEAN OF THE DATA.
500  
510         SECOND FIND THE DIFFERENCE BETWEEN EACH ELEMENT AND THE
520         MEAN.  IF OUR DATA IS (1,2,3,4,5) THEN THE MEAN IS  3 AND
530         THE FIRST DIFFERENCE IS (3-1).  BUT NOTICE THE LAST 
540         DIFFERENCE IS (3-5).  NOW (3-1)=2  BUT (3-5)= -2.
550         WE DON'T REALLY CARE ABOUT THE MINUS SIGN, WE JUST WANT TO
560         KNOW HOW FAR AWAY THE ELEMENT IS.  SO WE COULD TAKE THE
570         ABSOLUTE VALUE OF (3-1) AND (3-5).  BOTH OF THESE ARE
580         2  .  OR WE COULD SIMPLY SQUARE THE VALUE (3-1) AND
590         (3-5)--REMEMBERING THAT ANY NUMBER SQUARED IS POSITIVE--.
600         SO  INSTEAD OF GETTING THE DISTANCE AWAY FROM THE MEAN WE
610         GET THE SQUARE OF THE DISTANCE AWAY; IN THE EXAMPLE
620         4 INSTEAD OF 2 .
630          FOR HISTORICAL REASONS THE SQUARE OF THE DISTANCES IS
640         THE MEASURE THAT WE WILL USE IN SPITE OF THE FACT THAT
650         ABSOLUTE VALUE MAY APPEAR MORE NATURAL RIGHT NOW.
660     
670         THIRD, WE ADD THE SQUARES OF THE DISTANCE FROM THE MEAN.  
680         THAT IS WE SUM THE SQUARE OF THE DIFFERENCES.  IN OUR 
690         EXAMPLE WE ADD (3-1)^2+(3-2)^2+(3-3)^2+(3-4)^2+(3-5)^2 =
700                         4    +   1    +   0   +   1   +  4= 10
710  
720          FORTH, WE DIVIDE BY THE NUMBER OF ELEMENTS IN OUR SAMPLE
730          TO GET THE  AVERAGE SQUARE DIFFERENCE.  IN OUR EXAMPLE
740          WITH FIVE ELEMENTS  10/5 = 2. AND  2 IS THE VARIANCE
750          OF THE SAMPLE.  
760  
770  
780     REMEMBER WE SAID THE SQUARE ROOT OF THE VARIANCE IS  THE 
790 STANDARD DEVIATION.  SO IN OUR EXAMPLE THE STANDARD 
800 DEVIATION IS THE SQUARE ROOT OF 2, THAT IS 1.41421   .
810  *   *   *   *   *   *   *
820  
830    TRY TO WRITE A PROGRAM THAT READS  FIRST  N, THE NUMBER OF PIECES 
840 OF DATA AND THEN THE DATA AND THEN COMPUTES M, THE MEAN;  V, THE
850 VARIANCE AND D, THE STANDARD DEVIATION.
860 
870    THERE IS A TEST ROUTINE YOU CAN USE IF YOU LABEL YOUR VARIABLES 
880 AS LISTED ABOVE AND IF YOU NAME YOUR PROGRAM  STATBGIN  .
890 IN OTHER WORDS AFTER YOU HAVE EXPERIMENTED WITH VARIOUS SETS
900 OF DATA, YOU MAY TYPE  TEST  TO BE SURE YOUR PROGRAM IS CORRECT.
910   
920 GOOD LUCK. . . . .