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

dncbet_cdf(x, a, b, lambda1, lambda2)
% dncbet_cdf.m - evaluates a Doubly Non-Central Beta Cumulative Distribution.
%   See "A Note on the Noncentral Beta Distribution Function", R. Chattamvelli,
%   The American Statiticain, v.49, No.2, p.231, May 2005. 
%
%  Created by Jim Huntley,  09/30/11
%

function [cdf] = dncbet_cdf(x, a, b, lambda1, lambda2)

%persistent coef1 coef2 lgl1d2 lgl2d2 ijmax

%if(isempty(coef1))
    lamb1d2 = lambda1 / 2;
    lgl1d2 = log(lamb1d2);
    lamb2d2 = lambda2 / 2;
    lgl2d2 = log(lamb2d2);
    coef1 = exp(-lamb1d2);
    coef2 = exp(-lamb2d2);
    ijmax  = max(10,10 + 4*((lamb1d2+lamb2d2)-2.5))    %heuristic
%end

sumij = 0;
for ji = 1:ijmax 
    ii = ji - 1;        
    Pi = coef1 * exp(ii*lgl1d2 - gammaln(ii+1));
    for jj = 1:ijmax
        j = jj - 1;
        Qj = coef2 * exp(j*lgl2d2 - gammaln(j+1));
        sumij = sumij + Pi .* Qj .* betainc(x,a+ii,b+j);
    end
end
cdf = sumij;

return

Contact us