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

qcontag_pdf(n, N, m, s, u, q)
% qcontag_pdf.m - evaluates an q-Eggenberger Polya Urn (q-contagious)Probability Density.
%     "q-Probability: I. Basic Discrete Distributions", 
%     B. Kupershmidt, J. Nonlinear Math., vol. 7, No. 1 p.73, 2000.
%
%  Created by Jim Huntley,  03/01/07
%

function [pdf] = qcontag_pdf(n, N, m, s, u, q)

%persistent Q x prodc

%if(isempty(Q))
    Q = q^(-s);
    x = (Q^N - 1) / (Q - 1);
    prodc = 1;
    for jc = 1:N
        cp = (q^(m + u + (jc-1)*s) - 1) / (q - 1);
        prodc = prodc * cp;
    end
%end

prodx = 1;
prodk = 1;
proda = 1;
prodb = 1;
for jx = 1:n
    xp = (Q^(N-jx+1) - 1) / (Q - 1);
    prodx = prodx * xp;
end
for jk = 1:n
    kp = (Q^jk - 1) / (Q - 1);
    prodk = prodk * kp;
end
for ja = 1:n
    ap = (q^(m + (ja-1)*s) - 1) / (q - 1);
    proda = proda * ap;
end
for jb = 1:N-n
    bp = (q^(u + (jb-1)*s) - 1) / (q - 1);
    prodb = prodb * bp;
end

pdf = q^((m+s*n)*(N-n)) * prodx * proda * prodb / (prodk * prodc);

return


Contact us