Helios++
Helios software for LiDAR simulations
Statistics.hpp
1 #ifndef _SURFACEINSPECTOR_MATHS_STATISTICS_HPP_
2 #define _SURFACEINSPECTOR_MATHS_STATISTICS_HPP_
3 
4 #include <vector>
5 
6 #include <armadillo>
7 
8 #include <surfaceinspector/util/Object.hpp>
9 #include <surfaceinspector/util/draggers/IDragger.hpp>
10 
11 using std::vector;
12 
15 
16 namespace SurfaceInspector{ namespace maths {
17 
24 class Statistics : public Object{
25 public:
26  // *** STATIC METHODS *** //
27  // ************************ //
34  template <typename T> static T mean(vector<T> const &vals);
42  template <typename T> static T variance(vector<T> const &vals);
50  template <typename T>
51  static T variance(vector<T> const &vals, T const mean);
59  template <typename T>
60  static T stdev(vector<T> const &vals);
69  template <typename T>
70  static T stdev(vector<T> const &vals, T const mean);
77  template <typename T> static inline T stdev(T const variance)
78  {return std::sqrt(variance);};
94  template <typename T>
95  static T covariance(
96  vector<T> const &X,
97  vector<T> const &Y,
98  bool besselCorrection=false
99  );
100 
119  template <typename T>
120  static T covariance(
121  vector<T> const &X,
122  vector<T> const &Y,
123  T xMean,
124  T yMean,
125  bool besselCorrection=false
126  );
148  template <typename T>
149  static arma::Mat<T> covarianceMatrix(
150  vector<vector<T>> dataset,
151  bool besselCorrection=false
152  );
176  template <typename T>
177  static arma::Mat<T> covarianceMatrix(
178  vector<vector<T>> dataset,
179  vector<T> means,
180  bool besselCorrection=false
181  );
182 
192  template <typename T>
193  static vector<T> quantiles(
194  arma::Col<T> data,
195  size_t nQuantiles=3
196  );
197 
203  template <typename T>
204  static vector<T> quantiles(
205  vector<T> const &data,
206  size_t nQuantiles=3
207  );
208 
229  template <typename T>
230  static size_t quantileFiltering(
231  vector<T> &values,
232  size_t nQuantiles=3,
233  double filterFactor=1.5
234  );
235 
285  template <typename T>
286  static bool findTrustableMin(
287  vector<T> const & S,
288  size_t const m,
289  T const tau,
290  T &g,
291  size_t * discardsCount = nullptr
292  );
297  template <typename T>
298  static bool findTrustableMax(
299  vector<T> const & S,
300  size_t const m,
301  T const tau,
302  T &g,
303  size_t * discardsCount = nullptr
304  );
305 
306  // *** INNER METHODS *** //
307  // *********************** //
308 protected:
314  template <typename T> static bool _findTrustable(
315  vector<T> const & S,
316  size_t const m,
317  T const tau,
318  IDragger<double, vector<double>> &drg,
319  T &g,
320  size_t * discardsCount = nullptr
321  );
322 };
323 
324 }}
325 
326 #include <surfaceinspector/maths/Statistics.tpp>
327 
328 #endif
Class providing common statistics operations.
Definition: Statistics.hpp:24
static bool findTrustableMin(vector< T > const &S, size_t const m, T const tau, T &g, size_t *discardsCount=nullptr)
Obtain the trustable minimum between all elements in given collection .
static arma::Mat< T > covarianceMatrix(vector< vector< T >> dataset, vector< T > means, bool besselCorrection=false)
Compute matrix of covariances.
static T stdev(vector< T > const &vals)
Compute the standard deviation of given values, which requires to previously compute the variance.
static T covariance(vector< T > const &X, vector< T > const &Y, T xMean, T yMean, bool besselCorrection=false)
Compute the covariance between X and Y, considering provided means.
static vector< T > quantiles(vector< T > const &data, size_t nQuantiles=3)
Like quantiles(armas::vec, size_t) function but receiving data as a standard vector instead of an arm...
static size_t quantileFiltering(vector< T > &values, size_t nQuantiles=3, double filterFactor=1.5)
Remove those values which are considered outliers.
static T variance(vector< T > const &vals, T const mean)
Compute the variance of given values, considering provided mean.
static T variance(vector< T > const &vals)
Compute the variance of given values, which requires to previously compute the mean.
static vector< T > quantiles(arma::Col< T > data, size_t nQuantiles=3)
Compute quantiles.
static T stdev(vector< T > const &vals, T const mean)
Compute the standard deviation of given values, considering provided mean.
static T mean(vector< T > const &vals)
Compute the mean of given values.
static bool _findTrustable(vector< T > const &S, size_t const m, T const tau, IDragger< double, vector< double >> &drg, T &g, size_t *discardsCount=nullptr)
Common mechanics for find trustable methods.
static T covariance(vector< T > const &X, vector< T > const &Y, bool besselCorrection=false)
Compute the covariance between X and Y.
static T stdev(T const variance)
Compute the standard deviation for given variance.
Definition: Statistics.hpp:77
static arma::Mat< T > covarianceMatrix(vector< vector< T >> dataset, bool besselCorrection=false)
Compute matrix of covariances.
static bool findTrustableMax(vector< T > const &S, size_t const m, T const tau, T &g, size_t *discardsCount=nullptr)
Like findTrustableMin but with maximum value instead of minimum.
Class representing an object. All surface inspector classes must extend Object.
Definition: Object.hpp:12
Dragger interface provide methods to drag elements from a given collection following a certain order....
Definition: IDragger.hpp:21