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

alphetamu_cdf(x, alpha, eta, mu)
% alphetamu_cdf.m - evaluates an Alpha-Eta-Mu Cumulative Distribution.
%   See "The Alpha - Eta - Mu and Alpha - Kappa - Mu Fading Distributions", 
%   g. Fraidenraich and M. D. Yacoub et al., U. Campinas, IEEE.
%
%  Created by Jim Huntley,  9/18/06
%

function [cdf] = alphetamu_cdf(x, alpha, eta, mu)

%persistent sum0 coef

jlim = 7;

% Normalization.
%if(isempty(sum0))
    sum0 = 0;
    for j = 1:jlim+1
        %sum0 = sum0 + 2^(1-2*(j-1)) * sqrt(pi) * eta^mu * (eta+1)^(-2*(j-1)-2*mu) / ...
        %      (factorial(j-1) * gamma(mu) * gamma(j+mu-0.5));        
        sum0 = sum0 + exp(log(2^(1-2*(j-1)) * sqrt(pi) * eta^mu * (eta+1)^(-2*(j-1)-2*mu)) - ...
              (log(factorial(j-1)) + gammaln(mu) + gammaln(j+mu-0.5)));
    end
    coef = exp(log(sqrt(pi) * eta^mu) - (gammaln(mu) + log(sum0)));
%end

% Estimate CDF
sum = 0;
for j = 1:jlim+1
    %sum = sum + 2^(1-2*(j-1)) * (eta-1)^(2*(j-1)) * (eta+1)^(-2*(j-1)-2*mu) * ...
    %      gammainc(2*((j-1)+mu),0.5*x^alpha*(1+eta)^2*mu/eta) / ...
    %      (factorial(j-1) * gamma(0.5+j-1+mu));
    arg = max(2^(1-2*(j-1)) * (eta-1)^(2*(j-1)) * (eta+1)^(-2*(j-1)-2*mu) * ...
          gammainc(2*((j-1)+mu),0.5*x^alpha*(1+eta)^2*mu/eta),eps);
    sum = sum + exp(log(arg) - (log(factorial(j-1)) + gammaln(0.5+j-1+mu)));
end
%cdf = 1  - (sqrt(pi) * eta^mu * sum / (gamma(mu) * sum0));
cdf = 1  - coef * sum;

return

Contact us