Home > wafo > wstats > wtraylpdf.m

wtraylpdf

PURPOSE ^

Truncated Rayleigh probability density function

SYNOPSIS ^

f = wraylpdf(x,b,c);

DESCRIPTION ^

 WTRAYLPDF Truncated Rayleigh probability density function
 
  CALL:  f = wtraylpdf(x,b,c);
 
         f = density function evaluated at x
         b = scale parameter
         c = truncation parameter (default 0)
  
  The Truncated Rayleigh distribution is defined by its cdf
 
   F(x;b,c) = 1 - exp(-(x-c)^2/(2b^2)+c^2/(2*b^2)), x>=0, b>0
 
  Example: 
    x = linspace(0,4,200);
    p1 = wtraylpdf(x,1); p2 = wtraylpdf(x,0.5,-2);
    plot(x,p1,x,p2)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function f = wraylpdf(x,b,c);
002 %WTRAYLPDF Truncated Rayleigh probability density function
003 %
004 % CALL:  f = wtraylpdf(x,b,c);
005 %
006 %        f = density function evaluated at x
007 %        b = scale parameter
008 %        c = truncation parameter (default 0)
009 % 
010 % The Truncated Rayleigh distribution is defined by its cdf
011 %
012 %  F(x;b,c) = 1 - exp(-(x-c)^2/(2b^2)+c^2/(2*b^2)), x>=0, b>0
013 %
014 % Example: 
015 %   x = linspace(0,4,200);
016 %   p1 = wtraylpdf(x,1); p2 = wtraylpdf(x,0.5,-2);
017 %   plot(x,p1,x,p2)
018 
019 % Reference: Cohen & Whittle, (1988) "Parameter Estimation in Reliability
020 % and Life Span Models", p. 181 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 15.06.2000
028 
029 
030 error(nargchk(2,3,nargin))
031 if nargin<3|isempty(c),c=0;end
032 [errorcode, x, b,c] = comnsize (x,b,c);
033 if (errorcode > 0)
034   error ('x, b and c must be of common size or scalar');
035 end
036 
037 f=zeros(size(x));
038 
039 k = find ((x>=0)&(b>0));
040 if any (k)  
041   f(k)=(x(k)-c(k)).*exp(-((x(k)-c(k)).^2 -abs(c(k)).^2)./(2*b(k).^2))./b(k).^2;
042 end
043 
044 k1 = find (b<=0);
045 if any (k1)
046   tmp=NaN;
047   f(k1) = tmp(ones(size(k1)));
048 end
049 
050

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