Visual Servoing Platform  version 3.6.1 under development (2024-05-08)
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 
56 class VISP_EXPORT vpStatisticalTestAbstract
57 {
58 public:
62  typedef enum vpMeanDriftType
63  {
64  MEAN_DRIFT_NONE = 0,
65  MEAN_DRIFT_DOWNWARD = 1,
66  MEAN_DRIFT_UPWARD = 2,
67  MEAN_DRIFT_BOTH = 3,
68  MEAN_DRIFT_COUNT = 4,
69  MEAN_DRIFT_UNKNOWN = MEAN_DRIFT_COUNT
70  } vpMeanDriftType;
71 
78  static std::string vpMeanDriftTypeToString(const vpMeanDriftType &type);
79 
86  static vpMeanDriftType vpMeanDriftTypeFromString(const std::string &name);
87 
96  static std::string getAvailableMeanDriftType(const std::string &prefix = "<", const std::string &sep = " , ",
97  const std::string &suffix = ">");
98 
104  static void print(const vpMeanDriftType &type);
105 
106 protected:
108  float m_count;
109  float m_limitDown;
110  float m_limitUp;
111  float m_mean;
113  float *m_s;
114  float m_stdev;
115  float m_stdevmin;
116  float m_sumForMean;
126 
135 
144  virtual bool updateStatistics(const float &signal);
145 
151  virtual void updateTestSignals(const float &signal) = 0;
152 public:
157 
162 
166  virtual ~vpStatisticalTestAbstract();
167 
174  inline void getLimits(float &limitDown, float &limitUp) const
175  {
176  limitDown = m_limitDown;
177  limitUp = m_limitUp;
178  }
179 
185  inline float getMean() const
186  {
187  return m_mean;
188  }
189 
195  inline float getStdev() const
196  {
197  return m_stdev;
198  }
199 
203  void init();
204 
211  vpStatisticalTestAbstract &operator=(const vpStatisticalTestAbstract &other);
212 
219  void setMinStdev(const float &stdevmin)
220  {
221  m_stdevmin = stdevmin;
222  }
223 
230  void setNbSamplesForStat(const unsigned int &nbSamples);
231 
241  vpMeanDriftType testDownUpwardMeanDrift(const float &signal);
242 
252  vpMeanDriftType testDownwardMeanDrift(const float &signal);
253 
263  vpMeanDriftType testUpwardMeanDrift(const float &signal);
264 };
265 
266 #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.