Main MRPT website > C++ reference for MRPT 1.9.9
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 
14 
15 #include <algorithm> // std::transform
16 #include <cmath> // sqrt
17 #include <functional> // std::bind2nd
18 #include <numeric> // std::accumulate
19 #include <string>
20 #include <vector>
21 
22 namespace mrpt
23 {
24 namespace graphslam
25 {
26 /**\brief Class to monitor the evolution of a statistical quantity.
27  *
28  * ## Description
29  *
30  * Keeps track of the last N incoming measurements of the quantity at hand and
31  * upon request returns statistical properties of these measurements (mean,
32  * median, etc.)
33  *
34  * Class also contains methods for evaluating incoming measurements (whether to
35  * accept or reject those)
36  *
37  * ### .ini Configuration Parameters </b>
38  *
39  * \htmlinclude graphslam-engine_config_params_preamble.txt
40  *
41  * - \b sliding_win_size
42  * + \a Default value : 10
43  * + \a Required : FALSE
44  * + \a Description : How many of the latest measurements to take into
45  * account when computing the relevant statistics
46  *
47  * \ingroup mrpt_graphslam_grp
48  */
50 {
51  public:
52  TSlidingWindow(std::string name = "window");
54  /**\brief Return the current median value. */
55  double getMedian();
56  /**\brief Return the current mean value. */
57  double getMean();
58  /**\brief Return the Standard deviation of the current measurement vector*/
59  double getStdDev();
60  /**\brief Determine whether the incoming measurement is inside the
61  * [-3sigma, +3sigma] boundaries from the current mean value.
62  *
63  * \return True if it's inside the uncertainty boundaries
64  */
65  bool evaluateMeasurementInGaussian(double measurement);
66  /**\brief Determine whether the incoming measurement is over the current
67  * mean value.
68  *
69  * \return True if it's above the mean
70  */
71  bool evaluateMeasurementAbove(double value);
72  /**\brief Determine whether the incoming measurement is *less or equal* to
73  * the current mean value.
74  *
75  * \return True if it's <= to the mean
76  */
77  bool evaluateMeasurementBelow(double value);
78  /**\brief Update the sliding window by appending a new measurement */
79  void addNewMeasurement(double measurement);
80  /** Resize the window.
81  *
82  * \note Method affects the underlying vector only if the new_size
83  * specified has already been reached
84  */
85  void resizeWindow(size_t new_size);
86  void loadFromConfigFile(
87  const mrpt::utils::CConfigFileBase& source, const std::string& section);
88  // TODO - make it use the boundaries
89  void dumpToTextStream(mrpt::utils::CStream& out) const;
90 
91  /**\brief Return the size of the window
92  */
93  size_t getWindowSize() const;
94  /**\brief Check if the window has reached its limit. This limit is set by
95  * the user via the resizeWindow method.
96  *
97  * \sa resizeWindow
98  */
99  bool windowIsFull() const;
100 
101  private:
102  size_t m_win_size;
103  std::vector<double> m_measurements_vec;
104 
105  /**\brief Name of the TSlidingWindow Instance at hand */
107 
108  double m_mean_cached; /**< Cached mean value */
109  double m_median_cached; /**< Cached median value */
110  double m_std_dev_cached; /**< Cached version of the standard deviation */
111  bool m_mean_updated; /**< Is the mean up-to-date? */
112  bool m_median_updated; /**< Is the median up-to-date? */
113  bool m_std_dev_updated; /**< Is the standard deviation up-to-date? */
114 
115  /**\brief flag is raised the first time that
116  * TSlidingWindow::addNewMeasurement is
117  * called
118  */
120 };
121 }
122 } // end of namespaces
123 #endif /* end of include guard: TSLIDINGWINDOW_H */
void resizeWindow(size_t new_size)
Resize the window.
std::vector< double > m_measurements_vec
void loadFromConfigFile(const mrpt::utils::CConfigFileBase &source, const std::string &section)
This method load the options from a ".ini"-like file or memory-stored string list.
This class allows loading and storing values and vectors of different types from a configuration text...
bool evaluateMeasurementInGaussian(double measurement)
Determine whether the incoming measurement is inside the [-3sigma, +3sigma] boundaries from the curre...
bool evaluateMeasurementAbove(double value)
Determine whether the incoming measurement is over the current mean value.
void addNewMeasurement(double measurement)
Update the sliding window by appending a new measurement.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
bool m_is_initialized
flag is raised the first time that TSlidingWindow::addNewMeasurement is called
double getStdDev()
Return the Standard deviation of the current measurement vector.
double m_mean_cached
Cached mean value.
double getMean()
Return the current mean value.
double m_std_dev_cached
Cached version of the standard deviation.
GLsizei const GLchar ** string
Definition: glext.h:4101
bool m_median_updated
Is the median up-to-date?
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
TSlidingWindow(std::string name="window")
Class to monitor the evolution of a statistical quantity.
void dumpToTextStream(mrpt::utils::CStream &out) const
This method should clearly display all the contents of the structure in textual form, sending it to a CStream.
GLuint const GLchar * name
Definition: glext.h:4054
GLsizei GLsizei GLchar * source
Definition: glext.h:4082
std::string m_name
Name of the TSlidingWindow Instance at hand.
bool evaluateMeasurementBelow(double value)
Determine whether the incoming measurement is less or equal to the current mean value.
GLsizei const GLfloat * value
Definition: glext.h:4117
size_t getWindowSize() const
Return the size of the window.
bool m_mean_updated
Is the mean up-to-date?
bool windowIsFull() const
Check if the window has reached its limit.
double m_median_cached
Cached median value.
double getMedian()
Return the current 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.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019