X=autoregr2(0.3,100);
plot2d(X)
X2=autoregr2(1,100);
plot2d([1:100],X2,2)
X3=autoregr2(1.1,100);
clf
plot2d([1:100],X3,3)
clf

theta2=thc(X2);
theta1=thc(X);

plot2d(theta1)
plot2d([1:99],theta2,2)

theta3=thc(X3);

plot2d([1:99],theta3,3)

//thetachapeau semble etre un estimateur convergent de theta dans tous les cas
thestime=zeros(1,1000);
for i=1:1000
    X=autoregr2(0.3,100);
    thestime(i)=thc2(X);
end
t=-gsort(-(thestime-0.3))*sqrt(100);
figure
plot2d(t,[1:1000]/1000);
u=mean(thestime-0.3)*sqrt(100);
s=stdev(thestime-0.3)*sqrt(100);
a=[-4*s:0.02*s:4*s];
plot2d(a,pnorm(a,u,s),2)
thestime2=zeros(1,1000);
for i=1:1000
    X2=autoregr2(1,100);
    thestime2(i)=thc2(X2);
end
t=-gsort(-(thestime2-1))*sqrt(100);
figure
plot2d(t,[1:1000]/1000);
u=mean(thestime2-1)*sqrt(100);
s=stdev(thestime2-1)*sqrt(100);
a=[-4*s):0.02*s:4*s];
plot2d(a,pnorm(a,u,s),2)
thestime3=zeros(1,1000);
for i=1:1000
    X3=autoregr2(1.1,100);
    thestime3(i)=thc2(X3);
end
t=-gsort(-(thestime3-1.1))*sqrt(100);
figure
plot2d(t,[1:1000]/1000);
u=mean(thestime3-1.1)*sqrt(100);
s=stdev(thestime3-1.1)*sqrt(100);
a=[-4*s:0.02*s:4*s];
plot2d(a,pnorm(a,u,s),2)
//sqrtn(thetachapeu -theta) semble suivre une loi normale dans le cas sous critique, pas dans les cas critique ou surcritique

