Autocorrelation is informally defined (Wikipedia article) as "the similarity between observations as a function of the time lag between them".
I create the following time series in MATLAB:
>> x = 1:1000; >> y = zeros(1,length(x)); >> y(300:700) = x(1:401); >> plot(x,y,'LineWidth',2.0)
And compute the autocorrelation using MATLAB
Now, as far as I understood correctly, the value of 1 at lag 0 means that when there is no lag, the signal is perfectly correlated with itself. When the lag increases, the correlation decreases.
However, I am lost at the negative autocorrelation values. As far as I understand it, I will get negative correlation value when one function increases and other decreases. However, since this signal only increases (save for the sudden drop at the end), I would not expect any negative correlation. If taking into account the drop at the end is still only a small fragment of the signal.
My question is: how is it possible for this autocorrelation to be negative? What do I understand wrong?