Visual Servoing Platform  version 3.6.1 under development (2024-04-29)
vpStatisticalTestSigma Class Reference

#include <visp3/core/vpStatisticalTestSigma.h>

+ Inheritance diagram for vpStatisticalTestSigma:

Public Types

enum  vpMeanDriftType {
  MEAN_DRIFT_NONE = 0 , MEAN_DRIFT_DOWNWARD = 1 , MEAN_DRIFT_UPWARD = 2 , MEAN_DRIFT_BOTH = 3 ,
  MEAN_DRIFT_COUNT = 4 , MEAN_DRIFT_UNKNOWN = MEAN_DRIFT_COUNT
}
 
typedef enum vpStatisticalTestAbstract::vpMeanDriftType vpMeanDriftType
 

Public Member Functions

 vpStatisticalTestSigma (const float &h=3.f, const unsigned int &nbSamplesForStats=30)
 
 vpStatisticalTestSigma (const float &h, const float &mean, const float &stdev)
 
virtual float getSignal () const
 
void init (const float &h=3.f, const unsigned int &nbSamplesForStats=30)
 
void init (const float &h, const float &mean, const float &stdev)
 
void getLimits (float &limitDown, float &limitUp) const
 
float getMean () const
 
float getStdev () const
 
void init ()
 
void setMinStdev (const float &stdevmin)
 
void setNbSamplesForStat (const unsigned int &nbSamples)
 
vpMeanDriftType testDownUpwardMeanDrift (const float &signal)
 
vpMeanDriftType testDownwardMeanDrift (const float &signal)
 
vpMeanDriftType testUpwardMeanDrift (const float &signal)
 

Static Public Member Functions

static std::string vpMeanDriftTypeToString (const vpMeanDriftType &type)
 
static vpMeanDriftType vpMeanDriftTypeFromString (const std::string &name)
 
static std::string getAvailableMeanDriftType (const std::string &prefix="<", const std::string &sep=" , ", const std::string &suffix=">")
 
static void print (const vpMeanDriftType &type)
 

Protected Member Functions

virtual void computeLimits ()
 
virtual vpMeanDriftType detectDownwardMeanDrift () override
 
virtual vpMeanDriftType detectUpwardMeanDrift () override
 
virtual bool updateStatistics (const float &signal) override
 
virtual void updateTestSignals (const float &signal) override
 

Protected Attributes

float m_h
 
float m_s
 
bool m_areStatisticsComputed
 
float m_count
 
float m_limitDown
 
float m_limitUp
 
float m_mean
 
unsigned int m_nbSamplesForStatistics
 
float m_stdev
 
float m_stdevmin
 
float m_sumForMean
 

Detailed Description

Class that permits a simple test comparing the current value to the standard deviation of the signal.

Be $ s(t) $ the signal to monitor, $ \mu $ and $ \sigma $ the mean and standard deviation of this signal when it is "in control".

Be $ h $ a user-defined alarm factor.

A downward alarm is raised if: $ s(t) >= \mu - h \sigma $

An upward alarm is raised if: $ s(t) >= \mu - h \sigma $

$ h $ is often set to 3 if we assume the $ s(t) $ follows a normal distribution.

To detect only downward drifts of the input signal $ s(t) $ use testDownwardMeanDrift().To detect only upward drifts in $ s(t) $ use testUpwardMeanDrift(). To detect both, downward and upward drifts use testDownUpwardMeanDrift().

Examples
testSPC.cpp, and tutorial-meandrift.cpp.

Definition at line 68 of file vpStatisticalTestSigma.h.

Member Typedef Documentation

◆ vpMeanDriftType

Enum that indicates if a drift of the mean occurred.

Member Enumeration Documentation

◆ vpMeanDriftType

Enum that indicates if a drift of the mean occurred.

Enumerator
MEAN_DRIFT_NONE 

No mean drift occurred

MEAN_DRIFT_DOWNWARD 

A downward drift of the mean occurred.

MEAN_DRIFT_UPWARD 

An upward drift of the mean occurred.

MEAN_DRIFT_BOTH 

Both an aupward and a downward drifts occurred.

MEAN_DRIFT_COUNT 
MEAN_DRIFT_UNKNOWN 

Definition at line 62 of file vpStatisticalTestAbstract.h.

Constructor & Destructor Documentation

◆ vpStatisticalTestSigma() [1/2]

vpStatisticalTestSigma::vpStatisticalTestSigma ( const float &  h = 3.f,
const unsigned int &  nbSamplesForStats = 30 
)

Construct a new vpStatisticalTestSigma object.

Parameters
[in]hThe alarm factor applied to the standard deviation to compute the limits.
[in]nbSamplesForStatsThe number of samples to compute the statistics of the signal.

Definition at line 83 of file vpStatisticalTestSigma.cpp.

References vpStatisticalTestAbstract::init().

◆ vpStatisticalTestSigma() [2/2]

vpStatisticalTestSigma::vpStatisticalTestSigma ( const float &  h,
const float &  mean,
const float &  stdev 
)

Construct a new vpStatisticalTestSigma object.

Parameters
[in]hThe alarm factor applied to the standard deviation to compute the limits.
[in]meanThe expected mean of the signal.
[in]stdevThe expected standard deviation of the signal.

Definition at line 90 of file vpStatisticalTestSigma.cpp.

References vpStatisticalTestAbstract::init().

Member Function Documentation

◆ computeLimits()

void vpStatisticalTestSigma::computeLimits ( )
protectedvirtual

Compute the upper and lower limits of the test signal.

Reimplemented in vpStatisticalTestShewhart.

Definition at line 42 of file vpStatisticalTestSigma.cpp.

References m_h, vpStatisticalTestAbstract::m_limitDown, vpStatisticalTestAbstract::m_limitUp, vpStatisticalTestAbstract::m_mean, and vpStatisticalTestAbstract::m_stdev.

Referenced by init(), and updateStatistics().

◆ detectDownwardMeanDrift()

vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestSigma::detectDownwardMeanDrift ( )
overrideprotectedvirtual

Detects if a downward mean drift occured.

Returns
vpMeanDriftType::MEAN_DRIFT_DOWNWARD if a downward mean drift occured, vpMeanDriftType::MEAN_DRIFT_NONE otherwise.
See also
detectUpwardMeanDrift()

Implements vpStatisticalTestAbstract.

Reimplemented in vpStatisticalTestShewhart.

Definition at line 49 of file vpStatisticalTestSigma.cpp.

References vpStatisticalTestAbstract::m_limitDown, m_s, vpStatisticalTestAbstract::MEAN_DRIFT_DOWNWARD, and vpStatisticalTestAbstract::MEAN_DRIFT_NONE.

◆ detectUpwardMeanDrift()

vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestSigma::detectUpwardMeanDrift ( )
overrideprotectedvirtual

Detects if an upward mean drift occured on the mean.

Returns
vpMeanDriftType::MEAN_DRIFT_UPWARD if an upward mean drift occured, vpMeanDriftType::MEAN_DRIFT_NONE otherwise.
See also
detectDownwardMeanDrift()

Implements vpStatisticalTestAbstract.

Reimplemented in vpStatisticalTestShewhart.

Definition at line 59 of file vpStatisticalTestSigma.cpp.

References vpStatisticalTestAbstract::m_limitUp, m_s, vpStatisticalTestAbstract::MEAN_DRIFT_NONE, and vpStatisticalTestAbstract::MEAN_DRIFT_UPWARD.

◆ getAvailableMeanDriftType()

std::string vpStatisticalTestAbstract::getAvailableMeanDriftType ( const std::string &  prefix = "<",
const std::string &  sep = " , ",
const std::string &  suffix = ">" 
)
staticinherited

Get the list of available vpMeanDriftType objects that are handled.

Parameters
[in]prefixThe prefix that should be placed before the list.
[in]sepThe separator between each element of the list.
[in]suffixThe suffix that should terminate the list.
Returns
std::string The list of handled type of process tests, presented as a string.
Examples
tutorial-meandrift.cpp.

Definition at line 82 of file vpStatisticalTestAbstract.cpp.

References vpStatisticalTestAbstract::MEAN_DRIFT_COUNT, and vpStatisticalTestAbstract::vpMeanDriftTypeToString().

◆ getLimits()

void vpStatisticalTestAbstract::getLimits ( float &  limitDown,
float &  limitUp 
) const
inlineinherited

Get the upper and lower limits of the test signal.

Parameters
[out]limitDownThe lower limit.
[out]limitUpThe upper limit.
Examples
testSPC.cpp, and tutorial-meandrift.cpp.

Definition at line 174 of file vpStatisticalTestAbstract.h.

◆ getMean()

float vpStatisticalTestAbstract::getMean ( ) const
inlineinherited

Get the mean used as reference.

Returns
float The mean.
Examples
tutorial-meandrift.cpp.

Definition at line 185 of file vpStatisticalTestAbstract.h.

◆ getSignal()

virtual float vpStatisticalTestSigma::getSignal ( ) const
inlinevirtual

Get the last value of the signal.

Returns
float The signal.

Reimplemented in vpStatisticalTestShewhart.

Definition at line 150 of file vpStatisticalTestSigma.h.

References vpStatisticalTestAbstract::m_s.

◆ getStdev()

float vpStatisticalTestAbstract::getStdev ( ) const
inlineinherited

Get the standard deviation used as reference.

Returns
float The standard deviation.
Examples
tutorial-meandrift.cpp.

Definition at line 195 of file vpStatisticalTestAbstract.h.

◆ init() [1/3]

◆ init() [2/3]

void vpStatisticalTestSigma::init ( const float &  h,
const float &  mean,
const float &  stdev 
)

(Re)Initialize the test.

Parameters
[in]hThe alarm factor applied to the standard deviation to compute the limits.
[in]meanThe expected mean of the signal.
[in]stdevThe expected standard deviation of the signal.

Definition at line 105 of file vpStatisticalTestSigma.cpp.

References computeLimits(), vpStatisticalTestAbstract::init(), vpStatisticalTestAbstract::m_areStatisticsComputed, m_h, vpStatisticalTestAbstract::m_mean, m_s, and vpStatisticalTestAbstract::m_stdev.

◆ init() [3/3]

void vpStatisticalTestSigma::init ( const float &  h = 3.f,
const unsigned int &  nbSamplesForStats = 30 
)

(Re)Initialize the test.

Parameters
[in]hThe alarm factor applied to the standard deviation to compute the limits.
[in]nbSamplesForStatsThe number of samples to compute the statistics of the signal.

Definition at line 97 of file vpStatisticalTestSigma.cpp.

References vpStatisticalTestAbstract::init(), m_h, m_s, and vpStatisticalTestAbstract::setNbSamplesForStat().

◆ print()

void vpStatisticalTestAbstract::print ( const vpMeanDriftType type)
staticinherited

Print the message corresponding to the type of mean drift.

Parameters
[in]typeThe type of mean drift.

Definition at line 95 of file vpStatisticalTestAbstract.cpp.

References vpStatisticalTestAbstract::vpMeanDriftTypeToString().

◆ setMinStdev()

void vpStatisticalTestAbstract::setMinStdev ( const float &  stdevmin)
inlineinherited

Set the minimum value of the standard deviation that is expected. The computed standard deviation cannot be lower this value if set.

Parameters
[in]stdevminThe minimum value of the standard deviation that is expected.

Definition at line 219 of file vpStatisticalTestAbstract.h.

◆ setNbSamplesForStat()

void vpStatisticalTestAbstract::setNbSamplesForStat ( const unsigned int &  nbSamples)
inherited

Set the number of samples required to compute the mean and standard deviation of the signal and allocate the memory accordingly.

Parameters
[in]nbSamplesThe number of samples we want to use.

Definition at line 190 of file vpStatisticalTestAbstract.cpp.

References vpStatisticalTestAbstract::m_nbSamplesForStatistics, and vpStatisticalTestAbstract::m_s.

Referenced by vpStatisticalTestHinkley::init(), vpStatisticalTestEWMA::init(), vpStatisticalTestMeanAdjustedCUSUM::init(), init(), and vpStatisticalTestAbstract::operator=().

◆ testDownUpwardMeanDrift()

vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestAbstract::testDownUpwardMeanDrift ( const float &  signal)
inherited

Test if a downward or an upward mean drift occurred according to the new value of the signal.

Parameters
[in]signalThe new value of the signal.
Returns
vpMeanDriftType The type of mean drift that occurred.
See also
testDownwardMeanDrift() testUpwardMeanDrift()
Examples
testSPC.cpp, and tutorial-meandrift.cpp.

Definition at line 199 of file vpStatisticalTestAbstract.cpp.

References vpStatisticalTestAbstract::detectDownwardMeanDrift(), vpStatisticalTestAbstract::detectUpwardMeanDrift(), vpStatisticalTestAbstract::m_areStatisticsComputed, vpStatisticalTestAbstract::MEAN_DRIFT_BOTH, vpStatisticalTestAbstract::MEAN_DRIFT_NONE, vpStatisticalTestAbstract::updateStatistics(), and vpStatisticalTestAbstract::updateTestSignals().

◆ testDownwardMeanDrift()

vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestAbstract::testDownwardMeanDrift ( const float &  signal)
inherited

Test if a downward mean drift occurred according to the new value of the signal.

Parameters
[in]signalThe new value of the signal.
Returns
vpMeanDriftType The type of mean drift that occurred.
See also
testUpwardMeanDrift()

Definition at line 224 of file vpStatisticalTestAbstract.cpp.

References vpStatisticalTestAbstract::detectDownwardMeanDrift(), vpStatisticalTestAbstract::m_areStatisticsComputed, vpStatisticalTestAbstract::MEAN_DRIFT_NONE, vpStatisticalTestAbstract::updateStatistics(), and vpStatisticalTestAbstract::updateTestSignals().

◆ testUpwardMeanDrift()

vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestAbstract::testUpwardMeanDrift ( const float &  signal)
inherited

Test if an upward mean drift occurred according to the new value of the signal.

Parameters
[in]signalThe new value of the signal.
Returns
vpMeanDriftType The type of mean drift that occurred.
See also
testDownwardMeanDrift()

Definition at line 236 of file vpStatisticalTestAbstract.cpp.

References vpStatisticalTestAbstract::detectUpwardMeanDrift(), vpStatisticalTestAbstract::m_areStatisticsComputed, vpStatisticalTestAbstract::MEAN_DRIFT_NONE, vpStatisticalTestAbstract::updateStatistics(), and vpStatisticalTestAbstract::updateTestSignals().

◆ updateStatistics()

bool vpStatisticalTestSigma::updateStatistics ( const float &  signal)
overrideprotectedvirtual

Update m_s and if enough values are available, compute the mean, the standard deviation and the limits.

Parameters
[in]signalThe new value of the signal to monitor.

Reimplemented from vpStatisticalTestAbstract.

Reimplemented in vpStatisticalTestShewhart.

Definition at line 69 of file vpStatisticalTestSigma.cpp.

References computeLimits(), and vpStatisticalTestAbstract::updateStatistics().

◆ updateTestSignals()

void vpStatisticalTestSigma::updateTestSignals ( const float &  signal)
overrideprotectedvirtual

Update the test signals.

Parameters
[in]signalThe new value of the signal to monitor.

Implements vpStatisticalTestAbstract.

Reimplemented in vpStatisticalTestShewhart.

Definition at line 78 of file vpStatisticalTestSigma.cpp.

References m_s.

◆ vpMeanDriftTypeFromString()

vpStatisticalTestAbstract::vpMeanDriftType vpStatisticalTestAbstract::vpMeanDriftTypeFromString ( const std::string &  name)
staticinherited

Cast a string into a vpMeanDriftType.

Parameters
[in]nameThe name of the mean drift.
Returns
vpMeanDriftType The corresponding vpMeanDriftType.
Examples
tutorial-meandrift.cpp.

Definition at line 65 of file vpStatisticalTestAbstract.cpp.

References vpStatisticalTestAbstract::MEAN_DRIFT_COUNT, vpStatisticalTestAbstract::MEAN_DRIFT_UNKNOWN, and vpStatisticalTestAbstract::vpMeanDriftTypeToString().

Referenced by TutorialMeanDrift::vectorOfStringToMeanDriftTypeArray().

◆ vpMeanDriftTypeToString()

Member Data Documentation

◆ m_areStatisticsComputed

◆ m_count

float vpStatisticalTestAbstract::m_count
protectedinherited

◆ m_h

float vpStatisticalTestSigma::m_h
protected

The alarm factor applied to the standard deviation to compute the limits.

Definition at line 71 of file vpStatisticalTestSigma.h.

Referenced by computeLimits(), and init().

◆ m_limitDown

◆ m_limitUp

◆ m_mean

◆ m_nbSamplesForStatistics

unsigned int vpStatisticalTestAbstract::m_nbSamplesForStatistics
protectedinherited

Number of samples to use to compute the mean and the standard deviation.

Definition at line 112 of file vpStatisticalTestAbstract.h.

Referenced by vpStatisticalTestAbstract::init(), vpStatisticalTestAbstract::operator=(), vpStatisticalTestAbstract::setNbSamplesForStat(), and vpStatisticalTestAbstract::updateStatistics().

◆ m_s

float vpStatisticalTestSigma::m_s
protected

The last value of the signal.

Definition at line 72 of file vpStatisticalTestSigma.h.

Referenced by detectDownwardMeanDrift(), detectUpwardMeanDrift(), init(), and updateTestSignals().

◆ m_stdev

◆ m_stdevmin

float vpStatisticalTestAbstract::m_stdevmin
protectedinherited

Minimum allowed standard deviation of the monitored signal.

Definition at line 115 of file vpStatisticalTestAbstract.h.

Referenced by vpStatisticalTestAbstract::updateStatistics().

◆ m_sumForMean

float vpStatisticalTestAbstract::m_sumForMean
protectedinherited