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

holla_pdf(n, mu, lambda)
% holla_pdf.m  is the Holla Probability Density.
%   See "http://www.addlink.es/pdf/AGDWeb250.pdf", Mathstatica.
%
%  Created by Jim Huntley,  09/11/06
%

function [pdf] = holla_pdf(n, mu, lambda)

%persistent coef lglambda lgmu lgterm

%if(isempty(coef))
    coef = sqrt(2/pi) * exp(lambda/mu);
    lglambda = log(lambda);
    lgmu = log(mu);
    lgterm = log(lambda+2*mu^2);
%end

%pdf = coef * lambda^(0.25*(1+2*n)) * mu^(n-0.5) * (lambda+2*mu^2)^(0.25*((1-2*n))) ...
%    * besselk(0.5-n,sqrt(lambda*(lambda+2*mu^2))/mu) / factorial(n);
pdf = coef * exp((0.25*(1+2*n))*lglambda + (n-0.5)*lgmu + (0.25*((1-2*n)))*lgterm ...
    + log(besselk(0.5-n,sqrt(lambda*(lambda+2*mu^2))/mu)) - gammaln(n+1));

return

Contact us