# How to remove aliasing effects?

I collected data in the time domain and then calculated the FFT to see how it looks in the frequency domain. Since the signal isn't band-limited, I think I have aliasing and there are features at high frequencies that don't make physical sense to me. I'd like to apply an anti-aliasing (low-pass) filter, but how do I know what is artificial due to aliasing and what is physical? Do I need just to apply what I know a priori about the system? Applying a filter with an arbitrary passband doesn't seem like the best idea.

• It's too late for data already recorded but you can anti-alias filter for new recordings. What is the sample rate and input bandwidth of your recording device? Y Jul 8, 2022 at 0:51
• What exactly do you mean by "there are features at high frequencies". High frequencies relative to what? Your sampling frequency? Jul 8, 2022 at 1:34

The whole problem with aliasing is that after sampling, you can't tell the difference between a signal at some frequency $$\f\$$, and some other frequency $$\f + F_s\$$. This is actually the definition of aliasing -- sampling a signal at $$\f + n F_s\$$, for any integer $$\n\$$, will result in a signal in your sampled data at $$\f\$$.

Hence, you need to collect the data with an anti-alias filter in place. The only other thing you could do is exactly what you stated: choose some frequency, and filter out anything above that. That still leaves your data susceptible to aliasing that lands on lower frequencies, but you can't fix that without collecting data again, with an anti-alias filter.

• @user2561523 He's saying any frequency above your Nyquist frequency (half your sampling rate) gets folded back and forth until it fits under your Nyquist frequency. How do you fit a 5m long object into a 30cm long tube? You keep chopping off 30cm segments and throwing them away until whatever you have left fits. 20cm in this case. Jul 8, 2022 at 0:54
• @DKNguyen Lovely illustration of aliasing or modulo arithmetic, I might use it myself some time. Jul 8, 2022 at 8:59
• @DKNguyen Wow. You could illustrate that by folding up a strip of paper -- that would be a nice demonstration for tactile learners. Jul 8, 2022 at 15:17
• @TimWescott I think folding wasn't actually the best term to use here since if you fold a piece of paper just a bit longer than the Nyquist the remainder ends up near the high-end of the Nyquist when it is supposed to end up near the low end. It's more like wraparound I guess. Folding makes more sense for something like current limiting when it is actually folded. Jul 8, 2022 at 15:21
• @DKNguyen nope -- you were right the first time. For the spectrum of a real-valued signal, folding on the $F_s/2$ boundary is almost the same as cutting at the $-F_s/2$ boundary and shifting by $F_s$. The only thing wrong is the phase -- and if you're trying to introduce the subject to a radio hobbyist or a student, that phase is a pretty small detail at that point. Jul 9, 2022 at 16:25

Put your anti-aliasing filter cut-off at the maximum frequency of interest and then theoretically you need to sample at twice that frequency in order to be able to reconstruct the original signal. In practice you'd sample at a bit higher frequency than twice the maximum frequency of interest because your anti-aliasing filter will not be a "brick wall" filter, it will have some slope to its roll-off.

If you don't use an anti-aliasing filter then frequencies above half the sampling rate can be folded over and appear as lower frequencies below half the sample rate.

For example, if the maximum frequency of interest is 20 kHz and you sample at 40 kHz then, if there was no anti-aliasing filter, a 25 kHz signal would appear as 15 kHz, a 22 KHz frequency would appear as 18 kHz and a 35 kHz signal would appear as 5 kHz.

The higher frequencies, in which you have no interest, have been "folded over" the half sample-rate frequency to appear as lower frequencies in the band of interest.

Once the aliased frequencies are in the band of interest there is no way of telling which is an original frequency and which is an aliased frequency.

This can get a little confusing when learning because some references refer to the "Nyquist frequency" as being half the sampling frequency and other references refer to the "Nyquist frequency" as being the actual sampling frequency itself.

• "refer to the "Nyquist frequency" as being the actual sampling frequency itself." Oh god. That happens? Jul 8, 2022 at 2:04
• @DKNguyen There is some confusion out there in the usage of the terms "Nyquist Rate", "Nyquist frequency" and "sample rate". My understanding and usage of these terms is to use "sample rate" or "sample frequency" for the sampling frequency, "Nyquist frequency" for half the sample frequency and "Nyquist rate" for twice the bandwidth of the filter limited signal.
– user173271
Jul 8, 2022 at 2:41
• @DKNguyen ...... so the sample rate is equal to the Nyquist rate when sampling at twice the maximum frequency of interest, and in this case they are both equal to twice the Nyquist frequency.
– user173271
Jul 8, 2022 at 2:54
• That is my understanding too except for Nyquist rate which I never use. Jul 8, 2022 at 3:00
• Thanks, James. I am sampling in the time domain at 10 kHz and the likely spurious frequencies I am seeing are at around 3-5 kHz, which is the high end of the frequency domain after I take the FFT out to 5 kHz. As I understand it, you're saying these can't be due to aliasing?
– user314730
Jul 10, 2022 at 2:56