# zero padding avoids aliasing

Started by December 28, 2006
```hey guys - i can't seem to find find this statement any where - but it
makes sense to me - could someone please verify.
When you find the DFT of a signal say: x[0]=2, x[1]=4, x[2]=6, x[3]=8 -
you will get four discrete points in frequency (per period) now if you
zero pad such that tou get x[0]=2, x[1]=4, x[2]=6, x[3]=8 x[4]=0, x[5]=0,
x[6]=0, x[7]=0 - you will once agin get four discrete frequency points but
now the gap between each period will be larger (thus decreasing any chances
of aliasing) thnks

john

```
```John182 skrev:
> hey guys - i can't seem to find find this statement any where - but it
> makes sense to me - could someone please verify.

Nope. The statement is plain wrong.

> When you find the DFT of a signal say: x[0]=2, x[1]=4, x[2]=6, x[3]=8 -
> you will get four discrete points in frequency (per period) now if you
> zero pad such that tou get x[0]=2, x[1]=4, x[2]=6, x[3]=8 x[4]=0, x[5]=0,
> x[6]=0, x[7]=0 - you will once agin get four discrete frequency points but
> now the gap between each period will be larger (thus decreasing any chances
> of aliasing) thnks

Zero padding interpolates the spectrum. As you have observed, extending

the length of a sequence by zero padding introduces more spectrum
coefficients than in the original spectrum.

What zero padding does NOT do is to change the relation of sinusoidals
with respect to the sampling frequency. The ration f/fs remains
unchanged,
so if there is aliasing in the original signal, there is aliasing in
the zero-
padded signal as well.

Just test with a sinusoidal with frequency fs/4. With four samples,
the peak in the spectrum will fall on the index 1 [*] DFT coefficient.
After you zero-pad to length 8, the peak in the spectrum falls on
the index 3 DFT coefficient.

* Index 0 is the DC coefficient.

Rune

```
```thanks.

Now can someone tell me if zero padding affects the frequency resolution?

i read that it does not?
but i can't undersatnd this because when we zero pad we increase our
number of samples and our frequency resolution is totally dependent on the
number of samples therfore it has to change.

thanks

```
```John182 wrote:
> thanks.
>
> Now can someone tell me if zero padding affects the frequency resolution?
>
> i read that it does not?
> but i can't undersatnd this because when we zero pad we increase our
> number of samples and our frequency resolution is totally dependent on the
> number of samples therfore it has to change.
>
> thanks

Zero-padding a finite-length time-domain signal will increase the
number of frequency bins output if you perform a DFT. Since
zero-padding doesn't affect the sample rate, the greater number of bins
still span the same frequency range as before. So, the frequencies that
you get are more finely-spaced; this can be interpreted to mean you
have greater resolution.

Jason

```
```thanks.

Now can someone tell me if zero padding affects the frequency resolution?

i read that it does not?
but i can't undersatnd this because when we zero pad we increase our
number of samples and our frequency resolution is totally dependent on the
number of samples therfore it has to change.

thanks

```
```John182 wrote:

> Now can someone tell me if zero padding affects the frequency resolution?

> i read that it does not?
> but i can't undersatnd this because when we zero pad we increase our
> number of samples and our frequency resolution is totally dependent on the
> number of samples therfore it has to change.

To increase the resolution in a real sense you need more information.

Say you take a discrete frequency spectrum (such as an FFT output),
transform to the time domain (all the information is still there),
zero out the last half of the points (some information is now gone).

If you transform back, you will still have as many frequency
points, but half of the information is gone.

For a different point of view, say I measure the lengths of some
objects with a ruler to 1mm resolution.  Now I write down the
numbers with 10 digits after the decimal point and give them to you.
(Maybe using a random number generator.)

You now have what looks like high resolution measurements, but
there is no more information than the 1mm that I actually measured.

-- glen

```
```cincydsp@gmail.com wrote:
> John182 wrote:
>> thanks.
>>
>> Now can someone tell me if zero padding affects the frequency resolution?
>>
>> i read that it does not?
>> but i can't undersatnd this because when we zero pad we increase our
>> number of samples and our frequency resolution is totally dependent on the
>> number of samples therfore it has to change.
>>
>> thanks
>
> Zero-padding a finite-length time-domain signal will increase the
> number of frequency bins output if you perform a DFT. Since
> zero-padding doesn't affect the sample rate, the greater number of bins
> still span the same frequency range as before. So, the frequencies that
> you get are more finely-spaced; this can be interpreted to mean you
> have greater resolution.

Such an interpretation would be wrong. What you get is mere
interpolation, not new data. The interpolation might as well have been
done with a French curve or draftsman's spline.

Jerry
--
Engineering is the art of making what you want from things you can get.
&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
```
```John182 wrote:
> Now can someone tell me if zero padding affects the frequency resolution?

If you think interpolation algorithms (as opposed to just picking
the largest bin) affect frequency resolution, then zero padding
affects frequency resolution is a similar manner.  Zero padding a
much larger fft is a computationally expensive way of creating a
large number of interpolated points.  But usually you only want
only one interpolated maxima, and this can be done with a more
local interpolation (a table corrected parabolic interpolation was
posted a few weeks ago) at a much lower computation cost than doing
a whole and longer fft.

IMHO. YMMV.
--
rhn A.T nicholson d.0.t C-o-M

```
```Jerry Avins wrote:
> cincydsp@gmail.com wrote:
> > John182 wrote:
> >> thanks.
> >>
> >> Now can someone tell me if zero padding affects the frequency resoluti=
on?
> >>
> >> i read that it does not?
> >> but i can't undersatnd this because when we zero pad we increase our
> >> number of samples and our frequency resolution is totally dependent on=
the
> >> number of samples therfore it has to change.
> >>
> >> thanks
> >
> > Zero-padding a finite-length time-domain signal will increase the
> > number of frequency bins output if you perform a DFT. Since
> > zero-padding doesn't affect the sample rate, the greater number of bins
> > still span the same frequency range as before. So, the frequencies that
> > you get are more finely-spaced; this can be interpreted to mean you
> > have greater resolution.
>
> Such an interpretation would be wrong. What you get is mere
> interpolation, not new data. The interpolation might as well have been
> done with a French curve or draftsman's spline.
>
> Jerry
> --
> Engineering is the art of making what you want from things you can get.
> =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=
=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF

Correct. The interpolated DFT outputs don't have any new information,
but you have greater resolution in the sense that the frequency bins
are more finely spaced, not any other way. It's just a semantic issue
on whether or not you want to call that greater "resolution."

By the sampling theorem, as long as you sample a bandlimited signal
under the Nyquist rate, you know everything you need to know to
perfectly reconstruct the signal (provided you could construct the
filters or some other implementation needed to do so, which we know is
impossible). Therefore, at that point, you've done the best you can do;
you can zero-pad all you want to get more points at the output of your
DFT, but you don't get any new information, because you already have
all the information there is on the continuous-time signal.

Jason

```
```j...@gmail.com wrote:
>....
> Correct. The interpolated DFT outputs don't have any new information,
> but you have greater resolution in the sense that the frequency bins
> are more finely spaced, not any other way. It's just a semantic issue
> on whether or not you want to call that greater "resolution."
> ...

I don't think that anybody else has mentioned this so I will put my two
cents in here.  The kind of resolution that people are talking about
when they say that you can't get any more by zero padding is the
ability to resolve two very close tones.  If you want to do that, you
need a longer record in the first place.  This is the same as using a
larger lens to be able to image objects that are close together, with a
small lens the points (think stars) will be blured to some radius, with
a larger lens they will be blurred to some smaller radius.

For more information on this refer to Hayes Statistical Digital Signal
Processing and Modeling pp 402-403, or any Spectral Estimation book
(Stoica, Kay, Marple).

-John

```