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_cdf(n, a)
% deranged_cdf.m - evaluates a Deranged Cumulative Distribution Function.
%   See FORTRAN code: prob_f90, John Burkhardt, 12/19/99.
%
%  Translated by Jim Huntley,  03/10/04
%

function [cdf] = deranged_cdf(n, a)

%persistent glnap1

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

  if ( n < 0 || n > a )
    cdf = 0;
  else
    sum1 = 0;
    for n2 = 0:n
      [cnk] = binomial_coef(a,n2);
      [dnmk] = deranged_enum(a-n2);
      sum1 = sum1 + cnk*dnmk;
    end
    cdf = exp(log(sum1) - glnap1);
  end

return

Contact us