

small (250x250 max)
medium (500x500 max)
Large
Extra Large
large ( > 500x500)
Full Resolution


COMPARISON OF THE CUSUM, FIRSTORDER, SELFTUNING AND KALMAN FILTERS By DANIEL FAKUNLE Bachelor of Science in Chemical Engineering Obafemi Awolowo University IleIfe, Nigeria 2005 Submitted to the Faculty of the Graduate College of the Oklahoma State University in partial fulfillment of the requirements for the Degree of MASTER OF SCIENCE May, 2010 COMPARISON OF THE CUSUM, FIRSTORDER, SELFTUNING AND KALMAN FILTERS Thesis Approved: Dr. R.R. Rhinehart Thesis Adviser Dr. A.J. Johannes Dr. Rob Whiteley Dr. A. Gordon Emslie Dean of the Graduate College 2 ACKNOWLEDGMENTS I will like to express my appreciation and gratitude to Dr. Rhinehart, Dr.Gasem, Dr. Johannes, Dr. Whiteley, and Dr.Fahlenkamp. 3 TABLE OF CONTENTS ......................................................................................................... 5 LIST OF TABLES .................................................................................................................... 6 LIST OF FIGURES .................................................................................................................. 7 CHAPTER I .............................................................................................................................. 8 INTRODUCTION .................................................................................................................... 8 CHAPTER II ........................................................................................................................... 11 REVIEW OF LITERATURE ................................................................................................. 11 2.1 Noise............................................................................................................................. 11 2.2Why filter ....................................................................................................................... 11 2.3 Use of filters and Statistical Process Control (SPC) ..................................................... 12 2.4 Filters ............................................................................................................................. 12 2.4.1 FirstOrder filter: .................................................................................................... 13 2.4.2 SelfTuning Filter ................................................................................................... 13 2.4.3 CUSUM Filter ........................................................................................................ 14 2.4.4 Kalman filter ........................................................................................................... 15 CHAPTER III ......................................................................................................................... 17 METHODOLOGY ................................................................................................................. 17 3.1 Criteria for comparing filters ....................................................................................... 17 3.2 Integral sum of errors .................................................................................................... 17 4 3.2.1 Base value with a step change introduced .............................................................. 19 3.2.2 Base value with a ramp change introduced. ........................................................... 21 3.2.3 Base value with an oscillatory change introduced. ................................................. 22 3.3 Cost............................................................................................................................... 24 3.4 Ease of understanding ................................................................................................... 24 3.5 Filter Equations and code: ............................................................................................. 24 3.5.1 CUSUM filter  ....................................................................................................... 24 3.5.2 Firstorder filter .......................................................................................................... 25 3.5.3 Selftuning filter ......................................................................................................... 25 3.5.4 Kalman Filter.............................................................................................................. 26 CHAPTER IV ......................................................................................................................... 28 RESULTS AND DISCUSSION OF RESULTS..................................................................... 28 4.1 Part 1 ............................................................................................................................. 28 4.2 CUSUM Filter Results .................................................................................................. 29 4.3 Firstorder filter (FOF) .................................................................................................. 34 SelfTuning Filter (STF) .................................................................................................. 39 4.4. The Kalman Filter ........................................................................................................ 43 4.5 Comparison of Results between the four filters: ........................................................... 48 4.2 EASE OF UNDERSTANDING THE FILTERS .......................................................... 60 4.3 Cost............................................................................................................................... 61 5 4.3.1 Ranking of filters based on cost analysis derived from the total operations .......... 62 3.2. Ranking of filters based on cost analysis derived from the Number of ....................... 65 CHAPTER V .......................................................................................................................... 67 RECOMMENDATION .......................................................................................................... 67 REFERENCES ....................................................................................................................... 68 APPPENDIX.......................................................................................................................... 69 6 LIST OF TABLES Table Page 1. CUSUM ISE values to determine optimal trigger value ………………………30 2. Firstorder ISE values to determine optimal Filtering factor (λ)...……………..35 3. STF ISE values to determine optimal Filter tuning value (Ef) ………………...40 4. Kalman ISE values to determine optimal filter tuning value (Q)………………44 5. Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman filter for introduction of a step change to steady state base value……………….48 6. Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman…53 filter for introduction of a ramp change to steady state base value 7. Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman filter for introduction of a step change to steady state base value……………….55 8. Ease of understanding the filter……………………………………………….. 61 9 Evaluation of operations required in CUSUM filter…………………………….62 10 Evaluation of operations required in firstorder filter………………………….62 11 Evaluation of operations required in selftuning filter…………………………63 12 Evaluation of operations required in Kalman filter……………………………..64 13. Ranking of filter in increasing order of relative cost…………………………...65 14 Ranking of filter based on the required number of memory…………………….66 location / required variables 7 LIST OF FIGURES Figure Page 4.1: Plot Of CUSUM ISE values with the introduction of a step change to the base value vs CUSUM ISE values with no change in the base steady state value……32 4.2: Plot Of Firstorder ISE values with the introduction of a step change to the base value vs Firstorder ISE values with no change in the base steady state value………………………………………………………………………..…….37 4.3. Plot of Selftuning ISE values with the introduction of a step change to the base value vs Selftuning ISE values with no change in the base steady state value……………………………………………………………………………...42 4.4. Plot of Kalman ISE values with the introduction of a step change to the base value vs Kalman ISE values with no change in the steady state base value……..46 4.5. Plot of ISE values with the introduction of a step change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder , STF, and Kalman filter……………………………………………..50 4.6. Plot of ISE values with the introduction of a ramp change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder , STF, and Kalman filter…………………………………………….54 4.7. Plot of ISE values with the introduction of an oscillatory change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder , STF, and Kalman filter………………………………….58 8 CHAPTER I INTRODUCTION Filtering is the process of removing the noise associated with process measurements in order to observe the noiseless “or true” value. Filters seek to identify the true process signal in the presence of noise [6]. It is desired to have a filter that gives an accurate process signal for a variety of patterns in process. This is because filters are used to “filter out” the noise in a process and the more accurate the resulting signal, the better the filter. In this work, four filters are evaluated and compared for performance; and based on the comparison, conclusions are made. The comparison aspects include speed of tracking a change in the process (measured by ISE (Integral Sum of errors)), closeness of the filtered value to the true signal when there is no change in the process (also measured by ISE), computational burden, complexity for human understanding, and cost issues. A series of simulations was done to generate data for the comparison using Visual Basic for Applications Programming. Noise was added to the simulation in order to corrupt the produced signal. The noisy signal was then filtered to obtain the true value which is known. Based on the filtered value, measures of goodness were calculated for each filter 9 in each simulated run. The simulation involved a steady base value and the introduction of a change to the base value. This steady base value is used to obtain the accuracy of the filter in finding the true signal value for a steady value, while the change is introduced in order to obtain the speed of tracking a change and the accuracy of the filter in tracking the change. The performance of the filters was then evaluated using the calculated ISE values. Step change, ramp change and oscillatory changes were introduced to the base value and the effect on the four filter outputs was then evaluated for results. The experiments also included range of tuning factors to determine the best value to give a nondominated individual on a multiobjective (ISE1 vs. ISE2) plane. Where ISE1 involved no change in a steady base value and ISE2 involved the introduction of a change to the steady state base value. The experiments included three changes; step, ramp and oscillatory. The filters considered were the firstorder filter (FOF) [6], the selftuning filter (STF) [1], the CUSUM filter [6] and the Kalman filter [4]. The firstorder filter was chosen because it is used in the industry as a common industrial filtering practice [1]. The selftuning filter was chosen because it can achieve a high ratio of noise reduction without giving up its fast tracking of a process [1]. The Kalman filter was chosen because it is a wellknown and oftenused tool for mathematical stochastic estimation from noisy sensor measurements [3]. The CUSUM filter was chosen as an innovative filter to compare its performance to other industrially used filter such as the firstorder and the Kalman filter. 10 The firstorder filter averages data to reduce the effects of noise, but it also causes undesirable lag in the filtered variable. The greater the noise amplitude, the higher the required filtering. It is an Infinite Impulse Response (IIR) filter. The objective of the selftuning filter is to determine the filtering factor (λ) such that there is a 95% probability that the true value lies within the user chosen confidence interval about the average [1]. The CUSUM filter is a novel filter based on a cumulative sum of deviations. It is derived from Statistical Process Control Concepts (SPC) [6]. The CUSUM filter action holds the filtered value constant until there is sufficient statistical level of confidence that a change has occurred. The Kalman filter is a recursive data processing algorithm [5]. A Kalman filter combines all available measurement data, plus prior knowledge about the system and measuring devices, to produce an estimate of the desired variables. It estimates a process by using a form of feedback control by utilizing time update equations and measurement update equations. 11 CHAPTER II REVIEW OF LITERATURE 2.1 Noise In this work, noise is defined as a fluctuating influence on process measurement that cannot be controlled because it is either: 1) a fluctuating misrepresentation of the true Process Variable (PV) (for example, some random electrical noise is added to the signal through the sensor and the electrical circuits) or 2) a transient influence on the PV. Noise is often described as a zeromean, independent, Gaussian distributed addition to the true PV (process variable) value [6]. This time varying ratio of “pure” signal to the electrical noise affects the quality of the information. [7]. 2.2Why filter Filtering is done in order to remove noise and obtain the true process value. In process control, process noise and instrument noise are undesirable. This is because the controller will respond to the noise rather than the true process change. The noise masks the true 12 process variable. A result of this would be an increase in the process variability and increased wear and tear in final control element. 2.3 Use of filters and Statistical Process Control (SPC) Usually the process variable (PV) is filtered and the filtered value is fed to the controller. Statistical Process Control (SPC) is a philosophy that overrides the desire to implement a change until there is sufficient statistical evidence to implement the change [6]. Statistical Process Control involves a broad scope of activities including the design of sampling and inspection schemes, experimental design and analysis to detect shifts in the mean or variability of a process [3]. 2.4 Filters There are two models for a digital filter. These are the Infinite Impulse Response filter (IIR) and the Finite Impulse Response filter (FIR) [8]. FIR has a finite memory. It is non recursive because it does not require a feedback loop in its implementation. IIR has infinite memory. It is called a recursive filter because the output is fed back into the input. One of the most important criterions for filters is the squared error minimization [1]. This is because a filter with a low value of the squared error gives an output that is very close to the true value of the signal it is filtering, while one with a high value of the squared error gives an output that is far away from the true value of the filtered signal. 13 2.4.1 FirstOrder filter: The firstorder filter averages data to reduce the effects of noise. It is a recursive filter. It has an undesirable characteristic of introducing a lag in the control loop. This lag in the loop affects stability, and undesirably limits the aggressiveness of the controller. When there is a change in process variable (PV) value, the firstorder filter output lags behind. During a noisy steady state period, the firstorder filter output keeps changing at every sample. The FOF equation is given as [1]: 1 1 Where is the filtered value is the filtering factor i is the sample counter And is the input signal 2.4.2 SelfTuning Filter The selftuning filter automatically adjusts λ in the FOF. It is based on the 95% confidence interval for engineering economic decisions. Its objective is to determine λ such that there is a 95% probability that the true steady state process value is within the user chosen confidence interval about the average. The three equations for the selftuning filter are [1]: 0.1 0.9 2 . !" # $# % ,1' 3 1 4 14 Where x is the current measured value of the signal. Where is the old signal measured value. Where is the resulting filtered value. Where E is the error between the true (unknown) value and the 2.5% extreme value of the filtered value. It is chosen by the user. is a measure of data variance. 2.4.3 CUSUM Filter In statistics, 3sigma is the two specific points on a normal distribution centered about the mean. Out of a population, 99.73% of the population will fall between these values. It represents the entire population and +3sigma and 3sigma represents the probable range of variation [2]. It is used in the industry as an organized and systematic method for strategic process improvement, new product and service development relying on statistical methods and the scientific method to make dramatic reductions in customer defined defect rates [9]. The CUSUM filter is based on this principle. The filter attempts to find the mean within noisy data. The concept holds the mean is unchanged, until there is sufficient statistical confidence that a real change has occurred. If the Process Variable (PV) “really” changes, then the average will shift. The CUSUM gives the criteria for making a change as [6]: *+,+ Σ / /0123 45 5 If *+,+ > TRIGGER*√9 6 ; <=> ?@ @ A ; ? @ A <=> 7 ;/ C4"DEF # 8 15 Where 9 is the number of samples for which CUSUM had been calculated. is the measured value of the variable. 0 is the old value of the calucated mean of the measured variable. ;/is defined by equations 7 and 8 M ≅ 11 (This gives the “best” balance of removing variability from the estimate) Trigger value represents the SPC confidence level in a decision. The trigger value of 1 represents 68.3% confidence level. A value of 2 represents traditional economic decision trigger values of I2; representing a 95% confidence in a decision. A value of 3 is the 3 sigma 99.73% confidence level. Values from 2 to 4 are generally chosen to balance responsiveness and false alarms for particular SPC applications [6]. 2.4.4 Kalman filter The Kalman filter is the application of the combination of the method of combining a model of the process with adjusted process measurements to produce an estimate of the state [4]. It named after Rudolph E. Kalman, who published a paper describing a recursive solution to the discretedata linear filtering problem in 1960 [8]. The equations are given below [3]. The process model is given as JK L M NOM PK Q 9 Measurement model is given as RK SJK TK 10 PK and TK represent the measurement and process noise. They are assumed to be independent, white, and with normal probability distributions. P(w)~ N(0,Q) (11) 16 P(v)~ N(0,R) (12) Q is the process noise covariance and R is the measurement noise covariance matrix. They usually change with each time step, but are assumed to be constant for simplicity in this work. Matrix A relates the state at previous time step k1 to the current time step k. Matrix B relates the optional control input O to the state J. Matrix H in the measurement equation relates the state to the measurement RK . 17 CHAPTER III METHODOLOGY 3.1 Criteria for comparing filters In this work, the following were the criteria used for the filter comparisons: 1. Integral Sum of errors (ISE) 2. Cost 3. Ease of understanding 3.2 Integral sum of errors The integral sum of the errors is used as a basis for the filters comparison. This shows how close to the true value that the filtered value of the noisy signal goes. The higher the value of the ISE the less desirable the filter. The ISE is calculated using the equation: V,W Σ X 13 Where is the filtered value while X is the true value of the signal. Each simulation run gives the value of the ISE for each of the four filters. All simulation was performed with the following variables ;<=2 dt=0.1 18 T=100s τn=2 ;< is the standard deviation of the noise Y< is noise periodic time dt is the time step T is the total duration of the simulation Gaussian distributed noise was added to the signal to corrupt it. This is to enable the evaluation of the filter ability to filter out the noise. Noise is generated using equation (14) xnoise = sigmaw * Sqr(2 * Log(Rnd)) * Sin(2 * 3.14159 * Rnd) (14) Where sigmaw is the noise standard deviation. Rnd is the random number generator to generate a random number for generating the value of the noise. xnoise is the generated noise. An optimal filtering value was required for each of the four filters. The optimal filtering value is required in order to use this value to tune the filter for the purpose of comparison of filter performance relative to the other filters evaluated in this study. An optimal filtering value is the value of the filtering factor that produces the lowest minimization of squared error values (i.e. lowest ISE values). To obtain the optimal filtering value, series of simulation was run for various tuning values. 19 3.2.1 Base value with a step change introduced Figure 3.1 Sample of step change In order to obtain the ISE values during the process with the introduction of a step change, the ISE values calculated using the formula above during the steady state is subtracted from that obtained during the step change. This gives the true ISE value for the introduction of the change. 20 The process is allowed to run for 50 seconds with a time step of 0.1seconds with a steady state base value. After the initial 50 seconds, a step change was introduced to by changing the steady state base value to a value greater than the steady state base plus the standard deviation of the noise (0.1). The process is made to run for another 50 seconds. The time duration of the steady state and the step window is the same in order to be able to obtain the ISE due to the introduction of the change to the base value i.e. all variables are kept constant except the change. The ISE due to the introduction of the change in the signal base value is obtained by subtracting the ISE obtained during the steady state window from the step window. This obtained value after the subtraction represents the ISE due to the change, since the signal was maintained at constant values before and after the change respectively. 21 3.2.2 Base value with a ramp change introduced. Figure 3.2 Sample of Ramp Change In order to obtain the ISE values during the process with the introduction of a ramp change, the ISE values were calculated using the formula above during the steady state and then with the ramp change introduced. The simulation was performed with the steady state base value was held constant for 50 seconds with a time step of “0.1seconds”. After, the initial 50 seconds, a ramp change was introduced using the formula “x =3+ (t50)” for a subsequent 50 seconds. This gives 22 a ramp signal with a slope of “1”. The signal has an intercept of 3 at time t=50 in order to begin the ramp at the previous steady state value. “x” is the true value of the signal and “t” is the time. 3.2.3 Base value with an oscillatory change introduced. Figure 3.3 Sample of oscillatory change 10 5 0 5 10 15 20 0 50 100 150 Signal value time Signal vs time for oscillatory change noisy signal true signal value 23 In order to obtain the ISE values for a process with the introduction of an oscillatory change, the ISE values were calculated using the ISE formula above during the steady state and then also with the oscillatory change introduced. The base value was fixed for 50 seconds with a time step of “0.1seconds”. After, the initial 50 seconds an oscillatory change was introduced using equation (15) 3 0.729535369032546 ,V9 Z[\ [ ] ?^ _ A ` 50 % ) (15) Where: x is the true value of the signal t is the time/duration of the signal radians converts the angle ?^ _ A ` 50 from radian angles into degrees. (The simulation program was written in VBA which defaults to radians). 0.729535369032546 is the amplitude of the oscillatory function. 3 is the base value about which the signal oscillates. These values (i.e. angle " ?^ _ A ` 50 ", amplitude " 0.729535369032546" were chosen by using the “goal seek” trial and error function of Excel in order to obtain an oscillatory signal that initiates at the steady state base value and oscillates about this value. The base value is maintained at the same value as the earlier simulation runs of the signals with the introduction of a step change and the ramp change. A total of 1000 time steps were simulated with 500 time steps for steady base value and 500 time steps for the base value with an oscillatory change introduced. 24 3.3 Cost The cost of the filter was analyzed by a. The number of the required arithmetic operations b. The number of the required variables. The higher the number of the required arithmetic operations the higher the cost since a faster processor would be required for the process. While a filter that requires a higher number of variables would have a greater cost since more memory space would be required to carry out the process. 3.4 Ease of understanding This is a relative comparison based on the education required to understand how the filter works. Based on opinion numbers are assigned to each of the filters. The filter with the lower numbers require a relatively lower level of education for understanding while those with the higher numbers require higher level of education for the understanding. 3.5 Filter Equations and code: 3.5.1 CUSUM filter  The code for the used for the CUSUM filter is given below [6]. IF (first call) THEN N = 0 XOLD = 0.0 XSPC = 0.0 V = 0.0 CUSUM = 0.0 M=11 FF1 = REAL((M2)/(M1)) FF2 = (1.0 – FF1)/2.0 END IF Obtain X N = N + 1 25 V = FF1* V + FF2*(X – XOLD)**2 XOLD = X CUSUM = CUSUM + X  XSPC IF (ABS (CUSUM).GT.TRIGGER*SQR(V*N)) THEN XSPC = XSPC + CUSUM/N N = 0 CUSUM = 0.0 END IF If the absolute value of CUSUM is greater than the critical value of “Trigger*(σ)*N”, the filter assumes that a true change in process has occurred, and it updates the filtered value as XSPC= XSPC + CUSUM/N. And then the variables “N” and “CUSUM” are reset. If the CUSUM is less than the critical value, then the filter assumes that the change in input is due to normal variability of the process, not a true change in level. Hence, it does not change the filtered output. 3.5.2 Firstorder filter The code for the firstorder filter is given below [1]. XF = FF * X + (1  FF) * XF Where XF is the filtered value FF is the filtering factor And X is the input signal to be filtered for noise This filter has the disadvantage that it lags behind the true value. 3.5.3 Selftuning filter The code equations used for the selftuning filter are given below[1]. DELTAF = 0.9 * DELTAF + 0.1 * (XXOLD) ^ 2 XOLD=X LAMBDA=1/(0.5+1.1668*DELTAF/EF^2) IF LAMBDA>1 THEN LAMBDA=1 XF=LAMBDA*X+(1LAMBDA)*XF where: 26 XF is the filtered value LAMBDA is defined above as 1/ (0.5 + 1.1668 * DELTAF / EF ^ 2) EF is the filtering value X is the measured value of the signal DELTAF is a measure of data variance 3.5.4 Kalman Filter The Kalman filter has two sets of equations. They are the time update equations and the measurement update equations. The equations are given below [7]. Time update: XHATMINUS(i) = XHAT(i1) PMINUS(i) =P(i  1) + Q Measurement update: K(i) = PMINUS(i) / (PMINUS(i) + R) XHAT(i) = XHATMINUS(i) + K(i) * (XMEAS  XHATMINUS(i)) P(i) = (1  K(i)) * PMINUS(i)) XF =XHAT(i) where XHATMINUS is the projected state XHAT is actual state measurement vector PMINUS is projected error covariance XMEAS is the measured value of the signal to be filtered P is the updated error covariance Q is the noise covariance 27 R is the variance associated with the measurement K is the Kalman gain XF is the Kalman filtered value 28 CHAPTER IV RESULTS AND DISCUSSION OF RESULTS The following results were obtained from the simulated experiment to compare the performance of four filters (CUSUM, FOF, STF and Kalman) using the ISE (integral sum of errors).In order to carry out the comparison, the experiment was divided into three parts. Part one evaluated the filters performance for a simulated process involving an initial fixed base steady state value with the introduction of a subsequent step change to the base value. The second part had a fixed base value with the introduction of a subsequent ramp change. The final part had a fixed base value with the introduction of a subsequent oscillatory change. 4.1 Part 1 The details of the obtained results are given below: Column 1 of Table 1shows the number of the simulation run, the other columns show the name of the filter, the filter tuning value and whether a change was introduced or not. The first of each of the pairs of columns shows the ISE values for a steady state signal with no change introduced. The second columns show the ISE values with the introduction of a step change. 29 4.2 CUSUM Filter Results Using the filtering values of 1.5, 2, 2.5, 3, 3.5 and 4, a series of simulations was run in order to obtain the filtering value which is nondominated by the other values. A nondominated value is a value which has no other ISE value lower than itself. The obtained results are as shown in Table 1. 30 Table 1. CUSUM ISE values to determine optimal trigger value 31 Table 1 continued. Column 1 shows the number of the simulation run, the other columns show the name of the filter, the filter tuning value and whether a change was introduced or not. The first of each pair of columns shows the ISE values for a steady state signal with no change introduced. Each of the second columns shows the ISE values with the introduction of a step change. 32 Figure 4.1 Plot of CUSUM ISE values with the introduction of a step change to the base value vs CUSUM ISE values with no change in the base steady state value. In Figure 4.1, the xaxis represents the ISE value during the steady state window, while the yaxis represents the ISE values during the window involving the introduction of a step change to the initial steady state value. The diamonds represent a trigger value of 1.5 The squares represent a trigger value of 2 0.0 100.0 200.0 300.0 400.0 500.0 600.0 700.0 800.0 900.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 ISE values with step chaneg in steady state base value ISE values for no change in steady state base value CUSUM (ISE no change vs ISE with Step change) Trigger=1.5 Trigger=2 trigger=2.5 Trigger=3 Trigger=3.5 Trigger=4 33 The “X” represents a trigger value of 3 The “ ” represents a trigger value of 3.5 The circles represent a trigger value of 4 Figure 4.1.1 selection of optimum CUSUM filter tuning value The nondominated values are 1.The diamonds representing a filter tuning value of 1.5 (There are 2 non dominated diamonds as shown by the markers in Figure 4.1.1) 2. The triangles representing a filter tuning value of 2.5 (There are 2 nondominated triangles as shown by the markers in Figure 4.1.1) 34 3 The “X” representing a filter tuning value of 3 (There is 1 nondominated “X” as shown by the marker in Figure 4.1.1). The chosen optimum trigger tuning value is 3. This is because there are two non dominated triangles. And the triangles dominate the “X” on the xaxis. 4.3 Firstorder filter (FOF) A series of simulation was run for FOF with filtering values of 0.1, 0.2, 0.3, 0.4, 0.5 and 0.6. From Figure 4.2, the filtering factor of 0.2 is nondominated; hence this is selected as the optimum filtering value for the FOF. The results are shown in Table 2. 35 Table 2.Firstorder ISE values to determine optimal Filtering factor (λ) 36 Table 2 Continued 37 Figure 4.2 Plot Of Firstorder ISE values with the introduction of a step change to the base value vs Firstorder ISE values with no change in the base steady state value. In Figure 4.2 The diamonds represent a filtering factor value of 0.1 The squares represent a filtering factor value of 0.2 The triangles represent a filtering factor value of 0.3 The “X” represent a a filtering factor value of 0.35 The “ ” represent a filtering factor value of 0.4 0.0 50.0 100.0 150.0 200.0 250.0 0.0 20.0 40.0 60.0 80.0 100.0 120.0 ISE values with step chaneg in steady state base value ISE values for no change in steady state base value FOF (ISE with step change vs ISE with No change in steady state base value) ff=0.1 ff=0.2 ff=0.3 ff=0.4 ff=0.5 ff=0.6 38 The circles represent a filtering factor value of 0.45 Figure 4.2.1 Selection of optimum firstorder filter tuning value The nondominated values are: 1. The diamond representing tuning value of 0.1 (Enclosed by circle 1 in Figure 4.2.1) 2. The squares representing tuning value of 0.2 (Enclosed by circle 2 in Figure 4.2.1) 3. The triangles representing tuning value 0.3 (Enclosed by circle 3 in Figure 4.2.1) 39 The chosen optimum filter tuning value is 0.2. This is the choice because the values of the triangle enclosed by circle 2 dominate the other tuning values enclosed by circle 3 and circle 4 on the xaxis and dominate circle 1 on the yaxis. SelfTuning Filter (STF) The selftuning filter simulation results are given in Table 3. 40 Table 3.STF ISE values to determine optimal filter tuning value (Ef) 41 Table 3 Continued 42 Figure 4.3. Plot of selftuning ISE values with the introduction of a step change to the base value vs selftuning ISE values with no change in the base steady state value. In Figure 4.3 The diamonds represent a filtering factor value of 0.1 The squares represent a filtering factor value of 0.2 The triangles represent a filtering factor value of 0.3 The “X” represent a a filtering factor value of 0.35 The “ ” represent a filtering factor value of 0.4 0.0 500.0 1000.0 1500.0 2000.0 2500.0 3000.0 3500.0 4000.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 ISE values with step chaneg in steady state base value ISE values for no change in steady state base value STF ISE (With a step change vs no change) Ef=0.1 Ef=0.2 Ef=0.3 Ef=0.35 Ef=0.4 Ef=0.45 43 The circles represent a filtering factor value of 0.45 Figure 4.3.1 Selection of optimum selftuning filter tuning value The chosen optimum filter tuning value for the selftuning filter is 0.35 represented by the “X” . This is because the “X” enclosed by rounded rectangle 1 dominate the tuning value 0.3 (enclosed by rounded rectangle 2), 0.2 (enclosed by rounded rectangle 3) and 0.1 (enclosed by rounded rectangle 4) on the yaxis. Tuning value 0.35 (in rounded rectangle 1) also dominates the other tuning values 0.4 and 0.45 (enclosed by rounded rectangle 5 on the xaxis. Thus its choice as optimum tuning value. 4.4. The Kalman Filter The Kalman filter results are as given in table 4. 44 Column 1 with numbers 1 to 20 shows the number of the simulation run. There was a total of 20 simulation runs done to generate each of the 20 results in Table 4 below. Table 4. Kalman ISE values to determine optimal filter tuning value (Q) 45 Table 4 continued 46 Figure 4.4 Plot of Kalman ISE values with the introduction of a step change to the base value vs Kalman ISE values with no change in the steady state base value. In Figure 4.4 The diamonds represent a filtering factor value of 6E2 The squares represent a filtering factor value of 6E3 The triangles represent a filtering factor value of 6.5E3 The “X” represent a a filtering factor value of 7E3 The “ ” represent a filtering factor value of 7.1E3 0.0 20.0 40.0 60.0 80.0 100.0 120.0 0.0 20.0 40.0 60.0 80.0 100.0 ISE values with step chaneg in steady state base value ISE values for no change in steady state base value Kalman ISE (with a step change vs no change in steady state base value) Q=6E2 Q=6e3 Q=6.5E3 Q=7e3 Q=7.1e3 Q=7.2e3 47 The circles represent a filtering factor value of 7.2E3 Figure 4.4.1 Selection of optimum Kalman filter tuning value The nondominated values are 1. The square representing a filtering factor value of 6E3 (The is 1 non dominated value as shown in Figure 4.4.1) 2. The triangle representing a filtering factor value of 6.5E3 (There is 1 non dominated value as shown in Figure 4.4.1) 3. The “X” representing a filtering value of 7E3 (There are 3 nondominated value) 48 The chosen optimum tuning value is 7E3. This is because there are 3 non dominated “X” which is more than the other non dominated shapes. The diamonds enclosed by circle 4 are non chosen because they are all dominated on the xaxis by the other tuning values 4.5 Comparison of Results between the four filters Part 1 Step Change Having obtained the optimum filter tuning values discussed above, these values were then used for the comparison to obtain the filter with the lowest ISE. The result is shown below: Column 1 with numbers 1 to 20 shows the number of the simulation run. Twenty simulation runs was done to generate each of the 20 results below: 49 Table 5. Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman filter for introduction of a step change to steady state base value. 50 Figure 4.5 Plot of ISE values with the introduction of a step change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder , STF, and Kalman filter. In Figure 4.5 The diamonds represent the CUSUM filter The squares represent the firstorder filter The triangles represent the selftuning filter The “X” represent the Kalman filter 0.0 100.0 200.0 300.0 400.0 500.0 600.0 700.0 800.0 0.0 5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 ISE values with step chaneg in steady state base value ISE values for no change in steady state base value ISE (with a step change vs no change in base value cusum(2.5) FOF(0.2) STF(0.35) Kalman(7E3) 51 Figure 4.5.1 Comparison of filter performance for step change Figure 4.5.1 shows that the selftuning filter (rounded rectangle 8) is dominated by the firstorder filter (in rectangle 7) the CUSUM filter (in rounded rectangle 6) and by the Kalman filter (thick rectangle 9) on the yaxis, While the CUSUM filter is dominated by the firstorder filter and Kalman filter on the yaxis. The Kalman filter (enclosed by thick rectangle 7) does well on the yaxis but is dominated by the first order filter (in rectangle 7) on the xaxis. Hence, from Figure 4.5.1 considering rectangles 6, 7 and 8, it can be concluded that the CUSUM filter performs best for a steady state process with no change in base value (i.e. is not dominated on the xaxis during the steady state window), while the Kalman filter performs better for a process that involves a step change to a steady state process. 52 Part 2 Ramp Based on the optimum filter filtering values from the ramp tests, a series of simulation runs was done involving the introduction of a ramp change to the steady state base value and the ISE values for the steady state portion as well as the portion with the change was calculated. The results are given in Table 6. Comparison of the four filter simulation results: 53 Table 6 Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman filter for introduction of a ramp change to steady state base value. Column 1 shows the number of the simulation run, the other columns show the name of the filter, the filter tuning value and whether a change was introduced or not. The first of each pair of the two columns shows the ISE values for a steady state signal with no change introduced. Each of the second columns shows the ISE values with the introduction of a ramp change. 54 Figure 4.6 Plot of ISE values with the introduction of a ramp change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder, STF, and Kalman filter. 0.0 50.0 100.0 150.0 200.0 250.0 300.0 350.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 ISE values with ramp chaneg in steady state base value ISE values for no change in steady state base value ISE (with a ramp change vs no change in base value) cusum (2.5) FOF(0.2) STF(0.35) Kalman(7E3) 55 Figure 4.6 is a plot of the ISE values for simulation runs with a ramp change introduced to the base point on the vertical axis, while the horizontal axis shows values for the steady state base point with no change introduced. The diamonds represent the CUSUM ISE values The squares represent the FOF ISE values The triangles represent the STF ISE values The “X” represent the Kalman ISE values Figure 4.6.1 Comparison of filter performance for ramp change 56 It is observed in Figure 4.6.1 that the Kalman filter (in rounded rectangle 4) dominates the firstorder filter (in rounded rectangle 3) and that the CUSUM filter (in rounded rectangle 1) dominates the selftuning filter (in rounded rectangle 2) on the xaxis. From this observation, it can be concluded that he CUSUM filter performs best for a steady state process with no change in base value (i.e. is not dominated on the xaxis), while the Kalman filter performs best for a process that involves a ramp change to the steady state process (i.e. is not dominated during the ramp change window on the yaxis). Part 3 (Oscillatory signal) The result of simulations with the introduction of an oscillatory change is shown below. Column 1 shows the number of the simulation run, the other columns show the name of the filter, the filter tuning value and whether a change was introduced or not. The first of each pair of columns shows the ISE values for a steady state signal with no change introduced. Each of the second columns shows the ISE values with the introduction of an oscillatory change. 57 Table 7. Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman filter for introduction of a step change to steady state base value. 58 Figure 4.7 Plot of ISE values with the introduction of an oscillatory change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder , STF, and Kalman filter. Figure 4.7 is a plot of the ISE values for simulation runs with an oscillatory change introduced to the base value on the vertical axis, while the horizontal axis shows values for the steady state base value with no change introduced. The diamonds represent the CUSUM ISE values The squares represent the FOF ISE values 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 0.0 5.0 10.0 15.0 20.0 25.0 30.0 ISE values with coscillatory chaneg in steady state base value ISE values for no change in steady state base value ISE (with an oscillatory change vs no change in base value) cusum(2.5) FOF(0.2) STF(0.35) Kalman(7E3) 59 The triangles represent the STF ISE values The “X” represent the Kalman ISE values Figure 4.7.1 Comparison of filter performance for oscillatory change From Figure 4.7.1, it is observed that the CUSUM filter enclosed in rounded rectangle 1 performs well on the xaxis. However, the CUSUM filter is dominated on the yaxis by the selftuning filter, the Kalman filter, and the firstorder filter. The selftuning filter enclosed in rounded rectangle 2 dominates firstorder filter (in rounded rectangle 3) and the Kalman filter (in rounded rectangle 4) on the xaxis. Hence, it can be concluded that the CUSUM filter performs best for a steady state process with no change to the steady state base value, while the selftuning filter performs best for a process that involves an 60 oscillatory change to the steady state process. This is because the selftuning filter is not dominated on the yaxis by any of the other filters, but it dominates the firstorder and Kalman on the xaxis. Thus the choice of the selftuning filter. 4.2 EASE OF UNDERSTANDING THE FILTERS Based on the human ease of understanding, the four filters are grouped into four levels. With level 1 having the relatively easiest understanding and level 100 being the relatively most complex. 61 Table 8. Ease of understanding the filters Filter Relative rank based on ease of understanding First order Filter (FOF) 1. Selftuning filter (STF) 4 . CUSUM 5. Kalman filter 100. FOF is assigned a rank of 1 for ease of understanding because it involved relatively simple mathematics of multiplication, addition and subtraction. STF is assigned a rank of 4 because it involves relatively higher computations of exponential, conditional statement and more variables with assigned values. CUSUM filter is assigned a rank of 5 because it involves relatively higher computations than the FOF and STF with even more variables, conditional statements and calculations. Kalman filter is assigned a rank of 100 because it involves the relatively most complex calculations of the four filters. It involves the use of matrices and matrix operations for the time update and measurement update operations. 4.3 Cost The results for analysis based on arithmetic operations are as given below. The first column shows the number of arithmetic operations (such as “*”, “+”, “”, “^” etc) involved in the filter equation. The second column shows the actual equation. The third column shows the number of “Get” operations required to read a certain input. And, the 62 final column shows the number of “put” operations required to assign a value to a certain variable. 4.3.1 Ranking of filters based on cost analysis derived from the total operations required in the filter equation. Table 9 Evaluation of operations required in CUSUM filter Equation Number Equation Evaluated 1 2 3 Equation Arithmetic Operation Get(Read) Put 1 n=n+1 1 1 1 2 V=ff1*v+ff2*(xxxxold)^ 2 5 5 1 3 CUSUM=CUSUM+xxxxspc 2 3 1 4 xmeas=xxspc 1 1 5 (xx=xmeas) 1 1 6 (xxold=xx) 1 1 Sum 8 12 6 Total 26 Table 10 Evaluation of operations required in firstorder filter Equation Number Equation Evaluation 1 (Arithmetic operation) Evaluation 2 Get (Read) Evaluation3 Put 1 xmeasff=ff*(xmeas)+(1 ff)*(xmeasff) 4 4 1 Total 9 xmeas is the signal measured value xmeasff is the filtered value 63 Table 11 Evaluation of operations required in selftuning filter Equation Number Equation Evaluated 1 2 3 (Arithmetic operation) Get (Read) Put 1 Ef=2*sigmad 1 1 1 2 deltaf=0.9*deltaf+0.1*(xmeasxmeasold)^ 2 5 3 1 3 lambda= (0.5+1.1668*deltaf/Ef^2)^1 4 2 1 4 (xmeasold=xmeas) 1 1 5 (xmeasf=lambda*xmeas+(1 lambda))*xmeasf 4 4 1 Sum 14 11 5 Total 30 sigmad is the standard deviation of the measurement xmeasf is the filtered value 64 Table 12 Evaluation of operations required in Kalman filter Equation Number Equation Evaluated Arithmetic operation Get(Read) Put 1 xhatminus(i)=xhat(i1) 1 2 1 2 Pminus(i)=P(i1)+Q 2 3 1 3 xhat(i)=xhatminus(i)+k(i)*(xmeasxhatminus( i) 3 4 1 4* k(i)=Pminus(i)/(Pminus(i)+R) 3 3 1 5 P(i)=(1k(i))*Pminus(i) 2 3 1 6 xmeaskf=xhat(i) 2 1 7 R=(value) 1 1 8 Q=(Value) 1 1 Sum 11 15 8 Total 34 In equation 4* the inversion operation would require several steps of arithmetic operation when it involves matrices. (This shows that the Kalman filter will involve much more operations than indicated above) xmeaskf is the kalman filtered value xmeas is the signal measurement value Given the results above the filters are ranked on a scale of one to four, with one being the cheapest to operate and four being the most expensive. 65 Table 13. Ranking of filter in increasing order of relative cost. Filter Relative Rank (based on total number of operations) Total number of operations FOF 1 9 CUSUM 3 26 STF 3 30 Kalman 4 34 From the above scale, the firstorder filter is the cheapest to operate in terms of arithmetic operations, while the Kalman filter is the most expensive in terms of arithmetical operations. 3.2. Ranking of filters based on cost analysis derived from the Number of Variables used in Filter Equation. Based on the number of variables required in the filter equation, the four filters are ranked as shown below, with a rank of 1 requiring the least number of variables and 4 requiring the most number of variables: 66 Table 14 Ranking of filter based on the required number of memory location/required variables Filter Rank based on required number of variables Number of memory location (or variables required) FOF 1 3 STF 2 7 Kalman 3 10 CUSUM 4 12 From the result above, The Firstorder filter requires the least number of variables and thus is the least expensive in terms of the required number of variables while the CUSUM filter requires the most number of variables and is thus the most expensive in terms of the required number of variables. 67 CHAPTER V CONCLUSION AND RECOMMENDATION The CUSUM filter is the best filter to use in a steady state process involving no change. In a process that involves a step change, the Kalman filter is the best filter to use. A process that involves a ramp change is best filtered using the Kalman filter. And, an oscillatory process is best filtered using the selftuning filter. Firstorder filter is the easiest to understand, while the Kalman filter is the most complex to understand. The firstorder filter is the cheapest to operate in terms of arithmetic operations, while the Kalman filter is the most expensive in terms of arithmetical operations. The firstorder filter is the least expensive considering required number of variables, while the CUSUM filter requires the most number of variables and is thus the most expensive in terms of the required number of variables. It is recommended that further analysis involving different signal to noise ratio should be carried out. Also, the filter speed of tracking the signal be analyzed in subsequent studies. 68 REFERENCES 1. Cao, S. and Rhinehart, R. R. (1997). "A SelfTuning Filter." Journal of Process Control 7(Number 2): 139148. 2. Douglas, C. M. (1993). Process/Industrial Instruments and Controls Handbook. N Y, McGrawHill. 3. Harris, T. J. and Ross, W. J. (1991). "Statistical Process Control Procedures for Correlated Observations." Canadian Journal of Chemical Engineering 69(1): 4857. 4. Koenig, D. M. (2009). Practical Control Engineering: A Guide for Engineers, Managers, and Practitioners. New York, McGrawHill. 5. Maybeck, P. M. (1979). Stochastic Models, Estimation and Control. New York, Academic Press. 6. Muthiah, N. and Rhinehart, R. R. (2009). "Evaluation of a Statistically Based Controller Override on a PilotScale Flow Loop." ISA Transactions: 31. 7. Welch, G and Bishop, G. (2001). An Introduction to the Kalman Filter. NC, ACM Inc. 8. Vu, Ky M. (2007). The ARIMA and VARIMA Time series: Their Modelings, Analyses and Applications. Ottawa ON, Library and Archives Canada Cataloguing in Publication. 9. Zu, X., Fredendall, L. D. and Douglas, T. J. (2008). "The Evolving Theory of Quality Management:The role of Six Sigma." Journal of Operations Management 26: 630–650. 69 APPPENDIX A VBA codes used in the simulation of steady state signal with the addition of a step change 'VBA codes written with help from Dr. R.R. Rhinehart 'Department of Chemical Engineering, Oklahoma State University 'Daniel Fakunle 'MSC Research Project '101309 'A sub program to generate noisy signal and filter the noise using a 'cusum filter,first order filter and Kalman filter Dim t As Single Dim sigmad As Single Dim dt As Single Dim i As Single Dim sp As Single Dim xmeas As Single Dim ff As Single Dim kc As Single Dim taud As Single Dim n As Single Dim xx As Single Dim xxold As Single Dim xxspc As Single Dim v As Single Dim cusum As Single Dim m As Single Dim ff1 As Single Dim ff2 As Single Dim Trigger As Single Dim xhatminus(1000) Dim Ef As Single Dim xhat(1000) Dim Pminus(1000) Dim P(1000) Dim k(1000) Dim xkp As Single 70 Dim pkp As Single Dim xold As Single Dim pkold As Single Dim Q As Single Dim R As Single Dim kk As Single Dim xk As Single Dim pk As Single Dim xmeaskf As Variant 'Kalman filtered value Dim deltaf As Single Dim lambda As Single Dim xmeasold As Single Dim xmeassf As Single 'Self tuning filtered value Dim xmeasff As Single 'First order filtered value Dim xmeasc As Single 'cusum fltered value Sub signal() Application.ScreenUpdating = False 'Inital values of constants ff = Sheet3.Cells(7, 24) dt = Sheet3.Cells(3, 24) Trigger = Sheet3.Cells(8, 24) kp = Sheet3.Cells(11, 24) Ef = Sheet3.Cells(10, 24) 'kalman filter constants xhat(0) = 1 Pminus(0) = 1 Randomize 'Main Program For i = 1 To 1000 'For loop t = dt * i x = 3 If i > 500 Then x = 10 Call Process(x, xmeas) 'Call filter Call ffilter(xmeas, xmeasff) Call cusumf(xmeas, xmeasc) Call kalman(xmeas, xmeaskf) Call selftuningfilter(xmeas, xmeassf) 'Print out observable results 71 'Application.ScreenUpdating = False Sheet3.Cells(2 + i, 1).Value = t Sheet3.Cells(2 + i, 3).Value = xmeas Sheet3.Cells(i + 2, 4).Value = xmeassf 'STF Sheet3.Cells(i + 2, 5).Value = xmeasc 'Cusum Sheet3.Cells(i + 2, 16).Value = xmeaskf 'Kalmnan Sheet3.Cells(i + 2, 17).Value = xhat(i) Sheet3.Cells(i + 2, 18).Value = Pminus(i) Sheet3.Cells(i + 2, 19) = k Sheet3.Cells(i + 2, 20) = xhatminus(i) Sheet3.Cells(i + 2, 21) = P(i) Sheet3.Cells(i + 2, 22) = xmeasff 'FOF filter 'Sheet3.Cells(i + 2, 44) = Ef 'FOFilter Next i 'Call signal2 Application.ScreenUpdating = True End Sub 'FIRST ORDER FILTER Sub ffilter(xmeas, xmeasff) xmeasff = ff * (xmeas) + (1  ff) * (xmeasff) End Sub 'CUSUM FILTER Sub cusumf(xmeas, xmeasc) If i = 1 Then n = 0 xx = 0 xxold = 0 xxspc = 0 v = 0 cusum = 0 m = 11 ff1 = ((m  2) / (m  1)) ff2 = (1  ff1) / 2 End If xx = xmeas n = n + 1 v = ff1 * v + ff2 * (xx  xxold) ^ 2 xxold = xx cusum = cusum + xx  xxspc If (Abs(cusum) > Trigger * Sqr(v * n)) Then xxspc = xxspc + cusum / n 72 cusum = 0 n = 0 End If xmeasc = xxspc End Sub Sub kalman(xmeas, xmeaskf) 'KALMAN FILTER R = Sheet3.Cells(9, 24).Value Q = Sheet3.Cells(4, 24).Value 'Time Update xhatminus(i) = xhat(i  1) Pminus(i) = P(i  1) + Q 'Measurement Update k(i) = Pminus(i) / (Pminus(i) + R) xhat(i) = xhatminus(i) + k(i) * (xmeas  xhatminus(i)) P(i) = (1  k(i)) * Pminus(i) xmeaskf = xhat(i) 'xold = xk End Sub Sub Process(x, xmeas) taun = Sheet3.Cells(5, 24) If taun = 0 Then taun = 0.0001 sigmad = Sheet3.Cells(6, 24) alpha1 = Exp(dt / taun) beta0 = 1  alpha1 sigmaw = sigmad * Sqr((1 + alpha1) / beta0) xnoise = sigmaw * Sqr(2 * Log(Rnd)) * Sin(2 * 3.14159 * Rnd) 'Gaussian distributed noise sp = x xmeas = x + xnoise End Sub Sub selftuningfilter(xmeas, xmeassf) deltaf = 0.9 * deltaf + 0.1 * (xmeas  xmeasold) ^ 2 lambda = 1 / (0.5 + 1.1668 * deltaf / Ef ^ 2) If lambda > 1 Then lambda = 1 xmeasold = xmeas xmeassf = lambda * xmeas + (1  lambda) * xmeassf End Sub 73 APPPENDIX B VBA codes used in the simulation of steady state signal with the addition of a ramp change 'VBA codes written with help from Dr. R.R. Rhinehart 'Department of Chemical Engineering, Oklahoma state university 'Daniel Fakunle 'MSC Research Project '101309 'A sub program to generate noisy signal and filter the noise using a 'cusum filter,first order filter and Kalman filter Sub signalramp() Application.ScreenUpdating = False 'Inital values of constants ff = Sheet4.Cells(7, 24) dt = Sheet4.Cells(3, 24) Trigger = Sheet4.Cells(8, 24) Ef = Sheet4.Cells(10, 24) 'kalman filter constants xhat(0) = xmeas Pminus(0) = 1 Randomize dt = 0.1 'Main Program For i = 1 To 1000 'For loop t = dt * i x = 3 + (t  50) If i > 500 Then x = 3 + (t  50) Call Process(x, xmeas) 'Call filter Call ffilter(xmeas, xmeasff) Call cusumf(xmeas, xmeasc) Call kalman(xmeas, xmeaskf) Call selftuningfilter(xmeas, xmeassf) 'Print out observable results 74 Application.ScreenUpdating = False Sheet4.Cells(2 + i, 1).Value = t Sheet4.Cells(2 + i, 2).Value = x Sheet4.Cells(2 + i, 3).Value = xmeas Sheet4.Cells(i + 2, 4).Value = xmeassf 'STF Sheet4.Cells(i + 2, 5).Value = xmeasc 'Cusum Sheet4.Cells(i + 2, 16).Value = xmeaskf 'Kalmnan Sheet4.Cells(i + 2, 22) = xmeasff 'FOFilter Next i Application.ScreenUpdating = True End Sub 'FIRST ORDER FILTER Sub ffilter(xmeas, xmeasff) xmeasff = ff * (xmeas) + (1  ff) * (xmeasff) End Sub 'CUSUM FILTER Sub cusumf(xmeas, xmeasc) If i = 1 Then n = 0 xx = 0 xxold = 0 xxspc = 0 v = 0 cusum = 0 m = 11 ff1 = ((m  2) / (m  1)) ff2 = (1  ff1) / 2 End If xx = xmeas n = n + 1 v = ff1 * v + ff2 * (xx  xxold) ^ 2 xxold = xx cusum = cusum + xx  xxspc If (Abs(cusum) > Trigger * Sqr(v * n)) Then xxspc = xxspc + cusum / n cusum = 0 n = 0 End If xmeasc = xxspc End Sub 75 Sub kalman(xmeas, xmeaskf) 'KALMAN FILTER R = Sheet4.Cells(9, 24).Value Q = Sheet4.Cells(4, 24).Value 'Time Update xhatminus(i) = xhat(i  1) Pminus(i) = P(i  1) + Q 'Measurement Update k(i) = Pminus(i) / (Pminus(i) + R) xhat(i) = xhatminus(i) + k(i) * (xmeas  xhatminus(i)) P(i) = (1  k(i)) * Pminus(i) xmeaskf = xhat(i) End Sub Sub Process(x, xmeas) taun = Sheet4.Cells(5, 24) If taun = 0 Then taun = 0.0001 sigmad = Sheet4.Cells(6, 24) alpha1 = Exp(dt / taun) beta0 = 1  alpha1 sigmaw = sigmad * Sqr((1 + alpha1) / beta0) xnoise = sigmaw * Sqr(2 * Log(Rnd)) * Sin(2 * 3.14159 * Rnd) 'Gaussian distributed noise xmeas = x + xnoise End Sub Sub selftuningfilter(xmeas, xmeassf) deltaf = 0.9 * deltaf + 0.1 * (xmeas  xmeasold) ^ 2 lambda = 1 / (0.5 + 1.1668 * deltaf / Ef ^ 2) If lambda > 1 Then lambda = 1 xmeasold = xmeas xmeassf = lambda * xmeas + (1  lambda) * xmeassf End Sub 76 APPPENDIX C VBA codes used in the simulation of steady state signal with the addition of an oscillatory change 'VBA codes written with help from Dr. R.R. Rhinehart 'Department of Chemical Engineering, Oklahoma state university 'Daniel Fakunle 'MSC Research Project '101309 'A sub program to generate noisy signal and filter the noise using a 'cusum filter,first order filter and Kalman filter Sub signaloscillatory() Application.ScreenUpdating = False 'Inital values of constants ff = Sheet5.Cells(7, 24) dt = Sheet5.Cells(3, 24) Trigger = Sheet5.Cells(8, 24) Ef = Sheet5.Cells(10, 24) 'kalman filter constants xhat(0) = xmeas Pminus(0) = 1 Randomize dt = 0.1 'Main Program For i = 1 To 1000 'For loop t = dt * i x = 3 If i > 500 Then x = 3 + 0.729535369032456 * Sin(Application.WorksheetFunction.Radians(50 * Application.WorksheetFunction.Pi() * (t  50) / 20)) Call Process4(x, xmeas) 'Call filter Call ffilter4(xmeas, xmeasff) Call cusumf4(xmeas, xmeasc) Call kalman4(xmeas, xmeaskf) 77 Call selftuningfilter4(xmeas, xmeassf) 'Print out observable results Application.ScreenUpdating = False Sheet5.Cells(2 + i, 1).Value = t Sheet5.Cells(2 + i, 2).Value = x Sheet5.Cells(2 + i, 3).Value = xmeas Sheet5.Cells(i + 2, 4).Value = xmeassf 'STF Sheet5.Cells(i + 2, 5).Value = xmeasc 'Cusum Sheet5.Cells(i + 2, 16).Value = xmeaskf 'Kalmnan Sheet5.Cells(i + 2, 22) = xmeasff 'FOFilter Next i Application.ScreenUpdating = True End Sub 'FIRST ORDER FILTER Sub ffilter4(xmeas, xmeasff) xmeasff = ff * (xmeas) + (1  ff) * (xmeasff) End Sub 'CUSUM FILTER Sub cusumf4(xmeas, xmeasc) If i = 1 Then n = 0 xx = 0 xxold = 0 xxspc = 0 v = 0 cusum = 0 m = 11 ff1 = ((m  2) / (m  1)) ff2 = (1  ff1) / 2 End If xx = xmeas n = n + 1 v = ff1 * v + ff2 * (xx  xxold) ^ 2 xxold = xx cusum = cusum + xx  xxspc If (Abs(cusum) > Trigger * Sqr(v * n)) Then xxspc = xxspc + cusum / n cusum = 0 n = 0 End If xmeasc = xxspc 78 End Sub Sub kalman4(xmeas, xmeaskf) 'KALMAN FILTER R = Sheet5.Cells(9, 24).Value Q = Sheet5.Cells(4, 24).Value 'Time Update xhatminus(i) = xhat(i  1) Pminus(i) = P(i  1) + Q 'Measurement Update k(i) = Pminus(i) / (Pminus(i) + R) xhat(i) = xhatminus(i) + k(i) * (xmeas  xhatminus(i)) P(i) = (1  k(i)) * Pminus(i) xmeaskf = xhat(i) End Sub Sub Process4(x, xmeas) taun = Sheet5.Cells(5, 24) If taun = 0 Then taun = 0.0001 sigmad = Sheet5.Cells(6, 24) alpha1 = Exp(dt / taun) beta0 = 1  alpha1 sigmaw = sigmad * Sqr((1 + alpha1) / beta0) xnoise = sigmaw * Sqr(2 * Log(Rnd)) * Sin(2 * 3.14159 * Rnd) 'Gaussian distributed noise sp = x xmeas = x + xnoise End Sub Sub selftuningfilter4(xmeas, xmeassf) deltaf = 0.9 * deltaf + 0.1 * (xmeas  xmeasold) ^ 2 lambda = 1 / (0.5 + 1.1668 * deltaf / Ef ^ 2) If lambda > 1 Then lambda = 1 xmeasold = xmeas xmeassf = lambda * xmeas + (1  lambda) * xmeassf End Sub 79 VITA DANIEL FAKUNLE Candidate for the Degree of Master of Science Thesis: COMPARISON OF THE CUSUM, FIRST ORDER, SELFTUNING AND KALMAN FILTERS Major Field: Chemical engineering Biographical: Personal Data: Education: Completed the requirements for the Master of Science in Chemical Engineering at Oklahoma State University, Stillwater, Oklahoma in May, 2010. Completed the requirements for the Master of Science in Petroleum Engineering at University of Houston, Houston, Texas in December, 2008. Completed the requirements for the Bachelor of Science/Arts in your major at Obafemi Awolowo University, IleIfe in 2005. ADVISER’S APPROVAL: Dr. R. R. Rhinehart Name: Daniel Fakunle Date of Degree: May, 2010 Institution: Oklahoma State University Location: Stillwater, Oklahoma Title of Study: COMPARISON OF THE CUSUM, FIRSTORDER, SELFTUNING AND KALMAN FILTERS Pages in Study: 79 Candidate for the Degree of Master of Science Major Field: Chemical Engineering Scope and Method of Study: This work involved the comparison of the CUSUM filter, the firstorder filter, the selftuning filter and the Kalman filter. The filters were compared on the basis of the minimization of the integral sum of errors (ISE), the relative cost and the relative ease of understanding. The ISE was compared for processes involving a step change, a ramp change and an oscillatory process change. These three processes were simulated using Visual Basic for Applications (VBA). The four filters were also compared based on the relative ease of human understanding based on the complexity of equations. The relative cost of the filters was based on the number of operations and the required number of storage variables. Findings and Conclusions: The CUSUM filter is the best filter to use in a steady state process involving no change. In a process that involves a step change, the Kalman filter is the best filter to use. A process that involves a ramp change is best filtered using the Kalman filter. And, an oscillatory process is best filtered using the selftuning filter. Firstorder filter is the easiest to understand, while the Kalman filter is the most complex to understand. The firstorder filter is the cheapest to operate in terms of arithmetic operations, while the Kalman filter is the most expensive in terms of arithmetical operations. The firstorder filter is the least expensive considering required number of variables, while the CUSUM filter requires the most number of variables and is thus the most expensive in terms of the required number of variables.
Click tabs to swap between content that is broken into logical sections.
Rating  
Title  Comparison of the Cusum, FirstOrder, SelfTuning and Kalman Filters 
Date  20100501 
Author  Fakunle, Daniel 
Keywords  CUSUM, Filters, Firstorder, Integral Sum of Errors, Process Control, Selftuning 
Department  Chemical Engineering 
Document Type  
Full Text Type  Open Access 
Abstract  This work involved the comparison of the CUSUM filter, the firstorder filter, the selftuning filter and the Kalman filter. The filters were compared on the basis of the minimization of the integral sum of errors (ISE), the relative cost and the relative ease of understanding. The ISE was compared for processes involving a step change, a ramp change and an oscillatory process change. These three processes were simulated using Visual Basic for Applications (VBA). The four filters were also compared based on the relative ease of human understanding based on the complexity of equations. The relative cost of the filters was based on the number of operations and the required number of storage variables. The CUSUM filter is the best filter to use in a steady state process involving no change. In a process that involves a step change, the Kalman filter is the best filter to use. A process that involves a ramp change is best filtered using the Kalman filter. And, an oscillatory process is best filtered using the selftuning filter. Firstorder filter is the easiest to understand, while the Kalman filter is the most complex to understand. The firstorder filter is the cheapest to operate in terms of arithmetic operations, while the Kalman filter is the most expensive in terms of arithmetical operations. The firstorder filter is the least expensive considering required number of variables, while the CUSUM filter requires the most number of variables and is thus the most expensive in terms of the required number of variables. 
Note  Thesis 
Rights  � Oklahoma Agricultural and Mechanical Board of Regents 
Transcript  COMPARISON OF THE CUSUM, FIRSTORDER, SELFTUNING AND KALMAN FILTERS By DANIEL FAKUNLE Bachelor of Science in Chemical Engineering Obafemi Awolowo University IleIfe, Nigeria 2005 Submitted to the Faculty of the Graduate College of the Oklahoma State University in partial fulfillment of the requirements for the Degree of MASTER OF SCIENCE May, 2010 COMPARISON OF THE CUSUM, FIRSTORDER, SELFTUNING AND KALMAN FILTERS Thesis Approved: Dr. R.R. Rhinehart Thesis Adviser Dr. A.J. Johannes Dr. Rob Whiteley Dr. A. Gordon Emslie Dean of the Graduate College 2 ACKNOWLEDGMENTS I will like to express my appreciation and gratitude to Dr. Rhinehart, Dr.Gasem, Dr. Johannes, Dr. Whiteley, and Dr.Fahlenkamp. 3 TABLE OF CONTENTS ......................................................................................................... 5 LIST OF TABLES .................................................................................................................... 6 LIST OF FIGURES .................................................................................................................. 7 CHAPTER I .............................................................................................................................. 8 INTRODUCTION .................................................................................................................... 8 CHAPTER II ........................................................................................................................... 11 REVIEW OF LITERATURE ................................................................................................. 11 2.1 Noise............................................................................................................................. 11 2.2Why filter ....................................................................................................................... 11 2.3 Use of filters and Statistical Process Control (SPC) ..................................................... 12 2.4 Filters ............................................................................................................................. 12 2.4.1 FirstOrder filter: .................................................................................................... 13 2.4.2 SelfTuning Filter ................................................................................................... 13 2.4.3 CUSUM Filter ........................................................................................................ 14 2.4.4 Kalman filter ........................................................................................................... 15 CHAPTER III ......................................................................................................................... 17 METHODOLOGY ................................................................................................................. 17 3.1 Criteria for comparing filters ....................................................................................... 17 3.2 Integral sum of errors .................................................................................................... 17 4 3.2.1 Base value with a step change introduced .............................................................. 19 3.2.2 Base value with a ramp change introduced. ........................................................... 21 3.2.3 Base value with an oscillatory change introduced. ................................................. 22 3.3 Cost............................................................................................................................... 24 3.4 Ease of understanding ................................................................................................... 24 3.5 Filter Equations and code: ............................................................................................. 24 3.5.1 CUSUM filter  ....................................................................................................... 24 3.5.2 Firstorder filter .......................................................................................................... 25 3.5.3 Selftuning filter ......................................................................................................... 25 3.5.4 Kalman Filter.............................................................................................................. 26 CHAPTER IV ......................................................................................................................... 28 RESULTS AND DISCUSSION OF RESULTS..................................................................... 28 4.1 Part 1 ............................................................................................................................. 28 4.2 CUSUM Filter Results .................................................................................................. 29 4.3 Firstorder filter (FOF) .................................................................................................. 34 SelfTuning Filter (STF) .................................................................................................. 39 4.4. The Kalman Filter ........................................................................................................ 43 4.5 Comparison of Results between the four filters: ........................................................... 48 4.2 EASE OF UNDERSTANDING THE FILTERS .......................................................... 60 4.3 Cost............................................................................................................................... 61 5 4.3.1 Ranking of filters based on cost analysis derived from the total operations .......... 62 3.2. Ranking of filters based on cost analysis derived from the Number of ....................... 65 CHAPTER V .......................................................................................................................... 67 RECOMMENDATION .......................................................................................................... 67 REFERENCES ....................................................................................................................... 68 APPPENDIX.......................................................................................................................... 69 6 LIST OF TABLES Table Page 1. CUSUM ISE values to determine optimal trigger value ………………………30 2. Firstorder ISE values to determine optimal Filtering factor (λ)...……………..35 3. STF ISE values to determine optimal Filter tuning value (Ef) ………………...40 4. Kalman ISE values to determine optimal filter tuning value (Q)………………44 5. Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman filter for introduction of a step change to steady state base value……………….48 6. Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman…53 filter for introduction of a ramp change to steady state base value 7. Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman filter for introduction of a step change to steady state base value……………….55 8. Ease of understanding the filter……………………………………………….. 61 9 Evaluation of operations required in CUSUM filter…………………………….62 10 Evaluation of operations required in firstorder filter………………………….62 11 Evaluation of operations required in selftuning filter…………………………63 12 Evaluation of operations required in Kalman filter……………………………..64 13. Ranking of filter in increasing order of relative cost…………………………...65 14 Ranking of filter based on the required number of memory…………………….66 location / required variables 7 LIST OF FIGURES Figure Page 4.1: Plot Of CUSUM ISE values with the introduction of a step change to the base value vs CUSUM ISE values with no change in the base steady state value……32 4.2: Plot Of Firstorder ISE values with the introduction of a step change to the base value vs Firstorder ISE values with no change in the base steady state value………………………………………………………………………..…….37 4.3. Plot of Selftuning ISE values with the introduction of a step change to the base value vs Selftuning ISE values with no change in the base steady state value……………………………………………………………………………...42 4.4. Plot of Kalman ISE values with the introduction of a step change to the base value vs Kalman ISE values with no change in the steady state base value……..46 4.5. Plot of ISE values with the introduction of a step change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder , STF, and Kalman filter……………………………………………..50 4.6. Plot of ISE values with the introduction of a ramp change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder , STF, and Kalman filter…………………………………………….54 4.7. Plot of ISE values with the introduction of an oscillatory change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder , STF, and Kalman filter………………………………….58 8 CHAPTER I INTRODUCTION Filtering is the process of removing the noise associated with process measurements in order to observe the noiseless “or true” value. Filters seek to identify the true process signal in the presence of noise [6]. It is desired to have a filter that gives an accurate process signal for a variety of patterns in process. This is because filters are used to “filter out” the noise in a process and the more accurate the resulting signal, the better the filter. In this work, four filters are evaluated and compared for performance; and based on the comparison, conclusions are made. The comparison aspects include speed of tracking a change in the process (measured by ISE (Integral Sum of errors)), closeness of the filtered value to the true signal when there is no change in the process (also measured by ISE), computational burden, complexity for human understanding, and cost issues. A series of simulations was done to generate data for the comparison using Visual Basic for Applications Programming. Noise was added to the simulation in order to corrupt the produced signal. The noisy signal was then filtered to obtain the true value which is known. Based on the filtered value, measures of goodness were calculated for each filter 9 in each simulated run. The simulation involved a steady base value and the introduction of a change to the base value. This steady base value is used to obtain the accuracy of the filter in finding the true signal value for a steady value, while the change is introduced in order to obtain the speed of tracking a change and the accuracy of the filter in tracking the change. The performance of the filters was then evaluated using the calculated ISE values. Step change, ramp change and oscillatory changes were introduced to the base value and the effect on the four filter outputs was then evaluated for results. The experiments also included range of tuning factors to determine the best value to give a nondominated individual on a multiobjective (ISE1 vs. ISE2) plane. Where ISE1 involved no change in a steady base value and ISE2 involved the introduction of a change to the steady state base value. The experiments included three changes; step, ramp and oscillatory. The filters considered were the firstorder filter (FOF) [6], the selftuning filter (STF) [1], the CUSUM filter [6] and the Kalman filter [4]. The firstorder filter was chosen because it is used in the industry as a common industrial filtering practice [1]. The selftuning filter was chosen because it can achieve a high ratio of noise reduction without giving up its fast tracking of a process [1]. The Kalman filter was chosen because it is a wellknown and oftenused tool for mathematical stochastic estimation from noisy sensor measurements [3]. The CUSUM filter was chosen as an innovative filter to compare its performance to other industrially used filter such as the firstorder and the Kalman filter. 10 The firstorder filter averages data to reduce the effects of noise, but it also causes undesirable lag in the filtered variable. The greater the noise amplitude, the higher the required filtering. It is an Infinite Impulse Response (IIR) filter. The objective of the selftuning filter is to determine the filtering factor (λ) such that there is a 95% probability that the true value lies within the user chosen confidence interval about the average [1]. The CUSUM filter is a novel filter based on a cumulative sum of deviations. It is derived from Statistical Process Control Concepts (SPC) [6]. The CUSUM filter action holds the filtered value constant until there is sufficient statistical level of confidence that a change has occurred. The Kalman filter is a recursive data processing algorithm [5]. A Kalman filter combines all available measurement data, plus prior knowledge about the system and measuring devices, to produce an estimate of the desired variables. It estimates a process by using a form of feedback control by utilizing time update equations and measurement update equations. 11 CHAPTER II REVIEW OF LITERATURE 2.1 Noise In this work, noise is defined as a fluctuating influence on process measurement that cannot be controlled because it is either: 1) a fluctuating misrepresentation of the true Process Variable (PV) (for example, some random electrical noise is added to the signal through the sensor and the electrical circuits) or 2) a transient influence on the PV. Noise is often described as a zeromean, independent, Gaussian distributed addition to the true PV (process variable) value [6]. This time varying ratio of “pure” signal to the electrical noise affects the quality of the information. [7]. 2.2Why filter Filtering is done in order to remove noise and obtain the true process value. In process control, process noise and instrument noise are undesirable. This is because the controller will respond to the noise rather than the true process change. The noise masks the true 12 process variable. A result of this would be an increase in the process variability and increased wear and tear in final control element. 2.3 Use of filters and Statistical Process Control (SPC) Usually the process variable (PV) is filtered and the filtered value is fed to the controller. Statistical Process Control (SPC) is a philosophy that overrides the desire to implement a change until there is sufficient statistical evidence to implement the change [6]. Statistical Process Control involves a broad scope of activities including the design of sampling and inspection schemes, experimental design and analysis to detect shifts in the mean or variability of a process [3]. 2.4 Filters There are two models for a digital filter. These are the Infinite Impulse Response filter (IIR) and the Finite Impulse Response filter (FIR) [8]. FIR has a finite memory. It is non recursive because it does not require a feedback loop in its implementation. IIR has infinite memory. It is called a recursive filter because the output is fed back into the input. One of the most important criterions for filters is the squared error minimization [1]. This is because a filter with a low value of the squared error gives an output that is very close to the true value of the signal it is filtering, while one with a high value of the squared error gives an output that is far away from the true value of the filtered signal. 13 2.4.1 FirstOrder filter: The firstorder filter averages data to reduce the effects of noise. It is a recursive filter. It has an undesirable characteristic of introducing a lag in the control loop. This lag in the loop affects stability, and undesirably limits the aggressiveness of the controller. When there is a change in process variable (PV) value, the firstorder filter output lags behind. During a noisy steady state period, the firstorder filter output keeps changing at every sample. The FOF equation is given as [1]: 1 1 Where is the filtered value is the filtering factor i is the sample counter And is the input signal 2.4.2 SelfTuning Filter The selftuning filter automatically adjusts λ in the FOF. It is based on the 95% confidence interval for engineering economic decisions. Its objective is to determine λ such that there is a 95% probability that the true steady state process value is within the user chosen confidence interval about the average. The three equations for the selftuning filter are [1]: 0.1 0.9 2 . !" # $# % ,1' 3 1 4 14 Where x is the current measured value of the signal. Where is the old signal measured value. Where is the resulting filtered value. Where E is the error between the true (unknown) value and the 2.5% extreme value of the filtered value. It is chosen by the user. is a measure of data variance. 2.4.3 CUSUM Filter In statistics, 3sigma is the two specific points on a normal distribution centered about the mean. Out of a population, 99.73% of the population will fall between these values. It represents the entire population and +3sigma and 3sigma represents the probable range of variation [2]. It is used in the industry as an organized and systematic method for strategic process improvement, new product and service development relying on statistical methods and the scientific method to make dramatic reductions in customer defined defect rates [9]. The CUSUM filter is based on this principle. The filter attempts to find the mean within noisy data. The concept holds the mean is unchanged, until there is sufficient statistical confidence that a real change has occurred. If the Process Variable (PV) “really” changes, then the average will shift. The CUSUM gives the criteria for making a change as [6]: *+,+ Σ / /0123 45 5 If *+,+ > TRIGGER*√9 6 ; <=> ?@ @ A ; ? @ A <=> 7 ;/ C4"DEF # 8 15 Where 9 is the number of samples for which CUSUM had been calculated. is the measured value of the variable. 0 is the old value of the calucated mean of the measured variable. ;/is defined by equations 7 and 8 M ≅ 11 (This gives the “best” balance of removing variability from the estimate) Trigger value represents the SPC confidence level in a decision. The trigger value of 1 represents 68.3% confidence level. A value of 2 represents traditional economic decision trigger values of I2; representing a 95% confidence in a decision. A value of 3 is the 3 sigma 99.73% confidence level. Values from 2 to 4 are generally chosen to balance responsiveness and false alarms for particular SPC applications [6]. 2.4.4 Kalman filter The Kalman filter is the application of the combination of the method of combining a model of the process with adjusted process measurements to produce an estimate of the state [4]. It named after Rudolph E. Kalman, who published a paper describing a recursive solution to the discretedata linear filtering problem in 1960 [8]. The equations are given below [3]. The process model is given as JK L M NOM PK Q 9 Measurement model is given as RK SJK TK 10 PK and TK represent the measurement and process noise. They are assumed to be independent, white, and with normal probability distributions. P(w)~ N(0,Q) (11) 16 P(v)~ N(0,R) (12) Q is the process noise covariance and R is the measurement noise covariance matrix. They usually change with each time step, but are assumed to be constant for simplicity in this work. Matrix A relates the state at previous time step k1 to the current time step k. Matrix B relates the optional control input O to the state J. Matrix H in the measurement equation relates the state to the measurement RK . 17 CHAPTER III METHODOLOGY 3.1 Criteria for comparing filters In this work, the following were the criteria used for the filter comparisons: 1. Integral Sum of errors (ISE) 2. Cost 3. Ease of understanding 3.2 Integral sum of errors The integral sum of the errors is used as a basis for the filters comparison. This shows how close to the true value that the filtered value of the noisy signal goes. The higher the value of the ISE the less desirable the filter. The ISE is calculated using the equation: V,W Σ X 13 Where is the filtered value while X is the true value of the signal. Each simulation run gives the value of the ISE for each of the four filters. All simulation was performed with the following variables ;<=2 dt=0.1 18 T=100s τn=2 ;< is the standard deviation of the noise Y< is noise periodic time dt is the time step T is the total duration of the simulation Gaussian distributed noise was added to the signal to corrupt it. This is to enable the evaluation of the filter ability to filter out the noise. Noise is generated using equation (14) xnoise = sigmaw * Sqr(2 * Log(Rnd)) * Sin(2 * 3.14159 * Rnd) (14) Where sigmaw is the noise standard deviation. Rnd is the random number generator to generate a random number for generating the value of the noise. xnoise is the generated noise. An optimal filtering value was required for each of the four filters. The optimal filtering value is required in order to use this value to tune the filter for the purpose of comparison of filter performance relative to the other filters evaluated in this study. An optimal filtering value is the value of the filtering factor that produces the lowest minimization of squared error values (i.e. lowest ISE values). To obtain the optimal filtering value, series of simulation was run for various tuning values. 19 3.2.1 Base value with a step change introduced Figure 3.1 Sample of step change In order to obtain the ISE values during the process with the introduction of a step change, the ISE values calculated using the formula above during the steady state is subtracted from that obtained during the step change. This gives the true ISE value for the introduction of the change. 20 The process is allowed to run for 50 seconds with a time step of 0.1seconds with a steady state base value. After the initial 50 seconds, a step change was introduced to by changing the steady state base value to a value greater than the steady state base plus the standard deviation of the noise (0.1). The process is made to run for another 50 seconds. The time duration of the steady state and the step window is the same in order to be able to obtain the ISE due to the introduction of the change to the base value i.e. all variables are kept constant except the change. The ISE due to the introduction of the change in the signal base value is obtained by subtracting the ISE obtained during the steady state window from the step window. This obtained value after the subtraction represents the ISE due to the change, since the signal was maintained at constant values before and after the change respectively. 21 3.2.2 Base value with a ramp change introduced. Figure 3.2 Sample of Ramp Change In order to obtain the ISE values during the process with the introduction of a ramp change, the ISE values were calculated using the formula above during the steady state and then with the ramp change introduced. The simulation was performed with the steady state base value was held constant for 50 seconds with a time step of “0.1seconds”. After, the initial 50 seconds, a ramp change was introduced using the formula “x =3+ (t50)” for a subsequent 50 seconds. This gives 22 a ramp signal with a slope of “1”. The signal has an intercept of 3 at time t=50 in order to begin the ramp at the previous steady state value. “x” is the true value of the signal and “t” is the time. 3.2.3 Base value with an oscillatory change introduced. Figure 3.3 Sample of oscillatory change 10 5 0 5 10 15 20 0 50 100 150 Signal value time Signal vs time for oscillatory change noisy signal true signal value 23 In order to obtain the ISE values for a process with the introduction of an oscillatory change, the ISE values were calculated using the ISE formula above during the steady state and then also with the oscillatory change introduced. The base value was fixed for 50 seconds with a time step of “0.1seconds”. After, the initial 50 seconds an oscillatory change was introduced using equation (15) 3 0.729535369032546 ,V9 Z[\ [ ] ?^ _ A ` 50 % ) (15) Where: x is the true value of the signal t is the time/duration of the signal radians converts the angle ?^ _ A ` 50 from radian angles into degrees. (The simulation program was written in VBA which defaults to radians). 0.729535369032546 is the amplitude of the oscillatory function. 3 is the base value about which the signal oscillates. These values (i.e. angle " ?^ _ A ` 50 ", amplitude " 0.729535369032546" were chosen by using the “goal seek” trial and error function of Excel in order to obtain an oscillatory signal that initiates at the steady state base value and oscillates about this value. The base value is maintained at the same value as the earlier simulation runs of the signals with the introduction of a step change and the ramp change. A total of 1000 time steps were simulated with 500 time steps for steady base value and 500 time steps for the base value with an oscillatory change introduced. 24 3.3 Cost The cost of the filter was analyzed by a. The number of the required arithmetic operations b. The number of the required variables. The higher the number of the required arithmetic operations the higher the cost since a faster processor would be required for the process. While a filter that requires a higher number of variables would have a greater cost since more memory space would be required to carry out the process. 3.4 Ease of understanding This is a relative comparison based on the education required to understand how the filter works. Based on opinion numbers are assigned to each of the filters. The filter with the lower numbers require a relatively lower level of education for understanding while those with the higher numbers require higher level of education for the understanding. 3.5 Filter Equations and code: 3.5.1 CUSUM filter  The code for the used for the CUSUM filter is given below [6]. IF (first call) THEN N = 0 XOLD = 0.0 XSPC = 0.0 V = 0.0 CUSUM = 0.0 M=11 FF1 = REAL((M2)/(M1)) FF2 = (1.0 – FF1)/2.0 END IF Obtain X N = N + 1 25 V = FF1* V + FF2*(X – XOLD)**2 XOLD = X CUSUM = CUSUM + X  XSPC IF (ABS (CUSUM).GT.TRIGGER*SQR(V*N)) THEN XSPC = XSPC + CUSUM/N N = 0 CUSUM = 0.0 END IF If the absolute value of CUSUM is greater than the critical value of “Trigger*(σ)*N”, the filter assumes that a true change in process has occurred, and it updates the filtered value as XSPC= XSPC + CUSUM/N. And then the variables “N” and “CUSUM” are reset. If the CUSUM is less than the critical value, then the filter assumes that the change in input is due to normal variability of the process, not a true change in level. Hence, it does not change the filtered output. 3.5.2 Firstorder filter The code for the firstorder filter is given below [1]. XF = FF * X + (1  FF) * XF Where XF is the filtered value FF is the filtering factor And X is the input signal to be filtered for noise This filter has the disadvantage that it lags behind the true value. 3.5.3 Selftuning filter The code equations used for the selftuning filter are given below[1]. DELTAF = 0.9 * DELTAF + 0.1 * (XXOLD) ^ 2 XOLD=X LAMBDA=1/(0.5+1.1668*DELTAF/EF^2) IF LAMBDA>1 THEN LAMBDA=1 XF=LAMBDA*X+(1LAMBDA)*XF where: 26 XF is the filtered value LAMBDA is defined above as 1/ (0.5 + 1.1668 * DELTAF / EF ^ 2) EF is the filtering value X is the measured value of the signal DELTAF is a measure of data variance 3.5.4 Kalman Filter The Kalman filter has two sets of equations. They are the time update equations and the measurement update equations. The equations are given below [7]. Time update: XHATMINUS(i) = XHAT(i1) PMINUS(i) =P(i  1) + Q Measurement update: K(i) = PMINUS(i) / (PMINUS(i) + R) XHAT(i) = XHATMINUS(i) + K(i) * (XMEAS  XHATMINUS(i)) P(i) = (1  K(i)) * PMINUS(i)) XF =XHAT(i) where XHATMINUS is the projected state XHAT is actual state measurement vector PMINUS is projected error covariance XMEAS is the measured value of the signal to be filtered P is the updated error covariance Q is the noise covariance 27 R is the variance associated with the measurement K is the Kalman gain XF is the Kalman filtered value 28 CHAPTER IV RESULTS AND DISCUSSION OF RESULTS The following results were obtained from the simulated experiment to compare the performance of four filters (CUSUM, FOF, STF and Kalman) using the ISE (integral sum of errors).In order to carry out the comparison, the experiment was divided into three parts. Part one evaluated the filters performance for a simulated process involving an initial fixed base steady state value with the introduction of a subsequent step change to the base value. The second part had a fixed base value with the introduction of a subsequent ramp change. The final part had a fixed base value with the introduction of a subsequent oscillatory change. 4.1 Part 1 The details of the obtained results are given below: Column 1 of Table 1shows the number of the simulation run, the other columns show the name of the filter, the filter tuning value and whether a change was introduced or not. The first of each of the pairs of columns shows the ISE values for a steady state signal with no change introduced. The second columns show the ISE values with the introduction of a step change. 29 4.2 CUSUM Filter Results Using the filtering values of 1.5, 2, 2.5, 3, 3.5 and 4, a series of simulations was run in order to obtain the filtering value which is nondominated by the other values. A nondominated value is a value which has no other ISE value lower than itself. The obtained results are as shown in Table 1. 30 Table 1. CUSUM ISE values to determine optimal trigger value 31 Table 1 continued. Column 1 shows the number of the simulation run, the other columns show the name of the filter, the filter tuning value and whether a change was introduced or not. The first of each pair of columns shows the ISE values for a steady state signal with no change introduced. Each of the second columns shows the ISE values with the introduction of a step change. 32 Figure 4.1 Plot of CUSUM ISE values with the introduction of a step change to the base value vs CUSUM ISE values with no change in the base steady state value. In Figure 4.1, the xaxis represents the ISE value during the steady state window, while the yaxis represents the ISE values during the window involving the introduction of a step change to the initial steady state value. The diamonds represent a trigger value of 1.5 The squares represent a trigger value of 2 0.0 100.0 200.0 300.0 400.0 500.0 600.0 700.0 800.0 900.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 ISE values with step chaneg in steady state base value ISE values for no change in steady state base value CUSUM (ISE no change vs ISE with Step change) Trigger=1.5 Trigger=2 trigger=2.5 Trigger=3 Trigger=3.5 Trigger=4 33 The “X” represents a trigger value of 3 The “ ” represents a trigger value of 3.5 The circles represent a trigger value of 4 Figure 4.1.1 selection of optimum CUSUM filter tuning value The nondominated values are 1.The diamonds representing a filter tuning value of 1.5 (There are 2 non dominated diamonds as shown by the markers in Figure 4.1.1) 2. The triangles representing a filter tuning value of 2.5 (There are 2 nondominated triangles as shown by the markers in Figure 4.1.1) 34 3 The “X” representing a filter tuning value of 3 (There is 1 nondominated “X” as shown by the marker in Figure 4.1.1). The chosen optimum trigger tuning value is 3. This is because there are two non dominated triangles. And the triangles dominate the “X” on the xaxis. 4.3 Firstorder filter (FOF) A series of simulation was run for FOF with filtering values of 0.1, 0.2, 0.3, 0.4, 0.5 and 0.6. From Figure 4.2, the filtering factor of 0.2 is nondominated; hence this is selected as the optimum filtering value for the FOF. The results are shown in Table 2. 35 Table 2.Firstorder ISE values to determine optimal Filtering factor (λ) 36 Table 2 Continued 37 Figure 4.2 Plot Of Firstorder ISE values with the introduction of a step change to the base value vs Firstorder ISE values with no change in the base steady state value. In Figure 4.2 The diamonds represent a filtering factor value of 0.1 The squares represent a filtering factor value of 0.2 The triangles represent a filtering factor value of 0.3 The “X” represent a a filtering factor value of 0.35 The “ ” represent a filtering factor value of 0.4 0.0 50.0 100.0 150.0 200.0 250.0 0.0 20.0 40.0 60.0 80.0 100.0 120.0 ISE values with step chaneg in steady state base value ISE values for no change in steady state base value FOF (ISE with step change vs ISE with No change in steady state base value) ff=0.1 ff=0.2 ff=0.3 ff=0.4 ff=0.5 ff=0.6 38 The circles represent a filtering factor value of 0.45 Figure 4.2.1 Selection of optimum firstorder filter tuning value The nondominated values are: 1. The diamond representing tuning value of 0.1 (Enclosed by circle 1 in Figure 4.2.1) 2. The squares representing tuning value of 0.2 (Enclosed by circle 2 in Figure 4.2.1) 3. The triangles representing tuning value 0.3 (Enclosed by circle 3 in Figure 4.2.1) 39 The chosen optimum filter tuning value is 0.2. This is the choice because the values of the triangle enclosed by circle 2 dominate the other tuning values enclosed by circle 3 and circle 4 on the xaxis and dominate circle 1 on the yaxis. SelfTuning Filter (STF) The selftuning filter simulation results are given in Table 3. 40 Table 3.STF ISE values to determine optimal filter tuning value (Ef) 41 Table 3 Continued 42 Figure 4.3. Plot of selftuning ISE values with the introduction of a step change to the base value vs selftuning ISE values with no change in the base steady state value. In Figure 4.3 The diamonds represent a filtering factor value of 0.1 The squares represent a filtering factor value of 0.2 The triangles represent a filtering factor value of 0.3 The “X” represent a a filtering factor value of 0.35 The “ ” represent a filtering factor value of 0.4 0.0 500.0 1000.0 1500.0 2000.0 2500.0 3000.0 3500.0 4000.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 ISE values with step chaneg in steady state base value ISE values for no change in steady state base value STF ISE (With a step change vs no change) Ef=0.1 Ef=0.2 Ef=0.3 Ef=0.35 Ef=0.4 Ef=0.45 43 The circles represent a filtering factor value of 0.45 Figure 4.3.1 Selection of optimum selftuning filter tuning value The chosen optimum filter tuning value for the selftuning filter is 0.35 represented by the “X” . This is because the “X” enclosed by rounded rectangle 1 dominate the tuning value 0.3 (enclosed by rounded rectangle 2), 0.2 (enclosed by rounded rectangle 3) and 0.1 (enclosed by rounded rectangle 4) on the yaxis. Tuning value 0.35 (in rounded rectangle 1) also dominates the other tuning values 0.4 and 0.45 (enclosed by rounded rectangle 5 on the xaxis. Thus its choice as optimum tuning value. 4.4. The Kalman Filter The Kalman filter results are as given in table 4. 44 Column 1 with numbers 1 to 20 shows the number of the simulation run. There was a total of 20 simulation runs done to generate each of the 20 results in Table 4 below. Table 4. Kalman ISE values to determine optimal filter tuning value (Q) 45 Table 4 continued 46 Figure 4.4 Plot of Kalman ISE values with the introduction of a step change to the base value vs Kalman ISE values with no change in the steady state base value. In Figure 4.4 The diamonds represent a filtering factor value of 6E2 The squares represent a filtering factor value of 6E3 The triangles represent a filtering factor value of 6.5E3 The “X” represent a a filtering factor value of 7E3 The “ ” represent a filtering factor value of 7.1E3 0.0 20.0 40.0 60.0 80.0 100.0 120.0 0.0 20.0 40.0 60.0 80.0 100.0 ISE values with step chaneg in steady state base value ISE values for no change in steady state base value Kalman ISE (with a step change vs no change in steady state base value) Q=6E2 Q=6e3 Q=6.5E3 Q=7e3 Q=7.1e3 Q=7.2e3 47 The circles represent a filtering factor value of 7.2E3 Figure 4.4.1 Selection of optimum Kalman filter tuning value The nondominated values are 1. The square representing a filtering factor value of 6E3 (The is 1 non dominated value as shown in Figure 4.4.1) 2. The triangle representing a filtering factor value of 6.5E3 (There is 1 non dominated value as shown in Figure 4.4.1) 3. The “X” representing a filtering value of 7E3 (There are 3 nondominated value) 48 The chosen optimum tuning value is 7E3. This is because there are 3 non dominated “X” which is more than the other non dominated shapes. The diamonds enclosed by circle 4 are non chosen because they are all dominated on the xaxis by the other tuning values 4.5 Comparison of Results between the four filters Part 1 Step Change Having obtained the optimum filter tuning values discussed above, these values were then used for the comparison to obtain the filter with the lowest ISE. The result is shown below: Column 1 with numbers 1 to 20 shows the number of the simulation run. Twenty simulation runs was done to generate each of the 20 results below: 49 Table 5. Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman filter for introduction of a step change to steady state base value. 50 Figure 4.5 Plot of ISE values with the introduction of a step change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder , STF, and Kalman filter. In Figure 4.5 The diamonds represent the CUSUM filter The squares represent the firstorder filter The triangles represent the selftuning filter The “X” represent the Kalman filter 0.0 100.0 200.0 300.0 400.0 500.0 600.0 700.0 800.0 0.0 5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 ISE values with step chaneg in steady state base value ISE values for no change in steady state base value ISE (with a step change vs no change in base value cusum(2.5) FOF(0.2) STF(0.35) Kalman(7E3) 51 Figure 4.5.1 Comparison of filter performance for step change Figure 4.5.1 shows that the selftuning filter (rounded rectangle 8) is dominated by the firstorder filter (in rectangle 7) the CUSUM filter (in rounded rectangle 6) and by the Kalman filter (thick rectangle 9) on the yaxis, While the CUSUM filter is dominated by the firstorder filter and Kalman filter on the yaxis. The Kalman filter (enclosed by thick rectangle 7) does well on the yaxis but is dominated by the first order filter (in rectangle 7) on the xaxis. Hence, from Figure 4.5.1 considering rectangles 6, 7 and 8, it can be concluded that the CUSUM filter performs best for a steady state process with no change in base value (i.e. is not dominated on the xaxis during the steady state window), while the Kalman filter performs better for a process that involves a step change to a steady state process. 52 Part 2 Ramp Based on the optimum filter filtering values from the ramp tests, a series of simulation runs was done involving the introduction of a ramp change to the steady state base value and the ISE values for the steady state portion as well as the portion with the change was calculated. The results are given in Table 6. Comparison of the four filter simulation results: 53 Table 6 Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman filter for introduction of a ramp change to steady state base value. Column 1 shows the number of the simulation run, the other columns show the name of the filter, the filter tuning value and whether a change was introduced or not. The first of each pair of the two columns shows the ISE values for a steady state signal with no change introduced. Each of the second columns shows the ISE values with the introduction of a ramp change. 54 Figure 4.6 Plot of ISE values with the introduction of a ramp change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder, STF, and Kalman filter. 0.0 50.0 100.0 150.0 200.0 250.0 300.0 350.0 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 ISE values with ramp chaneg in steady state base value ISE values for no change in steady state base value ISE (with a ramp change vs no change in base value) cusum (2.5) FOF(0.2) STF(0.35) Kalman(7E3) 55 Figure 4.6 is a plot of the ISE values for simulation runs with a ramp change introduced to the base point on the vertical axis, while the horizontal axis shows values for the steady state base point with no change introduced. The diamonds represent the CUSUM ISE values The squares represent the FOF ISE values The triangles represent the STF ISE values The “X” represent the Kalman ISE values Figure 4.6.1 Comparison of filter performance for ramp change 56 It is observed in Figure 4.6.1 that the Kalman filter (in rounded rectangle 4) dominates the firstorder filter (in rounded rectangle 3) and that the CUSUM filter (in rounded rectangle 1) dominates the selftuning filter (in rounded rectangle 2) on the xaxis. From this observation, it can be concluded that he CUSUM filter performs best for a steady state process with no change in base value (i.e. is not dominated on the xaxis), while the Kalman filter performs best for a process that involves a ramp change to the steady state process (i.e. is not dominated during the ramp change window on the yaxis). Part 3 (Oscillatory signal) The result of simulations with the introduction of an oscillatory change is shown below. Column 1 shows the number of the simulation run, the other columns show the name of the filter, the filter tuning value and whether a change was introduced or not. The first of each pair of columns shows the ISE values for a steady state signal with no change introduced. Each of the second columns shows the ISE values with the introduction of an oscillatory change. 57 Table 7. Comparison of ISE results of CUSUM, Firstorder, Selftuning and Kalman filter for introduction of a step change to steady state base value. 58 Figure 4.7 Plot of ISE values with the introduction of an oscillatory change to the steady state base value vs ISE values with no change introduction for the CUSUM, Firstorder , STF, and Kalman filter. Figure 4.7 is a plot of the ISE values for simulation runs with an oscillatory change introduced to the base value on the vertical axis, while the horizontal axis shows values for the steady state base value with no change introduced. The diamonds represent the CUSUM ISE values The squares represent the FOF ISE values 0.0 10.0 20.0 30.0 40.0 50.0 60.0 70.0 0.0 5.0 10.0 15.0 20.0 25.0 30.0 ISE values with coscillatory chaneg in steady state base value ISE values for no change in steady state base value ISE (with an oscillatory change vs no change in base value) cusum(2.5) FOF(0.2) STF(0.35) Kalman(7E3) 59 The triangles represent the STF ISE values The “X” represent the Kalman ISE values Figure 4.7.1 Comparison of filter performance for oscillatory change From Figure 4.7.1, it is observed that the CUSUM filter enclosed in rounded rectangle 1 performs well on the xaxis. However, the CUSUM filter is dominated on the yaxis by the selftuning filter, the Kalman filter, and the firstorder filter. The selftuning filter enclosed in rounded rectangle 2 dominates firstorder filter (in rounded rectangle 3) and the Kalman filter (in rounded rectangle 4) on the xaxis. Hence, it can be concluded that the CUSUM filter performs best for a steady state process with no change to the steady state base value, while the selftuning filter performs best for a process that involves an 60 oscillatory change to the steady state process. This is because the selftuning filter is not dominated on the yaxis by any of the other filters, but it dominates the firstorder and Kalman on the xaxis. Thus the choice of the selftuning filter. 4.2 EASE OF UNDERSTANDING THE FILTERS Based on the human ease of understanding, the four filters are grouped into four levels. With level 1 having the relatively easiest understanding and level 100 being the relatively most complex. 61 Table 8. Ease of understanding the filters Filter Relative rank based on ease of understanding First order Filter (FOF) 1. Selftuning filter (STF) 4 . CUSUM 5. Kalman filter 100. FOF is assigned a rank of 1 for ease of understanding because it involved relatively simple mathematics of multiplication, addition and subtraction. STF is assigned a rank of 4 because it involves relatively higher computations of exponential, conditional statement and more variables with assigned values. CUSUM filter is assigned a rank of 5 because it involves relatively higher computations than the FOF and STF with even more variables, conditional statements and calculations. Kalman filter is assigned a rank of 100 because it involves the relatively most complex calculations of the four filters. It involves the use of matrices and matrix operations for the time update and measurement update operations. 4.3 Cost The results for analysis based on arithmetic operations are as given below. The first column shows the number of arithmetic operations (such as “*”, “+”, “”, “^” etc) involved in the filter equation. The second column shows the actual equation. The third column shows the number of “Get” operations required to read a certain input. And, the 62 final column shows the number of “put” operations required to assign a value to a certain variable. 4.3.1 Ranking of filters based on cost analysis derived from the total operations required in the filter equation. Table 9 Evaluation of operations required in CUSUM filter Equation Number Equation Evaluated 1 2 3 Equation Arithmetic Operation Get(Read) Put 1 n=n+1 1 1 1 2 V=ff1*v+ff2*(xxxxold)^ 2 5 5 1 3 CUSUM=CUSUM+xxxxspc 2 3 1 4 xmeas=xxspc 1 1 5 (xx=xmeas) 1 1 6 (xxold=xx) 1 1 Sum 8 12 6 Total 26 Table 10 Evaluation of operations required in firstorder filter Equation Number Equation Evaluation 1 (Arithmetic operation) Evaluation 2 Get (Read) Evaluation3 Put 1 xmeasff=ff*(xmeas)+(1 ff)*(xmeasff) 4 4 1 Total 9 xmeas is the signal measured value xmeasff is the filtered value 63 Table 11 Evaluation of operations required in selftuning filter Equation Number Equation Evaluated 1 2 3 (Arithmetic operation) Get (Read) Put 1 Ef=2*sigmad 1 1 1 2 deltaf=0.9*deltaf+0.1*(xmeasxmeasold)^ 2 5 3 1 3 lambda= (0.5+1.1668*deltaf/Ef^2)^1 4 2 1 4 (xmeasold=xmeas) 1 1 5 (xmeasf=lambda*xmeas+(1 lambda))*xmeasf 4 4 1 Sum 14 11 5 Total 30 sigmad is the standard deviation of the measurement xmeasf is the filtered value 64 Table 12 Evaluation of operations required in Kalman filter Equation Number Equation Evaluated Arithmetic operation Get(Read) Put 1 xhatminus(i)=xhat(i1) 1 2 1 2 Pminus(i)=P(i1)+Q 2 3 1 3 xhat(i)=xhatminus(i)+k(i)*(xmeasxhatminus( i) 3 4 1 4* k(i)=Pminus(i)/(Pminus(i)+R) 3 3 1 5 P(i)=(1k(i))*Pminus(i) 2 3 1 6 xmeaskf=xhat(i) 2 1 7 R=(value) 1 1 8 Q=(Value) 1 1 Sum 11 15 8 Total 34 In equation 4* the inversion operation would require several steps of arithmetic operation when it involves matrices. (This shows that the Kalman filter will involve much more operations than indicated above) xmeaskf is the kalman filtered value xmeas is the signal measurement value Given the results above the filters are ranked on a scale of one to four, with one being the cheapest to operate and four being the most expensive. 65 Table 13. Ranking of filter in increasing order of relative cost. Filter Relative Rank (based on total number of operations) Total number of operations FOF 1 9 CUSUM 3 26 STF 3 30 Kalman 4 34 From the above scale, the firstorder filter is the cheapest to operate in terms of arithmetic operations, while the Kalman filter is the most expensive in terms of arithmetical operations. 3.2. Ranking of filters based on cost analysis derived from the Number of Variables used in Filter Equation. Based on the number of variables required in the filter equation, the four filters are ranked as shown below, with a rank of 1 requiring the least number of variables and 4 requiring the most number of variables: 66 Table 14 Ranking of filter based on the required number of memory location/required variables Filter Rank based on required number of variables Number of memory location (or variables required) FOF 1 3 STF 2 7 Kalman 3 10 CUSUM 4 12 From the result above, The Firstorder filter requires the least number of variables and thus is the least expensive in terms of the required number of variables while the CUSUM filter requires the most number of variables and is thus the most expensive in terms of the required number of variables. 67 CHAPTER V CONCLUSION AND RECOMMENDATION The CUSUM filter is the best filter to use in a steady state process involving no change. In a process that involves a step change, the Kalman filter is the best filter to use. A process that involves a ramp change is best filtered using the Kalman filter. And, an oscillatory process is best filtered using the selftuning filter. Firstorder filter is the easiest to understand, while the Kalman filter is the most complex to understand. The firstorder filter is the cheapest to operate in terms of arithmetic operations, while the Kalman filter is the most expensive in terms of arithmetical operations. The firstorder filter is the least expensive considering required number of variables, while the CUSUM filter requires the most number of variables and is thus the most expensive in terms of the required number of variables. It is recommended that further analysis involving different signal to noise ratio should be carried out. Also, the filter speed of tracking the signal be analyzed in subsequent studies. 68 REFERENCES 1. Cao, S. and Rhinehart, R. R. (1997). "A SelfTuning Filter." Journal of Process Control 7(Number 2): 139148. 2. Douglas, C. M. (1993). Process/Industrial Instruments and Controls Handbook. N Y, McGrawHill. 3. Harris, T. J. and Ross, W. J. (1991). "Statistical Process Control Procedures for Correlated Observations." Canadian Journal of Chemical Engineering 69(1): 4857. 4. Koenig, D. M. (2009). Practical Control Engineering: A Guide for Engineers, Managers, and Practitioners. New York, McGrawHill. 5. Maybeck, P. M. (1979). Stochastic Models, Estimation and Control. New York, Academic Press. 6. Muthiah, N. and Rhinehart, R. R. (2009). "Evaluation of a Statistically Based Controller Override on a PilotScale Flow Loop." ISA Transactions: 31. 7. Welch, G and Bishop, G. (2001). An Introduction to the Kalman Filter. NC, ACM Inc. 8. Vu, Ky M. (2007). The ARIMA and VARIMA Time series: Their Modelings, Analyses and Applications. Ottawa ON, Library and Archives Canada Cataloguing in Publication. 9. Zu, X., Fredendall, L. D. and Douglas, T. J. (2008). "The Evolving Theory of Quality Management:The role of Six Sigma." Journal of Operations Management 26: 630–650. 69 APPPENDIX A VBA codes used in the simulation of steady state signal with the addition of a step change 'VBA codes written with help from Dr. R.R. Rhinehart 'Department of Chemical Engineering, Oklahoma State University 'Daniel Fakunle 'MSC Research Project '101309 'A sub program to generate noisy signal and filter the noise using a 'cusum filter,first order filter and Kalman filter Dim t As Single Dim sigmad As Single Dim dt As Single Dim i As Single Dim sp As Single Dim xmeas As Single Dim ff As Single Dim kc As Single Dim taud As Single Dim n As Single Dim xx As Single Dim xxold As Single Dim xxspc As Single Dim v As Single Dim cusum As Single Dim m As Single Dim ff1 As Single Dim ff2 As Single Dim Trigger As Single Dim xhatminus(1000) Dim Ef As Single Dim xhat(1000) Dim Pminus(1000) Dim P(1000) Dim k(1000) Dim xkp As Single 70 Dim pkp As Single Dim xold As Single Dim pkold As Single Dim Q As Single Dim R As Single Dim kk As Single Dim xk As Single Dim pk As Single Dim xmeaskf As Variant 'Kalman filtered value Dim deltaf As Single Dim lambda As Single Dim xmeasold As Single Dim xmeassf As Single 'Self tuning filtered value Dim xmeasff As Single 'First order filtered value Dim xmeasc As Single 'cusum fltered value Sub signal() Application.ScreenUpdating = False 'Inital values of constants ff = Sheet3.Cells(7, 24) dt = Sheet3.Cells(3, 24) Trigger = Sheet3.Cells(8, 24) kp = Sheet3.Cells(11, 24) Ef = Sheet3.Cells(10, 24) 'kalman filter constants xhat(0) = 1 Pminus(0) = 1 Randomize 'Main Program For i = 1 To 1000 'For loop t = dt * i x = 3 If i > 500 Then x = 10 Call Process(x, xmeas) 'Call filter Call ffilter(xmeas, xmeasff) Call cusumf(xmeas, xmeasc) Call kalman(xmeas, xmeaskf) Call selftuningfilter(xmeas, xmeassf) 'Print out observable results 71 'Application.ScreenUpdating = False Sheet3.Cells(2 + i, 1).Value = t Sheet3.Cells(2 + i, 3).Value = xmeas Sheet3.Cells(i + 2, 4).Value = xmeassf 'STF Sheet3.Cells(i + 2, 5).Value = xmeasc 'Cusum Sheet3.Cells(i + 2, 16).Value = xmeaskf 'Kalmnan Sheet3.Cells(i + 2, 17).Value = xhat(i) Sheet3.Cells(i + 2, 18).Value = Pminus(i) Sheet3.Cells(i + 2, 19) = k Sheet3.Cells(i + 2, 20) = xhatminus(i) Sheet3.Cells(i + 2, 21) = P(i) Sheet3.Cells(i + 2, 22) = xmeasff 'FOF filter 'Sheet3.Cells(i + 2, 44) = Ef 'FOFilter Next i 'Call signal2 Application.ScreenUpdating = True End Sub 'FIRST ORDER FILTER Sub ffilter(xmeas, xmeasff) xmeasff = ff * (xmeas) + (1  ff) * (xmeasff) End Sub 'CUSUM FILTER Sub cusumf(xmeas, xmeasc) If i = 1 Then n = 0 xx = 0 xxold = 0 xxspc = 0 v = 0 cusum = 0 m = 11 ff1 = ((m  2) / (m  1)) ff2 = (1  ff1) / 2 End If xx = xmeas n = n + 1 v = ff1 * v + ff2 * (xx  xxold) ^ 2 xxold = xx cusum = cusum + xx  xxspc If (Abs(cusum) > Trigger * Sqr(v * n)) Then xxspc = xxspc + cusum / n 72 cusum = 0 n = 0 End If xmeasc = xxspc End Sub Sub kalman(xmeas, xmeaskf) 'KALMAN FILTER R = Sheet3.Cells(9, 24).Value Q = Sheet3.Cells(4, 24).Value 'Time Update xhatminus(i) = xhat(i  1) Pminus(i) = P(i  1) + Q 'Measurement Update k(i) = Pminus(i) / (Pminus(i) + R) xhat(i) = xhatminus(i) + k(i) * (xmeas  xhatminus(i)) P(i) = (1  k(i)) * Pminus(i) xmeaskf = xhat(i) 'xold = xk End Sub Sub Process(x, xmeas) taun = Sheet3.Cells(5, 24) If taun = 0 Then taun = 0.0001 sigmad = Sheet3.Cells(6, 24) alpha1 = Exp(dt / taun) beta0 = 1  alpha1 sigmaw = sigmad * Sqr((1 + alpha1) / beta0) xnoise = sigmaw * Sqr(2 * Log(Rnd)) * Sin(2 * 3.14159 * Rnd) 'Gaussian distributed noise sp = x xmeas = x + xnoise End Sub Sub selftuningfilter(xmeas, xmeassf) deltaf = 0.9 * deltaf + 0.1 * (xmeas  xmeasold) ^ 2 lambda = 1 / (0.5 + 1.1668 * deltaf / Ef ^ 2) If lambda > 1 Then lambda = 1 xmeasold = xmeas xmeassf = lambda * xmeas + (1  lambda) * xmeassf End Sub 73 APPPENDIX B VBA codes used in the simulation of steady state signal with the addition of a ramp change 'VBA codes written with help from Dr. R.R. Rhinehart 'Department of Chemical Engineering, Oklahoma state university 'Daniel Fakunle 'MSC Research Project '101309 'A sub program to generate noisy signal and filter the noise using a 'cusum filter,first order filter and Kalman filter Sub signalramp() Application.ScreenUpdating = False 'Inital values of constants ff = Sheet4.Cells(7, 24) dt = Sheet4.Cells(3, 24) Trigger = Sheet4.Cells(8, 24) Ef = Sheet4.Cells(10, 24) 'kalman filter constants xhat(0) = xmeas Pminus(0) = 1 Randomize dt = 0.1 'Main Program For i = 1 To 1000 'For loop t = dt * i x = 3 + (t  50) If i > 500 Then x = 3 + (t  50) Call Process(x, xmeas) 'Call filter Call ffilter(xmeas, xmeasff) Call cusumf(xmeas, xmeasc) Call kalman(xmeas, xmeaskf) Call selftuningfilter(xmeas, xmeassf) 'Print out observable results 74 Application.ScreenUpdating = False Sheet4.Cells(2 + i, 1).Value = t Sheet4.Cells(2 + i, 2).Value = x Sheet4.Cells(2 + i, 3).Value = xmeas Sheet4.Cells(i + 2, 4).Value = xmeassf 'STF Sheet4.Cells(i + 2, 5).Value = xmeasc 'Cusum Sheet4.Cells(i + 2, 16).Value = xmeaskf 'Kalmnan Sheet4.Cells(i + 2, 22) = xmeasff 'FOFilter Next i Application.ScreenUpdating = True End Sub 'FIRST ORDER FILTER Sub ffilter(xmeas, xmeasff) xmeasff = ff * (xmeas) + (1  ff) * (xmeasff) End Sub 'CUSUM FILTER Sub cusumf(xmeas, xmeasc) If i = 1 Then n = 0 xx = 0 xxold = 0 xxspc = 0 v = 0 cusum = 0 m = 11 ff1 = ((m  2) / (m  1)) ff2 = (1  ff1) / 2 End If xx = xmeas n = n + 1 v = ff1 * v + ff2 * (xx  xxold) ^ 2 xxold = xx cusum = cusum + xx  xxspc If (Abs(cusum) > Trigger * Sqr(v * n)) Then xxspc = xxspc + cusum / n cusum = 0 n = 0 End If xmeasc = xxspc End Sub 75 Sub kalman(xmeas, xmeaskf) 'KALMAN FILTER R = Sheet4.Cells(9, 24).Value Q = Sheet4.Cells(4, 24).Value 'Time Update xhatminus(i) = xhat(i  1) Pminus(i) = P(i  1) + Q 'Measurement Update k(i) = Pminus(i) / (Pminus(i) + R) xhat(i) = xhatminus(i) + k(i) * (xmeas  xhatminus(i)) P(i) = (1  k(i)) * Pminus(i) xmeaskf = xhat(i) End Sub Sub Process(x, xmeas) taun = Sheet4.Cells(5, 24) If taun = 0 Then taun = 0.0001 sigmad = Sheet4.Cells(6, 24) alpha1 = Exp(dt / taun) beta0 = 1  alpha1 sigmaw = sigmad * Sqr((1 + alpha1) / beta0) xnoise = sigmaw * Sqr(2 * Log(Rnd)) * Sin(2 * 3.14159 * Rnd) 'Gaussian distributed noise xmeas = x + xnoise End Sub Sub selftuningfilter(xmeas, xmeassf) deltaf = 0.9 * deltaf + 0.1 * (xmeas  xmeasold) ^ 2 lambda = 1 / (0.5 + 1.1668 * deltaf / Ef ^ 2) If lambda > 1 Then lambda = 1 xmeasold = xmeas xmeassf = lambda * xmeas + (1  lambda) * xmeassf End Sub 76 APPPENDIX C VBA codes used in the simulation of steady state signal with the addition of an oscillatory change 'VBA codes written with help from Dr. R.R. Rhinehart 'Department of Chemical Engineering, Oklahoma state university 'Daniel Fakunle 'MSC Research Project '101309 'A sub program to generate noisy signal and filter the noise using a 'cusum filter,first order filter and Kalman filter Sub signaloscillatory() Application.ScreenUpdating = False 'Inital values of constants ff = Sheet5.Cells(7, 24) dt = Sheet5.Cells(3, 24) Trigger = Sheet5.Cells(8, 24) Ef = Sheet5.Cells(10, 24) 'kalman filter constants xhat(0) = xmeas Pminus(0) = 1 Randomize dt = 0.1 'Main Program For i = 1 To 1000 'For loop t = dt * i x = 3 If i > 500 Then x = 3 + 0.729535369032456 * Sin(Application.WorksheetFunction.Radians(50 * Application.WorksheetFunction.Pi() * (t  50) / 20)) Call Process4(x, xmeas) 'Call filter Call ffilter4(xmeas, xmeasff) Call cusumf4(xmeas, xmeasc) Call kalman4(xmeas, xmeaskf) 77 Call selftuningfilter4(xmeas, xmeassf) 'Print out observable results Application.ScreenUpdating = False Sheet5.Cells(2 + i, 1).Value = t Sheet5.Cells(2 + i, 2).Value = x Sheet5.Cells(2 + i, 3).Value = xmeas Sheet5.Cells(i + 2, 4).Value = xmeassf 'STF Sheet5.Cells(i + 2, 5).Value = xmeasc 'Cusum Sheet5.Cells(i + 2, 16).Value = xmeaskf 'Kalmnan Sheet5.Cells(i + 2, 22) = xmeasff 'FOFilter Next i Application.ScreenUpdating = True End Sub 'FIRST ORDER FILTER Sub ffilter4(xmeas, xmeasff) xmeasff = ff * (xmeas) + (1  ff) * (xmeasff) End Sub 'CUSUM FILTER Sub cusumf4(xmeas, xmeasc) If i = 1 Then n = 0 xx = 0 xxold = 0 xxspc = 0 v = 0 cusum = 0 m = 11 ff1 = ((m  2) / (m  1)) ff2 = (1  ff1) / 2 End If xx = xmeas n = n + 1 v = ff1 * v + ff2 * (xx  xxold) ^ 2 xxold = xx cusum = cusum + xx  xxspc If (Abs(cusum) > Trigger * Sqr(v * n)) Then xxspc = xxspc + cusum / n cusum = 0 n = 0 End If xmeasc = xxspc 78 End Sub Sub kalman4(xmeas, xmeaskf) 'KALMAN FILTER R = Sheet5.Cells(9, 24).Value Q = Sheet5.Cells(4, 24).Value 'Time Update xhatminus(i) = xhat(i  1) Pminus(i) = P(i  1) + Q 'Measurement Update k(i) = Pminus(i) / (Pminus(i) + R) xhat(i) = xhatminus(i) + k(i) * (xmeas  xhatminus(i)) P(i) = (1  k(i)) * Pminus(i) xmeaskf = xhat(i) End Sub Sub Process4(x, xmeas) taun = Sheet5.Cells(5, 24) If taun = 0 Then taun = 0.0001 sigmad = Sheet5.Cells(6, 24) alpha1 = Exp(dt / taun) beta0 = 1  alpha1 sigmaw = sigmad * Sqr((1 + alpha1) / beta0) xnoise = sigmaw * Sqr(2 * Log(Rnd)) * Sin(2 * 3.14159 * Rnd) 'Gaussian distributed noise sp = x xmeas = x + xnoise End Sub Sub selftuningfilter4(xmeas, xmeassf) deltaf = 0.9 * deltaf + 0.1 * (xmeas  xmeasold) ^ 2 lambda = 1 / (0.5 + 1.1668 * deltaf / Ef ^ 2) If lambda > 1 Then lambda = 1 xmeasold = xmeas xmeassf = lambda * xmeas + (1  lambda) * xmeassf End Sub 79 VITA DANIEL FAKUNLE Candidate for the Degree of Master of Science Thesis: COMPARISON OF THE CUSUM, FIRST ORDER, SELFTUNING AND KALMAN FILTERS Major Field: Chemical engineering Biographical: Personal Data: Education: Completed the requirements for the Master of Science in Chemical Engineering at Oklahoma State University, Stillwater, Oklahoma in May, 2010. Completed the requirements for the Master of Science in Petroleum Engineering at University of Houston, Houston, Texas in December, 2008. Completed the requirements for the Bachelor of Science/Arts in your major at Obafemi Awolowo University, IleIfe in 2005. ADVISER’S APPROVAL: Dr. R. R. Rhinehart Name: Daniel Fakunle Date of Degree: May, 2010 Institution: Oklahoma State University Location: Stillwater, Oklahoma Title of Study: COMPARISON OF THE CUSUM, FIRSTORDER, SELFTUNING AND KALMAN FILTERS Pages in Study: 79 Candidate for the Degree of Master of Science Major Field: Chemical Engineering Scope and Method of Study: This work involved the comparison of the CUSUM filter, the firstorder filter, the selftuning filter and the Kalman filter. The filters were compared on the basis of the minimization of the integral sum of errors (ISE), the relative cost and the relative ease of understanding. The ISE was compared for processes involving a step change, a ramp change and an oscillatory process change. These three processes were simulated using Visual Basic for Applications (VBA). The four filters were also compared based on the relative ease of human understanding based on the complexity of equations. The relative cost of the filters was based on the number of operations and the required number of storage variables. Findings and Conclusions: The CUSUM filter is the best filter to use in a steady state process involving no change. In a process that involves a step change, the Kalman filter is the best filter to use. A process that involves a ramp change is best filtered using the Kalman filter. And, an oscillatory process is best filtered using the selftuning filter. Firstorder filter is the easiest to understand, while the Kalman filter is the most complex to understand. The firstorder filter is the cheapest to operate in terms of arithmetic operations, while the Kalman filter is the most expensive in terms of arithmetical operations. The firstorder filter is the least expensive considering required number of variables, while the CUSUM filter requires the most number of variables and is thus the most expensive in terms of the required number of variables. 



A 

B 

C 

D 

E 

F 

I 

J 

K 

L 

O 

P 

R 

S 

T 

U 

V 

W 


