# Predicting a seasonal signal

Consider a noisy signal $$X$$ and a time variable $$T$$ as seen in Fig. 1. This is a simulated generalization of data I am currently facing with the goal of making predictions for future time points $$t_f$$.

From a visual inspection we can see that while noisy, the signal is quite repetitive in the observed time frame. Were we to ask an elementary school student to continue the pattern, he/she would probably do a decent enough job.
How can such a signal be predicted for a given time point not just in the near future (prediction horizon $$\gg$$ training window size) ?

### Fig. 1: Timed signal with and without noise

Optional addition: my thoughts on this

Although it is quite clear visually, a look at the one-sided spectrum of the FFT as shown in Fig. 2 tells us that there's indeed a frequent repetition in the signal at intervals of ~0.018 and the rough extend of it. My first thoughts were therefore to simply localise the time gaps between the peaks and valleys in the signal, their approximate values and simply forecasting a continuation of the signal.
A colleague rightly noted that since our original signal is not precisely as nice as this simulation, with small variations in the timing of the extrema and their extents. Furthermore he argued that using some established method within forecasting might make life easier for us, as it requires less explanation of our procedure and motivation for its use.
While I was looking into time series methods I started to doubt whether they are the right tool for this.

## Matlab code for data generation and plotting

% Creating a signal as in segment 1, with amplitude = 0.02
rng(32)
period = 0.02;
frequency = 1/period;
amplitude = 1;
noisestrength = 0.3;
tmax = 0.36;
tmin = 0.20;

T = linspace(tmin,tmax,1000);
S = cos(2*pi*T/period)/2*amplitude; % create a cosine wave with defined period and amplitude
N = (rand(size(T))-.5)*amplitude; % create a noise signal with mean=0 and range=amplitude
X = S*(1-noisestrength) + noisestrength*N; % combined signal
figure(1);hold on
plot(T,X,'color',[0 0 1])
plot(T,S,'color',[0 0 0],'linewidth',2);
legend({'Noisy Signal','Signal'});
title('Signal')
xlabel('T')
ylabel('X(T)')

% Fourier analysis
% See https://www.mathworks.com/help/matlab/examples/using-fft.html
Y=fft(X);  % frequency in relation to complete length of window, i.e., how frequent is signal within window
P2 = abs(Y/length(X)); % double-sided spectrum
P1 = P2(1:(length(P2)/2+1)); % half
P1(2:end-1) = 2*P1(2:end-1); % half-sided spectrum
per = (tmax-tmin)./(1:length(P1));

figure(2)
plot(per,P1)
xlabel('Time / Cycle')
ylabel('Power')

• Have you considered fitting a sine wave equation to the data? Something like "Y = amplitude * sin(X + shift)"? I see that the data appears symmetrical about the Y axis value of zero, so there should be no need to add an offset term. – James Phillips May 23 at 14:17
• I've had a similar thought since I asked this question. I am currently trying out a fourier series which seems to yield fairly good results for this so far. – deemel May 23 at 14:19