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

norgam_pdf(x, lambda, alpha, bet, mu)
% norgam_pdf.m - evaluates a Normal Gamma Probability Density.
%   See "Garch Modelling with Skewed Conditional Distributions",
%   J. Miettinen, U. Helsinki, Aug, 2005 (draft),
%   http://www.valt.helsinki.fi/staff/lanne/workshop05/miettinen.pdf.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  1/07/08
%

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

%persistent coef lpow

%if(isempty(coef))
    lpow = lambda - 0.5;
    %coef = (alpha^2-bet^2)^lambda / (sqrt(pi)*2^lpow*gamma(lambda)*alpha^lpow);
    coef = exp(lambda*log(alpha^2-bet^2) - 0.5*log(pi)-lpow*log(2)-gammaln(lambda)-lpow*log(alpha));
%end

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

return

Contact us