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

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

function [pdf] = dblnct_pdf(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 PDF.
sum = 0;
arg0(1:jlim) = 0;
for jj = 1:jlim
    arg0(jj) = x * sqrt(1+2*(jj-1)/nu);
    nctpdf = nc_t_pdf(arg0(jj),arg1(jj),delta);
    sum = sum + ratioj(jj) * nctpdf;    
end
    
pdf = coef * sum;
    
return

Contact us