Re: "Correct" Data Philosophy [message #69092 is a reply to message #69024] |
Mon, 21 December 2009 14:03   |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
We did a major software upgrade on our servers last Friday,
which broke a few things, then had a two-hour power outage
today just to add to the fun.
I think things are working now.
You can download the interpolation chapter from my book here
http://csrp.tamu.edu/pdf/idl/sample_chapter.pdf
I also made a sample program that shows how to fit sines and
cosines using least-squares (REGRESS in this case).
http://csrp.tamu.edu/downloads/fft_vs_least_squares.pro.zip
Most of the program is concerned with printing and plotting. The
actual calculations don't take much space.
This program creates a 1-D function containing a sine term, a
cosine term, and some noise. The noise serves to ensure that
there is spectral power at all frequencies. You can set the
amplitude of the noise to zero to get a pure sinusoid.
Part 1 computes the FFT and inverse FFT and plots the result.
Part 2 uses REGRESS to fit sines and cosines. Using the equivalent
set of sines and cosines as FFT, the coefficients are identical.
Part 3 demonstrates fitting sines and cosines with REGRESS when
data points are unevenly spaced or missing. This is particularly
useful when you only need to estimate a few Fourier components,
as it is much slower than an FFT when n is large.
In this sample program you can see that deleting two points
does not cause large errors in the estimates of the magnitudes
of the original sine and cosine components.
Bob Stockwell posted a comment earlier about how using regression
to compute FFTs when data are missing can affect the results.
This was exactly my point at the beginning of this discussion.
You really need to understand the methods that you are using.
If detailed spectral analysis is necessary, then regression
may not be appropriate. On the other hand, how do you deal with
missing data? Interpolating to fill data gaps will also
affect the spectrum. It is important to experiment with data
that has known properties to determine how your particular
choices affect the results.
I don't think I have ever been to a thesis defense where someone
didn't ask the question: "You did such-and-such to your data.
How did that assumption or approximation affect your results?"
Cheers, Ken
|
|
|