38 #include <visp3/core/vpStatisticalTestAbstract.h>
49 name =
"downward_drift";
52 name =
"upward_drift";
59 name =
"undefined_drift";
70 bool hasNotFound =
true;
71 while ((
id < count) && hasNotFound) {
83 const std::string &suffix)
85 std::string msg(prefix);
87 unsigned int lastId = count - 1;
88 for (
unsigned int i = 0; i < lastId; i++) {
102 m_s[
static_cast<unsigned int>(
m_count)] = signal;
110 float sumSquaredDiff = 0.f;
112 for (
unsigned int i = 0; i < count; ++i) {
115 float stdev = std::sqrt(sumSquaredDiff /
m_count);
129 : m_areStatisticsComputed(false)
134 , m_nbSamplesForStatistics(0)
148 if (
m_s !=
nullptr) {
162 if (
m_s !=
nullptr) {
180 else if (
m_s !=
nullptr) {
193 if (
m_s !=
nullptr) {
196 m_s =
new float[nbSamples];
Base class for methods detecting the drift of the mean of a process.
static std::string vpMeanDriftTypeToString(const vpMeanDriftType &type)
Cast a vpMeanDriftType into a string.
virtual ~vpStatisticalTestAbstract()
Destroy the vpStatisticalTestAbstract object.
vpMeanDriftType
Enum that indicates if a drift of the mean occurred.
static vpMeanDriftType vpMeanDriftTypeFromString(const std::string &name)
Cast a string into a vpMeanDriftType.
virtual vpMeanDriftType detectUpwardMeanDrift()=0
Detects if a upward mean drift occurred.
vpMeanDriftType testUpwardMeanDrift(const float &signal)
Test if an upward mean drift occurred according to the new value of the signal.
vpMeanDriftType testDownwardMeanDrift(const float &signal)
Test if a downward mean drift occurred according to the new value of the signal.
void init()
(Re)Initialize the algorithm.
vpStatisticalTestAbstract()
Construct a new vpStatisticalTestAbstract object.
virtual bool updateStatistics(const float &signal)
Update m_s and if enough values are available, compute the mean, the standard deviation and the limit...
virtual void updateTestSignals(const float &signal)=0
Update the test signals.
void setNbSamplesForStat(const unsigned int &nbSamples)
Set the number of samples required to compute the mean and standard deviation of the signal and alloc...
bool m_areStatisticsComputed
vpMeanDriftType testDownUpwardMeanDrift(const float &signal)
Test if a downward or an upward mean drift occurred according to the new value of the signal.
static void print(const vpMeanDriftType &type)
Print the message corresponding to the type of mean drift.
unsigned int m_nbSamplesForStatistics
virtual vpMeanDriftType detectDownwardMeanDrift()=0
Detects if a downward mean drift occurred.
vpStatisticalTestAbstract & operator=(const vpStatisticalTestAbstract &other)
Copy operator of a vpStatisticalTestAbstract.
static std::string getAvailableMeanDriftType(const std::string &prefix="<", const std::string &sep=" , ", const std::string &suffix=">")
Get the list of available vpMeanDriftType objects that are handled.