Forums

FFT Rounding error?

Started by Andrew Holme May 12, 2007
I computed this forward FFT using MS VC++ 6.0 and FFTW:

http://www.holmea.demon.co.uk/Misc/FFT.gif

I don't think the "tail" should flick up like that at the low-frequency end. 
Is this caused by a lack of floating-point precision?

TIA





On 13 May, 00:55, "Andrew Holme" <and...@nospam.com> wrote:
> I computed this forward FFT using MS VC++ 6.0 and FFTW: > > http://www.holmea.demon.co.uk/Misc/FFT.gif > > I don't think the "tail" should flick up like that at the low-frequency end. > Is this caused by a lack of floating-point precision? > > TIA
It would be a lot easier to have an opinion if one knew the input data and what is displayed...? Rune
Andrew Holme wrote:
> I computed this forward FFT using MS VC++ 6.0 and FFTW: > > http://www.holmea.demon.co.uk/Misc/FFT.gif > > I don't think the "tail" should flick up like that at the low-frequency end. > Is this caused by a lack of floating-point precision?
What are the two lowest frequencies calculated in that display? This may be a result of having a non integer number of cycles at the lowest frequency computed.
"Rune Allnor" <allnor@tele.ntnu.no> wrote in message 
news:1179011809.143264.72260@p77g2000hsh.googlegroups.com...
> On 13 May, 00:55, "Andrew Holme" <and...@nospam.com> wrote: >> I computed this forward FFT using MS VC++ 6.0 and FFTW: >> >> http://www.holmea.demon.co.uk/Misc/FFT.gif >> >> I don't think the "tail" should flick up like that at the low-frequency >> end. >> Is this caused by a lack of floating-point precision? >> >> TIA > > It would be a lot easier to have an opinion if one knew the > input data and what is displayed...? > > Rune >
It's a prediction of frequency synthesizer phase noise, generated by simulation. FFT input is 1e6 samples of VCO control voltage. Graph is generated by calculating modulation index at each point in FFT output (NBFM approximation). Phase noise dominated by VCO rolls off at -20dB/decade outside loop bandwidth. Spur is 100 KHz reference frequency. Due to use of 3rd order loop filter, noise slope should be 40-20=20dB per decade inside loop bandwidth, and it is, except where that "tail" flicks up. Does anyone recognise the effect? TIA
"John Popelish" <jpopelish@rica.net> wrote in message 
news:NdydneGbHaGG0dvbnZ2dnUVZ_qfinZ2d@comcast.com...
> Andrew Holme wrote: >> I computed this forward FFT using MS VC++ 6.0 and FFTW: >> >> http://www.holmea.demon.co.uk/Misc/FFT.gif >> >> I don't think the "tail" should flick up like that at the low-frequency >> end. Is this caused by a lack of floating-point precision? > > What are the two lowest frequencies calculated in that display? > > This may be a result of having a non integer number of cycles at the > lowest frequency computed.
I'm not sure what you mean by the two lowest frequencies. FFT input is 1e6 samples, sampled at 1 MHz. There are 1e6 output buckets, each 1 Hz wide. Bucket 0 is DC (not plotted) Bucket 1 is 1 Hz Bucket 2 is 2 Hz e.t.c The data is not repetitive, essentially a steady DC level with noise and 100 KHz ripple.
Andrew Holme wrote:
> "John Popelish" <jpopelish@rica.net> wrote in message > news:NdydneGbHaGG0dvbnZ2dnUVZ_qfinZ2d@comcast.com... >> Andrew Holme wrote: >>> I computed this forward FFT using MS VC++ 6.0 and FFTW: >>> >>> http://www.holmea.demon.co.uk/Misc/FFT.gif >>> >>> I don't think the "tail" should flick up like that at the low-frequency >>> end. Is this caused by a lack of floating-point precision? >> What are the two lowest frequencies calculated in that display? >> >> This may be a result of having a non integer number of cycles at the >> lowest frequency computed. > > I'm not sure what you mean by the two lowest frequencies. > > FFT input is 1e6 samples, sampled at 1 MHz. There are 1e6 output buckets, > each 1 Hz wide.
So the line at the left side of the graph is really not information. the only information is in the points at 1 Hz, 2 Hz, etc. So 1Hz and 2Hz are the two lowest frequencies displayed by this graph.
> Bucket 0 is DC (not plotted) > Bucket 1 is 1 Hz > Bucket 2 is 2 Hz e.t.c > The data is not repetitive, essentially a steady DC level with noise and 100 > KHz ripple.
What would you expect to find in this data if the original samples contained some 1.5 Hz energy?
On May 12, 3:55 pm, "Andrew Holme" <and...@nospam.com> wrote:
> I computed this forward FFT using MS VC++ 6.0 and FFTW: > > http://www.holmea.demon.co.uk/Misc/FFT.gif > > I don't think the "tail" should flick up like that at the low-frequency end. > Is this caused by a lack of floating-point precision? >
Does your data have a ramp in it? 1,2,3,4,5,6.... makes that sort of shape.
"John Popelish" <jpopelish@rica.net> wrote in message 
news:NdydneGbHaGG0dvbnZ2dnUVZ_qfinZ2d@comcast.com...
> Andrew Holme wrote: >> I computed this forward FFT using MS VC++ 6.0 and FFTW: >> >> http://www.holmea.demon.co.uk/Misc/FFT.gif >> >> I don't think the "tail" should flick up like that at the low-frequency >> end. Is this caused by a lack of floating-point precision? >
> This may be a result of having a non integer number of cycles at the > lowest frequency computed.
Ah! I think you put your finger on it. I've just removed the DC, and the problem has gone. When you have an exactly integral number of cycles, the FFT shows a sharp reponse, and when you don't, it spills into adjacent buckets doesn't it? I think my DC bucket is spilling. Thanks John.
On 13 May, 01:36, "Andrew Holme" <and...@nospam.com> wrote:
> "Rune Allnor" <all...@tele.ntnu.no> wrote in message > > news:1179011809.143264.72260@p77g2000hsh.googlegroups.com... > > > > > > > On 13 May, 00:55, "Andrew Holme" <and...@nospam.com> wrote: > >> I computed this forward FFT using MS VC++ 6.0 and FFTW: > > >>http://www.holmea.demon.co.uk/Misc/FFT.gif > > >> I don't think the "tail" should flick up like that at the low-frequency > >> end. > >> Is this caused by a lack of floating-point precision? > > >> TIA > > > It would be a lot easier to have an opinion if one knew the > > input data and what is displayed...? > > > Rune > > It's a prediction of frequency synthesizer phase noise, generated by > simulation.
Phase noise? Is this the phase, not magnitude, as returned by the FFT?
> FFT input is 1e6 samples of VCO control voltage. Graph is > generated by calculating modulation index at each point in FFT output (NBFM > approximation). Phase noise dominated by VCO rolls off at -20dB/decade > outside loop bandwidth. Spur is 100 KHz reference frequency. Due to use of > 3rd order loop filter, noise slope should be 40-20=20dB per decade inside > loop bandwidth, and it is, except where that "tail" flicks up.
This is a WAY to complicated an example to verify the FFT! To test the FFT, use one sinusoidal at a fraction of the sampling frequency, f = n/N*Fs, and see what happens. You use FFTW. That library returns results in ways that some times are not at all obvious. Are you sure you unwrapped the results properly? Rune
"Andrew Holme" <andrew@nospam.com> wrote in message 
news:f25kim$607$1$8300dec7@news.demon.co.uk...
> > "John Popelish" <jpopelish@rica.net> wrote in message > news:NdydneGbHaGG0dvbnZ2dnUVZ_qfinZ2d@comcast.com... >> Andrew Holme wrote: >>> I computed this forward FFT using MS VC++ 6.0 and FFTW: >>> >>> http://www.holmea.demon.co.uk/Misc/FFT.gif >>> >>> I don't think the "tail" should flick up like that at the low-frequency >>> end. Is this caused by a lack of floating-point precision? >> > >> This may be a result of having a non integer number of cycles at the >> lowest frequency computed. > > Ah! I think you put your finger on it. I've just removed the DC, and the > problem has gone. When you have an exactly integral number of cycles, the > FFT shows a sharp reponse, and when you don't, it spills into adjacent > buckets doesn't it? I think my DC bucket is spilling. > > Thanks John. > >
Damn. The problem is back. It's not just DC. I think I need to make the 1e6 samples end on the same value they started at. Something like a Hanning window. I think the discontinuity is creating a response at 1 Hz. Does FFTW do windowing?