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

fisher_pdf(x, rho2, n, k)
% fisher_pdf.m - evaluates a Fisher Probability Density.
%   See "Continuous Univariate Distributions", Vol. 2, Johnson, Kotz and Balkrishnan,
%   J. Wiley, p. 619, 1995.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  01/11/07
%

function [pdf] = fisher_pdf(x, rho2, n, k)

arg = 0.5 * (n-1);
kd2 = 0.5 * k;
arg2 = 0.5 * (n-k-1);
%pdf = (1-rho2)^arg .* x.^(kd2-1) .* (1-x).^(arg2-1) .* ...
%      genHyper([arg arg],0.5*k,rho2.*x) ./ beta(kd2,arg2);

ilim = 20;

for jx = 1:size(x,2)
    sumi = 0;
    for ji = 1:ilim
        i = ji - 1;
        sumi = sumi + exp(i*log(rho2) + i*log(x(jx)) + 2*gammaln(arg+i) - ...
               (gammaln(i+1) + gammaln(kd2+i)));
    end
    pdf(jx) = exp(arg*log(1-rho2) + (0.5*(k-2))*log(x(jx)) + (0.5*(n-k-3))*log(1-x(jx)) + log(sumi) - ...
              (gammaln(arg) + gammaln(arg2)));
end

return

Contact us