% EXPO_MLE The log-likelihood function of the exponential model
function loglik = expo_mle(w)
   global n t x;
   p = w(1,1)*exp(-w(2,1)*t); % exponential model prediction
   %p = p+(p==zeros(6,1))*1e-5 - (p==ones(6,1))*1e-5; % ensure 0 < p < 1
   p=(p < ones(6,1)).*p+(p >= ones(6,1))*0.999999; %fixed tutorial error
   loglik = (-1)*(x.*log(p)+(n-x).*log(1-p));      %fixed tutorial error
   % minus log-likelihood for individual observations
   loglik = sum(loglik); % overall minus log-likelihood being minimized
