HistoStats.hpp
1 #pragma once
2 
3 #include "opals/config.hpp"
4 #include "opals/String.hpp"
5 #include "opals/Array.hpp"
6 #include "opals/Vector.hpp"
7 #include "opals/HistoMode.hpp"
8 
9 namespace opals {
10 
11  /// \brief HistoStats provides a histogram and additional statistical measures.
12  ///
13  /// HistoStats provides a histogram and additional statistical measures like
14  /// min, max, mean, median ... of certain data sample.
15  /// The histogram in particular is stored as a std::vector of std:pairs, each of which
16  /// stores the data of a single histogram bin (class) with its lower
17  /// boundary (first) and relative frequency (second). The first bin
18  /// contains all underflow values, followed by the regular bins of
19  /// constant width. The last class contains all overflow values. Absolute
20  /// frequencies can be obtained by multiplying the relative frequancies
21  /// with the total numer of samples (countUsed). Additionally, several
22  /// standard statistical values are provided (min, max, mean, median...)
23  ///
24  /// \author GM
25  /// \date 12.06.2010
26  class OPALS_API HistoStats
27  {
28  public:
29  /// vector of double pairs
32 
33  /// vector of histogram bins stored as std::pair
34  /** first: lower bound of bin, second: absolute or relative frequency */
36  typedef PairOfDblVec RelBinVector;
37 
38  typedef RelBinVector BinVector; ///deprecated: use AbsBinVector or RelBinVector instead
39 
40 
41 
42  /// vector of quantiles
43  /** first: probabilities (double: 0 <= p <= 1), second: according quantiles */
45 
46  public:
47  HistoStats();
48  virtual ~HistoStats();
49 
50  /// access functions
51  void setHistoStats( const long long &CountData,
52  const long long &CountUsed,
53  const double &Min, const double &Max, const double &Mean,
54  const double &Median, const double &Mode,
55  const double &StdDev, const double &Rms,
56  const double &StdDevMAD, const double &Skewness,
58  const QuantileVector &Quantiles, const AbsBinVector &Bins );
59  void setCountData( const double &Count ) { countData = Count; }
60  void setCountUsed( const double &Count ) { countUsed = Count; }
61  void setMin( const double &Min ) { min = Min; }
62  void setMax( const double &Max ) { max = Max; }
63  void setMean( const double &Mean ) { mean = Mean; }
64  void setMedian( const double &Median ) { median = Median; }
65  void setMode(const double &Mode) { mode = Mode; }
66  void setStdDev( const double &StdDev) { stdDev = StdDev; }
67  void setRms( const double &Rms) { rms = Rms; }
68  void setStdDevMAD( const double &StdDev) { stdDev = StdDev; }
69  void setSkewness( const double &Skewness ) { skewness = Skewness; }
70  void setQuantiles( const QuantileVector &Quantiles ) { quantiles = Quantiles; }
71  void setAbsBins( const AbsBinVector &Bins ) { bins = Bins; }
72  void setCalcMode( const opals::HistoMode CalcMode) { calcMode = CalcMode; }
73  void setLabel( const opals::String &Label ) { label = Label; }
74 
75  /// query functions
76  long long getCountData() const { return countData; }
77  long long getCountUsed() const { return countUsed; }
78  double getMin() const { return min; }
79  double getMax() const { return max; }
80  double getMean() const{ return mean; }
81  double getMedian() const { return median; }
82  double getMode() const { return mode; }
83  double getStdDev() const { return stdDev; }
84  double getRms() const { return rms; }
85  double getStdDevMAD() const { return stdDevMAD; }
86  double getSkewness() const { return skewness; }
87  QuantileVector getQuantiles() const { return quantiles; }
88  AbsBinVector getAbsBins() const { return bins; } ///< get bin vector with absolute frequency values
89  RelBinVector getRelBins() const; ///< get bin vector with relative frequency values
90  opals::HistoMode getCalcMode() const { return calcMode; }
91  const opals::String& getLabel() const { return label; }
92 
93  BinVector getBins() const { return getRelBins(); } ///deprecated: use getRelBins instead
94 
95 
96  /// output functions
97  String logHistoStats(bool absBins = true) const; /// for xml output
98  String printHistoStats(bool absBins = true) const; /// for log output (in more readable format)
99 
100  private:
101  long long countUsed, countData;
102  double count, min, max, mean, median, mode, stdDev, rms, stdDevMAD, skewness;
103  QuantileVector quantiles;
104  AbsBinVector bins;
105  opals::String label;
106  HistoMode calcMode;
107  };
108 }
CalcMode
TODO: Enumerator for what?
Definition: calcMode.hpp:8
DblInt64Vec AbsBinVector
vector of histogram bins stored as std::pair
Definition: HistoStats.hpp:35
HistoMode
HistoMode enumerates different modes of histogram computations.
Definition: HistoMode.hpp:8
PairOfDblVec QuantileVector
deprecated: use AbsBinVector or RelBinVector instead
Definition: HistoStats.hpp:44
@ mean
Mean.
Contains the public interface of OPALS.
Definition: ApplyTrafo.hpp:5
long long getCountData() const
query functions
Definition: HistoStats.hpp:76
@ count
always last element
opals::Vector< std::pair< double, double > > PairOfDblVec
vector of double pairs
Definition: HistoStats.hpp:30
Mimics std::vector<T>
Definition: fwd.hpp:18
A dynamic character string whose interface conforms to STL's std::string.
Definition: String.hpp:35
HistoStats provides a histogram and additional statistical measures.
Definition: HistoStats.hpp:26