00001 // $Id: StatisticsOfArray.hh,v 1.1.1.1 2004/06/11 22:56:02 zweck Exp $ 00002 00003 //################################################################### 00004 // 00005 // Optical Communication Systems Simulator 00006 // 00007 // Copyright (2000): 00008 // Optical Fiber Communications Laboratory (OFCL) 00009 // Computer Science & Electrical Engineering Department (CSEE) 00010 // University of Maryland Baltimore County (UMBC) 00011 // 00012 //################################################################### 00013 00014 00015 // Created by John Zweck. Sept 25th, 2000. 00016 00017 // This class extracts simple statistics from a double array. 00018 // It's role is different from the Histogram class since in that class 00019 // each time you want to add a sample you make a separate function call. 00020 // In the StatisticsOfArrray class we are computing the statistics 00021 // of a given array. 00022 00023 // The statistics are computed when the constructor is called. 00024 // They may be accessed directly as the min,max,mean,std_dev and 00025 // variance are public variables (for simplicity and spped of coding). 00026 00027 00028 #ifndef _STATISTICS_OF_ARRAY_HH_ 00029 #define _STATISTICS_OF_ARRAY_HH_ 00030 00031 class StatisticsOfArray 00032 { 00033 00034 // ### Public Methods ### 00035 00036 public: 00037 00038 StatisticsOfArray(int arrayLengthIn, double *arrayIn); 00039 ~StatisticsOfArray(); 00040 00041 double GetMinimum() {return minimum;}; 00042 double GetMaximum() {return maximum;}; 00043 double GetMean() {return mean;}; 00044 double GetStdDev() {return standardDeviation;}; 00045 double GetVariance() {return variance;}; 00046 double GetMedian() {return median;}; 00047 00048 // ### Private Data ### 00049 00050 private: 00051 00052 int arrayLength; 00053 00054 double * array; 00055 double * sortedArray; 00056 00057 double minimum,maximum; 00058 double mean,standardDeviation,variance; 00059 double median; 00060 00061 00062 // ### Private Methods ### 00063 00064 private: 00065 00066 double Minimum(void); 00067 double Maximum(void); 00068 double Mean(void); 00069 double MeanSquares(void); 00070 double Variance(void); 00071 double Median(double * SortedArray, int Length); 00072 00073 void SelectionSort(double * Array, double * SortedArray, int Length); 00074 int MaximumIndex(double * Array, int Length); 00075 00076 }; // ## end declaration of class StatisticsOfArray 00077 00078 00079 #endif /* _STATISTICS_OF_ARRAY_HH_ */