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

kempton_pdf(n, b, p, q, N)
% kempton_pdf.m - evaluates a Kempton Probability Density.
%   See "Univariate Discrete Distributions", Johnson, Kemp & Kotz,
%   J. Wiley, 2005, 319. 
%
%  Created by Jim Huntley,  6/22/07
%

function [pdf] = kempton_pdf(n, b, p, q, N)

%persistent coef y dy

%if(isempty(coef))
    ymin = 1e-9;
    ymax = 1;
    ny = 10000;
    dy = (ymax-ymin) / (ny-1);
    y = ymin:dy:ymax;
    coef = (b^p / beta(p,q));
%end


%kern = exp(-y) .* y.^(n(jn)+p-1) ./ (gamma(n(jn)+1) .* (1+b.*y).^(p+q));
kern = exp(-y + (n+p-1).*log(y) - gammaln(n+1) - (p+q).*log(1+b.*y));
I = simps(kern) * dy;
pdf = coef * I;
    
return

Contact us