# Extrapolation of sinusoidal signal

Let there be a discrete signal that is the sum of sinusoidals and can be described by $$s(n)=\sum_i A_i \mathrm{sin}(2\pi f_i \frac{n}{f_s}+\phi_i)$$ where $$A_i, f_i, \phi_i$$ are unknown but fixed parameters of my signal, $$f_s$$ is my sampling rate, and $$n$$ is the sample measured at time $$t=\frac{n}{f_s}$$.

Of this signal I measure the first $$N$$ samples ($$n=1,2,3...N$$) and I also measure another $$N$$ samples at points $$n=N+20000,....2N+20000$$. I am now interested in estimating/predicting/extrapolating the value of a single sample that is exactly in the middle between my measured chunks: $$s(n=N+10000)$$. I don't care about all the other samples in the gap.

What is the best and most efficient way to estimate my desired sample? Note that $$N$$ would be ideally between 100 to 1000 and my sampling rate $$f_s=100\mathrm{MHz}$$.

• Do you know how many sinusoids you have a sum of? What is the range of the index $i$? – Engineer Oct 18 '20 at 19:11
• I don't know that but I am willing to make assumptions. – SignalExtrapChicago Oct 19 '20 at 17:18
• this is called sinusoidal modeling. lotsa papers written about it. i would suggest using a Gaussian window, DFT, peak picking, fitting each sinusoid, subtracting that sinusoid from the spectrum, and repeat. – robert bristow-johnson Oct 20 '20 at 17:08

One natural way to do this is to use the the total $$2N$$ samples (two chunks of $$N$$ samples each) to estimate the parameters. Amplitude, frequency, and phase estimation are all textbook equations that you can look up so the problem here is the fact that they are all mixed together. If you are assuming that you don't know how many sinusoids are mixed, then you also have to detect how many are present. The basic pseudo code is:

Detect how many sinusoids there are
For each sinusoid:
Estimate amplitude
Estimate frequency
Estimate phase
end
Reconstruct signal at n = N + 10000

## Detect how many sinusoids there are

You can do this by detecting how many peaks there are in the FFT of the signal. A sinusoid will present a peak at its frequency. At a peak, the slope of the curve will change from positive to negative, so the slope has a zero crossing at the peak. For a discrete signal, there are different ways to compute the slope/derivative but I would start with the simple before moving to more sophisticated methods. A simple way to compute the derivative is just the difference, $$x_d[n]=x[n]-x[n-1]$$, and a zero crossing happens if $$x_d[n-1] > 0 > x_d[n]$$. This will give you the number of zero crossings and where they occur.

Edit

The model that was presented in the question is a noise free model, and the detection described relies on that. You can still use this zero crossing method for a noisy signal but need to apply a threshold because the noise will cause many small peaks to occur. The threshold is needed to keep only the ones that have a significant enough amount of energy. Threshold should be picked to satisfy some probability of false alarm metric that you desire.

## Estimate ...

As I mentioned above, estimating the amplitude, frequency, and phase of a sinusoid can be found through the FFT peak finding method (and we already found the locations of the peaks) so we are all set.

## Reconstruct signal

Now that we have all the estimates, you can calculate your equation using your estimates.

$$\hat{s}(n+10000) = \sum_i \hat{A}_i \text{sin}\bigg( \frac{2\pi \hat{f}_i (n+10000)}{f_s} + \hat{\theta}_i \bigg)$$

Assuming that the number of the sinuses is less than $$N$$, this problem becomes solvable by the least mean squares. In the case of equality, should be solved by the usual matrix invention.

The liner form is achieved by replacing the phase variable $$\phi_i$$ with a cosine.

Once all the variables are estimated, the interpolation is done by simple substitution of the new points into the expression.

I think that a similar process was described in the last by Kay

edit

Another option is to pad zeros in the not sampled locations and use the usual FFT spectrum estimation

• How would you go about solving this with a least mean squares if there are less than N sinuses? Do you have a reference where this is described? – SignalExtrapChicago Oct 22 '20 at 7:45
• if you have more equations (here data points) than variables (here coefficients before sines and cosines) the solution is achieved by least mean squares. Look in the attached link – Gideon Genadi Kogan Oct 22 '20 at 8:35
• However, my variables are not only the amplitudes but also the frequency? I can assume that there are less than N sinuses but I can not preselect the frequencies. – SignalExtrapChicago Oct 22 '20 at 9:00
• if you don't know the number of the frequencies I would create equally spaced frequencies and solve for them. Mind that what I suggest is very similar to the usual spectrum estimation but with a not uniform sampling rate – Gideon Genadi Kogan Oct 22 '20 at 9:18