DSPRelated.com
Forums

Window functions

Started by Rune Allnor August 31, 2004
Fred Marshall wrote:

> "Jerry Avins" <jya@ieee.org> wrote in message > news:4138592b$0$19725$61fed72c@news.rcn.com... > >>Fred Marshall wrote: >> >>> >>>Jerry, >>> >>>If the end points are zero then you need to use them. And, the results > > are > >>>not the same. >>> >>>That is, if I understand you: >>> >>>a) Calculate an N+2 window with zero end points and throw out both zero > > end > >>>points to get a length N window. >>> >>>b) Calculate an N+1 window with zero end points and throw out one zero > > (the > >>>N+1th) end point to get a length N window. >>> >>>In a, there are no zero end points at all. >>>In b, there is a zero on the first point and an assumed zero on the > > N+1th > >>>point. >>>So, they are different. >>> >>>Fred >>>But, you will drop one of them because it occurs on the N+1th == the > > first > >>>location (repeats). >> >>Let's stay with the non-circular symmetric case. I collect N samples and >>window them to prepare for a DFT with a window of length N. The first >>and last window coefficients are zero, so the first and last samples >>that the N-point DFT operates on are zero. Except for the bin spacing, I >>will get the same results by discarding the end samples and running an >>(N-2)-point DFT. Why did I bother to collect those samples? > > > Jerry, > > I think we're talking about two different things. And, the second sentence > above isn't really proper - which is what we *are* talking about I think. I > suppose we've all done what you describe, but it isn't really proper I > believe - Rick's point. > > What's (I think) proper is to prepare for a DFT with a window of length N+1 > and drop the last sample in the window to apply it to a sequence of length N > and do a DFT of length N. > (I have said nothing about zeros at the ends one way or another). > And, this has nothing to do with efficiency or collecting samples, just > plain proper math. > > Now, if you want to say that a particular window is going to have zeros at > the ends, then you could collect one fewer sample - the first one - and pad > a single zero at the beginning of the array beforedoingtheDFT.Whichever > is best for your situation is fine. > > >>Conversely: I use a window of length N+2, discarding the zero end >>points. After applying the truncated window to the data, I pad the >>result with a zero at each end, achieving what is indistinguishable from >>what would be had starting with N+2 samples. Where did those two free >>samples come from? They ain't no free lunch. Those samples were there >>all along; this time, I didn't throw them away. > > > You start with the idea that there will be an N+2 point DFT, right? > I prefer to keep the DFT at N points just to keep apples to apples. > So, then is this what you're saying: > > >>Conversely: I use a window of length N [that has zero end points), >>discarding the zero end points. >>After applying the truncated window to the data, I pad the >>result with a zero at each end, achieving what is indistinguishable from >>what would be had starting with N samples. Where did those two free >>samples come from? They ain't no free lunch. Those samples were there >>all along; this time, I didn't throw them away. > > > It's the same deal. You would compute a window of length *N+1* [that has > zero end points] discarding one end point for an apparently asymmetrical > window (Rick's point). Now you have a window of length N, that has a > starting point of zero, to be applied to a data sequence of length N . If > you would like to not capture the first sample or multiply by zero, either > one, and pad the sequence with a zero at the beginning - th at'sfine.It > doesn't change the fact that you need to compute the window to be one sample > longer than the data and truncate the window by one sample before applying > it. > > Fred
I'm confused, but that's not new. Suppose I collect 65 samples, then pad out to 128 for easy FFT. (I know don't have to, but I'm lazy.) I surely don't want a window of length 128; that would be about as bad as no window at all. It seems to me that I want to taper the significant samples to zero at both ends -- or just outside them. I just don't see how driving one end but not the other to zero makes sense here. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Rick Lyons" <r.lyons@_BOGUS_ieee.org> wrote in message 
news:41365058.204625031@news.sf.sbcglobal.net...
> But speaking of windows, I'm beginning to believe that > my equations for the Hanning and Hamming windows > are incorrect! > > My N-point Hamming equation, for example, is: > > w1(n) = 0.54 - 0.46*cos(2*pi*n/(N-1)) [1] > for n = 0,1,2,...,N-1. > > My Eq. [1] agrees, by the way, with Proakis & Manolakis, > Opp & Schafer, MATLAB, etc. > > If you plot the w1(n) samples in [1] give ya' this nice > symmetrical window sequence where the first and last > samples are both zero-valued. However, I just discovered > (maybe I knew this years ago and forgot) that the Fourier > transform of Eq. [1]'s w1(n) does *not* give us the > correct Fourier transform of a Hamming window!! > > The correct N-point discrete Fourier transform (DFT) of an > N-point Hamming window is three real non-zero samples. > The amplitudes of those samples are 0.23N, 0.54N, and > 0.23N. The imaginary part of the correct N-point DFT of > an N-point Hamming window is all zeros. > > The DFT of Eq. [1]'s w1(n) is neither real-only nor does > it's freq-domain samples have the correct amplitudes. > > I now think the correct N-point Hamming equation > should be: > > w2(n) = 0.54 - 0.46*cos(2*pi*n/(N)) [2] > for n = 0,1,2,...,N-1. > > If you plot w2(n) in the time domain it does not "look > symmetric". The w2(n) sequence's first and last samples > are not equal. But the DFT of Eq. [2]'s w2(n) is real-only > and it's freq-domain samples do have the correct amplitudes > (0.23N, 0.54N, and 0.23N). > > I want to call w2(n) "DFT symmetric", because if we circularize > (is that a word) it, by repeating it over and over, making > it periodic, then it becomes symmetrical. > > I know I know, the difference between w1(n) and w2(n) becomes > smaller and smaller as N becomes larger. > > Anyway, I'm thinking that there are two different types of > symmetry: "linear symmetry" and "DFT symmetry". And > that window functions should always be "DFT Symmetric". > And maybe I should change the equations in my book with > regard to the Hanning and Hamming windows.
You are exactly correct. This is one of the subtle points about data windows that few (if any) textbooks talk about. If your purpose is to window data before doing a DFT, you want the window equation to use divide-by-N, the one you call "DFT Symmetric". One reason you want this is that it gives the expected line spectrum when given input data that is periodic within the input blocksize. Note that in this case, N is usually an even number, and you want the window to be symmetric around the N/2+1 sample rather than symmetric around N/2+0.5, so that you don't introduce a phase ramp into your frequency spectrum. On the other hand, if your purpose is to window the coefficients of an FIR filter, you want the divide-by-N-1 formula. Note that in this case, N is usually an odd number, and you generally want the window to be symmetric around the center filter coefficient. Worrying about whether the window goes to zero at the beginning or end of the data is the wrong way to look at this. Windows that go to zero are just a (very common) special case. The Hamming window and Kaiser windows, for example, doesn't go to zero at the ends. -- Eric Backus R&D Design Engineer Agilent Technologies, Inc. 425-356-6010 Tel
"Eric Backus" <eric_backus@alum.mit.edu> wrote in message news:<1094239880.872470@cswreg.cos.agilent.com>...
> "Rick Lyons" <r.lyons@_BOGUS_ieee.org> wrote in message > news:41365058.204625031@news.sf.sbcglobal.net...
> > Anyway, I'm thinking that there are two different types of > > symmetry: "linear symmetry" and "DFT symmetry". And > > that window functions should always be "DFT Symmetric". > > And maybe I should change the equations in my book with > > regard to the Hanning and Hamming windows. > > You are exactly correct. This is one of the subtle points about data > windows that few (if any) textbooks talk about. If your purpose is to > window data before doing a DFT, you want the window equation to use > divide-by-N, the one you call "DFT Symmetric". One reason you want this is > that it gives the expected line spectrum when given input data that is > periodic within the input blocksize.
OK... you present a very subtle point here, that I haven't really thought about. My instant reaction is that the reason for using windoes is exactly to "smear" the spectra they operate on, be it the smoothing of the periodogram or suppresion of side lobes in FIR filters. The one effect one does *not* want from a window function, is that the spectrum degenerates to just a few non-zero coefficients. Designing a window as a cosine over one period plus one sample, is a very neat way to achieve this "non-degenerate" spectrum.
> Note that in this case, N is usually > an even number, and you want the window to be symmetric around the N/2+1 > sample rather than symmetric around N/2+0.5, so that you don't introduce a > phase ramp into your frequency spectrum.
Even or odd symmetry does not play a part in introducing the phase lag, except for determining exactly how much of a phase lag is introduced. I can think of two reasons to use window functions. The first is in FIR filter design, which is the main subject of this thread. The second is for smoothing the periodogram in spectrum estimation. Do note that the theory of spectrum estimation requires the *autocorrelation function*, not the data series iteslf, to be weighted by the window function. So with N data samples available, the relevant part of the autocorrelation seqience is at most 2N-1 samples long. It may be shorter, but because of the requirement of the periodogram to be real- valued (the Wiener-Kinchin theorem), the autocorrelation sequence must be symmetrical around lag = 0, and thus of odd length.
> On the other hand, if your purpose is to window the coefficients of an FIR > filter, you want the divide-by-N-1 formula. Note that in this case, N is > usually an odd number, and you generally want the window to be symmetric > around the center filter coefficient. > > Worrying about whether the window goes to zero at the beginning or end of > the data is the wrong way to look at this. Windows that go to zero are just > a (very common) special case. The Hamming window and Kaiser windows, for > example, doesn't go to zero at the ends.
The value of the coefficients at the ends have nothing to do with anything, as the number N of coefficients is included in the complex exponential in the Fourier transform. The one adaptation that could be useful, would be to use a length N+2 Bartlett, Blackman or Hann window, so that the end points in the data frame actually contribute to the spectrum, and that also reduce the computational delays in FIR filters. Rune
In the famous Harris window's paper (see FAQ for pointer) there is a chart and 
a plot of the various paramteters associated with the comomon window 
functions.  There is also a Fortran program in "Handbood of Digital Signal 
Processing: Engineering Applications" which is supposed to generate those 
parameters.  If it worked.  For small window sizes.

In article <3YudnT5_xdBRbKncRVn-gw@centurytel.net>, "Fred Marshall" 
<fmarshallx@remove_the_x.acm.org> wrote:
> >"Rune Allnor" <allnor@tele.ntnu.no> wrote in message >news:f56893ae.0408310548.8ba60b4@posting.google.com... >> Hi all. >> >> I'm playing a bit with window functions in filter design etc, and >> have come across a couple of gruelling expressions. More specifically, >> the Chebychev window [1, eq. 5-17], the Tukey window [2, table 8.1] >> and the Lanczos window, [2, table 8.1]. >> >> I would like to know how one estimates the width of the main lobe >> for these filters, and how one uses the various control parameters. >> Table 8.1 in P&M seems to contain quite a few typos, which does not >> exactly help me understand what's going on. > >Rune, > >I'm going to note that you said "etc." and not worry about what you're going >to do with the windows. You may peek through them for all I care! :-) > >I don't recall a general method or figure or table that compares them - >although fred harris or Al Nuttall may have done so. I have a more >arm-waving method..... > >1) First you need to define how main lobe width will be measured. -3dB >points? first zero points? etc. Note that they are all pretty much the >same at -3dB and can be quite different at the first zero point. > >2) Then, realize that the van der Maas functin provides the lowest >(minimax) sidelobe for a given main lobe width - exept it's not physically >realizable and the end points of the window are infinite as I recall. >Nonetheless, it's a good data point. > >3) Also, realize that the rectangular window "sinc" isn't optimum in >frequency in any particular way - regarding main lobe width or sidelobes. >So this one isn't interesting. > >4) The Dolph-Chebyshev window is an approximation to the van der Maas and >is physically realizable. So, presumably, this is the best you can do in >combination of main lobe width vs. side lobe level. > >5) All of the others have some nice properties of their own but are less >"good" in combination - wider main lobe / higher sidelobes - but perhaps >with rapid sidelobe decay, easy to compute, etc. Lyon's Figure 5-26 gives a >pretty good idea of what's possible in the minimax case. Everything else >will be "worse" in the strict main lobe / sidelobe comparison. Compare >Kaiser beta=4 to gamma=1.5 for Dolph-Chebyshev. The first sidelobes are >nearly the same and the Kaiser main lobe is wider... > >Fred > > > > >
"Rune Allnor" <allnor@tele.ntnu.no> wrote in message 
news:f56893ae.0409032307.5aa7d4d9@posting.google.com...
> "Eric Backus" <eric_backus@alum.mit.edu> wrote in message > news:<1094239880.872470@cswreg.cos.agilent.com>... >> "Rick Lyons" <r.lyons@_BOGUS_ieee.org> wrote in message >> news:41365058.204625031@news.sf.sbcglobal.net... > >> > Anyway, I'm thinking that there are two different types of >> > symmetry: "linear symmetry" and "DFT symmetry". And >> > that window functions should always be "DFT Symmetric". >> > And maybe I should change the equations in my book with >> > regard to the Hanning and Hamming windows. >> >> You are exactly correct. This is one of the subtle points about data >> windows that few (if any) textbooks talk about. If your purpose is to >> window data before doing a DFT, you want the window equation to use >> divide-by-N, the one you call "DFT Symmetric". One reason you want this >> is >> that it gives the expected line spectrum when given input data that is >> periodic within the input blocksize. > > OK... you present a very subtle point here, that I haven't really thought > about. My instant reaction is that the reason for using windoes is exactly > to "smear" the spectra they operate on, be it the smoothing of the > periodogram or suppresion of side lobes in FIR filters. The one effect > one does *not* want from a window function, is that the spectrum > degenerates to just a few non-zero coefficients. Designing a window as > a cosine over one period plus one sample, is a very neat way to achieve > this "non-degenerate" spectrum.
I think we all agree that the spectrum resulting from windowing a block of data is the convolution of (un-windowed spectrum) with (spectrum of the window). If the window is composed of a sum-of-cosines, and the periods of those cosines match the DFT blocksize, then the spectrum of the window itself is a line spectrum with the lines showing the magnitudes of the cosine terms. In many cases this doesn't matter much, but in the special case where the input data is also periodic in the DFT blocksize, the spectrum of the windowed input data is another line spectrum. This is sometimes a useful property.
>> Note that in this case, N is usually >> an even number, and you want the window to be symmetric around the N/2+1 >> sample rather than symmetric around N/2+0.5, so that you don't introduce >> a >> phase ramp into your frequency spectrum. > > Even or odd symmetry does not play a part in introducing the phase lag, > except for determining exactly how much of a phase lag is introduced.
Well, that is true, but having the phase lag be an integral number of samples is sometimes a useful property.
> I can think of two reasons to use window functions. The first is in FIR > filter design, which is the main subject of this thread. The second is > for smoothing the periodogram in spectrum estimation.
For the most part, I think suppression of sidelobes is more important and desirable than smoothing. When designing windows, there is generally a trade-off between the amount of sidelobe suppression and the width of the window main lobe. Usually you try to minimize the width of the main lobe (which *minimizes* the smoothing) for a given amount of sidelobe suppression. -- Eric Backus R&D Design Engineer Agilent Technologies, Inc. 425-356-6010 Tel
"Jerry Avins" <jya@ieee.org> wrote in message
news:4138af32$0$19728$61fed72c@news.rcn.com...
> Fred Marshall wrote: > > > "Jerry Avins" <jya@ieee.org> wrote in message > > news:4138592b$0$19725$61fed72c@news.rcn.com... > > > >>Fred Marshall wrote: > >> > >>> > >>>Jerry, > >>> > >>>If the end points are zero then you need to use them. And, the results > > > > are > > > >>>not the same. > >>> > >>>That is, if I understand you: > >>> > >>>a) Calculate an N+2 window with zero end points and throw out both zero > > > > end > > > >>>points to get a length N window. > >>> > >>>b) Calculate an N+1 window with zero end points and throw out one zero > > > > (the > > > >>>N+1th) end point to get a length N window. > >>> > >>>In a, there are no zero end points at all. > >>>In b, there is a zero on the first point and an assumed zero on the > > > > N+1th > > > >>>point. > >>>So, they are different. > >>> > >>>Fred > >>>But, you will drop one of them because it occurs on the N+1th == the > > > > first > > > >>>location (repeats). > >> > >>Let's stay with the non-circular symmetric case. I collect N samples and > >>window them to prepare for a DFT with a window of length N. The first > >>and last window coefficients are zero, so the first and last samples > >>that the N-point DFT operates on are zero. Except for the bin spacing, I > >>will get the same results by discarding the end samples and running an > >>(N-2)-point DFT. Why did I bother to collect those samples? > > > > > > Jerry, > > > > I think we're talking about two different things. And, the second
sentence
> > above isn't really proper - which is what we *are* talking about I
think. I
> > suppose we've all done what you describe, but it isn't really proper I > > believe - Rick's point. > > > > What's (I think) proper is to prepare for a DFT with a window of length
N+1
> > and drop the last sample in the window to apply it to a sequence of
length N
> > and do a DFT of length N. > > (I have said nothing about zeros at the ends one way or another). > > And, this has nothing to do with efficiency or collecting samples, just > > plain proper math. > > > > Now, if you want to say that a particular window is going to have zeros
at
> > the ends, then you could collect one fewer sample - the first one - and
pad
> > a single zero at the beginning of the array
beforedoingtheDFT.Whichever
> > is best for your situation is fine. > > > > > >>Conversely: I use a window of length N+2, discarding the zero end > >>points. After applying the truncated window to the data, I pad the > >>result with a zero at each end, achieving what is indistinguishable from > >>what would be had starting with N+2 samples. Where did those two free > >>samples come from? They ain't no free lunch. Those samples were there > >>all along; this time, I didn't throw them away. > > > > > > You start with the idea that there will be an N+2 point DFT, right? > > I prefer to keep the DFT at N points just to keep apples to apples. > > So, then is this what you're saying: > > > > > >>Conversely: I use a window of length N [that has zero end points), > >>discarding the zero end points. > >>After applying the truncated window to the data, I pad the > >>result with a zero at each end, achieving what is indistinguishable from > >>what would be had starting with N samples. Where did those two free > >>samples come from? They ain't no free lunch. Those samples were there > >>all along; this time, I didn't throw them away. > > > > > > It's the same deal. You would compute a window of length *N+1* [that
has
> > zero end points] discarding one end point for an apparently asymmetrical > > window (Rick's point). Now you have a window of length N, that has a > > starting point of zero, to be applied to a data sequence of length N .
If
> > you would like to not capture the first sample or multiply by zero,
either
> > one, and pad the sequence with a zero at the beginning - th
at'sfine.It
> > doesn't change the fact that you need to compute the window to be one
sample
> > longer than the data and truncate the window by one sample before
applying
> > it. > > > > Fred > > I'm confused, but that's not new. Suppose I collect 65 samples, then pad > out to 128 for easy FFT. (I know don't have to, but I'm lazy.) I surely > don't want a window of length 128; that would be about as bad as no > window at all. It seems to me that I want to taper the significant > samples to zero at both ends -- or just outside them. I just don't see > how driving one end but not the other to zero makes sense here.
Jerry, We agree - if you're going to zero pad then the situation changes. In that case, the periodicity is longer than the non-zero part. In that case, I would apply the full window over the non-zero part. Still, I would caution that not all windows are zero at the edges. So, you don't want to throw out the ends of the window. What you want to do is apply a length N window to a length N sequence and then zero pad the result with M zero-valued samples - in principle. Now, if you do have a window with zero edges then you could do one of two things (at least): Have the windowed sequence of length N start with a zero value and end with a zero value plus the zero padding of M zero-valued samples - same as above. or Have the windowed sequence start with the first non-zero sample and then end with a zero value (length N-1) plus the zero padding of M as above, plus one zero-valued sample to bring the N-1 up to N. This is simply a one-sample rotation of the first case. Fred
Jerry Avins wrote:

> Stan Pawlukiewicz wrote: > >> Jon Harris wrote: > > ... > >>> That may be true, but the windowing technique can be very useful >>> when you need >>> to calculate filter coefficients "on the fly". Computationally, >>> it is much >>> simpler than the optimized methods. So while it might be >>> sub-optimal, I wouldn't say it is obsolete. >>> >>> >> >> Signal Processing with flies should be called FSP ;) > > The dyslexics among us sometimes store data in flies. > > Jerry
Sorry for the delayed question (holidays on the lake of Constance (Germany) were splendid!), but the food chain of curiosity seems to be closed-loop: I still want to know what OY! in the topic means! Is it another stroke of applied dyslexics, and should read OT instead, or is it just a personalized form which has to do with the last letter of JerrY ? Bernhard
Bernhard Holzmayer wrote:

> Jerry Avins wrote: > > >>Stan Pawlukiewicz wrote: >> >> >>>Jon Harris wrote: >> >> ... >> >> >>>>That may be true, but the windowing technique can be very useful >>>>when you need >>>>to calculate filter coefficients "on the fly". Computationally, >>>>it is much >>>>simpler than the optimized methods. So while it might be >>>>sub-optimal, I wouldn't say it is obsolete. >>>> >>>> >>> >>>Signal Processing with flies should be called FSP ;) >> >>The dyslexics among us sometimes store data in flies. >> >>Jerry > > > Sorry for the delayed question > (holidays on the lake of Constance (Germany) were splendid!), > but the food chain of curiosity seems to be closed-loop: > I still want to know what OY! in the topic means! > > Is it another stroke of applied dyslexics, and should read OT > instead, or is it just a personalized form which has to do with the > last letter of JerrY ? > > Bernhard
It started as a typo; T and Y are adjacent keys. Then I laughed at the shortening of "Oy Weh!" (spelled "oy, vay" in Yiddish transliteration to English) and decided to leave it. I apologize for the distraction. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Fred Marshall wrote:

> "Jerry Avins" <jya@ieee.org> wrote in message > news:4138af32$0$19728$61fed72c@news.rcn.com... > >>Fred Marshall wrote: >> >> >>>"Jerry Avins" <jya@ieee.org> wrote in message >>>news:4138592b$0$19725$61fed72c@news.rcn.com... >>> >>> >>>>Fred Marshall wrote: >>>> >>>> >>>>>Jerry, >>>>> >>>>>If the end points are zero then you need to use them. And, the results >>> >>>are >>> >>> >>>>>not the same. >>>>> >>>>>That is, if I understand you: >>>>> >>>>>a) Calculate an N+2 window with zero end points and throw out both zero >>> >>>end >>> >>> >>>>>points to get a length N window. >>>>> >>>>>b) Calculate an N+1 window with zero end points and throw out one zero >>> >>>(the >>> >>> >>>>>N+1th) end point to get a length N window. >>>>> >>>>>In a, there are no zero end points at all. >>>>>In b, there is a zero on the first point and an assumed zero on the >>> >>>N+1th >>> >>> >>>>>point. >>>>>So, they are different. >>>>> >>>>>Fred >>>>>But, you will drop one of them because it occurs on the N+1th == the >>> >>>first >>> >>> >>>>>location (repeats). >>>> >>>>Let's stay with the non-circular symmetric case. I collect N samples and >>>>window them to prepare for a DFT with a window of length N. The first >>>>and last window coefficients are zero, so the first and last samples >>>>that the N-point DFT operates on are zero. Except for the bin spacing, I >>>>will get the same results by discarding the end samples and running an >>>>(N-2)-point DFT. Why did I bother to collect those samples? >>> >>> >>>Jerry, >>> >>>I think we're talking about two different things. And, the second > > sentence > >>>above isn't really proper - which is what we *are* talking about I > > think. I > >>>suppose we've all done what you describe, but it isn't really proper I >>>believe - Rick's point. >>> >>>What's (I think) proper is to prepare for a DFT with a window of length > > N+1 > >>>and drop the last sample in the window to apply it to a sequence of > > length N > >>>and do a DFT of length N. >>>(I have said nothing about zeros at the ends one way or another). >>>And, this has nothing to do with efficiency or collecting samples, just >>>plain proper math. >>> >>>Now, if you want to say that a particular window is going to have zeros > > at > >>>the ends, then you could collect one fewer sample - the first one - and > > pad > >>>a single zero at the beginning of the array > > beforedoingtheDFT.Whichever > >>>is best for your situation is fine. >>> >>> >>> >>>>Conversely: I use a window of length N+2, discarding the zero end >>>>points. After applying the truncated window to the data, I pad the >>>>result with a zero at each end, achieving what is indistinguishable from >>>>what would be had starting with N+2 samples. Where did those two free >>>>samples come from? They ain't no free lunch. Those samples were there >>>>all along; this time, I didn't throw them away. >>> >>> >>>You start with the idea that there will be an N+2 point DFT, right? >>>I prefer to keep the DFT at N points just to keep apples to apples. >>>So, then is this what you're saying: >>> >>> >>> >>>>Conversely: I use a window of length N [that has zero end points), >>>>discarding the zero end points. >>>>After applying the truncated window to the data, I pad the >>>>result with a zero at each end, achieving what is indistinguishable from >>>>what would be had starting with N samples. Where did those two free >>>>samples come from? They ain't no free lunch. Those samples were there >>>>all along; this time, I didn't throw them away. >>> >>> >>>It's the same deal. You would compute a window of length *N+1* [that > > has > >>>zero end points] discarding one end point for an apparently asymmetrical >>>window (Rick's point). Now you have a window of length N, that has a >>>starting point of zero, to be applied to a data sequence of length N . > > If > >>>you would like to not capture the first sample or multiply by zero, > > either > >>>one, and pad the sequence with a zero at the beginning - th > > at'sfine.It > >>>doesn't change the fact that you need to compute the window to be one > > sample > >>>longer than the data and truncate the window by one sample before > > applying > >>>it. >>> >>>Fred >> >>I'm confused, but that's not new. Suppose I collect 65 samples, then pad >>out to 128 for easy FFT. (I know don't have to, but I'm lazy.) I surely >>don't want a window of length 128; that would be about as bad as no >>window at all. It seems to me that I want to taper the significant >>samples to zero at both ends -- or just outside them. I just don't see >>how driving one end but not the other to zero makes sense here. > > > Jerry, > > We agree - if you're going to zero pad then the situation changes. > > In that case, the periodicity is longer than the non-zero part. > In that case, I would apply the full window over the non-zero part. > > Still, I would caution that not all windows are zero at the edges. So, you > don't want to throw out the ends of the window. > What you want to do is apply a length N window to a length N sequence and > then zero pad the result with M zero-valued samples - in principle. > > Now, if you do have a window with zero edges then you could do one of two > things (at least): > Have the windowed sequence of length N start with a zero value and end with > a zero value plus the zero padding of M zero-valued samples - same as above. > or > Have the windowed sequence start with the first non-zero sample and then end > with a zero value (length N-1) plus the zero padding of M as above, plus one > zero-valued sample to bring the N-1 up to N. This is simply a one-sample > rotation of the first case.
Fred, What I would do without thinking is pad my 65 samples with a single zero at each end, apply a 67-point window, then pad with the additional 61 points to get up to 128. That works whether the window is zero at the end points or not. Now that you've encouraged me to think, I don't know what I would do. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Jerry Avins" <jya@ieee.org> wrote in message
news:41385dd5$0$19718$61fed72c@news.rcn.com...
> Fred Marshall wrote: > > > "Rune Allnor" <allnor@tele.ntnu.no> wrote in message > > news:f56893ae.0409020113.3692a8c0@posting.google.com... > > > >>r.lyons@_BOGUS_ieee.org (Rick Lyons) wrote in message > > > > news:<41365058.204625031@news.sf.sbcglobal.net>... > > > >>>The DFT of Eq. [1]'s w1(n) is neither real-only nor does > >>>it's freq-domain samples have the correct amplitudes. > >>> > >>>I now think the correct N-point Hamming equation > >>>should be: > >>> > >>>w2(n) = 0.54 - 0.46*cos(2*pi*n/(N)) [2] > >>>for n = 0,1,2,...,N-1. > >>> > >>>If you plot w2(n) in the time domain it does not "look > >>>symmetric". The w2(n) sequence's first and last samples > >>>are not equal. But the DFT of Eq. [2]'s w2(n) is real-only > >>>and it's freq-domain samples do have the correct amplitudes > >>>(0.23N, 0.54N, and 0.23N). > >>> > >>>I want to call w2(n) "DFT symmetric", because if we circularize > >>>(is that a word) it, by repeating it over and over, making > >>>it periodic, then it becomes symmetrical. > >> > >>It's lunchtime and my head is not quite as foggy as when I made my > >>first attempt at answering your post this morning: > >> > >>Should't you use a N-1 pt DFT and leave one end-point out of it? > >> > >>If so, the formulas are correct, and the end points of the windows > >>appear twice in an analysis where they should appear only once. > >> > >>Could this account for the apparent error? > > > > > > Yes. As you say: In a normal N-point FFT we are assuming that the first > > input sample is repeated at N+1. The resulting FFT has the same
property ->
> > N samples with the N+1th sample assumed to be the same as the first. > > > > We would similarly view a window as being periodic with the N+1th point
the
> > same as the first. So, for the window to be symmetric it would have N+1 > > symmetrical points with the N+1th point removed (and assumed). > > > > Fred > > Early in my exploration of DSP, I did a paper design of a windowed > Hilbert Transformer with an odd number of taps (so there would be a > middle tap for matching pure delay). The ripple increases toward the > band edges. To get symmetric ripple, I needed the window's end values to > be the same. Are you saying that filter coefficients and measured data > need to be windowed differently? I'm asking, not maintaining a position. > > The argument about the (N+1)st sample repeating the first (I would have > written the Nth repeating the zeroeth) is persuasive, but what happens > with zero padding?
With zero padding it's different because the assumed period is longer than the length of the window. Thus, the entire window would be captured *within* the sequence and no part of it repeated. Let's think about windows that are *not* zero at the ends. Then it's easier to think about what crimes are committed. A raised cosine on a pedestal or gate is a good example. If we start with N samples that are to be windowed. Then we'd compute a length N+1 window and truncate by 1 sample - as we've been discussing. As long as we stay with N samples, then the sequence is a consistent periodic function. If we start with N samples that are to be windowed and to be zero padded, then we would compute a length N window and apply it on the nonzero data sequence. One might ask: "Why is there a difference in the actual window applied between taking N samples and N samples zero padded?" In the one case, the periodicity in frequency will occur at intervals of 1/T samples with spacing 1/N: First point at index zero. Last point at index N-1. Total points: N Repeats at index N at 1/T with the same value as at index zero. In the latter case, the periodicity in frequency occurs at intervals of 1/T with spacing of 1/(N+M) samples: Fist point at index zero. Nth point at index N-1. Last point at index N-1+M. Total points N+M Repeats at index N+M at 1/T with the same value as at index zero. Simple cases: Case 1 even data Window [1/2 1 1/2] N+1=3 Truncated window [ 1/2 1 ] N=2 Data: [1 1] N=2 Periodic data: [1/2 1 1/2 1 1/2 1 ...... ] Case 2 odd data Window [1/2 1 1 1/2] N+1=4 Truncated window [ 1/2 1 1] N=3 Data: [1 1 1] N=3 Periodic data: [1/2 1 1 1/2 1 1 1/2 ...... ] Case 3 even data padded Window [1/2 1 1/2] N+1=3 Truncated window [ 1/2 1 ] N=2 Data: [1 1] N=2 Padded data: [ 1 1 0 0] M=2 Periodic data: [1/2 1 0 0 1/2 1 ...... ] which doesn't make sense to do Case 4 odd data padded Window [1/2 1 1 1/2] N+1=4 Truncated window [ 1/2 1 1] N=3 Data: [1 1 1] N=3 Padded data: [1 1 1 0 0 0] Periodic data: [1/2 1 0 0 0 1/2 1 1 0 ...... ] which also doesn't make sense to do. The obvious conclusion is that the window needs to be a different length if one is going to zero-pad the *same* data as follows: Case 5 even data padded: Window [1/2 1/2] N=2 (instead of N=3) Truncated window (does not apply) Data: [1 1] N=2 (as before) Padded data: [ 1 1 0 0] M=2 Periodic data: [1/2 1/2 0 0 1/2 1/2 ...... ] Case 6 odd data padded: Window [1/2 1 1/2] N=3 (instead of N=4) Truncated window (does not apply) Data: [1 1 1] N=3 Padded data: [1 1 1 0 0 0] Periodic data: [1/2 1 1/2 0 0 0 1/2 1 1/2 0 0 0 ...... ] So, if zero padding is going to be used, the calculated window should be the same length as the data. If zero padding isn't going to be used, the calculated window should be 1 longer than the data and truncated. I think this makes sense.... Fred