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

deranged_pdf(n, a)
% deranged_pdf.m - evaluates a Deranged Probability Density Function.
%   See FORTRAN code: prob_f90, John Burkhardt, 12/19/99.
%
%  Created by Jim Huntley,  03/10/04
%
%

function [pdf] = deranged_pdf(n, a)

%persistent glnap1

%if(isempty(glnap1))
    glnap1 = gammaln(a+1);
%end

if ( n < 0 || n > a )
    pdf = 0;
else
    [cnk] = binomial_coef(a, n);
    [dnmk] = deranged_enum(a-n);
    pdf = exp(log(cnk) + log(dnmk) - glnap1);
end

return

Contact us