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

unisum_pdf(x, n)
% unsum_pdf.m - evaluates a Uniform Sum Probability Density.
%   See "Uniform Sum Distribution", http://mathworld.wolfram.com.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  11/03/05
%

function [pdf] = unisum_pdf(x, n)

facnm1=factorial(n-1);
%facn = factorial(n);
facn = gammaln(n+1);
sx = size(x,2);

for jx = 1:sx
sum1 = 0;
	for jk = 1:n+1
        %sum1 = sum1 + (-1)^(jk-1) * facn * (x(jx)-jk+1)^(n-1) * sign(x(jx)-jk+1) / (factorial(n-jk+1)*factorial(jk-1));
        sum1 = sum1 + (-1)^(jk-1) * sign(x(jx)-jk+1) * real(exp(facn + (n-1)*log(x(jx)-jk+1+eps)  - (gammaln(n-jk+2)+gammaln(jk))));
    end 
pdf(jx) = sum1 / (2*facnm1);
end


return

Contact us