Greg Stanley and Associates
 Home   About Us   Products   Services   Success Stories   Tech Resources   Contact Us 
HomeTech ResourcesFault DiagnosisFiltering > Derivative Estimate >

Derivative (Rate of Change) Estimation

Filtering topics:

 

This page describes the filtering needed to estimate derivatives (rate of change of variables over time). This page is part of the section on
Filtering that is part of
A Guide to Fault Detection and Diagnosis.

We sometimes want to estimate a variable’s rate of change

For many applications, the rate of change of a variable is of interest. For instance, in the case of a surge drum level that is high, we might really only consider it a problem if the level is both high and still rising. “Still rising” means that the rate of change of level is greater than zero. In mechanical applications, we may wish to estimate velocity, based on a series of position measurements over time.

We would like a calculation that takes samples of an input x over time, and estimates the rate of change (its time derivative dx/dt) as the output. How would we create a “calculation block” of the same form as the filters we’ve already described, where now y is an estimate of the rate of change?

derivative filter

The noise problem in estimating rate of change

At first glance, estimating rate of change seems simple. You could calculate the difference in the signal x , dividing it by the time difference between the samples. This is the first order approximation to a derivative:

dx/dt = ( x(k) - x(k-1) ) / ( t(k) - t(k-1) )

where
x(k) is the input at sample time k, and
t(k) is the time at sample time k

But the problem is that this is very sensitive to noise. For instance, suppose the input signal is steady or only changing slowly. By subtracting the previous input from the current one, the “true” signal difference is at or close to zero. If there is high frequency noise, all or most of the entire value of the estimate of dx/dt is noise. So, filtering is required.

Least squares filtering for estimating the rate of change, including Savitzky-Golay

You can do a least squares curve fit of the data over time, as described in the page on the least squares filter. At the same time you do the calculations for the current or smoothed value, you also determine the slope of the line (the derivative). 

The same is true in the case of the already-described Savitzky-Golay filter, which is the least square filter solution for the special case of a fixed sample time interval. That is, the current or smoothed derivative estimate is just a weighted linear combination of the recent input values, just like the current or smoothed estimate of the variable itself.

The fixed coefficients for Savitzky-Golay filtering to obtain derivative estimates using between 2 and 13 data points are shown below:

 

least squares derivative filter coefficients for 2-7 data points

 

least squares derivative filter coefficients for 8-13 data points

 

For instance, when using 4 data points, the Savitzky-Golay filter for estimating the derivative is,
y(k) = .3 x(k) + .1 x(k-1) - .1 x(k-2) - .3 x(k-3)

where
x(k) is the newest (current) input
x(k - 1) is the previous input
x(k-2) is the next oldest input
x(k-3) is the oldest input used for the 4-point filter
y(k) is the newest (current) filtered (output) value, estimating the rate of change of input per time step.

The units for the calculations are the rate of change of the input variable per time step. To convert to the time derivative, divide the output by the time step size. In the above example, if the fixed sample time is 2 minutes, the time derivative estimate is half of y(k).

The special case of a 2-point filter is just included for completeness. The least squares fit of a straight line for two points goes through both those points, so the least squares estimate is simply the difference between the values (per time step). 

The sum of all the coefficients is always 0.0 (within rounding error in the tables above), which makes sense because the response to a steady input (or step response) must be zero.

For filter sizes that are an odd number, the data input at the center of the time window is completely ignored in each time step. For the most effective noise reduction for the amount of computation, you might as well use filters with an even number of data point inputs If you want to use a time period that requires more than 13 data points, consider sampling more slowly at the input to this filter, taking care to avoid aliasing by first filtering with an exponential filter at the higher sample rate.

One problem with least squares filtering is that you get overshoot in the current derivative estimate following an input (step) change, just like you get for the current value estimate. (This is not an issue for smoothing at the midpoint of the data time window.) Another problem is that, unless you use a Savitzky-Golay filter, it is computationally intensive compared to most filters. Despite these problems, this is a common approach to estimating derivatives.

The “MACD approach” to estimating rate of change

There is another approach to estimating rate of change, described on the next page in this series.

Copyright 2010 - 2013, Greg Stanley

Return to Filtering   Next: The “MACD approach” to estimating rate of change

Return to A Guide to Fault Detection and Diagnosis

 

Share this page: Share this page via LinkedIn... Bookmark or share this page on Delicious... Share this page by e-mailing link...    

 Home   About Us   Products   Services   Success Stories   Tech Resources   Contact Us 
Enter keywords to search this site:
Now operated by Performity LLC