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

invhypsin_pdf(x, mu, sigma, k, lambda)
% invhypsin_pdf.m - evaluatess an Inverse Hyperbolic Sine Probability Density.
%   See "Some Flexible Parametric Models for Partially Adaptive Estimators
%   of Econometric Models", C.B. Hansen et al., 11 Oct., 2005.
%
%   Vector form of PDF!!!
%
%  Created by Jim Huntley,  04/08/09
%

function [pdf] = invhypsin_pdf(x, mu, sigma, k, lambda)

%persistent sigmasq ksq theta delta

%if(isempty(ksq))
    sigmasq = sigma^2;
    ksq = k^2;
    odksq = 1 / ksq;
    sigmaw = 0.5 * sqrt(exp(2*lambda+odksq)+exp(-2*lambda+odksq)+2) * sqrt(exp(odksq-1));
    muw = 0.5 * (exp(lambda)-exp(-lambda)) * exp(0.5*odksq);
    theta = 1 ./ sigmaw;
    delta = muw .* theta;
%end

u = x - mu + delta*sigma;
arg = theta^2 +u.^2./sigmasq;
pdf = k.*exp(-(0.5.*ksq.*(log(u./sigma+sqrt(arg))-(lambda+log(theta))).^2)) ./ ...
      sqrt(2.*pi.*arg.*sigmasq);

return

Contact us