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

trap_pdf(x, a, b, c, d)
% trap_pdf.m - evaluates a Trapazoidal Probability Density.
%   See "Dataplot Reference Manual, TRAPDF", NIST, 2/3/04.
%
%  Created by Jim Huntley,  8/02/04
%

function [pdf] = trap_pdf(x, a, b, c, d)

u = 2/(d+c-b-a);
if(x < a)
    pdf = 0;
elseif(x >= a & x < b)
    pdf = u*((x-a)/(b-a));
elseif(x >= b & x < c);
    pdf = u;
elseif(x >= c & x < d)
    pdf = u*((d-x)/(d-c));
elseif(x >= d)
    pdf = 0;    
end

return

Contact us