51 #include <visp/vpHinkley.h>
52 #include <visp/vpDebug.h>
53 #include <visp/vpIoTools.h>
54 #include <visp/vpMath.h>
203 if (nsignal == 1) mean = signal;
210 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2
211 <<
" signal: " << signal <<
" Sk: " << Sk <<
" Mk: " << Mk;
214 if ((Mk - Sk) > alpha)
218 if (VP_DEBUG_MODE >=2) {
221 std::cout <<
"noJump " << std::endl;
224 std::cout <<
"downWardJump " << std::endl;
227 std::cout <<
"upwardJump " << std::endl;
236 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
238 Sk = 0; Mk = 0; nsignal = 0;
261 if (nsignal == 1) mean = signal;
268 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2
269 <<
" signal: " << signal <<
" Tk: " << Tk <<
" Nk: " << Nk;
272 if ((Tk - Nk) > alpha)
276 if (VP_DEBUG_MODE >= 2) {
279 std::cout <<
"noJump " << std::endl;
282 std::cout <<
"downWardJump " << std::endl;
285 std::cout <<
"upWardJump " << std::endl;
293 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
295 Tk = 0; Nk = 0; nsignal = 0;
318 if (nsignal == 1) mean = signal;
327 vpCDEBUG(2) <<
"alpha: " << alpha <<
" dmin2: " << dmin2
328 <<
" signal: " << signal
329 <<
" Sk: " << Sk <<
" Mk: " << Mk
330 <<
" Tk: " << Tk <<
" Nk: " << Nk << std::endl;
333 if ((Mk - Sk) > alpha)
335 else if ((Tk - Nk) > alpha)
339 if (VP_DEBUG_MODE >= 2) {
342 std::cout <<
"noJump " << std::endl;
345 std::cout <<
"downWardJump " << std::endl;
348 std::cout <<
"upwardJump " << std::endl;
357 vpCDEBUG(2) <<
"\n*** Reset the Hinkley test ***\n";
359 Sk = 0; Mk = 0; Tk = 0; Nk = 0; nsignal = 0;
376 void vpHinkley::computeMean(
double signal)
384 if ( ( std::fabs(Mk-Sk) <= std::fabs(
vpMath::maximum(Mk,Sk))*std::numeric_limits<double>::epsilon() )
386 ( std::fabs(Tk-Nk) <= std::fabs(
vpMath::maximum(Tk,Nk))*std::numeric_limits<double>::epsilon() ) )
390 mean = (mean * (nsignal - 1) + signal) / (nsignal);
400 void vpHinkley::computeSk(
double signal)
404 Sk += signal - mean + dmin2;
411 void vpHinkley::computeMk()
413 if (Sk > Mk) Mk = Sk;
421 void vpHinkley::computeTk(
double signal)
425 Tk += signal - mean - dmin2;
432 void vpHinkley::computeNk()
434 if (Tk < Nk) Nk = Tk;
442 std::cout <<
" No jump detected " << std::endl ;
445 std::cout <<
" Jump downward detected " << std::endl ;
448 std::cout <<
" Jump upward detected " << std::endl ;
451 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)