
function [logp] = loglogistic(z)

% takes the log of the logistic function in a numerically stable manner

logp = zeros(size(z));

I = find(z>0);
logp(I) = -log(1+exp(-z(I)));

I = find(z<=0);
logp(I) = z(I)-log(1+exp(z(I)));
