erfinv

Inverse error function.

Category: Mathematics > Elementary Math

Syntax

X = erfinv(Y)

Returns the value X such that erf(X) == Y.

Description

erf is increasing and bounded between -1 and 1, so it can be inverted on that open interval. erfinv is the inverse, an odd function that grows without bound as Y approaches 1.

A common use is turning uniform random numbers into normal ones: if U is uniform in (0, 1), then sqrt(2)*erfinv(2*U-1) follows a standard normal distribution.

Input arguments

Y
Real array with values in the closed interval from -1 to 1.

Output arguments

X
Array of the same size as Y. The endpoints map to -Inf and Inf; values outside the interval give NaN.

Example

Inverting erf

erfinv([-0.5 0 0.5 1 2])
erf(erfinv(0.3))
Output
ans = 1×5

   -0.4769         0    0.4769       Inf       NaN
ans = 0.3000

See also

erf erfc erfcinv erfcx