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

boxcox_pdf(x, sigma, mu, nu)
% boxcox_pdf.m - evaluates a BoxCox Probability Density.
%   See "The Gamlss Package", at
%   "http://cran.r-project.org/doc/packages/gamlss.pdf"
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  07/17/06
%

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

%persistent coef gcdfend

%if(isempty(coef))
    coef = 1 / (sqrt(2*pi) * sigma * mu^nu);
    % Normalization.
    ymax = 1/(sigma*abs(nu));
    gcdfend = gaus_cdf(ymax,0,1);
%end
    
for jx = 1:size(x,2);
    if(nu ~= 0)
        z = ((x(jx)/mu)^nu - 1) / (nu*sigma);
    else
        z = log(x(jx)/mu) / sigma;
    end
    pdf(jx) = coef * x(jx)^(nu-1) * exp(-0.5*z^2);
end

pdf = pdf ./ gcdfend;

return

Contact us