function [H,DH,D2H]=H_missing(mu,x0,Z,theta)
%L=likleihood function for missing data example, DL is first derivate and
%D2L is second
% Z is assumed exponential with mean theta and pie(Z)=exp(-Z),Z>0 and must
% be scalar-otherwise loops through elements of Z
%x0=[-1.5 -1 -.3 .5 1 2]; 
m=length(Z); H=zeros(1,m);DH=H;D2H=H;
for i=1:m
x=[x0 Z(i)];
H(i)=exp(-.5*sum((x-mu).^2));
H(i)=H(i)*(1-exp(-max(Z(i),0)))*theta*exp(Z(i)/theta);
s=sum(x-mu);
DH(i)=H(i)*s;
D2H(i)=H(i)*(s^2-length(x));
end
% for use with fminsearch see H_miss2