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

betanorm_pdf(x, alpha, bet, mu, sigma)
% betanorm_pdf.m - evaluates a Beta Normal Probability Density.
%   See "Beta-Normal Distribution: Bimodality Properties and Application", 
%   F. Famoye, C. Lee, N. Eugene,
%   Journal of Modern Applied Staistical Methods, Vol. 3, No. 1, May 2004, p. 85.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  04/05/05
%

function [pdf] = betanorm_pdf(x, alpha, bet, mu, sigma)

%persistent gamsum prodgam logsigma

%if(isempty(gamsum))
    gamsum = gammaln(alpha + bet);
    prodgam = gammaln(alpha) + gammaln(bet);
    logsigma = log(sigma);
%end

sx = size(x,2);
for jx = 1:sx
    arg = (x(jx) - mu) / sigma;
    cdfnorm = gaus_cdf(arg, mu, sigma);
    pdfnorm = gaus_pdf(arg, mu, sigma);
    %pdf(jx) = gamsum * (cdfnorm)^(alpha-1) * (1-cdfnorm)^(bet-1) * pdfnorm / (sigma * prodgam);
    pdf(jx) = exp(gamsum + log((cdfnorm)^(alpha-1) * (1-cdfnorm)^(bet-1) * pdfnorm) - (logsigma + prodgam));
end 

return

Contact us