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

apd_pdf(x, alpha, lambda)
% apd_pdf.m - evaluates an Asymmetric Power Probability Density.
%   See "Asymmetric Power Distributions: Theory and Applications to Risk Management", 
%   I. Komunjer, Caltech, web.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  3/30/05
%

function [pdf] = apd_pdf(x, alpha, lambda)

%persistent delta deltalam

%if(isempty(delta))
    delta = 2 * alpha^lambda * (1-alpha)^lambda / (alpha^lambda + (1-alpha)^lambda);
    deltalam = log(delta^(1/lambda));
%end

sx = size(x,2);

for jx = 1:sx
    arg = delta * (abs(x(jx)))^lambda;
    if(x(jx) <= 0)
        pdf(jx) = exp(deltalam + (-arg/alpha^lambda) - gammaln(1 + 1/lambda));
    elseif(x(jx) > 0)
        pdf(jx) = exp(deltalam + (-arg/(1-alpha)^lambda) - gammaln(1 + 1/lambda));    
    end
end 

return

Contact us