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

genherm(n, alpha, bet, m)
% genherm.m - evaluates a Generalized Hermite Polynomial (Gupta-Jain).
%   See "A Generalized Hermite Distribution", R. Gupta & G. Jain, Sian J. Appl. Math., 
%   v. 27, No. 2, Sept., 1974, p. 359.
%
%  Created by Jim Huntley,  9/28/05.
%
%

function [y] = genherm(n, alpha, bet, m)

%persistent loga logb

%if(isempty(loga))    
    loga = log(alpha);
    logb = log(bet);
%end

uplim = fix(n/m);
nfact = gammaln(n+1);
sum1 = 0;
for jk = 0:uplim
    %sum1 = sum1 + bet^jk * nfact * alpha^(n-m*jk) / (factorial(jk) * factorial(n-m*jk));
    sum1 = sum1 + exp(jk*logb + nfact + (n-m*jk)*loga - (gammaln(jk+1) + gammaln(n-m*jk+1)));
end

y = sum1;

return

Contact us