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

pearson4_cdf(x, m, nu, a, lambda)
% pearson4_cdf.m - evaluates a Cumulative Pearson Type IV Distribution.
%   See "A Guide to the Pearson Type IV Distribution", J. Heinrich, U. PA, 1/8/04.
%
%  Created by Jim Huntley,  8/18/04
%

function [cdf] = pearson4_cdf(x, m, nu, a, lambda)

%persistent k

%if(isempty(k))
    %k = 2^(2*m-2) * (abs(cgamma(m + i*nu*0.5)))^2 / (pi*a*gamma(2*m - 1));
    k = exp(log(2^(2*m-2) * (abs(cgamma(m + 1i*nu*0.5)))^2) - (log(pi*a) + gammaln(2*m - 1)));
%end

argx = (x - lambda) / a;
if(x < lambda-a*sqrt(3))
    z = 2/(1-1i*argx);
    aa = [1, m+1i*nu*0.5];
    bb = 2*m;
    y = (k*a/(2*m-1)) * (1+(argx^2))^(-m) * exp(-nu*atan(argx)) * ...
        (1i - argx) * pfq(aa, bb, z);
        %(i - (x-lambda)/a) * hypergeometric2f1(aa(1), aa(2), bb, z, 399);
        %(i - (x-lambda)/a) * genHyper(aa, bb, z, 0, 0, 10);       
               
elseif(x > lambda+a*sqrt(3))
    z = 2/(1+1i*argx);
    aa = [1, m-1i*nu*0.5];
    bb = 2*m;
    y = 1 - (k*a/(2*m-1)) * (1+(-argx)^2)^(-m) * exp(nu*atan(-argx)) * ... 
        (1i + argx) * pfq(aa, bb, z);
        %(i - (-x+lambda)/a) * hypergeometric2f1(aa(1), aa(2), bb, z, 399);
        %(i - (-x+lambda)/a) * genHyper(aa, bb, z, 0, 0, 10);
                           
elseif(abs(x-lambda) <= a*sqrt(3))
    z = 0.5*(1+1i*argx);
    aa = [1, 2-2*m];
    bb = 2-m+1i*nu*0.5;
    y = 1/(1-exp(-(nu+2*1i*m)*pi)) - 1i*a*pearson4_pdf(x, m, nu, a, lambda)/(1i*nu-2*m+2) * ...
        (1 + (argx^2)) * pfq(aa, bb, z); 
        %(1 + ((x-lambda)/a)^2) * hypergeometric2f1(aa(1), aa(2), bb, z, 399);
        %(1 + ((x-lambda)/a)^2) * genHyper(aa, bb, z, 0, 0, 10);
                      
end
cdf = abs(y);         

return

Contact us