Search code examples
c++filteringsensors

What type of filter is this?


output = (((previous * rate) + current) / (rate + 1.0))

I believe it's a low pass, but correct me if I'm wrong. Is there a more accurate way to describe a function like this?


Solution

  • This is a low pass filter, with an Infinite Impulse Response design. The rate is used to determine how much a single new value can change the output. A large rate puts more value on the previous state, and less on the current value.

    Consider when rate is 1: output is 1/2 of the previous value plus 1/2 of the current value. In other words, it's the average of the two.

    When rate is larger, output is more heavily weighted to the previous value, so high-frequency variations in subsequent values of current are filtered out, and only slow changes to current affect the output.