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

dblncf_cdf(x,nu1,nu2,lambda1,lambda2)
% dblncf_cdf.m - tests a Doubly Non-Central F Cumulative Distribution.
%   See "Continuous Univariate Distributions", Johnson, Kotz, & Balakrishnan,
%   J. Wiley, v.1, p.500, 1994. 
%
%  Created by Jim Huntley,  12/20/06
%

function [cdf] = dblncf_cdf(x,nu1,nu2,lambda1,lambda2)

%persistent coef jlim klim arg1 arg2 ratioj ratiok

% Initializations.
%if(isempty(coef))
    coef = exp(-0.5*(lambda1+lambda2));
    jlim = 20;
    klim = 20;
    for jj = 1:jlim
        facj = gammaln(jj);
        c1 = (0.5.*lambda1).^(jj-1);
        arg1(jj) = 0.5*nu1+jj-1;
        ratioj(jj) = exp(log(c1) - facj);
    end
    for kk = 1:klim
        fack = gammaln(kk);
        c2 = (0.5.*lambda2).^(kk-1);
        arg2(kk) = 0.5*nu2+kk-1;
        ratiok(kk) = exp(log(c2) - fack);
    end   
%end

% Calculate CDF.
sum = 0;
arg0 = x / (1+x);
for jj = 1:jlim
    for kk = 1:klim
        sum = sum + ratioj(jj) * ratiok(kk) * betainc(arg0,arg1(jj),arg2(kk)); 
    end
end

cdf = coef * sum;
    
return

Contact us