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

lineonorm_pdf(x, sigma)
% lineonorm_pdf.m - evaluates a Lineo-Normal Probability Density.
%   See "Continuous Univariate Distributions", v.1, Johnson, Kotz, & Balakrishnan, 
%   J. Wiley, 1995, p.172.
%
%   Vector Form of PDF !!!
%
%  Created by Jim Huntley,  7/12/07
%

function [pdf] = lineonorm_pdf(x, sigma)

%persistent coef

%if(isempty(coef))
    coef = sqrt(2/(pi*sigma^2));
%end

nt = 500;
dt = (1-eps) / (nt-1);
t = eps:dt:1;

for jx = 1:size(x,2)
    kern = sqrt(t) .* exp(-0.5.*x(jx)^2./(t.*sigma^2));
    pdf(jx) = coef * trapz(kern) * dt;
end
    
return

Contact us