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

qnarayana_pdf(n, q, k, nmax)
% qnarayana_pdf.m - evaluates a q-Narayana Probability denisity.
%   See "q-Narayana Numbers and the Flag h-Vector of J(2 x n)", Petter Branden, 
%   http://www.math.chalmers.se/Math/Research/Combinatorics/preprints/branden/napo.pdf
%
%  Created by Jim Huntley,  10/28/09
%


function [pdf] = qnarayana_pdf(n, q, k, nmax)

%persistent pdfall

%Initializations.
%if(isempty(pdfall))
    omq = 1 - q;
    coef = q^(k^2 + k);
    kp1 = k + 1;
    for jn = 1:nmax
        qn = (1-q^jn) / omq;
        qk = (1-q^k) / omq;
        qkp1 = (1-q^kp1) / omq;
        qbinnk = binomial_coef(qn,qk);
        qbinnkp1 = binomial_coef(qn,qkp1);
        cdfall(jn) = coef * qbinnk * qbinnkp1 / qn;   
    end
    cdfall = cdfall ./ cdfall(end);
    pdfall = filter(-smooth_diff(4),1,cdfall);
%end

pdf = pdfall(n);

return


    

Contact us