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

qhyper2_pdf(n, s, r, m, nn)
% qhyper2_pdf.m - evaluates a quasi-Hypergemoertic (-Polya) II Probability Density.
%   See "Sheffer sequences, probability distributions
%    and approximation operators", Craciun and DiBucchianico, 29 Oct, 2004.    
%
%  Created by Jim Huntley,  9/26/07
%
%   Calls:  'fallfac' included below.
%

function [pdf] = qhyper2_pdf(n, s, r, m, nn)

%persistent coef

%if(isempty(coef))
    coef = s * m / ((s+m)*fallfac(s+m+r*nn-1,nn-1));
%end

pdf = coef * binomial_coef(nn,n) * fallfac(s+r*n-1,n-1) * fallfac(m+r*(nn-n)-1,nn-n-1);

return


function [val] = fallfac(n,k)

if(k == -1)
    val = 1 / (n+1);                                
end
if(k == 0)
    val = 1;
end
if(k > 0)
    val = exp(-gammaln(n-k+1) + gammaln(n+1));      
end

return

Contact us