1
$\begingroup$

As I understand aliasing is because you sample a high frequency with a low sample rate, and the sample points don't have enough information about the high frequency component. Here is an example of aliasing:

w = 5.0;(*signal frequency*) 
dt = 0.66125;(*sampling rate*)
f[x_] := Sin[w x]
ls = Table[f[x], {x, dt, 200 dt, dt}];(*sample points*)

ListPlot[ls, PlotRange -> All, Joined -> True, 
 DataRange -> {dt, 200 dt}]

enter image description here

we can see in the plot that there is beating. And the Fourier transform gives only one frequency(except the symmetric negative frequency one).

DFT[A_, ht_] := 
 RotateRight[
  ht/Sqrt[2 \[Pi]]*
   Fourier[RotateLeft[A, Length[A]/2 - 1], 
    FourierParameters -> {1, 1}], Length[A]/2 - 1]

ListPlot[Abs[DFT[ls, dt]]^2, PlotRange -> All, Joined -> True, 
 DataRange -> {-1/dt/2, 1/dt/2}, Axes -> False, Frame -> True]

enter image description here

question:

  1. Why there is the beating but only one peak in the Fourier transform? Since there is only one frequency in the sample, what is it beating against?
  2. How to calculate the beating frequency and the aliasing frequency?

Update 1

As chirlu points out there is not beating, if it is the beating because of adjacent frequencies, we would expect to see two separated peaks if we increase the Fourier transform resolution. Here I increase the frequency resolution by including more sample points, and we can see it is a single peak, not adjacent peaks.

ls = Table[f[x], {x, dt, 800 dt, dt}];(*sample points*)ListPlot[ls, 
 PlotRange -> All, Joined -> True, DataRange -> {dt, 200 dt}]

enter image description here

enter image description here


Update 2

Here is an example using sound:

Play[Sin[3000 t], {t, 0, 2}, SampleRate -> 6000]

enter image description here

Play[Sin[3000 t], {t, 0, 2}, SampleRate -> 950]

enter image description here

So use a lower sample rate, we can actually hear the beating!

$\endgroup$
15
  • 1
    $\begingroup$ Your Sampling Frequency appears to be 1.5Hz for a 5Hz Sinusoid. Anyway, with your FFT you can view only frequencies from -0.75Hz to 0.75Hz. Essentially all of your signal energy is falling in the ultimate bin of 0.75Hz. The aliasing frequencies can be computed from the fact that Sampling just repeats the spectrum of original signal(which will have peaks at -5Hz and +5Hz) at every 1.5Hz interval(which is your sampling frequency). Hence your aliased frequencies appear at 3.5Hz and -3.5Hz which is characterized by the last bins of your FFT because you cannot see anything more than + or - 1.5Hz. $\endgroup$
    – Sudarsan
    Aug 21, 2013 at 1:06
  • $\begingroup$ @Sudarsan thanks for the help, I'm sorry I don't quite get you. So we see the beating, where is it from? Maybe that's not correct but by aliasing frequency I mean the frequency peaks in the spectrum in the second plot.So do you know how to get that frequency? $\endgroup$ Aug 21, 2013 at 1:13
  • $\begingroup$ Beating is repetition of frequencies in the Signal that you're sampling. Now your sampling rate is too low. This causes two problems: You cannot view the Beating carefully since your sampling frequency is not even at least equal to the Signal's max Frequency. Now if you had sampled the signal at 8Hz, you'd have seen two peaks at 3Hz and -3Hz respectively, unlike the above plot where all the energy falls in the last bin of the FFT(which is because you've chosen a sampling frequency with which if you take the FFT, you'll view the entire content of the signal in the last bin). $\endgroup$
    – Sudarsan
    Aug 21, 2013 at 1:18
  • $\begingroup$ I'm not sure exactly as to which is the best source to point you to so as to understand the full effect of Sampling, but something like this document should help: eas.uccs.edu/wickert/ece2610/lecture_notes/ece2610_chap4.pdf $\endgroup$
    – Sudarsan
    Aug 21, 2013 at 1:19
  • 1
    $\begingroup$ @xslittlegrass: Your question is very similar to this one from a couple months ago. You aren't observing beating at all. The apparent "beating" when looking at the envelope of your real signal only comes from the fact that you're sampling a sinusoid at near the Nyquist rate and then linearly interpolating them to obtain the curves you showed. $\endgroup$
    – Jason R
    Aug 22, 2013 at 2:35

4 Answers 4

5
$\begingroup$

Let’s look at an example. I’m going to use a sample rate of 50 throughout this post (i.e. the functions are sampled at 0, 0.02, 0.04, 0.06, …) and simple sine waves of the form $f_a(t) = \sin (2\pi\cdot a\cdot t)$, where $a$ is the frequency of the sine wave. For example, this is a plot of $f_3$:

sine wave of frequency 3, sampled and continuous

The red impulses indicate the sample values. The green line, on the other hand, is the continuous function that is being sampled. The sample values all lie on this curve, and it goes through three complete cycles, as one would expect.

Aliasing

Because the sample rate is 50, anything above the Nyquist frequency of 25 is going to alias. As an example, here is a plot of $f_{53}$; mind the axes, I zoomed in to one tenth of the above, because otherwise the image would have become quite crowded.

sine wave of frequency 53, sampled and continuous

There is slightly less than one sample per cycle, so the sampled values don’t follow the continuous waveform very closely. Actually, if all you saw were the sample values without the green curve, like so …

sine wave of frequency 53, sampled

… you might be tempted to draw a much slower wave. Here is what happens when we plot not only $f_{53}$, but $f_3$ at the same time:

sine waves of frequencies 3 and 53, sampled and continuous

While the two sine waves are quite dissimilar in appearance, they happen to coincide at each and every sample point. There is absolutely no way to tell them apart given only the sample values. That’s aliasing. In fact, not only the samples of $f_{53}$ are exactly the same as those of $f_3$, but $f_{103}$, $f_{153}$, $f_{-47}$ etc. alias in the same way.

Put differently, due to sampling at a frequency of 50, the ranges 0–25, 50–75, 100–125, etc. collapse. What about the “upper half”, from the Nyquist frequency to the sampling frequency? It is mirrored; $f_{47}$ is the same as $-f_3$, and in general the frequency range 25–50 aliases to 25–0, with the samples inverted (or, equivalently, a phase shift by $\pi$).

This means, for your question, that the effect you are observing is not due to you using signals that exceed the Nyquist frequency; you can replace any higher-than-Nyquist-frequency signal with its alias in the Nyquist range and will get exactly the same results.

The “beating”

So what causes the apparent “beating”? Here is the very first plot of $f_3$ again, but this time it shows the sample values and linear interpolation between them (i.e. straight line segments from each sample point to the next), not the actual continuous waveform that was sampled:

sine wave of frequency 3, sampled, and linear interpolation of the sample values

The interpolated waveform is a bit edgy, but overall a good approximation of the original sine wave. Unfortunately, this is only because the frequency is very low relative to the sample rate. Here is $f_7$:

sine wave of frequency 7, sampled, and linear interpolation of the sample values

Urgh. It worsens as we get to higher frequencies, closer to the Nyquist frequency; this is $f_{23}$:

sine wave of frequency 23, sampled, and linear interpolation of the sample values

Unfortunately, even if we don’t draw those straight lines, our eye will try to connect the dots all on its own, and the impression is similar: It looks like a slow oscillation modulated onto a fast one. And that impression actually isn’t completely beside the point:

sine wave of frequency 23, sampled, and ring modulation of two sine waves of frequencies 2 and 25, continuous

The same sample values, from $f_{23}$, can equally well explained by a ring modulation of $f_2$ and $f_{25}$ (with some phase adjustment), namely, $g(t) = -f_2(t)\cdot f_{25}(t+0.01)$. Thus, $g$ and $f_{23}$ are aliases, when sampled at a rate of 50. Here is a close-up again, showing that $g$ and $f_{23}$ in fact meet at 0, 0.02, 0.04 etc.:

sine wave of frequency 23, sampled and continuous, and ring modulation as above

A different way to write $g$ is $g(t) = 0.5 f_{23}(t) - 0.5 f_{27}(t)$, a sum of two sine waves of similar frequency, exactly the case where beating could be expected to happen. So it is beating after all, isn’t it? Not really, because $f_{27}$ is beyond the Nyquist frequency; as outlined above, it is an alias of $-f_{50-27}=-f_{23}$, and so $g(t)$ becomes $0.5 f_{23}(t) - 0.5 f_{27}(t) = 0.5 f_{23}(t) + 0.5 f_{23}(t) = f_{23}(t)$.

This is, within the baseband from 0 to 25, the only possible interpretation of those sample values.

Conclusion

Watch out for improper interpolation! When reconstructing a continuous signal from samples, the limited bandwidth must be taken into account (band-limited interpolation). Unfortunately, our eyes are not good at this; and many software waveform editors and resamplers aren’t, either.

$\endgroup$
0
0
$\begingroup$

If there is apparent beating in the time domain, and you zoom into your apparent one peak in the frequency domain, you will find the main lobe or skirt around that peak is slightly fatter than if there is no beating. This is because there is really a second peak (and potentially more peaks) hidden inside and/or under that wider main lobe or it's skirts. It's not always one pure sinusoid frequency causing a peak in a zoomed-out FFT result. And two adjacent frequency sinusoids can cause an amplitude modulation in the envelope of the linear sum (beating).

$\endgroup$
2
  • 4
    $\begingroup$ There is no beating here. It only looks like it because the plot employs linear interpolation between the samples. $\endgroup$
    – chirlu
    Aug 21, 2013 at 7:46
  • $\begingroup$ @hotpaw2 I agree with chirlu that there is only one frequency, and we can't see the second peak even if we increase the frequency resolution. See my updates. $\endgroup$ Aug 21, 2013 at 15:52
0
$\begingroup$

Sudarsun is correct. You aren't seeing the additional frequencies because your sample rate is only 1.5Hz. You are limited due to the periodicity of the fourrier transform to a band of .0.75Hz to 0.75Hz. If you do it on paper you will see that sure enough by repeating the spectrum of the 5Hz sinewave by n*1.5Hz in both the + and - direction you will see exactly what you show in your graphics for a frequency span of -0.75Hz to 0.75Hz. You were mistaken to increase the resolution of the FFT, no need for that that. what you needed to do was increase the sampling rate without changing your original signal. To do that just pack 7 zeros between sample points. This will give you a sampling rate of 1.5*8 = 12Hz. I'll bet you see all the frequencies you think you should see...

$\endgroup$
0
$\begingroup$

If your signal is of frequency $f_0$ and you are sampling at $F_s$, then you can find all aliasing frequencies by $\sin(2\pi(f_0-mF_s)t)$ where $m$ is an integer such that $|f_0 - mF_s|< F_s/2$.

So if $f_0 = 6$ and $F_s = 10$, you have for $m = 1$, an alias at frequency of 4 Hz. However there are other aliases at $m = 2, 3$ etc. with frequencies of 14 Hz, 24 Hz etc.

Charan Langton

www.complextoreal.com You can see my book "Intuitive Guide to Fourier Analysis ...."

$\endgroup$
1
  • $\begingroup$ Please use math markup in your answers; it makes them much easier to read. $\endgroup$
    – MBaz
    Sep 20, 2017 at 18:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.