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.
-
5It'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 – DKNguyen Jul 08 '22 at 00:51
-
What exactly do you mean by "there are features at high frequencies". High frequencies relative to what? Your sampling frequency? – SteveSh Jul 08 '22 at 01:34
2 Answers
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.

- 44,867
- 1
- 41
- 104
-
Thanks. Could you please elaborate on what you mentioned in the first paragraph? – user2561523 Jul 08 '22 at 00:01
-
OK, I did -- but that first paragraph was basically the _definition_ of aliasing; if you don't understand that you may want to review how sampling works. – TimWescott Jul 08 '22 at 00:06
-
3@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. – DKNguyen Jul 08 '22 at 00:54
-
2@DKNguyen Lovely illustration of aliasing or modulo arithmetic, I might use it myself some time. – Neil_UK Jul 08 '22 at 08:59
-
1@DKNguyen Wow. You could illustrate that by folding up a strip of paper -- that would be a nice demonstration for tactile learners. – TimWescott Jul 08 '22 at 15:17
-
1@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. – DKNguyen Jul 08 '22 at 15:21
-
2@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. – TimWescott Jul 09 '22 at 16:25
-
@TimWescott Oh was I? I'll have to review then. So you're saying that if the valid spectrum bandwidth after sampling was 100Hz, then a frequency component that was 101Hz would alias to appear as 99Hz? Not 1Hz? I don't even know what happens to the phase. I had never even considered it before until your comment. – DKNguyen Jul 09 '22 at 16:30
-
This needs a thread somewhere. If _Nyquist_ is 100Hz (i.e., if you sample at 200Hz), then that 101Hz frequency component shows up at 99Hz. I _think_ that's what you mean by "valid spectrum after sampling is 100Hz". – TimWescott Jul 09 '22 at 23:12
-
But doesn't the Nyquist frequency not apply since, as I mentioned in my post, the signal isn't bandlimited? – user2561523 Jul 10 '22 at 01:54
-
The Nyquist frequency is a property of what _sampling does to your signal_, not about your signal itself. Sampling _will_ alias signal components around the Nyquist frequency -- the point of anti-aliasing filters is to make sure there's no signal components to alias. – TimWescott Jul 10 '22 at 15:09
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.
-
1"*refer to the "Nyquist frequency" as being the actual sampling frequency itself.*" Oh god. That happens? – DKNguyen Jul 08 '22 at 02: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. – Jul 08 '22 at 02: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. – Jul 08 '22 at 02:54
-
1That is my understanding too except for Nyquist rate which I never use. – DKNguyen Jul 08 '22 at 03: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? – user2561523 Jul 10 '22 at 02:56
-
It's actually not necessary for the sampling rate to be twice the highest frequency that's present in the input, but merely that it be twice the difference between the highest and lowest frequencies that are present in the input. There are many cases where the lowest frequency that's present will be so much lower than the highest that it may as well be zero, but there are others where it may be useful to pass an input through a band-pass filter before sampling. – supercat Jul 10 '22 at 13:34