Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

James Huntley (view profile)

 

generates random variates from over 870 univariate distributions

powexp_pdf(x, mu, sigma, nu)
% powexp_pdf.m - evaluates an Power Exponential Probability Density.
%   See "The gamlss Package", 29 May 2006, see
%   "http://cran.xedio.de/doc/packages/gamlss.pdf".
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  8/23/06
%

function [pdf] = powexp_pdf(x, mu, sigma, nu)

%persistent c coef

%if(isempty(c))
    %c = sqrt(2^(-2/nu)*gamma(1/nu)/gamma(3/nu));
    %coef = nu / (sigma*c*2^(1+1/nu)*gamma(1/nu));
    c = sqrt(exp(log(2^(-2/nu)) + gammaln(1/nu) - gammaln(3/nu)));
    coef = log(nu) - log(sigma*c*2^(1+1/nu)) - gammaln(1/nu);
%end

z = (x - mu) ./ sigma;
for jx = 1:size(x,2)
    pdf(jx) = coef * exp(-0.5*(abs(z(jx)-mu)/c)^nu);
end 

return

Contact us