Home > wafo > wstats > wtweibpdf.m

wtweibpdf

PURPOSE ^

Truncated Weibull probability density function

SYNOPSIS ^

f = wtweibpdf(x,a,b,c)

DESCRIPTION ^

 WTWEIBPDF Truncated Weibull probability density function
 
  CALL:  f = wtweibpdf(x,a,b,c);
 
         f = density function evaluated at x
     a,b,c = parameters
 
 
  The Weibull distribution is defined by its cdf
 
   F(x;a,c) = 1 -  exp(-((x+c)/a)^b+abs(c/a)^b), x>=0
 
    Some references refer to the Weibull distribution with
    a single parameter, this corresponds to WTWEIBPDF with a = 1.
 
  Example: 
    x = linspace(0,6,200);
    p1 = wtweibpdf(x,1,1,2); p2 = wtweibpdf(x,2,2,3);
    plot(x,p1,x,p2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function f = wtweibpdf(x,a,b,c)
002 %WTWEIBPDF Truncated Weibull probability density function
003 %
004 % CALL:  f = wtweibpdf(x,a,b,c);
005 %
006 %        f = density function evaluated at x
007 %    a,b,c = parameters
008 %
009 %
010 % The Weibull distribution is defined by its cdf
011 %
012 %  F(x;a,c) = 1 -  exp(-((x+c)/a)^b+abs(c/a)^b), x>=0
013 %
014 %   Some references refer to the Weibull distribution with
015 %   a single parameter, this corresponds to WTWEIBPDF with a = 1.
016 %
017 % Example: 
018 %   x = linspace(0,6,200);
019 %   p1 = wtweibpdf(x,1,1,2); p2 = wtweibpdf(x,2,2,3);
020 %   plot(x,p1,x,p2)
021 
022 % Reference: Cohen & Whittle, (1988) "Parameter Estimation in Reliability
023 % and Life Span Models", p. 25 ff, Marcel Dekker.
024 
025 
026 % Tested on; Matlab 5.3
027 % History: 
028 % revised pab 12.11.2000
029 %  - added check on f(k): Replace NaN's with zero 
030 % revised pab 24.10.2000
031 %  - added comnsize, nargchk
032 % rewritten ms 15.06.2000
033 
034 
035 error(nargchk(3,4,nargin))
036 if nargin<4|isempty(c),c=0;end
037 [errorcode, x, a,b, c] = comnsize (x,a,b, abs(c));
038 if (errorcode > 0)
039   error ('x, a, b and c must be of common size or scalar');
040 end
041 
042 f=zeros(size(x));
043 
044 ok = ((b > 0)  & (a > 0));
045 
046 k = find (x>=0&ok);
047 if any (k)  
048   f(k)=((x(k)+c(k))./a(k)).^(b(k)-1).*b(k)./a(k).*exp(-((x(k)+c(k))./a(k)).^b(k)+abs(c(k)./a(k)).^b(k));
049   k0 = find(isnan(f(k)));
050   if any(k0), 
051     f(k(k0))=0; 
052   end
053 end
054 
055 k1 = find (~ok);
056 if any (k1)
057   tmp=NaN;
058   f(k1) = tmp(ones(size(k1)));
059 end
060 
061 
062 
063 
064 
065 
066

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