Main Page | Class Hierarchy | Class List | File List | Class Members

measure.h

00001 /* 00002 * Copyright (C) 2006 Dip. Ing. dell'Informazione, University of Pisa, Italy 00003 * http://info.iet.unipi.it/~cng/ns2measure/ns2measure.html 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, USA 00018 */ 00019 00032 #ifndef __MEASURE_MEASURE_H 00033 #define __MEASURE_MEASURE_H 00034 00035 #include <config.h> 00036 #include <stat.h> 00037 00038 #include <iostream> 00039 #include <vector> 00040 #include <string> 00041 #include <map> 00042 00044 class Population { 00046 std::vector<sample_t> population; 00047 public: 00049 Population () { } 00051 ~Population () { } 00052 00054 unsigned int getSize () const { return population.size(); } 00056 void addSample (sample_t x); 00058 sample_t getSample (bool& valid, unsigned int i); 00060 double mean (bool& valid) { 00061 return Stat::mean (valid, population); } 00063 double confInterval (bool& valid, double cl) { 00064 return Stat::confInterval (valid, population, cl); } 00065 00067 void dump (std::ostream& os); 00068 }; 00069 00071 class AvgMeasure : public Object { 00073 std::vector<Population> populations; 00075 std::vector<bool> valid; 00076 public: 00078 AvgMeasure () : Object ("AvgMeasure") { } 00080 ~AvgMeasure () { } 00081 00083 void addSample (sample_t x, unsigned int id); 00085 Population& getPopulation (unsigned int id); 00087 bool getValid (unsigned int id); 00089 unsigned int getSize () const { return populations.size(); } 00090 }; 00091 00093 00106 class DstMeasure : public Object { 00108 std::vector< std::vector<Population> > populations; 00110 00115 std::vector< std::vector<Population> > populationsCDF; 00117 std::vector< std::vector<bool> > valid; 00119 sample_t binSize; 00121 sample_t distLower; 00123 bool binSizeSet; 00125 bool distLowerSet; 00126 00128 std::vector<Population> meanPopulations; 00130 std::vector<Population> medianPopulations; 00132 std::vector<Population> percentile95Populations; 00134 std::vector<Population> percentile99Populations; 00136 std::vector<unsigned int> derivedLast; 00137 public: 00139 DstMeasure () : Object ("DstMeasure") { } 00141 ~DstMeasure () { } 00142 00144 void addSample (sample_t x, unsigned int id, unsigned int bin); 00146 Population& getPopulation (unsigned int id, unsigned int bin); 00148 Population& getPopulationCDF (unsigned int id, unsigned int bin); 00150 Population& getMeanPopulation (unsigned int id); 00152 Population& getMedianPopulation (unsigned int id); 00154 Population& getPercentile95Population (unsigned int id); 00156 Population& getPercentile99Population (unsigned int id); 00157 00159 void computeDerivedStatistics (unsigned int id); 00160 00162 bool getValid (unsigned int id, unsigned int bin); 00164 unsigned int getSize () const { return populations.size(); } 00166 unsigned int getSize (unsigned int id); 00168 void setBinSize (sample_t s) { binSize = s; binSizeSet = true; } 00170 void setDistLower (sample_t s) { distLower = s; distLowerSet = true; } 00172 sample_t getBinSize () const { return binSize; } 00174 sample_t getDistLower () const { return distLower; } 00175 }; 00176 00178 class Metrics : public Object { 00179 std::map<std::string, AvgMeasure> avgMeasures; 00180 std::map<std::string, DstMeasure> dstMeasures; 00181 public: 00183 Metrics () : Object ("Metrics") { } 00185 ~Metrics () { } 00186 00188 void addSample (std::string m, sample_t x, unsigned int id); 00190 void addSample (std::string m, sample_t x, unsigned int id, unsigned int bin); 00192 void setBinSize (std::string m, sample_t binSize); 00194 void setDistLower (std::string m, sample_t distLower); 00195 00197 std::map<std::string, AvgMeasure>& getAvgMeasures () { 00198 return avgMeasures; } 00200 std::map<std::string, DstMeasure>& getDstMeasures () { 00201 return dstMeasures; } 00202 00204 void dump (std::ostream& os); 00205 }; 00206 00207 #endif // __MEASURE_MEASURE_H

Generated on Tue May 30 08:09:56 2006 for ns2measure by doxygen 1.3.7