I am interested to find the analytical expression for the autocorrelation function of a signal that comprises triangular pulses. I have followed the derivation in "Statistical Theory of Communication" by Lee (1960, p.16)
However, if I replicate this in MATLAB, then I do not obtain the autocorrelation function as derived here. The general shape is the same, but it looks as follows:
with the autocorrelation function dipping below zero. In this case, the triangular pulses are spaced such that each triangle is half of the period, with the remainder of each period being zero.
Why is this different from Lee's Derivation, and how can I go about adapting his technique to find the analytical form that matches the empirical result?
The code I used in MATLAB was as follows:
function [x, acf1, acf2] = ACFTriangle(leftbase,rightbase,height,gap,repeat)
x = [zeros(1,gap) (1:leftbase)*(height/leftbase) (rightbase-1:-1:1)*(height/rightbase) 0];
x = repmat(x,[1,repeat]);
t = 0:length(x)-1;
acf = xcov(x,'unbiased');
n = length(acf);
s = (n-1)/2 + 1;
acf1 = acf(s:n)/var(x);
acf2 = autocorr(x,length(x)-1);
x = [t; x]';
end
The reason for my question is that I have a very large number of time series in which there may be a hidden triangular pulse wave. If I have an analytical expression for the autocorrelation sequence, then I can identify their characteristics from the shape of the autocorrelation function.
New edit
Notwithstanding the excellent answer below, how would one go about modifying Lee's mathematical derivation to allow for removal of the means? I can attempt this doing the following:
\begin{equation} \varphi_{11} = \frac{1}{T_1}\int_0^{b-\tau} \left(\frac{E_m}{b}t - m\right)\left(\frac{E_m}{b}\left(t+\tau\right) - m\right)\,dt \end{equation}
where $m$ is the mean of the series. However, following this through gives:
\begin{equation} \varphi_{11} = \frac{E_m^2}{6b^2T_1}\left(\tau^3-3b^2\tau + 2b^3\right) + m^2\left(b-\tau\right) - \frac{mE_m}{bT_1}\left(b-\tau\right)^2 - \frac{mE_m}{bT_1}\tau\left(b-\tau\right) \end{equation}
which clearly gives $\varphi_{11}=0$ for $\tau=b$. Where is the error in this working?