3
$\begingroup$

I am trying to understand how to interpolate discrete sinusoidal data that I (for now) generate myself, and I get problems that I don't understand. I'm a newbie in this field so do not hesitate to point out even the most basic errors.

I have tried two approaches.

The first is to take (Python's/numpy's) fft(), get amplitudes with abs() and phases with $$ \frac{\text{angle} - \pi/2}{2 \pi} * \text{signal_length} $$

Then, for each sampling point $p$ I do a sine series, $$ \sum_i \text{amplitude}_i * \sin(2 \pi i * \frac{p - \text{phase}_i}{\text{signal_length}}) $$

For artificial data where the (only) sine lambda is signal_length the fit is perfect regardless of the artificial data phase. However, if I generate the data with sine that has lambda of half the signal length, the fit is far from good for most phase offsets. Obviously, the fit is also not good when I generate a signal from several added sines of different lambdas.

Edit 1: Note that I can artificially correct the phases of different lambdas by dividing them by n, where n is signal_length / lambda of the generating function, but this doesn't help when I don't know the lambda of the generating function and/or when the signal is a mix of several sines.

The second approach was to get separate sine and cosine amplitudes from fft() output by real() and -1 * imag() and then do a summation similar to above for both sine and cosine terms. This works well whenever the phase offset of the generated data is n*2*pi but unwell when it's anything else.

Eventually I'd like to be able to interpolate data generated by a superposition of several sinusoidal functions of various lambdas and phases, but so far it's not looking good. I think there is something that I don't understand about Fourier/DFT.

Note that I can't/don't want to use any built-in ifft functions but I need to do some kind of a sine/cosine summation manually. I tried to write the definition of inverse DFT, but the built-in functions don't understand correctly things such as e^i. Ideally I would want to sum just the sine or the cosine terms, but not both.

Edit 2 LaTeXed some math

$\endgroup$

migrated from math.stackexchange.com Jul 4 '12 at 9:56

This question came from our site for people studying math at any level and professionals in related fields.

  • $\begingroup$ Remember that this is math site, not a programming site, you should at least state that you are refering to Python functions. And please try to format math equations. $\endgroup$ – leonbloy Jul 3 '12 at 12:59
  • $\begingroup$ I am curious as to how you settled on this approach. There are many published in the literature for time series interpolation most of which do not require the use of the FFT (try googleing 'interpolation'). It also matters what type of data you intend to ultimately use your method on (i.e. random process, stationary, etc). If you wanted to use the FFT as an interpolation method, you could take an FFT of the data, then append zeros to the end of the FFT (i.e. to increase the sample rate) then take the IFFT of the result. You could also use the sinc() function. $\endgroup$ – Tpofofn Jul 3 '12 at 13:08
  • $\begingroup$ Tpofofn: The main reason is to try to replicate analysis that has been done by other authors. I'm not saying that it doesn't make sense, since the time-series data set in question is very clearly a superposition of a few sine waves. leonbloy: Thanks for the comments, I'll see if I can manage to make the question better. $\endgroup$ – DohnJoe Jul 3 '12 at 13:14
  • $\begingroup$ Regarding your statement "but the built-in functions don't understand correctly things such as e^i," you could use the fact that $e^{i\theta} = \cos\theta + i\sin\theta$. $\endgroup$ – Tpofofn Jul 4 '12 at 3:03
1
$\begingroup$

I resolved this problem by myself. Using approach 1, I replaced $$phase_i$$ with $$\frac{phase_i}{i+1}$$ in the summation formula, and suddenly everything worked perfectly.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.