Main   Class Hierarchy   Classes   Compound List   Files   Compound Members   File Members   Pages  

statistics.h

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 /** @file statistics.h
00003     Search statistics.
00004 
00005     $Id: statistics_8h-source.html,v 1.1.1.1 2003/08/07 19:41:39 emarkus Exp $
00006     $Source: /usr/cvsroot/www_pathfind/libpathfind/0.1.0/doc/statistics_8h-source.html,v $
00007 */
00008 //-----------------------------------------------------------------------------
00009 
00010 #ifndef PATHFIND_STATISTICS_H
00011 #define PATHFIND_STATISTICS_H
00012 
00013 #include <iostream>
00014 #include <math.h>
00015 #include <map>
00016 #include <string>
00017 
00018 //-----------------------------------------------------------------------------
00019 
00020 namespace PathFind
00021 {
00022     using namespace std;
00023 
00024     /** Keeps track of the mean and variance of a variable. */
00025     class Statistics
00026     {
00027     public:
00028         Statistics();
00029 
00030         void add(double value);
00031 
00032         void add(const Statistics& statistics);
00033 
00034         void clear();
00035 
00036         double getCount() const
00037         {
00038             return m_count;
00039         }
00040 
00041         double getMean() const
00042         {
00043             return m_sum / m_count;
00044         }
00045 
00046         double getDeviation() const
00047         {
00048             return sqrt(getVariance());
00049         }
00050 
00051         double getVariance() const;
00052 
00053         void print(ostream& o) const;
00054 
00055     private:
00056         double m_count;
00057 
00058         double m_sum;
00059 
00060         double m_sumSq;
00061     };
00062 
00063     /** Set of statistics variables. */
00064     class StatisticsCollection
00065     {
00066     public:
00067         /** Add the statistics of another collection.
00068             The collections must contain the same entries.
00069         */
00070         void add(const StatisticsCollection& collection);
00071 
00072         void clear();
00073 
00074         void create(const string& name);
00075 
00076         const Statistics& get(const string& name) const;
00077 
00078         Statistics& get(const string& name);
00079 
00080         void print(ostream& o) const;
00081 
00082     private:
00083         map<string, Statistics> m_map;
00084     };
00085 }
00086 
00087 //-----------------------------------------------------------------------------
00088 
00089 #endif


Generated on Thu Aug 7 13:04:50 2003 by Doxygen1.3.1