39#include <visp3/core/vpStatisticalTestShewhart.h>
44#include <visp3/core/vpException.h>
45#include <visp3/core/vpMath.h>
50#if (VISP_CXX_STANDARD < VISP_CXX_STANDARD_17)
59 name =
"3-sigma alarm";
62 name =
"2-sigma alarm";
65 name =
"1-sigma alarm";
68 name =
"Same-side alarm";
75 name =
"Unknown WECO alarm";
106 unsigned int nbAboveMean = 0;
107 unsigned int nbAbove2SigmaLimit = 0;
108 unsigned int nbAbove1SigmaLimit = 0;
111 nbAbove2SigmaLimit = 0;
112 nbAbove1SigmaLimit = 0;
121 ++nbAbove2SigmaLimit;
125 ++nbAbove2SigmaLimit;
127 if (nbAbove2SigmaLimit >= 2) {
135 ++nbAbove1SigmaLimit;
139 ++nbAbove1SigmaLimit;
141 if (nbAbove1SigmaLimit >= 4) {
152 else if (nbAbove2SigmaLimit >= 2) {
156 else if (nbAbove1SigmaLimit >= 4) {
178 unsigned int nbAboveMean = 0;
179 unsigned int nbAbove2SigmaLimit = 0;
180 unsigned int nbAbove1SigmaLimit = 0;
183 nbAbove2SigmaLimit = 0;
184 nbAbove1SigmaLimit = 0;
193 ++nbAbove2SigmaLimit;
197 ++nbAbove2SigmaLimit;
199 if (nbAbove2SigmaLimit >= 2) {
207 ++nbAbove1SigmaLimit;
211 ++nbAbove1SigmaLimit;
213 if (nbAbove1SigmaLimit >= 4) {
224 else if (nbAbove2SigmaLimit >= 2) {
228 else if (nbAbove1SigmaLimit >= 4) {
239 if (areStatsAvailable) {
242 return areStatsAvailable;
265 init(activateWECOrules, activatedRules, nbSamplesForStats);
279 init(activateWECOrules, activatedRules, mean, stdev);
284 std::vector<float> signals;
298 if (activatedRules.size() !=
COUNT_WECO - 1) {
299 std::stringstream errMsg;
300 errMsg <<
"Error: the expected number of rules is " <<
COUNT_WECO -1 <<
", the number given to the method is " << activatedRules.size() << std::endl;
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
static float modulo(const float &value, const float &modulo)
Gives the rest of value divided by modulo when the quotient can only be an integer.
vpMeanDriftType
Enum that indicates if a drift of the mean occurred.
void init()
(Re)Initialize the algorithm.
virtual bool updateStatistics(const float &signal)
Update m_s and if enough values are available, compute the mean, the standard deviation and the limit...
bool m_areStatisticsComputed
vpStatisticalTestShewhart(const bool &activateWECOrules=true, const std::vector< bool > &activatedRules=CONST_ALL_WECO_ACTIVATED, const unsigned int &nbSamplesForStats=30)
Construct a new vpStatisticalTestShewhart object.
virtual bool updateStatistics(const float &signal) VP_OVERRIDE
Update m_s and if enough values are available, compute the mean, the standard deviation and the limit...
static const unsigned int NB_DATA_SIGNAL
virtual vpMeanDriftType detectUpwardMeanDrift() VP_OVERRIDE
Detects if an upward mean drift occurred on the mean.
static VP_ATTRIBUTE_NO_DESTROY const std::vector< bool > CONST_ALL_WECO_ACTIVATED
virtual vpMeanDriftType detectDownwardMeanDrift() VP_OVERRIDE
Detects if a downward mean drift occurred.
virtual void updateTestSignals(const float &signal) VP_OVERRIDE
Update the test signals.
std::vector< float > getSignals() const
Get the NB_DATA_SIGNAL last signal values, sorted from the latest [0] to the newest [NB_DATA_SIGNAL -...
std::vector< bool > m_activatedWECOrules
unsigned int m_nbDataInBuffer
unsigned int m_idCurrentData
float m_signal_vec[NB_DATA_SIGNAL]
virtual void computeLimits() VP_OVERRIDE
Compute the upper and lower limits of the test signal.
static std::string vpWecoRulesAlarmToString(const vpWecoRulesAlarm &alarm)
vpStatisticalTestSigma(const float &h=3.f, const unsigned int &nbSamplesForStats=30)
Construct a new vpStatisticalTestSigma object.