47 #include <visp3/core/vpHinkley.h>
48 #include <visp3/core/vpDebug.h>
50 #include <visp3/core/vpMath.h>
77 : dmin2(0.1), alpha(0.2), nsignal(0), mean(0), Sk(0), Mk(0), Tk(0), Nk(0)
98 : dmin2(delta_val/2.), alpha(alpha_val), nsignal(0), mean(0), Sk(0), Mk(0), Tk(0), Nk(0)
173 this->alpha = alpha_val;
193 if (nsignal == 1) mean = signal;
200 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2
201 <<
" signal: " << signal <<
" Sk: " << Sk <<
" Mk: " << Mk;
204 if ((Mk - Sk) > alpha)
208 if (VP_DEBUG_MODE >=2) {
211 std::cout <<
"noJump " << std::endl;
214 std::cout <<
"downWardJump " << std::endl;
217 std::cout <<
"upwardJump " << std::endl;
226 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
228 Sk = 0; Mk = 0; nsignal = 0;
251 if (nsignal == 1) mean = signal;
258 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2
259 <<
" signal: " << signal <<
" Tk: " << Tk <<
" Nk: " << Nk;
262 if ((Tk - Nk) > alpha)
266 if (VP_DEBUG_MODE >= 2) {
269 std::cout <<
"noJump " << std::endl;
272 std::cout <<
"downWardJump " << std::endl;
275 std::cout <<
"upWardJump " << std::endl;
283 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
285 Tk = 0; Nk = 0; nsignal = 0;
308 if (nsignal == 1) mean = signal;
317 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2
318 <<
" signal: " << signal
319 <<
" Sk: " << Sk <<
" Mk: " << Mk
320 <<
" Tk: " << Tk <<
" Nk: " << Nk << std::endl;
323 if ((Mk - Sk) > alpha)
325 else if ((Tk - Nk) > alpha)
329 if (VP_DEBUG_MODE >= 2) {
332 std::cout <<
"noJump " << std::endl;
335 std::cout <<
"downWardJump " << std::endl;
338 std::cout <<
"upwardJump " << std::endl;
347 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
349 Sk = 0; Mk = 0; Tk = 0; Nk = 0; nsignal = 0;
366 void vpHinkley::computeMean(
double signal)
374 if ( ( std::fabs(Mk-Sk) <= std::fabs(
vpMath::maximum(Mk,Sk))*std::numeric_limits<double>::epsilon() )
376 ( std::fabs(Tk-Nk) <= std::fabs(
vpMath::maximum(Tk,Nk))*std::numeric_limits<double>::epsilon() ) )
380 mean = (mean * (nsignal - 1) + signal) / (nsignal);
390 void vpHinkley::computeSk(
double signal)
394 Sk += signal - mean + dmin2;
401 void vpHinkley::computeMk()
403 if (Sk > Mk) Mk = Sk;
411 void vpHinkley::computeTk(
double signal)
415 Tk += signal - mean - dmin2;
422 void vpHinkley::computeNk()
424 if (Tk < Nk) Nk = Tk;
432 std::cout <<
" No jump detected " << std::endl ;
435 std::cout <<
" Jump downward detected " << std::endl ;
438 std::cout <<
" Jump upward detected " << std::endl ;
441 std::cout <<
" Jump detected " << std::endl ;
vpHinkleyJumpType testDownUpwardJump(double signal)
vpHinkleyJumpType testUpwardJump(double signal)
static Type maximum(const Type &a, const Type &b)
static void print(vpHinkleyJumpType jump)
vpHinkleyJumpType testDownwardJump(double signal)
void setAlpha(double alpha)
void setDelta(double delta)