I found some snippets of code on the internet that are really simple signal filters. Unfortunately there wasn't much info to back it up. Using Google I've found similar code, but none of it backed up by research or documentation. I've tried it and it works well enough for my situation.
The low pass filter looks like this:
float RC = 1.0/(CUTOFF*2*3.14);
float dt = 1.0/SAMPLE_RATE;
float alpha = dt/(RC+dt);
float out[numSamples];
out[0] = in[0];
for(i=1; i out[i] = out[i-1] + (alpha*(in[i] - out[i-1]));
}
And the high pass filter looks like this:
float RC = 1.0/(CUTOFF*2*3.14);
float dt = 1.0/SAMPLE_RATE;
float alpha = RC/(RC + dt);
float out[numSamples];
out[0] = in[0];
for (i = 1; i out[i] = alpha * (out[i-1] + in[i] - in[i-1]);
}
I'd like to know if there is a name for these algorithms or who invented them so I can find more information about them.
Answer
In addition to @MarcusMüller answer, you can find other names and historical details on this type of filter in Is there a technical term for this simple method of smoothing out a signal?.
I will not rewrite the other answer, just give here a few aspects:
This filter is so useful and common that its has several names, for instance first order exponential averaging low-pass filter, exponentially weighted moving average (EWMA). History also knows it as Brown's Simple (linear) Exponential Smoothing (sometimes called SES). The above link provides mentions of this filter in 1956, and possibly dating back to 1944.
No comments:
Post a Comment