Home > wafo > wstats > winvgpdf.m

winvgpdf

PURPOSE ^

Inverse Gaussian probability density function

SYNOPSIS ^

f = winvgpdf(x,m,l);

DESCRIPTION ^

 WINVGPDF Inverse Gaussian probability density function
 
  CALL:  f = winvgpdf(x,m,l);
 
         f = density function evaluated at x
       m,l = parameters
 
  The Inverse Gaussian distribution is defined by its pdf
 
         f(x)=(l/(2*pi*x^3))^(1/2)*exp(-l*(x-m)^2/(2*m^2*x)), x>0.
 
  Example: 
    x = linspace(0,3,200);
    p1 = winvgpdf(x,1,1); p2 = winvgpdf(x,1,.25);
    plot(x,p1,x,p2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

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