2
$\begingroup$

Having found some unofficial sources on Complementary Filter (Thousand Thoughts Sensor Fusion and The Balance Filter by Shane Colton), I wish to work out its rigorous mathematical proof.

The Complementary Filter, $$y=\alpha \times y+(1-\alpha) \times x$$ where $\alpha$ is the filter parameter, usually chosen to be ~0.98, is named as such, because effectively the filter highpasses $y$ and lowpasses $x$.

With this setup ($\alpha=0.98$), man claims that the filter can filter out the low-frequency part of $y$ and meanwhile the high-frequency part of $x$.

What is the mathematical proof here?

There is no rigorous proof so far available. All the sources simply take it as granted and validates it with experiment data, which is unacceptable in scientific validation.

$\endgroup$
  • 2
    $\begingroup$ The definition of complementary in the original article is sloppy at best: One quote on Kalman filters is "I have no idea how it works. It’s mathematically complex, requiring some knowledge of linear algebra". Before you can proof something you need a crispy definition. Best I can tell is that "complementary" refers to the use of two different types of sensors which are combined in some way and it has little to do with the actual filters $\endgroup$ – Hilmar Sep 4 '13 at 11:34
  • 1
    $\begingroup$ In addition to the good answer below, this type of filter is often called a leaky integrator. Previous questions that talk about it are here, here, and here. $\endgroup$ – Jason R Sep 4 '13 at 14:50
  • $\begingroup$ @Hilmar thanks for the comment! It helps! $\endgroup$ – Sibbs Gambling Sep 11 '13 at 15:26
  • $\begingroup$ @JasonR THank you for the resources pointed out! They really help! :) $\endgroup$ – Sibbs Gambling Sep 11 '13 at 15:27
5
$\begingroup$

This is a first order, low pass infinite impulse response filter (IIR). It is some times called the exponentially weighted moving average. You can find the derivation on Wikipedia. Orfanidis' Introduction to Signal Processing gives a nice description as well.

Picture from Orfanidis, page 573.

Don't think of it as high passing y and low passing x, this will lead to confusion. It is weighting y more heavily than x, the consequence is short time variations of x have a small effect on y, therefore removing higher frequencies.

Also looking at your other questions, it appears that you think that this is a high pass filter as well. This is not the case. α is valid from 0 to 1, so you can see that you will get a lot of low pass filtering (High time constant, limited by your digital precision) or no filtering where y = x ( In the case of x = 0). Read up on high pass filters if you need one, wikipedia gives the difference equation (you have provided the low pass one) for a single order high pass filter.

$\endgroup$
  • $\begingroup$ Thank you very much for the nice answer! It is indeed a LP IIR. I suddenly realized that it was also an implementation of EWMA, which is simply a smoothing technique acting as a LPF. I agree. However, as said, it has no functions of HPF, then how can it remove the DC drift in this case?thousand-thoughts.com/2012/03/android-sensor-fusion-tutorial If it is just a simply EWMA, then the DC drift should remain. I still don't get it why it can remove the low-freq DC drift... $\endgroup$ – Sibbs Gambling Sep 4 '13 at 9:06
  • 1
    $\begingroup$ He hasn't implemented a high pass filter, he is using the second filter to fuse the two data sources, weighted away from the one with the drift (I assume). You can see it is not a filter like his diagram suggests by the fact that its not output = oldOutput * a + input * b. The implementation while might work fine, isn't strictly what is claimed. $\endgroup$ – woollissjp Sep 4 '13 at 9:17
  • $\begingroup$ I myself has also implemented such a so-called complementary filter. ONLY with this filter (i.e., no additional HPF), I can really remove the DC drift in y. How can it be accounted for, if it is not like a HPF? Thanks!:) $\endgroup$ – Sibbs Gambling Sep 11 '13 at 15:31
0
$\begingroup$

That's the result I got when I implemented the filter on MatLab. Notice that the yellow line is the usual implementation, with alpha = 0.95. So, indeed, it doesn`t seem to eliminate the DC drift, although it do filter the high frequency input the bigger the alpha.

implementation of complementary filter

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.