Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

 

generates random variates from over 870 univariate distributions

pearson5_pdf(x, a, b, c);
% PEARSON_05_PDF evaluates the Pearson 5 PDF.  Vector Form!
%
%
%  Formula:
%
%    PDF(X)(A,B) = A**B * ( X - C )**(-B-1) 
%      * exp ( - A / ( X - C ) ) / Gamma ( B )
%
%  Modified:
%
%    04 December 1999
%
%  Author:
%
%    John Burkardt
%
%  Translated/Modified:
%
%    Jim Huntley,  03/11/04
%
%  Parameters:
%
%    Input, real X, the argument of the PDF.
%    C < X
%
%    Input, real A, B, C, the parameters of the PDF.
%    0.0 < A, 0.0 < B.
%
%    Output, real PDF, the value of the PDF.
%

function [pdf] = pearson5_pdf(x, a, b, c);

%persistent gamlnb bla

%if(isempty(gamlnb))
    gamlnb = gammaln(b);
    bla = b*log(a);
%end

sx = size(x,2);
for jx = 1:sx
  if (x(jx) <= c) 
    pdf(jx) = 0;
  else
    %pdf(jx) = a^b * (x(jx) - c)^(-b-1) * exp(-a/(x(jx) - c)) / gamma(b);  
    pdf(jx) = exp(bla + log((x(jx) - c)^(-b-1)) + (-a/(x(jx) - c)) - gamlnb);
  end
end

return

Contact us