Richard Owlett wrote:> > jim wrote: > > > > Richard Owlett wrote: > > > >>What happens when signal frequency is *NOT* equal to center of bin? > > > > > > [snip] Fortunately, most of the energy will show > > up in the vicinity of the bin which has the closest frequency. > > > > > > That's what I THOUGHT I read. > Solves my problem as I'll looking at how the "average" energy in a > group of bins varies with time. Average in quotes as I may be able to > be lazy and do arithmetic rather than RMS.It is useful to consider how the DFT responds to mathematically perfect tones (especially to check if your implementation is working properly). But in real world signals you won't find mathematically perfect tones. As far as averaging bins: Any linear operation performed in the frequency domain has a corresponding linear operation in the time domain. Look up "DFT properties" to see what some of these paired operations are. One such operation pair is multiplication/convolution. So if you are talking about going through the DFT bins and for each bin replacing it with the average of the bins in that neighborhood, that is a convolution operation in the frequency domain. It is equivalent to multiplying the time domain by a window function. Multipling the data by a window function is a common way of dealing with spectral smearing/leakage. -jim -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Newbie asks "What's in a bin?"
Started by ●February 10, 2004
Reply by ●February 11, 20042004-02-11
Reply by ●February 11, 20042004-02-11
Hi Richard,> Some reference I read commented on "smear" between bins when signal > frequency was not identically equal to the center frequency of a bin.There's a really great section on this, with very instructive diagrams, in Richard Lyon's book "Understanding Digital Signal Processing". You may have had your question answered already, but it never hurts to hear something discussed from different angles. HTH Rick Armstrong (note: reply address is bogus)
Reply by ●February 12, 20042004-02-12
Hi Rune, I am get confused by your explanation of bin width and resolution. I am quoting your message. ------------------------------------------------------------------------- There is a practical difference between bin width and resolution. The bin width is related to the number N of samples in the data sequence you Fourier tranform. Each bin width in the DFT is fs/N where fs is the sampling frequency. It would be very convenient if we could state that the spectrum resolution is directly related to the bin width of the DFT, but it isn't. The phenomenon is demosntrated by zero padding, i.e. when a data sequence of original lengths M is expanded by appending zeros to make up a sequence of total length N > M. If you compute the DFT of this zero padded sequence, you will find that the bin width is fs/N, but the resolution, when understood as the ability to separate different spectrum lines, is related to fs/M. ------------------------------------------------------------------------ Each bin (index) in the frequency axis represents a frequency value. So more bins for a given signal gives more resolution. By zero padding, we are not introducing any new sample values, so we are not gaining any thing in the magnitude of the output spectrum. But we are evaluating the DFT on more points, i.e. on more valid frequency points. So some of the frequencies are undefined in the original case, are defined after zero padding. Consider a signal contains 24Hz, 25Hz and 26Hz components, which is sampled at fs = 128Hz. Take a 64 point DFT, and then 24Hz will be at 12th bin, 26Hz at the 13th bin and the 25Hz is smeared on these bins. Here the frequency resolution is fs/N = 2Hz. The same signal is zero padded with 64 zeros and takes the DFT. Now the resolution becomes fs/N = 1Hz. So the 24Hz, 25Hz and 26Hz are on 24th, 25th and 26th bin respectively. So by padding zeros we could differentiate 25Hz from 24Hz and 26Hz. (Before and after padding zeros, the signal contains 12 complete cycles of 24Hz, 12.5 cycles of 25Hz and 13 cycles of 26Hz - 64points in 128Hz sampling frequency corresponding to 0.5secs. So there will not be any gain in the amplitude spectrum due to zero padding). Am I missing something? regards ajith
Reply by ●February 12, 20042004-02-12
ajith_pc@yahoo.com (Ajith Kumar P C) wrote in message news:<18eae751.0402112334.2d3279e4@posting.google.com>...> Hi Rune, > > I am get confused by your explanation of bin width and resolution. I > am quoting your message. > > ------------------------------------------------------------------------- > There is a practical difference between bin width and resolution. > > The bin width is related to the number N of samples in the data > sequence > you Fourier tranform. Each bin width in the DFT is fs/N where fs is > the > sampling frequency. > > It would be very convenient if we could state that the spectrum > resolution is directly related to the bin width of the DFT, but it > isn't. The phenomenon is demosntrated by zero padding, i.e. when > a data sequence of original lengths M is expanded by appending zeros > to make up a sequence of total length N > M. If you compute the DFT > of this zero padded sequence, you will find that the bin width > is fs/N, but the resolution, when understood as the ability to > separate different spectrum lines, is related to fs/M. > ------------------------------------------------------------------------ > > Each bin (index) in the frequency axis represents a frequency value. > So more bins for a given signal gives more resolution. By zero > padding, we are not introducing any new sample values, so we are not > gaining any thing in the magnitude of the output spectrum. But we are > evaluating the DFT on more points, i.e. on more valid frequency > points.Agreed. Some people use the term "spectrum interpolation" here.> So some of the frequencies are undefined in the original case, > are defined after zero padding. Consider a signal contains 24Hz, > 25Hz and 26Hz components, which is sampled at fs = 128Hz. Take a 64 > point DFT, and then 24Hz will be at 12th bin, 26Hz at the 13th bin and > the 25Hz is smeared on these bins. Here the frequency resolution is > fs/N = 2Hz. The same signal is zero padded with 64 zeros and takes the > DFT. Now the resolution becomes fs/N = 1Hz. So the 24Hz, 25Hz and 26Hz > are on 24th, 25th and 26th bin respectively. So by padding zeros we > could differentiate 25Hz from 24Hz and 26Hz.I don't know how you achieve this. When I do the 64 pt DFT I can see a broad feature with two sharp peaks around 25 Hz. I can see that in the zero-padded sequence as well. I am not capable of identifying three separate components in any of the plots. Compare with the DFT of 256 data samples, where you clearly separate the broad feature as three separate lines (watch out for the vanishing coefficients in the bins at 24.5 Hz and 25.5 Hz). The term "spectral resolution" is often used for the ability to resolve two close spectral lines as distinct. It is closely related to the Time-Bandwidth product and the Heisenberg inequality.>(Before and after padding > zeros, the signal contains 12 complete cycles of 24Hz, 12.5 cycles of > 25Hz and 13 cycles of 26Hz - 64points in 128Hz sampling frequency > corresponding to 0.5secs. So there will not be any gain in the > amplitude spectrum due to zero padding). Am I missing something?I usually give this example to illustrate my point: Make a signal with N=8 samples as a sum of two sines with frequencies f1=0.14 fs and f2=0.20 fs (fs is samppling frequency) and unit amplitudes. First, compute the DFT of the raw signal and plot its magnitude versus frequency. Then, zero-pad the signal to a total length of, say, 128. Plot the DFT magnitude of this signal as well. Make sure to map the frequency bands properly. Then, repeat this exercise but with N=32 samples in the original data series. Take some time to contemplate the difference between the magnitude spectra of the zero-padded short sequence and the 32-pt DFT of the long sequence. Rune
Reply by ●February 13, 20042004-02-13
allnor@tele.ntnu.no (Rune Allnor) wrote in message news:<f56893ae.0402120338.4c125374@posting.google.com>...> ajith_pc@yahoo.com (Ajith Kumar P C) wrote in message news:<18eae751.0402112334.2d3279e4@posting.google.com>... > > Hi Rune, > > > > I am get confused by your explanation of bin width and resolution. I > > am quoting your message. > > > > ------------------------------------------------------------------------- > > There is a practical difference between bin width and resolution. > > > > The bin width is related to the number N of samples in the data > > sequence > > you Fourier tranform. Each bin width in the DFT is fs/N where fs is > > the > > sampling frequency. > > > > It would be very convenient if we could state that the spectrum > > resolution is directly related to the bin width of the DFT, but it > > isn't. The phenomenon is demosntrated by zero padding, i.e. when > > a data sequence of original lengths M is expanded by appending zeros > > to make up a sequence of total length N > M. If you compute the DFT > > of this zero padded sequence, you will find that the bin width > > is fs/N, but the resolution, when understood as the ability to > > separate different spectrum lines, is related to fs/M. > > ------------------------------------------------------------------------ > > > > Each bin (index) in the frequency axis represents a frequency value. > > So more bins for a given signal gives more resolution. By zero > > padding, we are not introducing any new sample values, so we are not > > gaining any thing in the magnitude of the output spectrum. But we are > > evaluating the DFT on more points, i.e. on more valid frequency > > points. > > Agreed. Some people use the term "spectrum interpolation" here. > > > So some of the frequencies are undefined in the original case, > > are defined after zero padding. Consider a signal contains 24Hz, > > 25Hz and 26Hz components, which is sampled at fs = 128Hz. Take a 64 > > point DFT, and then 24Hz will be at 12th bin, 26Hz at the 13th bin and > > the 25Hz is smeared on these bins. Here the frequency resolution is > > fs/N = 2Hz. The same signal is zero padded with 64 zeros and takes the > > DFT. Now the resolution becomes fs/N = 1Hz. So the 24Hz, 25Hz and 26Hz > > are on 24th, 25th and 26th bin respectively. So by padding zeros we > > could differentiate 25Hz from 24Hz and 26Hz. > > I don't know how you achieve this. When I do the 64 pt DFT I can see > a broad feature with two sharp peaks around 25 Hz. I can see that > in the zero-padded sequence as well. I am not capable of identifying > three separate components in any of the plots. Compare with the DFT > of 256 data samples, where you clearly separate the broad feature > as three separate lines (watch out for the vanishing coefficients > in the bins at 24.5 Hz and 25.5 Hz). > > The term "spectral resolution" is often used for the ability > to resolve two close spectral lines as distinct. It is closely > related to the Time-Bandwidth product and the Heisenberg inequality. > > >(Before and after padding > > zeros, the signal contains 12 complete cycles of 24Hz, 12.5 cycles of > > 25Hz and 13 cycles of 26Hz - 64points in 128Hz sampling frequency > > corresponding to 0.5secs. So there will not be any gain in the > > amplitude spectrum due to zero padding). Am I missing something? > > I usually give this example to illustrate my point: > > Make a signal with N=8 samples as a sum of two sines with frequencies > f1=0.14 fs and f2=0.20 fs (fs is samppling frequency) and unit > amplitudes. > > First, compute the DFT of the raw signal and plot its magnitude versus > frequency. Then, zero-pad the signal to a total length of, say, 128. > Plot the DFT magnitude of this signal as well. Make sure to map > the frequency bands properly. > > Then, repeat this exercise but with N=32 samples in the original > data series. Take some time to contemplate the difference between > the magnitude spectra of the zero-padded short sequence and the > 32-pt DFT of the long sequence. > > RuneHi Rune, You are right. It is my mistake; I haven't tried before composing the message. I just spoke from my limited theoretical knowledge. I should have to think that the frequency spectrum is not just a spike, but is an approximated sinc function. I had tried my example with 64 points, and zero padded etc, but I am unable to separate them. When I take a 256 real sample points, the three frequencies are clearly separated. I tried your example also. I come in to the same conclusion as yours. Thank you very much. regards ajith






