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

neg_cdf(x,lambda,gam)
% neg_cdf.m - compute Normal Exponential Gamma Cumulative Distribution Function.
%   See "Simultaneous Analysis of all SNPs in a Genome-Wide Association Study -
%   Supplementary material", C. J. Hoggart et al., 28 May, 2008,
%   http://ukpmc.ac.uk/ukpmc/ncbi/articles/PMC2464715/bin/pgen.1000130.s001.pdf
%
%   NOTE:  'lambda' must be >0 but cannot have values of 1/2, 1, 3/2, 2, 5/2, ...
%
%               Vector Form of CDF !!!
%
%  Created by:  Jim Huntley,  8/09/11.
%

function [cdf] = neg_cdf(x,lambda,gam)

pdf = neg_pdf(x,lambda,gam);
sx = size(x,2);
cdf(1:sx) = 0;
dx = x(2) - x(1);

for jx = 1:sx
    if(jx <= 2)
        cdf(jx) = trapz(pdf(1:jx)) * dx;
    elseif(jx > 2)
        cdf(jx) = simps(pdf(1:jx)) * dx;
    end
end

return

return



Contact us