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

dstable_pdf(n, gam, lambda)
% dstable_pdf.m - tests a Discrete Stable Probability Density.
%   See "Discrete Stable Random Variables", G. Christop and K. Schreiber,
%   U. Magdeburg.
%
%  Created by Jim Huntley,  8/08/06
%

function [pdf] = dstable_pdf(n, gam, lambda)

yy(1) = exp(-lambda);
for kk = 1:n
    k = kk - 1;
    coef = lambda / (k+1);    
    sum = 0;
    for mm = 1:k+1
        m = mm - 1;
        pterm = yy(k-m+1) * (m+1) * (-1)^m;
        prod = gam;
        for j = 1:m
           prod = prod * (gam-j);
        end
        sum = sum + exp(log(pterm*prod) - gammaln(m+2));
   end 
   yy(k+2) = coef * sum; 
end

pdf = yy(end);

return

Contact us