function Y=Loiautoregr(a,th)

S=0;
for j=1:5000
X=a;
for i=2:100
    U=rand(1)
    X=th*X+(1-th)*(U<X);
end
S=S+(X<0.01)
end
Y=S/5000;
endfunction
