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

sged_pdf(x, mu, sigma, k, lambda)
% sged_pdf.m - evaluates a Skewed Generalized Error Distribution Probability Density.
%   See "Cyclicality in Catastrophic and Operational Risk Measurements", 
%   L Allen and T.G. Bali, CUNY.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  8/24/06
%

function [pdf] = sged_pdf(x, mu, sigma, k, lambda)

%persistent C theta delta sigmak

%if(isempty(C))
    %A = gamma(2/k)/sqrt(gamma(1/k))/sqrt(gamma(3/k));
    A = exp(gammaln(2/k) - 0.5*gammaln(1/k) - 0.5*gammaln(3/k));
    S = sqrt(1+3*lambda^2-4*A^2*lambda^2);
    %theta = sqrt(gamma(1/k)/gamma(3/k))/S;
    theta = exp(0.5*gammaln(1/k) - 0.5*gammaln(3/k))/S;
    %C = k / (2*sigma*theta*gamma(1/k));
    C = exp(log(k) - (log(2*sigma*theta) + gammaln(1/k)));
    delta = 2*lambda*A/S;
    sigmak = sigma^k;
%end

epsi = x - mu + delta*sigma;
pdf = C .* exp(-abs(epsi).^k./(1+sign(epsi).*lambda).^k./theta.^k./sigmak); 

return

Contact us