<<"Desktop/TimeSeries/timeseries.m"

data= RandomVariate[NormalDistribution[0,9],10^4];
(*we drop the data -2 to equal the length for covariance since it's discrete in this case*)

z = data;
zminus2 = Drop[z, 2];
z = Drop[z,-2];
a1 = 3;
b= 5;
c=7;

a = Table[a1, {i, 1, Length[z]}];
x = a+(b*z)+(c*zminus2);

t = 100;
h = 100;

ListPlot[ Table[autoCorrelation[x,h,t], {t, 1, 1000}], PlotRange->{{0,1000}, {-0.5, 0.5}}]

t = 1;
h = 100;

(* Constant signal always sums 0 covariance *)
Covariance[a, a]+Covariance[a, b*z]+Covariance[a, c*zminus2]

Covariance[a, a]+Covariance[a, b*z]+Covariance[a, c*zminus2]+((b^2*autoCovariance[z, 0,h,t])+(c^2*autoCovariance[z, -2,-2+h,t]) + (b*c*(autoCovariance[z, -2, h, t]+autoCovariance[z, 0, -2+h, t])   ))
autoCovariance[x,0, h,t]

z = data;
zminus1 = Drop[z, 1];
z = Drop[z,-1];
c=7;

x = zminus1*Cos[c*t]+z*Sin[c*t];

t = 2;
h = 100;

ListPlot[ Table[autoCorrelation[x,h,t], {t, 1, 1000}], PlotRange->{{0,1000}, {-0.5, 0.5}}]

z = data;
zminus1 = Drop[z, 1];
z = Drop[z,-1];
c=7;

x = z*Cos[c*t]+zminus1*Sin[c*t];

t = 100;
h = 100;

ListPlot[ Table[autoCorrelation[x,h,t], {t, 1, 1000}], PlotRange->{{0,1000}, {-0.5, 0.5}}]

z = data;

z0 = z[[1]];
a1 = 3;
b= 5;
z= Table[z0,{i,1,Length[z]}];
a = Table[a1, {i, 1, Length[z]}];
x = a+b*z;

t = 700;
h = 200;


ListPlot[ Table[autoCorrelation[x,h,t], {t, 1, 1000}], PlotRange->{{0,1000}, {-3, 3}}]

z = data;

z0 = z[[1]];

z= Table[z0,{i,1,Length[z]}];
c=7;
x = z*Cos[c*t];

t = 700;
h = 200;

ListPlot[ Table[autoCorrelation[x,h,t], {t, 1, 1000}], PlotRange->{{0,1000}, {-3, 3}}]

z = data;
zminus1 = Drop[z, 1];
z = Drop[z,-1];


x = Table[z[[i]]*zminus1[[i]], {i, 1, Length[z]}];

t = 100;
h = 100;

ListPlot[ Table[autoCorrelation[x,h,t], {t, 1, 1000}], PlotRange->{{0,1000}, {-0.5, 0.5}}]