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

qdisunifr_pdf(n, M, nn, q)
% qdisunifr_pdf.m - evaluates a q-Discrete Uniform Range 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/02/07
%

function [pdf] = qdisunifr_pdf(n, M, nn, q)

%persistent bmp1q Q bmp1qn b2qn

%if(isempty(Q))
    bmp1q = (q^(M+1) - 1) / (q - 1);
    Q = q^nn;
    bmp1qn = (Q^(M+1) - 1) / (Q - 1);
    b2qn = (Q^2 - 1) / (Q - 1);
%end

if(n == 1)
    pdf(1) = bmp1qn / bmp1q^nn;
else
    blq = (q^n - 1) / (q - 1);
    blp1q = (q^(n+1) - 1) / (q - 1);
    blm1q = (q^(n-1) - 1) / (q - 1);
    bmp1mlqn = (Q^(M+1-n) - 1) / (Q - 1);
    pdf = bmp1mlqn * (blp1q^nn - b2qn*blq^nn + (q^nn * blm1q^nn)) / bmp1q^nn;
end

return


Contact us