Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates

by

James Huntley (view profile)

 

generates random variates from over 870 univariate distributions

qhyper1_pdf(n, s, r, m, nn)
% qhyper1_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] = qhyper1_pdf(n, s, r, m, nn)

%persistent coef

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

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

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