Code covered by the BSD License  

Highlights from
Generation of Random Variates

image thumbnail

Generation of Random Variates


James Huntley (view profile)


generates random variates from over 870 univariate distributions

dbtrnorm_cdf(x, mu, sigma, A, B)
% dbtrnorm_cdf.m  computes a Doubly Truncated normal Cumulative Distribution.
%   See "Continuous Univariate Distributions", Johnson, Kotz and Balakrishnan,
%   Vol.1, J. Wiley, 1995, p.156.
%  Created by Jim Huntley,  10/13/08

function [cdf] = dbtrnorm_cdf(x, mu, sigma, A, B)

%persistent t1 denom

%if (isempty(t1))
    t1 = erf((A-mu) ./ (sigma * sqrt(2)));
    denom = erf((B-mu) ./ (sigma * sqrt(2)))- t1;

cdf = (erf((x-mu) ./ (sigma * sqrt(2)))- t1) ./ denom;


Contact us