function X=autoregr(th,n)

a=0.3;
X=zeros(1,n);
X(1)=a;
for i=2:n
    U=rand(1)
    X(i)=th*X(i-1)+(1-th)*(U<X(i-1));
end
endfunction
