Exponential Filter
Post on: 16 Март, 2015 No Comment
This page describes exponential filtering, the simplest and most popular filter. This is part of the section
Filtering that is part of
Overview, time constant, and analog equivalent
The simplest filter is the exponential filter. It has only one tuning parameter (other than the sample interval). It requires the storage of only one variable — the previous output. It is an IIR (autoregressive ) filter — the effects of an input change decay exponentially until the limits of displays or computer arithmetic hide it.
In various disciplines, use of this filter is also referred to as exponential smoothing. In some disciplines such as investment analysis, the exponential filter is called an Exponentially Weighted Moving Average (EWMA), or just Exponential Moving Average (EMA). This abuses the traditional ARMA moving average terminology of time series analysis, since there is no input history that is used — just the current input.
It is the discrete time equivalent of the first order lag commonly used in analog modeling of continuous-time control systems. In electrical circuits, an RC filter (filter with one resistor and one capacitor) is a first-order lag. When emphasizing the analogy to analog circuits, the single tuning parameter is the time constant, usually written as the lower case Greek letter Tau (). In fact, the values at the discrete sample times exactly match the equivalent continuous time lag with the same time constant. The relationship between the digital implementation and the time constant is shown in the equations below.
Exponential filter equations and initialization
The exponential filter is a weighted combination of the previous estimate (output) with the newest input data, with the sum of the weights equal to 1 so that the output matches the input at steady state. Following the filter notation already introduced:
y(k) = a * y(k-1) + (1-a) * x(k)
where
x(k) is the raw input at time step k
y(k) is the filtered output at time step k
a is a constant between 0 and 1, normally between 0.8 and 0.99. (a-1) or a is sometimes called the smoothing constant.
For systems with a fixed time step T between samples, the constant a is calculated and stored for convenience only when the application developer specifies a new value of the desired time constant .
a = exp (-T/)
where (tau) is the filter time constant, in the same units of time as T.
For systems with data sampling at irregular intervals, the exponential function above must be used with each time step, where T is the time since the previous sample.
The filter output is usually initialized to match the first input.
As the time constant approaches 0, a goes to zero, so there is no filtering the output equals the new input. As the time constant gets very large, a approaches 1, so that new input is almost ignored very heavy filtering.
The filter equation above can be rearranged into the following predictor-corrector equivalent:
y(k) = y(k-1) + (1-a)*( x(k) — y(k-1) )
This form makes it more apparent that the variable estimate (output of the filter) is predicted as unchanged from the previous estimate y(k-1) plus a correction term based on the unexpected innovation — the difference between the new input x(k) and the prediction y(k-1). This form is also the result of deriving the exponential filter as a simple special case of a Kalman filter. which is the optimal solution to an estimation problem with a particular set of assumptions.
Step response
One way to visualize the operation of the exponential filter is to plot its response over time to a step input. That is, starting with the filter input and output at 0, the input value is suddenly changed to 1. The resulting values are plotted below: