Home > wafo > wstats > wlognpdf.m

wlognpdf

PURPOSE ^

Lognormal probability density function

SYNOPSIS ^

f = wlognpdf(x,m,v);

DESCRIPTION ^

 WLOGNPDF Lognormal probability density function
 
  CALL:  f = wlognpdf(x,m,s);
 
         f = density function evaluated at x
         m = mean of log(x)     (default 0)
         v = variance of log(x) (default 1)
 
  The Lognormal distribution is defined by its pdf
 
      f(x) = exp(-(log(x)-m)^2/(2*v))/sqrt(v*2*pi*x^2), x>=0.
 
  Example: 
    x = linspace(0,3,200);
    p1 = wlognpdf(x,0,1); p2 = wlognpdf(x,.5,0.25);
    plot(x,p1,x,p2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function f = wlognpdf(x,m,v);
002 %WLOGNPDF Lognormal probability density function
003 %
004 % CALL:  f = wlognpdf(x,m,s);
005 %
006 %        f = density function evaluated at x
007 %        m = mean of log(x)     (default 0)
008 %        v = variance of log(x) (default 1)
009 %
010 % The Lognormal distribution is defined by its pdf
011 %
012 %     f(x) = exp(-(log(x)-m)^2/(2*v))/sqrt(v*2*pi*x^2), x>=0.
013 %
014 % Example: 
015 %   x = linspace(0,3,200);
016 %   p1 = wlognpdf(x,0,1); p2 = wlognpdf(x,.5,0.25);
017 %   plot(x,p1,x,p2)
018 
019 
020 % Reference: Cohen & Whittle, (1988) "Parameter Estimation in Reliability
021 % and Life Span Models", p. 59 ff, Marcel Dekker.
022 
023 % Tested on; Matlab 5.3
024 % History: 
025 % revised pab 24.10.2000
026 %  - added comnsize, nargchk
027 %  - added default values
028 %  - fixed a bug in the parameterization
029 % added ms 10.08.2000
030 
031 error(nargchk(1,3,nargin))
032 if nargin<2|isempty(m),  m=0;  end
033 if nargin<3|isempty(v),  v=1;  end
034 
035 [errorcode, x, m, v] = comnsize (x,m, v);
036 if (errorcode > 0)
037   error ('x, m and v must be of common size or scalar');
038 end
039 
040 f=zeros(size(x));
041 
042 k = find (x>0&v>0);
043 if any(k)    
044   f(k)=1./sqrt(2*pi*v(k)).*exp(-0.5*(log(x(k))-m(k)).^2./v(k))./x(k);
045 end
046 
047 k1 = find (v<=0);
048 if any (k1)
049   tmp=NaN;
050   f(k1) = tmp(ones(size(k1)));
051 end
052 
053 
054 
055 
056

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003