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

nc_beta_pdf(x, p, q, lambda)
% nc_beta_pdf.m - evaluates a Non-Central Beta Probability Density.
%   See "Handbook on Statistical Distributions for Experimentalists", C. Walck, 5/22/01, p. 108.
%
%  Created by Jim Huntley,  8/25/04
%

function [pdf] = nc_beta_pdf(x, p, q, lambda)

%persistent rlimit ohlam logl

%if(isempty(logl))
    rlimit = 50;
    ohlam = 0.5 * lambda;
    logl = log(ohlam);
%end

sum1 = 0;
for jr = 1:rlimit
    %sum1 = sum1 + (0.5*lambda)^(jr-1) * exp(-0.5*lambda) * x^(p+jr-2) * (1-x)^(q-1) / ...
    %      (factorial(jr-1) * beta(p+jr-1,q));
    sum1 = sum1 + exp((jr-1)*logl - ohlam + (p+jr-2)*log(x) + (q-1)*log(1-x) - ...
          (gammaln(jr) + log(beta(p+jr-1,q)+eps)));
end
pdf = sum1;  

return

Contact us