Monday, 30 November 2015

What is the name of this digital low pass filter?


I found this digital filter in code I am working on. It is a low pass filter. In the code it is called an "alpha filter", but it is not the same as the alpha filter mentioned here.


I post the relevant code below:




float alpha = 0.7;
float prev = 0.0;

float filter(float sample) {
float filtered = (sample * alpha) + (prev * (1.0 - alpha));
prev = sample;
return filtered;
}

It looks like alpha should be in range $[0, 1]$. By increasing alpha, the filter tracks the measurement with less delay, but lets more noise through.



I am tasked with writing library functions, and I would like to give this thing its proper name, and hopefully link to a Wikipedia article in the doc tags.



Answer



I'm new, so I can't add this comment to Matt L.'s answer.


It is not an exponential filter, the equation is actually:


$$ y[n] \ = \ \alpha \, x[n] \ + \ ( 1 - \alpha ) \, x[n-1] $$


So it is a very short FIR filter, not an IIR filter. I'm not expert enough to know a specific name.


Ced


============================================= Followup:


I want to thank everyone for their upvotes. Yes, I've contributed to comp.dsp and I am a blogger at dsprelated.com.


Like all of you, I suspect that the intent of the function was to be an exponential filter and was coded erroneously.



If I were to name the filter as coded, I would call it a "Linear Interpolation Filter", or perhaps a "Subsamplesize Time Shift filter" when $\alpha$ is between zero and one. It would make more sense as such if the $\alpha$ and $(1-\alpha)$ coefficients were reversed.


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...