Sign up ×

The algorithm to implement a low-pass filter is stated as follows (sourced from Wikipedia):

for i from 1 to n


α = T/(tau + T)

T, is the period, in other words, the time interval in which data is received. And, tau, is the time constant, defined as:

tau = RC.

OK it's all clear. Everyone seem to come up with different values for, α, but it beats me - how can one reach a logical decision for this value?

Surely, the values of, R, and, C, are not available to use - or is it?

Does anybody know how to determine the value of, tau, and thus the value of, α?

Thanks one and all!

share|improve this question
Alpha will determine the cutoff frequency of the filter and thus which frequencies get through. You'll need to determine what you want for your particular application and then you should be able to find examples of plugging the frequency into a function for alpha. – Jason Nov 6 '12 at 2:28
The scenario is in Android application development. For example implementing a compass. How does one determine that values of the variables 'R' and 'C'? – Igwe Kalu Nov 6 '12 at 9:25
As @user1801819 said, you need T and fc. T is from int getMinDelay() converted to Hz and fc is going to be something you tweak depending on your application, and will also be Hz. I'm sure you've seen sensor overview, it has information on working with sensor data. – Jason Nov 6 '12 at 22:21
It's clear to me what T is because I set it by myself. Sorry, @Jason, user1801819 is wrong. You can't just assume that the inverse of a time constant is equivalent to the cut-off frequency; I do know something about signals and systems. If I wanted to tweak, then I wouldn't be here asking questions. I brought this issue up because I wanted to get a clearer definition to help understand how to put those parameters into good use. Also I care to know if there are some accepted standards out there - I have noticed that many people set tau = 0.2. I would like to know why they do so. – Igwe Kalu Nov 10 '12 at 21:16

4 Answers 4

T: sampling period.

tau: time constant.

fc: cutoff frecuency of the filter. fc = 1 / tau


alpha = T / ( T + 1/fc )

best regards!

share|improve this answer
I know what each variable stands for. The issue is this, how do you determine fc? For example when implementing a compass in Android, who do you determine fc? – Igwe Kalu Nov 6 '12 at 9:20
Thanks all the same @user1801819. But I'm afraid, your comment doesn't answer my question at all. – Igwe Kalu Nov 10 '12 at 21:17

I had the same problem with the calculation of the smoothing parameter (ALPHA) of the compass sensor data using low pass filter.

I have figured out and the calculated ALPHA value works good for my application.

For more understanding and discussion refer the following post

How to calculate the value of the smoothing parameter for lowpass filter (in case of smoothing of compass sensor data)

share|improve this answer

For a different lowpass filter, you may want to consider the RBJ biquad:

The implementation of which is described in detail here:

share|improve this answer

From wikipedia's RC time constant entry: Cutoff frequency - The time constant is related to the cutoff frequency fc, an alternative parameter of the RC circuit

tau = 1 / (2π * f)

Why 2π? From wikipedia's time constant entry

ω = 2π * f is the frequency in radians per second.

From the same entry, Tau is the equivalent of RC and is the rise time of the system. A low rise time means that higher frequency input will not excite the system. It is easy to image then that it is connected to the low pass filter's cutoff frequency. Ultimately it controls how much of the feedback signal is mixed in with the new input signal.

In my 2nd order low pass filter, I use the following for alpha.

α = 1 / (T * tau)

In my audio application the 2nd order filter is two single order filters chained, and I calculate the filter output like this. filter1Out and filter2out are the current values of the filters and this is the update after receiving input.

filter1Out = filter1Out + (alpha * (input - filter1Out));
filter2Out = filter2Out + (alpha * (filter1Out - filter2Out));

To determine what you want your cutoff frequency to be with the Android compass, I would at first not implement any filtering and try to use the data as provided. The cutoff really depends on what you are doing with the signal. Are you smoothing it for on screen animations? Are you smoothing it for path tracking? Is there noise in the signal that you want to reject? Each could need a different setting. If the unfiltered signal changes too often then figure out how often you want it to change and use that as your starting point for the filter cutoff.

I hope this helps. The derivation of the DSP math is beyond my skills, but I've implemented low pass filters for audio applications a few times.

share|improve this answer
Cheers for the effort @Jason. Your input is tentatively acceptable. But instead of arriving too quickly on an easy conclusion, I'll do a little more thinking... As it is I'll leave this question open, hopefully some other person can offer an interesting argument as yours. – Igwe Kalu Nov 12 '12 at 20:28
Maybe you'll have more luck migrating the question to signal processing, or by adding more descriptions for what you are trying to do and the code you refer to with a 0.2 tau value. – Jason Nov 12 '12 at 21:37

Your Answer


