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

err_cdf(x,alpha)
% err_cdf.m  -  Error Probability Density Function.
% See Dataplot Reference Manual, ERRCDF, NIST.
%
% Created by:  J. Huntley,  04/13/06

function [cdf] = err_cdf(x,alpha)

%persistent oda gamlnoda gamln1poda l2a

%if(isempty(oda))
    oda = 1 / alpha;
    gamlnoda = gammaln(oda);
    gamln1poda = gammaln(1+oda);
    l2a = log(2*alpha);
%end

absx = abs(x);
if(x >= 0)
    %cdf = gamma(oda)*gammainc(absx^alpha,oda) / (2*alpha*gamma(1+oda)) + 0.5;
    cdf = exp(gamlnoda + log(gammainc(absx^alpha,oda)) - (l2a + gamln1poda)) + 0.5;
end
if(x < 0)
    %cdf = -gamma(oda)*gammainc(absx^alpha,oda) / (2*alpha*gamma(1+oda)) + 0.5;
    cdf = -exp(gamlnoda + log(gammainc(absx^alpha,oda)) - (l2a + gamln1poda)) + 0.5;
end

return

Contact us