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

vargam_pdf(x, mu, alpha, bet, lambda)
% vargam_pdf.m - evaluates a Variance Gamma Probability Density.
%   See Wikipedia, web.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  8/14/07
%

function [pdf] = vargam_pdf(x, mu, alpha, bet, lambda)

%persistent coef gam pow

%if(isempty(gam))
    gam = sqrt(alpha^2 - bet^2);
    pow = lambda-0.5;
    coef = exp((2*lambda)*log(gam) - (log(sqrt(pi))+gammaln(lambda)+pow*(2*alpha)));
%end

arg = abs(x-mu);
pdf = coef .* arg.^pow .* besselk(pow,alpha.*arg) .* exp(bet.*(x-mu));

return

Contact us