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

parnprod1_pdf(x, nn, k, a)
% test_parnprod1.m - tests a Pareto n-Product constant "k" Probability Density.
%   See "Continuous Univariate Distributions", Vol.1, Johnson, Kotz
%   and Balakrishnan, p.605, 1995.
%
%   Note: Multiple Errors in text - see "Modeling Income Distributions and 
%   Lorenz Curves", D. Chotikapanich, p.125, 2008.
%
%  Created by Jim Huntley,  04/06/09
%
%   Vector form of PDF!!!
%

function [pdf] = parnprod1_pdf(x, nn, k, a)

%persistent prodlhold

%if(isempty(prodlhold))
    for ji = 1:nn
        prodl = 1;
        for jl = 1:nn
            if(jl ~= ji)
                prodl = prodl * a(jl) / (a(jl)-a(ji));
            end  
        end
        prodlhold(ji) = prodl;
    end
%end

for jx = 1:size(x,2)
    sumi = 0;
    for ji = 1:nn
        arg = a(ji) * (x(jx)/k)^(-a(ji)-1) / k;
        sumi = sumi + arg * prodlhold(ji);
    end
    pdf(jx) = sumi;
end

return

Contact us