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

tweedie_cdf(x,lambda,alpha,tau)
% tweedie_cdf.m - compute Tweedie Cumulative Distribution Function.
%   See " Regression Analysis of Quantity Data with Exact Zeros", G. K. Smyth,
%   Proc. 2nd Australia-Japan Workshop on Stochastic Models in Engineering, 
%   Technology and Management, 1996.
%
%   Vector form of CDF!!!
%
%  Created by Jim Huntley,  10/10/07
%
%   Calls:  'simps.m'

function [cdf] = tweedie_cdf(x,lambda,alpha,tau)

cdf(1:size(x,2)) = 0;
dx = x(2) - x(1);
cdf(1) = exp(-lambda);
pdf(1:size(x,2)) = tweedie_pdf(x,lambda,alpha,tau);

for jx = 2:size(x,2)
    if(jx < 4)
        cdf(jx) = cdf(1) + trapz(pdf(2:jx)) * dx;
    elseif(jx >= 4)
        cdf(jx) = cdf(1) + simps(pdf(2:jx)) * dx;
    end
end

return



Contact us