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

erf(x)
function y = erf(x)
%ERF Error function.
%   Y = ERF(X) is the error function for each element of X.  X must be
%   real. The error function is defined as:
%
%     erf(x) = 2/sqrt(pi) * integral from 0 to x of exp(-t^2) dt.
%
%   See also ERFC, ERFCX, ERFINV.

%   Ref: Abramowitz & Stegun, Handbook of Mathematical Functions, sec. 7.1.

%   Copyright 1984-2002 The MathWorks, Inc. 
%   $Revision: 5.13 $  $Date: 2002/04/09 00:29:47 $

% Derived from a FORTRAN program by W. J. Cody.
% See ERFCORE.

if ~isreal(x), error('X must be real.'); end
siz = size(x);
x = x(:);
y = erfcore(x,0);
y = reshape(y,siz);

Contact us