include/MathStatisticMaker.hpp

Go to the documentation of this file.
00001 // MathStatisticMaker.hpp: this file is part of the REGAL project.
00002 //
00003 // REGAL : Random and Exhaustive Generators for Automata - Library
00004 //
00005 // Copyright (C) 2007 Julien DAVID.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 //
00016 #ifndef MATHSTATISTICMAKER
00017 #define MATHSTATISTICMAKER
00018 
00019 #include "StatisticMaker.hpp"
00020 
00021 namespace regal{
00022   
00023   class MathStatisticMaker{
00024   private:
00025     double counter; 
00026     double sum; 
00027     double sum_sum; 
00029   public:
00030     
00035     void addValue(const double & value){
00036       counter++;
00037       sum+=value;
00038       sum_sum+=value*value;
00039     }
00040     
00045     double getMean(){
00046       return sum/counter;
00047     }
00048    
00053     double getVariance(){
00054       double mean=sum/counter;
00055       return sum_sum/counter-mean*mean;
00056     }
00057     
00062     double getStandardDeviation(){
00063       return sqrt(getVariance());
00064     }
00065     
00069     void resetCounter(){
00070       counter=0.;
00071       sum=0.;
00072       sum_sum=0.;
00073     }
00074     
00080     MathStatisticMaker(){
00081       counter=0.;
00082       sum=0.;
00083       sum_sum=0.;
00084     }
00085     
00089     ~MathStatisticMaker(){}
00090     
00091   };
00092   
00093 
00094 }
00095 
00096 #endif 

Generated on Mon Sep 29 16:33:58 2008 for REGAL by  doxygen 1.5.1