DSPRelated.com
Forums
Online · Live + on demand
February 9-11, 2027
Price goes up Jan 1: register now to lock in today's rate
Register Now →

FFT, zero padding and DFT bins

Started by wond3rboy ●February 19, 2013
On 2/21/13 6:38 PM, Eric Jacobsen wrote:
> > Interpolation using parabolic fit to the coefficient magnitudes has > significant bias and performs poorly in noise. > > A more recent development in a simple estimator with good performance > at high and low SNR: > > http://www.eee.metu.edu.tr/~ccandan/pub_dir/FineDopplerEst_IEEE_SPL_June2011.pdf
wow, Eric, Fig 1 really illustrates the issue: you pick the peak and its two adjacent neighbors and one of those neighbors is on a sidelobe, a *different* lobe from the other two and you have a discontinuity in the the derivative in between. you can't expect to fit an "analytic function" (one that is continuous with continuous derivatives) to that and get it to do the right thing. i'm gonna read that sucker tonight. thanks for the link. i wonder if you were to zero pad by a 1:1 ratio (double the length before the FFT). then the 3 FFT bins should all be on the same main lobe. then how good does the parabolic fit work? -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Feb 21, 3:59&#4294967295;pm, robert bristow-johnson <r...@audioimagination.com>
wrote:
> On 2/21/13 3:07 PM, Vladimir Vassilevsky wrote: > > > "Dave"<dspg...@netscape.net> &#4294967295;wrote: > > "Vladimir Vassilevsky"<nos...@nowhere.com> &#4294967295;wrote: > > >>> Resolution depends on signal to noise ratio only. > >>> Infinite SNR = infinite resolution. > > >> Vlad has his own definition of resolution, The ability to detect two > >> closely spaced sinusoids has nothing to do with SNR - this is also > >> called the Rayleigh resolution. > > just off hand, if measurement time is fixed, this does not seem to be > the case, as far as i can tell. > > i think you can model zero-mean gaussian noise, white but bandlimited to > Nyquist (so it has finite variance), add it to the samples that are two > sinusoids not far apart and not much louder, make some linear > approximations, and come up with an expectation value for the estimation > of the number of components and of the component frequencies and > amplituded. &#4294967295;those results *could* be biased if there is noise. &#4294967295;i might > guess that the probability of 1 component decreases and the probability > of 2 components increases as the noise amplitude increases. &#4294967295;i would > expect that the continuous expectation value of the number of components > increases from 1 to 2 as the noise variance increases. &#4294967295;and the variance > around that expectation value (whether it's biased or not) should > certainly increase as the noise variance increases. &#4294967295;that's what i would > expect. > > what does Rayleigh say about that? &#4294967295;i dunno what exactly happens. > > > > > As long as SNR permits, it is possible to sepate two sinusoids. > > The SNR is the only limiting factor. > > >> If you want to accurate estimate the frequency of that sinusoid then > >> SNR plays a very important part. > > > Resolution is measurement. > > ya know, i'm aware sorta of the problem and i know how to understand it > in the noiseless context, but in the noisy case i hadn't really thought > about it. &#4294967295;anyway, Vlad, how do we quantitatively define resolution? &#4294967295;is > it, given a fixed window width, the minimum separation of frequencies of > two sinusoids that does what? &#4294967295;have a probability that it's 2 sinusoids > equal the probability that it's 1 sinusoid? > > just curious. > > -- > > r b-j &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295;r...@audioimagination.com > > "Imagination is more important than knowledge."
There are various algorithms that have different resolution - eg MUSIC, or Compressive Sensing. But the original post is about FFT resolution - so this pre-supposes the algorithm being used. For the most part the FFT resolution is SNR independent. The point of resolution is being able to resolve (or detect) two separate sinusoids. If the SNR is such that you can't even detect a single sinusoid then there's not much point in defining resolution. If you google Rayleigh resolution you get quite a good description. Unfortunately, I don't think Vlad has ever given "his" definition of resolution. "Resolution is measurement" - measurement of what? If it measurement of frequency - then you're really talking about estimation, and you'll get into Cramer Rao bound - which are quite definitely SNR dependent. Cheers David
On 2/21/13 6:38 PM, Eric Jacobsen wrote:

>This is another sad confirmation that even when you have a long-time >membership and supposedly appropriate society membership, the paper is >inaccessible unless a fee is paid or some other membership is >obtained. I've never figured out what society memberships is/are >necessary to have access to Proc. IEEE.
Well, I agree with that. I had a membership for many years, but because I wasn't a member of the particular society that published it, I usually had to find copies in the stacks at a local uni library, or search for the author's name or affiliation on the web and hope they also publish there.
>Interpolation using parabolic fit to the coefficient magnitudes has >significant bias and performs poorly in noise.
In the Gaussian method, the authors don't use the magnitude, rather they use the log of the magnitude. By using a Gaussian window, one obtains a series of Gaussian bandpass filters in the frequency domain. Then, since the log of a Gaussian is a parabola, by using the log of the magnitudes (vice the magnitudes), and applying a parabolic fit, they show that the estimates obtained are several orders of magnitude better than a simple parabolic fit to magnitudes. A different but not too dissimilar technique was shown by McEachern back in the early 1990's: http://www.edn.com/design/analog/4352503/EDN--03-03-94-Ratio-detection-precisely-characterizes-signals-amplitude-and-frequenc The above is a two-point method that that the author uses to solve for frequency. Once agin, he uses the log of the magnitude, and not the magnitude itself. He also has a patent where he describes it, but the algorithm is not part of the patent claims: http://www.google.com/patents/US5214708 Kevin McGee
"Dave" <dspguy2@netscape.net> wrote:

> Unfortunately, I don't think Vlad has ever given "his" definition of > resolution.
There are signals X and Y, the test procedure T, and unpredictable input component N. X and Y are resolvable by procedure T in the presense of N if norma T(X) - T(Y) is greater then norma T(X) - T(X +N)
> "Resolution is measurement" - measurement of what?
Of the difference between the signals.
> If it measurement of frequency - then you're really talking about > estimation, and you'll get into Cramer Rao bound - which are quite > definitely SNR dependent.
If test procedure T approaches CRB, then T is optimal.
> For the most part the FFT resolution is SNR independent.
That has to do with exponential fall of resolution wrt SNR when you venture into sub 1/T area. Vladimir Vassilevsky DSP and Mixed Signal Consultant www.abvolt.com
On Thu, 21 Feb 2013 21:43:55 -0800 (PST), kevin
<kevinjmcgee@netscape.net> wrote:

>On 2/21/13 6:38 PM, Eric Jacobsen wrote: > >>This is another sad confirmation that even when you have a long-time >>membership and supposedly appropriate society membership, the paper is >>inaccessible unless a fee is paid or some other membership is >>obtained. I've never figured out what society memberships is/are >>necessary to have access to Proc. IEEE. > >Well, I agree with that. I had a membership for many years, but >because I wasn't a member of the particular society that published >it, I usually had to find copies in the stacks at a local uni library, >or search for the author's name or affiliation on the web and hope >they also publish there. > >>Interpolation using parabolic fit to the coefficient magnitudes has >>significant bias and performs poorly in noise. > >In the Gaussian method, the authors don't use the magnitude, rather >they use the log of the magnitude. By using a Gaussian window, one >obtains a series of Gaussian bandpass filters in the frequency >domain. Then, since the log of a Gaussian is a parabola, by using the >log of the magnitudes (vice the magnitudes), and applying a parabolic >fit, they show that the estimates obtained are several orders of >magnitude better than a simple parabolic fit to magnitudes.
What has generally been found is that when the phase information is thrown away, performance suffers for it. Algorithms that work on the magnitude only have fallen by the wayside.
>A different but not too dissimilar technique was shown by McEachern >back in the early 1990's: > >http://www.edn.com/design/analog/4352503/EDN--03-03-94-Ratio-detection-precisely-characterizes-signals-amplitude-and-frequenc
>The above is a two-point method that that the author uses to solve for >frequency. Once agin, he uses the log of the magnitude, and not the >magnitude itself. He also has a patent where he describes it, but the >algorithm is not part of the patent claims: > >http://www.google.com/patents/US5214708 > >Kevin McGee
That's not a well-presented article and there is no performance information included. I've not simulated or used that algorithm, but I suspect if it was any good it would have shown up a time or two in references in frequency estimation papers over the last couple of decades. FWIW, this is actually still an area of active research and getting simpler algorithms or algorithms that improve some performance metric under conditions of interest is still being pursued. The usual problem with two-sample estimators is that they're very noisy when the tone is near the center of a bin, or has close to an integer number of cycles within the DFT aperture. This puts one of the two samples on the tone peak and the other contributes mostly noise. This is a little bit reversed from the three-sample estimators, which are sometimes noisiest when the tone is exactly between bins, since in that case two of the samples will be nearly equal, straddling the sinx/x main lobe, and the third just contributes mostly noise. In general the three-sample estimators greatly outperform the two-sample estimators overall, which seems to be why they're the more often used. Hybrid estimators that select an algorithm output depending on the frequency estimated by each (e.g., perhaps a two-sample estimator if the estimators generally agree the tone is near the zone exactly between bins, and three-sample estimators otherwise) can be used as well, and some algorithms iterate using rough initial estimates and then refine the estimate. I think you'd benefit from a search of recent literature on the topic. Candan's paper that I linked is one of the pertinent recent ones for simple, accurate estimators, especially in high SNR or low N. As the SNR decreases and/or N increases, his correction term becomes less important and the algorithm is still one of the best of the simple algorithms in those conditions. Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
On Fri, 22 Feb 2013 18:02:29 GMT, eric.jacobsen@ieee.org (Eric
Jacobsen) wrote:

>In general the three-sample estimators greatly outperform the >two-sample estimators overall, which seems to be why they're the more >often used. Hybrid estimators that select an algorithm output >depending on the frequency estimated by each (e.g., perhaps a >two-sample estimator if the estimators generally agree the tone is >near the zone exactly between bins, and three-sample estimators >otherwise) can be used as well, and some algorithms iterate using >rough initial estimates and then refine the estimate.
I guess I have been using a three-sample estimator, although I didn't know that is what it is called. I have a piano tuning app that needs to measure musical frequencies as accurately as possible given the limitation of resonding quickly (no extremely long sample periods allowed). I took a completely empirical approach. Calling the three amplitudes yLeft, yMiddle, and yRight I calculated: d = (yMiddle - yLeft) / (2 * yMiddle - yRight - yLeft); Then I synthesized a large set of sinusoids exploring the frequency offsets around a single bin and calculated the "d' parameter for each of them. I then built a 64-element lookup table of (d,frequency offset) pairs. Now when I want to interpolate between bins I calculate "d" and then search the table for the closest "d" value and use the corresponding frequency offset to estimate my frequency. So how good is my estimator likely to be, compared to other closed-form formulaic three-sample estimators? I think I am getting 1/10 of a bin accuracy for clean isolated sinusoids. Robert Scott Hopkins, MN
On Fri, 22 Feb 2013 21:17:03 GMT, no-one@notreal.invalid (Robert
Scott) wrote:

>On Fri, 22 Feb 2013 18:02:29 GMT, eric.jacobsen@ieee.org (Eric >Jacobsen) wrote: > >>In general the three-sample estimators greatly outperform the >>two-sample estimators overall, which seems to be why they're the more >>often used. Hybrid estimators that select an algorithm output >>depending on the frequency estimated by each (e.g., perhaps a >>two-sample estimator if the estimators generally agree the tone is >>near the zone exactly between bins, and three-sample estimators >>otherwise) can be used as well, and some algorithms iterate using >>rough initial estimates and then refine the estimate. > >I guess I have been using a three-sample estimator, although I didn't >know that is what it is called. I have a piano tuning app that needs >to measure musical frequencies as accurately as possible given the >limitation of resonding quickly (no extremely long sample periods >allowed). > >I took a completely empirical approach. Calling the three amplitudes >yLeft, yMiddle, and yRight I calculated: > > d = (yMiddle - yLeft) / (2 * yMiddle - yRight - yLeft);
If you're just taking the magnitudes of the bins for yLeft, etc., that's close to the traditional quadratic estimator. Compared to other "better" estimators it is biased and performs poorly in noise. If, instead, you do the same thing with the complex values and then take the real part at the end, like this: d = Re{ (yMiddle - yLeft) / (2 * yMiddle - yRight - yLeft); } then that's essentially the estimator I self-published about seventeen years ago, and that later appeared in Signal Processing Magazine: http://www.ingelec.uns.edu.ar/pds2803/Materiales/Articulos/AnalisisFrecuencial/04205098.pdf Candan's estimator is mine with a simple correction term applied that improves performance at high SNR, especially for small N. That would probably benefit your application.
>Then I synthesized a large set of sinusoids exploring the frequency >offsets around a single bin and calculated the "d' parameter for each >of them. I then built a 64-element lookup table of (d,frequency >offset) pairs. Now when I want to interpolate between bins I >calculate "d" and then search the table for the closest "d" value and >use the corresponding frequency offset to estimate my frequency. > >So how good is my estimator likely to be, compared to other >closed-form formulaic three-sample estimators? I think I am getting >1/10 of a bin accuracy for clean isolated sinusoids.
The link to the Signal Processing Magazine article above has some performance data for some of the better estimators. Candan's paper has some of that as well: http://www.eee.metu.edu.tr/~ccandan/pub_dir/FineDopplerEst_IEEE_SPL_June2011.pdf
>Robert Scott >Hopkins, MN
Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
On 2/22/13 4:47 PM, Eric Jacobsen wrote:
> On Fri, 22 Feb 2013 21:17:03 GMT, no-one@notreal.invalid (Robert > Scott) wrote: > >> On Fri, 22 Feb 2013 18:02:29 GMT, eric.jacobsen@ieee.org (Eric >> Jacobsen) wrote: >> >>> In general the three-sample estimators greatly outperform the >>> two-sample estimators overall, which seems to be why they're the more >>> often used. Hybrid estimators that select an algorithm output >>> depending on the frequency estimated by each (e.g., perhaps a >>> two-sample estimator if the estimators generally agree the tone is >>> near the zone exactly between bins, and three-sample estimators >>> otherwise) can be used as well, and some algorithms iterate using >>> rough initial estimates and then refine the estimate. >> >> I guess I have been using a three-sample estimator, although I didn't >> know that is what it is called. I have a piano tuning app that needs >> to measure musical frequencies as accurately as possible given the >> limitation of resonding quickly (no extremely long sample periods >> allowed). >> >> I took a completely empirical approach. Calling the three amplitudes >> yLeft, yMiddle, and yRight I calculated: >> >> d = (yMiddle - yLeft) / (2 * yMiddle - yRight - yLeft); > > If you're just taking the magnitudes of the bins for yLeft, etc., > that's close to the traditional quadratic estimator. Compared to > other "better" estimators it is biased and performs poorly in noise. > If, instead, you do the same thing with the complex values and then > take the real part at the end, like this: > > d = Re{ (yMiddle - yLeft) / (2 * yMiddle - yRight - yLeft); } > > then that's essentially the estimator I self-published about seventeen > years ago, and that later appeared in Signal Processing Magazine: > > http://www.ingelec.uns.edu.ar/pds2803/Materiales/Articulos/AnalisisFrecuencial/04205098.pdf >
Eric. i know it's 15 years later, but i have trouble with Eq. 2. it's the same problem i had with our discussion about it way back when. Eq. 2 is off by a factor of two. Eq. 2 is not the "Parabolic approximation for peak determination". it needs a 6 dB boost. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
On Fri, 22 Feb 2013 17:13:11 -0500, robert bristow-johnson
<rbj@audioimagination.com> wrote:

>On 2/22/13 4:47 PM, Eric Jacobsen wrote: >> On Fri, 22 Feb 2013 21:17:03 GMT, no-one@notreal.invalid (Robert >> Scott) wrote: >> >>> On Fri, 22 Feb 2013 18:02:29 GMT, eric.jacobsen@ieee.org (Eric >>> Jacobsen) wrote: >>> >>>> In general the three-sample estimators greatly outperform the >>>> two-sample estimators overall, which seems to be why they're the more >>>> often used. Hybrid estimators that select an algorithm output >>>> depending on the frequency estimated by each (e.g., perhaps a >>>> two-sample estimator if the estimators generally agree the tone is >>>> near the zone exactly between bins, and three-sample estimators >>>> otherwise) can be used as well, and some algorithms iterate using >>>> rough initial estimates and then refine the estimate. >>> >>> I guess I have been using a three-sample estimator, although I didn't >>> know that is what it is called. I have a piano tuning app that needs >>> to measure musical frequencies as accurately as possible given the >>> limitation of resonding quickly (no extremely long sample periods >>> allowed). >>> >>> I took a completely empirical approach. Calling the three amplitudes >>> yLeft, yMiddle, and yRight I calculated: >>> >>> d = (yMiddle - yLeft) / (2 * yMiddle - yRight - yLeft); >> >> If you're just taking the magnitudes of the bins for yLeft, etc., >> that's close to the traditional quadratic estimator. Compared to >> other "better" estimators it is biased and performs poorly in noise. >> If, instead, you do the same thing with the complex values and then >> take the real part at the end, like this: >> >> d = Re{ (yMiddle - yLeft) / (2 * yMiddle - yRight - yLeft); } >> >> then that's essentially the estimator I self-published about seventeen >> years ago, and that later appeared in Signal Processing Magazine: >> >> http://www.ingelec.uns.edu.ar/pds2803/Materiales/Articulos/AnalisisFrecuencial/04205098.pdf >> > >Eric. i know it's 15 years later, but i have trouble with Eq. 2. it's >the same problem i had with our discussion about it way back when. > >Eq. 2 is off by a factor of two. Eq. 2 is not the "Parabolic >approximation for peak determination". it needs a 6 dB boost.
You can follow the source references for that. Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
On 2/22/13 6:47 PM, Eric Jacobsen wrote:
> On Fri, 22 Feb 2013 17:13:11 -0500, robert bristow-johnson > <rbj@audioimagination.com> wrote: > >> On 2/22/13 4:47 PM, Eric Jacobsen wrote: >>> On Fri, 22 Feb 2013 21:17:03 GMT, no-one@notreal.invalid (Robert >>> Scott) wrote: >>> >>>> On Fri, 22 Feb 2013 18:02:29 GMT, eric.jacobsen@ieee.org (Eric >>>> Jacobsen) wrote: >>>> >>>>> In general the three-sample estimators greatly outperform the >>>>> two-sample estimators overall, which seems to be why they're the more >>>>> often used. Hybrid estimators that select an algorithm output >>>>> depending on the frequency estimated by each (e.g., perhaps a >>>>> two-sample estimator if the estimators generally agree the tone is >>>>> near the zone exactly between bins, and three-sample estimators >>>>> otherwise) can be used as well, and some algorithms iterate using >>>>> rough initial estimates and then refine the estimate. >>>> >>>> I guess I have been using a three-sample estimator, although I didn't >>>> know that is what it is called. I have a piano tuning app that needs >>>> to measure musical frequencies as accurately as possible given the >>>> limitation of resonding quickly (no extremely long sample periods >>>> allowed). >>>> >>>> I took a completely empirical approach. Calling the three amplitudes >>>> yLeft, yMiddle, and yRight I calculated: >>>> >>>> d = (yMiddle - yLeft) / (2 * yMiddle - yRight - yLeft); >>> >>> If you're just taking the magnitudes of the bins for yLeft, etc., >>> that's close to the traditional quadratic estimator. Compared to >>> other "better" estimators it is biased and performs poorly in noise. >>> If, instead, you do the same thing with the complex values and then >>> take the real part at the end, like this: >>> >>> d = Re{ (yMiddle - yLeft) / (2 * yMiddle - yRight - yLeft); } >>> >>> then that's essentially the estimator I self-published about seventeen >>> years ago, and that later appeared in Signal Processing Magazine: >>> >>> http://www.ingelec.uns.edu.ar/pds2803/Materiales/Articulos/AnalisisFrecuencial/04205098.pdf >>> >> >> Eric. i know it's 15 years later, but i have trouble with Eq. 2. it's >> the same problem i had with our discussion about it way back when. >> >> Eq. 2 is off by a factor of two. Eq. 2 is not the "Parabolic >> approximation for peak determination". it needs a 6 dB boost. > > You can follow the source references for that. >
well, usually i trust my own mathematics with something is as simple as that. but, alas, i am wrong, Eq. 2 is correct. we *did* have an issue of a factor of two when we discussed this way back when: http://www.ericjacobsen.org/fe.htm but i confused or conflated this with that. i can't remember what that factor of 2 was about back then. as Emily Litella would say: "Never mind." -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."