function f = logn_pdf(X,medX,covX)
% f = logn_pdf(X,medX,covX)
% return PDF of lognormal distribution with median medX and
% coefficient of variation covX, at points X
%
%    If X is a lognormal random variable, then the log of X is normally 
%    distributed with a median of medX and a coefficient of variation of covX 
%
%    Reference: http://en.wikipedia.org/wiki/Log-normal_distribution

  [r_x,c_x] = size(X);

  idx = find(X<=0);
  X(idx) = 0.01;

  Vlnx = log(1 + covX^2);	% variance of log X

  f = 1/sqrt(2*pi*Vlnx) * (1./X) .* exp(-0.5*(log(X/medX)).^2/Vlnx);

% ----------------------------------------------------------------- logn_pdf
