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

cascade2_pdf(n, d, p, r)
% cascade2_pdf.m - evaluates a Cascade Probability Density.
%   See "A Probabilistic Loading-Dependent Model for Cascading Failure
%   and Possible Implications for Blackouts", I. Dobson et al., 
%   Hawaii Internaltional Conference on System Science, Jan., 2003.
%
%  Created by Jim Huntley,  7/24/06
%

function [y] = cascade2_pdf(n, d, p, r)

if(d >= 1)
    y = 0;
    if(n == r)
        y = 1;
    end
elseif(d > 0 && d < 1)
    if(n == 0)
        y = (1-d)^r;
    elseif(n == 1 && r == 1)
        y = d;
    elseif(n > 0 && r > 1)
        sum1 = 0;
        for jn = 1:n
            arg1 = d;
            arg2 = 1 - (jn-1)*p - d;
            coef = 1;
            if(arg1 < 0)
                phi1 = 0;
            elseif(arg1 >= 0 && arg1 <= 1)
                coef = binomial_coef(r,jn-1) * ((jn-1)*p + d) ^(jn-2);
                phi1 = arg1;
            elseif(arg1 > 1)
                coef = binomial_coef(r,jn-1) * ((jn-1)*p + d) ^(jn-2);
                phi1 = 1;
            end
            if(arg2 < 0)
                phi2 = 0;
            elseif(arg2 >= 0 && arg2 <= 1)
                coef = binomial_coef(r,jn-1) * ((jn-1)*p + d) ^(jn-2);  
                phi2 = arg2;
            elseif(arg2 > 1)
                coef = binomial_coef(r,jn-1) * ((jn-1)*p + d) ^(jn-2);
                phi2 = 1;
            end
            sum1 = sum1 + coef * phi1 * phi2^(r-jn+1);
        end
        y = 1 - sum1;
end    

return

Contact us