Browse Source

+ fixed meanandstddev

michael 25 years ago
parent
commit
5893a28fc2
1 changed files with 6 additions and 5 deletions
  1. 6 5
      rtl/objpas/math.pp

+ 6 - 5
rtl/objpas/math.pp

@@ -604,13 +604,11 @@ begin
     StdDev:=StdDev+Sqr(Data[i]);
     StdDev:=StdDev+Sqr(Data[i]);
     end;
     end;
   Mean:=Mean/N;
   Mean:=Mean/N;
-  StdDev:=StdDev/sqr(N)-Sqr(Mean);
-{  // the following depends on the definition of standard deviation...
+  StdDev:=(StdDev-N*Sqr(Mean));
   If N>1 then
   If N>1 then
     StdDev:=Sqrt(Stddev/(N-1))
     StdDev:=Sqrt(Stddev/(N-1))
   else  
   else  
     StdDev:=0;
     StdDev:=0;
-}
 end;
 end;
 
 
 function variance(const data : array of float) : float;
 function variance(const data : array of float) : float;
@@ -644,7 +642,7 @@ function totalvariance(const data : Pfloat;Const N : Integer) : float;
     else
     else
       begin
       begin
       SumsAndSquares(Data,N,S,SS);
       SumsAndSquares(Data,N,S,SS);
-      Result := SS-Sqr(S)/(N-1);
+      Result := SS-Sqr(S)/N;
       end;
       end;
   end;
   end;
 
 
@@ -858,7 +856,10 @@ end;
 end.
 end.
 {
 {
     $Log$
     $Log$
-    Revision 1.23  2000-07-08 06:45:07  michael
+    Revision 1.24  2000-07-08 07:03:20  michael
+    + fixed meanandstddev
+
+    Revision 1.23  2000/07/08 06:45:07  michael
     + Added some functions
     + Added some functions
 
 
     Revision 1.22  2000/07/06 21:59:25  michael
     Revision 1.22  2000/07/06 21:59:25  michael