00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _statistics_h
00018 #define _statistics_h
00019
00020 #include <spl/Exception.h>
00021 #include <spl/math/Math.h>
00022 #include <spl/Memory.h>
00023 #include <spl/collection/List.h>
00024 #include <spl/RefCountPtr.h>
00025 #include <spl/collection/Vector.h>
00026
00035 class Sample : public IMemoryValidate
00036 {
00037 private:
00038
00039 double *m_data;
00040 double m_min;
00041 double m_max;
00042 double m_mean;
00043 int m_n;
00044 double m_ssd;
00045 double m_variance;
00046 double m_averageDeviation;
00047
00048 void Recalc();
00049 static double Gammp(const double a, const double x);
00050 static double Gammq(const double a, const double x);
00051 static double Gcf(const double a, const double x);
00052 static double Gser(const double a, const double x);
00053
00054 public:
00055
00056 Sample(List<double> *list);
00057 Sample(Vector<double> *list);
00058 Sample(const double *list, const int count);
00059 Sample (const Sample& s);
00060 virtual ~Sample();
00061
00062 Sample& operator =(const Sample& s);
00063
00064 inline double Min() const
00065 {
00066 return m_min;
00067 }
00068
00069 inline double Max() const
00070 {
00071 return m_max;
00072 }
00073
00074 inline double Mean() const
00075 {
00076 return m_mean;
00077 }
00078
00079 inline int N() const
00080 {
00081 return m_n;
00082 }
00083
00084 inline double StDevSample() const
00085 {
00086 return m_ssd;
00087 }
00088
00089 inline double Variance() const
00090 {
00091 return m_variance;
00092 }
00093
00094 inline double AverageDeviation() const
00095 {
00096 return m_averageDeviation;
00097 }
00098
00099 inline double Item(int idx) const
00100 {
00101 if ( idx >= m_n || idx < 0 )
00102 {
00103 throw IndexOutOfBoundsException();
00104 }
00105 return m_data[idx];
00106 }
00107
00108 double AverageVariance() const;
00109 double Median() const;
00110 double Skew() const;
00111 double Kurtosis() const;
00112 double ErrorFunction(double x) const;
00113
00114 Sample TransformASin() const;
00115 Sample TransformSqrt375() const;
00116 Sample TransformLog10() const;
00117
00118 #ifdef DEBUG
00119 virtual void ValidateMem () const;
00120 virtual void CheckMem () const;
00121 #endif
00122 };
00123
00126 #endif