00001
00063 #ifndef INC_MI32_STATUNIVAR_H
00064 #define INC_MI32_STATUNIVAR_H
00065
00066 #ifndef INC_MI32_NUMTYPE_H
00067 #include <mi32/numtype.h>
00068 #endif
00069
00070 #ifndef INC_MI32_RANGE_H
00071 #include <mi32/range.h>
00072 #endif
00073
00074 #ifndef INC_MI32_DOUBLEAR_H
00075 #include <mi32/doublear.h>
00076 #endif
00077
00078 #ifndef INC_MI32_MISTRING_H
00079 #include <mi32/mistring.h>
00080 #endif
00081
00082 #ifdef GEOMDLL
00083 #define CLASSLIBEXPORT MI_DLLCLASSEXPORT
00084 #else
00085 #define CLASSLIBEXPORT MI_DLLCLASSIMPORT
00086 #endif
00087
00088 #ifndef GENERATING_DOXYGEN_OUTPUT
00089 class XMLNODE;
00090 #endif
00091
00092
00093
00096 class CLASSLIBEXPORT STAT_UNIVARIATE {
00097 public:
00098
00100 STAT_UNIVARIATE ();
00101
00103 ~STAT_UNIVARIATE ();
00104
00106 ERRVALUE Accumulate (
00107 UINT32 NumValues,
00108 const void *pValues,
00109 const UINT8 *pValidity = 0
00110 );
00111
00113 ERRVALUE Accumulate (
00114 const STAT_UNIVARIATE& stats
00115 );
00116
00118 ERRVALUE AccumulateCounted (
00119 const void *pValue,
00120 UINT64 count
00121 );
00122
00124 ERRVALUE AccumulateWeighted (
00125 const void *pValue,
00126 double weight
00127 );
00128
00130 void Clear (
00131 );
00132
00134 double ComputeBinCenter (
00135 INT32 BinIndex
00136 ) const;
00137
00139 INT32 ComputeBinIndex (
00140 double value
00141 ) const;
00142
00144 UINT32 ComputeBinIndexLimit (
00145 double value
00146 ) const;
00147
00149 void ComputeBinRange (
00150 INT32 BinIndex,
00151 DOUBLE_RANGE& BinRange
00152 ) const;
00153
00155 ERRVALUE Finalize ();
00156
00159 INT32 FindBinIndexPctAbove (
00160 double pct
00161 ) const;
00162
00165 INT32 FindBinIndexPctBelow (
00166 double pct
00167 ) const;
00168
00171 UINT64 GetBinCount (
00172 INT32 BinIndex
00173 ) const;
00174
00176 double GetBinCountWeighted (
00177 INT32 BinIndex
00178 ) const;
00179
00181 const DOUBLE_RANGE& GetBinRange (
00182 ) const { return (m_BinRange); }
00183
00185 double GetBinWidth (
00186 INT32 BinIndex = 0
00187 ) const;
00188
00191 UINT64 GetCountAboveMaxBin (
00192 ) const;
00193
00195 double GetCountAboveMaxBinWeighted (
00196 ) const;
00197
00200 UINT64 GetCountBelowMinBin (
00201 ) const;
00202
00204 double GetCountBelowMinBinWeighted (
00205 ) const;
00206
00208 UINT64 GetCountInvalid (
00209 ) const { return (m_CountInvalid); }
00210
00213 UINT64 GetCountValid (
00214 ) const;
00215
00217 double GetCountValidWeighted (
00218 ) const;
00219
00221 MISTRING GetDisplayStats (
00222 ) const;
00223
00225 double GetMean (
00226 ) const { return (m_Mean); }
00227
00229 INT32 GetMedianBinIndex (
00230 ) const { return (m_MedianBinIndex); }
00231
00233 INT32 GetModeBinIndex (
00234 ) const { return (m_ModeBinIndex); }
00235
00237 UINT32 GetNumBins (
00238 ) const { return (m_BinCounts.GetNumItems()); }
00239
00241 NUMTYPE GetNumType (
00242 ) const { return (m_NumType); }
00243
00245 double GetStdDev (
00246 ) const { return (m_StdDev); }
00247
00249 double GetSum2 (
00250 ) const { return (m_Sum2); }
00251
00253 const DOUBLE_RANGE& GetValueRange (
00254 ) const { return (m_ValueRange); }
00255
00257 XMLNODE* GetXML (
00258 XMLNODE *parentnode,
00259 const char *nodename
00260 ) const;
00261
00263 bool HasEqualBinWidths (
00264 ) const { return (true); }
00265
00268 ERRVALUE Initialize (
00269 NUMTYPE NumType,
00270 UINT32 NumBins,
00271 double MinBin,
00272 double MaxBin,
00273 double BinWidth = 0
00274 );
00275
00277 ERRVALUE Initialize (
00278 NUMTYPE NumType,
00279 const STAT_UNIVARIATE& existing
00280 ) { return (Initialize(NumType,existing.m_BinCounts.GetNumItems(),existing.m_BinRange.GetMinimum(),existing.m_BinRange.GetMaximum(),existing.m_BinWidth)); }
00281
00283 bool IsValid (
00284 ) const { return (m_State == STATE_Valid); }
00285
00287 ERRVALUE Set (
00288 UINT64 CountValid,
00289 UINT64 CountBelowMinBin,
00290 UINT64 CountAboveMaxBin,
00291 UINT64 CountInvalid,
00292 double Mean,
00293 double Sum2,
00294 const DOUBLE_RANGE& ValueRange,
00295 const DOUBLE_RANGE& BinRange,
00296 double BinWidth,
00297 const void *BinCounts,
00298 UINT32 NumBins,
00299 int BinBytes,
00300 NUMTYPE NumType = NUMTYPE_Invalid
00301 );
00302
00304 void SetAllInvalid (
00305 UINT64 CountInvalid
00306 );
00307
00310 ERRVALUE SetFromXML (
00311 const XMLNODE *xmlnode
00312 );
00313
00314 private:
00315 #ifndef GENERATING_DOXYGEN_OUTPUT
00316
00317 enum STATE {
00318 STATE_Invalid,
00319 STATE_Accumulating,
00320 STATE_Valid
00321 };
00322
00323 STATE m_State;
00324 NUMTYPE m_NumType;
00325 DOUBLE_RANGE m_ValueRange;
00326 DOUBLE_RANGE m_BinRange;
00327 double m_BinWidth;
00328 double m_Mean;
00329 double m_StdDev;
00330 double m_Sum2;
00331 UINT64 m_CountBelowMinBin;
00332 UINT64 m_CountAboveMaxBin;
00333 UINT64 m_CountValid;
00334 UINT64 m_CountInvalid;
00335 double m_WeightedBelowMinBin;
00336 double m_WeightedAboveMaxBin;
00337 double m_WeightedTotal;
00338 INT32 m_MedianBinIndex;
00339 INT32 m_ModeBinIndex;
00340 DOUBLE_ARRAY<UINT64> m_BinCounts;
00341 DOUBLE_ARRAY<double> m_BinWeighted;
00342
00343
00344
00345 void ClearLow ();
00346 void ClearWeighted ();
00347 void ComputeMedianAndMode ();
00348
00349 #endif // GENERATING_DOXYGEN_OUTPUT
00350 };
00351
00352
00353
00354 #undef CLASSLIBEXPORT
00355
00356 #endif // INC_MI32_STATUNIVAR_H