StatFeature.hpp
1 #ifndef OPALS_STAT_FEATURE_HPP_INCLUDED
2 #define OPALS_STAT_FEATURE_HPP_INCLUDED
3 
4 #pragma once
5 
6 #include "opals/config.hpp"
7 
8 namespace opals {
9 
10  /// Enumerator defining different cell feature types (used by opalsCell)
11  namespace StatFeatureType {
12  enum Type {
13  unknown = -1,
14  min = 0, ///< lowest
15  max, ///< highest
16  range, ///< difference between highest and lowest
17  nmin, ///< n lowest
18  nmax, ///< n highest
19  mean, ///< mean
20  median, ///< median
21  sum, ///< sum
22  stdDev, ///< standard deviation \f$\sqrt{\sum_{i=1}^{N}(r_i - \bar{r})^2 / (N-1) }\f$
23  variance, ///< (sample) variance \f$\sum_{i=1}^{N}(r_i - \bar{r})^2 / (N-1)\f$
24  rms, ///< root mean square \f$\sqrt{\sum_{i=1}^{N} r_i^2 / N}\f$
25  stdDevMAD, ///< robust standard deviation estimator computed from the median of absolute deviations from the median \f$1.4826 \cdot median_i(\left|r_i - median_j(r_j)\right|)\f$.
26  ///< In literature this robust estimator is often referred to as normalized MAD (NMAD)
27  minority, ///< the class with the lowest relative frequency (histogram based)
28  majority, ///< the class with the highest relative frequency (histogram based)
29  pdens, ///< point density
30  pcount, ///< point count
31  quantile, ///< p-quantile (p=0..1)
32  entropy, ///< (shannon) entropy, measure of information content
33  center, ///< select closest to cell center
34  rank, ///< quantile rank [0..100]
35  posOpenness, ///< positive openness
36  negOpenness, ///< negative openness
37  pdist, ///< average linear point distance (see DM::ILinearDistance2D for details)
38  null, ///< respresenting void feature
39  Count ///< number of available StatFeatures
40  };
41  };
42 
43  class OPALS_API StatFeature
44  {
45  public:
46  StatFeature();
48  StatFeature(StatFeatureType::Type type, unsigned n); ///< only for nmin and nmax
49  StatFeature(StatFeatureType::Type type, double value); ///< only for quantile, minority and majority
50  virtual ~StatFeature();
51 
52  private:
53  StatFeatureType::Type e_featureType;
54  unsigned u_n; ///< value for n in case of "n lowest" or "n highest" (only relevant if e_featureType is StatFeatureType::nmin or StatFeatureType::nmax)
55  double d_p; ///< p-value for quantile estimation (StatFeatureType::quantile)
56  double d_binWidth; ///< bin width for the minority and majority feature (default value 1)
57 
58  public:
59  StatFeatureType::Type e_getFeatureType() const;
60  unsigned u_getN() const;
61  double d_getP() const;
62  double d_getBinWidth() const;
63  void v_setFeatureType(const StatFeatureType::Type &Ire_featureType);
64  void v_setN(const unsigned &Iru_n);
65  void v_setP(const double &Ird_p);
66  void v_setBinWidth(const double &Ird_binWidth);
67 
68  ///returns minimum number of elements needed to be computable
69  unsigned u_minNumberOfElement() const;
70  };
71 }
72 
73 #endif //OPALS_STAT_FEATURE_HPP_INCLUDED