home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / turbopas / pas_sci.arc / MEANSTD.LIB < prev    next >
Text File  |  1985-07-21  |  573b  |  24 lines

  1. procedure meanstd
  2.                 (x              : ary;  {array of values}
  3.                  length         : integer;
  4.                  var mean       : real;
  5.                  var std_dev    : real);
  6.  
  7. var
  8.                 i               : integer;
  9.                 sum_x,sum_sq    : real;
  10.  
  11.  
  12.  
  13. begin {main}
  14.  sum_x:=0;
  15.  sum_sq:=0;
  16.  for i:=1 to length do
  17.         begin
  18.          sum_x:=sum_x+x[i];
  19.          sum_sq:=sum_sq+x[i]*x[i]
  20.         end;
  21.  mean:=sum_x/length;
  22.  std_dev:=sqrt((sum_sq-sqr(sum_x)/length)/(length-1))
  23. end     { procedure meanstd };
  24.