Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
vpStatisticalTestAbstract.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2024 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See https://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  */
31 
37 #ifndef _vpStatisticalTestAbstract_h_
38 #define _vpStatisticalTestAbstract_h_
39 
40 #include <algorithm>
41 #include <cmath>
42 #include <iostream>
43 #include <string>
44 
45 #include <visp3/core/vpConfig.h>
46 
47 BEGIN_VISP_NAMESPACE
57 class VISP_EXPORT vpStatisticalTestAbstract
58 {
59 public:
63  typedef enum vpMeanDriftType
64  {
65  MEAN_DRIFT_NONE = 0,
66  MEAN_DRIFT_DOWNWARD = 1,
67  MEAN_DRIFT_UPWARD = 2,
68  MEAN_DRIFT_BOTH = 3,
69  MEAN_DRIFT_COUNT = 4,
70  MEAN_DRIFT_UNKNOWN = MEAN_DRIFT_COUNT
71  } vpMeanDriftType;
72 
79  static std::string vpMeanDriftTypeToString(const vpMeanDriftType &type);
80 
87  static vpMeanDriftType vpMeanDriftTypeFromString(const std::string &name);
88 
97  static std::string getAvailableMeanDriftType(const std::string &prefix = "<", const std::string &sep = " , ",
98  const std::string &suffix = ">");
99 
105  static void print(const vpMeanDriftType &type);
106 
107 protected:
109  float m_count;
110  float m_limitDown;
111  float m_limitUp;
112  float m_mean;
114  float *m_s;
115  float m_stdev;
116  float m_stdevmin;
117  float m_sumForMean;
127 
136 
145  virtual bool updateStatistics(const float &signal);
146 
152  virtual void updateTestSignals(const float &signal) = 0;
153 public:
158 
163 
167  virtual ~vpStatisticalTestAbstract();
168 
175  inline void getLimits(float &limitDown, float &limitUp) const
176  {
177  limitDown = m_limitDown;
178  limitUp = m_limitUp;
179  }
180 
186  inline float getMean() const
187  {
188  return m_mean;
189  }
190 
196  inline float getStdev() const
197  {
198  return m_stdev;
199  }
200 
204  void init();
205 
212  vpStatisticalTestAbstract &operator=(const vpStatisticalTestAbstract &other);
213 
220  void setMinStdev(const float &stdevmin)
221  {
222  m_stdevmin = stdevmin;
223  }
224 
231  void setNbSamplesForStat(const unsigned int &nbSamples);
232 
242  vpMeanDriftType testDownUpwardMeanDrift(const float &signal);
243 
253  vpMeanDriftType testDownwardMeanDrift(const float &signal);
254 
264  vpMeanDriftType testUpwardMeanDrift(const float &signal);
265 };
266 END_VISP_NAMESPACE
267 #endif
Base class for methods detecting the drift of the mean of a process.
vpMeanDriftType
Enum that indicates if a drift of the mean occurred.
void getLimits(float &limitDown, float &limitUp) const
Get the upper and lower limits of the test signal.
virtual vpMeanDriftType detectUpwardMeanDrift()=0
Detects if a upward mean drift occurred.
void setMinStdev(const float &stdevmin)
Set the minimum value of the standard deviation that is expected. The computed standard deviation can...
virtual void updateTestSignals(const float &signal)=0
Update the test signals.
float getMean() const
Get the mean used as reference.
float getStdev() const
Get the standard deviation used as reference.
virtual vpMeanDriftType detectDownwardMeanDrift()=0
Detects if a downward mean drift occurred.