N = 4000;

for i=1:5
eps=1;
n=1;
t=5;
a=i;

while(eps>10^(-9))
	x2_i(n) = randn+t;
	w2_i(n) = exp(-a*(abs(x2_i(n)-a)+a));
	thetaN_2(n) = (1/2)*(exp(a^2/2)*mean(w2_i');
		if(n==1)
			eps=1;
		else
			eps=abs(var(thetaN_2(1:n)')-var(thetaN_2(1:n-1)'));
		end;
	n=n+1;
end;

disp('The esitmated theta is for ', num2str(a));
disp('thetaN_2(end)');

end
