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

dblnct_cdf(x, nu, delta, lambda)
% dblnct_cdf.m - evaluatess a Doubly Non-Central T Cumulative Distribution.
%   See "Continuous Univariate Distributions", Johnson, Kotz, & Balakrishnan,
%   J. Wiley, v.1, p.499, 1994. 
%
%  Created by Jim Huntley,  12/21/06
%

function [cdf] = dblnct_cdf(x, nu, delta, lambda)

%persistent coef jlim ratioj arg1

% Initializations.
%if(isempty(coef))
    coef = exp(-0.5*lambda);
    jlim = 20;
    for jj = 1:jlim
        %facj = factorial(jj-1);
        c1 = (0.5*lambda)^(jj-1);
        %ratioj(jj) = c1 / facj;
        ratioj(jj) = exp(log(c1) - gammaln(jj));
        arg1(jj) = nu + 2*(jj-1);        
    end
%end

% Calculate CDF.
sum = 0;
arg0(1:jlim) = 0;
for jj = 1:jlim
    arg0(jj) = x*sqrt(1+2*(jj-1)/nu);
    nctcdf = nc_t_cdf(arg0(jj),arg1(jj),delta);
    sum = sum + ratioj(jj) * nctcdf;    
end
    
cdf = coef * sum;
    
return

Contact us