This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Inverse error function





erfinv(x) returns the Inverse Error Function evaluated for each element of x. For inputs outside the interval [-1 1], erfinv returns NaN.


collapse all

ans = 0.2253

For inputs outside [-1,1], erfinv returns NaN. For -1 and 1, erfinv returns -Inf and Inf, respectively.

erfinv([-2 -1 1 2])
ans = 1×4

   NaN  -Inf   Inf   NaN

Find the inverse error function of the elements of a matrix.

M = [0 -0.5; 0.9 -0.2];
ans = 2×2

         0   -0.4769
    1.1631   -0.1791

Plot the inverse error function for -1 < x < 1.

x = -1:0.01:1;
y = erfinv(x);
grid on
title('Inverse Error Function for -1 < x < 1')

Generate Gaussian distributed random numbers using uniformly distributed random numbers. To convert a uniformly distributed random number x to a Gaussian distributed random number y, use the transform


Note that because x has the form -1 + 2*rand(1,10000), you can improve accuracy by using erfcinv instead of erfinv. For details, see Tips.

Generate 10,000 uniformly distributed random numbers on the interval [-1,1]. Transform them into Gaussian distributed random numbers. Show that the numbers follow the form of the Gaussian distribution using a histogram plot.

x = -1 + 2*rand(1,10000);
y = sqrt(2)*erfinv(x);
h = histogram(y);

Input Arguments

collapse all

Input, specified as a real number, or a vector, matrix, or multidimensional array of real numbers. x cannot be sparse.

Data Types: single | double

More About

collapse all

Inverse Error Function

The inverse error function erfinv is defined as the inverse of the error function, such that



  • For expressions of the form erfinv(1-x), use the complementary inverse error function erfcinv instead. This substitution maintains accuracy. When x is close to 1, then 1 - x is a small number and may be rounded down to 0. Instead, replace erfinv(1-x) with erfcinv(x).

Extended Capabilities

See Also

| | |

Introduced before R2006a