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

hotel_pdf(x, n, rho)
% hotel_pdf.m - evaluates a Hotelling r Probability Density.
%   See "Continuous Univariate Distributions", Johnson, Kotz, & Balakrishnan, 
%   J. Wiley, V. 2, p.549, 1995.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  3/15/07
%

function [pdf] = hotel_pdf(x, n, rho)

%persistent coef 

% Initializations.
%if(isempty(coef))
    coef = (n - 2) * (1 - rho^2)^(0.5*(n-1)) / (sqrt(2) * (n-1) * beta(0.5,n-0.5));
%end

for jx = 1:size(x,2)
    pdf(jx) = coef * (1 - x(jx)^2)^(0.5*(n-4)) * pfq([0.5 0.5],n-0.5,0.5*(1+rho*x(jx))) / ...
              (1 - rho.*x(jx))^(n-1.5);
end

return

Contact us