# dealing with aliasing

Started by June 18, 2010
```Hello Forum,

if a continuous-time sinusoid x(t)=cos(2pi*f1*t+theta) is sampled at an
arbitrary rate f_s, we will obtain a sequence x[n].

This sequence will be the same sequence we would obtain from sampling, at
the same rate f_s, an infinite number of other sinusoids of continuous
frequency different from f1.
The spectrum would be a series of delta at locations f =f1 +- k*f_s.

This would happens even if f_s>>2*f1: the ambiguity on which continuous
frequency sinusoid this sequence x[n] belongs to will remain...

Does that mean that we need to make some assumptions, that we need to know
something beforehand, to be able to associate x[n] to cos(2pi*f1*t+theta)?
What are these assumptions?

Aliasing occurs if our interpolating algorithm assumes that f_max=f_s/2,
correct? If f1=5 Hz f_s/2=8 Hz, an ideal passband filter (-f_s/2 to f_s/2)
in the freq. domain will pass f1=5 but also the frequency f=3 Hz, correct?

thanks
fisico32
```
```On 18 Jun, 22:10, "fisico32" <marcoscipioni1@n_o_s_p_a_m.gmail.com>
wrote:
> Hello Forum,
>
> if a continuous-time sinusoid x(t)=cos(2pi*f1*t+theta) is sampled at an
> arbitrary rate f_s, we will obtain a sequence x[n].
>
> This sequence will be the same sequence we would obtain from sampling, at
> the same rate f_s, an infinite number of other sinusoids of continuous
> frequency different from f1.
> The spectrum would be a series of delta at locations f =f1 +- k*f_s.
>
> This would happens even if f_s>>2*f1: the ambiguity on which continuous
> frequency sinusoid this sequence x[n] belongs to will remain...
>
> Does that mean that we need to make some assumptions,

No.

> that we need to know
> something beforehand, to be able to associate x[n] to cos(2pi*f1*t+theta)?

Yes.

> What are these assumptions?

There aren't any.

Rune
```
```On 06/18/2010 01:10 PM, fisico32 wrote:
> Hello Forum,
>
> if a continuous-time sinusoid x(t)=cos(2pi*f1*t+theta) is sampled at an
> arbitrary rate f_s, we will obtain a sequence x[n].
>
> This sequence will be the same sequence we would obtain from sampling, at
> the same rate f_s, an infinite number of other sinusoids of continuous
> frequency different from f1.
> The spectrum would be a series of delta at locations f =f1 +- k*f_s.
>
> This would happens even if f_s>>2*f1: the ambiguity on which continuous
> frequency sinusoid this sequence x[n] belongs to will remain...
>
> Does that mean that we need to make some assumptions, that we need to know
> something beforehand, to be able to associate x[n] to cos(2pi*f1*t+theta)?
> What are these assumptions?

The obvious one: that f1 < f_s/2.  Generally you enforce this with
anti-aliasing filters.

Note that you can also sample to a lower frequency, by sampling a high
frequency bandpass signal and intentionally aliasing it down to DC.
There's a term for it that escapes me at the moment...

> Aliasing occurs if our interpolating algorithm assumes that f_max=f_s/2,
> correct?

Aliasing is a consequence of sampling, depending on how you view things
it either occurs any time you sample, or whenever you sample a signal
with frequency components outside of your assumed range.

> If f1=5 Hz f_s/2=8 Hz, an ideal passband filter (-f_s/2 to f_s/2)
> in the freq. domain will pass f1=5 but also the frequency f=3 Hz, correct?

Yes.  But if f_s = 16Hz, then the alias frequency for 5Hz will be 11Hz,
not 3Hz.

This may help:
http://www.wescottdesign.com/articles/Sampling/sampling.html

--
Tim Wescott
Control system and signal processing consulting
www.wescottdesign.com
```
```fisico32 wrote:
> Hello Forum,
>
> if a continuous-time sinusoid x(t)=cos(2pi*f1*t+theta) is sampled at an
> arbitrary rate f_s, we will obtain a sequence x[n].

**By definition.

>
> This sequence will be the same sequence we would obtain from sampling, at
> the same rate f_s, an infinite number of other sinusoids of continuous
> frequency different from f1.

**No *tw o times* -  as long as the sampling and the sinusoids in
combination meet the Nyquist criterion.

No, the sequence won't be the same sequence (that is, the values will be
different) even if you keep the sampling instants at relatively the same
points in time.

and:

> The spectrum would be a series of delta at locations f =f1 +- k*f_s.

No, the spectrum won't be a series of deltas.
- That's because you said we were dealing with a continuous time set of
sinusoids of any frequency, yes?
- And, because you didn't say that the number of samples was finite
there can be no "assumptive model" that says the time sequence is
periodic.  For example sin(t) + sin(pi*t) is not periodic and, with
judicious selection of frequencies and sampling rate can meet the
Nyquist criterion.  But you have to sample over infinite time.  As long
as you sample over infinite time then the spectrum will be continuous
and you can add all the sinusoids you want as close together as you
want.  Just consider the inverse Fourier Transform of a continuous spectrum.

>
> This would happens even if f_s>>2*f1: the ambiguity on which continuous
> frequency sinusoid this sequence x[n] belongs to will remain...

***I don't see this ambiguity for what's been given so far.

>
> Does that mean that we need to make some assumptions, that we need to know
> something beforehand, to be able to associate x[n] to cos(2pi*f1*t+theta)?
> What are these assumptions?

***No.  None.
>
> Aliasing occurs if our interpolating algorithm assumes that f_max=f_s/2,
> correct? If f1=5 Hz f_s/2=8 Hz, an ideal passband filter (-f_s/2 to f_s/2)
> in the freq. domain will pass f1=5 but also the frequency f=3 Hz, correct?

***The interpolating algorithm, if linear, is just a filter.  If there's
no aliasing going into the filter then there's no aliasing coming out of it.

***I think you're confusing practice with theory.  This often happens
here  :-).

Well this *is* comp.*DSP* so it may be OK for you to assume:
1) sampled data in time.
and
2) sampled data in frequency.
But then you can't apply all the theoretical notions that come from
continuous time and frequency.

Maybe more like this:

Joe decides to sample 5Hz at 16kHz.  This takes his signals from
continuous time to discrete time.  And, he "knows" that the Nyquist
criterion will be met. But, it's still conceptual because what he
"knows" only applies if there's infinite time.  And, Joe doesn't have
infinite time to do this.

Joe can only start the sampling when he can start it - push a button or
click a mouse.  So, there is a "current" time that the sequence of
samples starts.  And, after he gets tired or memory is filled up, Joe
stops the sampling.  Once it has been started and stopped, Joe has
effectively applied a rectangular window on the originally conceived
infinite sinusoid.

Switching things around, Joe designs an analog gate that will be opened
as the sampling starts and closed when the sampling is scheduled to end.
So now, Joe has a continuous time sinsuoid multiplied by a "gate" -
a rectangular window has been applied in time.  And then, he samples the
gated sinusoid.

Is the Nyquist criterion still met?  No.
Why not?  Because the discontinuities introduced by the window/gate
introduce an infinity of frequency components.
This means that almost any finite time record contains aliased
components relative to the assumed, underlying infinite signal.

I say "almost" because there are sinusoids which may be windowed without
introducing sharp discontinuities.  It takes two things:
1) there has to be an integer number of periods of the sinusoid in the
window.
2) one then may assume, for that particular set of sinuoids, that what's
in the window is a true replica of the underlying infinite composite of
sinusoids.
If that's the case then the window contains one period of an infinite
but periodic waveform.

And, this allows us to get past the aliasing that would otherwise be
caused by the window / the finite time aspect of all this.

And, if the underlying waveform is periodic (or if we *assume* that it
is - which isn't exactly the same thing, is it?) then the spectrum will
be discrete in our way of thinking and handling it.  That's what we do
when we compute a DFT - discrete in and discrete out.

Well, then what happens if there's a sinusoid in the window whose period
is not an integral fraction of the window?  For that one,there will be a
sharp discontinuity at the edge of the assumed underlying period defined
by the window.  And, that one will be aliased.

Take a look in the frequency domain.

If everything is infinite in time then all the temporal sinusoids show
up as samples in frequency.  If a window is chosen then there are
harmonically related sinusoids which will remain looking like samples in
frequency.  However, if there's a sinusoid at some odd frequency then
the window chops it off in time and it is convolved with a sinc in
frequency.  The tails of the sinc represent the aliasing that we
expected.  BUT, typically we call this "spectral leakage" and not
aliasing.  And, because we as using a sampled version of the spectrum,
the leakage shows up on all the sample points with various values.

There are other ways to come at all these things but this seems most
focused on what you're asking.

So, now let's see how you get 3Hz:

Sample 5Hz at 16Hz - for how long?
16/5 = 3.2 samples per period of the 5Hz.
To get an integer number of periods of the 5Hz, we might sample for
5,10,15 seconds.... multiples of the inverse of 0.2 and we'll get 25, 50
or 75 periods of the 5Hz sinusoid - exactly.
In this case there's no aliasing and we can safely assume, because we
forced it, that the windowed sequence is one cycle of an infinite
waveform.

The result is a spectrum with a sample at 5 Hz and another at 11Hz (or,
if you like -5Hz).  It doesn't matter which because this sequence is
assumed to be periodic as well.  Why?  Because the time sequence we
stared with was discrete.

No matter what, I don't see where you get 3Hz.... 8-5 doesn't apply
here, it's 16-5.

Oh!  But, if there's a typo above and fs=8 and *not* f_s/2=8 Hz then the
Nyquist criterion is not met no matter what and there will be aliasing
due to the sampling no matter what.  Reconstruction has nothing to do
with that.  In that case there will be a sample at 5Hz (which
corresponds to -3Hz) and a sample at 3Hz just as you say.

But why discuss anomalous situations?  :-)

Fred
```