function y = log_pnorm(x,mu,sigma) %%log_pnorm(x,mu,sigma) returns the log of the probability of observing x from a normal distribution with %%mean mu and variance exp(sigma) temp1 = -(0.5)*log(2*pi) - (0.5)*log(sigma); %temp2 = log(sigma) - log(2) + 2*log(x) + 2*log(1-(mu/x)); if x~=mu temp2 = -log(sigma) - log(2) +log((x-mu)^2); y= temp1 - exp(temp2); else y=temp1; end