The Cusum Algorithm - a Small Review Pierre Granjon
Total Page:16
File Type:pdf, Size:1020Kb
The CuSum algorithm - a small review Pierre Granjon To cite this version: Pierre Granjon. The CuSum algorithm - a small review. 2013. hal-00914697 HAL Id: hal-00914697 https://hal.archives-ouvertes.fr/hal-00914697 Submitted on 13 Mar 2014 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. The CUSUM algorithm a small review Pierre Granjon GIPSA-lab March 13, 2014 Contents 1 The CUSUM algorithm 2 1.1 Algorithm ............................... 2 1.1.1 The problem ......................... 2 1.1.2 The different steps ...................... 3 1.1.3 The whole algorithm ..................... 5 1.1.4 Example ............................ 7 1.2 Performance .............................. 7 1.2.1 Criteria ............................ 7 1.2.2 Optimality .......................... 9 1.3 Practical considerations ....................... 9 1.3.1 Dealing with unknowns ................... 9 1.3.2 Setting the parameters .................... 12 1.3.3 Two-sided algorithm ..................... 15 1.4 Variations ............................... 18 1.4.1 Fast initial response CUSUM . 18 1.4.2 Combined Shewhart-CUSUM . 19 1.4.3 Multivariate CUSUM .................... 19 Bibliography 20 1 Chapter 1 The CUSUM algorithm Lai [Lai 1995] and Basseville [Basseville 1993] give a full treatment of the field, from the simplest to more complicated sequential detection procedures (from Shewhart control charts [Shewhart 1931] to GLR algorithm first given in [Lorden 1971]). 1.1 Algorithm It is Page who first proposes different forms of the cumulative sum (CUSUM) algorithm in [Page 1954a]: direct or recursive forms. • one- or two-sided forms, • 1.1.1 The problem Let X[n] be a discrete random signal with independent and identically dis- tributed samples. Each of them follows a probability density function (PDF) p (x[n],θ) depending on a deterministic parameter θ (for example the mean µX 2 or the variance σX of X[n]). This signal may contain one abrupt change occur- ring at the change time nc. This abrupt change is modeled by an instantaneous modification of the value of θ occurring at the change time nc. Therefore θ = θ0 before nc and θ = θ1 from nc to the current sample. Under these assumptions, the whole PDF of the signal pX observed between the first sample x[0] and the current one x[k] can take two different forms. Under the no change hypothesis ( ), the PDF of X[n] is given by: • H0 k pX|H0 = p (x[n],θ0) . (1.1) nY=0 2 Under the one change hypothesis ( ), this PDF becomes: • H1 nc−1 k pX|H1 = p (x[n],θ0) p (x[n],θ1) . (1.2) nY=0 nY=nc In this problem, the PDF of each sample p (x[n],θ) and the values of the pa- rameter before (θ0) and after (θ1) the abrupt change are supposed to be known. Finally, the only unknowns to be determined are: the lack or occurrence of an abrupt change between n = 0 and n = k, • the value of the possible change time nc. • In order to develop the desired algorithm, we follow an on-line approach. This means that the abrupt change possibly contained in the past of the signal has to be sequentially detected sample after sample. Therefore, at each new sample x[k], one of the two previous hypotheses 0 and 1 has first to be decided. Then, in the case a change has been detectedH ( decided),H the change time has H1 to be estimated thanks to an estimator nc. The general form of this sequential algorithm is given in algorithm 1. c initialization if necessary end while the algorithm is not stopped do measure the current sample x[k] decide between 0 (no change) and 1 (one change) if decided thenH H H1 store the detection time nd k ← estimate the change time nc stop or reset the algorithm end end Algorithm 1: general form of a sequential change detection algorithm. Two important steps appear in this algorithm : detection step: How to decide between and ? H0 H1 estimation step: How to efficiently estimate the change time nc? These steps are further detailed in the two following sections. 1.1.2 The different steps Detection step The problem here is to decide between two possible hypotheses 0 and 1 from the measured samples x[0],...,x[k], which is also termed a binaryH hypothesisH 3 testing problem. The solution, given by the detection theory, is to use the so-called likelihood ratio test [Kay 1998, chap. 3]: test 1. Let the log-likelihood ratio LX be defined by: pX|H1 LX = ln . (1.3) pX|H0 Then, decide if LX >h (else ), where h is a threshold set by the user. H1 H0 In our case, the theoretical expression of LX at the current sample x[k] is ob- tained by reporting (1.1) and (1.2) in (1.3): k pX|H1 [k,nc] p (x[n],θ1) LX [k,nc]=ln = ln . (1.4) pX|H0 [k] p (x[n],θ0) nX=nc Unfortunately, this quantity can not be calculated since it depends on the un- known change time nc. Once again, the detection theory leads to an efficient solution which consists of replacing all the unknowns in LX by their maximum likelihood estimates. Such a test is termed the generalized likelihood ratio test, and is given by [Kay 1998, chap. 6]: test 2. Let the generalized log-likelihood ratio GX be defined by: GX[k] = max LX [k,nc] 1≤nc≤k k p (x[n],θ ) = max ln 1 . (1.5) 1≤nc≤k p (x[n],θ0) nX=nc Then, decide if GX[k] >h (else ), where h is a threshold set by the user. H1 H0 The quantity defined in (1.5) can now be calculated at each new sample and is thus used to decide between and . It is also termed a decision function. H0 H1 Estimation step Once has been decided and an abrupt change has been detected, the prob- H1 lem is to efficiently estimate the change time nc from the measured samples x[0],...,x[k]. One way to solve this problem is to use its maximum likeli- hood estimate, which is the value of nc maximizing the likelihood pX|H1 [k,nc] [Kay 1993, chap. 7]: nc = arg max pX|H1 [k,nc] = arg max LX [k,nc] 1≤nc≤k 1≤nc≤k c k p (x[n],θ ) = arg max ln 1 . (1.6) 1≤nc≤k p (x[n],θ0) nX=nc 4 1.1.3 The whole algorithm Direct form In order to obtain a simplified form of the whole algorithm, let’s define from (1.4) the instantaneous log-likelihood ratio at time n by: p (x[n],θ1) s[n]= LX[n,n]=ln , (1.7) p (x[n],θ0) and its cumulative sum from 0 to k: k S[k]= s[n]. (1.8) nX=0 From (1.7) and (1.8), the log-likelihood ratio LX[k,nc] defined in (1.4) can be rewritten as: LX [k,nc]= S[k] S[nc 1]. (1.9) − − Reporting this expression in (1.5) and (1.6), we obtain new expressions for the decision function GX[k] and for the change time estimate nc[k]: GX[k] = S[k] min S[nc 1]c (1.10) − 1≤nc≤k − nc = arg min S[nc 1]. (1.11) 1≤nc≤k − c Equation (1.10) shows that the decision function GX[k] is the current value of the cumulative sum S[k] minus its current minimum value. Equation (1.11) shows that the change time estimate is the time following the current minimum of the cumulative sum. Therefore, each step composing the whole algorithm relies on the same quantity: the cumulative sum S[k] defined through (1.7) and (1.8). This explains the name of cumulative sum or CUSUM algorithm. By using equations (1.7), (1.8), (1.10) and (1.11) into algorithm 1, the direct form of the CUSUM algorithm 2 is obtained. Recursive form The previous algorithm can easily be rewritten in a recursive manner. Indeed, the cumulative sum (1.8) can be calculated through the simple recursive formula: S[k]= S[k 1] + s[k]. (1.12) − Moreover, as shown in [Basseville 1993, chap. 2], since the decision function is compared to a positive threshold h, it can be rewritten as: + GX[k]= GX[k 1] + s[k] , (1.13) { − } where z + = sup(z, 0). Finally, by using (1.12) and (1.13) into the direct form algorithm{ }2, the recursive form of the CUSUM algorithm 3 is obtained. Clearly, the obtained algorithm is very simple and very interesting to use in real-time or on-line applications. 5 initialization set the detection threshold h> 0 k = 0 end while the algorithm is not stopped do measure the current sample x[k] s[k]=ln p(x[k],θ1) p(x[k],θ0) k S[k]= n=0 s[n] GX[k]=PS[k] min1≤nc≤k S[nc 1] − − if GX[k] >h then nd k ← nc = arg min S[nc 1] 1≤nc≤k − stop or reset the algorithm c end k = k + 1 end Algorithm 2: CUSUM algorithm, direct form. initialization set the detection threshold h> 0 S[ 1] = GX[ 1] = 0 k =− 0 − end while the algorithm is not stopped do measure the current sample x[k] p(x[k],θ1) s[k]=ln p(x[k],θ ) 0 S[k]= S[k 1] + s[k] − + GX[k]= GX[k 1] + s[k] { − } if GX[k] >h> 0 then nd k ← nc = arg min S[nc 1] 1≤nc≤k − stop or reset the algorithm c end k = k + 1 end Algorithm 3: CUSUM algorithm, recursive form.