H[Z_]:=0.5*(1+Z^(-1));
Hf[f_]:=H[Exp[I*2*Pi*f]];
                
Plot[Abs[Hf[f]],{f,0,0.5},PlotRange->{{0,0.5},{0,1}},AxesLabel->{"f/fe","|H|"}]
Plot[Arg[Hf[f]],{f,0,0.5},PlotRange->{{0,0.5},{-Pi,Pi}},AxesLabel->{"f/fe","phi"}]
x[t_]:=Cos[2*Pi*t]+0.05*Random[];
tmax=5;
n=1000;
tn=Table[(k-1)*tmax/n,{k,n}];
xn=Table[x[tn[[k]]],{k,n}];
                
ListPlot[Transpose[{tn,xn}],Joined->True,AxesLabel->{"t","x"}]
h={0.5,0.5};
yn=ListConvolve[h,xn];
tn=Table[k*tmax/n,{k,n-1}];
                
ListPlot[Transpose[{tn,yn}],Joined->True,AxesLabel->{"t","y"}]
reponseImp[a_,p_]:=Table[2*a*Sinc[2*Pi*(k-p)*a],{k,0,2*p}];
h=reponseImp[0.2,10];
reponseFreq[h_,f_]:=Sum[h[[k]]*Exp[-I*2*Pi*k*f],{k,Length[h]}];
Plot[Abs[reponseFreq[h,f]],{f,0,0.5},AxesLabel->{"f/fe","G"}]
Plot[Arg[reponseFreq[h,f]],{f,0,0.5},AxesLabel->{"f/fe","phi"}]
reponseImp[a_,p_]:=Table[2*a*Sinc[2*Pi*(k-p)*a]*0.5*(1+Cos[(k-p)*2*Pi/(2*p+1)]),
                {k,0,2*p}];
p=10;
h=reponseImp[0.2,p];
                
Plot[Abs[reponseFreq[h,f]],{f,0,0.5},AxesLabel->{"f/fe","G"}]
Plot[Arg[reponseFreq[h,f]],{f,0,0.5},AxesLabel->{"f/fe","phi"}]
x[t_]:=Cos[2*Pi*t]+0.1*Random[];
tmax=2;
n=200;
tnx=Table[(k-1)*tmax/n,{k,n}];
xn=Table[x[tnx[[k]]],{k,n}];
                
yn=ListConvolve[h,xn];
tny=Table[tnx[[p+k]],{k,Length[yn]}];
ListPlot[Transpose[{tnx,xn}],Joined->True,AxesLabel->{"t","x"}]
ListPlot[Transpose[{tny,yn}],Joined->True,AxesLabel->{"t","y"}]
