function [L] = logl_prob(b)
% The following is the loglikelihood function for a probit model.

global x z N

b0 = b(1);
b1 = b(2);

XB = b0*ones(size(x,1),1) + b1*x ;

L=0 ;
for i = 1:N
  if z(i) == 1
    L = L + log(normcdf(XB(i)));
  else
    L = L + log(1 - normcdf(XB(i)));
  end   
end

L = -L;

end

