Dear all, we're using the Matlab implementation of Welch's periodogram for computing the Power Spectral Density (PSD) estimate of a discrete-time signal vector X: Pxx = = PWELCH(X,WINDOW,NOVERLAP,NFFT) As Rune pointed out in another thread (http://groups.google.com/group/ comp.dsp/browse_thread/thread/ae0f764dc5b01812/141fa5c63175c5ea? lnk=gst&q=welch+periodogram&rnum=3#141fa5c63175c5ea) 1) The "Welch method [...] uses windowing" 2) "Second, the Welch method chops the long data sequence into shorter subseries that may overlap with as much as 75%, and computes the (windowed) periodogram of each such subseries and averages all these subseries to produce the final PSD estimate." In Matlab NFFT appears to refer to the length of 1) and WINDOW to the length of 2), and NOVERLAP to the number of overlapping data points of the WINDOW. Matlab help further states, that the default for NFFT is the larger one of either 256 or the the next power of two greater than WINDOW. Given a WINDOW of 512, this would result in 2^9=512. Could anyone explain to me, if (and why) there are (reasonable) upper vs. lower limits for NFFT, an why the default may be teh best choice (if it is)? This is the most important information I need to find out about. However, if you can spare the time I'd appreciate help for some additional questions I have: 1) Choosing WINDOW larger than the length of X is resolved by zero- padding in Matlab. I read in another posting, that this could attenuate the PSD. Is this correct? Should I therefore avoid it? I thought zero padding to allow WINDOW being the next greater power of 2 which is greater then the length of X is a good idea to enhance efficiency? 2) Choosing WINDOW too small may result in a loss of power in the low frequency range - right? To avoid this, I make WINDOW no smaller than required by the Nyquist theorem - right? 3) Is there a specifc advantage of using a 50% overlap over using other percentages? Thanks much!! Stefan
Welch's periodogram - recommended window size
Started by ●August 8, 2007
Reply by ●August 9, 20072007-08-09
On Aug 8, 9:53 am, kommun...@gmail.com wrote:> Dear all, > we're using the Matlab implementation of Welch's periodogram for > computing the Power Spectral Density (PSD) estimate of a discrete-time > signal vector X: Pxx = = PWELCH(X,WINDOW,NOVERLAP,NFFT) > > As Rune pointed out in another thread (http://groups.google.com/group/ > comp.dsp/browse_thread/thread/ae0f764dc5b01812/141fa5c63175c5ea? > lnk=gst&q=welch+periodogram&rnum=3#141fa5c63175c5ea) > > 1) The "Welch method [...] uses windowing" > 2) "Second, the Welch method chops the long data sequence into shorter > subseries that may overlap with as much as 75%, and computes the > (windowed) periodogram of each such subseries and averages all > these subseries to produce the final PSD estimate." > > In Matlab NFFT appears to refer to the length of 1) and WINDOW to the > length of 2), and NOVERLAP to the number of overlapping data points of > the WINDOW. > Matlab help further states, that the default for NFFT is the larger > one of either 256 or the the next power of two greater than WINDOW. > Given a WINDOW of 512, this would result in 2^9=512. > > Could anyone explain to me, if (and why) there are (reasonable) upper > vs. lower limits for NFFT, an why the default may be teh best choice > (if it is)? > > This is the most important information I need to find out about. > However, if you can spare the time I'd appreciate help for some > additional questions I have: > > 1) Choosing WINDOW larger than the length of X is resolved by zero- > padding in Matlab. I read in another posting, that this could > attenuate the PSD. Is this correct? Should I therefore avoid it? I > thought zero padding to allow WINDOW being the next greater power of 2 > which is greater then the length of X is a good idea to enhance > efficiency? > > 2) Choosing WINDOW too small may result in a loss of power in the low > frequency range - right? To avoid this, I make WINDOW no smaller than > required by the Nyquist theorem - right? > > 3) Is there a specifc advantage of using a 50% overlap over using > other percentages? > > Thanks much!! > StefanA better source for how to use fft sizes, weightings and overlap than a Matlab function definition might be technical literature from a manufacturer of fft instrumentation (sometimes not). Take a look at: http://www.bksv.com/pdf/bv0031.pdf and http://www.bksv.com/pdf/Bv0032.pdf Dale B. Dalrymple http://dbdimages.com
Reply by ●August 9, 20072007-08-09
On Aug 9, 7:30 am, dbd <d...@ieee.org> wrote:> On Aug 8, 9:53 am, kommun...@gmail.com wrote: > > > > > Dear all, > > we're using the Matlab implementation of Welch's periodogram for > > computing the Power Spectral Density (PSD) estimate of a discrete-time > > signal vector X: Pxx = = PWELCH(X,WINDOW,NOVERLAP,NFFT) > > > As Rune pointed out in another thread (http://groups.google.com/group/ > > comp.dsp/browse_thread/thread/ae0f764dc5b01812/141fa5c63175c5ea? > > lnk=gst&q=welch+periodogram&rnum=3#141fa5c63175c5ea) > > > 1) The "Welch method [...] uses windowing" > > 2) "Second, the Welch method chops the long data sequence into shorter > > subseries that may overlap with as much as 75%, and computes the > > (windowed) periodogram of each such subseries and averages all > > these subseries to produce the final PSD estimate." > > > In Matlab NFFT appears to refer to the length of 1) and WINDOW to the > > length of 2), and NOVERLAP to the number of overlapping data points of > > the WINDOW. > > Matlab help further states, that the default for NFFT is the larger > > one of either 256 or the the next power of two greater than WINDOW. > > Given a WINDOW of 512, this would result in 2^9=512. > > > Could anyone explain to me, if (and why) there are (reasonable) upper > > vs. lower limits for NFFT, an why the default may be teh best choice > > (if it is)? > > > This is the most important information I need to find out about. > > However, if you can spare the time I'd appreciate help for some > > additional questions I have: > > > 1) Choosing WINDOW larger than the length of X is resolved by zero- > > padding in Matlab. I read in another posting, that this could > > attenuate the PSD. Is this correct? Should I therefore avoid it? I > > thought zero padding to allow WINDOW being the next greater power of 2 > > which is greater then the length of X is a good idea to enhance > > efficiency? > > > 2) Choosing WINDOW too small may result in a loss of power in the low > > frequency range - right? To avoid this, I make WINDOW no smaller than > > required by the Nyquist theorem - right? > > > 3) Is there a specifc advantage of using a 50% overlap over using > > other percentages? > > > Thanks much!! > > Stefan > > A better source for how to use fft sizes, weightings and overlap than > a Matlab function definition might be technical literature from a > manufacturer of fft instrumentation (sometimes not). > > Take a look at:http://www.bksv.com/pdf/bv0031.pdf > andhttp://www.bksv.com/pdf/Bv0032.pdf > > Dale B. Dalrymplehttp://dbdimages.comHi Dale, thanks! That's intresting stuff. However, I couldn't find much on fft size (i.e. WINDOW in my original post). I may also mention, that I'm a psychologist. So the books are a bit advanced for my poor understanding of the matter :( I found a few bits on overlapping (with regards to Hanning windows, which is what we are using). However, I found it more confusing than helpful. Also there was no explanation of advantages of a 50% overlap (besides the arguement that it speeds up the computation wihtout a loss of "confidence in the results". However speed is not a problem with the small data-sets we're using). Other hints on overlapping included the recommendation of 2/3 (=> largest bandwith in the analysis) and 75% overlap (=> recommended for transients [is this equivalent to WINDOW??] longer than the record length). However, I'm not sure if these criteria are important with my data. What we try to do is spectroanalysis of heart-rate-variability. This means, we record some minutes of EKG-data, next we compute time-stamps for each heart-beat. Then we resample/interpolate the data in order to get data with equal time steps for each entry in the data vector. This is submitted to fft. Typically a frequency range of 0.00001 to 0.4 Hz is of interest (chopped up into several sub-ranges). What I really would like to understand is, how to choose the size of WINDOW (fft size) and NFFT (the size of the subseries). What are the criteria? I believe key is to understand why the results change if I change these values, but that's just my current idea, and the reason why I started my question the way I did... Thanks much for additional help! Stefan ((P.S: sorry Dale for posting to you directly before))
Reply by ●August 9, 20072007-08-09
Hi Stefan, The key idea of Welch's method is to average the PSDs obtained for each data segment in a data sequence, therefore, the two most important parameters here are the length of the data segment and the overlap. The length of the data segment is specified in WINDOW because you may want to apply a window to each data segment. The length of the overlap is specified in NOVERLAP. It is important to understand how these two parameters affect your final result. First, because you are breaking the entire sequence into small data segments, the final PSD resolution is determined by the length of each data segment. Therefore, finer resolution requires longer data segment (or window). On the other hand, the number of overlap determines how many data segments you can obtain from the original sequence. For example, considering a 100 samples data sequence, if each data segment is 50 samples, then with no overlap, you can only average between two PSDs. If you choose to overlap 50%, then you can then average over three PSDs. More averaging reduces the error variance of the final PSD resolution. Of course, for a given overlap percentage, longer data segments also implies less number of averaging. As you noticed that normally the overlap is less than 75%. Since more averaging means smaller error variance in the final estimates, why don't we just increase the overlap percentage to, say, 90%? There are two reasons behind this. The first one is a practical concern, since more overlap means more calculation. The second one is more important. The reason that averaging reduces the error variance is based on the assumption that samples that get averaged are uncorrelated. If we are going to overlap the two segments by 90%, then they are essentially the same, and the averaging then can no longer effectively reduce the error variance. As to NFFT, that is just the size of FFT for each data segment. It determines the number of samples in your final PSD, but does not determine the resolution of your final PSD. If your data segment is 140 pts, then the resolution of PSD is determined by the number of 140. The NFFT being 256 just (1) makes the computation more efficient and (2) makes your final estimates of PSD look smoother. As you can see, there is a trade off between less error variance and finer resolution depending how you choose WINDOW and NOVERLAP. The default implemented in pwelch is not guaranteed to be a best choice for all cases. It merely gives you a starting point. You may also want to check the following references regarding these issues: [1] Hayes, Statistical Digital Signal Processing and Modeling, 1996 [2] Kay, Modern Spectral Estimation, 1988 HTH, Honglei <kommunaut@gmail.com> wrote in message news:1186592015.126907.53730@57g2000hsv.googlegroups.com...> Dear all, > we're using the Matlab implementation of Welch's periodogram for > computing the Power Spectral Density (PSD) estimate of a discrete-time > signal vector X: Pxx = = PWELCH(X,WINDOW,NOVERLAP,NFFT) > > As Rune pointed out in another thread (http://groups.google.com/group/ > comp.dsp/browse_thread/thread/ae0f764dc5b01812/141fa5c63175c5ea? > lnk=gst&q=welch+periodogram&rnum=3#141fa5c63175c5ea) > > 1) The "Welch method [...] uses windowing" > 2) "Second, the Welch method chops the long data sequence into shorter > subseries that may overlap with as much as 75%, and computes the > (windowed) periodogram of each such subseries and averages all > these subseries to produce the final PSD estimate." > > In Matlab NFFT appears to refer to the length of 1) and WINDOW to the > length of 2), and NOVERLAP to the number of overlapping data points of > the WINDOW. > Matlab help further states, that the default for NFFT is the larger > one of either 256 or the the next power of two greater than WINDOW. > Given a WINDOW of 512, this would result in 2^9=512. > > Could anyone explain to me, if (and why) there are (reasonable) upper > vs. lower limits for NFFT, an why the default may be teh best choice > (if it is)? > > This is the most important information I need to find out about. > However, if you can spare the time I'd appreciate help for some > additional questions I have: > > 1) Choosing WINDOW larger than the length of X is resolved by zero- > padding in Matlab. I read in another posting, that this could > attenuate the PSD. Is this correct? Should I therefore avoid it? I > thought zero padding to allow WINDOW being the next greater power of 2 > which is greater then the length of X is a good idea to enhance > efficiency? > > 2) Choosing WINDOW too small may result in a loss of power in the low > frequency range - right? To avoid this, I make WINDOW no smaller than > required by the Nyquist theorem - right? > > 3) Is there a specifc advantage of using a 50% overlap over using > other percentages? > > Thanks much!! > Stefan >
Reply by ●August 9, 20072007-08-09
"Honglei Chen" <hchen@mathworks.com> wrote in news:f9fdcs$fs8$1@fred.mathworks.com:> As to NFFT, that is just the size of FFT for each data segment. It > determines the number of samples in your final PSD, but does not > determine the resolution of your final PSD. If your data segment is > 140 pts, then the resolution of PSD is determined by the number of > 140. The NFFT being 256 just (1) makes the computation more efficient > and (2) makes your final estimates of PSD look smoother.Doesn't the size of the PSD dictate the resolution of the frequency scale?? As a quick aside, Matlab uses FFTW, and powers of two are not necessary more efficient. -- Scott Reverse name to reply
Reply by ●August 9, 20072007-08-09
On Aug 9, 3:38 am, kommun...@gmail.com wrote:> ... > What I really would like to understand is, how to choose the size of > WINDOW (fft size) and NFFT (the size of the subseries). What are the > criteria? > I believe key is to understand why the results change if I change > these values, but that's just my current idea, and the reason why I > started my question the way I did... > Thanks much for additional help! > Stefan >...It can be useful to consider the processing as described by three independent terms: 1) Transform size - the size in samples of the FFT calculated 2) Window size - the size in samples of the (possibly non-uniformly weighted) data set to be analyzed by each FFT calculated 3) Stride - the distance in samples between the starting sample of consecutive window size data blocks. (Stride is transform size minus overlap in samples. Overlap in samples is overlap percent times transform size / 100. The point of using stride is that it is independent of transform size.) If the transform size is greater than the window size, zeros are used to fill out the FFT input vector. If the window size is greater than the transform size the data is 'folded'. This is what is done in polyphase FFT filterbanks. One way of looking at this data segmenting/weighting/transforming process is as filter bank where each FFT bin is a filter output. Each filter frequency response is the DFT of the window weighting. In the filterbank interpretation of this process, the stride is the desampling ratio between the original sampling frequency and the sample rate of the output filter bins. Now to the question about sizes. (Considering, for the moment, the case of window size less than or equal to the transform size.) If the signal analyzed is a pure tone in broadband noise, scaling to a larger window and transform size puts less broadband noise energy in each bin and the same maximum possible signal energy in the peak bin. So, larger is better. But few sources of tones produce exactly pure tones. A common alternate assumption is that the signal is a narrowband noise in a broadband noise background. Here, if the bin filter width is made less than the narrowband noise width, the measurement SNR does not improve as the window size increases, but the number of independent measurements to be obtained from a fixed data set (or equivalently, in a time interval) drops. Since we average the independent measurements to reduce the variance of the measurement, we would like to have as many as possible. The best window length is the one that makes the filter bin response just match the shape of the narrowband noise. This can achieve the best measurement SNR and the most independent measurements to average. Notice I wrote: 'can achieve'. There is no promise that a bin center of your FFT will match the center of your narrowband signal. Calculating a larger FFT (even with the same window size) makes it more likely that a bin center will be close to your narrowband signal center, at the cost of more processing. One measure of error due to centers not matching is reported in the literature as 'scalloping loss'. When non-uniform data windows (non-rectangular) are used, we can reduce the variance of the estimate of the narrowband noise level by averaging additional bin outputs transformed from weighted data segments that overlap and are not completely independent. The dependence of overlapped data windows is reported in the literature as 'overlap correlation' by window type and overlap. The greater the 'overlap correlation' the less reduction in variance of the estimate of the energy of the narrowband component by averaging (for a given window size and stride). Why do we even bother with nonuniform weightings? Because, in practice, the signals we sample are even more complicated and so are our measurement goals. I hope this helps Stefan. Dale B. Dalrymple http://dbdimages.com
Reply by ●August 10, 20072007-08-10
On Aug 9, 8:59 am, Scott Seidman <namdiestt...@mindspring.com> wrote:> "Honglei Chen" <hc...@mathworks.com> wrote innews:f9fdcs$fs8$1@fred.mathworks.com: > > > As to NFFT, that is just the size of FFT for each data segment. It > > determines the number of samples in your final PSD, but does not > > determine the resolution of your final PSD. If your data segment is > > 140 pts, then the resolution of PSD is determined by the number of > > 140. The NFFT being 256 just (1) makes the computation more efficient > > and (2) makes your final estimates of PSD look smoother. > > Doesn't the size of the PSD dictate the resolution of the frequency scale??One can use either interpolation, or zero-pad the FFT, to produce any frequency scale one wants. However the degree of freedom of the the FFT spectrum is set by the number of actual samples transformed. Some people use the term "resolution" to mean the bin spacing of an FFT/DFT whose number of bins corresponds to this degree of freedom. Of course, one can interpolate isolated sinusoids, if they are assumed to be a component of the data, to estimate at a much higher "resolution" (using a different definition of the term) from an FFT. In any case, a typical implementation of Welch's method throws away information by summing magnitudes. However if, in addition to summing magnitudes, one also does linear regression and interpolation along the sequence of complex FFT results, higher resolution information about any composing sinusoids, or other very narrow band signals, may appear from the interpolation, while still allowing the regression results to reject noise more strongly as the number of frames increases. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M http://www.nicholson.com/rhn/dsp.html
Reply by ●August 10, 20072007-08-10
On Aug 10, 12:54 pm, "Ron N." <rhnlo...@yahoo.com> wrote:> On Aug 9, 8:59 am, Scott Seidman <namdiestt...@mindspring.com> wrote: > > > "Honglei Chen" <hc...@mathworks.com> wrote innews:f9fdcs$fs8$1@fred.mathworks.com: > > > > As to NFFT, that is just the size of FFT for each data segment. It > > > determines the number of samples in your final PSD, but does not > > > determine the resolution of your final PSD. If your data segment is > > > 140 pts, then the resolution of PSD is determined by the number of > > > 140. The NFFT being 256 just (1) makes the computation more efficient > > > and (2) makes your final estimates of PSD look smoother. > > > Doesn't the size of the PSD dictate the resolution of the frequency scale?? > > One can use either interpolation, or zero-pad the FFT, to > produce any frequency scale one wants. However the degree > of freedom of the the FFT spectrum is set by the number > of actual samples transformed. Some people use the term > "resolution" to mean the bin spacing of an FFT/DFT whose > number of bins corresponds to this degree of freedom. > Of course, one can interpolate isolated sinusoids, if they > are assumed to be a component of the data, to estimate at > a much higher "resolution" (using a different definition > of the term) from an FFT. > > In any case, a typical implementation of Welch's method > throws away information by summing magnitudes. However if, > in addition to summing magnitudes, one also does linear > regression and interpolation along the sequence of complex > FFT results,Actually, to correct myself, either a spiral regression and interpolation of the complex sequence, or a linear regression of the unwrapped phase is what's needed.> higher resolution information about any > composing sinusoids, or other very narrow band signals, > may appear from the interpolation, while still allowing > the regression results to reject noise more strongly as > the number of frames increases. > > IMHO. YMMV. > -- > rhn A.T nicholson d.0.t C-o-M > http://www.nicholson.com/rhn/dsp.html
Reply by ●August 10, 20072007-08-10
On Aug 10, 1:47 pm, "Ron N." <rhnlo...@yahoo.com> wrote:> On Aug 10, 12:54 pm, "Ron N." <rhnlo...@yahoo.com> wrote: > > > > > On Aug 9, 8:59 am, Scott Seidman <namdiestt...@mindspring.com> wrote: > > > > "Honglei Chen" <hc...@mathworks.com> wrote innews:f9fdcs$fs8$1@fred.mathworks.com: > > > > > As to NFFT, that is just the size of FFT for each data segment. It > > > > determines the number of samples in your final PSD, but does not > > > > determine the resolution of your final PSD. If your data segment is > > > > 140 pts, then the resolution of PSD is determined by the number of > > > > 140. The NFFT being 256 just (1) makes the computation more efficient > > > > and (2) makes your final estimates of PSD look smoother. > > > > Doesn't the size of the PSD dictate the resolution of the frequency scale?? > > > One can use either interpolation, or zero-pad the FFT, to > > produce any frequency scale one wants. However the degree > > of freedom of the the FFT spectrum is set by the number > > of actual samples transformed. Some people use the term > > "resolution" to mean the bin spacing of an FFT/DFT whose > > number of bins corresponds to this degree of freedom. > > Of course, one can interpolate isolated sinusoids, if they > > are assumed to be a component of the data, to estimate at > > a much higher "resolution" (using a different definition > > of the term) from an FFT. > > > In any case, a typical implementation of Welch's method > > throws away information by summing magnitudes. However if, > > in addition to summing magnitudes, one also does linear > > regression and interpolation along the sequence of complex > > FFT results, > > Actually, to correct myself, either a spiral regression > and interpolation of the complex sequence, or a linear > regression of the unwrapped phase is what's needed. > > > higher resolution information about any > > composing sinusoids, or other very narrow band signals, > > may appear from the interpolation, while still allowing > > the regression results to reject noise more strongly as > > the number of frames increases. > > > IMHO. YMMV. > > -- > > rhn A.T nicholson d.0.t C-o-M > > http://www.nicholson.com/rhn/dsp.htmlStationary tones are the ideal signals for FFT analysis. Many signals of interest are not stationary tones. If the deviation from stationarity is coherent, such as a linear FM, a slow amplitude modulation or a polynomial phase variation, and the signal is high SNR, coherent processes such as regression of the unwrapped phase give more information. When the deviation from stationarity is incoherent, the Welch method is appropriate and the Welch method is most accurate when the bin response matches the bandwidth of the signal. Dale B. Dalrymple http://dbdimages.com
Reply by ●August 10, 20072007-08-10
On Aug 10, 4:34 pm, dbd <d...@ieee.org> wrote:> On Aug 10, 1:47 pm, "Ron N." <rhnlo...@yahoo.com> wrote: > > > > > On Aug 10, 12:54 pm, "Ron N." <rhnlo...@yahoo.com> wrote: > > > > On Aug 9, 8:59 am, Scott Seidman <namdiestt...@mindspring.com> wrote: > > > > > "Honglei Chen" <hc...@mathworks.com> wrote innews:f9fdcs$fs8$1@fred.mathworks.com: > > > > > > As to NFFT, that is just the size of FFT for each data segment. It > > > > > determines the number of samples in your final PSD, but does not > > > > > determine the resolution of your final PSD. If your data segment is > > > > > 140 pts, then the resolution of PSD is determined by the number of > > > > > 140. The NFFT being 256 just (1) makes the computation more efficient > > > > > and (2) makes your final estimates of PSD look smoother. > > > > > Doesn't the size of the PSD dictate the resolution of the frequency scale?? > > > > One can use either interpolation, or zero-pad the FFT, to > > > produce any frequency scale one wants. However the degree > > > of freedom of the the FFT spectrum is set by the number > > > of actual samples transformed. Some people use the term > > > "resolution" to mean the bin spacing of an FFT/DFT whose > > > number of bins corresponds to this degree of freedom. > > > Of course, one can interpolate isolated sinusoids, if they > > > are assumed to be a component of the data, to estimate at > > > a much higher "resolution" (using a different definition > > > of the term) from an FFT. > > > > In any case, a typical implementation of Welch's method > > > throws away information by summing magnitudes. However if, > > > in addition to summing magnitudes, one also does linear > > > regression and interpolation along the sequence of complex > > > FFT results, > > > Actually, to correct myself, either a spiral regression > > and interpolation of the complex sequence, or a linear > > regression of the unwrapped phase is what's needed. > > > > higher resolution information about any > > > composing sinusoids, or other very narrow band signals, > > > may appear from the interpolation, while still allowing > > > the regression results to reject noise more strongly as > > > the number of frames increases. > > > > IMHO. YMMV. > > > -- > > > rhn A.T nicholson d.0.t C-o-M > > > http://www.nicholson.com/rhn/dsp.html > > Stationary tones are the ideal signals for FFT analysis. Many signals > of interest are not stationary tones. If the deviation from > stationarity is coherent, such as a linear FM, a slow amplitude > modulation or a polynomial phase variation, and the signal is high > SNR, coherent processes such as regression of the unwrapped phase give > more information. When the deviation from stationarity is incoherent, > the Welch method is appropriate and the Welch method is most accurate > when the bin response matches the bandwidth of the signal.If the modulation is incoherent, the statistical distribution about a regression fit to the phase may produce information allowing one to adaptively adjust the bin width to match the likely current bandwidth of the signal in question. And, I'm not sure about this, but it may also help one choose between various possible window functions. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M http://www.nicholson.com/rhn/dsp.html






