Discussion:
Zero-padding in PWELCH
(too old to reply)
Chris Shooner
2006-06-26 20:48:14 UTC
Permalink
As I understand, the function PWELCH does a discrete Fourier analysis
on each segment of the input and averages for a final result. The
question is if the input parameter NFFT specifies the number of
points used in each of these FFT's.

It is unclear from the help documentation if the smaller segments are
zero padded to reach the length of NFFT, or rather the entire record
length.
Jay Holden
2006-07-03 02:11:59 UTC
Permalink
Post by Chris Shooner
As I understand, the function PWELCH does a discrete Fourier
analysis
on each segment of the input and averages for a final result. The
question is if the input parameter NFFT specifies the number of
points used in each of these FFT's.
It is unclear from the help documentation if the smaller segments are
zero padded to reach the length of NFFT, or rather the entire
record
length.
I agree the documentation is a bit vague. My experience with pwelch
suggests that if you use an integer power of 2 input, and specify
NFFT and Noverlap as even multipules of that power of two, you get
back an appropriate number of frequencies, which indicates no zero
padding. However, you can run simple checks that show if you put in
very short series, e.g. zeros(38,1), you get back 129 coefficents
even when specifying a 'onsided' fft. So there must be zeropadding
going on in that case. 2000 zeros produces 257 frequencies, 1025
frequencies produces 129 frequencies. So apparently, it depends...

Not an authoritative answer, I hope it is helpful
Jay
Rune Allnor
2006-07-03 05:40:43 UTC
Permalink
Post by Chris Shooner
As I understand, the function PWELCH does a discrete Fourier analysis
on each segment of the input and averages for a final result. The
question is if the input parameter NFFT specifies the number of
points used in each of these FFT's.
It is unclear from the help documentation if the smaller segments are
zero padded to reach the length of NFFT, or rather the entire record
length.
Computing the power spectrum of one long data record by Welch's
method, is based on averaging the periodograms of several sub-records
of the data set. For instance, if you have a data set with N = 2048
samples and specify NFFT = 512 and overlap 256, you will have K = 7
sub-records to work with.

One could imagine that one specifies a window length NW and NFFT
separately, in which case NW = 512 above. In this case one could
zero-pad each sub-record to, say, 1024 points. I am not sure why
one would want to do that, though.

The way I understand the documentation of PWELCH, the factor
NFFT defines the window length of the sub-records. The default
seems to be that the sequence is divided into eight sub-records,
the length of which depend on the total length N. In my interpretation,

NFFT determines the number of frequency bins in the PSD estimate.

Having said that, the documentation is of little help unless one
has a bit of prior insight into Welch's method.

Rune
ralphs
2006-07-03 08:13:05 UTC
Permalink
Post by Rune Allnor
Post by Chris Shooner
As I understand, the function PWELCH does a discrete Fourier analysis
on each segment of the input and averages for a final result. The
question is if the input parameter NFFT specifies the number of
points used in each of these FFT's.
It is unclear from the help documentation if the smaller segments are
zero padded to reach the length of NFFT, or rather the entire record
length.
Computing the power spectrum of one long data record by Welch's
method, is based on averaging the periodograms of several sub-records
of the data set. For instance, if you have a data set with N = 2048
samples and specify NFFT = 512 and overlap 256, you will have K = 7
sub-records to work with.
One could imagine that one specifies a window length NW and NFFT
separately, in which case NW = 512 above. In this case one could
zero-pad each sub-record to, say, 1024 points. I am not sure why
one would want to do that, though.
The way I understand the documentation of PWELCH, the factor
NFFT defines the window length of the sub-records. The default
seems to be that the sequence is divided into eight sub-records,
the length of which depend on the total length N. In my interpretation,
NFFT determines the number of frequency bins in the PSD estimate.
Having said that, the documentation is of little help unless one
has a bit of prior insight into Welch's method.
Rune
The parameter NFFT does NOT define the window length of the subrecord.
The length ist defined by the parameter WINDOW. Either as a positiv
integer (the window lengt of the Hamming window) or as a vector (the
window weights specified in this vector). This subrecord defined by
WINDOW is now transformed by FFT with the length NFFT. If you omit the
NFFT parameter, the length N of the FFT is the larger of 256 and the
next power of 2 greater than the length of the WINDOW.

Ralph
Rune Allnor
2006-07-03 09:30:21 UTC
Permalink
Post by ralphs
Post by Rune Allnor
Post by Chris Shooner
As I understand, the function PWELCH does a discrete Fourier analysis
on each segment of the input and averages for a final result. The
question is if the input parameter NFFT specifies the number of
points used in each of these FFT's.
It is unclear from the help documentation if the smaller segments are
zero padded to reach the length of NFFT, or rather the entire record
length.
Computing the power spectrum of one long data record by Welch's
method, is based on averaging the periodograms of several sub-records
of the data set. For instance, if you have a data set with N = 2048
samples and specify NFFT = 512 and overlap 256, you will have K = 7
sub-records to work with.
One could imagine that one specifies a window length NW and NFFT
separately, in which case NW = 512 above. In this case one could
zero-pad each sub-record to, say, 1024 points. I am not sure why
one would want to do that, though.
The way I understand the documentation of PWELCH, the factor
NFFT defines the window length of the sub-records. The default
seems to be that the sequence is divided into eight sub-records,
the length of which depend on the total length N. In my interpretation,
NFFT determines the number of frequency bins in the PSD estimate.
Having said that, the documentation is of little help unless one
has a bit of prior insight into Welch's method.
Rune
The parameter NFFT does NOT define the window length of the subrecord.
The length ist defined by the parameter WINDOW. Either as a positiv
integer (the window lengt of the Hamming window) or as a vector (the
window weights specified in this vector). This subrecord defined by
WINDOW is now transformed by FFT with the length NFFT. If you omit the
NFFT parameter, the length N of the FFT is the larger of 256 and the
next power of 2 greater than the length of the WINDOW.
So the window length is implicitly specified? I didn't know that (I
don't
use the SP toolbox myself). Maybe a cause for confusion...

Rune
ralphs
2006-07-04 05:58:41 UTC
Permalink
Post by Rune Allnor
Post by ralphs
Post by Rune Allnor
Post by Chris Shooner
As I understand, the function PWELCH does a discrete Fourier analysis
on each segment of the input and averages for a final result. The
question is if the input parameter NFFT specifies the number of
points used in each of these FFT's.
It is unclear from the help documentation if the smaller segments are
zero padded to reach the length of NFFT, or rather the entire record
length.
Computing the power spectrum of one long data record by Welch's
method, is based on averaging the periodograms of several sub-records
of the data set. For instance, if you have a data set with N = 2048
samples and specify NFFT = 512 and overlap 256, you will have K = 7
sub-records to work with.
One could imagine that one specifies a window length NW and NFFT
separately, in which case NW = 512 above. In this case one could
zero-pad each sub-record to, say, 1024 points. I am not sure why
one would want to do that, though.
The way I understand the documentation of PWELCH, the factor
NFFT defines the window length of the sub-records. The default
seems to be that the sequence is divided into eight sub-records,
the length of which depend on the total length N. In my interpretation,
NFFT determines the number of frequency bins in the PSD estimate.
Having said that, the documentation is of little help unless one
has a bit of prior insight into Welch's method.
Rune
The parameter NFFT does NOT define the window length of the subrecord.
The length ist defined by the parameter WINDOW. Either as a positiv
integer (the window lengt of the Hamming window) or as a vector (the
window weights specified in this vector). This subrecord defined by
WINDOW is now transformed by FFT with the length NFFT. If you omit the
NFFT parameter, the length N of the FFT is the larger of 256 and the
next power of 2 greater than the length of the WINDOW.
So the window length is implicitly specified? I didn't know that (I
don't
use the SP toolbox myself). Maybe a cause for confusion...
Rune
If you omit the parameter NFFT, the length N of the FFT is set as I
wrote above. If you specify the parameter NFFT, this value is used. But
NFFT must be equal or greater than the WINDOW length.

Ralph

Loading...