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

hari_pdf(n, p)
% hari_pdf.m - evaluates a Hari Probability Density.
%   See "Lagrangian Probability Distributions", P.C. Consul & F. Famoye,
%   Birkhauser, 2006, Table 1.1.
%
%  Created by Jim Huntley,  11/25/08
%

function [pdf] = hari_pdf(n, p)

%persistent q logp logom2q logpq

%if(isempty(q))
    logp = log(p);
    q = 1 - p;
    logom2q = log(1-2*q);
    logpq = log(p*q);
%end

%pdf = (1-lambda) * exp(-n*lambda + (n-1)*log(n*lambda) - gammaln(n));
pdf = exp(gammaln(n+1) + logp + logom2q + ((n-1)/2)*logpq -...
      (gammaln((n+1)/2)+gammaln((n+3)/2)));

return

Contact us