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

dbtrinvgaus_pdf(x, lambda, mu, x1, x2)
% dbtrinvgaus_pdf.m - tests a Doubly Truncated Inverse Gaussian Probability Density.
%   See "Continuous Univariate Distributions", Johnson, Kotz and Balakrishnan,
%   Vol.1, J. Wiley, 1995, p.277.
%
%  Created by Jim Huntley,  10/10/08
%

function [pdf] = dbtrinvgaus_pdf(x, lambda, mu, x1, x2)

%persistent u2 K

%if(isempty(K))
    u2 = mu^2;
    ny = 1000;
    ymin = x1;
    ymax = x2;
    dy = (ymax-ymin) / (ny-1);
    y = ymin:dy:ymax;
    kern = y.^(-1.5) .* exp(0.5.*lambda.*y./u2-0.5.*lambda./y);
    K = 1 / (simps(kern)*dy);
%end

pdf = K .* x.^(-1.5) .* exp(0.5.*lambda.*x./u2-0.5.*lambda./x);

return


Contact us