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

binunif_pdf(x, p, h)
% binunif_pdf.m - evaluates a Binomial Uniform Probability Density.
%   See "Continuous Univariate Distributions", V 2, Johnson, Kemp, and Kotz,
%   J. Wiley, p.310, 1996. 
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  11/28/06
%

function [pdf] = binunif_pdf(x, p, h)

% Initializations.
q = 1 - p;
coef = p / h^2;

% Calculate PDF.
for jx = 1:size(x,2)
    k  = fix(x(jx)/h);
    if(k == 0)
        pdf(jx) = coef * x(jx);
    elseif(k > 0)
        pdf(jx) = coef * q^(k-1) * (h - p*(x(jx)-k*h));
    end
end

return


Contact us