Main MRPT website > C++ reference for MRPT 1.5.7
TSlidingWindow.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef TSLIDINGWINDOW_H
11 #define TSLIDINGWINDOW_H
12 
15 
16 #include <algorithm> // std::transform
17 #include <cmath> // sqrt
18 #include <functional> // std::bind2nd
19 #include <numeric> // std::accumulate
20 #include <string>
21 #include <vector>
22 
23 namespace mrpt { namespace graphslam {
24 
25 /**\brief Class to monitor the evolution of a statistical quantity.
26  *
27  * ## Description
28  *
29  * Keeps track of the last N incoming measurements of the quantity at hand and
30  * upon request returns statistical properties of these measurements (mean,
31  * median, etc.)
32  *
33  * Class also contains methods for evaluating incoming measurements (whether to
34  * accept or reject those)
35  *
36  * ### .ini Configuration Parameters </b>
37  *
38  * \htmlinclude graphslam-engine_config_params_preamble.txt
39  *
40  * - \b sliding_win_size
41  * + \a Default value : 10
42  * + \a Required : FALSE
43  * + \a Description : How many of the latest measurements to take into
44  * account when computing the relevant statistics
45  *
46  * \ingroup mrpt_graphslam_grp
47  */
49  public:
51  ~TSlidingWindow();
52  /**\brief Return the current median value. */
53  double getMedian();
54  /**\brief Return the current mean value. */
55  double getMean();
56  /**\brief Return the Standard deviation of the current measurement vector*/
57  double getStdDev();
58  /**\brief Determine whether the incoming measurement is inside the
59  * [-3sigma, +3sigma] boundaries from the current mean value.
60  *
61  * \return True if it's inside the uncertainty boundaries
62  */
63  bool evaluateMeasurementInGaussian(double measurement);
64  /**\brief Determine whether the incoming measurement is over the current
65  * mean value.
66  *
67  * \return True if it's above the mean
68  */
69  bool evaluateMeasurementAbove(double value);
70  /**\brief Determine whether the incoming measurement is *less or equal* to
71  * the current mean value.
72  *
73  * \return True if it's <= to the mean
74  */
75  bool evaluateMeasurementBelow(double value);
76  /**\brief Update the sliding window by appending a new measurement */
77  void addNewMeasurement(double measurement);
78  /** Resize the window.
79  *
80  * \note Method affects the underlying vector only if the new_size
81  * specified has already been reached
82  */
83  void resizeWindow(size_t new_size);
84  void loadFromConfigFile(
86  const std::string &section);
87  // TODO - make it use the boundaries
88  void dumpToTextStream(mrpt::utils::CStream &out) const;
89 
90  /**\brief Return the size of the window
91  */
92  size_t getWindowSize() const;
93  /**\brief Check if the window has reached its limit. This limit is set by
94  * the user via the resizeWindow method.
95  *
96  * \sa resizeWindow
97  */
98  bool windowIsFull() const;
99 
100  private:
101  size_t m_win_size;
102  std::vector<double> m_measurements_vec;
103 
104  /**\brief Name of the TSlidingWindow Instance at hand */
106 
107  double m_mean_cached; /**< Cached mean value */
108  double m_median_cached; /**< Cached median value */
109  double m_std_dev_cached; /**< Cached version of the standard deviation */
110  bool m_mean_updated; /**< Is the mean up-to-date? */
111  bool m_median_updated; /**< Is the median up-to-date? */
112  bool m_std_dev_updated; /**< Is the standard deviation up-to-date? */
113 
114  /**\brief flag is raised the first time that
115  * TSlidingWindow::addNewMeasurement is
116  * called
117  */
119 };
120 
121 } } // end of namespaces
122 #endif /* end of include guard: TSLIDINGWINDOW_H */
std::vector< double > m_measurements_vec
This class allows loading and storing values and vectors of different types from a configuration text...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
bool m_is_initialized
flag is raised the first time that TSlidingWindow::addNewMeasurement is called
double m_mean_cached
Cached mean value.
double m_std_dev_cached
Cached version of the standard deviation.
GLsizei const GLchar ** string
Definition: glext.h:3919
bool m_median_updated
Is the median up-to-date?
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Class to monitor the evolution of a statistical quantity.
GLuint const GLchar * name
Definition: glext.h:3891
GLsizei GLsizei GLchar * source
Definition: glext.h:3908
std::string m_name
Name of the TSlidingWindow Instance at hand.
GLsizei const GLfloat * value
Definition: glext.h:3929
bool m_mean_updated
Is the mean up-to-date?
double m_median_cached
Cached median value.
This is a virtual base class for sets of options than can be loaded from and/or saved to configuratio...
bool m_std_dev_updated
Is the standard deviation up-to-date?



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019