[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Butterworth and critically damped filter reference



PureBytes Links

Trading Reference Links

For those of you who are inclined to code and experiment, I have put
up a page that tabulates the calculations steps needed to construct
any of these four kinds of filters:

2-pole Butterworth low pass
2-pole Butterworth high pass
2-pole critically-damped low pass
2-pole critically-damped high pass

The page is at http://unicorn.us.com/trading/buttercrit.html

EL code, written as a single EL function that implements ALL of those
filters, is at http://unicorn.us.com/trading/src/_buttercrit.txt
Be sure to read the comments if you use it.

A unique property of the Butterworth filter is that a single
even-order (2n-pole) Butterworth is identical to a cascade of n
2-pole Butterworths.  So you can construct a high-order filter using
the basic 2-pole filter.  This isn't true for other filter types,
but it works here.

The Butterworth overshoots slightly, but the critically-damped
one doesn't, although the Butterworth has better attenuation in
the stopband.  Any of these filters, however, perform better
than a moving average.  Simply multiply the filter length by pi
to get the same 3 dB cutoff frequency as an exponential moving
average.  That is, xaverage(price,length) has the same cutoff as
butterworth(price,length*pi).

You can combine these in unique ways.  For example, cascading two
critically-damped filters of length L with one Butterworth of length
L/2 (3 passes altogether), will also result in a critically-damped
filter, having less lag but better stopband attenuation than a
3-pass critical-damped filter.  Or you can take the average of the
2-pass critical of length L and the 1-pass Butterworth of length
L/2, and get yet another critically damped filter having about the
same response as a Butterworth.

The highpass critically damped filter is OK for a single pass, but
exhibits ringing in response to a step function when cascading
two or more filters.  The ringing isn't as bad as the Butterworth
though.  The highpass filter can be used bi-directionally (passing
it across your data forward and backward) which would eliminate the
ringing, but we don't have the luxury of doing that in real time,
when we're interested in the most recent value.

Please don't ask for help understanding the calculations or the EL
code.  I have said in the comments all I can say, and the web page
references the articles I got the calculations from, if you are
interested in further reading.  If you have ideas on how to keep the
higher-order highpass filter from ringing, please let me know.

-- 
  ,|___    Alex Matulich -- alex@xxxxxxxxxxxxxx
 // +__>   Director of Research and Development
 //  \ 
 // __)    Unicorn Research Corporation -- http://unicorn.us.com