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

geninvnorm_pdf(x, alpha, mu, tau)
% geninvnorm_pdf.m - evaluates a Generalized Invesre Normal Probability Density.
%   See "Monte Carlo Statistical Methods" By Christian P. Robert, George Casella, 
%   Springer, http//books.google.com/books?isbn=0387212396... 
%
%   Vector form of PDF!!!
%
%  Created by Jim Huntley,  10/21/08
%

function[pdf] = geninvnorm_pdf(x, alpha, mu, tau)

%persistent K mu2 tau2 alpham1 ohalpham1 exp1

%if(isempty(K))
    mu2 = mu^2;
    tau2 = tau^2;
    alpham1 = alpha - 1;
    ohalpham1= 0.5 * alpham1;
    exp1 = 0.5 * mu2 / tau2;
    K = exp(-alpham1*log(tau) + exp1 - ohalpham1*log(2) - gammaln(ohalpham1) - ...
        log(genHyper(ohalpham1,0.5,exp1)))
%end

pdf = K .* (abs(x)).^(-alpha) .* exp(-0.5 .* (1./x - mu).^2 ./tau2);

return



Contact us