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

qchuvan_pdf(n, c, q, tsi)
% qchuvan_pdf.m - evaluates a q-Chu Vandermode Probability Density.
%   See "Steady-State Markov Chain models for Certain q-confluent Hypergeometric 
%   Distributions", A.W. Kemp, Journal of Stat. Planning and Inference", 
%   vol.135, 2005, p.107.
%
%  Created by Jim Huntley,  2/23/09
%

function [pdf] = qchuvan_pdf(n, c, q, tsi)

%persistent pdfhold prodlim
persistent pdfhold

%if(isempty(prodlim))
    prodlim = 20/(1-q);         % heuristic.
%end

if(n == 0)
    pdfhold = uq(c,q,prodlim) / uq(-c/tsi,q,prodlim);
    pdf = pdfhold;
elseif(n > 0)
    pdf = pdfhold * (1+tsi*q^(n-1))*q^(n-1)*c / ... 
                (tsi*(1-c*q^(n-1))*(1-q^n));
    pdfhold = pdf;
end

return

function [prodjn] = uq(u,q,prodlim)

prodjn = 0;
for jn = 1:prodlim
    prodjn = prodjn + log((1-u*q^(jn-1)));
end
prodjn = exp(prodjn);

return

Contact us