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

invgausmix_pdf(x, mu, sigma, p)
% invgausmix_pdf.m - evaluates an Inverse Gaussian Mixture Probability Density.
%   See "Continuous Univaiate Distributions", Vol.1, Johnson, Kotz, & Balakrishnan,
%   J. Wiley, 1995, p.286.
%
%       Vector form of PDF!!!
%
%  Created by Jim Huntley,  11/06/08
%

function [pdf] = invgausmix_pdf(x, mu, sigma, p)

%persistent coef sigma2 mu2 gam

%if(isempty(coef))
    sigma2 = sigma^2;
    mu2 = mu^2;
    gam = mu * (1-p) / p;
    coef = 1 / sqrt(2*pi*sigma2) / (gam+mu);
%end

argx = (x - mu).^2;
pdf = coef .* x.^(-1.5) .* (gam+x) .* exp(-0.5.*argx ./ (x.*mu2*sigma2));

end

Contact us