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

genmarpol_pdf(n, rho, r, s, N)
% genmarpol_pdf.m - evaluates a Generalized Markov-Polya Probability Density.
%   See "On a Generalized Markov Polya Distribution", K. G. Janardan,   
%   Gujarat Statistical Review, Vol. 5, No.1, April, 1978.  
%
%  Created by Jim Huntley,  10/30/08
%

function[pdf] = genmarpol_pdf(n, rho, r, s, N)

%persistent coef q

%if(isempty(coef))
    q = 1 - rho;
    prod3 = 1;
    for jj = 1:N
        j = jj - 1;
        prod3 = prod3 * (1 + N*s + j*r);
    end
    coef = rho*q*(1+N*s) / prod3;
%end

prod1 = 1;
prod2 = 1;
for jj = 1:n
    j = jj - 1;
    prod1 = prod1 * (rho + n*s + j*r);
end
for jj = 1:N-n
    j = jj - 1;
    prod2 = prod2 * (q + N*s - n*s + j*r);
end 
pdf = coef * prod1 * prod2 * binomial_coef(N,n) / ...
          ((rho+n*s)*(q+N*s-n*s));

return



Contact us