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

fmax_pdf(x, nu, k)
% fmax_pdf.m - evaluates an F Maximum Probability Density.
%   See "Continuous Univariate Distributions", Johnson, Kotz & Balakrishnan,
%   Vol. 2, J. Wiley, 1995, p.353.
%
%  Created by Jim Huntley,  11/20/06
%

function[pdf] = fmax_pdf(x, nu, k)

%persistent nud2 coef ny ymin

%if(isempty(coef))
    nud2 = 0.5 * nu;
    coef = exp(-k*(nud2*log(2)+gammaln(nud2)));
    ny = 1000;
    ymin = 0;
%end

for jx = 1:size(x,2)
    ymax = x(jx);
    dy = (ymax-ymin) / (ny-1);
    y = ymin:dy:ymax;
    kern = y.^(nud2-1) .* exp(-0.5.*y);
    ikern = simps(y,kern);    
    pdf(jx) = k .* coef .* ikern^(k-1) .* x(jx)^(nud2-1) .* exp(-0.5*x(jx));
end

return



Contact us