Forums

zero-padding and normalization for fft

Started by A.E lover November 18, 2007
hi all,
Normally to normalize an fft such that a pure sinusoid with amplitude
of 1 in time domain will correspond with spectrum with magnitude of 1
in frequency domain, I perform fft then devide the obtained spectrum
by N/2 (where N is the length of the signal).

Now I want to pad zeros so that the spectrum will look better, do you
know how to normalize fft in this way such that a sinusoid with
amplitude 1 will correspond with spectrum with magnitude of 1?
Thanks
On Sun, 18 Nov 2007 15:06:45 -0800 (PST), "A.E lover"
<aelover11@gmail.com> wrote:

>Now I want to pad zeros so that the spectrum will look better, do you >know how to normalize fft in this way such that a sinusoid with >amplitude 1 will correspond with spectrum with magnitude of 1?
Also divide by N/2, where N is the number of points before zeropadding. In either situation, the value at DC needs to be divided by N, not N/2. Greg
On Nov 18, 6:50 pm, Greg Berchin <gberc...@comicast.net> wrote:
> On Sun, 18 Nov 2007 15:06:45 -0800 (PST), "A.E lover" > > <aelove...@gmail.com> wrote: > >Now I want to pad zeros so that the spectrum will look better, do you > >know how to normalize fft in this way such that a sinusoid with > >amplitude 1 will correspond with spectrum with magnitude of 1? > > Also divide by N/2, where N is the number of points before zeropadding. > > In either situation, the value at DC needs to be divided by N, not N/2.
just to add, that is if you're defining the DFT the most conventional way: N-1 X[k] = SUM{ x[n] e^(-j*2*pi*n*k/N) } n=0 with iDFT: N-1 x[n] = (1/N)*SUM{ X[k] e^(+j*2*pi*n*k/N) } k=0 some of us think that a more natural definition would be DFT: N-1 X[k] = (1/N)*SUM{ x[n] e^(-j*2*pi*n*k/N) } n=0 iDFT: N-1 x[n] = SUM{ X[k] e^(+j*2*pi*n*k/N) } k=0 and this would work: N/2-1 x[n] = SUM{ X[k] e^(+j*2*pi*n*k/N) } k=-N/2 with the understanding that X[k] (as well as x[n]) are periodic: X[k+N] = X[k] (and x[n+N] = x[n]) i see that definition as being more natural so that (at least when there is no zero-padding, which is IMO an active change of definition of the signal) you need not divide by N anywhere. the value of the DFT bin X[k] is, by definition, the amplitude of the kth complex frequency component (there's ambiguity about the +/- (N/2)th components, but screw those guys, unless you wanna divide that bin amplitude by 2 and assign each half to each frequency). anyway, it doesn't matter where you put the 1/N factor, in the forward or inverse DFT, or a little in both, as long as the two leading factors, in the DFT and iDFT, themselves multiply to 1/N (so that the round-trip gain is unity and x[n] = x[n]). r b-j
On Nov 18, 3:50 pm, Greg Berchin <gberc...@comicast.net> wrote:
> On Sun, 18 Nov 2007 15:06:45 -0800 (PST), "A.E lover" > > <aelove...@gmail.com> wrote: > >Now I want to pad zeros so that the spectrum will look better, do you > >know how to normalize fft in this way such that a sinusoid with > >amplitude 1 will correspond with spectrum with magnitude of 1? > > Also divide by N/2, where N is the number of points before zeropadding.
This works if the sinusoid is perfectly periodic in both N and the new length after zero-padding. Otherwise the two fft's will have different scalloping losses (unless one does perfect interpolation), and, depending on where the zero-padding is added, the phase of the sinusoid with respect to the center of the dft/fft aperture might change, which could affect the sign of the contribution from the negative frequency bins. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M http://www.nicholson.com/rhn/dsp.html
On Nov 19, 1:40 am, "Ron N." <rhnlo...@yahoo.com> wrote:

> This works if the sinusoid is perfectly periodic in both > N and the new length after zero-padding.
I had assumed from context that there was an integer number of sine periods in the original N. I don't think that it's necessary that there be an integer number of sine periods in N+Z, where N+Z is the zeropadded FFT size. You're computing the dot products of the same two sinusoids in both cases -- the zeropadded section contributes nothing to the sum. Greg
Thank you guys.

Hi Ron, can you please tell me more so in general case, i.e both in
both N and new length M the sinusoid is not perfectly periodic, how to
normalize the signal?
As I understand it, in this case, the reason is the angular frequency
of the original sinusoid doesn't fall exactly in a frequency bin of
DFT. Is it correct?
So is there any way to determine this scalloping losses?

On Nov 19, 1:40 am, "Ron N." <rhnlo...@yahoo.com> wrote:
> two fft's will have different scalloping losses (unless > one does perfect interpolation), and, depending on where > the zero-padding is added, the phase of the sinusoid with > respect to the center of the dft/fft aperture might change, > which could affect the sign of the contribution from the > negative frequency bins. > > IMHO. YMMV. > -- > rhn A.T nicholson d.0.t C-o-M > http://www.nicholson.com/rhn/dsp.html
I read somewhere it said that zero padding doesn't increase the analysis resolution at all in frequency domain. What it does is to "interpolate" the spectrum so that we have more frequency samples and so yield a better look of the spectrum. Would any one please tell me the way to derive this interpolation methematically? Thanks
On Nov 19, 6:22 am, "A.E lover" <aelove...@gmail.com> wrote:
> I read somewhere it said that zero padding doesn't increase the > analysis resolution at all in frequency domain. What it does is to > "interpolate" the spectrum so that we have more frequency samples and > so yield a better look of the spectrum.
It doesn't increase the resolution in terms of being able to resolve more closely spaced spectral peaks. It does interpolate accurately enough to often allow the measurement of isolated maxima with higher resolution in the absence of nearby spectral interference or noise. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
On Nov 19, 3:54 am, Greg Berchin <gberc...@sentientscience.com> wrote:
> On Nov 19, 1:40 am, "Ron N." <rhnlo...@yahoo.com> wrote: > > > This works if the sinusoid is perfectly periodic in both > > N and the new length after zero-padding. > > I had assumed from context that there was an integer number of sine > periods in the original N. I don't think that it's necessary that > there be an integer number of sine periods in N+Z, where N+Z is the > zeropadded FFT size. You're computing the dot products of the same > two sinusoids in both cases
The basis vector set of a DFT/FFT depends on it length. If the data is periodic in N and not periodic in N+Z, then the basis vector set of the first FFT will not be completely contained in the basis set of the second FFT. Thus the dot products won't be of the same two sinusoids in all cases. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
On Nov 19, 1:05 pm, "Ron N." <rhnlo...@yahoo.com> wrote:

> If the data is periodic in N and not periodic in N+Z, > then the basis vector set of the first FFT will not be > completely contained in the basis set of the second FFT.
Ah, yes, of course. In other words, if the length of the FFT after zeropadding is not an integer multiple of the period of the waveform, then the frequency of the waveform will not fall on an FFT bin and the magnitude will be altered according to the (effective) rectangular window applied. We are normalizing N-1 |SUM F(n)*{exp[j2PIkn/N]}| n=0 such that, when F(n) is a pure sinusoid and the period of F(n) is an exact integer submultiple of N, the resulting magnitude equals the amplitude of F(n). Add some zeropadding and the expression becomes: N+Z-1 | SUM F'(n)*{exp[j2PIkn/(N+Z)]}| n=0 N-1 N+Z-1 = |SUM F(n)*{exp[j2PIkn/(N+Z)]}| + SUM [0] n=0 n=N It's that (N+Z) in the denominator that changes things. Greg