DSPRelated.com
Forums

Zero-padding, resolution and aliasing

Started by Amelia February 16, 2008
Hi,

I understand that zero-padding a time domain signal cannot add any extra
information to the spectrum, and that you only end up with a more finely
sampled spectrum.

What I'm interested to know is whether zero-padding can cause spectral
leakage? Or if I will always see a true representation of my original
signal in the spectrum?

Basically, I have been zero-padding my data by 100,000 points and seeing
peaks appear in the spectrum where before there was just a broad,
asymmetric peak. I want to know if I can believe these new peaks or if
they might be due to spectral leakage.

And is zero-padding a time series to that extent a crazy thing to do??


Can anyone help me?

Thanks!

Amelia


"Amelia" <meelie2002@yahoo.fr> writes:

> Hi, > > I understand that zero-padding a time domain signal cannot add any extra > information to the spectrum, and that you only end up with a more finely > sampled spectrum. > > What I'm interested to know is whether zero-padding can cause spectral > leakage? Or if I will always see a true representation of my original > signal in the spectrum? > > Basically, I have been zero-padding my data by 100,000 points and seeing > peaks appear in the spectrum where before there was just a broad, > asymmetric peak. I want to know if I can believe these new peaks or if > they might be due to spectral leakage. > > And is zero-padding a time series to that extent a crazy thing to do?? > > > Can anyone help me? > > Thanks! > > Amelia
Hi Amelia, Is the length of your original signal short enough so that you can get all of into a single FFT, or are you truncating a piece of the signal and putting that into the FFT? If it's the former, then you will be seeing the "true" spectrum no matter how much you zero-pad. If it's the latter, then you won't be seeing the "true" spectrum whether you zero-pad or not. In theory there is no problem with zero-padding 100,000 points. In practice, one can begin to experience finite-precision effects (even with Matlab's 8-byte floats) when going to very large FFT lengths, so you could be seeing some anomalies due to this effect if you're using, e.g., 128K FFTs. I would ask this question on the Matlab newsgroup to get a precise answer. -- % Randy Yates % "She tells me that she likes me very much, %% Fuquay-Varina, NC % but when I try to touch, she makes it %%% 919-577-9882 % all too clear." %%%% <yates@ieee.org> % 'Yours Truly, 2095', *Time*, ELO http://www.digitalsignallabs.com
On Sat, 16 Feb 2008 06:03:15 -0600, "Amelia" <meelie2002@yahoo.fr>
wrote:

>Hi,
Hi Amelia,
>I understand that zero-padding a time domain signal cannot add any extra >information to the spectrum, and that you only end up with a more finely >sampled spectrum.
I agree with your words. The way I look at "zero padding" is as follows: given a finite duration sequence of time samples, that sequence has an "actual" continuous spectrum (infinitely fine granularity). The continuous spectrum is called the "discrete-time Fourier transform (DTFT). Using the DFT (or FFT), we can effectively "sample" that continuous spectrum and plot those samples on our computer screens. Zero padding the time sequence and performing larger DFTs merely gives us "more closely spaced" samples of the time sequence's continuous spectrum (its DTFT).
>What I'm interested to know is whether zero-padding can cause spectral >leakage? Or if I will always see a true representation of my original >signal in the spectrum?
If I understand your question, my answer is "No." If your time series contains spectral components that we call "leakage", then zero padding will merely display those leakage components with finer spectral granularity. (As you probably know, what we call "leakage" is not caused by performing a DFT. Leakage is caused by the finite-duration nature of a time-domain sequence.)
>Basically, I have been zero-padding my data by 100,000 points and seeing >peaks appear in the spectrum where before there was just a broad, >asymmetric peak. I want to know if I can believe these new peaks or if >they might be due to spectral leakage.
Again, your time sequence has some spectral content. Zero padding, and then DFTing, gives you a more accurate display of that spectrum than if you did no zero padding. If zero padding is making some spectral "bumps" become visible then you can rest assured that those spectral bumps exist in your original time-domain sequence.
>And is zero-padding a time series to that extent a crazy thing to do??
Assuming that you're using floating-point numbers in your computations, I see no problem in zero padding a time sequence by 100,000. You might have noticed that I avoided using the word "resolution". I'm trying to avoid using that word, whenever possible, because it seems to cause all sorts of confusion and heartache. The word "resolution", like the word "diversity", means different things to different people. Good Luck, [-Rick-]
On 16 Feb, 13:03, "Amelia" <meelie2...@yahoo.fr> wrote:
> Hi, > > I understand that zero-padding a time domain signal cannot add any extra > information to the spectrum, and that you only end up with a more finely > sampled spectrum. > > What I'm interested to know is whether zero-padding can cause spectral > leakage?
Nope. Zero-padding does not alter the contents of the spectrum, only its representation.
> Or if I will always see a true representation of my original > signal in the spectrum?
You will se *another* representation of the spectrum. Including terms like 'true' only messes up the discussion.
> Basically, I have been zero-padding my data by 100,000 points and seeing > peaks appear in the spectrum where before there was just a broad, > asymmetric peak. I want to know if I can believe these new peaks or if > they might be due to spectral leakage.
The peaks *might* be there because of spectral leakage, but *not* because of zero-padding. Consider a data series containing one sinusoidal at 0.25 Hz, that is sampled at 1 Hz. If you start with N = 32 samples the sine will be represented as exactly one non-zero coefficient in the spectrum. No spectral leakage. Now zero-pad to 64 or 1024 points and plot the magnitude spectrum. The spectrum is now of a general sinc-like shape, but if you look closely, it has zero crossings at the same frequencies where the original spectrum has zeros. What happens is that zero-padding 'connects the dots' outlined by the original spectrum, in a systematical way. Note that the zero-padded spectrum is *not* the 'true' spectrum. Consider the case when the data is only a subset of a large data set, say, a sinusoidal that originally contained 2^16 elements. In this case the 'true' spectrum is the DFT of the 2^16 element data vector. This 'connecting the dots' has nothing to do with spectral leakage. Spectral leakage is what happens if the sinusoidal in the original data does not fall exactly on the frequency of a spectrum coefficient. Spectral leakage happens regardless of whether the data are zero-padded or not, as it is caused by the original data being truncated.
> And is zero-padding a time series to that extent a crazy thing to do??
Yes, those sorts of numbers are crazy. Rune
Hi Amelia,
Here's some material on the topic.

http://www.dspguide.com/ch9/1.htm 
On Feb 16, 4:03 am, "Amelia" <meelie2...@yahoo.fr> wrote:
> I understand that zero-padding a time domain signal cannot add any extra > information to the spectrum, and that you only end up with a more finely > sampled spectrum. > > What I'm interested to know is whether zero-padding can cause spectral > leakage?
It doesn't cause leakage. But it may make previously hidden information about the finite width of your data window become visible in the new spectrum. If this isn't information that you want, then one could say that zero padding caused unwanted artifacts to appear.
> Or if I will always see a true representation of my original > signal in the spectrum?
You will see another representation. Your question should be about what kind of representations are most useful for your needs.
> Basically, I have been zero-padding my data by 100,000 points and seeing > peaks appear in the spectrum where before there was just a broad, > asymmetric peak. I want to know if I can believe these new peaks or if > they might be due to spectral leakage.
The key word is "believe". What kind of result do you wish to believe in? If you believe that information about how your non-periodic data was windowed is important, then all the Sinc-like interpolation ripples you find will contribute to that knowledge. If you want to believe only in periodic oscillator sources which might have produced the longer signal from which your finite sample set was taken, then perhaps you should consider new peaks below a certain relative height as form of noise caused by "spectral leakage".
> And is zero-padding a time series to that extent a crazy thing to do??
This depends on how the signal-to-noise ratio of your original sample set compares to the height of the Sinc-like ripples. In my current applications, I rarely find anything useful from zero-padding an FFT by more than 10X to 20X, but YMMV. If I need to plot more points (high resolution printer, etc.), a much simpler form of interpolation usually serves just as well. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
Rick Lyons wrote:

(snip)

> I agree with your words. The way I look > at "zero padding" is as follows: given a > finite duration sequence of time samples, that > sequence has an "actual" continuous spectrum > (infinitely fine granularity). The continuous > spectrum is called the "discrete-time Fourier > transform (DTFT). Using the DFT (or FFT), we > can effectively "sample" that continuous spectrum > and plot those samples on our computer screens. > Zero padding the time sequence and performing > larger DFTs merely gives us "more closely spaced" > samples of the time sequence's continuous > spectrum (its DTFT).
I disagree. I finite sequence of samples does not have a continuous transform unless you assume that there are an infinite number of zero samples before and after the sequence. With the extra zeros it is then an infinite sequence. Without specifying the rest of the sequence, the other points should be considered "don't care" samples. -- glen
On Sat, 16 Feb 2008 23:46:09 -0800, glen herrmannsfeldt
<gah@ugcs.caltech.edu> wrote:

>Rick Lyons wrote: > >(snip) > >> I agree with your words. The way I look >> at "zero padding" is as follows: given a >> finite duration sequence of time samples, that >> sequence has an "actual" continuous spectrum >> (infinitely fine granularity). The continuous >> spectrum is called the "discrete-time Fourier >> transform (DTFT). Using the DFT (or FFT), we >> can effectively "sample" that continuous spectrum >> and plot those samples on our computer screens. >> Zero padding the time sequence and performing >> larger DFTs merely gives us "more closely spaced" >> samples of the time sequence's continuous >> spectrum (its DTFT). > >I disagree. > >I finite sequence of samples does not have a continuous >transform unless you assume that there are an infinite >number of zero samples before and after the sequence. >With the extra zeros it is then an infinite sequence. > >Without specifying the rest of the sequence, the other >points should be considered "don't care" samples. > >-- glen
Hi glen, Well,...perhaps we're having a sematics (language) problem here. I was referring to a finite-duration sequence's Fourier transform to be defined by the sequence's discrete-time Fourier transform (DTFT). And the DTFT is a continuous (and complex) function of the frequency variable omega defined by: n = +inf --- X(w) = \ x(n)*exp(-jwn) / --- n = -inf. So if we consider the two-sample sequence: x1 = [2,3] and the 16-sample sequence: x2 = [0,0,0,0,0,0,0,2,3,0,0,0,0,0,0,0] and the infinite-length sequence: x3 = [...,0,0,0,0,0,0,2,3,0,0,0,0,0,0,...] is it not true that the above three sequences will all have identical discrete-time Fourier transforms (DTFTs)? (Of course, as shown on page 50 of Oppenheim and Schafer, 3rd Edition, the DTFT of a sequence only exists if the sum of that sequence's samples is less than infinity.) All I'm saying is that the x1 = [2,3] sequence has a continuous Fourier transform and that transform is: X(w) = 2*exp(-j2w) + 3*exp(-j3w) where the continuous frequency variable w (omega) is defined over a range of 2*pi, typically -pi to +pi. See Ya', [-Rick-]
On 17 Feb, 14:00, Rick Lyons <R.Lyons@_BOGUS_ieee.org> wrote:
> On Sat, 16 Feb 2008 23:46:09 -0800, glen herrmannsfeldt > <g...@ugcs.caltech.edu> wrote: > >Rick Lyons wrote: > > >(snip) > > >> I agree with your words. &#4294967295;The way I look > >> at "zero padding" is as follows: given a > >> finite duration sequence of time samples, that > >> sequence has an "actual" continuous spectrum > >> (infinitely fine granularity). &#4294967295;The continuous > >> spectrum is called the "discrete-time Fourier > >> transform (DTFT). &#4294967295; Using the DFT (or FFT), we > >> can effectively "sample" that continuous spectrum > >> and plot those samples on our computer screens. &#4294967295; > >> Zero padding the time sequence and performing > >> larger DFTs merely gives us "more closely spaced" > >> samples of the time sequence's continuous > >> spectrum (its DTFT). &#4294967295; > > >I disagree. > > >I finite sequence of samples does not have a continuous > >transform unless you assume that there are an infinite > >number of zero samples before and after the sequence. > >With the extra zeros it is then an infinite sequence. > > >Without specifying the rest of the sequence, the other > >points should be considered "don't care" samples.
...
> All I'm saying is that the x1 = [2,3] sequence has a > continuous Fourier transform and that transform is: > > &#4294967295; &#4294967295;X(w) = 2*exp(-j2w) + 3*exp(-j3w) > > where the continuous frequency variable w (omega) is > defined over a range of 2*pi, typically -pi to +pi.
I have to side with Glen. Your statement of the problem is incomplete. The sequence x1=[2,3] is a finite sequence of length 2. The DFT is well-defined, but you need to specify how to extend x1 towards infinity. That can be done in several ways, 1) By inserting leading and trailing zeros ...,0,0,2,3,0,0,... 2) By periodic extension ...,2,3,2,3,2,3,... 3) By stochastic extension (that is, insert leading and trailing sequences with the same statistics as x1) Assuming x1 is a finite-duartion sample of a (conceptually) infinite-duration stochastic process, the one thing one can be certain about is that whatever one chooses, it is *not* what would have ben measured if an infinite sample of the process could be obtained. Rune
On Feb 17, 5:00 am, Rick Lyons <R.Lyons@_BOGUS_ieee.org> wrote:
> On Sat, 16 Feb 2008 23:46:09 -0800, glen herrmannsfeldt > > > > <g...@ugcs.caltech.edu> wrote: > >Rick Lyons wrote: > > >(snip) > > >> I agree with your words. The way I look > >> at "zero padding" is as follows: given a > >> finite duration sequence of time samples, that > >> sequence has an "actual" continuous spectrum > >> (infinitely fine granularity). The continuous > >> spectrum is called the "discrete-time Fourier > >> transform (DTFT). Using the DFT (or FFT), we > >> can effectively "sample" that continuous spectrum > >> and plot those samples on our computer screens. > >> Zero padding the time sequence and performing > >> larger DFTs merely gives us "more closely spaced" > >> samples of the time sequence's continuous > >> spectrum (its DTFT). > > >I disagree. > > >I finite sequence of samples does not have a continuous > >transform unless you assume that there are an infinite > >number of zero samples before and after the sequence. > >With the extra zeros it is then an infinite sequence. > > >Without specifying the rest of the sequence, the other > >points should be considered "don't care" samples. > > >-- glen > > Hi glen, > Well,...perhaps we're having a sematics (language) > problem here. I was referring to a finite-duration > sequence's Fourier transform to be defined by the sequence's > discrete-time Fourier transform (DTFT). And the DTFT is > a continuous (and complex) function of the frequency > variable omega defined by: > > n = +inf > --- > X(w) = \ x(n)*exp(-jwn) > / > --- > n = -inf. > > So if we consider the two-sample sequence: > > x1 = [2,3] > > and the 16-sample sequence: > > x2 = [0,0,0,0,0,0,0,2,3,0,0,0,0,0,0,0] > > and the infinite-length sequence: > > x3 = [...,0,0,0,0,0,0,2,3,0,0,0,0,0,0,...] > > is it not true that the above three sequences will all > have identical discrete-time Fourier transforms (DTFTs)? > > (Of course, as shown on page 50 of Oppenheim and Schafer, > 3rd Edition, the DTFT of a sequence only exists if the > sum of that sequence's samples is less than infinity.) > > All I'm saying is that the x1 = [2,3] sequence has a > continuous Fourier transform and that transform is: > > X(w) = 2*exp(-j2w) + 3*exp(-j3w) > > where the continuous frequency variable w (omega) is > defined over a range of 2*pi, typically -pi to +pi.
You've just assumed that the coeff's of exp(-j4w), etc. are zero. What allows you to make the assumption that an unspecified value is zero, or 17.5? A better assumption might be that those coeff's are random variables with a 50% chance of being either 2 or 3, since that's what's been observed in the population so far. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M