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

ztgengeg_pdf(n, alpha, bet, lambda, m)
% ztgengeg_pdf.m - evaluates a Zero-Truncated Generalized Gegenbauer Probability Density.
%   See "Generalized Gegenbauer Distribution Revised ", G. Wimmer & G. Altmann, 
%   Indian Journal of Statistics, 1995, V. 57, Ser. B. Pt 3, p.452.
%
%  Created by Jim Huntley,  9/7/04
%

function [pdf] = ztgengeg_pdf(n, alpha, bet, lambda, m)

%persistent coef loga logb

%if(isempty(coef))
	coef = (1 - alpha - bet)^lambda;
    loga = log(alpha);
    logb = log(bet);
%end

intlim = fix(n/m) + 1;
sum1 = 0;
for ji = 1:intlim       
    %sum1 = sum1 + gamma(lambda+n-m*(ji-1)+ji-1) * alpha^(n-m*(ji-1)) * bet^(ji-1) / ...
    %            (factorial(ji-1) * gamma(n-m*(ji-1)+1) * gamma(lambda));
    sum1 = sum1 + exp(gammaln(lambda+n-m*(ji-1)+ji-1) + (n-m*(ji-1))*loga + (ji-1)*logb - ...
                (gammaln(ji) + gammaln(n-m*(ji-1)+1)) + gammaln(lambda));        
end
pdf = coef * sum1 / (1-coef);

return

Contact us