function F = ss_init1(x)

% steady-state program for ekf_PH3d_fc_rec3
global T;global U;global nt;global Y;

%{
U1 = sum(Y(1:T,1),1)/T;
U2 = sum(Y(1:T,2),1)/T;
U3 = sum(Y(1:T,3),1)/T;
U4 = sum(Y(1:T,4),1)/T;
U5 = sum(Y(1:T,5),1)/T;
%}
U1 = mean(U(:,1),1)/1000;
U2 = mean(U(:,2),1)/1000;
U3 = mean(U(:,3),1)/1000;
U4 = mean(U(:,4),1)/1000;
U5 = mean(U(:,5),1)/1000;

d=x(5);
%d=0.0097;
n =nt;
wl = x(1);
wh = x(2);
pl(1,1) = exp(-exp(x(3)));
ph(1,1) = exp(-exp(x(4)));

for i=2:n
pl(i,1) = exp(-exp(x(3)+(i-1)*d));
ph(i,1) = exp(-exp(x(4)+(i-1)*d));
end

uhat(1,1) = wl+wh;
for j=2:n
uhat(j,1) = wl*prod(pl(1:j-1,1),1)+wh*prod(ph(1:j-1,1),1);
end

uhat1 = uhat(1,1);
uhat23 = sum(uhat(2:3,1),1);
uhat46 = sum(uhat(4:6,1),1);
uhat712 = sum(uhat(7:12,1),1);
uhat13 = sum(uhat(13:n,1),1);

X = [uhat1-U1;
     uhat23-U2;
     uhat46-U3;
     uhat712-U4;
     uhat13-U5];

F = 10000*(X'*X);
