Home > wafo > wstats > wfrechpdf.m

wfrechpdf

PURPOSE ^

Frechet probability density function

SYNOPSIS ^

f = wfrechpdf(x,a,c)

DESCRIPTION ^

 WFRECHPDF Frechet probability density function
 
  CALL:  f = wfrechpdf(x,a,c);
 
         f = density function evaluated at x
      a, c = parameters
 
  The Frechet distribution is defined by its cdf
 
   F(x;a,c) = exp(-(x/a)^(-c)), x>=0, a,c>0
 
  Example: 
    x = linspace(0,6,200);
    p1 = wfrechpdf(x,1,1); p2 = wfrechpdf(x,2,2); p3 = wfrechpdf(x,2,5);
    plot(x,p1,x,p2,x,p3)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function f = wfrechpdf(x,a,c)
002 %WFRECHPDF Frechet probability density function
003 %
004 % CALL:  f = wfrechpdf(x,a,c);
005 %
006 %        f = density function evaluated at x
007 %     a, c = parameters
008 %
009 % The Frechet distribution is defined by its cdf
010 %
011 %  F(x;a,c) = exp(-(x/a)^(-c)), x>=0, a,c>0
012 %
013 % Example: 
014 %   x = linspace(0,6,200);
015 %   p1 = wfrechpdf(x,1,1); p2 = wfrechpdf(x,2,2); p3 = wfrechpdf(x,2,5);
016 %   plot(x,p1,x,p2,x,p3)
017 
018 % Reference: 
019 
020 % Tested on; Matlab 5.3
021 % History: 
022 % Added PJ 10-May-2001
023 
024 
025 error(nargchk(3,3,nargin))
026 
027 [errorcode, x, a, c] = comnsize (x,a, c);
028 if (errorcode > 0)
029   error ('x, a and c must be of common size or scalar');
030 end
031 
032 f=zeros(size(x));
033 
034 ok = ((c > 0)  & (a > 0));
035 
036 k = find (x>=0&ok);
037 if any (k)  
038   f(k)=(a(k)./x(k)).^c(k).*c(k)./x(k).*exp(-(x(k)./a(k)).^(-c(k)));
039 %  f(k)=(x(k)./a(k)).^(c(k)-1).*c(k)./a(k).*exp(-(x(k)./a(k)).^c(k));
040 end
041 
042 k1 = find (~ok);
043 if any (k1)
044   tmp=NaN;
045   f(k1) = tmp(ones(size(k1)));
046 end
047

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