% Generate AR(1) process: e_t=alpha*e_t-1+v_t
% Last checking: 05/20/2019

function [e, e1, eo]=genar(alpha,T,n,throw)
e=zeros(T+throw,n);% bins
v=randn(T+throw,n);
y0=0;% y0=initial value
e(1,:)=alpha*y0+v(1,:);
for s=2:T+throw
    e(s,:)=alpha*e(s-1,:)+v(s,:);
end
eo=e;% full set
e1=e(throw:T+throw-1,:);% e_t-1
e=e(throw+1:T+throw,:);% e_t
