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

norrecgam_pdf(x, lambda, alpha, delta, mu)
% norrecgam_pdf.m - evaluates a Normal ReciprocalGamma 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 !!!
%
%   Note:   Can take sign of alpha in exponential to be negative!!!!
%
%  Created by Jim Huntley,  1/07/08
%

function [pdf] = norrecgam_pdf(x, lambda, alpha, delta, mu)

%persistent coef lpow 

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

arg = sqrt(delta^2 + (x-mu).^2);
pdf = coef .* arg.^lpow .* exp(alpha.*(x-mu)) .* besselk(lpow,alpha.*arg);  

return

Contact us