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

boxcoxt_pdf(x, mu, sigma, nu, tau)
% boxcoxt_pdf.m - evaluates a Box Cox T Probability Density.
%   See BCT, "The GAMLSS Package", 
%   http://cran.r-project.org/doc/packages/gamlss.pdf, p.12.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  11/8/07
%

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

%persistent coef anu

%if(isempty(coef))
    %coef = gamma(0.5*(tau+1)) / (mu^nu * sigma * gamma(0.5) * gamma(0.5*tau) * sqrt(tau));
    coef = gammaln(0.5*(tau+1)) - (nu*log(mu) + log(sigma) + gammaln(0.5) + ...
           0.5*log(tau) + gammaln(0.5*tau));
    anu = abs(nu);
%end

if(nu == 0)
    z = log(x./mu) ./ sigma;
else
    z = ((x./mu).^nu - 1) ./ (nu * sigma);
end

pdf = exp(coef + (nu-1).*log(x) - 0.5.*(tau+1) .* log(1 + (z.^2)./tau));
% Normalization.
pdf = pdf ./ t_cdf(1/(sigma*anu),tau);

return

Contact us