51 #include <visp/vpHinkley.h>
52 #include <visp/vpDebug.h>
53 #include <visp/vpIoTools.h>
54 #include <visp/vpMath.h>
81 : dmin2(0.1), alpha(0.2), nsignal(0), mean(0), Sk(0), Mk(0), Tk(0), Nk(0)
102 : dmin2(delta_val/2.), alpha(alpha_val), nsignal(0), mean(0), Sk(0), Mk(0), Tk(0), Nk(0)
177 this->alpha = alpha_val;
197 if (nsignal == 1) mean = signal;
204 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2
205 <<
" signal: " << signal <<
" Sk: " << Sk <<
" Mk: " << Mk;
208 if ((Mk - Sk) > alpha)
212 if (VP_DEBUG_MODE >=2) {
215 std::cout <<
"noJump " << std::endl;
218 std::cout <<
"downWardJump " << std::endl;
221 std::cout <<
"upwardJump " << std::endl;
230 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
232 Sk = 0; Mk = 0; nsignal = 0;
255 if (nsignal == 1) mean = signal;
262 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2
263 <<
" signal: " << signal <<
" Tk: " << Tk <<
" Nk: " << Nk;
266 if ((Tk - Nk) > alpha)
270 if (VP_DEBUG_MODE >= 2) {
273 std::cout <<
"noJump " << std::endl;
276 std::cout <<
"downWardJump " << std::endl;
279 std::cout <<
"upWardJump " << std::endl;
287 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
289 Tk = 0; Nk = 0; nsignal = 0;
312 if (nsignal == 1) mean = signal;
321 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2
322 <<
" signal: " << signal
323 <<
" Sk: " << Sk <<
" Mk: " << Mk
324 <<
" Tk: " << Tk <<
" Nk: " << Nk << std::endl;
327 if ((Mk - Sk) > alpha)
329 else if ((Tk - Nk) > alpha)
333 if (VP_DEBUG_MODE >= 2) {
336 std::cout <<
"noJump " << std::endl;
339 std::cout <<
"downWardJump " << std::endl;
342 std::cout <<
"upwardJump " << std::endl;
351 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
353 Sk = 0; Mk = 0; Tk = 0; Nk = 0; nsignal = 0;
370 void vpHinkley::computeMean(
double signal)
378 if ( ( std::fabs(Mk-Sk) <= std::fabs(
vpMath::maximum(Mk,Sk))*std::numeric_limits<double>::epsilon() )
380 ( std::fabs(Tk-Nk) <= std::fabs(
vpMath::maximum(Tk,Nk))*std::numeric_limits<double>::epsilon() ) )
384 mean = (mean * (nsignal - 1) + signal) / (nsignal);
394 void vpHinkley::computeSk(
double signal)
398 Sk += signal - mean + dmin2;
405 void vpHinkley::computeMk()
407 if (Sk > Mk) Mk = Sk;
415 void vpHinkley::computeTk(
double signal)
419 Tk += signal - mean - dmin2;
426 void vpHinkley::computeNk()
428 if (Tk < Nk) Nk = Tk;
436 std::cout <<
" No jump detected " << std::endl ;
439 std::cout <<
" Jump downward detected " << std::endl ;
442 std::cout <<
" Jump upward detected " << std::endl ;
445 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)