Home > wafo > wstats > wlognstat.m

wlognstat

PURPOSE ^

Mean and variance for the Lognormal distribution.

SYNOPSIS ^

[m,v]= wlognstat(m0,v0);

DESCRIPTION ^

 WLOGNSTAT Mean and variance for the Lognormal distribution.
  
  CALL:  [m,v] = wlognstat(m0,v0)
 
    m, v = the mean and variance, respectively 
  m0, v0 = parameters of the Lognormal distribution.
 
   Mean (m) and variance (v) for the Lognormal distribution is
 
   m=exp(m0+v0/2)  and  v=exp(2*m0+v0)*(exp(v0)-1);
 
  Example:
    [m,v] = wlognstat(0,1)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function [m,v]= wlognstat(m0,v0);
002 %WLOGNSTAT Mean and variance for the Lognormal distribution.
003 % 
004 % CALL:  [m,v] = wlognstat(m0,v0)
005 %
006 %   m, v = the mean and variance, respectively 
007 % m0, v0 = parameters of the Lognormal distribution.
008 %
009 %  Mean (m) and variance (v) for the Lognormal distribution is
010 %
011 %  m=exp(m0+v0/2)  and  v=exp(2*m0+v0)*(exp(v0)-1);
012 %
013 % Example:
014 %   [m,v] = wlognstat(0,1)
015 
016 % Reference: Cohen & Whittle, (1988) "Parameter Estimation in Reliability
017 % and Life Span Models", p. 59 ff, Marcel Dekker.
018 
019 
020 
021 % Tested on; Matlab 5.3
022 % History:
023 % revised pab 24.10.2000
024 %  - added comnsize, nargchk
025 %  - added default values
026 % added ms 10.08.2000
027 
028 error(nargchk(0,2,nargin))
029 if nargin<1|isempty(m0),  m0=0;  end
030 if nargin<2|isempty(v0),  v0=1;  end
031 
032 [errorcode, m0, v0] = comnsize (m0, v0);
033 if (errorcode > 0)
034   error ('m and v must be of common size or scalar');
035 end
036 
037 m = zeros(size(m0));
038 v = m;
039 k = find(v0>=0);
040 if any(k),
041   m(k) = exp(m0(k)+v0(k)/2);
042   v(k) = exp(2*m0(k)+v0(k)).*(exp(v0(k))-1);
043 end
044 k1 = find(v0<0);
045 if any(k1),
046   tmp=NaN;
047   m(k1) = tmp(ones(size(k1)));
048   v(k1) = m(k1);
049 end
050 
051 
052

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